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.

168 lines
4.0 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 "uincsa.h"
  8. #include "LogGenPg.h"
  9. #include "logtools.h"
  10. #define OLE_NAME _T("NCSA_Logging_UI")
  11. static const DWORD BASED_CODE _dwOleMisc = OLEMISC_INSIDEOUT | OLEMISC_CANTLINKINSIDE;
  12. extern HINSTANCE g_hInstance;
  13. CFacNcsaLogUI::CFacNcsaLogUI() :
  14. COleObjectFactory(CLSID_NCSALOGUI, RUNTIME_CLASS(CNcsaCreator), TRUE, OLE_NAME)
  15. {
  16. }
  17. //---------------------------------------------------------------
  18. static const LPCTSTR rglpszServerRegister[] =
  19. {
  20. _T("%2\\CLSID\0") _T("%1"),
  21. _T("%2\\NotInsertable\0") _T(""),
  22. _T("CLSID\\%1\0") _T("%5"),
  23. _T("CLSID\\%1\\Verb\\0\0") _T("&Edit,0,2"),
  24. _T("CLSID\\%1\\NotInsertable\0") _T(""),
  25. _T("CLSID\\%1\\AuxUserType\\2\0") _T("%4"),
  26. _T("CLSID\\%1\\AuxUserType\\3\0") _T("%6"),
  27. _T("CLSID\\%1\\MiscStatus\0") _T("32"),
  28. NULL,
  29. };
  30. static const LPCTSTR rglpszServerOverwriteDLL[] =
  31. {
  32. _T("%2\\CLSID\0") _T("%1"),
  33. _T("CLSID\\%1\\ProgID\0") _T("%2"),
  34. _T("CLSID\\%1\\InProcServer32\0") _T("%3"),
  35. _T("CLSID\\%1\\DefaultIcon\0") _T("%3,%7"),
  36. NULL
  37. };
  38. BOOL CFacNcsaLogUI::UpdateRegistry( BOOL bRegister )
  39. {
  40. if (bRegister)
  41. if ( AfxOleRegisterServerClass(
  42. CLSID_NCSALOGUI,
  43. OLE_NAME,
  44. _T("LogUI ncsa"),
  45. _T("LogUI ncsa"),
  46. OAT_SERVER,
  47. (LPCTSTR *)rglpszServerRegister,
  48. (LPCTSTR *)rglpszServerOverwriteDLL
  49. ) )
  50. {
  51. return FSetObjectApartmentModel( CLSID_NCSALOGUI );
  52. }
  53. else
  54. return AfxOleUnregisterClass(m_clsid, OLE_NAME);
  55. return FALSE;
  56. }
  57. IMPLEMENT_DYNCREATE(CNcsaCreator, CCmdTarget)
  58. LPUNKNOWN CNcsaCreator::GetInterfaceHook(const void* piid)
  59. {
  60. return new CImpNcsaLogUI;
  61. }
  62. CImpNcsaLogUI::CImpNcsaLogUI():
  63. m_dwRefCount(0)
  64. {
  65. AfxOleLockApp();
  66. }
  67. CImpNcsaLogUI::~CImpNcsaLogUI()
  68. {
  69. AfxOleUnlockApp();
  70. }
  71. HRESULT CImpNcsaLogUI::OnProperties(
  72. OLECHAR * pocMachineName,
  73. OLECHAR * pocMetabasePath
  74. )
  75. {
  76. return OnPropertiesEx(pocMachineName, pocMetabasePath, NULL, NULL);
  77. }
  78. HRESULT CImpNcsaLogUI::OnPropertiesEx(
  79. OLECHAR * pocMachineName,
  80. OLECHAR * pocMetabasePath,
  81. OLECHAR * pocUserName,
  82. OLECHAR * pocPassword
  83. )
  84. {
  85. AFX_MANAGE_STATE(_afxModuleAddrThis);
  86. // specify the resources to use
  87. HINSTANCE hOldRes = AfxGetResourceHandle();
  88. AfxSetResourceHandle( g_hInstance );
  89. // prepare the help
  90. ((CLoguiApp*)AfxGetApp())->PrepHelp( pocMetabasePath );
  91. CLogGeneral pageLogGeneral;
  92. CPropertySheet propsheet(IDS_SHEET_NCSA_TITLE);
  93. try
  94. {
  95. pageLogGeneral.m_szMeta = pocMetabasePath;
  96. pageLogGeneral.m_szServer = pocMachineName;
  97. pageLogGeneral.m_szUserName = pocUserName;
  98. pageLogGeneral.m_szPassword = pocPassword;
  99. pageLogGeneral.szPrefix.LoadString(IDS_LOG_NCSA_PREFIX);
  100. pageLogGeneral.szSizePrefix.LoadString(IDS_LOG_SIZE_NCSA_PREFIX);
  101. pageLogGeneral.m_fLocalMachine = FIsLocalMachine( pocMachineName );
  102. propsheet.AddPage( &pageLogGeneral );
  103. propsheet.m_psh.dwFlags |= PSH_HASHELP;
  104. pageLogGeneral.m_psp.dwFlags |= PSP_HASHELP;
  105. propsheet.DoModal();
  106. }
  107. catch ( CException * pException )
  108. {
  109. pException->Delete();
  110. }
  111. AfxSetResourceHandle( hOldRes );
  112. return NO_ERROR;
  113. }
  114. HRESULT CImpNcsaLogUI::QueryInterface(REFIID riid, void **ppObject)
  115. {
  116. if ( riid==IID_IUnknown
  117. || riid==IID_LOGGINGUI
  118. || riid==IID_LOGGINGUI2
  119. || riid==CLSID_NCSALOGUI
  120. )
  121. {
  122. *ppObject = (ILogUIPlugin*) this;
  123. }
  124. else
  125. {
  126. return E_NOINTERFACE;
  127. }
  128. AddRef();
  129. return NO_ERROR;
  130. }
  131. ULONG CImpNcsaLogUI::AddRef()
  132. {
  133. DWORD dwRefCount;
  134. dwRefCount = InterlockedIncrement((long *)&m_dwRefCount);
  135. return dwRefCount;
  136. }
  137. ULONG CImpNcsaLogUI::Release()
  138. {
  139. DWORD dwRefCount;
  140. dwRefCount = InterlockedDecrement((long *)&m_dwRefCount);
  141. if (dwRefCount == 0) {
  142. delete this;
  143. }
  144. return dwRefCount;
  145. }