imservices/xmppsettingsfetcher/src/xmppsettingsfetcher.cpp
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     1 /*
       
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  fetches xmpp settings from settings store 
       
    15 *
       
    16 */
       
    17 
       
    18 #include "xmppsettingsfetcher.h"
       
    19 #include "xmppservicesettingsapi.h"
       
    20 
       
    21 #include "xmppparameters.h"
       
    22 #include <xmppparams.h>
       
    23 
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // CXmppSettingsFetcher::ReadSettings
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 EXPORT_C TInt CXmppSettingsFetcher::ReadSettingsL( TUint32 aSettingsId, CXmppParameters& aParams )
       
    31     {
       
    32     TBool settingsFound = EFalse;
       
    33     RArray<TUint32> settingIdArray;
       
    34     CXmppSettingsApi* api = CXmppSettingsApi::NewLC();
       
    35 
       
    36 	CleanupClosePushL( settingIdArray );
       
    37     api->GetSettingsRecordIdArrayL( settingIdArray );
       
    38 
       
    39 	//first store the settingsid
       
    40 	aParams.SetSettingsId(aSettingsId);
       
    41 
       
    42     for ( TInt i=0; i<settingIdArray.Count(); i++ )
       
    43         {
       
    44         if (settingIdArray[i] == aSettingsId ) //settings id we are looking for
       
    45         	{
       
    46         	//settings with integer values
       
    47 	        TInt paramValueInt(0);
       
    48 	        api->GetParamL( settingIdArray[i], 
       
    49 	        					XmppParams::KXmppParamServerPort(), 
       
    50 	        					paramValueInt );
       
    51 			aParams.SetServerPort(paramValueInt);
       
    52 				                                                    
       
    53 	        api->GetParamL( settingIdArray[i],
       
    54 	        					XmppParams::KXmppParamHttpsProxyServerPort(),
       
    55 								paramValueInt );
       
    56 			aParams.SetProxyPort(paramValueInt);
       
    57 
       
    58 	        api->GetParamL( settingIdArray[i],
       
    59 	        					XmppParams::KXmppParamSnapId(),
       
    60 								paramValueInt );
       
    61 			aParams.SetIapId(paramValueInt);
       
    62 
       
    63         	//settings with boolean values
       
    64 			TBool paramValueBool(EFalse);
       
    65 	        api->GetParamL( settingIdArray[i],
       
    66 	        					XmppParams::KXmppParamOldSSLRequired(),
       
    67 								paramValueBool );
       
    68 			aParams.SetSsl(paramValueBool);
       
    69 			
       
    70         	//settings with descriptor values
       
    71 	        RBuf paramValueBuf;
       
    72 	        paramValueBuf.CreateL( KMaxLength );
       
    73 			paramValueBuf.CleanupClosePushL();
       
    74 
       
    75 	        api->GetParamL( settingIdArray[i],
       
    76 	        					XmppParams::KXmppParamXmppServerAddress(),
       
    77 								paramValueBuf );
       
    78 			aParams.SetServerAddress(paramValueBuf);
       
    79 	        paramValueBuf.Zero();
       
    80 
       
    81 	        api->GetParamL( settingIdArray[i],
       
    82 								XmppParams::KXmppParamUsername(),
       
    83 	                            paramValueBuf );
       
    84 			aParams.SetUserName(paramValueBuf);
       
    85 	        paramValueBuf.Zero();
       
    86 
       
    87 	        api->GetParamL( settingIdArray[i],
       
    88 	        					XmppParams::KXmppParamPassword(),
       
    89 	                            paramValueBuf );
       
    90 			aParams.SetPasswd(paramValueBuf);
       
    91 	        paramValueBuf.Zero();
       
    92 
       
    93 	        api->GetParamL( settingIdArray[i],
       
    94 	        					XmppParams::KXmppParamResource(),
       
    95 	                            paramValueBuf );
       
    96 			aParams.SetResource(paramValueBuf);
       
    97 	        paramValueBuf.Zero();
       
    98 
       
    99 	        api->GetParamL( settingIdArray[i],
       
   100 	        					XmppParams::KXmppParamHttpsProxyServerAddress(),
       
   101 	                            paramValueBuf );
       
   102 			aParams.SetProxyServer(paramValueBuf);
       
   103 			paramValueBuf.Zero();
       
   104 
       
   105 	        api->GetParamL( settingIdArray[i],
       
   106 	        					XmppParams::KXmppParamConnMgrBus(),
       
   107 	                            paramValueBuf );
       
   108 			aParams.SetConnMgrBus(paramValueBuf);
       
   109 			paramValueBuf.Zero();
       
   110 
       
   111 	        api->GetParamL( settingIdArray[i],
       
   112 	        					XmppParams::KXmppParamConnMgrPath(),
       
   113 	                            paramValueBuf );
       
   114 			aParams.SetConnMgrPath(paramValueBuf);
       
   115 			paramValueBuf.Zero();
       
   116 
       
   117 	        api->GetParamL( settingIdArray[i],
       
   118 	        					XmppParams::KXmppParamProtocol(),
       
   119 	                            paramValueBuf );
       
   120 			aParams.SetProtocol(paramValueBuf);
       
   121 
       
   122 	        CleanupStack::PopAndDestroy( &paramValueBuf );
       
   123 			settingsFound = ETrue;
       
   124 	        break;
       
   125         	}
       
   126         }
       
   127 
       
   128     CleanupStack::PopAndDestroy( &settingIdArray );
       
   129     CleanupStack::PopAndDestroy( api );
       
   130     if(!settingsFound)
       
   131     	return KErrNotFound;
       
   132     return KErrNone;
       
   133     }
       
   134 
       
   135 // End of File
       
   136