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.

155 lines
3.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: C O N T R A Y S . C P P
  7. //
  8. // Contents: Implementation of the CConnectionTrayStats object.
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 11 Dec 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "foldinc.h" // Standard shell\tray includes
  18. #include "ctrayui.h"
  19. #include "traymsgs.h"
  20. #include "trayres.h"
  21. #include <confold.h>
  22. #include <smutil.h>
  23. extern HWND g_hwndTray;
  24. CConnectionTrayStats::CConnectionTrayStats() throw()
  25. {
  26. m_dwConPointCookie = 0;
  27. m_uiIcon = 0;
  28. m_fStaticIcon = FALSE;
  29. m_ccfe.clear();
  30. }
  31. CConnectionTrayStats::~CConnectionTrayStats() throw()
  32. {
  33. // $REVIEW(tongl 9/4/98): release the duplicate pccfe we created
  34. // when adding the icon
  35. m_ccfe.clear();
  36. }
  37. //+---------------------------------------------------------------------------
  38. //
  39. // Member: CConnectionFolderEnum::CreateInstance
  40. //
  41. // Purpose: Create an instance of the CConnectionFolderEnum object, and
  42. // returns the requested interface
  43. //
  44. // Arguments:
  45. // riid [in] Interface requested
  46. // ppv [out] Pointer to receive the requested interface
  47. //
  48. // Returns: Standard OLE HRESULT
  49. //
  50. // Author: jeffspr 5 Nov 1997
  51. //
  52. // Notes:
  53. //
  54. HRESULT CConnectionTrayStats::CreateInstance(
  55. IN const CONFOLDENTRY& ccfe,
  56. IN UINT uiIcon,
  57. IN BOOL fStaticIcon,
  58. IN REFIID riid,
  59. OUT VOID** ppv)
  60. {
  61. Assert(!ccfe.empty());
  62. Assert(!ccfe.GetWizard());
  63. HRESULT hr = E_OUTOFMEMORY;
  64. CConnectionTrayStats * pObj = NULL;
  65. pObj = new CComObject <CConnectionTrayStats>;
  66. if (pObj)
  67. {
  68. Assert(!ccfe.GetWizard());
  69. Assert(uiIcon != BOGUS_TRAY_ICON_ID);
  70. hr = pObj->m_ccfe.HrDupFolderEntry(ccfe);
  71. if (SUCCEEDED(hr))
  72. {
  73. pObj->m_uiIcon = uiIcon;
  74. pObj->m_fStaticIcon = fStaticIcon;
  75. // Do the standard CComCreator::CreateInstance stuff.
  76. //
  77. pObj->SetVoid (NULL);
  78. pObj->InternalFinalConstructAddRef ();
  79. hr = pObj->FinalConstruct ();
  80. pObj->InternalFinalConstructRelease ();
  81. if (SUCCEEDED(hr))
  82. {
  83. hr = pObj->QueryInterface (riid, ppv);
  84. }
  85. }
  86. if (FAILED(hr))
  87. {
  88. delete pObj;
  89. }
  90. }
  91. TraceHr(ttidError, FAL, hr, FALSE, "CConnectionTrayStats::CreateInstance");
  92. return hr;
  93. }
  94. //+---------------------------------------------------------------------------
  95. //
  96. // Member: CConnectionTrayStats::OnStatisticsChanged
  97. //
  98. // Purpose: Callback from the stats engine that tells us when data
  99. // has actually changed
  100. //
  101. // Arguments:
  102. // dwCookie [in] Our interface cookie
  103. // dwChangeFlags [in] Undefined, as of yet
  104. //
  105. // Returns:
  106. //
  107. // Author: jeffspr 12 Dec 1997
  108. //
  109. // Notes:
  110. //
  111. HRESULT CConnectionTrayStats::OnStatisticsChanged(
  112. IN DWORD dwChangeFlags)
  113. {
  114. HRESULT hr = S_OK;
  115. // Updage the icon.
  116. //
  117. if (g_pCTrayUI)
  118. {
  119. if (!m_fStaticIcon)
  120. {
  121. INT iIconResourceId;
  122. iIconResourceId = IGetCurrentConnectionTrayIconId(
  123. m_ccfe.GetNetConMediaType(), m_ccfe.GetNetConStatus(), dwChangeFlags);
  124. PostMessage(g_hwndTray, MYWM_UPDATETRAYICON,
  125. (WPARAM) m_uiIcon, (LPARAM) iIconResourceId);
  126. }
  127. }
  128. TraceHr(ttidError, FAL, hr, FALSE, "CConnectionTrayStats::OnStatisticsChanged", hr);
  129. return hr;
  130. }