The service manager automatically detects object changes and deletions by comparing the list of handles that are returned during enumeration with the handles that are saved in Repl.dat. Before starting an enumeration process, the service manager:
If the object has changed, it calls IReplStore::CopyObject to copy the data from the returned handle into the handle that is saved in Repl.dat.
All handles in Repl.dat that remain marked once enumeration is complete represent deleted objects.
To hasten the enumeration process, the desktop provider module can detect and report desktop changes to the service manager in real time. To do this:
The following illustration shows the sequence of real-time notification calls.
The desktop provider module also can call IReplNotify::OnItemNotify with RNC_SHUTDOWN if it detects that the desktop application has closed. The service manager responds by unloading the desktop provider module and updating the status display.
The following code examples show how to implement IReplStore::IsItemChanged and IReplStore::IsItemReplicated.
STDMETHODIMP_(BOOL) CStore::IsItemChanged
(
HREPLFLD hFolder, // Handle of the folder or the container
// that stores the object
HREPLITEM hItem, // Handle of the object
HREPLITEM hItemComp // Handle of the object that is 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 the modification time stamp from the object into ft.
// Compare it with the time stamp given in the object.
fChanged = CompareFileTime( &pItem->m_ftModified, &ft );
}
return fChanged;
}
STDMETHODIMP_(BOOL) CStore::IsItemReplicated
(
HREPLFLD hFolder, // Handle of the folder or the container
// that stores the object
HREPLITEM hItem // Handle of the object
)
{
CFolder *pFolder = (CFolder *)hFolder;
CItem *pItem = (CItem *)hItem;
// hItem can be passed NULL.
if ( pItem == NULL )
return TRUE;
// Search for the item; return FALSE if the item is not found.
// Check if pItem should be replicated by using information stored
//both in pFolder & pItem. If so, return TRUE.
return FALSE;
}