Share via


Detecting Device Object Changes (Windows Embedded CE 6.0)

1/6/2010

Changes on the Windows Embedded CE-based device are handled through the ObjectNotify function. The service manager calls ObjectNotify in the following cases.

  • When a user connects the Windows Embedded CE-based device and there is a changed object.
  • Immediately after connection.
  • After an acknowledgement is received from the desktop that the object has been synchronized successfully.
  • Two seconds after the device provider sets ONF_CALLING_BACK.

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.

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 should mark the object as up-to-date. OBJNOTIFY::oidObject is the synchronized object identifier, not the Windows Embedded CE object identifier.

ONF_CALL_BACK

Set by the device provider 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 structure size is the same.
   if (pNotify->cbStruct != sizeof (OBJNOTIFY))
       return FALSE;

   // Check ONF_* flags to see if notification is relevant.
   if (!(pNotify->uFlags & ONF_DELETED))
   {
       // Make sure 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 if object changed again during synchronization.
       // If so, return TRUE. If not, return FALSE.
   }

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

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

   // If you store one object per file and/or record, you need only
   // 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 database information in the OBJTYPEINFO structure.
   wcsncpy (pInfo->szName, 
            oidInfo.infDatabase.szDbaseName,
            sizeof(pInfo->szName));
   pInfo->cObjects       = oidInfo.infDatabase.wNumRecords;
   pInfo->cbAllObj       = oidInfo.infDatabase.dwSize;
   pInfo->ftLastModified = oidInfo.infDatabase.ftLastModified;

   return TRUE;
}

See Also

Concepts

Developing the Device Provider