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.

210 lines
7.3 KiB

  1. /*****************************************************************************
  2. * (C) COPYRIGHT MICROSOFT CORPORATION, 2002
  3. *
  4. * AUTHOR: ByronC
  5. *
  6. * DATE: 4/10/2002
  7. *
  8. * @doc INTERNAL
  9. *
  10. * @module EventHandlerInfo.cpp - Declaration for <c EventHandlerInfo> |
  11. *
  12. * This file contains the implementation of the <c EventHandlerInfo> class.
  13. *
  14. *****************************************************************************/
  15. #include "precomp.h"
  16. /*****************************************************************************
  17. * @doc INTERNAL
  18. *
  19. * @mfunc | EventHandlerInfo | EventHandlerInfo |
  20. *
  21. * We initialize all member variables. In general, this sets the values to 0,
  22. * except:
  23. * <nl><md EventHandlerInfo::m_ulSig> is set to be EventHandlerInfo_INIT_SIG.
  24. * <nl><md EventHandlerInfo::m_cRef> is set to be 1.
  25. *
  26. *****************************************************************************/
  27. EventHandlerInfo::EventHandlerInfo(
  28. const CSimpleStringWide &cswName,
  29. const CSimpleStringWide &cswDescription,
  30. const CSimpleStringWide &cswIcon,
  31. const CSimpleStringWide &cswCommandline,
  32. const GUID &guidCLSID
  33. ) :
  34. m_ulSig(EventHandlerInfo_INIT_SIG),
  35. m_cRef(1),
  36. m_cswName(cswName),
  37. m_cswDescription(cswDescription),
  38. m_cswIcon(cswIcon),
  39. m_cswCommandline(cswCommandline),
  40. m_guidCLSID(guidCLSID)
  41. {
  42. }
  43. /*****************************************************************************
  44. * @doc INTERNAL
  45. *
  46. * @mfunc | EventHandlerInfo | ~EventHandlerInfo |
  47. *
  48. * Do any cleanup that is not already done.
  49. *
  50. * Also:
  51. * <nl><md EventHandlerInfo::m_ulSig> is set to be EventHandlerInfo_DEL_SIG.
  52. *
  53. *****************************************************************************/
  54. EventHandlerInfo::~EventHandlerInfo()
  55. {
  56. m_ulSig = EventHandlerInfo_DEL_SIG;
  57. m_cRef = 0;
  58. }
  59. /*****************************************************************************
  60. * @doc INTERNAL
  61. *
  62. * @mfunc ULONG | EventHandlerInfo | AddRef |
  63. *
  64. * Increments this object's ref count. We should always AddRef when handing
  65. * out a pointer to this object.
  66. *
  67. * @rvalue Count |
  68. * The reference count after the count has been incremented.
  69. *****************************************************************************/
  70. ULONG __stdcall EventHandlerInfo::AddRef()
  71. {
  72. InterlockedIncrement((long*) &m_cRef);
  73. return m_cRef;
  74. }
  75. /*****************************************************************************
  76. * @doc INTERNAL
  77. *
  78. * @mfunc ULONG | EventHandlerInfo | Release |
  79. *
  80. * Decrement this object's ref count. We should always Release when finished
  81. * with a pointer to this object.
  82. *
  83. * @rvalue Count |
  84. * The reference count after the count has been decremented.
  85. *****************************************************************************/
  86. ULONG __stdcall EventHandlerInfo::Release()
  87. {
  88. ULONG ulRefCount = m_cRef - 1;
  89. if (InterlockedDecrement((long*) &m_cRef) == 0)
  90. {
  91. delete this;
  92. return 0;
  93. }
  94. return ulRefCount;
  95. }
  96. /*****************************************************************************
  97. * @doc INTERNAL
  98. *
  99. * @mfunc CSimpleStringWide | EventHandlerInfo | getName |
  100. *
  101. * Accessor method for the friendly Name for this handler
  102. * It's usage is something like:
  103. * <nl>CSimpleStringWide cswTemp = pEventHandlerInfo->getName();
  104. *
  105. * @rvalue CSimpleStringWide |
  106. * The handler name. Notice that the return is a copy by value
  107. * of the <md EventHandlerInfo::m_cswName> member.
  108. *****************************************************************************/
  109. CSimpleStringWide EventHandlerInfo::getName()
  110. {
  111. return m_cswName;
  112. }
  113. /*****************************************************************************
  114. * @doc INTERNAL
  115. *
  116. * @mfunc CSimpleStringWide | EventHandlerInfo | getDescription |
  117. *
  118. * Accessor method for the description for this handler
  119. * It's usage is something like:
  120. * <nl>CSimpleStringWide cswTemp = pEventHandlerInfo->getDescription();
  121. *
  122. * @rvalue CSimpleStringWide |
  123. * The handler name. Notice that the return is a copy by value
  124. * of the <md EventHandlerInfo::m_cswDescription> member.
  125. *****************************************************************************/
  126. CSimpleStringWide EventHandlerInfo::getDescription()
  127. {
  128. return m_cswDescription;
  129. }
  130. /*****************************************************************************
  131. * @doc INTERNAL
  132. *
  133. * @mfunc CSimpleStringWide | EventHandlerInfo | getIconPath |
  134. *
  135. * Accessor method for the icon path for this handler
  136. * It's usage is something like:
  137. * <nl>CSimpleStringWide cswTemp = pEventHandlerInfo->getIconPath();
  138. *
  139. * @rvalue CSimpleStringWide |
  140. * The handler name. Notice that the return is a copy by value
  141. * of the <md EventHandlerInfo::m_cswIcon> member.
  142. *****************************************************************************/
  143. CSimpleStringWide EventHandlerInfo::getIconPath()
  144. {
  145. return m_cswIcon;
  146. }
  147. /*****************************************************************************
  148. * @doc INTERNAL
  149. *
  150. * @mfunc CSimpleStringWide | EventHandlerInfo | getCommandline |
  151. *
  152. * Accessor method for the commandline for this handler. The commandline
  153. * will be the empty string for COM registered apps.
  154. * It's usage is something like:
  155. * <nl>CSimpleStringWide cswTemp = pEventHandlerInfo->getCommandline();
  156. *
  157. * @rvalue CSimpleStringWide |
  158. * The handler name. Notice that the return is a copy by value
  159. * of the <md EventHandlerInfo::m_cswCommandline> member.
  160. *****************************************************************************/
  161. CSimpleStringWide EventHandlerInfo::getCommandline()
  162. {
  163. return m_cswCommandline;
  164. }
  165. /*****************************************************************************
  166. * @doc INTERNAL
  167. *
  168. * @mfunc CSimpleStringWide | EventHandlerInfo | getCLSID |
  169. *
  170. * Accessor method for the CLSID for this handler.
  171. *
  172. * @rvalue GUID |
  173. * The handler name. Notice that the return is a copy by value
  174. * of the <md EventHandlerInfo::m_guidCLSID> member.
  175. *****************************************************************************/
  176. GUID EventHandlerInfo::getCLSID()
  177. {
  178. return m_guidCLSID;
  179. }
  180. /*****************************************************************************
  181. * @doc INTERNAL
  182. *
  183. * @mfunc CSimpleStringWide | EventHandlerInfo | getEventGuid |
  184. *
  185. * For debugging: this method dumps the internal fields of this object.
  186. *
  187. *****************************************************************************/
  188. VOID EventHandlerInfo::Dump()
  189. {
  190. WCHAR wszGuidString[50] = {0};
  191. DBG_TRC(("EventHandlerInfo for (%p)", this));
  192. DBG_TRC((" Name: [%ws]", m_cswName.String()));
  193. DBG_TRC((" Description: [%ws]", m_cswDescription.String()));
  194. DBG_TRC((" Icon: [%ws]", m_cswIcon.String()));
  195. DBG_TRC((" Commandline: [%ws]", m_cswCommandline.String()));
  196. StringFromGUID2(m_guidCLSID, wszGuidString, sizeof(wszGuidString)/sizeof(wszGuidString[0]));
  197. DBG_TRC((" CLSID: [%ws]", wszGuidString));
  198. DBG_TRC((" "));
  199. }