×
Namespaces

Variants
Actions

Archived:Showing progress details of the SyncML process using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Article Metadata
Tested with
Devices(s): Nokia N95, Nokia E71
Compatibility
Platform(s): S60 3rd Edition, FP1
S60 3rd Edition FP1
Article
Keywords: SyncML, MSyncMLProgressObserver
Created: User:Technical writer 1 (12 Feb 2009)
Last edited: hamishwillee (15 Jun 2012)

Contents

Overview

This article demonstrates how to display progress information of a synchronisation process, similar to what the standard SyncML client provides.


Description

The MSyncMLProgressObserver class can be used to show the progress details of a SyncML process.

The final value of the progress bar (CAknProgressDialog) can be set in the OnSyncMLSyncProgress() callback function.

The current progress value can be set in the OnSyncMLDataSyncModifications callback. In addition, the name of the current task (RSyncMLTask) (Contacts, Calendar etc) can be updated here.


Solution

The aInfo1 parameter in OnSyncMLSyncProgress() (called for each task) contains

  • Total number of entries to be sent if {{{1}}}, or
  • Total number of entries to be received if {{{1}}}
 void CMySyncHandler::OnSyncMLSyncProgress( TStatus aStatus,
TInt aInfo1,
TInt /*aInfo2*/ )
{
switch( aStatus )
{
case ESmlSendingModificationsToServer:
iProgressInfo->SetFinalValue( aInfo1 );
break;
 
// Similarly for ESmlReceivingModificationsFromServer
 
// If a wait note is used, update its display
// according to other status values
}
 
iStatus = aStatus;
}

In OnSyncMLDataSyncModifications(), update the progress bar and current task name.

 void CMySyncHandler::OnSyncMLDataSyncModifications( TInt aTaskId, 
const TSyncMLDataSyncModifications& aClientModifications,
const TSyncMLDataSyncModifications& aServerModifications )
{
// Trap the call to implementation that may leave
TRAPD(err, OnSyncMLDataSyncModificationsL( aTaskId,
aClientModifications,
aServerModifications) );
if(err != KErrNone)
{
// Handle errors
}
}
 
 
void CMySyncHandler::OnSyncMLDataSyncModificationsL( TInt aTaskId,
const TSyncMLDataSyncModifications& aClientModifications,
const TSyncMLDataSyncModifications& aServerModifications )
{
RSyncMLDataSyncProfile profile;
RSyncMLTask task;
 
// iProfileId is the ID of SyncML profile in use
profile.OpenL( iSyncMLSession, iProfileId, ESmlOpenRead);
task.OpenL( profile, (TSmlTaskId)aTaskId );
 
if ( iStatus == ESmlReceivingModificationsFromServer )
{
TSmlDataProviderId dataProviderId = task.DataProvider();
RSyncMLDataProvider dataProvider;
dataProvider.OpenL(syncMLSession,dataProviderId);
TBuf<256> dataProBuf;
dataProBuf.Copy(dataProvider.DisplayName());
dataProBuf.Append(_L(": Receiving..."));
TInt mods = aClientModifications.iNumAdded
+ aClientModifications.iNumReplaced
+ aClientModifications.iNumMoved
+ aClientModifications.iNumDeleted
+ aClientModifications.iNumFailed;
 
// Update dialog text and increment the progress bar
iProgressDialog->SetTextL(dataProBuf);
iProgressInfo->SetAndDraw(mods);
}
else if( iStatus == ESmlSendingModificationsToServer )
{
// As above
}
}


Notes:

RSyncMLDataProvider::DisplayName() and RSyncMLTask::DisplayName() return localised strings for some data providers. Therefore it is better to use TSmlDataProviderId for comparison or identification purposes.

See also

SyncML Client API

This page was last modified on 15 June 2012, at 03:51.
65 page views in the last 30 days.
×