×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    187

    SyncML setting default values

    Hi all,
    I have created New Profile using RSyncMLDataSyncProfile,it is created successfully but how can i set its Host address value in Connections Settings programmatically and also in Applications->Contacts-> how can set defaults values of (i) Include in sync to "Yes" (ii) Remote dataBase value to "Card" and same settings for Calander programatically.can any body provide me a sample example of setting default values.

    I have Set defaults values of Username ,password ,Display Name and Version successfully.

    Regards
    Asif Nazir
    Last edited by Asif Nazir; 2008-06-16 at 11:51.

  2. #2
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: SyncML setting default values

    Hello Asif,
    in fact there's a lack of docs on it, but after all it's not part of standard api ;-)
    I've written this for 3rd Ed MR, i couldn't test it on other versions, but i hope it helps.
    "con" and "cal" are the syncml server sources (values provided by Funambol syncml server, "con" and "caltask" on Mobical syncml server)

    Code:
    void CSyncProfileManager::CreateProfileL(const TDesC& aProfileName, const TDesC8& aUsername, const TDesC8& aPassword, const TDesC8& aServerURI, const TDesC& aIapName)
    {
    	RSyncMLSession syncMLSession;
    	RSyncMLDataSyncProfile syncProfile;
    	
    	TInt err=KErrNone;
    	
    	// open SyncML session
    	TRAP(err,syncMLSession.OpenL());
    	User::LeaveIfError(err);
    	
    	// create a profile
    	TRAP(err,syncProfile.CreateL(syncMLSession));
    	User::LeaveIfError(err);
    	TSmlCreatorId creatorId = _UID3;
    	syncProfile.SetCreatorId(creatorId);
    	
    	TRAP(err, {
    	syncProfile.SetDisplayNameL(aProfileName);
    	syncProfile.SetUserNameL(aUsername);
    	syncProfile.SetPasswordL(aPassword);
    	// protocol version, values are:
    	// ESmlVersion1_1_2 = 1.1.2
    	// ESmlVersion1_2 = 1.2
    	syncProfile.SetProtocolVersionL(ESmlVersion1_1_2);
    	// This is for accepting all sync requests
    	syncProfile.SetSanUserInteractionL(ESmlEnableSync);
    	//syncProfile.DeleteAllowed();
    	// save profile
    	syncProfile.UpdateL();
    	});
    	User::LeaveIfError(err);
    
    	// create and enable tasks (applications)
    	// retrieve needed data provider ids
    	TSmlDataProviderId contactsProvider = -1;
    	TSmlDataProviderId calendarProvider = -1;
    	
    	RArray<TSmlDataProviderId> dataProvidersArr;
    	TRAP(err,syncMLSession.ListDataProvidersL(dataProvidersArr));
    	User::LeaveIfError(err);
    	TInt count = dataProvidersArr.Count();
    	
    	for(int i=0;i<count;i++)
    	{
    		RSyncMLDataProvider dataProvider;
    		TRAP(err,dataProvider.OpenL(syncMLSession,dataProvidersArr[i]));
    		User::LeaveIfError(err);
    		
    		if(dataProvider.DisplayName().Compare(_L("Calendar"))==0)
    		{
    			calendarProvider = dataProvider.Identifier();
    		}
    		else if(dataProvider.DisplayName().Compare(_L("Contacts"))==0)
    		{
    			contactsProvider = dataProvider.Identifier();
    		}
    		dataProvider.Close();
    	}
    	
    	if(contactsProvider == -1)
    		User::Leave(KErrNoContactsProvider);
    	// contacts
    	RSyncMLTask contactsTask;
    	TRAP(err,contactsTask.CreateL(syncProfile,contactsProvider,_L("con"),_L("C:Contacts.cdb")));
    	User::LeaveIfError(err);
    	contactsTask.SetCreatorId(creatorId);
    	
    	TRAP(err,
    	{contactsTask.SetEnabledL(ETrue);
    	contactsTask.SetDisplayNameL(_L("Contacts"));
    	contactsTask.SetDefaultSyncTypeL(ESmlTwoWay);
    	contactsTask.SetFilterMatchTypeL(ESyncMLMatchDisabled);
    	contactsTask.UpdateL();
    	});
    	User::LeaveIfError(err);
    	contactsTask.Close();
    	
    	if(calendarProvider == -1)
    		User::Leave(KErrNoCalendarProvider);
    	// calendar 
    	RSyncMLTask calendarTask;
    	TRAP(err,calendarTask.CreateL(syncProfile,calendarProvider,_L("caltask"),_L("C:Calendar")));
    	User::LeaveIfError(err);
    	calendarTask.SetCreatorId(creatorId);
    	TRAP(err,
    	{calendarTask.SetEnabledL(ETrue);
    	calendarTask.SetDisplayNameL(_L("Calendar"));
    	calendarTask.SetDefaultSyncTypeL(ESmlTwoWay);
    	calendarTask.SetFilterMatchTypeL(ESyncMLMatchDisabled);
    	calendarTask.UpdateL();
    	});
    	User::LeaveIfError(err);
    	
    	calendarTask.Close();
    	
    	// SAVE PROFILE AGAIN to save tasks!!!!
    	TRAP(err,syncProfile.UpdateL());
    	User::LeaveIfError(err);
    
    	// set server URI and IapId
    	// if NSmlIapId = -1, user is asked for IAP
    	// otherwise it is set to the specified IapId
    	// useful property names: NSmlIapId,NSmlIapId2,NSmlIapId3,NSmlIapId4,NSmlUseRoaming,NSmlHTTPAuth,NSmlHTTPUsername,NSmlHTTPPassword
    	RArray<TSmlConnectionId> connArr;
    	TRAP(err,syncProfile.ListConnectionsByConnectionIdL(connArr));
    	User::LeaveIfError(err);
    	TInt count2 = connArr.Count();
    	//TBuf<20> connNumber;
    	//connNumber.AppendNum(count2);
    	//CEikonEnv::InfoWinL(_L("ConnectionNumber:"),connNumber);
    	
    	
    	for(int i=0;i<count2;i++)
    	{
    		RSyncMLConnection syncConnection;
    		TRAP(err,syncConnection.OpenByConnectionIdL(syncProfile,connArr[i]));
    		User::LeaveIfError(err);
    		SetIapIdForConnProperties(aIapName);
    		syncConnection.SetPriority(0);
    		syncConnection.SetRetryCount(0);
    		TRAP(err, {
    		syncConnection.SetServerURIL(aServerURI);
    		syncConnection.SetPropertyL(_L8("NSmlIapId"),iIapId);
    		syncConnection.UpdateL();
    		});
    		User::LeaveIfError(err);
    		syncConnection.Close();
    	}
    	
    	TRAP(err,syncProfile.UpdateL());
    	User::LeaveIfError(err);
    	
    	// close profile
    	syncProfile.Close();
    	
    	// close SyncML session 	
    	syncMLSession.Close();
    
    }
    regards,
    pg

  3. #3
    Registered User
    Join Date
    Dec 2006
    Posts
    187

    Re: SyncML setting default values

    Thanks pavarang: i want to clear some variables

    error: undefined identifier 'KErrNoContactsProvider'
    error: undefined identifier 'KErrNoCalendarProvider'
    error: undefined identifier 'SetIapIdForConnProperties'
    error: undefined identifier 'iIapId'


    can u tell me how can i resolve these.
    Last edited by Asif Nazir; 2008-06-16 at 13:05.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: SyncML setting default values

    Hello,

    error: undefined identifier 'KErrNoContactsProvider'
    error: undefined identifier 'KErrNoCalendarProvider'

    those were errors defined by me, you can delete that line of code and put whatever you want to do if the check in the line before is true

    error: undefined identifier 'SetIapIdForConnProperties'
    error: undefined identifier 'iIapId'

    iIapId is the IapId of the IAP you want to set for the connection, there is plenty of code here on the forum/wiki to obtain it; and SetIapIdForConnProperties was my function to retrive the IapId from the name of the IAP.

    You can delete SetIapIdForConnProperties and use -1 instead of iIapId; this way the IAP setting will result in "Always ask":
    syncConnection.SetPropertyL(_L8("NSmlIapId"),_L8("-1");

    Please don't just copy and paste the code before, but take it as an example of how to try things :-)

    hope it helps
    pg

  5. #5
    Registered User
    Join Date
    Dec 2006
    Posts
    187

    Re: SyncML setting default values

    Above code is creating profile on E61i E61 correctly but not on N96,N95,N95 8gb, it is leaving at if(contactsProvider == -1)
    User::Leave(KErrNoContactsProvider);


    can any body tell me why.

  6. #6
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: SyncML setting default values

    Hello Asif,
    maybe it doesn't find the contact provider with this line of code:

    else if(dataProvider.DisplayName().Compare(_L("Contacts"))==0)

    maybe on N95 the DisplayName is not "Contacts" but something else... try to display it with a cycle through data providers, _something like_:

    Code:
    RArray<TSmlDataProviderId> dataProvidersArr;
    	TRAP(err,syncMLSession.ListDataProvidersL(dataProvidersArr));
    	User::LeaveIfError(err);
    	TInt count = dataProvidersArr.Count();
    	
    	for(int i=0;i<count;i++)
    	{
    		RSyncMLDataProvider dataProvider;
    		TRAP(err,dataProvider.OpenL(syncMLSession,dataProvidersArr[i]));
    		User::LeaveIfError(err);
    		
    CEikonEnv::InfoWinL(_L("DisplayName:"),dataProvider.DisplayName());
    				dataProvider.Close();
    	}

  7. #7
    Registered User
    Join Date
    Dec 2006
    Posts
    187

    Re: SyncML setting default values

    I have already displayed dataProvider.DisplayName() but it is showing some unknown characters .can any body tell me why it is giving like this.ON E61,E61i,N78,5500 & E70 it is giving correct Names.

    code is given below


    TSmlDataProviderId contactsProvider = -1;
    TSmlDataProviderId calendarProvider = -1;
    RArray<TSmlDataProviderId> dataProvidersArr;
    TRAP(err,syncMLSession.ListDataProvidersL(dataProvidersArr));
    User::LeaveIfError(err);
    for(int i=0;i<dataProvidersArr.Count();i++)
    {
    RSyncMLDataProvider dataProvider;
    TRAP(err,dataProvider.OpenL(syncMLSession,dataProvidersArr[i]));
    User::LeaveIfError(err);
    CEikonEnv::InfoWinL(_L(""),dataProvider.DisplayName());
    if(dataProvider.DisplayName().Compare(_L("Calendar"))==0)
    {
    //Calendar
    }
    else if(dataProvider.DisplayName().Compare(_L("Contacts"))==0
    {
    //Contacts
    }
    dataProvider.Close();
    }

  8. #8
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: SyncML setting default values

    Hello,
    RSyncMLDataProvider class also have GetDataStoreNamesL, DefaultDataStoreName and AllowsMultipleDatastore methods, maybe one of them gives you some descriptor consistent across the various devices... ?

    all the best
    pg

  9. #9
    Registered User
    Join Date
    Jun 2008
    Posts
    2

    Re: SyncML setting default values

    Hello,
    Contact provider name is different for N95 phones (it is: C:Contacts.cdb). Calendar provider is called "C:Calendar"
    You can use the DefaultDataStoreName() to compare the name of the datastore, as shown in code below:
    // create and enable tasks (applications)
    // retrieve needed data provider ids
    TSmlDataProviderId contactsProvider = -1;
    TSmlDataProviderId calendarProvider = -1;

    RArray<TSmlDataProviderId> dataProvidersArr;
    TRAP(err,syncMLSession.ListDataProvidersL(dataProvidersArr));
    User::LeaveIfError(err);
    TInt count = dataProvidersArr.Count();

    for(int i=0;i<count;i++)
    {
    RSyncMLDataProvider dataProvider;
    TRAP(err,dataProvider.OpenL(syncMLSession,dataProvidersArr[i]));
    User::LeaveIfError(err);

    if(dataProvider.DefaultDataStoreName().Compare(_L("C:Contacts.cdb"))==0)
    {
    calendarProvider = dataProvider.Identifier();
    }
    else if(dataProvider.DefaultDataStoreName().Compare(_L("C:Calendar"))==0)
    {
    contactsProvider = dataProvider.Identifier();
    }
    dataProvider.Close();
    }
    Last edited by am_ran32; 2008-07-15 at 12:57. Reason: Added proper code tag

  10. #10
    Registered User
    Join Date
    Jul 2008
    Posts
    1

    Re: SyncML setting default values

    Hello,

    I have a few questions to pavarang:
    -How did you get the information about the "NSmlIapId" parameter.
    -I need to pass additional device specific data in the SyncML message. How can I do that on Symbian?
    Do you know if some parameters allows to set the Device ID value or any other value of the the syncML header? (I mean IMEI:xxxxxxxxxxx)

    Thanks for your previous help, it was really usefull.

  11. #11
    Registered User
    Join Date
    Jan 2005
    Location
    Italy
    Posts
    639

    Re: SyncML setting default values

    Hello Trulio,
    as for your first question:
    i manually configured a working profile on the phone, for Mobical or Funambol free servers, for example; then i peeked into the APIs and displayed all possible values, something like this (take it only as a bare example!):

    Code:
    void CSyncProfileManager::TestL(void)
    {
    	//CSyncMLTransportPropertiesArray* propArr;
    	
    	RSyncMLSession syncMLSession;
    	RSyncMLDataSyncProfile syncProfile;
    	TSmlProfileId  profileId = -1;
    	TInt err;
    	
    	// open SyncML session
    	TRAP(err,syncMLSession.OpenL());
    	User::LeaveIfError(err);
    		
    	// find the specified profile
    	RArray<TSmlProfileId> profileArr;
    	TRAP(err,syncMLSession.ListProfilesL(profileArr,ESmlDataSync));
    	User::LeaveIfError(err);
    	TInt count = profileArr.Count();
    	for(int i=0;i<count;i++)
    	{
    		TRAP(err,syncProfile.OpenL(syncMLSession,profileArr[i],ESmlOpenRead));
    		User::LeaveIfError(err);
    		if(syncProfile.DisplayName().Compare(_L("Mobical"))== 0)
    		{
    			CEikonEnv::InfoWinL(_L("Found profile!"),_L(""));
    			profileId = syncProfile.Identifier();
    			syncProfile.Close();
    			break;
    		}
    		syncProfile.Close();
    	}
    	
    	if(profileId == -1)
    		User::Leave(KErrNoProfile);
    	
    	syncProfile.OpenL(syncMLSession,profileId,ESmlOpenRead);
    	
    	// find all connections
    	/*
    	RArray<TSmlTransportId> transportArr;
    	TRAP(err,syncProfile.ListConnectionsL(transportArr));
    	User::LeaveIfError(err);
    	TInt count2 = transportArr.Count();
    	TBuf<20> connNumber;
    	connNumber.AppendNum(count2);
    	CEikonEnv::InfoWinL(_L("ConnectionNumber:"),connNumber);
    	
    	for(int i=0;i<count2;i++)
    	{
    		RSyncMLTransport syncTransport;
    		
    		TRAP(err,syncTransport.OpenL(syncMLSession,transportArr[i]));
    		User::LeaveIfError(err);
    		
    		CEikonEnv::InfoWinL(_L("transport name"),syncTransport.DisplayName());
    		
    		TInt count3 = syncTransport.Properties().Count();
    		TBuf<32> propCount;
    		propCount.AppendNum(count3);
    		CEikonEnv::InfoWinL(_L("properties count"),propCount);
    		for(i=0;i<count3;i++)
    		{
    			TBuf<KSmlMaxTransportPropertyNameLen> propName;
    			propName.Copy(syncTransport.Properties().At(i).iName);
    			CEikonEnv::InfoWinL(_L("name:"),propName);
    			//
    			// found properties:
    			// NSmlIapId (-1: always ask; otherwise IapId)
    			// NSmlIapId2
    			// NSmlIapId3
    			// NSmlIapId4
    			// NSmlUseRoaming
    			// NSmlHTTPAuth
    			// NSmlHTTPUsername
    			// NSmlHTTPPassword
    			//
    			
    			if(propName.Compare(_L("NSmlIapId"))==0)
    			{
    				CEikonEnv::InfoWinL(_L("gotcha"),_L(""));
    				
    				RSyncMLConnection syncConnection;
    				syncConnection.OpenL(syncProfile,syncTransport.Identifier());
    				TBuf<KSmlMaxTransportPropertyNameLen> propValue;
    				propValue.Copy(syncConnection.GetPropertyL(syncTransport.Properties().At(i).iName));
    				CEikonEnv::InfoWinL(_L("NSmlIapId:"),propValue);
    				syncConnection.Close(); 
    			}
    		}
    		syncTransport.Close();
    		
    	} */
    	RArray<TSmlConnectionId> connArr;
    	TRAP(err,syncProfile.ListConnectionsByConnectionIdL(connArr));
    	User::LeaveIfError(err);
    	TInt count2 = connArr.Count();
    	TBuf<20> connNumber;
    	connNumber.AppendNum(count2);
    	CEikonEnv::InfoWinL(_L("ConnectionNumber:"),connNumber);
    	
    	for(int i=0;i<count2;i++)
    	{
    		RSyncMLConnection syncConnection;
    		syncConnection.OpenByConnectionIdL(syncProfile,connArr[i]);
    		
    		TBuf<128> serverURI;
    		serverURI.Copy(syncConnection.ServerURI());
    		CEikonEnv::InfoWinL(_L("ServerURI:"),serverURI);
    		
    		TBuf<20> p;
    		TUint priority = syncConnection.Priority();
    		p.AppendNum(priority);
    		CEikonEnv::InfoWinL(_L("Priority:"),p);
    		
    		TBuf<20> r;
    		TUint retry = syncConnection.RetryCount();
    		r.AppendNum(retry);
    		CEikonEnv::InfoWinL(_L("Retry:"),r);
    		
    		TSmlTransportId transportId;
    		transportId = syncConnection.Identifier();
    		RSyncMLTransport syncTransport;
    		syncTransport.OpenL(syncMLSession,transportId);
    		CEikonEnv::InfoWinL(_L("transportName:"),syncTransport.DisplayName());
    		
    		syncTransport.Close();
    		syncConnection.Close();
    	}
    	
    	syncProfile.Close();
    	syncMLSession.Close();
    }
    as for your second question, i don't know, i didn't need such functionality

    all the best
    pg

  12. #12
    Registered User
    Join Date
    Mar 2003
    Posts
    23

    Re: SyncML setting default values

    That's a great bit of code right there:

    Code:
    	// open SyncML session
    	TRAP(err,syncMLSession.OpenL());
    	User::LeaveIfError(err);
    You might want to do a bit of reading around CleanupClosePushL too.

  13. #13
    Regular Contributor
    Join Date
    Jun 2007
    Location
    Jakarta, Indonesia
    Posts
    269

    Re: SyncML setting default values

    Hi pavarang & all


    Thanks to pavarang's sharing, i have succeeded in creating sync profiles in 3rd edition.

    Just one question again. How can i set the port used for the host server?

  14. #14
    Regular Contributor
    Join Date
    Jun 2007
    Location
    Jakarta, Indonesia
    Posts
    269

    Re: SyncML setting default values

    its ok i have it worked out

    RSyncMLConnection::SetServerURIL with http://yourserver:8080 will set the port to 8080

  15. #15
    Registered User
    Join Date
    Dec 2006
    Posts
    187

    Thumbs down Re: SyncML setting default values

    Hi,

    I have created New Profile using RSyncMLDataSyncProfile succesfully and also sets

    .Host address value in Connections Settings
    .In Applications->Contacts-> i have set defaults values of
    (i) Include in sync to "Yes"
    (ii) Remote dataBase value to "Card"

    After settings default values how can i Update its default Values of Applications->Contacts->
    (i) Include in sync to "No"


    Regards
    Asif Nazir

Similar Threads

  1. Two-line setting & Multi-selection list setting items
    By azavor in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-06-04, 19:39
  2. Nokia 3660 SyncML Setting
    By adywicaksono in forum OMA DM/DS/CP
    Replies: 5
    Last Post: 2007-05-03, 11:15
  3. Replies: 0
    Last Post: 2006-10-16, 17:31
  4. SyncML setting provisioning with DM
    By slavaCh in forum OMA DM/DS/CP
    Replies: 1
    Last Post: 2006-10-12, 12:14
  5. Setting CBA default button dynamically
    By cl_errorcode11 in forum Symbian User Interface
    Replies: 1
    Last Post: 2001-12-05, 20:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×