natplugins/natpdevmgmtnatfwadapter/inc/nsmldmnatfwtraversaladapter.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Device Management NAT-FW Traversal adapter
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __NSMLDMNATFWTRAVERSALADAPTER_H__
       
    20 #define __NSMLDMNATFWTRAVERSALADAPTER_H__
       
    21 
       
    22 // INCLUDES
       
    23 #include <smldmadapter.h>
       
    24 
       
    25 // CLASS DECLARATION
       
    26 class CNATFWDomainEntry;
       
    27 class CNATFWIAPEntry;
       
    28 class CRepository;
       
    29 
       
    30 /**
       
    31  *  TDMNATFWStatusInfo
       
    32  *  For buffering DM commands for NAT-FW
       
    33  *  @since Series 60_3.1
       
    34  */
       
    35 class TDMNATFWStatusInfo
       
    36     {
       
    37 
       
    38 public:
       
    39 
       
    40     enum TCommandType
       
    41         {
       
    42         EDMAddDomain,
       
    43         EDMUpdateDomain,
       
    44         EDMDeleteDomain,
       
    45         EDMAddIAP,
       
    46         EDMUpdateIAP,
       
    47         EDMDeleteIAP,
       
    48         EDMAddSTUN,
       
    49         EDMUpdateSTUN,
       
    50         EDMDeleteSTUN,
       
    51         EDMAddTURN,
       
    52         EDMUpdateTURN,
       
    53         EDMDeleteTURN
       
    54         };
       
    55 
       
    56 public:  // data members
       
    57 
       
    58     // Key id for this command 
       
    59     TUint32 iKeyId;
       
    60     
       
    61     // Status reference for this command 
       
    62     TInt iStatusRef;
       
    63     
       
    64     // command type 
       
    65     TCommandType iCommandType;
       
    66 
       
    67     // Settings location for interior nodes.
       
    68     TInt iLocation;
       
    69     };
       
    70 
       
    71 /**
       
    72  *  CNSmlDmNATFWTraversalAdapter
       
    73  *  Main implementation of NAT-FW Traversal Adapter
       
    74  *  @since Series 60_3.1
       
    75  */
       
    76 class CNSmlDmNATFWTraversalAdapter : public CSmlDmAdapter
       
    77     {
       
    78 public: // enumerations
       
    79 
       
    80     enum TNatProtocol
       
    81         {
       
    82         EProtocolNone = 0,
       
    83         EStunProtocol,
       
    84         ETurnProtocol,
       
    85         EIceProtocol
       
    86         };
       
    87 
       
    88 public:
       
    89     
       
    90     static CNSmlDmNATFWTraversalAdapter* NewL( MSmlDmCallback* aDmCallback );
       
    91     static CNSmlDmNATFWTraversalAdapter* NewLC( MSmlDmCallback* aDmCallback );
       
    92     virtual ~CNSmlDmNATFWTraversalAdapter();
       
    93 
       
    94 private:
       
    95 
       
    96     /**
       
    97      * From MSmlDmAdapter
       
    98      * @since Series 60_3.1
       
    99      * @param aDDFVersion for returning DDF version of adapter
       
   100      */
       
   101     void DDFVersionL( CBufBase& aDDFVersion );
       
   102 
       
   103     /**
       
   104      * From MSmlDmAdapter
       
   105      * @since Series 60_3.1
       
   106      * @param aDDF for returning DDF structure of adapter
       
   107      */
       
   108     void DDFStructureL( MSmlDmDDFObject& aDDF );
       
   109 
       
   110     /**
       
   111      * From MSmlDmAdapter
       
   112      * @since Series 60_3.1
       
   113      * @param aURI URI of the object
       
   114      * @param aLUID LUID of the object
       
   115      * @param aObject Data of the object.
       
   116      * @param aType MIME type of the object
       
   117      * @param aStatusRef Reference to correct command
       
   118      */
       
   119     void UpdateLeafObjectL( 
       
   120         const TDesC8& aURI, 
       
   121         const TDesC8& aLUID, 
       
   122         const TDesC8& aObject,
       
   123         const TDesC8& aType, 
       
   124         const TInt aStatusRef );
       
   125 
       
   126     /**
       
   127      * From MSmlDmAdapter
       
   128      * @since Series 60_3.1
       
   129      * @param aURI URI of the object
       
   130      * @param aLUID LUID of the object 
       
   131      * @param aStream Data of the object.
       
   132      * @param aType MIME type of the object
       
   133      * @param aStatusRef Reference to correct command
       
   134      */
       
   135     void UpdateLeafObjectL( 
       
   136         const TDesC8& aURI, 
       
   137         const TDesC8& aLUID, 
       
   138         RWriteStream*& aStream,
       
   139         const TDesC8& aType, 
       
   140         TInt aStatusRef );
       
   141 
       
   142     /**
       
   143      * From MSmlDmAdapter
       
   144      * @since Series 60_3.1
       
   145      * @param aURI URI of the object
       
   146      * @param aLUID LUID of the object
       
   147      * @param aStatusRef Reference to correct command
       
   148      */
       
   149     void DeleteObjectL( 
       
   150         const TDesC8& aURI, 
       
   151         const TDesC8& aLUID, 
       
   152         const TInt aStatusRef );
       
   153 
       
   154     /**
       
   155      * From MSmlDmAdapter
       
   156      * @since Series 60_3.1
       
   157      * @param aURI URI of the object
       
   158      * @param aLUID LUID of the object
       
   159      * @param aType MIME type of the object
       
   160      * @param aResultsRef Reference to correct results
       
   161      * @param aStatusRef Reference to correct command
       
   162      */
       
   163     void FetchLeafObjectL( 
       
   164         const TDesC8& aURI, 
       
   165         const TDesC8& aLUID, 
       
   166         const TDesC8& aType, 
       
   167         const TInt aResultsRef, 
       
   168         const TInt aStatusRef );
       
   169 
       
   170     /**
       
   171      * From MSmlDmAdapter
       
   172      * @since Series 60_3.1
       
   173      * @param aURI URI of the object
       
   174      * @param aLUID LUID of the object
       
   175      * @param aType MIME type of the object
       
   176      * @param aResultsRef Reference to correct results
       
   177      * @param aStatusRef Reference to correct command
       
   178      */
       
   179     void FetchLeafObjectSizeL( 
       
   180         const TDesC8& aURI, 
       
   181         const TDesC8& aLUID, 
       
   182         const TDesC8& aType, 
       
   183         TInt aResultsRef, 
       
   184         TInt aStatusRef );
       
   185 
       
   186     /**
       
   187      * From MSmlDmAdapter
       
   188      * @since Series 60_3.1
       
   189      * @param aURI URI from dm-module
       
   190      * @param aLUID LUID of the parent object
       
   191      * @param aPreviousURISegmentList from dm-module
       
   192      * @param aResultsRef results reference from dm-module
       
   193      * @param aStatusRef Reference to correct command
       
   194      */
       
   195     void ChildURIListL( 
       
   196         const TDesC8& aURI, 
       
   197         const TDesC8& aLUID, 
       
   198         const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, 
       
   199         const TInt aResultsRef, 
       
   200         const TInt aStatusRef );
       
   201 
       
   202     /**
       
   203      * From MSmlDmAdapter
       
   204      * @since Series 60_3.1
       
   205      * @param aURI URI of the object
       
   206      * @param aParentLUID LUID of the parent object
       
   207      * @param aStatusRef Reference to correct command
       
   208      */
       
   209     void AddNodeObjectL( 
       
   210         const TDesC8& aURI, 
       
   211         const TDesC8& aParentLUID, 
       
   212         const TInt aStatusRef );
       
   213 
       
   214     /**
       
   215      * From MSmlDmAdapter
       
   216      * @since Series 60_3.1
       
   217      * @param aURI URI from dm-module
       
   218      * @param aLUID LUID of the object
       
   219      * @param aArgument Argument for the command
       
   220      * @param aType MIME type of the object 
       
   221      * @param aStatusRef Reference to correct command 
       
   222      */
       
   223     void ExecuteCommandL( 
       
   224         const TDesC8& aURI, 
       
   225         const TDesC8& aLUID, 
       
   226         const TDesC8& aArgument, 
       
   227         const TDesC8& aType, 
       
   228         const TInt aStatusRef );
       
   229 
       
   230     /**
       
   231      * From MSmlDmAdapter
       
   232      * @since Series 60_3.1
       
   233      * @param aURI URI from dm-module
       
   234      * @param aLUID LUID of the object
       
   235      * @param aStream Argument for the command
       
   236      * @param aType MIME type of the object 
       
   237      * @param aStatusRef Reference to correct command 
       
   238      */
       
   239     void ExecuteCommandL( 
       
   240         const TDesC8& aURI, 
       
   241         const TDesC8& aLUID, 
       
   242         RWriteStream*& aStream, 
       
   243         const TDesC8& aType, 
       
   244         const TInt aStatusRef );
       
   245 
       
   246     /**
       
   247      * From MSmlDmAdapter
       
   248      * @since Series 60_3.1
       
   249      * @param aTargetURI Target URI for the command
       
   250      * @param aTargetLUID LUID of the target object
       
   251      * @param aSourceURI Source URI for the command
       
   252      * @param aSourceLUID LUID of the source object
       
   253      * @param aType MIME type of the objects
       
   254      * @param aStatusRef Reference to correct command
       
   255      */
       
   256     void CopyCommandL( 
       
   257         const TDesC8& aTargetURI, 
       
   258         const TDesC8& aTargetLUID, 
       
   259         const TDesC8& aSourceURI, 
       
   260         const TDesC8& aSourceLUID, 
       
   261         const TDesC8& aType, 
       
   262         TInt aStatusRef );
       
   263 
       
   264     /**
       
   265      * From MSmlDmAdapter
       
   266      * @since Series 60_3.1
       
   267      * 
       
   268      */
       
   269     void StartAtomicL();
       
   270 
       
   271     /**
       
   272      * From MSmlDmAdapter
       
   273      * @since Series 60_3.1
       
   274      * 
       
   275      */
       
   276     void CommitAtomicL();
       
   277 
       
   278     /**
       
   279      * From MSmlDmAdapter
       
   280      * @since Series 60_3.1
       
   281      * 
       
   282      */
       
   283     void RollbackAtomicL();
       
   284 
       
   285     /**
       
   286      * From MSmlDmAdapter
       
   287      * @since Series 60_3.1
       
   288      * @param aItemSize size limit for stream usage
       
   289      * @return TBool ETrue for streaming support
       
   290      */
       
   291     TBool StreamingSupport( TInt& aItemSize );
       
   292 
       
   293     /**
       
   294      * From MSmlDmAdapter
       
   295      * @since Series 60_3.1
       
   296      * 
       
   297      */
       
   298     void StreamCommittedL();
       
   299 
       
   300     /**
       
   301      * From MSmlDmAdapter
       
   302      * @since Series 60_3.1
       
   303      * 
       
   304      */
       
   305     void CompleteOutstandingCmdsL();
       
   306 
       
   307 private: 
       
   308 
       
   309     CNSmlDmNATFWTraversalAdapter( TAny* aEcomArguments );
       
   310 
       
   311     /**
       
   312      * Fetches leaf object values
       
   313      * @since Series 60_3.1
       
   314      * @param aURI, URI of the object
       
   315      * @param aLUID, LUID of the object
       
   316      * @param aObject, data of the object.
       
   317      * @return TError Status code of operation
       
   318      */
       
   319     CSmlDmAdapter::TError FetchObjectL( 
       
   320         const TDesC8& aURI, 
       
   321         const TDesC8& aLUID, 
       
   322         CBufBase& aObject );
       
   323         
       
   324     /**
       
   325      * Fetches Domain specific leaf object values
       
   326      * @since Series 60_3.1
       
   327      * @param aURI, URI of the object
       
   328      * @param aLUID, LUID of the object
       
   329      * @param aObject, data of the object.
       
   330      * @return TError Status code of operation
       
   331      */
       
   332     CSmlDmAdapter::TError FetchDomainObjectL(
       
   333         const TDesC8& aURI, 
       
   334         const TDesC8& aLUID,
       
   335         TDes8& aSegmentResult );
       
   336         
       
   337     /**
       
   338      * Fetches IAP specific leaf object values
       
   339      * @since Series 60_3.1
       
   340      * @param aURI, URI of the object
       
   341      * @param aLUID, LUID of the object
       
   342      * @param aObject, data of the object.
       
   343      * @return TError Status code of operation
       
   344      */
       
   345     CSmlDmAdapter::TError FetchIAPObjectL(
       
   346         const TDesC8& aURI, 
       
   347         const TDesC8& aLUID,
       
   348         TDes8& aSegmentResult,
       
   349         CBufBase& aObject );
       
   350 
       
   351     /**
       
   352      * Fetches AdditionalSTUNServer/<x>/ leaf object values
       
   353      * @since Series 60_3.2
       
   354      * @param aURI, URI of the object
       
   355      * @param aLUID, LUID of the object
       
   356      * @param aObject, data of the object.
       
   357      * @return TError Status code of operation
       
   358      */
       
   359     CSmlDmAdapter::TError FetchAdditionalSTUNServerObjectL(
       
   360         const TDesC8& aURI, 
       
   361         const TDesC8& aLUID,
       
   362         TDes8& aSegmentResult );
       
   363 
       
   364     /**
       
   365      * Fetches STUNSpecific/STUNServer/<x>/ leaf object values
       
   366      * @since Series 60_3.2
       
   367      * @param aURI, URI of the object
       
   368      * @param aLUID, LUID of the object
       
   369      * @param aObject, data of the object.
       
   370      * @return TError Status code of operation
       
   371      */
       
   372     CSmlDmAdapter::TError FetchTURNServerObjectL(
       
   373         const TDesC8& aURI, 
       
   374         const TDesC8& aLUID,
       
   375         TDes8& aSegmentResult );
       
   376 
       
   377     /**
       
   378      * Updates DomainSpecific node
       
   379      * @since Series 60_3.2
       
   380      */   
       
   381     CSmlDmAdapter::TError UpdateDomainSpecificObjectL(
       
   382         const TDesC8& aURI,
       
   383         const TDesC8& aLUID, 
       
   384         const TDesC8& aObject, 
       
   385         const TInt aStatusRef );
       
   386 
       
   387     /**
       
   388      * Updates IAPSpecific node
       
   389      * @since Series 60_3.2
       
   390      */   
       
   391     CSmlDmAdapter::TError UpdateIAPSpecificObjectL(
       
   392         const TDesC8& aURI,
       
   393         const TDesC8& aLUID, 
       
   394         const TDesC8& aObject, 
       
   395         const TInt aStatusRef );
       
   396 
       
   397     /**
       
   398      * Updates DomainSpecific/<x>/AdditionalSTUNServer node
       
   399      * @since Series 60_3.2
       
   400      */   
       
   401     CSmlDmAdapter::TError UpdateAdditionalSTUNServerObjectL(
       
   402         const TDesC8& aURI,
       
   403         const TDesC8& aLUID, 
       
   404         const TDesC8& aObject, 
       
   405         const TInt aStatusRef );
       
   406 
       
   407     /**
       
   408      * Updates DomainSpecific/<x>/TURNSpecific/TURNServer node
       
   409      * @since Series 60_3.2
       
   410      */   
       
   411     CSmlDmAdapter::TError UpdateTURNServerObjectL(
       
   412         const TDesC8& aURI,
       
   413         const TDesC8& aLUID, 
       
   414         const TDesC8& aObject, 
       
   415         const TInt aStatusRef );
       
   416 
       
   417     /**
       
   418      * Lists the Domain specific children of the node
       
   419      * @since Series 60_3.2
       
   420      */
       
   421     CSmlDmAdapter::TError DomainChildURIListL(
       
   422         const TDesC8& aURI,
       
   423         const TDesC8& aLUID, 
       
   424         CBufBase* const aURISegmentList,
       
   425         const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList );
       
   426 
       
   427     /**
       
   428      * Lists the IAP specific children of the node
       
   429      * @since Series 60_3.2
       
   430      */
       
   431     CSmlDmAdapter::TError IAPChildURIListL(
       
   432         const TDesC8& aURI,
       
   433         const TDesC8& aLUID, 
       
   434         CBufBase* const aURISegmentList,
       
   435         const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList );
       
   436 
       
   437     /**
       
   438      * Loads NAT-FW profile information
       
   439      * @since Series 60_3.1
       
   440      */
       
   441     void LoadProfilesL();
       
   442 
       
   443     /**
       
   444      * Saves NAT-FW profile information
       
   445      * @since Series 60_3.1
       
   446      */
       
   447     void SaveProfilesL();
       
   448     
       
   449     /**
       
   450      * Adds NAT-FW settings
       
   451      * @param aRep Central Repository for NAT-FW Traversal settings.
       
   452      * @since Series 60_3.2
       
   453      */
       
   454     void AddSettingsL( CRepository* aRep );
       
   455 
       
   456     /**
       
   457      * Updates NAT-FW settings
       
   458      * @param aRep Central Repository for NAT-FW Traversal settings.
       
   459      * @since Series 60_3.2
       
   460      */
       
   461     void UpdateSettingsL( CRepository* aRep );
       
   462 
       
   463     /**
       
   464      * Deletes NAT-FW settings
       
   465      * @param aRep Central Repository for NAT-FW Traversal settings.
       
   466      * @since Series 60_3.2
       
   467      */
       
   468     void DeleteSettingsL( CRepository* aRep );
       
   469 
       
   470     /**
       
   471      * Gets domain specific settings from CenRep.
       
   472      * @since Series 60_3.1
       
   473      * @param aDomainKeyId CenRep domain key to get.
       
   474      * @param aEntry, domain entry to store values.
       
   475      */
       
   476     void GetDomainSettingsL( TUint32 aDomainKeyId, 
       
   477         CNATFWDomainEntry& aEntry );
       
   478 
       
   479     /**
       
   480      * Gets IAP specific settings from CenRep.
       
   481      * @since Series 60_3.1
       
   482      * @param aIAPKey CenRep IAP key to get.
       
   483      * @param aEntry, IAP entry to store values.
       
   484      */
       
   485     void GetIAPSettingsL( TUint32 aIAPKey, 
       
   486         CNATFWIAPEntry& aEntry );
       
   487 
       
   488     /**
       
   489      * Finds domain location in buffered entries.
       
   490      * @since Series 60_3.1
       
   491      * @param aLUID, LUID value to look.
       
   492      * @return TInt, location in entries.
       
   493      */
       
   494     TInt FindDomainLocation( const TDesC8& aLUID );
       
   495 
       
   496     /**
       
   497      * Finds domain location in buffered entries.
       
   498      * @since Series 60_3.1
       
   499      * @param aDomainKey, CenRep key value to look.
       
   500      * @return TInt, location in entries.
       
   501      */
       
   502     TInt FindDomainLocation( TUint32 aDomainKey );
       
   503 
       
   504     /**
       
   505      * Finds IAP location in buffered entries.
       
   506      * @since Series 60_3.1
       
   507      * @param aLUID, LUID value to look.
       
   508      * @return TInt, location in entries.
       
   509      */
       
   510     TInt FindIAPLocation( const TDesC8& aLUID );
       
   511 
       
   512     /**
       
   513      * Finds IAP location in buffered entries.
       
   514      * @since Series 60_3.1
       
   515      * @param aLUID, CenRep key value to look.
       
   516      * @return TInt, location in entries.
       
   517      */
       
   518     TInt FindIAPLocation( TUint32 aIAPKey );
       
   519 
       
   520     /**
       
   521      * Converts descriptor to TUint.
       
   522      * @since Series 60_3.1
       
   523      * @param aDes descriptor to convert.
       
   524      * @return TUint, converted value.
       
   525      */
       
   526     TUint DesToTUint( const TDesC8& aDes );
       
   527 
       
   528     /**
       
   529      * Find accesspoint with AP adapter and sets it to IAP specific entry.
       
   530      * @since Series 60_3.1
       
   531      * @param aObject, PrefConRef value to be set.
       
   532      * @param aProfileLoc, entry location to set IAP ID.
       
   533      * @return TInt, IAP Id found.
       
   534      */
       
   535     TInt SetConRefL( const TDesC8& aObject, TInt aProfileLoc );
       
   536 
       
   537     /**
       
   538      * Find PrefConRef value (AP/APIdxxx) with AP adapter.
       
   539      * @since Series 60_3.1
       
   540      * @param aObject, PrefConRef value to be set.
       
   541      * @param aProfileLoc, entry location to get IAP ID.
       
   542      * @return TInt, IAP Id found.
       
   543      */
       
   544     TBool GetConRefL( CBufBase& aObject, TInt aProfileLoc );
       
   545 
       
   546     /**
       
   547      * Converts descriptor to int.
       
   548      * @since Series 60_3.0
       
   549      * @param aDes descriptor to convert.
       
   550      * @return TInt. Converted value.
       
   551      */
       
   552     TInt DesToInt( const TDesC8& aDes );
       
   553 
       
   554     /**
       
   555      * Removes last uri segment from aURI
       
   556      * @since Series 60_3.0
       
   557      * @param aDes Descriptor to handle
       
   558      * @return pointer to uri
       
   559      */
       
   560     TPtrC8 RemoveLastURISeg( const TDesC8& aURI );
       
   561 
       
   562     /**
       
   563      * Gets number of uri segments.
       
   564      * @since Series 60_3.0
       
   565      * @param aURI Descriptor to handle
       
   566      * @return TInt. Number of URI segments.
       
   567      */
       
   568     TInt NumOfURISegs( const TDesC8& aURI );
       
   569 
       
   570     /**
       
   571      * Gets last uri segment.
       
   572      * @since Series 60_3.0
       
   573      * @param aURI Descriptor to handle
       
   574      * @return TPtrC8. Pointer to beginning of last uri segment.
       
   575      */
       
   576     TPtrC8 LastURISeg( const TDesC8& aURI );
       
   577 
       
   578     /**
       
   579      * Removes ./ from uri
       
   580      * @since Series 60_3.0
       
   581      * @param aURI Descriptor to handle
       
   582      * @return pointer to uri
       
   583      */
       
   584     TPtrC8 RemoveDotSlash( const TDesC8& aURI );
       
   585 
       
   586 private: // Data
       
   587 
       
   588     /**
       
   589      * For returning data to DM module.
       
   590      * Not own.
       
   591      */
       
   592     MSmlDmCallback* iDmCallback;
       
   593     
       
   594     /**
       
   595      * Profile ID currently being modified.
       
   596      */
       
   597     TInt iProfileID;
       
   598 
       
   599     /**
       
   600      * Array of pointers to all Domain entries.
       
   601      * Own.
       
   602      */
       
   603     CArrayPtrFlat<CNATFWDomainEntry>* iNATFWDomainEntries;
       
   604     
       
   605     /**
       
   606      * Array of pointers to all IAP entries.
       
   607      * Own.
       
   608      */
       
   609     CArrayPtrFlat<CNATFWIAPEntry>* iNATFWIAPEntries;
       
   610     
       
   611     /**
       
   612      * For buffering DM commands.
       
   613      */
       
   614     RArray< TDMNATFWStatusInfo > iNATFWCommandBuffer;
       
   615     
       
   616     /**
       
   617      * For knowing status of dm-module.
       
   618      */
       
   619     TInt iStatus;
       
   620     
       
   621     /**
       
   622      * For returning results to dm-module.
       
   623      * Not own.
       
   624      */
       
   625     CBufBase *iResults;
       
   626 
       
   627 private: // Friend class for testing
       
   628 
       
   629    	#if defined( TEST_EUNIT )
       
   630     friend class UT_CNSmlDmNATFWTraversalAdapter;
       
   631     #endif
       
   632     };
       
   633 
       
   634 #endif // __NSMLDMNATFWTRAVERSALADAPTER_H__
       
   635 
       
   636 // End of File