Contents |
SyncML Client API is SyncML server’s client side API. This provides services to create Data synchronization profile and modify profile values.
Header files
#include <syncmlclient.h>
#include <syncmlclientds.h>
#include <syncmldef.h>
Libraries Used
LIBRARY syncmlclientapi.lib
Capabilities required
Capabilities WriteDeviceData ReadDeviceData ReadUserData WriteUserData
First you need to open a SyncML session:
// DS profile classes
RSyncMLSession syncMLSession;
RSyncMLDataSyncProfile profile;
// Open syncML session
syncMLSession.OpenL();
The following code displays total number of profiles available:
// Displays Number of DS profiles available
void CSyncMLdsProfAppUi::DisplayDSProfileCount()
{
RArray<TSmlProfileId> arr;
// Get the list of available profiles into an array
TRAPD(err, syncMLSession.ListProfilesL(arr, ESmlDataSync));
if (err == KErrNone)
{
TInt count = arr.Count();
TBuf<20> proCount;
proCount.AppendNum(count);
// Displays total number of syncML DS profiles available in device
CEikonEnv::InfoWinL(_L("No. of Profiles available: "),proCount);
}
}
The following code displays profiles information:
// Displays DS profiles information
void CSyncMLdsProfAppUi::DisplayDSProfileInfo()
{
RArray<TSmlProfileId> arr;
TInt count;
// Get the list of available profiles into an array
TRAPD(err, syncMLSession.ListProfilesL(arr, ESmlDataSync));
if (err == KErrNone)
{
count = arr.Count();
}
for (int i=0;i<count;i++)
{
TRAPD(error,profile.OpenL(syncMLSession,arr[i], ESmlOpenReadWrite));
if(KErrNone != error)
{
User::Leave(error);
}
TBuf<50> displayName;
displayName.Append(profile.DisplayName());
CEikonEnv::InfoWinL(_L("Display Name"),displayName);
TBuf8<50> serverID;
serverID.Append(profile.ServerId());
TBuf<50> serverID1;
serverID1.Copy(serverID);
CEikonEnv::InfoWinL(_L("Server Id"),serverID1);
TBuf8<50> userName;
userName.Append(profile.UserName());
TBuf<50> userName1;
userName1.Copy(userName);
CEikonEnv::InfoWinL(_L("User Name"),userName1);
TBuf8<50> passWd;
passWd.Append(profile.Password());
TBuf<50> passWd1;
passWd1.Copy(passWd);
CEikonEnv::InfoWinL(_L("Password"),passWd1);
TSmlProfileId profId;
TBuf<20> profileID;
profId = profile.Identifier();
profileID.AppendNum(profId);
CEikonEnv::InfoWinL(_L("Profile ID"),profileID);
TSmlProtocolVersion protVers;
TBuf<20> protocolVersion;
protVers = profile.ProtocolVersion();
protocolVersion.AppendNum(protVers);
if(ESmlVersion1_1_2 == protVers)
{
CEikonEnv::InfoWinL(_L("Version 1.1.2"),_L(""));
}
else if (ESmlVersion1_2 == protVers)
{
CEikonEnv::InfoWinL(_L("Version 1.2"),_L(""));
}
// To save modifications
profile.UpdateL();
// close profile
profile.Close();
}
}
The following code creates new data synchronization profile and sets profile values:
// Creates new DS profile
void CSyncMLdsProfAppUi::CreateNewDSProfile()
{
RSyncMLDataSyncProfile profile;
// Creates an unnamed Ds profile
profile.CreateL( syncMLSession );
// To set profile display name
profile.SetDisplayNameL(_L("New Profile"));
// To set User name
profile.SetUserNameL(_L8("NewUser"));
// To set password
profile.SetPasswordL(_L8("pwd"));
// To set Protocol Version to be used when synchronizing
TSmlProtocolVersion protocol = ESmlVersion1_2;
profile.SetProtocolVersionL( protocol );
// To sets the server-alerted notification user interaction.
TSmlServerAlertedAction action = ESmlConfirmSync;
profile.SetSanUserInteractionL( action );
// To save modifications
profile.UpdateL();
// close profile
profile.Close();
CEikonEnv::InfoWinL(_L("New Profile "),_L("Created"));
}
Finally close the SyncML session:
// close syncML session
syncMLSession.Close();
An example application to create SyncML data synchronization profile
No related wiki articles found