Developing the Device Provider Module

The service manager interfaces with the device provider module to access data. To facilitate this interaction, a device provider module must implement the same IReplObjHandler interface that you use for the desktop provider module. It also must implement the InitObjType, GetObjTypeInfo, ObjectNotify functions. The device provider module can also implement the ReportStatus function, which is optional.

    To implement the device provider module

  1. Create one GUID for the store, by using the Visual C++ GUID generator tool, Guidgen.exe.
  2. Initialize the device store.
  3. Enumerate device objects.
  4. Detect device object changes and send and receive device data.

Initializing the Device Store

To initialize the device provider module, call InitObjType. If the device provider module supports synchronization of multiple object types, it calls InitObjType for each object type whose lpszObjType is not NULL. When an ActiveSync service terminates, the lpszObjType of its objects are set to NULL, thereby allowing the device provider module to free any resources it may have allocated.

The following code example shows how to implement InitObjType.

EXTERN_C BOOL InitObjType
( 
    LPWSTR lpszObjType, 
    IReplObjHandler **ppObjHandler, 
    UINT uPartnerBit 
)
{
    if ( lpszObjType == NULL )
    {
        // Terminates the device provider module and frees all
        // allocated resources.
        // ...

        return TRUE;
    }

    // Allocates a new IReplObjHandler. 
    *ppObjHandler = new CDataHandler;

    // Saves the uPartnerBit so that you can use it later in 
    // ObjectNotify. 

    // Initializing the module.
    // ...

    return TRUE;
}

ActiveSync supports the synchronization of two desktop computers with a Windows CE–based device. To differentiate between two computers, the service manager passes a partner bit into InitObjType when initializing the device provider module. This bit is set to 1 if the connected desktop computer is the first partner and 2 if it is the second partner. The device provider module must use this partner bit when setting and resetting dirty bits of an object.