Source code of Windows XP (NT5)
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.

397 lines
9.9 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. ilogcat.cpp
  5. Abstract:
  6. Internal implementation for a logging category item.
  7. Environment:
  8. WIN32 User Mode
  9. Author:
  10. Darwin Ouyang (t-darouy) 30-Sept-1997
  11. --*/
  12. #include "StdAfx.h"
  13. #include "inode.h" // base class
  14. #include "ilogcat.h" // log category item
  15. #include "ilogging.h" // logging folder
  16. #include "faxcomp.h" // CFaxComponent
  17. #include "faxdataobj.h" // dataobject
  18. #include "faxstrt.h" // string table
  19. #pragma hdrstop
  20. #define PRI_CONTEXT_MENU 10;
  21. extern CStringTable * GlobalStringTable;
  22. // Generated with uuidgen. Each node must have a GUID associated with it.
  23. // This one is for the main root node.
  24. const GUID GUID_LogCatNode = /* 208dd5bc-44e2-11d1-9076-00a0c90ab504 */
  25. {
  26. 0x208dd5bc,
  27. 0x44e2,
  28. 0x11d1,
  29. {0x90, 0x76, 0x00, 0xa0, 0xc9, 0x0a, 0xb5, 0x04}
  30. };
  31. ////////////////////////////////////////////////////////////////////////////////////////////////////
  32. ////////////////////////////////////////////////////////////////////////////////////////////////////
  33. ////////////////////////////////////////////////////////////////////////////////////////////////////
  34. ////////////////////////////////////////////////////////////////////////////////////////////////////
  35. //
  36. //
  37. // Constructor and destructor.
  38. //
  39. //
  40. CInternalLogCat::CInternalLogCat( CInternalNode * pParent, CFaxComponentData * pCompData ) :
  41. CInternalNode( pParent, pCompData )
  42. /*++
  43. Routine Description:
  44. Constructor.
  45. Arguments:
  46. None.
  47. Return Value:
  48. None.
  49. --*/
  50. {
  51. pCategory = NULL;
  52. }
  53. CInternalLogCat::~CInternalLogCat()
  54. /*++
  55. Routine Description:
  56. Destructor.
  57. Arguments:
  58. None.
  59. Return Value:
  60. None.
  61. --*/
  62. {
  63. }
  64. ////////////////////////////////////////////////////////////////////////////////////////////////////
  65. ////////////////////////////////////////////////////////////////////////////////////////////////////
  66. ////////////////////////////////////////////////////////////////////////////////////////////////////
  67. ////////////////////////////////////////////////////////////////////////////////////////////////////
  68. //
  69. //
  70. // Mandatory CInternalNode implementations.
  71. //
  72. //
  73. const GUID *
  74. CInternalLogCat::GetNodeGUID()
  75. /*++
  76. Routine Description:
  77. Returns the node's associated GUID.
  78. Arguments:
  79. None.
  80. Return Value:
  81. A const pointer to a binary GUID.
  82. --*/
  83. {
  84. // DebugPrint(( TEXT("Trace: CInternalLogCat::GetNodeGUID") ));
  85. return &GUID_LogCatNode;
  86. }
  87. const LPTSTR
  88. CInternalLogCat::GetNodeDisplayName()
  89. /*++
  90. Routine Description:
  91. Returns a const TSTR pointer to the node's display name.
  92. Arguments:
  93. None.
  94. Return Value:
  95. A const pointer to a TSTR.
  96. --*/
  97. {
  98. // DebugPrint(( TEXT("Trace: CInternalLogCat::GetNodeDisplayName") ));
  99. return (LPTSTR)pCategory->Name;
  100. }
  101. const LONG_PTR
  102. CInternalLogCat::GetCookie()
  103. /*++
  104. Routine Description:
  105. Returns the cookie for this node.
  106. Arguments:
  107. None.
  108. Return Value:
  109. A const long containing the cookie for the pointer,
  110. in this case, a NULL, since the root node has no cookie.
  111. --*/
  112. {
  113. // DebugPrint(( TEXT("Trace: CInternalLogCat::GetCookie") ));
  114. DebugPrint(( TEXT("Log Category Node Cookie: 0x%p"), this ));
  115. return (LONG_PTR)this; // status node's cookie is the node id.
  116. }
  117. ////////////////////////////////////////////////////////////////////////////////////////////////////
  118. ////////////////////////////////////////////////////////////////////////////////////////////////////
  119. ////////////////////////////////////////////////////////////////////////////////////////////////////
  120. ////////////////////////////////////////////////////////////////////////////////////////////////////
  121. //
  122. //
  123. // IComponent over-rides
  124. //
  125. //
  126. HRESULT
  127. STDMETHODCALLTYPE
  128. CInternalLogCat::ResultGetDisplayInfo(
  129. IN CFaxComponent * pComp,
  130. IN OUT RESULTDATAITEM __RPC_FAR *pResultDataItem)
  131. /*++
  132. Routine Description:
  133. This routine dispatches result pane GetDisplayInfo requests to the appropriate handlers
  134. in the mandatory implementations of the node, as well as handling special case data requests.
  135. Arguments:
  136. pComp - a pointer to the IComponent associated with this node.
  137. pResultDataItem - a pointer to the RESULTDATAITEM struct which needs to be filled in.
  138. Return Value:
  139. HRESULT indicating SUCCEEDED() or FAILED()
  140. --*/
  141. {
  142. // DebugPrint(( TEXT("Trace: CInternalLogCat::ResultGetDisplayInfo") ));
  143. assert(pResultDataItem != NULL);
  144. if( pResultDataItem->mask & RDI_STR ) {
  145. if( pResultDataItem->nCol == 0 ) {
  146. pResultDataItem->str = GetNodeDisplayName();
  147. }
  148. if( pResultDataItem->nCol == 1) {
  149. pResultDataItem->str = ::GlobalStringTable->GetString( IDS_LOG_LEVEL_NONE + pCategory->Level );
  150. }
  151. }
  152. if( pResultDataItem->mask & RDI_IMAGE ) {
  153. pResultDataItem->nImage = GetNodeDisplayImage();
  154. }
  155. return S_OK;
  156. }
  157. ////////////////////////////////////////////////////////////////////////////////////////////////////
  158. ////////////////////////////////////////////////////////////////////////////////////////////////////
  159. ////////////////////////////////////////////////////////////////////////////////////////////////////
  160. ////////////////////////////////////////////////////////////////////////////////////////////////////
  161. //
  162. //
  163. // IExtendContextMenu event handlers - default implementations
  164. //
  165. //
  166. HRESULT
  167. STDMETHODCALLTYPE
  168. CInternalLogCat::ComponentContextMenuAddMenuItems(
  169. IN CFaxComponent * pComp,
  170. IN CFaxDataObject * piDataObject,
  171. IN LPCONTEXTMENUCALLBACK piCallback,
  172. IN OUT long __RPC_FAR *pInsertionAllowed)
  173. /*++
  174. Routine Description:
  175. Adds items to the context menu.
  176. Arguments:
  177. pComp - a pointer to the IComponent associated with this node.
  178. piDataObject - pointer to the dataobject associated with this node
  179. piCallback - a pointer to the IContextMenuCallback used to insert pages
  180. pInsertionAllowed - a set of flag indicating whether insertion is allowed.
  181. Return Value:
  182. HRESULT indicating SUCCEEDED() or FAILED()
  183. --*/
  184. {
  185. CONTEXTMENUITEM menuItem;
  186. WORD menuID;
  187. HRESULT hr = S_OK;
  188. if( !( *pInsertionAllowed | CCM_INSERTIONALLOWED_TOP ) ) {
  189. assert( FALSE );
  190. return S_OK;
  191. }
  192. // build the submenu
  193. ZeroMemory( (void*)&menuItem, sizeof( menuItem ));
  194. menuItem.strName = ::GlobalStringTable->GetString( IDS_LOG_LEVEL );
  195. menuItem.strStatusBarText = ::GlobalStringTable->GetString( IDS_LOG_LEVEL_DESC );
  196. menuItem.lCommandID = PRI_CONTEXT_MENU;
  197. menuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;
  198. menuItem.fFlags = MF_POPUP | MF_ENABLED;
  199. menuItem.fSpecialFlags = CCM_SPECIAL_SUBMENU;
  200. hr = piCallback->AddItem( &menuItem );
  201. if( FAILED(hr) ) {
  202. return hr;
  203. }
  204. // build the submenu
  205. for( menuID = 0; menuID < 4; menuID++ ) {
  206. ZeroMemory( ( void* )&menuItem, sizeof( menuItem ) );
  207. menuItem.strName = ::GlobalStringTable->GetString( IDS_LOG_LEVEL_NONE + menuID );
  208. menuItem.strStatusBarText = ::GlobalStringTable->GetString( IDS_LOG_LEVEL_NONE_DESC + menuID );
  209. menuItem.lCommandID = menuID;
  210. menuItem.lInsertionPointID = PRI_CONTEXT_MENU;
  211. if( menuID == pCategory->Level ) {
  212. menuItem.fFlags = MF_ENABLED | MF_CHECKED;
  213. } else {
  214. menuItem.fFlags = MF_ENABLED;
  215. }
  216. menuItem.fSpecialFlags = 0;
  217. hr = piCallback->AddItem( &menuItem );
  218. if( FAILED(hr) ) {
  219. return hr;
  220. }
  221. }
  222. return hr;
  223. }
  224. HRESULT
  225. STDMETHODCALLTYPE
  226. CInternalLogCat::ComponentContextMenuCommand(
  227. IN CFaxComponent * pComp,
  228. IN long lCommandID,
  229. IN CFaxDataObject * piDataObject)
  230. /*++
  231. Routine Description:
  232. Handles context menu commands.
  233. Arguments:
  234. pComp - a pointer to the IComponent associated with this node.
  235. lCommandID - the command ID
  236. piDataObject - pointer to the dataobject associated with this node
  237. Return Value:
  238. HRESULT indicating SUCCEEDED() or FAILED()
  239. --*/
  240. {
  241. HRESULT hr;
  242. if( lCommandID >= 0 || lCommandID < 4 ) {
  243. pCategory->Level = lCommandID;
  244. assert( m_pParentINode );
  245. hr = ((CInternalLogging *)m_pParentINode)->CommitChanges( pComp );
  246. if( SUCCEEDED( hr ) ) {
  247. pComp->m_pResultData->UpdateItem( hItemID );
  248. }
  249. }
  250. // if we return a failure here, the MMC will assert on us!!
  251. // so we return only S_OK.
  252. return S_OK;
  253. }
  254. ////////////////////////////////////////////////////////////////////////////////////////////////////
  255. ////////////////////////////////////////////////////////////////////////////////////////////////////
  256. ////////////////////////////////////////////////////////////////////////////////////////////////////
  257. ////////////////////////////////////////////////////////////////////////////////////////////////////
  258. //
  259. //
  260. // Internal Event Handlers
  261. //
  262. //
  263. HRESULT
  264. CInternalLogCat::ResultOnSelect(
  265. IN CFaxComponent* pComp,
  266. IN CFaxDataObject * lpDataObject,
  267. IN LPARAM arg, LPARAM param)
  268. /*++
  269. Routine Description:
  270. Event handler for the MMCN_SELECT message for the log category node.
  271. Arguments:
  272. pCompData - a pointer to the instance of IComponentData which this root node is associated with.
  273. pdo - a pointer to the data object associated with this node
  274. arg, param - the arguements of the message
  275. Return Value:
  276. HRESULT which indicates SUCCEEDED() or FAILED()
  277. --*/
  278. {
  279. DebugPrint(( TEXT("Trace: CInternalRoot::OnSelect") ));
  280. pComp->m_pConsoleVerb->SetDefaultVerb( MMC_VERB_NONE );
  281. return S_OK;
  282. }