Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
The service manager automatically detects object changes and deletions by comparing the list of handles returned during enumeration with the handles loaded from the service manager's persistent file. Before starting an enumeration process, the service manager does the following:
- Marks a bit for each handle stored in Repl.dat.
- Calls
IReplStore::FindFirstItemand
IReplStore::FindNextItem.
- Performs a binary search on the handles in Repl.dat each time
one of these methods returns a new handle to find a handle
representing the same object.
- If no matching handle is found, it creates a new object on the
desktop store.
- If a matching handle is found, it clears the bit from the
handle in Repl.dat and calls
IReplStore::IsItemChangedto see if the object has changed
since the last synchronization.
- If the object has changed, it calls
IReplStore::CopyObjectto copy the data from the returned
handle into the handle that is saved in Repl.dat.
- Calls
IReplStore::IsItemReplicatedto see if it should send the
object to the Windows Mobile device.
All handles in Repl.dat that remain marked once enumeration is complete represent deleted objects.
To speed up enumeration, the desktop provider can detect and report desktop changes to the service manager in real time. To do so, the desktop provider and service manager perform the following actions.
- The service manager calls
IReplNotify::OnItemNotifyto inform the desktop provider of
an object's status.
- The desktop provider passes RNC_MODIFIED for a modified object,
RNC_CREATED for a created object, and RNC_DELETED for a deleted
object.
- The desktop provider passes a handle to the object so the
service manager can search the persistent file for the
corresponding device object.
The following illustration shows the sequence of real-time notification calls.
If the desktop provider detects that the desktop application has closed, it calls IReplNotify::OnItemNotifywith RNC_SHUTDOWN. The service manager responds by unloading the desktop provider and updating the status display.
The following code examples show how to implement IReplStore::IsItemChangedand IReplStore::IsItemReplicated.
Copy Code | |
---|---|
STDMETHODIMP_(BOOL) CStore::IsItemChanged ( HREPLFLD hFolder, // handle of folder or container that stores object HREPLITEM hItem, // handle of object HREPLITEM hItemComp // handle of object used for comparison ) { CFolder *pFolder = (CFolder*)hFolder; CItem *pItem = (CItem*) hItem; CItem *pItemComp = (CItem*) hItemComp; BOOL fChanged = FALSE; if (pItemComp) fChanged = CompareFileTime (&pItem->m_ftModified, &pItemComp->m_ftModified); else { FILETIME ft; // Read modification time stamp from object into ft. // Compare with the time stamp in the object. fChanged = CompareFileTime (&pItem->m_ftModified, &ft); } return fChanged; } STDMETHODIMP_(BOOL) CStore::IsItemReplicated ( HREPLFLD hFolder, // handle of folder or container that stores object HREPLITEM hItem, // handle of object ) { CFolder *pFolder = (CFolder*)hFolder; CItem *pItem = (CItem*) hItem; // hItem can be NULL. if (pItem == NULL) return TRUE; // Search for the item. Return FALSE if not found. // ... // Check if pItem should be replicated by using information // stored both in pFolder & pItem. If so, return TRUE. // ... return FALSE; } |