omadm/omadmextensions/adapters/syncmldm/inc/NSmlDMSettingsAdapter.h
changeset 0 3ce708148e4d
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 /*
       
     2 * Copyright (c) 2005 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:    DM Settings adapter header file
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __NSMLDMSETTINGSADAPTER_H__
       
    22 #define __NSMLDMSETTINGSADAPTER_H__
       
    23 
       
    24 
       
    25 // INCLUDES
       
    26 #include <utf.h>
       
    27 #include <smldmadapter.h>
       
    28 #include <SyncMLClientDM.h>
       
    29 #include "NSmlPrivateAPI.h"
       
    30 
       
    31 // CONSTANTS
       
    32 const TInt KNSmlDMGranularity = 4;
       
    33 const TUint8 KNSmlDMColon = ':';
       
    34 const TUint8 KNSmlDMUriSeparator = '/';
       
    35 const TInt KPortMaxSize = 65535;
       
    36 const TInt KPortMinSize = 0;
       
    37 //Dynamic Node Posn Const --> SyncML/DMAcc/DMIDxxx
       
    38 const TInt KDynNodePosn = 3;
       
    39 
       
    40 //DDF accepted DM-fieldnames
       
    41 _LIT8( KNSmlDdfId,				"Id" );
       
    42 _LIT8( KNSmlDdfAddr,			"Addr" );
       
    43 _LIT8( KNSmlDdfAddrType,		"AddrType" );
       
    44 _LIT8( KNSmlDdfPortNbr,			"PortNbr" );
       
    45 _LIT8( KNSmlDdfAuthScheme,		"AuthPref" ); 
       
    46 _LIT8( KNSmlDdfServerId,		"ServerId" );
       
    47 _LIT8( KNSmlDdfServerPW,		"ServerPW" );
       
    48 _LIT8( KNSmlDdfServerNonce,		"ServerNonce" );
       
    49 _LIT8( KNSmlDdfClientUserName,	"UserName" );
       
    50 _LIT8( KNSmlDdfClientPW,		"ClientPW" );
       
    51 _LIT8( KNSmlDdfClientNonce,		"ClientNonce" );
       
    52 _LIT8( KNSmlDdfName,			"Name" );
       
    53 _LIT8( KNSmlDdfConRef,			"ConRef" );
       
    54 _LIT( KNSmlDdfMConRef,			"MConRef" );
       
    55 
       
    56 //DDF DM-field descriptions
       
    57 _LIT8( KNSmlDdfAddrDescription,				"Host address of the SyncML server, IP or URL" );
       
    58 _LIT8( KNSmlDdfAddrTypeDescription,			"The type of address specified in the Addr node" );
       
    59 _LIT8( KNSmlDdfPortNbrDescription,			"SyncML Server port" );
       
    60 _LIT8( KNSmlDdfAuthSchemeDescription,		"Scheme of authentication" );
       
    61 _LIT8( KNSmlDdfServerIdDescription,			"The ServerId value for this server" );
       
    62 _LIT8( KNSmlDdfServerPWDescription,			"The password or secret that the server will use to authenticate itself to the client" );
       
    63 _LIT8( KNSmlDdfServerNonceDescription,		"The next nonce that the server will use to authenticate itself to the client" );
       
    64 _LIT8( KNSmlDdfClientUserNameDescription,	"The username of the device (or user)" );
       
    65 _LIT8( KNSmlDdfClientPWDescription,			"The password or secret that the client will use to authenticate itself to the server" );
       
    66 _LIT8( KNSmlDdfClientNonceDescription,		"The next nonce that the client will use to authenticate itself to the server" );
       
    67 _LIT8( KNSmlDdfNameDescription,				"Displayable name for the SyncML setings" );
       
    68 _LIT8( KNSmlDdfConRefDescription,			"Logical reference to a connectivity node" );
       
    69 _LIT( KNSmlDdfMConRefDescription,			"Parent to Multiple Connection Reference objects" );
       
    70 
       
    71 //Default data values
       
    72 _LIT( KNSmlDefName,				"DMAdapterIns" );
       
    73 _LIT8( KNSmlDefDMAcc,			"DMAcc" );
       
    74 _LIT8( KNSmlDMStart,			"SyncML/DMAcc/DMId" );
       
    75 _LIT( KNSmlDefDMIAP,			"AP" );
       
    76 _LIT8( KNSmlDMUriDotSlash,      "./");
       
    77 _LIT8( KNSmlDMNullDesc8,        "");
       
    78 _LIT8(KNSmlIAPId,               "NSmlIapId");
       
    79 
       
    80 // AuthPref text values
       
    81 _LIT8( KNSmlDMAuthPrefNoAuth,"syncml:auth-none");
       
    82 _LIT8( KNSmlDMAuthPrefBasic, "syncml:auth-basic");
       
    83 _LIT8( KNSmlDMAuthPrefMD5,	 "syncml:auth-md5");
       
    84 
       
    85 _LIT8( KNSmlDMSettingsHTTP,  "http://" );
       
    86 _LIT8( KNSmlDMSettingsHTTPS, "https://" );
       
    87 
       
    88 _LIT8( KIAPid, "IAPid" );
       
    89 _LIT8( KSegmDMAcc,"Addr/AddrType/PortNbr/AuthPref/ServerId/ServerPW/ServerNonce/UserName/ClientPW/ClientNonce/Name/ConRef");
       
    90 _LIT8( KSmlDmSlash, "/");
       
    91 _LIT8( KVersion,"1.1" );
       
    92 _LIT8( KMimeType, "text/plain" );
       
    93 _LIT8( KSyncMLText, "SyncML" );
       
    94 _LIT8( KNSmlDMadapterDesc, "DM-Settings DDF description" );
       
    95 _LIT8( KNSmlDMadapterTitle,"DM-Settings title" );
       
    96 _LIT8( KDmAccMatch, "SyncML/DMAcc/*" );
       
    97 _LIT8( KDmAccMatch2, "SyncML/DMAcc" );
       
    98 
       
    99 
       
   100 // DATA TYPES
       
   101 enum TNSmlDMFieldType
       
   102 	{
       
   103 	EStr,
       
   104 	EInt,
       
   105 	EBin,
       
   106 	EWrong
       
   107 	};
       
   108 
       
   109 enum TNSmlDMLeafType
       
   110 	{
       
   111 	EDMUpdate,
       
   112 	EDMDelete,
       
   113 	EDMUnset
       
   114 	};
       
   115 
       
   116 enum TNSmlDMProfileData
       
   117 	{
       
   118 	EProfileId,
       
   119 	EProfileName,
       
   120 	EProfileIAPId,
       
   121 	EProfileMediumType,
       
   122 	EProfileDMServerUsername,
       
   123 	EProfileDMServerPassword,
       
   124 	EServerNonce,
       
   125 	ESharedSecret,
       
   126 	EClientNonce,
       
   127 	EProfileURL,
       
   128 	EProfilePort,
       
   129 	EServerId,
       
   130 	EAuthenticationRequired,
       
   131 	ESyncAccepted
       
   132 	};
       
   133 
       
   134 enum TAuthenticationType
       
   135 	{
       
   136 	ENoAuth,    //"syncml:auth-none"
       
   137 	EBasic,     //"syncml:auth-basic"
       
   138 	EMD5        //"syncml:auth-md5"
       
   139 	};
       
   140 
       
   141 enum TNSmlDMMediumType
       
   142 	{
       
   143 	ENone,
       
   144     EHttp,
       
   145 	EWsp,
       
   146     EObex
       
   147 	};
       
   148 
       
   149 struct TNSmlDMLeafElement
       
   150 	{
       
   151 	HBufC8 *iUri;
       
   152 	HBufC8 *iData;
       
   153 	TInt iStatusRef;
       
   154 	HBufC8* iLuid;
       
   155 	};
       
   156 
       
   157 struct TNSmlDMBufferElement
       
   158 	{
       
   159 	CArrayFixFlat<TNSmlDMLeafElement> *iLeafBuf;
       
   160 	HBufC8* iMappingName; //Holds the Dyn.Node URI
       
   161 	TBool iExecuted; //Node updated to dB or not
       
   162 	TInt iDMBuffStatusref; //Statusref for callback
       
   163 	TBool iAddr;
       
   164 	TBool iServerId; //Bools for Mandatory fields
       
   165 	TBool iUName;
       
   166 	TBool iServerName;
       
   167 	};
       
   168 // CLASS DECLARATION
       
   169 /**
       
   170 *  CNSmlDMSettingsAdapter class 
       
   171 *  Contains the whole implementation of the DM settings adapter.
       
   172 *
       
   173 *  @lib nsmldmsettingsadapter.dll
       
   174 *  @since Series 60 Series60_3.0
       
   175 */
       
   176 class CNSmlDMSettingsAdapter : public CSmlDmAdapter
       
   177 	{
       
   178     public: // Constructors and destructor
       
   179         
       
   180         /**
       
   181         * Two-phased constructor.
       
   182         */
       
   183 	    static CNSmlDMSettingsAdapter* NewL(MSmlDmCallback* aDmCallback );
       
   184 	    static CNSmlDMSettingsAdapter* NewLC(MSmlDmCallback* aDmCallback );
       
   185 
       
   186 	    void ConstructL();
       
   187 
       
   188         /**
       
   189         * Destructor.
       
   190         */
       
   191 	    virtual ~CNSmlDMSettingsAdapter();
       
   192 
       
   193     public: // Functions from base classes
       
   194 
       
   195 	    /**
       
   196         * From      CSmlDmAdapter   DDFVersionL returns current version of the DDF.
       
   197         * @since    Series60_3.0
       
   198         * @param    aVersion        DDF version of the adapter.
       
   199         * @return   none
       
   200         */
       
   201 	    void DDFVersionL( CBufBase& aVersion );
       
   202 
       
   203         /**
       
   204         * From      CSmlDmAdapter   DDFStructureL for filling the DDF structure of the adapter.
       
   205         * @since    Series60_3.0
       
   206         * @param    aDDF            Reference to root object.
       
   207         * @return   none
       
   208         */
       
   209 	    void DDFStructureL( MSmlDmDDFObject& aDDF );
       
   210 
       
   211         /**
       
   212         * From      CSmlDmAdapter   UpdateLeafObjectL creates new leaf objects, or replaces 
       
   213         *                           data in existing leaf objects.
       
   214         * @since    Series60_3.0
       
   215         * @param    aURI            URI of the object
       
   216         * @param    aLUID           LUID of the object
       
   217         * @param    aObject         Data of the object
       
   218         * @param    aType           MIME type of the object
       
   219         * @param    aStatusRef      Reference to correct command
       
   220         * @return   none
       
   221         */
       
   222 	    void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, 
       
   223                             const TDesC8& aObject, const TDesC8& aType, 
       
   224                             TInt aStatusRef );
       
   225         
       
   226         /**
       
   227         * From      CSmlDmAdapter   DeleteObjectL deletes an object and its child objects.
       
   228         * @since    Series60_3.0
       
   229         * @param    aURI            URI of the object
       
   230         * @param    aLUID           LUID of the object
       
   231         * @param    aStatusRef      Reference to correct command
       
   232         * @return   none
       
   233         */
       
   234 	    void DeleteObjectL( const TDesC8& aURI, const TDesC8& aLUID, 
       
   235                         const TInt aStatusRef );
       
   236         
       
   237         /**
       
   238         * From      CSmlDmAdapter   FetchLeafObjectL fetches data of a leaf object.
       
   239         * @since    Series60_3.0
       
   240         * @param    aURI            URI of the object
       
   241         * @param    aLUID           LUID of the object
       
   242         * @param    aType           MIME type of the object
       
   243         * @param    aResultsRef    	Reference to correct results
       
   244         * @param    aStatusRef      Reference to correct command
       
   245         * @return   none
       
   246         */
       
   247 	    void FetchLeafObjectL(  const TDesC8& aURI, 
       
   248                             const TDesC8& aLUID, 
       
   249                             const TDesC8& aType, 
       
   250                             const TInt aResultsRef, 
       
   251                             const TInt aStatusRef ); 
       
   252         /**
       
   253         * From      CSmlDmAdapter   ChildURIListL fetches URI list.
       
   254         * @since    Series60_3.0
       
   255         * @param    aURI                    URI of the object
       
   256         * @param    aLUID                   LUID of the object
       
   257         * @param    aPreviousURISegmentList URI list with mapping LUID information
       
   258         * @param    aResultsRef    	        Reference to correct results
       
   259         * @param    aStatusRef              Reference to correct command
       
   260         * @return   none
       
   261         */
       
   262 	    void ChildURIListL( const TDesC8& aURI, const TDesC8& aLUID, 
       
   263                         const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, 
       
   264                         const TInt aResultsRef, const TInt aStatusRef );
       
   265         
       
   266         /**
       
   267         * From      CSmlDmAdapter   AddNodeObjectL adds node object.
       
   268         * @since    Series60_3.0
       
   269         * @param    aURI            URI of the object
       
   270         * @param    aParentLUID     LUID of the parent object
       
   271         * @param    aStatusRef      Reference to correct command
       
   272         * @return   none
       
   273         */
       
   274 	    void AddNodeObjectL( const TDesC8& aURI, const TDesC8& aParentLUID, 
       
   275                             const TInt aStatusRef );
       
   276 
       
   277         /**
       
   278         * From      CSmlDmAdapter   UpdateLeafObjectL creates new leaf objects, or replaces 
       
   279         *                           data in existing leaf objects.
       
   280         * @since    Series60_3.0
       
   281         * @param    aURI            URI of the object
       
   282         * @param    aLUID           LUID of the object
       
   283         * @param    aStream         Data of the object
       
   284         * @param    aType           MIME type of the object
       
   285         * @param    aStatusRef      Reference to correct command
       
   286         * @return   none
       
   287         */
       
   288         void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, 
       
   289                             RWriteStream*& aStream, const TDesC8& aType, 
       
   290                             const TInt aStatusRef );
       
   291         
       
   292         /**
       
   293         * From      CSmlDmAdapter   FetchLeafObjectSizeL fetches the size of a leaf object.
       
   294         * @since    Series60_3.0
       
   295         * @param    aURI            URI of the object
       
   296         * @param    aLUID           LUID of the object
       
   297         * @param    aType           MIME type of the object
       
   298         * @param    aResultsRef    	Reference to correct results
       
   299         * @param    aStatusRef      Reference to correct command
       
   300         * @return   none
       
   301         */
       
   302 	    void FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& aLUID, 
       
   303                                 const TDesC8& aType, const TInt aResultsRef, 
       
   304                                 const TInt aStatusRef );
       
   305 
       
   306         /**
       
   307         * From      CSmlDmAdapter   The function implements execute command.
       
   308         * @since    Series60_3.0
       
   309         * @param    aURI            URI of the object
       
   310         * @param    aLUID           LUID of the object
       
   311         * @param    aArgument       Argument for the command
       
   312         * @param    aType       	MIME type of the object
       
   313         * @param    aStatusRef      Reference to correct command
       
   314         * @return   none
       
   315         */
       
   316 	    void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, 
       
   317                             const TDesC8& aArgument, const TDesC8& aType, 
       
   318                             const TInt aStatusRef );
       
   319 
       
   320         /**
       
   321         * From      CSmlDmAdapter   The function implements execute command.
       
   322         * @since    Series60_3.0
       
   323         * @param    aURI            URI of the object
       
   324         * @param    aLUID           LUID of the object
       
   325         * @param    aStream         Argument for the command
       
   326         * @param    aType       	MIME type of the object
       
   327         * @param    aStatusRef      Reference to correct command
       
   328         * @return   none
       
   329         */
       
   330 	    void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, 
       
   331                             RWriteStream*& aStream, const TDesC8& aType, 
       
   332                             const TInt aStatusRef );
       
   333         
       
   334         /**
       
   335         * From      CSmlDmAdapter   The function implements execute command.
       
   336         * @since    Series60_3.0
       
   337         * @param    aTargetURI      Target URI for the command
       
   338         * @param    aTargetLUID     LUID of the target object
       
   339         * @param    aSourceURI      Source URI for the command
       
   340         * @param    aSourceLUID    	LUID of the source object
       
   341         * @param    aType           MIME type of the object
       
   342         * @param    aStatusRef      Reference to correct command
       
   343         * @return   none
       
   344         */
       
   345 	    void CopyCommandL( const TDesC8& aTargetURI, const TDesC8& aTargetLUID, 
       
   346                         const TDesC8& aSourceURI, const TDesC8& aSourceLUID, 
       
   347                         const TDesC8& aType, TInt aStatusRef );
       
   348 	
       
   349         /**
       
   350         * From      CSmlDmAdapter   The function indicates start of Atomic command.
       
   351         * @since    Series60_3.0
       
   352         * @param    none
       
   353         * @return   none
       
   354         */
       
   355         void StartAtomicL();
       
   356 
       
   357         /**
       
   358         * From      CSmlDmAdapter   The function indicates successful end of Atomic command.
       
   359         * @since    Series60_3.0
       
   360         * @param    none
       
   361         * @return   none
       
   362         */
       
   363 	    void CommitAtomicL();
       
   364     
       
   365         /**
       
   366         * From      CSmlDmAdapter   The function indicates unsuccessful end of Atomic command.
       
   367         * @since    Series60_3.0
       
   368         * @param    none
       
   369         * @return   none
       
   370         */
       
   371 	    void RollbackAtomicL();
       
   372 
       
   373         /**
       
   374         * From      CSmlDmAdapter   Returns ETrue if adapter supports streaming otherwise EFalse.
       
   375         * @since    Series60_3.0
       
   376         * @param    aItemSize       Size limit for stream usage.
       
   377         * @return   ETrue or EFalse
       
   378         */
       
   379 	    TBool StreamingSupport( TInt& aItemSize );
       
   380         
       
   381         /**
       
   382         * From      CSmlDmAdapter   Called when stream returned from UpdateLeafObjectL or 
       
   383         *                           ExecuteCommandL has been written to and committed.
       
   384         * @since    Series60_3.0
       
   385         * @param    none
       
   386         * @return   none
       
   387         */
       
   388 	    void StreamCommittedL();
       
   389 
       
   390         /**
       
   391         * From      CSmlDmAdapter   The function tells the adapter that all the commands of the message that
       
   392 	    *                           can be passed to the adapter have now been passed.
       
   393         * @since    Series60_3.0
       
   394         * @param    none
       
   395         * @return   none
       
   396         */
       
   397 	    void CompleteOutstandingCmdsL();
       
   398 	
       
   399     private:
       
   400 	    
       
   401         /**
       
   402         * C++ default constructor.
       
   403         */
       
   404         CNSmlDMSettingsAdapter();
       
   405         CNSmlDMSettingsAdapter( TAny* aEcomArguments );
       
   406 	    
       
   407         /**
       
   408         * The function stores integer value to buffer and returns reference to it.
       
   409         * @param    aObject     data to be stored to buffer.
       
   410         * @return   reference to data buffer.
       
   411         */
       
   412         TDesC8& SetIntObjectLC( const TInt& aObject );
       
   413         
       
   414         /**
       
   415         * The function finds out the last element of the uri.
       
   416         * @param    aSource     Uri object that contains all elements.
       
   417         * @return   KErrNone if successful.
       
   418         */
       
   419 	    TInt SetField( const TDesC8& aSource );
       
   420 
       
   421         /**
       
   422         * The function converts data to integer and returns it.
       
   423         * @param    aObject     Data object to be converted.
       
   424         * @return   Integer value for an object.
       
   425         */
       
   426 	    TInt GetIntObject( const TDesC8& aObject );
       
   427 
       
   428         /**
       
   429         * The function converts data to integer and returns it.
       
   430         * @param    aObject     Data object to be converted.
       
   431         * @return   16-bit integer value for an object.
       
   432         */
       
   433 	    TInt GetIntObject16( const TDesC& aObject );
       
   434 
       
   435         /**
       
   436         * The function converts LUID to integer.
       
   437         * @param    aLUID     LUID data to be converted.
       
   438         * @return   Integer value for a LUID.
       
   439         */    
       
   440 	    TInt IntLUID( const TDesC8& aLUID );
       
   441 
       
   442         /**
       
   443         * The function sets the IAP value acording the given URI.
       
   444         * @param    aLUID     LUID for a profile.
       
   445         * @param    aObject   Data object containing the URI.
       
   446         * @return   KErrNone if successfull.
       
   447         */    
       
   448 	    TInt  SetConRefL( const TInt aLUID, const TDesC8& aObject );
       
   449     
       
   450         /**
       
   451         * The function gets the URI for profile IAP.
       
   452         * @param    aObject   Object where the result will be stored.
       
   453         * @return   KErrNone if successfull.
       
   454         */    
       
   455 	    TInt GetConRefL( CBufBase& aObject );
       
   456 	
       
   457         /**
       
   458         * The function checks if field to be handled is valid.
       
   459         * @param    none
       
   460         * @return   ETrue if valid field otherwise EFalse.
       
   461         */    
       
   462     	TBool AcceptDMField();
       
   463 
       
   464         /**
       
   465         * The function checks if field type to be handled is valid.
       
   466         * @param    none
       
   467         * @return   enum value for a field type.
       
   468         */ 
       
   469 	    TNSmlDMFieldType   GetDMFieldType() const;
       
   470 
       
   471         /**
       
   472         * The function returns enum value for a field to be handled.
       
   473         * @param    none
       
   474         * @return   enum value for a field to be handled.
       
   475         */ 
       
   476 	    TNSmlDMProfileData GetDMField() const;
       
   477 
       
   478         /**
       
   479         * The function checks if data length is valid.
       
   480         * @param    aProfileItem    Field / Leaf ID to be handled.
       
   481         * @param    aSource         Data to be handled.
       
   482         * @return   ETrue if data length is valid otherwise EFalse.
       
   483         */ 
       
   484 	    TBool NotValidStrLenght( const TNSmlDMProfileData& aProfileItem, 
       
   485                             const TDesC8& aSource );
       
   486         
       
   487         /**
       
   488         * The function converts 16-bit data to 8-bit and returns reference to it.
       
   489         * @param    aSource    Reference data to be converted.
       
   490         * @return   Reference to 8-bit data buffer.
       
   491         */ 
       
   492 	    TDesC8&  ConvertTo8LC( const TDesC& aSource );
       
   493 
       
   494         /**
       
   495         * The function converts 8-bit data to 16-bit and returns reference to it.
       
   496         * @param    aSource    Reference data to be converted.
       
   497         * @return   Reference to 16-bit data buffer.
       
   498         */ 
       
   499 	    TDesC16& ConvertTo16LC( const TDesC8& aSource );
       
   500 
       
   501         /**
       
   502         * The function find out the port number from URL and stores it to aPort.
       
   503         * @param    aRealURI    Reference data to be containing the whole URI.
       
   504         * @param    aPort       Reference variable where port number will be stored.
       
   505         * @return   KErrNone if successful otherwise KErrNotFound.
       
   506         */ 
       
   507 	    TInt ParseUri( const TDesC8& aRealURI, TInt& aPort );
       
   508 
       
   509         /**
       
   510         * The function opens the server session and profile via client API.
       
   511         * @param    aIntLUID    Integer value for a LUID of the profile.
       
   512         * @param    aMode       Read or Read and Write mode for a profile data.
       
   513         * @return   KErrNone if successful otherwise KErrNotFound.
       
   514         */ 
       
   515         TInt OpenSyncSessionAndProfileL( const TInt aIntLUID, TSmlOpenMode aMode );
       
   516 
       
   517         /**
       
   518         * The function checks if requested profile ID exits.
       
   519         * @param    aIntLUID    Integer value for a LUID of the profile.
       
   520         * @return   ETrue if profile exits otherwise EFalse.
       
   521         */ 
       
   522 	    TBool FindProfileIdL( const TInt aIntLUID );
       
   523 
       
   524         /**
       
   525         * The function creates new DM profile.
       
   526         * @param    aPID    Reference to variable where new profile will be stored.
       
   527         * @return   KErrNone if successful otherwise error code.
       
   528         */ 
       
   529         TInt CreateNewProfileL( TInt& aPID );
       
   530 
       
   531         /**
       
   532         * The function stores the server URL for a profile.
       
   533         * @param    aPID    Profile ID.
       
   534         * @param    aObj    Reference to server URL data.
       
   535         * @return   KErrNone if successful otherwise error code.
       
   536         */ 
       
   537         TInt SetProfileServerURIL( const TInt aPID, const TDesC8& aObj );
       
   538 
       
   539         /**
       
   540         * The function stores the display name for a profile.
       
   541         * @param    aPID    Profile ID.
       
   542         * @param    aObj    Reference to data.
       
   543         * @return   KErrNone if successful otherwise error code.
       
   544         */ 
       
   545         TInt SetProfileDisplayNameL( const TInt aPID, const TDesC8& aObj );
       
   546 
       
   547         /**
       
   548         * The function stores the user name for a profile.
       
   549         * @param    aPID    Profile ID.
       
   550         * @param    aObj    Reference to data.
       
   551         * @return   KErrNone if successful otherwise error code.
       
   552         */ 
       
   553         TInt SetProfileUserNameL( const TInt aPID, const TDesC8& aObj );
       
   554 
       
   555         /**
       
   556         * The function stores the protocol version for a profile.
       
   557         * @param    aPID    Profile ID.
       
   558         * @param    aObj    Reference to data.
       
   559         * @return   KErrNone if successful otherwise error code.
       
   560         */ 
       
   561         TInt SetProfileProtocolVersionL( const TInt aPID, const TDesC8& aObj );
       
   562 
       
   563         /**
       
   564         * The function stores the ServerId value for a profile.
       
   565         * @param    aPID    Profile ID.
       
   566         * @param    aObj    Reference to data.
       
   567         * @return   KErrNone if successful otherwise error code.
       
   568         */ 
       
   569         TInt SetProfileServerIdL( const TInt aPID, const TDesC8& aObj );
       
   570 
       
   571         /**
       
   572         * The function stores the Server password for a profile.
       
   573         * @param    aPID    Profile ID.
       
   574         * @param    aObj    Reference to data.
       
   575         * @return   KErrNone if successful otherwise error code.
       
   576         */ 
       
   577         TInt SetProfileServerPasswordL( const TInt aPID, const TDesC8& aObj );
       
   578 
       
   579         /**
       
   580         * The function stores the password value for a profile.
       
   581         * @param    aPID    Profile ID.
       
   582         * @param    aObj    Reference to data.
       
   583         * @return   KErrNone if successful otherwise error code.
       
   584         */ 
       
   585         TInt SetProfilePasswordL( const TInt aPID, const TDesC8& aObj );
       
   586 
       
   587         /**
       
   588         * The function stores the IAP id value for a profile.
       
   589         * @param    aLUID   Profile ID.
       
   590         * @param    aIAPid  Reference to data.
       
   591         * @return   KErrNone if successful otherwise error code.
       
   592         */ 
       
   593         TInt SetProfileConnectionPropertyL( const TInt aLUID, const TInt aIAPid );
       
   594 
       
   595         /**
       
   596         * The function deleted the profile data.
       
   597         * @param    aPID    Profile ID.
       
   598         * @return   KErrNone if successful otherwise error code.
       
   599         */ 
       
   600         TInt DeleteProfileL( const TInt aPID );
       
   601         
       
   602         /**
       
   603         * The function gets the profile data acoeding to aDMField.
       
   604         * @param    aLUID       Profile ID.
       
   605         * @param    aDMField    Data field ID to be handled.
       
   606         * @param    aObject     Reference where fetched data to be stored.
       
   607         * @return   KErrNone if successful otherwise error code.
       
   608         */ 
       
   609         TInt GetObjectL( TInt aLUID, TNSmlDMProfileData aDMField, 
       
   610                         CBufBase& aObject );
       
   611 
       
   612         /**
       
   613         * The function adds port number to address URL.
       
   614         * @param    aLUID       Profile ID.
       
   615         * @param    aPort       Reference to port number data.
       
   616         * @return   KErrNone if successful otherwise error code.
       
   617         */ 
       
   618         TInt SetProfileConnectionPortNrL( const TInt aLUID, const TDesC8& aPort );
       
   619         
       
   620         /**
       
   621         * The function adds port number to address URL.
       
   622         * @param    aSrvURI     Original address URI.
       
   623         * @param    aNewURI     New URI when port number has been added or deleted.
       
   624         * @param    aPort       Reference to port number data.
       
   625         * @return   KErrNone if successful otherwise error code.
       
   626         */ 
       
   627         void SetPortNrToAddrStr( const TDesC8& aSrvURI, HBufC8* aNewURI, 
       
   628                                 const TDesC8& aPort );
       
   629 
       
   630         /**
       
   631         * General function which selects which leaf to be handled.
       
   632         * @param    aLUID       Profile LUID.
       
   633         * @param    aObject     Data to be stored.
       
   634         * @param    aField      Leaf of field ID to be handled.
       
   635         * @return   KErrNone if successful otherwise error code.
       
   636         */ 
       
   637         TInt SetDMFieldDataL( const TInt aLUID, const TDesC8& aObject, 
       
   638                             const TNSmlDMProfileData aField );
       
   639         /**
       
   640         * The function fills the node info.
       
   641         * @param    aNode           Reference to node or leaf which info to be filled.
       
   642         * @param    aAccTypes       Access rights for a leaf / node.
       
   643         * @param    aOccurrence     Occurance of the node / leaf.
       
   644         * @param    aScope          Scope (dynamic / permanent) of the leaf / node.
       
   645         * @param    aFormat         Data format of the leaf / node.
       
   646         * @param    aDescription    Description of the node / leaf.
       
   647         * @param    aDefaultValue   Default value for a leaf or node.
       
   648         * @param    aMimeType       MIME type for a leaf / node.
       
   649         * @return   none
       
   650         */ 
       
   651         void FillNodeInfoL( MSmlDmDDFObject& aNode, TSmlDmAccessTypes aAccTypes, 
       
   652                         MSmlDmDDFObject::TOccurence aOccurrence, 
       
   653                         MSmlDmDDFObject::TScope aScope, 
       
   654                         MSmlDmDDFObject::TDFFormat aFormat, 
       
   655                         const TDesC8& aDescription, 
       
   656                         const TDesC8& aDefaultValue, const TDesC8& aMimeType );
       
   657         
       
   658         /**
       
   659         * The function reads the authentication data via private API.
       
   660         * @param    aLUID       LUID for a profile.
       
   661         * @param    aField      Leaf id to be handled.
       
   662         * @param    aObject     Reference where to store the data.
       
   663         * @return   KErrNone if successful otherwise error code.
       
   664         */ 
       
   665         TInt GetDMAuthInfoL( const TInt aLUID, const TNSmlDMProfileData aField, 
       
   666                             CBufBase& aObject );
       
   667 
       
   668         /**
       
   669         * The function delete's the authentication data via private API.
       
   670         * @param    aLUID       LUID for a profile.
       
   671         * @param    aField      Leaf id to be handled.
       
   672         * @return   KErrNone if successful otherwise error code.
       
   673         */ 
       
   674         TInt DeleteDMAuthInfoL( const TInt aLUID, const TNSmlDMProfileData aField );
       
   675         
       
   676         /**
       
   677         * The function set's the address type / medium type value for a profile.
       
   678         * @param    aLUID       LUID for a profile.
       
   679         * @param    aIntObj     Address type value.
       
   680         * @return   KErrNone if successful otherwise error code.
       
   681         */ 
       
   682         TInt SetProfileAddrTypeL( const TInt aLUID, const TInt aIntObj );
       
   683 
       
   684         /**
       
   685         * The function gets the profile medium type value.
       
   686         * @param    aObject     Reference where data to be stored.
       
   687         * @return   KErrNone if successful otherwise error code.
       
   688         */ 
       
   689         TInt GetProfileConnectiontypeL( CBufBase& aObject );
       
   690 
       
   691         /**
       
   692         * The function gets the profile IAP value.
       
   693         * @param    aIAPid     Reference where data to be stored.
       
   694         * @return   KErrNone if successful otherwise error code.
       
   695         */ 
       
   696         TInt GetProfileIAPIdL( TInt& aIAPid );
       
   697 
       
   698         /**
       
   699         * The function gets the profile Server URL value.
       
   700         * @param    aURL     Reference where data to be stored.
       
   701         * @return   KErrNone if successful otherwise error code.
       
   702         */ 
       
   703         void GetProfileServerURLL( CBufBase& aURL );
       
   704 
       
   705         /**
       
   706         * The function checks the requested medium type if supported.
       
   707         * @param    aIntObj         Medium type.
       
   708         * @param    aMediumType     UID for medium type.
       
   709         * @return   none
       
   710         */         
       
   711         void GetMediumTypeL( const TInt aIntObj, TInt& aMediumType );
       
   712 
       
   713         /**
       
   714         * The function gets the server id value.
       
   715         * @param    aObject     Reference where data to be stored.
       
   716         * @return   none
       
   717         */       
       
   718         void GetServerIdL( CBufBase& aObject );
       
   719 
       
   720         /**
       
   721         * The function gets the profile name value.
       
   722         * @param    aObject     Reference where data to be stored.
       
   723         * @return   none
       
   724         */       
       
   725         void GetProfileNameL( CBufBase& aObject );
       
   726 
       
   727         /**
       
   728         * The function gets the user name value.
       
   729         * @param    aObject     Reference where data to be stored.
       
   730         * @return   none
       
   731         */ 
       
   732         void GetProfileUserNameL( CBufBase& aObject );
       
   733 
       
   734         /**
       
   735         * The function gets the profile port number value.
       
   736         * @param    aObject     Reference where data to be stored.
       
   737         * @return   none
       
   738         */ 
       
   739         void GetProfilePortNumberL( CBufBase& aObject );
       
   740 
       
   741         /**
       
   742         * The function sets the profile authentication info via private API.
       
   743         * @param    aLUID       Profile LUID.
       
   744         * @param    aField      Leaf ID to be handled.
       
   745         * @param    aObject     Data to be stored.
       
   746         * @param    aStatus     Status of the function, KErrNone if successful.
       
   747         * @return   none
       
   748         */         
       
   749         void SetAuthInfoL( const TInt aLUID, const TNSmlDMProfileData aField, 
       
   750                         const TDesC8& aObject, TInt& aStatus );
       
   751 	//Buffers Node Object
       
   752 	void AddNodeBufferL( const TDesC8& aURI, const TInt aStatusRef);
       
   753 	//Buffers Leaf Object
       
   754 	void AddLeafBufferL( const TDesC8& aURI, const TDesC8& aObject,
       
   755 			const TInt aStatusRef);
       
   756 	// Executes Buffer
       
   757 	void ExecuteBufferL();
       
   758 	//Extracts the ParentURI
       
   759 	TPtrC8 ParentURI(const TDesC8& aURI);
       
   760 	// Clears the elements of the passed in LeafElement Structure
       
   761 	void ClearBuffer( CArrayFixFlat<TNSmlDMLeafElement>* aBuffer);
       
   762     private:    // Data
       
   763 	
       
   764         // Client API session class 
       
   765         RSyncMLSession iSyncSession;
       
   766         // Client API Device Management profile handling
       
   767         RSyncMLDevManProfile iProfile;
       
   768         // Callback interface for returning result or status
       
   769 	    MSmlDmCallback* iCallBack;
       
   770 	    
       
   771 	    TInt iCurrentProfile;
       
   772 	    
       
   773         // Profile LUID
       
   774         TInt iLUID;
       
   775         // Parent LUID
       
   776 	    TInt iParentLUID;
       
   777         // For handling profile medium type 
       
   778 	    TInt iObject;
       
   779                   
       
   780         // Buffer for URI leaf element
       
   781 	    HBufC8* iField;
       
   782 		
       
   783         // Information about data type
       
   784 	    TNSmlDMFieldType  iFieldType;
       
   785         // Information about leaf command
       
   786 	    TNSmlDMLeafType	  iLeafType;
       
   787         // Status information if session allready opened
       
   788         TBool iSyncSessionOpen;
       
   789 
       
   790         // Buffer for storing port number
       
   791         HBufC8* iPortNbr;
       
   792     
       
   793         // Private API interface for handling authebtication data
       
   794         RNSmlPrivateAPI iPrivateApi;
       
   795         
       
   796         struct TPortBuffer
       
   797             {
       
   798             // buffered data for updating port number
       
   799             TBufC8<5> iPortBuf;
       
   800             TInt iPortBufLUID;
       
   801             TInt iPortBufStatusRef;
       
   802             };
       
   803         RArray<TPortBuffer> iPortBuffer;    
       
   804 	TBool iBufOn;
       
   805 	TBool iComplete;
       
   806 	TInt iExecutionIndex;
       
   807 	CArrayFixFlat<TNSmlDMBufferElement> *iBuffer;
       
   808     };
       
   809 
       
   810 #endif // __NSMLDMSETTINGSADAPTER_H__
       
   811 
       
   812 // End of File
       
   813