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.

229 lines
6.1 KiB

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