Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
3.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: todcondition.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // TodCondition.cpp: implementation of the CTodCondition class.
  11. //
  12. //////////////////////////////////////////////////////////////////////
  13. #include "precompiled.h"
  14. #include "TodCondition.h"
  15. #include "timeofday.h"
  16. #include "iasdebug.h"
  17. #include "textmap.h"
  18. //////////////////////////////////////////////////////////////////////
  19. // Construction/Destruction
  20. //////////////////////////////////////////////////////////////////////
  21. CTodCondition::CTodCondition(IIASAttributeInfo* pCondAttr,
  22. ATL::CString& strConditionText
  23. )
  24. :CCondition(pCondAttr, strConditionText)
  25. {
  26. }
  27. CTodCondition::CTodCondition(IIASAttributeInfo* pCondAttr)
  28. :CCondition(pCondAttr)
  29. {
  30. }
  31. CTodCondition::~CTodCondition()
  32. {
  33. }
  34. HRESULT CTodCondition::Edit()
  35. {
  36. TRACE_FUNCTION("CTodCondition::Edit");
  37. //
  38. // time of day constraint
  39. //
  40. ATL::CString strTOD = m_strConditionText;
  41. HRESULT hr = S_OK;
  42. // get the new time of day constraint
  43. hr = ::GetTODConstaint(strTOD);
  44. DebugTrace(DEBUG_NAPMMC_TODCONDITION, "GetTodConstraint() returned %x",hr);
  45. m_strConditionText = strTOD;
  46. return hr;
  47. }
  48. //+---------------------------------------------------------------------------
  49. //
  50. // Function: CTodCondition::GetDisplayText
  51. //
  52. // Synopsis: Get the displayable text for this condition.
  53. // We just need to add the attribute name in front of the Hourmap string
  54. //
  55. // Arguments: None
  56. //
  57. // Returns: ATL::CString& - displayable text
  58. //
  59. // History: Created Header byao 2/22/98 11:38:41 PM
  60. //
  61. //+---------------------------------------------------------------------------
  62. ATL::CString CTodCondition::GetDisplayText()
  63. {
  64. TRACE_FUNCTION("CTodCondition::GetDisplayText");
  65. HRESULT hr;
  66. ::CString strLocalizedConditionText;
  67. // default implementation: as as condition text
  68. ATL::CString strDisplayText;
  69. CComBSTR bstrName;
  70. hr = m_spAttributeInfo->get_AttributeName( &bstrName );
  71. _ASSERTE( SUCCEEDED( hr ) );
  72. strDisplayText = bstrName;
  73. { ATL::CString matches;
  74. matches.LoadString(IDS_TEXT_MATCHES);
  75. strDisplayText += matches;
  76. }
  77. strDisplayText += _T("\"");
  78. if(NO_ERROR != LocalizeTimeOfDayConditionText(m_strConditionText, strLocalizedConditionText))
  79. strLocalizedConditionText = m_strConditionText;
  80. if(!strLocalizedConditionText.IsEmpty())
  81. strDisplayText += strLocalizedConditionText;
  82. strDisplayText += _T("\"");
  83. DebugTrace(DEBUG_NAPMMC_TODCONDITION, "GetDisplayText() returning %ws", (LPCTSTR)strDisplayText);
  84. return strDisplayText;
  85. }
  86. //+---------------------------------------------------------------------------
  87. //
  88. // Function: CTodCondition::GetConditionText
  89. //
  90. // Synopsis: Get the condition text for this condition.
  91. // We just need to add the TimeOfDay prefix to it
  92. //
  93. // Arguments: None
  94. //
  95. // Returns: WCHAR* - condition text
  96. //
  97. // History: Created Header byao 2/22/98 11:38:41 PM
  98. //
  99. //+---------------------------------------------------------------------------
  100. WCHAR* CTodCondition::GetConditionText()
  101. {
  102. TRACE_FUNCTION("CTodCondition::GetConditionText");
  103. WCHAR *pwzCondText;
  104. pwzCondText = new WCHAR[m_strConditionText.GetLength()+128];
  105. if (pwzCondText == NULL)
  106. {
  107. ShowErrorDialog(NULL, IDS_ERROR_SDO_ERROR_GET_CONDTEXT);
  108. return NULL;
  109. }
  110. // now form the condition text
  111. wcscpy(pwzCondText, TOD_PREFIX);
  112. wcscat(pwzCondText, _T("(\"") );
  113. wcscat(pwzCondText, (LPCTSTR)m_strConditionText);
  114. wcscat(pwzCondText, _T("\")") );
  115. DebugTrace(DEBUG_NAPMMC_TODCONDITION, "GetConditionText() returning %ws", (LPCTSTR)pwzCondText);
  116. return pwzCondText;
  117. }