×
Namespaces

Variants
Actions

显示SyncML进度的状态信息

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

文章
hoolee 在 03 Mar 2009 创建
最后由 hamishwillee 在 15 Dec 2011 编辑

TSS001305


  • 开发伙伴平台:

S60 3rd Edition, FP1


  • 详细描述

这篇文章演示了如何显示一个同步进程的状态信息,和标准SyncML客户端提供的相仿。


MSyncMLProgressObserver类可以用来显示一个SyncML进度的状态。进度框CAknProgressDialog的最终值可以在OnSyncMLSyncProgress()回调函数中设置。当前进度值可以在OnSyncMLDataSyncModifications回调函数中设置。此外,当前任务RSyncMLTask的名字(联系人,日历等)也可以在这里更新。


  • 解决方案

OnSyncMLSyncProgress()(在每个任务中调用)的aInfo1参数,包括:

如果aStatus == ESmlSendingModificationsToServer时发送的全部条目的数目,或

如果aStatus == ESmlReceivingModificationsFromServer时接收的全部条目的数目

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;
}


在OnSyncMLDataSyncModifications()中,更新进度条和当前任务的名称

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
}
}
<code>
 
注意:
 
RSyncMLDataProvider::DisplayName()和RSyncMLTask::DisplayName()返回了某些数据提供者的本地化字符串信息。因此最好使用TSmlDataProviderId来比较或识别目标值。
 
[[Category:Symbian C++]][[Category:Lang-Chinese]]
This page was last modified on 15 December 2011, at 09:16.
85 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×