Detecting Device Object Changes

Changes on the device are handled through the ObjectNotify function. The service manager calls ObjectNotify in the following cases:

ObjectNotify checks the flags and the file system identifier information in the OBJNOTIFY structure for a changed object.

The following table shows the values for the OBJNOTIFY::uFlags member.

Uflags member
Definition
ONF_FILE OBJNOTIFY::oidObject is a file.
ONF_DIRECTORY OBJNOTIFY::oidObject is a directory.
ONF_RECORD OBJNOTIFY::oidObject is a record.
ONF_DATABASE OBJNOTIFY::oidObject is a database.
ONF_CHANGED The file system object is changed.
ONF_DELETED The file system object is deleted. Only oidParent in OBJNOTIFY::oidInfo is defined. All other members in OBJNOTIFY::oidInfo are 0.
ONF_CLEAR_CHANGE The desktop provider module should mark the object as up to date. In this case, OBJNOTIFY::oidObject is the synchronized object identifier, and not the Windows CE object identifier.
ONF_CALL_BACK Set by the device provider module to ask the service manager to call back.
ONF_CALLING_BACK The service manager sets this flag and calls ObjectNotify.

The following code example shows how to implement ObjectNotify.

EXTERN_C BOOL ObjectNotify( POBJNOTIFY pNotify )
{
    // Check to see if the structure size is the same.
    if ( pNotify->cbStruct != sizeof( OBJNOTIFY ) )
         return FALSE;

    // Check ONF_* flags to see if the notification is 
    // relevant.
    if ( !( pNotify->uFlags & ONF_DELETED ) )
    {
        // Make sure that you are dealing with the records in your 
        // database.
        // The object (a record or a file) must exist.
    }

    if ( pNotify->uFlags & ONF_CLEAR_CHANGE )
    {
        // Check whether the object was changed again 
        // during synchronization.
        // If so, return TRUE; if not, return FALSE.
    }

    pNotify->poid = (UINT *)&pNotify->oidObject;

    // Determine what object identifier to return. Consider 
    // uPartnerBit in your decision.

    // If you store one object per file and/or record, you simply 
    // need to return the file system object identifier. Otherwise, 
    // you need to read the file system object and determine the list of 
    // object identifiers that have changed. 

    
    return TRUE;
 }

To get information from a database with the oidDataBase object identifier, the service manager calls GetObjTypeInfo.

The following code example shows how to implement GetObjTypeInfo.

EXTERN_C BOOL GetObjTypeInfo
( 
POBJTYPEINFO pInfo        // Pointer to the OBJTYPEINFO structure
)
{
CEOIDINFO   oidInfo;
if ( pInfo->cbStruct != sizeof( OBJTYPEINFO ) )
return FALSE;
    // Clear the structure.
    memset( &(oidInfo), 0, sizeof(oidInfo));

    // Retrieve information about the object in the object store.
CeOidGetInfo( oidDataBase, &oidInfo );

    // Store the database information into the OBJTYPEINFO structure.
wcscpy( pInfo->szName, oidInfo.infDatabase.szDbaseName );
     pInfo->cObjects = oidInfo.infDatabase.wNumRecords;
pInfo->cbAllObj = oidInfo.infDatabase.dwSize;
pInfo->ftLastModified = oidInfo.infDatabase.ftLastModified;

     return TRUE;
}