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.

177 lines
4.3 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 "uiOdbc.h"
  8. //#include "LogGenPg.h"
  9. #include "LogODBC.h"
  10. #include "logtools.h"
  11. #define OLE_NAME _T("Odbc_Logging_UI")
  12. static const DWORD BASED_CODE _dwOleMisc = OLEMISC_INSIDEOUT | OLEMISC_CANTLINKINSIDE;
  13. extern HINSTANCE g_hInstance;
  14. CFacOdbcLogUI::CFacOdbcLogUI() :
  15. COleObjectFactory( CLSID_ODBCLOGUI, RUNTIME_CLASS(COdbcCreator), TRUE, OLE_NAME )
  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 CFacOdbcLogUI::UpdateRegistry( BOOL bRegister )
  39. {
  40. if (bRegister)
  41. if ( AfxOleRegisterServerClass(
  42. CLSID_ODBCLOGUI,
  43. OLE_NAME,
  44. _T("LogUI odbc"),
  45. _T("LogUI odbc"),
  46. OAT_SERVER,
  47. (LPCTSTR *)rglpszServerRegister,
  48. (LPCTSTR *)rglpszServerOverwriteDLL
  49. ) )
  50. {
  51. return FSetObjectApartmentModel( CLSID_ODBCLOGUI );
  52. }
  53. else
  54. return AfxOleUnregisterClass(m_clsid, OLE_NAME);
  55. return FALSE;
  56. }
  57. IMPLEMENT_DYNCREATE(COdbcCreator, CCmdTarget)
  58. LPUNKNOWN COdbcCreator::GetInterfaceHook(const void* piid)
  59. {
  60. return new CImpOdbcLogUI;
  61. }
  62. CImpOdbcLogUI::CImpOdbcLogUI():
  63. m_dwRefCount(0)
  64. {
  65. AfxOleLockApp();
  66. }
  67. CImpOdbcLogUI::~CImpOdbcLogUI()
  68. {
  69. AfxOleUnlockApp();
  70. }
  71. HRESULT
  72. CImpOdbcLogUI::OnProperties(OLECHAR * pocMachineName, OLECHAR * pocMetabasePath)
  73. {
  74. return OnPropertiesEx(pocMachineName, pocMetabasePath, NULL, NULL);
  75. }
  76. HRESULT
  77. CImpOdbcLogUI::OnPropertiesEx(
  78. OLECHAR * pocMachineName,
  79. OLECHAR * pocMetabasePath,
  80. OLECHAR * pocUserName,
  81. OLECHAR * pocPassword
  82. )
  83. {
  84. AFX_MANAGE_STATE(_afxModuleAddrThis);
  85. HINSTANCE hOldRes = AfxGetResourceHandle();
  86. AfxSetResourceHandle( g_hInstance );
  87. // prepare the help
  88. ((CLoguiApp*)AfxGetApp())->PrepHelp( pocMetabasePath );
  89. // CLogGeneral pageLogGeneral;
  90. CLogODBC pageLogODBC;
  91. CPropertySheet propsheet( IDS_SHEET_ODBC_TITLE );
  92. try
  93. {
  94. // prepare the pages
  95. pageLogODBC.m_szMeta = pocMetabasePath;
  96. pageLogODBC.m_szServer = pocMachineName;
  97. pageLogODBC.m_szUserName = pocUserName;
  98. pageLogODBC.m_szPassword = pocPassword;
  99. // pageLogGeneral.m_szMeta = pocMetabasePath;
  100. // pageLogGeneral.m_szServer = pocMachineName;
  101. // pageLogGeneral.m_szUserName = pocUserName;
  102. // pageLogGeneral.m_szPassword = pocPassword;
  103. // pageLogGeneral.szPrefix.LoadString( IDS_LOG_EXTND_PREFIX );
  104. // pageLogGeneral.szSizePrefix.LoadString( IDS_LOG_SIZE_EXTND_PREFIX );
  105. // propsheet.AddPage( &pageLogGeneral ); // don't need general for ODBC
  106. propsheet.AddPage( &pageLogODBC );
  107. // turn on help
  108. propsheet.m_psh.dwFlags |= PSH_HASHELP;
  109. // pageLogGeneral.m_psp.dwFlags |= PSP_HASHELP;
  110. pageLogODBC.m_psp.dwFlags |= PSP_HASHELP;
  111. propsheet.DoModal();
  112. }
  113. catch ( CException * pException )
  114. {
  115. pException->Delete();
  116. }
  117. AfxSetResourceHandle( hOldRes );
  118. return NO_ERROR;
  119. }
  120. HRESULT CImpOdbcLogUI::QueryInterface(REFIID riid, void **ppObject)
  121. {
  122. if ( riid==IID_IUnknown
  123. || riid==IID_LOGGINGUI
  124. || riid==IID_LOGGINGUI2
  125. || riid==CLSID_ASCLOGUI
  126. )
  127. {
  128. *ppObject = (ILogUIPlugin*) this;
  129. }
  130. else
  131. {
  132. return E_NOINTERFACE;
  133. }
  134. AddRef();
  135. return NO_ERROR;
  136. }
  137. ULONG CImpOdbcLogUI::AddRef()
  138. {
  139. DWORD dwRefCount;
  140. dwRefCount = InterlockedIncrement((long *)&m_dwRefCount);
  141. return dwRefCount;
  142. }
  143. ULONG CImpOdbcLogUI::Release()
  144. {
  145. DWORD dwRefCount;
  146. dwRefCount = InterlockedDecrement((long *)&m_dwRefCount);
  147. if (dwRefCount == 0) {
  148. delete this;
  149. }
  150. return dwRefCount;
  151. }