Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

Example - privileged in-process class

An in-process class can be a privileged class. To instantiate the in-process class, the caller must include the ClassID of the in-process class as a privilege. An in-process class is declared to be privileged in its CIF using the privileged field of the Class primitive, as follows:

include "AEECLSID_ExService.bid" -- contains the definition of
                                 -- AEECLSID_ExService
include "ExService.h"            -- contains the definition of
                                 -- ExService_New

Class {
   classid = AEECLSID_ExService,
	  newfunc = ExService_New,
	  privileged = TRUE
}

Note that when a privileged class is used as the servedclassid for a service, that service automatically becomes privileged. To instantiate the service, the caller of the service also needs to include the ClassID of the privileged class as a privilege.

CIF contents for an application using the in-process class

The CIF for an application that uses the ExService class, shown above, needs to do the following in its CIF:

  • Include the .bid file that defines the ClassID for ExService
  • Include the privilege (the ClassID for an in-process class) in the privs field in its Applet primitive, as shown in the following example:
include "AEECLSID_ExampleApp.bid"   -- contains the definition of
                                    -- AEECLSID_ExampleApp
include "AEECLSID_ExService.bid"    -- contains the definition of
                                    -- AEECLSID_ExService
include "ExampleApp.h"              -- contains the definition of
                                    -- ExampleApp_New

Applet {
   appletid = AEECLSID_ExampleApp,
   resbaseid = 20, -- Applet base resource id
   applethostid = 0,
   type = 0,
   privs = { AEECLSID_ExService },
   newfunc = ExampleApp_New
};