ISyncMgrSyncCallback::ReportEvent Method

Provides an event to add to the Sync Results folder for an item being synchronized.

Syntax

HRESULT ReportEvent(      
    LPCWSTR pszItemID,
    SYNCMGR_EVENT_LEVEL nLevel,
    SYNCMGR_EVENT_FLAGS nFlags,
    LPCWSTR pszName,
    LPCWSTR pszDescription,
    LPCWSTR pszLinkText,
    LPCWSTR pszLinkReference,
    LPCWSTR pszContext,
    GUID *pguidEventID
);

Parameters

  • pszItemID
    [in] A pointer to a buffer that contains the unique ID of the item currently being synchronized. This string is of maximum length MAX_SYNCMGR_ID including the terminating null character.
  • nLevel
    [in] A value from the SYNCMGR_EVENT_LEVEL enumeration declaring the type of event involved.
  • nFlags
    [in] Not used.
  • pszName
    [in] A pointer to a buffer that contains the name of the event.
  • pszDescription
    [in] A pointer to a buffer that contains a description of the event.
  • pszLinkText
    [in] A pointer to a buffer that contains the text to be used in a hyperlink to the item. This parameter can be NULL
  • pszLinkReference
    [in] A pointer to a buffer that contains the URL of the item. This parameter can be NULL
  • pszContext
    [in] Handler-specific data to associate with the event.
  • pguidEventID
    [out] When this method returns, contains a pointer to a unique ID for the event.

Return Value

Remarks

For the handler to provide more details to the user about the sync result, the property sheet for individual sync results reported by the handler can be extended.

This method replaces ISyncMgrSynchronizeCallback::LogError.

The event is stored only in memory, so all events are cleared when the user logs off or shuts down. This is one reason to implement a custom ISyncMgrEventStore, which can provide its events from anywhere, including a file, over the network, or the registry. The sync results folder, however, shows events provided both by the internal event store and by custom event stores provided by sync handlers.

Example

The following example shows the usage of ISyncMgrSyncCallback::ReportProgress by the ISyncMgrHandler::Synchronize method.

STDMETHODIMP CMyDeviceHandler::Synchronize(...)
{
    ...
    // Get the event receiver interface.
    ISyncMgrEventReceiver *pEventReceiver = NULL;
    hr = pCallback->QueryInterface(IID_ISyncMgrEventReceiver,
                                   (void **) &pEventReceiver);

    ...

    // Start synchronizing the sync item.

    ...

    // Generate a GUID for this item.
    // Construct a string to display in the Sync Results folder.
    // Store the information about this event so we can display more details.
    // Report the event to Sync Center.
    hr = pEventReceiver->ReportEvent(pszItemID,
                                     SYNCMGR_EL_INFORMATION,
                                     SYNCMGR_EF_NONE,
                                     pszEventName,
                                     pszEventDescription,
                                     NULL,
                                     NULL,
                                     NULL,
                                     &guidEventID);
    ...
}