Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 17:35, 23 June 2008.

How to use observer classes in SyncML data synchronization

From Forum Nokia Wiki

Contents

Purpose

SyncML Client API is SyncML server’s client side API. This provides services to create Data synchronization profile and modify profile values. This also provides services to synchronize data by specifying the profile to be used for synchronizing. This page explains how to use observer classes - MSyncMLEventObserver and MSyncMLProgressObserver provided in SyncMLObservers.h header file.

Example code

Header files

#include <syncmlclient.h>
#include <syncmlclientds.h>
#include <syncmldef.h>
#include <syncmlobservers.h>

Libraries Used

syncmlclientapi.lib

Capabilities

WriteDeviceData ReadDeviceData ReadUserData WriteUserData LocalServices NetworkServices

MSyncMLEventObserver class provides session event notifications and MSyncMLProgressObserver class provides error notifications, progress state notifications and task modification notifications.

Session event notifications: Session event notifications relate to job start and job end, and to profile creation, deletion and modification events. Typically, a notification consists of the event type, ID and error code. If the event type is a job event, the ID is the job ID and if it is a profile event, the ID is the profile ID. The following code gives notifications related to profile events:

// Interface to receive notifications of SyncML session events.
void CSyncMLdsProfAppUi::OnSyncMLSessionEvent(TEvent aEvent, TInt aIdentifier, TInt aError, TInt aAdditionalData )
    {
    TBuf<255> msg;
    msg.Append(_L("Profile Id: "));
    msg.AppendNum(aIdentifier);
    switch(aEvent)
    	{
    		case EProfileCreated:
    		{
    		CEikonEnv::InfoWinL(_L("New Profile Created "),msg);
    		break;		
    		}
    		case EProfileChanged:
    		{
    		CEikonEnv::InfoWinL(_L("Profile config Changed "),msg);		
    		break;
    		}
    		case EProfileDeleted:
    		{
    		CEikonEnv::InfoWinL(_L("Profile Deleted "),msg);		
    		break;
    		}
   	}	
    }

Synchronization error notifications: A synchronization error notification includes information of error level, error code, task ID and additional information. Refer SyncMLErr.h header file for SyncML error values.

// Receives notification of a synchronisation error    
void CSyncHandler::OnSyncMLSyncError(TErrorLevel aErrorLevel, TInt aError,TInt aTaskId, TInt aInfo1, TInt aInfo2)
	{
	if(aErrorLevel == ESmlWarning)
		{	
		CEikonEnv::Static()->InfoWinL(_L("Recieved non-fatal error"),_L("Sync continues"));
		}
		
	else if (aErrorLevel == ESmlFatalError)
		{		
		CEikonEnv::Static()->InfoWinL(_L("Recieved fatal error"),_L("Sync stops"));	
		}
	}

Synchronization progress state notifications: Synchronization progress notifications are events created by synchronization phase changes.

// Receives notifications of SyncML synchronisation progress events	
void CSyncHandler::OnSyncMLSyncProgress(TStatus aStatus, TInt aInfo1, TInt aInfo2)
	{
	iStatus = aStatus;
	
	switch(iStatus)
    	    {
    		case ESmlConnecting:
    		{
    		CEikonEnv::InfoWinL(_L("Connecting to server "),_L(""));
    		break;		
    		}
    		case ESmlConnected:
    		{
    		CEikonEnv::InfoWinL(_L("Connected to server "),_L(""));		
    		break;
    		}
    		case ESmlCompleted:
    		{
    		CEikonEnv::InfoWinL(_L("Sync Completed"),_L(""));		
    		break;
    		}
    		case ESmlDisconnected:
    		{
    		CEikonEnv::InfoWinL(_L("DisConnected from server "),_L(""));		
    		break;
    		}
    		case ESmlLoggingOn:
    		{
    		CEikonEnv::InfoWinL(_L("Logging On to server "),_L(""));		
    		break;
    		}  
    		case ESmlLoggedOn:
    		{
    		CEikonEnv::InfoWinL(_L("Logged On to server "),_L(""));		
    		break;
    		}    	
    	    }   
	}

Synchronization task modification notifications: These notifications are received in synchronization during sending and receiving of task modifications. The notification includes the task ID and count of added, replaced, deleted and moved items since the last notification request.

// Receives notification of modifications to synchronisation tasks.	
void CSyncHandler::OnSyncMLDataSyncModifications(TInt aTaskId,
								 const	TSyncMLDataSyncModifications& aClientModifications,
								 const TSyncMLDataSyncModifications& aServerModifications)
	{
	
	if (iStatus == ESmlReceivingModificationsFromServer)
		{
		//handle aClientModifications
		TBuf<25> bufAdded;
		bufAdded.AppendNum(aClientModifications.iNumAdded);
		CEikonEnv::Static()->InfoWinL(_L("No. of Items added to client: "),bufAdded);			
		// similarly number of items replaced, moved, deleted and failed info can be known.
		}
		
	else if (iStatus == ESmlSendingModificationsToServer)
		{
		//handle aServerModifications
		TBuf<25> bufAdded;
		bufAdded.AppendNum(aServerModifications.iNumAdded);
		CEikonEnv::Static()->InfoWinL(_L("No. of Items added to server: "),bufAdded);
		// similarly number of items replaced, moved, deleted and failed info can be known.
		}
		
	}


Example Application

Sample application for profile event notifications

Internal Links

SyncML Client API

How to create SyncML Data Synchronization profile

How to synchronize in 3rd Edition

Related Discussions
Thread Thread Starter Forum Replies Last Post
Nokia 9300 and 9500 email via SyncML FenDevMan OMA DM/DS/CP 2 2005-07-21 11:10
Bitmap manip and Observer Jeepy General Symbian C++ 6 2003-09-08 20:20
SyncML verson? joy97 OMA DM/DS/CP 3 2004-04-09 19:44
8910i and SyncML zorgaliscious OMA DM/DS/CP 3 2002-12-19 08:21
Problems synchronising with 6680 native sync client burngreg OMA DM/DS/CP 3 2006-07-04 12:50
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZseriesE5f60Q
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX