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.

258 lines
6.8 KiB

  1. #include "stdafx.h"
  2. #include <iadmw.h>
  3. #include <inetcom.h>
  4. #include <logtype.h>
  5. #include <ilogobj.hxx>
  6. #include "wrapmb.h"
  7. #include "logui.h"
  8. #include "uiextnd.h"
  9. #include "LogGenPg.h"
  10. #include "LogExtPg.h"
  11. #include "LogAdvPg.h"
  12. #include "logtools.h"
  13. #include <inetprop.h>
  14. #define OLE_NAME _T("Extended_Logging_UI")
  15. static const DWORD BASED_CODE _dwOleMisc =
  16. OLEMISC_INSIDEOUT |
  17. OLEMISC_CANTLINKINSIDE;
  18. extern HINSTANCE g_hInstance;
  19. //====================== the required methods
  20. //---------------------------------------------------------------
  21. CFacExtndLogUI::CFacExtndLogUI() :
  22. COleObjectFactory( CLSID_EXTLOGUI, RUNTIME_CLASS(CExtndCreator), TRUE, OLE_NAME )
  23. {
  24. }
  25. //---------------------------------------------------------------
  26. static const LPCTSTR rglpszServerRegister[] =
  27. {
  28. _T("%2\\CLSID\0") _T("%1"),
  29. _T("%2\\NotInsertable\0") _T(""),
  30. _T("%2\\protocol\\StdFileEditing\\verb\\0\0") _T("&Edit"),
  31. _T("CLSID\\%1\0") _T("%5"),
  32. _T("CLSID\\%1\\Verb\\0\0") _T("&Edit,0,2"),
  33. _T("CLSID\\%1\\NotInsertable\0") _T(""),
  34. _T("CLSID\\%1\\AuxUserType\\2\0") _T("%4"),
  35. _T("CLSID\\%1\\AuxUserType\\3\0") _T("%6"),
  36. _T("CLSID\\%1\\MiscStatus\0") _T("32"),
  37. NULL
  38. };
  39. static const LPCTSTR rglpszServerOverwriteDLL[] =
  40. {
  41. _T("%2\\CLSID\0") _T("%1"),
  42. _T("%2\\protocol\\StdFileEditing\\server\0") _T("%3"),
  43. _T("CLSID\\%1\\ProgID\0") _T("%2"),
  44. _T("CLSID\\%1\\InProcServer32\0") _T("%3"),
  45. _T("CLSID\\%1\\DefaultIcon\0") _T("%3,%7"),
  46. NULL
  47. };
  48. BOOL CFacExtndLogUI::UpdateRegistry( BOOL bRegister )
  49. {
  50. if (bRegister)
  51. /*
  52. return AfxOleRegisterControlClass(
  53. AfxGetInstanceHandle(),
  54. CLSID_EXTLOGUI,
  55. OLE_NAME,
  56. 0,
  57. 0,
  58. afxRegApartmentThreading,
  59. _dwOleMisc,
  60. _tlid,
  61. _wVerMajor,
  62. _wVerMinor);
  63. */
  64. if (AfxOleRegisterServerClass(
  65. CLSID_EXTLOGUI,
  66. OLE_NAME,
  67. _T("LogUI extnd"),
  68. _T("LogUI extnd"),
  69. OAT_SERVER,
  70. (LPCTSTR *)rglpszServerRegister,
  71. (LPCTSTR *)rglpszServerOverwriteDLL
  72. )
  73. )
  74. {
  75. return FSetObjectApartmentModel( CLSID_EXTLOGUI );
  76. }
  77. else
  78. return AfxOleUnregisterClass(m_clsid, OLE_NAME);
  79. return FALSE;
  80. }
  81. //---------------------------------------------------------------
  82. IMPLEMENT_DYNCREATE(CExtndCreator, CCmdTarget)
  83. LPUNKNOWN CExtndCreator::GetInterfaceHook(const void* piid)
  84. {
  85. return new CImpExtndLogUI;
  86. }
  87. //====================== the action
  88. //---------------------------------------------------------------
  89. CImpExtndLogUI::CImpExtndLogUI():
  90. m_dwRefCount(0)
  91. {
  92. // guid = IID_LOGGINGUI;
  93. AfxOleLockApp();
  94. }
  95. //---------------------------------------------------------------
  96. CImpExtndLogUI::~CImpExtndLogUI()
  97. {
  98. AfxOleUnlockApp();
  99. }
  100. //---------------------------------------------------------------
  101. HRESULT CImpExtndLogUI::OnProperties( IN OLECHAR* pocMachineName, IN OLECHAR* pocMetabasePath )
  102. {
  103. AFX_MANAGE_STATE(_afxModuleAddrThis);
  104. // prepare the metabase wrapper
  105. IMSAdminBase* pMB = FInitMetabaseWrapper( pocMachineName );
  106. if ( !pMB )
  107. return 0xFFFFFFFF;
  108. // specify the resources to use
  109. HINSTANCE hOldRes = AfxGetResourceHandle();
  110. AfxSetResourceHandle( g_hInstance );
  111. // prepare the help
  112. ((CLoguiApp*)AfxGetApp())->PrepHelp( pocMetabasePath );
  113. // Things could (potentially maybe) throw here, so better protect it.
  114. try
  115. {
  116. // declare the property sheet
  117. CPropertySheet propsheet( IDS_SHEET_EXTND_TITLE );
  118. // declare the property pages
  119. CLogGeneral pageLogGeneral;
  120. CLogAdvanced pageLogAdvanced;
  121. CLogExtended pageLogExtended;
  122. // prepare the common pages
  123. pageLogGeneral.m_pMB = pMB;
  124. pageLogGeneral.m_szMeta = pocMetabasePath;
  125. pageLogGeneral.m_szServer = pocMachineName;
  126. pageLogGeneral.szPrefix.LoadString( IDS_LOG_EXTND_PREFIX );
  127. pageLogGeneral.szSizePrefix.LoadString( IDS_LOG_SIZE_EXTND_PREFIX );
  128. // make the use local time checkbox visible
  129. pageLogGeneral.m_fShowLocalTimeCheckBox = TRUE;
  130. // set the local flag
  131. pageLogGeneral.m_fLocalMachine = FIsLocalMachine( pocMachineName );
  132. // add the pages to the sheet and run
  133. propsheet.AddPage( &pageLogGeneral );
  134. // turn on help
  135. propsheet.m_psh.dwFlags |= PSH_HASHELP;
  136. pageLogGeneral.m_psp.dwFlags |= PSP_HASHELP;
  137. //
  138. // Extract the service name from the metabase path
  139. //
  140. // For /LM/W3SVC/1 scenario
  141. CString m_szServiceName(pocMetabasePath+3);
  142. m_szServiceName = m_szServiceName.Left( m_szServiceName.ReverseFind('/'));
  143. // For /LM/W3SVC scenario
  144. if (m_szServiceName.IsEmpty())
  145. {
  146. m_szServiceName = pocMetabasePath+3;
  147. }
  148. CServerCapabilities serverCap(pocMachineName, m_szServiceName);
  149. if ( SUCCEEDED(serverCap.LoadData()) && (serverCap.QueryMajorVersion() > 4))
  150. {
  151. pageLogAdvanced.m_pMB = pMB;
  152. pageLogAdvanced.m_szMeta = pocMetabasePath;
  153. pageLogAdvanced.m_szServer = pocMachineName;
  154. pageLogAdvanced.m_szServiceName = m_szServiceName;
  155. // add the pages to the sheet and run
  156. propsheet.AddPage( &pageLogAdvanced );
  157. // turn on help
  158. pageLogAdvanced.m_psp.dwFlags |= PSP_HASHELP;
  159. }
  160. else
  161. {
  162. pageLogExtended.m_pMB = pMB;
  163. pageLogExtended.m_szMeta = pocMetabasePath;
  164. pageLogExtended.m_szServer = pocMachineName;
  165. // add the pages to the sheet and run
  166. propsheet.AddPage( &pageLogExtended );
  167. // turn on help
  168. pageLogExtended.m_psp.dwFlags |= PSP_HASHELP;
  169. }
  170. propsheet.DoModal();
  171. }
  172. catch ( CException e )
  173. {
  174. }
  175. // close the metabase wrappings
  176. FCloseMetabaseWrapper(pMB);
  177. // restore the resources
  178. AfxSetResourceHandle( hOldRes );
  179. return NO_ERROR;
  180. }
  181. //====================== the required methods
  182. //---------------------------------------------------------------
  183. HRESULT CImpExtndLogUI::QueryInterface(REFIID riid, void **ppObject)
  184. {
  185. if (riid==IID_IUnknown || riid==IID_LOGGINGUI || riid==CLSID_EXTLOGUI)
  186. {
  187. *ppObject = (ILogUIPlugin*) this;
  188. }
  189. else
  190. {
  191. return E_NOINTERFACE;
  192. }
  193. AddRef();
  194. return NO_ERROR;
  195. }
  196. //---------------------------------------------------------------
  197. ULONG CImpExtndLogUI::AddRef()
  198. {
  199. DWORD dwRefCount;
  200. dwRefCount = InterlockedIncrement((long *)&m_dwRefCount);
  201. return dwRefCount;
  202. }
  203. //---------------------------------------------------------------
  204. ULONG CImpExtndLogUI::Release()
  205. {
  206. DWORD dwRefCount;
  207. dwRefCount = InterlockedDecrement((long *)&m_dwRefCount);
  208. if (dwRefCount == 0) {
  209. delete this;
  210. }
  211. return dwRefCount;
  212. }