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.

373 lines
9.8 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft OLE
  4. // Copyright (C) Microsoft Corporation, 1994 - 1995.
  5. //
  6. // File: automate.hxx
  7. //
  8. // Contents: Marina automation helper class
  9. // Marina aware applications use this class to aid in the
  10. // automation process
  11. //
  12. // Classes: CMAutomate
  13. //
  14. // Functions:
  15. //
  16. // History: 09-26-95 alexe Cleaned up / added more marina funcs
  17. // 1-25-95 kennethm Created
  18. //
  19. //--------------------------------------------------------------------------
  20. #ifndef __AUTOMATE_HXX__
  21. #define __AUTOMATE_HXX__
  22. #include <copydata.hxx>
  23. //
  24. // number of marina API functions in the CMAutomate class
  25. //
  26. #define MAX_NUM_FUNCS 16
  27. //
  28. // Function names: always unicode
  29. //
  30. // These are the known functions. TestDlls and application can always
  31. // cook up their own private function names, although this isn't
  32. // recommended.
  33. //
  34. #define FUNCNAME_CLOSEAPPLICATION L"MarinaCloseApplication"
  35. #define FUNCNAME_CREATEDOCUMENT L"MarinaCreateDocument"
  36. #define FUNCNAME_OPENDOCUMENT L"MarinaOpenDocument"
  37. #define FUNCNAME_CLOSEALLDOCUMENTS L"MarinaCloseAllDocuments"
  38. #define FUNCNAME_GETDOCUMENTCOUNT L"MarinaApiGetDocCount"
  39. #define FUNCNAME_GETAPPHWND L"MarinaGetAppHwnd"
  40. #define FUNCNAME_SAVEDOCUMENT L"MarinaSaveDocument"
  41. #define FUNCNAME_CLOSEDOCUMENT L"MarinaCloseDocument"
  42. #define FUNCNAME_COPYDOCUMENT L"MarinaCopyDocument"
  43. #define FUNCNAME_INSERTOBJECT L"MarinaInsertObject"
  44. #define FUNCNAME_GETOBJECT L"MarinaGetObject"
  45. #define FUNCNAME_GETOBJECTCOUNT L"MarinaApiGetObjCount"
  46. #define FUNCNAME_COPYOBJECT L"MarinaCopyObject"
  47. #define FUNCNAME_ACTIVATEOBJECT L"MarinaActivateObject"
  48. #define FUNCNAME_GETAPPPROCESSID L"MarinaGetAppProcessId"
  49. #define INVALID_MARINA_HANDLE (DWORD)-1
  50. //+-------------------------------------------------------------------------
  51. //
  52. // Class: CMAutomate
  53. //
  54. // Purpose: Automation helper class for marina aware applications
  55. //
  56. // Interface:
  57. //
  58. // Public Functions:
  59. //
  60. // CMAutomate
  61. // ~CMAutomate
  62. // CMAutomate(ptr)
  63. // FindMarinaHandle
  64. // WriteMarinaHandle
  65. // MarinaRegisterFile
  66. // SetJumpTable
  67. // DispatchCopyData
  68. // InMarina
  69. // MarinaParseCommandLine
  70. //
  71. // MarinaApiCloseApp
  72. // MarinaApiCreateDoc
  73. // MarinaApiOpenDoc
  74. // MarinaApiCloseAllDocs
  75. // MarinaApiGetDocCount
  76. // MarinaApiGetAppHwnd
  77. //
  78. // MarinaApiSaveDoc
  79. // MarinaApiCloseDoc
  80. // MarinaApiCopyDoc
  81. // MarinaApiInsertObject
  82. // MarinaApiGetObject
  83. // MarinaApiGetObjCount
  84. //
  85. // MarinaApiCopyObject
  86. // MarinaApiActivateObject
  87. //
  88. // MarinaApiGetAppProcessId
  89. //
  90. // Private functions:
  91. //
  92. // SetClassFunctionTable
  93. // DispatchCDExecFunction
  94. //
  95. // History: 2-01-95 kennethm Created
  96. // 7-25-95 kennethm Merged function table class
  97. // (MarinaApiXXXX functions)
  98. // 9-26-95 alexe Cleaned up/ added more 'Marina' functions
  99. // Removed some obsolete accessor functions
  100. //
  101. // Notes:
  102. //
  103. //--------------------------------------------------------------------------
  104. class CMAutomate
  105. {
  106. public:
  107. //
  108. // Default constructor and destructor
  109. //
  110. CMAutomate();
  111. ~CMAutomate();
  112. //
  113. // Special case initialization constructor
  114. //
  115. CMAutomate(struct tagMarinaFunctionTableElement *pJumpTable);
  116. //
  117. // On the server side, pull out the marina handle from ole storage
  118. // Called during object initialization.
  119. //
  120. HRESULT FindMarinaHandle(LPSTORAGE pStg, HWND hWndObj);
  121. //
  122. // On the container side, called to place the marina handle into
  123. // storage so FindMarinaHandle can get to it
  124. //
  125. HRESULT WriteMarinaHandle(LPSTORAGE pStg);
  126. //
  127. // Register a file name with marina
  128. //
  129. HRESULT MarinaRegisterFile(LPCWSTR pszFileName, HWND hWnd);
  130. //
  131. // Set the jump table used by Dispatch functions
  132. //
  133. VOID SetJumpTable(struct tagMarinaFunctionTableElement *pJumpTable);
  134. //
  135. // Called when a WM_COPYDATA message is received
  136. //
  137. LRESULT DispatchCopyData(HWND hwnd, LPARAM lParam);
  138. //
  139. // Called when a WM_PRIVATECOPYDATA message is received
  140. //
  141. LRESULT DispatchPrivateCopyData(HWND hwnd, LPARAM lParam);
  142. //
  143. // When an application starts up, checks to see if marina started
  144. // the application. Used by all applications
  145. //
  146. BOOL InMarina() const;
  147. //
  148. // When an application starts up, calls parsecommandline to see
  149. // if the application was started by marina
  150. //
  151. HRESULT MarinaParseCommandLine(HWND hWnd);
  152. //
  153. // Application level marina API functions
  154. //
  155. virtual HRESULT MarinaApiCloseApp(
  156. HWND hwnd,
  157. PVOID pvParam,
  158. PCOPYDATASTRUCT pOutParameter);
  159. virtual HRESULT MarinaApiCreateDoc(
  160. HWND hwnd,
  161. PVOID pvParam,
  162. PCOPYDATASTRUCT pOutParameter);
  163. virtual HRESULT MarinaApiOpenDoc(
  164. HWND hwnd,
  165. PVOID pvParam,
  166. PCOPYDATASTRUCT pOutParameter);
  167. virtual HRESULT MarinaApiCloseAllDocs(
  168. HWND hwnd,
  169. PVOID pvParam,
  170. PCOPYDATASTRUCT pOutParameter);
  171. virtual HRESULT MarinaApiGetDocCount(
  172. HWND hwnd,
  173. PVOID pvParam,
  174. PCOPYDATASTRUCT pOutParameter);
  175. virtual HRESULT MarinaApiGetAppHwnd(
  176. HWND hwnd,
  177. PVOID pvParam,
  178. PCOPYDATASTRUCT pOutParameter);
  179. //
  180. // Document level marina API functions
  181. //
  182. virtual HRESULT MarinaApiSaveDoc(
  183. HWND hwnd,
  184. PVOID pvParam,
  185. PCOPYDATASTRUCT pOutParameter);
  186. virtual HRESULT MarinaApiCloseDoc(
  187. HWND hwnd,
  188. PVOID pvParam,
  189. PCOPYDATASTRUCT pOutParameter);
  190. virtual HRESULT MarinaApiCopyDoc(
  191. HWND hwnd,
  192. PVOID pvParam,
  193. PCOPYDATASTRUCT pOutParameter);
  194. virtual HRESULT MarinaApiInsertObject(
  195. HWND hwnd,
  196. PVOID pvParam,
  197. PCOPYDATASTRUCT pOutParameter);
  198. virtual HRESULT MarinaApiGetObject(
  199. HWND hwnd,
  200. PVOID pvParam,
  201. PCOPYDATASTRUCT pOutParameter);
  202. virtual HRESULT MarinaApiGetObjCount(
  203. HWND hwnd,
  204. PVOID pvParam,
  205. PCOPYDATASTRUCT pOutParameter);
  206. //
  207. // Object level marina API functions
  208. //
  209. virtual HRESULT MarinaApiCopyObject(
  210. HWND hwnd,
  211. PVOID pvParam,
  212. PCOPYDATASTRUCT pOutParameter);
  213. virtual HRESULT MarinaApiActivateObject(
  214. HWND hwnd,
  215. PVOID pvParam,
  216. PCOPYDATASTRUCT pOutParameter);
  217. //
  218. // Other marina API functions
  219. //
  220. virtual HRESULT MarinaApiGetAppProcessId(
  221. HWND hwnd,
  222. PVOID pvParam,
  223. PCOPYDATASTRUCT pOutParameter);
  224. private:
  225. struct tagMarinaFunctionTableElement *m_MarinaDispatchTable;
  226. //
  227. // The marina handle that is being used for the current call
  228. //
  229. DWORD m_dwMarinaHandle;
  230. static BOOL m_fRunByMarina;
  231. //
  232. // The window that was registered for this particular instance of
  233. // CMAutomate
  234. //
  235. DWORD m_dwRegisteredhWnd;
  236. //
  237. // Our own internal Marina API function table. This list contains
  238. // pointers to all of the virtual MarinaApiXXXXX functions listed
  239. // above after the call to SetClassFunctionTable. This is done in
  240. // the constructor
  241. //
  242. struct tagMarinaClassTableElement *m_MarinaAPIFuncTable;
  243. HRESULT SetClassFunctionTable();
  244. //
  245. // Performs the actual call to the user api when a marina message
  246. // is received.
  247. //
  248. HRESULT DispatchCDExecFunction(
  249. HWND hwnd,
  250. PCDEXECINFO pCDExecInfo,
  251. PCOPYDATASTRUCT pOutParameter);
  252. };
  253. //
  254. // Each function in the jump table follows this prototype
  255. //
  256. typedef HRESULT (WINAPI *COPYDATA_FUNCTION)(
  257. HWND hWnd,
  258. LPVOID pInParameter,
  259. PCOPYDATASTRUCT pOutParameter);
  260. //
  261. // This is one element in the jump table used by the CMAutomate class
  262. // The list is terminated by a null entry at the end
  263. //
  264. typedef struct tagMarinaFunctionTableElement
  265. {
  266. COPYDATA_FUNCTION pfnFunction;
  267. LPWSTR lpszFunctionName;
  268. } MARINAFUNCTIONTABLEELEMENT;
  269. //
  270. // This is one element in the internal class API function table
  271. // The list is terminated by a null entry at the end
  272. //
  273. typedef struct tagMarinaClassTableElement
  274. {
  275. HRESULT (CMAutomate::*pfnFunction)(
  276. HWND hwnd,
  277. PVOID pvParam,
  278. PCOPYDATASTRUCT pOutParameter);
  279. LPWSTR lpszFunctionName;
  280. } MARINACLASSTABLEELEMENT;
  281. //
  282. // An itty bitty class to perform the global rpc binding.
  283. //
  284. // Note, the Mac doesn't support real RPC yet (04-Nov-96)
  285. //
  286. #ifndef _MAC
  287. class CMarinaAutomateRPCBinding
  288. {
  289. public:
  290. CMarinaAutomateRPCBinding();
  291. ~CMarinaAutomateRPCBinding();
  292. };
  293. #endif // !_MAC
  294. #endif // __AUTOMATE_HXX__