home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12otk1.exe / include / cmgrsrvr.idl < prev    next >
Text File  |  1997-04-02  |  17KB  |  372 lines

  1. //#====START_GENERATED_PROLOG======================================
  2. //#
  3. //#
  4. //#   COMPONENT_NAME: odscript
  5. //#
  6. //#   CLASSES: none
  7. //#
  8. //#   ORIGINS: 27
  9. //#
  10. //#
  11. //#   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  12. //#   All Rights Reserved
  13. //#   Licensed Materials - Property of IBM
  14. //#   US Government Users Restricted Rights - Use, duplication or
  15. //#   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  16. //#       
  17. //#   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  18. //#   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19. //#   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  20. //#   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  21. //#   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  22. //#   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  23. //#   OR PERFORMANCE OF THIS SOFTWARE.
  24. //#
  25. //#====END_GENERATED_PROLOG========================================
  26. //#
  27. // @(#) 1.5 com/src/odscript/idl/cmgrsrvr.idl, odscript, od96os2, odos29712d 10/31/96 12:43:59 [3/21/97 17:43:03]
  28. // ===========================================================================
  29. //
  30. // Component manager Server
  31. //
  32. // Provides interface for management of the Component Registry.
  33. //
  34. // Implements the Registry using a platform specific format (INI files
  35. // for OS/2 and Win NT/95, TBD for AIX).
  36. //
  37. // Interfaces provided to search the registry, add entries, remove entries
  38. // get the information from an entry, get the information needed to
  39. // create an instance of the class described by the registry, etc.
  40. //
  41. // ===========================================================================
  42.  
  43. #include <snglicls.idl>
  44.  
  45. #ifndef _ODTYPESM_
  46. #include <ODTypesM.idl>
  47. #endif
  48.  
  49. #ifndef _COMPONENTMANAGER_
  50. #include <compmgr.idl>
  51. #endif
  52.  
  53. #ifndef _COMPONENTMANAGERSERVER_
  54. #define _COMPONENTMANAGERSERVER_
  55.  
  56. //==============================================================================
  57. // Classes defined in this interface
  58. //==============================================================================
  59.  
  60. interface ComponentManagerServer;
  61.  
  62. //==============================================================================
  63. // Classes used by this interface
  64. //==============================================================================
  65.  
  66. interface Component;
  67.  
  68. //==============================================================================
  69. // Implementation Types
  70. //==============================================================================
  71.  
  72. typedef somToken LinkedList;
  73. typedef somToken ComponentLink;
  74. typedef somToken HAB;
  75. typedef somToken HINI;
  76. typedef somToken HMTX;
  77. typedef somToken HANDLE ;               // windows handle
  78.  
  79. //==============================================================================
  80. // Class ComponentManager
  81. //==============================================================================
  82.  
  83. interface ComponentManagerServer : SOMClass {
  84.  
  85. #ifdef __SOMIDL__
  86.  
  87. //---------------------------------------------------------------------------
  88. //
  89. // Function - CountComponents
  90. //
  91. // Inputs - A ComponentDescription block that specifies the search requirements
  92. //              to be used to identify entries that are to be counted.
  93. //
  94. // Outputs - Returns a count of the number of entries that matched the
  95. //              search conditions.
  96. //
  97. // Description - Searches the cached Component Registry information for items
  98. //              which match the criteria specified by the input ComponentDescription.
  99. //              Search algorithm will match entries as follows:
  100. //                      1. If the entry in the ComponentDescription is NULL
  101. //                         it 'matches' all entries in the Registry
  102. //                      2. If the entry for Type, SubType or Manufacturer is
  103. //                         not null, it 'matches' only if it is equal to the
  104. //                         corresponding value in the registry.
  105. //                      3. If the FlagsMask is not null, the flag bits implied
  106. //                         by that mask that are specified in the input block
  107. //                         must match the corresponding bits in the Registry
  108. //
  109. //---------------------------------------------------------------------------
  110.  
  111. ODULong          CountComponents(in ComponentDescription *plooking);
  112.  
  113. //---------------------------------------------------------------------------
  114. //
  115. // Function - FindNextComponent
  116. //
  117. // Inputs - plastFound - description of previously located registry entry
  118. //          plooking   - description of search critera
  119. //          pfound     - description block to receive info for a matched entry
  120. //          Each of these inputs is a pointer to a ComponentDescription block.
  121. //
  122. // Outputs - Block indicated by pfound will be filled in with the Type, SubType
  123. //           Flags and Manufacturer values for the matching entry.
  124. //           Return value is zero if a match was found, non-zero if no match
  125. //           or an error.
  126. //
  127. // Description - If the plastFound entry is not null, it is used to locate
  128. //              a previously 'found' entry, by searching for an entry that
  129. //              matches the Type and SubType specified in that block.  If
  130. //              plastFound is NULL, the search will begin at the first
  131. //              entry in the Registry.  The search uses plooking in the same
  132. //              way as CountEntries above.  When a matching entry is found,
  133. //              the Type, SubType, Manufacturer and Flags for that entry
  134. //              are set into the block indicated by pfound.
  135. //
  136. //---------------------------------------------------------------------------
  137.  
  138. OSErr            FindNextComponent(in ComponentDescription *plastFound,
  139.                                    in ComponentDescription *plooking,
  140.                                    out ComponentDescription pfound);
  141.  
  142. //---------------------------------------------------------------------------
  143. //
  144. // Function - GetComponentInfo
  145. //
  146. // Inputs - ComponentDescription block that specifies the Registry entry
  147. //          for which we want the string values.
  148. //          Pointers to string pointers to receive the long string values
  149. //          from the Registry entry identified.
  150. //
  151. // Outputs - If the specified entry is found, SOMAlloc is used to allocate
  152. //           storage for each of the string values in that entry.  The
  153. //           string value is then copied into that storage.  The caller must
  154. //           use SOMFree to release the storage.
  155. //           Returns zero if successful or non-zero if error occurs (not found,
  156. //           or unable to allocate storage).
  157. //
  158. // Description - Locate the entry specified by ptheComponent (uses Type and
  159. //              SubType values only).  If found, allocate storage to hold the
  160. //              string values and initialize that storage with the strings.
  161. //
  162. //---------------------------------------------------------------------------
  163.  
  164. OSErr            GetComponentInfo(in ComponentDescription *ptheComponent,
  165.                                   out string pcomponentClassName,
  166.                                   out string pcomponentDLL,
  167.                                   out string pcomponentName,
  168.                                   out string pcomponentInfo);
  169.  
  170. //---------------------------------------------------------------------------
  171. //
  172. // Function - GetComponentRefcon
  173. //
  174. // Inputs - ComponentDescription block identifying the Type and SubType
  175. //          of the Refcon to be accessed
  176. //
  177. // Outputs - Returns the component Refcon that has been placed in shared
  178. //           storage associated with the Type and SubType specified.
  179. //
  180. // Description - Use the Type and SubType to construct the needed shared storage
  181. //               access identifier.  Use that identifier to access the Refcon
  182. //               stored earlier.
  183. //
  184. //---------------------------------------------------------------------------
  185.  
  186. ODSLong          GetComponentRefcon(in ComponentDescription *ptheComponent);
  187.  
  188. //---------------------------------------------------------------------------
  189. //
  190. // Function - SetComponentRefcon
  191. //
  192. // Inputs - ComponentDescription block identifying the Type and SubType
  193. //          that identifies this Refcon.
  194. //          Long integer that is the value for the Refcon.
  195. //
  196. // Outputs - Refcon is updated in storage with the specified value.
  197. //
  198. // Description - Use the Type and SubType specified to construct the shared
  199. //               storage identifer for this component.  Use that key to set
  200. //               the value of the associated Refcon to the value supplied.
  201. //
  202. //---------------------------------------------------------------------------
  203.  
  204. void             SetComponentRefcon(in ComponentDescription *ptheComponent,
  205.                                     in ODSLong Refcon);
  206.  
  207. //---------------------------------------------------------------------------
  208. //
  209. // Function - OpenComponent
  210. //
  211. // Inputs - ComponenDescription block that specifies the requirements for the
  212. //          component we wish to open.
  213. //        - pointers to string values to receive the ClassName and DLL name for
  214. //          the component.
  215. //        - pointer to Unsigned long that will receive the version information
  216. //          for the component
  217. //
  218. // Outputs - Strings will be allocated and initialized for the ClassName and
  219. //           DLL name and the version number will be set.  The caller must
  220. //           release the storage allocated for the strings using SOMFree.
  221. //           Returns zero if successful or nonzero if no matching entry was
  222. //           found in the Registry.
  223. //
  224. // Description - Uses the values in the ComponentDescription to locate a
  225. //               matching entry (see CountEntries for search algorithm).
  226. //               If a match is found, allocates storage for the ClassName and
  227. //               DLL name and sets the string values.
  228. //               Note - the Caller is expected to use these values to actually
  229. //               create an instance of the component.
  230. //
  231. //---------------------------------------------------------------------------
  232.  
  233. void             OpenComponent(in ComponentDescription *ptheComponent,
  234.                                out string pcomponentClassName,
  235.                                out string pcomponentClassDLL,
  236.                                out ODULong pcomponentVersion);
  237.  
  238. //---------------------------------------------------------------------------
  239. //
  240. // Function - OpenDefaultComponent (a misnomer)
  241. //
  242. // Inputs - Type and SubType codes (as Unsigned integers), pointers to
  243. //          locations for the ClassName and DLL name and Version values
  244. //
  245. // Outputs - Storage is allocated for the ClassName and DLL name and the
  246. //           string values are set.  Caller must use SOMFree to release that
  247. //           storage as appropriate.
  248. //
  249. // Description - This function is misnamed.  It really does a search for
  250. //               the Registry entry that matches the Type and SubType specified
  251. //               and then proceeds just as OpenComponent above.  There is no
  252. //               concept of 'default' implemented.
  253. //
  254. //---------------------------------------------------------------------------
  255.  
  256. void             OpenDefaultComponent(in OSType componentType,
  257.                                       in OSType componentSubType,
  258.                                       out string pcomponentClassName,
  259.                                       out string pcomponentClassDLL,
  260.                                       out ODULong pcomponentVersion);
  261.  
  262. //---------------------------------------------------------------------------
  263. //
  264. // Function - InstallComponent
  265. //
  266. // Inputs - ComponentRegistryData block that contains the complete description
  267. //          for a new Compoent Registry entry.
  268. //
  269. // Outputs - Returns zero if successful or non-zero if an error occurs.  It
  270. //           will treat a pre-existing entry with the same Type and Subtype as
  271. //           an error and will not modify that entry.
  272. //
  273. // Description - Will create a new entry in the Registry to reflect the data
  274. //               specified in the Data block. On OS/2 and Windows NT/95 the
  275. //               registry is implemented using INI files with the following
  276. //               structure:
  277. //                   [COMPONENT]    - component section
  278. //                     TYPESTYP     - zero or more Type/SubType values as
  279. //                                    keywords with no value associated.
  280. //                   [TYPESTYP]     - a section for each of the values in
  281. //                                    the set of Type/SubType values listed
  282. //                                    under component
  283. //                     TYPE = xxxx  - Keyword value pairs for each of the
  284. //                                    component information items.  Type,
  285. //                                    SubType and Manufacturer are strings of
  286. //                                    less than 5 characters which will be
  287. //                                    mashed into an Unsigned Long in the
  288. //                                    inernal representation (with blank
  289. //                                    padding if needed).  The Flags and Version
  290. //                                    values will be represented as hexadecimal
  291. //                                    unsigned integer values.  The other fields
  292. //                                    will be simple strings.  (ClassName, DLL
  293. //                                    name, Name and Info.
  294. //               Note - AIX implementation is still to be done.
  295. //
  296. //---------------------------------------------------------------------------
  297.  
  298. OSErr            InstallComponent(in ComponentRegistryData *ptheData);
  299.  
  300. //---------------------------------------------------------------------------
  301. //
  302. // Function - UninstallComponent
  303. //
  304. // Inputs - Type and SubType values that specify the component to be deleted
  305. //
  306. // Outputs - Returns zero if successful or nonzero if Failure.
  307. //
  308. // Description - For OS/2 and Windows NT/95, uses the INI file format
  309. //               described above (InstallComponent).  Will remove the
  310. //               entry for the Type/SubType and will remove the Type/SubType
  311. //               entry under 'COMPONENTS' at the top level.
  312. //
  313. //---------------------------------------------------------------------------
  314.  
  315. OSErr            UninstallComponent(in OSType componentType,
  316.                                     in OSType componentSubType);
  317.  
  318.  
  319. implementation {
  320.  
  321. #ifdef _PLATFORM_OS2_
  322.         HAB         hab;                // application block handle
  323.         HINI        hini;               // INI handle
  324.         HMTX        hmtxCMGR;           // mutex control handle
  325. #endif
  326. #ifdef _PLATFORM_NT_
  327.         char *      inifilename ;       // INI filename
  328.         HANDLE      hmtxCMGR ;          // mutex handle
  329. #endif
  330.  
  331.         LinkedList *componentRegistryList;
  332.  
  333.         majorversion = 1;
  334.         minorversion = 0;
  335.         functionprefix = CMGRSRV_;
  336.         metaclass = SOMMSingleInstance;
  337.         releaseorder :  CountComponents,
  338.                         FindNextComponent,
  339.                         GetComponentInfo,
  340.                         GetComponentRefcon,
  341.                         SetComponentRefcon,
  342.                         OpenComponent,
  343.                         OpenDefaultComponent,
  344.                         InstallComponent,
  345.                         UninstallComponent,
  346.                         FindComponent;
  347.         somDefaultInit: override, init;
  348.         somDestruct: override;
  349.  
  350.         passthru C_xih = "#define REQUEST_TIMEOUT  30 * 1000  // 30 seconds;"
  351.                          "#define COMPONENTS     \"COMPONENTS\"   "
  352.                          "#define COMP_CLASS     \"COMP_CLASS\"   "
  353.                          "#define COMP_TYPE      \"COMP_TYPE\"    "
  354.                          "#define COMP_SUBTYPE   \"COMP_SUBTYPE\" "
  355.                          "#define COMP_MFTR      \"COMP_MFTR\"    "
  356.                          "#define COMP_FLAGS     \"COMP_FLAGS\"   "
  357.                          "#define COMP_VERSION   \"COMP_VERSION\" "
  358.                          "#define COMP_DLL       \"COMP_DLL\"     "
  359.                          "#define COMP_NAME      \"COMP_NAME\"    "
  360.                          "#define COMP_INFO      \"COMP_INFO\"    "
  361.                          "#define COMP_REFCON    \"\\SHAREMEM\\COMP_REFCON\"  "
  362.                          "#define CMGR_INI_FILENAME   \"opendoc.ini\" " ;
  363.         passthru C_xh  = "#include <cmgrutil.h>                   ";
  364.         dllname = "oddsscr.dll";
  365. };
  366.  
  367. #endif
  368.  
  369. };
  370.  
  371. #endif
  372.