cmmanager/cmmgr/Framework/Inc/cmdestinationimpl.h
changeset 20 9c97ad6591ae
parent 18 fcbbe021d614
child 21 b8e8e15e80f2
child 23 7ec726f93df1
child 28 860702281757
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
     1 /*
       
     2 * Copyright (c) 2006 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:  Implementation of destination class.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef DESTINATIONIMPL_H
       
    19 #define DESTINATIONIMPL_H
       
    20 
       
    21 // User includes
       
    22 #include "cmmanager.hrh"
       
    23 #include <cmmanagerdef.h>
       
    24 
       
    25 // System includes
       
    26 #include <e32def.h>
       
    27 #include <e32base.h>
       
    28 #include <metadatabase.h>
       
    29 #include <commsdattypesv1_1.h>
       
    30 
       
    31 // CONSTANTS
       
    32 const TInt KCmInitIndex =  1;
       
    33 const TInt KNumOfIcons = 12;
       
    34 
       
    35 #define RECORD_FROM_ELEMENT_ID( elementId ) \
       
    36                                     (( elementId & KCDMaskShowRecordId ) >> 8 )
       
    37 
       
    38 enum TSnapMetadataProtecionLevel
       
    39     {
       
    40     EProtectionLevel0 = 0x00000000,
       
    41     EProtectionLevel1 = 0x10000000,
       
    42     EProtectionLevel2 = 0x20000000
       
    43     };
       
    44     
       
    45 #define KSnapMetadataProtecionLevelMask 0xF0000000;
       
    46 
       
    47 // DATA TYPES    
       
    48     
       
    49 // FORWARD DECLARATIONS
       
    50 class CCmManagerImpl;
       
    51 class CCmPluginBaseEng;
       
    52 class CCmPluginBase;
       
    53 class TCmPluginInitParam;
       
    54 class CPluginItem;
       
    55 class CCDDataMobilitySelectionPolicyRecord;
       
    56 class CGulIcon;
       
    57 class CCmTransactionHandler;
       
    58 class CCDSNAPMetadataRecord;
       
    59 
       
    60 typedef CArrayPtrFlat<CPluginItem> CCmArray;
       
    61 
       
    62 #define KFlagRemove 0x00000001
       
    63 
       
    64 typedef CCDDataMobilitySelectionPolicyRecord CCDSnapRecord;
       
    65 
       
    66 const TUint32 KCmDefaultDestinationAPTagId = 0x1000;
       
    67 
       
    68 // CLASS DECLARATION
       
    69 NONSHARABLE_CLASS(CPluginItem) : public CBase
       
    70     {
       
    71     public:
       
    72     
       
    73         enum
       
    74             {
       
    75             ERemoveCm   = 0x00000001
       
    76             };
       
    77             
       
    78     public:
       
    79         
       
    80         CCDSnapRecord*     iDNRecord;
       
    81         CCmPluginBase*   iPlugin;
       
    82         TUint32             iFlags;
       
    83     };        
       
    84 
       
    85 /**
       
    86  * Holds all the destination specific data of the CCmDestinationImpl
       
    87  * This class is put in the object pool and may be shared
       
    88  * among CCmDestinationImpl objects
       
    89  */
       
    90 NONSHARABLE_CLASS( CCmDestinationData ): public CBase
       
    91     {
       
    92     //=====================================================================
       
    93     // Constructors/Destructors
       
    94     // 
       
    95     public:
       
    96         CCmDestinationData( CCmManagerImpl& aCmMgr );
       
    97         ~CCmDestinationData();
       
    98         /**
       
    99         * Increments the reference counter. Used by the object pool.
       
   100         */
       
   101         void IncrementRefCounter();
       
   102         /**
       
   103         * Increments the reference counter. Used by the object pool.
       
   104         */
       
   105         void DecrementRefCounter();
       
   106     private:
       
   107         /**
       
   108         * Reset and, if needed, destroy the passed array.
       
   109         * @since S60 3.2
       
   110         * @param aArray array to be reseted and deleted
       
   111         * @parar aDestroy ETrue if array has to be deleted
       
   112         */
       
   113         void ResetAndDestroyArray( CCmArray* &aArray, TBool aDestroy );
       
   114         
       
   115     public:
       
   116         /**
       
   117         * Returns the number of connection methods of the destination
       
   118         * @param None
       
   119         * @return TInt        
       
   120         */                  
       
   121         TInt ConnectionMethodCount();
       
   122         
       
   123         /**
       
   124         * Returns the destination's Id attribute
       
   125         * @param None
       
   126         * @return TUint32        
       
   127         */            
       
   128         inline TUint32 Id(){return iDestAPRecord->iRecordTag;};
       
   129                 
       
   130         /**
       
   131         * Returns the destination's ElementId attribute
       
   132         * @param None
       
   133         * @return TUint32        
       
   134         */            
       
   135         inline TUint32 ElementId() 
       
   136         { return iNetworkRecord->ElementId() & KCDMaskShowField;};
       
   137     
       
   138         /**
       
   139         * Returns that the destination is protected or not.
       
   140         * @return protection level   
       
   141         */
       
   142         CMManager::TProtectionLevel ProtectionLevel();
       
   143         
       
   144         /**
       
   145         * Returns that the destination is hidden or not.
       
   146         * @param None
       
   147         * @return TBool   
       
   148         */
       
   149         TBool IsHiddenL(); 
       
   150 
       
   151         /**
       
   152         * Indicates if the Id is valid or if this is a new object which sitll
       
   153         * haven't been updated. 
       
   154         * Used by the object pool.
       
   155         * @return TBool
       
   156         */
       
   157         TBool IdIsValid();
       
   158 
       
   159         /**
       
   160         * Returns the reference counter. Used by the object pool.
       
   161         * @return TInt
       
   162         */
       
   163         TInt GetRefCounter();
       
   164         /** 
       
   165         * Returns pointer to the CmManager object
       
   166         * Used in 'R' classes
       
   167         */
       
   168         CCmManagerImpl* Cmmgr();
       
   169 
       
   170         /**
       
   171         * Returns the Metadata
       
   172         * @param None
       
   173         * @return TUint32        
       
   174         */            
       
   175         TUint32 MetadataL( CMManager::TSnapMetadataField aMetaField ) const;
       
   176 
       
   177     private:
       
   178         CCmManagerImpl&               iCmMgr;         //< Not owned
       
   179         CommsDat::CCDNetworkRecord*   iNetworkRecord;
       
   180                 
       
   181         //To store Connection methods that belong to this destination
       
   182         CCmArray* iConnMethodArray;
       
   183         CCmArray* iDeleteCmArray;
       
   184         
       
   185         // DN_IAP Table has to be update if
       
   186         // - new CM is added to the destination
       
   187         // - CM is delete from the destination
       
   188         // - CM priority modified
       
   189         TBool iDNTableChanged;
       
   190         
       
   191         //Protection changed
       
   192         TBool   iProtectionChanged;
       
   193         //The last protection level of the destination
       
   194         TUint   iLastProtectionLevel;
       
   195         
       
   196         CCDSNAPMetadataRecord* iMetaDataRec;
       
   197         //Reference counter for the object pool
       
   198         TInt                iRefCounter;
       
   199         //indicates if the Id is valid or not (for the object pool)
       
   200         TBool               iIdIsValid;                
       
   201         CommsDat::CCDAccessPointRecord* iDestAPRecord;
       
   202 
       
   203         friend class CCmDestinationImpl;
       
   204         friend class CCmManagerImpl;
       
   205         TBool               iNewWithId;
       
   206     };
       
   207 /**
       
   208  *  RCmDestination is for getting/setting values of a network destination.
       
   209  *  @lib cmmanager.lib
       
   210  *  @since S60 v3.2
       
   211  */
       
   212 NONSHARABLE_CLASS( CCmDestinationImpl ) : public CBase
       
   213     {
       
   214     public:
       
   215     //=====================================================================
       
   216     // Constructors/Destructors
       
   217     // 
       
   218     public:
       
   219     
       
   220         /** Destructor. */
       
   221         ~CCmDestinationImpl();
       
   222         
       
   223         /** Epoc constructor 
       
   224         * This should be used only by the object pool
       
   225         */
       
   226         IMPORT_C static CCmDestinationImpl* NewL( CCmManagerImpl& aCmMgr,
       
   227                                                   const TDesC& aName );
       
   228         
       
   229         /** Epoc constructor 
       
   230         * This should be used only by the object pool
       
   231         */
       
   232         static CCmDestinationImpl* NewL( CCmManagerImpl& aCmMgr,
       
   233                                          CCmDestinationData* aData );
       
   234         
       
   235         /** Epoc constructor 
       
   236         * This should be used only by the 'R' classes
       
   237         */
       
   238         static CCmDestinationImpl* NewLC( CCmDestinationData* aData );
       
   239         
       
   240         /** Epoc constructor 
       
   241         * This should be used only by the object pool
       
   242         */
       
   243         IMPORT_C static CCmDestinationImpl* NewL( CCmManagerImpl& aCmMgr,
       
   244                                                   TUint aDestinationId );
       
   245         
       
   246     public:
       
   247         /** 
       
   248         * Returns pointer to the CmManager object
       
   249         * Used in 'R' classes
       
   250         */
       
   251         CCmManagerImpl* Cmmgr();
       
   252         //=====================================================================
       
   253         // Conn method handling
       
   254         
       
   255         /**
       
   256         * Create a connection method belonging to the destination
       
   257         * @param aImplementationUid - implementation uid of the connection 
       
   258         * method
       
   259         * @return CCmPluginBaseEng*
       
   260         */
       
   261         CCmPluginBase* CreateConnectionMethodL( TUint32 aBearerType );
       
   262 
       
   263         /**
       
   264         * Create a connection method belonging to the destination
       
   265         * @param aBearerType - implementation uid of the connection 
       
   266         * method
       
   267         * @param aConnMethId - Predefined id for the connection method.
       
   268         * @return CCmPluginBaseEng*
       
   269         */
       
   270         CCmPluginBase* CreateConnectionMethodL( TUint32 aBearerType,
       
   271                                                 TUint32 aConnMethId );
       
   272         /*
       
   273         * Adds an existing connection method to a destination
       
   274         * @param
       
   275         * @return TInt - index in the Connection Method list
       
   276         */
       
   277         TInt AddConnectionMethodL( CCmPluginBase& aConnectionMethod );
       
   278         
       
   279         /*
       
   280         * Embeds an existing destination to the destination
       
   281         * @param CCmDestinationImpl - Destinatio to be embedded
       
   282         * @return TInt - index in the Connection Method list
       
   283         */
       
   284         TInt AddEmbeddedDestinationL( CCmDestinationImpl& aDestination );        
       
   285         
       
   286         /**
       
   287         * Remove a connection method from a destination and delete it
       
   288         * on update. 
       
   289         * Exception: conenction method is not deleted  if it's referenced 
       
   290         * from any other destination.
       
   291         * @param aConnectionMethod the connection method to be deleted
       
   292         * @return none.
       
   293         */
       
   294         void DeleteConnectionMethodL( CCmPluginBase& aConnectionMethod ); 
       
   295     
       
   296         /**
       
   297         * Remove connection method from the destination
       
   298         * @param aConnectionMethod connection method to be removed
       
   299         */
       
   300         void RemoveConnectionMethodL( const CCmPluginBase& aConnectionMethod );
       
   301     
       
   302         /**
       
   303         * Remove connection method from the destination
       
   304         * @param aConnectionMethod connection method to be removed
       
   305         */
       
   306         void RemoveConnectionMethodL( const CCmPluginBaseEng& aConnectionMethod );
       
   307         
       
   308         /**
       
   309         * Notification from child plugin that it was deleted.
       
   310         * Remove it from the array and update priorities.
       
   311         * @param aConnectionMethod child connection method that was deleted.
       
   312         */
       
   313         void ConnectionMethodDeletedL( const CCmPluginBase& aConnectionMethod );
       
   314         
       
   315         /**
       
   316         * Set the CCMItem's priority based on the passed new index
       
   317         * @param aCCMItem The connection method item
       
   318         * @param aIndex The new index of the item in the list
       
   319         */
       
   320         void ModifyPriorityL( CCmPluginBase& aCCMItem, TUint aIndex );
       
   321 
       
   322         /**
       
   323         * Obsolete 
       
   324         */
       
   325         TUint PriorityL( CCmPluginBaseEng& aCCMItem );
       
   326 
       
   327         /**
       
   328         * Return the priority of the passed connection method
       
   329         * @param aCCMItem queried connection method
       
   330         * @return the priority of the queried connection method 
       
   331         */
       
   332         TUint PriorityL( CCmPluginBase& aCCMItem );
       
   333         
       
   334         /**
       
   335         * Returns the number of connection methods of the destination
       
   336         * @param None
       
   337         * @return TInt        
       
   338         */                  
       
   339         IMPORT_C TInt ConnectionMethodCount();
       
   340         
       
   341         //Operator
       
   342 
       
   343         /**
       
   344         * Obsolete
       
   345         */
       
   346         IMPORT_C CCmPluginBaseEng* ConnectionMethodL( TInt anIndex );
       
   347 
       
   348         /**
       
   349         * Returns a reference to the connection method. 
       
   350         * The index must be less than the return value of ConnMethodCount()
       
   351         * @param anIndex
       
   352         * @return plugin instance - ownership NOT passed
       
   353         */         
       
   354         IMPORT_C CCmPluginBase* GetConnectionMethodL( TInt anIndex );
       
   355 
       
   356         /**
       
   357         * Returns a reference to the connection method. 
       
   358         * The index must be less than the return value of ConnMethodCount()
       
   359         * @param anIapId IAP id of the queried connection method
       
   360         * @return plugin instance - ownership NOT passed
       
   361         */         
       
   362         CCmPluginBase* ConnectionMethodByIDL( TUint32 anIapId );
       
   363 
       
   364         void ConnectMethodIdArrayL( RArray<TUint32>& aCmIds );
       
   365         
       
   366         //Getting attributes
       
   367 
       
   368         /**
       
   369         * Returns the destination's Name attribute
       
   370         * HBuf ownership is passed to the caller
       
   371         * @param None
       
   372         * @return name of the destination. ownership is passed.
       
   373         */      
       
   374         IMPORT_C HBufC* NameLC();                        
       
   375         
       
   376         /**
       
   377         * Returns the destination's Id attribute
       
   378         * @param None
       
   379         * @return TUint32        
       
   380         */
       
   381         inline TUint32 Id(){return iData->Id();};
       
   382 
       
   383         /**
       
   384         * Returns the destination's ElementId attribute
       
   385         * @param None
       
   386         * @return TUint32
       
   387         */            
       
   388         inline TUint32 ElementId(){ return iData->ElementId();};
       
   389      
       
   390         /**
       
   391         * Returns the Icon pointer
       
   392         * This fucton leaves if the client does not have a valid UI context
       
   393         * @param None
       
   394         * @return TUint32  
       
   395         */ 
       
   396         IMPORT_C CGulIcon* IconL();
       
   397 
       
   398         /**
       
   399         * Returns the Metadata
       
   400         * @param None
       
   401         * @return TUint32        
       
   402         */            
       
   403         TUint32 MetadataL( CMManager::TSnapMetadataField aMetaField ) const;
       
   404         
       
   405         /**
       
   406         * Returns if there's connection created with any of the destination's
       
   407         * connection method.
       
   408         * @return ETrue if there's connection with any of the destination's
       
   409         * connection method.
       
   410         */
       
   411         IMPORT_C TBool IsConnectedL() const;
       
   412 
       
   413         //=====================================================================
       
   414         //Setting Attributes
       
   415         
       
   416         /**
       
   417         * Set the destination's Name attribute. Leaves if the name already 
       
   418         * exists
       
   419         * @param aDestinationName value to set
       
   420         * @return None   
       
   421         */
       
   422         IMPORT_C void SetNameL( const TDesC& aName );
       
   423            
       
   424         /**
       
   425         * Set the destination's Icon index.
       
   426         * This fucton leaves if the client does not have a valid UI context
       
   427         * @param aIconIndex value to set
       
   428         * @return None   
       
   429         */
       
   430         IMPORT_C void SetIconL( TUint32 anIndex );
       
   431     
       
   432         /**
       
   433         * Set the Metadata
       
   434         * @param aMetaField field to be modified
       
   435         * @param aValue value to be set
       
   436         */            
       
   437         void SetMetadataL( CMManager::TSnapMetadataField aMetaField, 
       
   438                            TUint32 aValue );    
       
   439     
       
   440         /**
       
   441         * Returns that the destination is protected or not.
       
   442         * @return protection level   
       
   443         */
       
   444         IMPORT_C CMManager::TProtectionLevel ProtectionLevel();
       
   445         
       
   446         /**
       
   447         * Set the protection of the destination.
       
   448         * @param aProtectionLevel
       
   449         * @return None   
       
   450         */
       
   451         IMPORT_C void SetProtectionL( CMManager::TProtectionLevel aProtectionLevel );
       
   452         
       
   453         /**
       
   454         * Update all the attributes of the Connection Methods and the 
       
   455         * Destination.
       
   456         * @return None   
       
   457         */        
       
   458         IMPORT_C void UpdateL();         
       
   459     
       
   460         /**
       
   461         * Deletes it's connection methods from comms.dat (unless shared)
       
   462         * then deletes itself
       
   463         */
       
   464         IMPORT_C void DeleteLD();
       
   465         
       
   466         /**
       
   467         * Performs RollbackTransactionL().
       
   468         */
       
   469         void Close();
       
   470         
       
   471         /**
       
   472         * Set iPlugin to NULL in plugin array, but not delete it.
       
   473         * Next reference to this connection method will load the
       
   474         * plugin again.
       
   475         */
       
   476         void PluginClosed( CCmPluginBase* aPlugin );
       
   477         
       
   478         /**
       
   479         * Returns that the destination is hidden or not.
       
   480         * @param None
       
   481         * @return TBool   
       
   482         */
       
   483         IMPORT_C TBool IsHidden(); 
       
   484         
       
   485         /**
       
   486         * Set that the destination is hidden or not.
       
   487         * @param aHidden - True if it is hidden.
       
   488         * @return None   
       
   489         */
       
   490         IMPORT_C void SetHiddenL( TBool aHidden );         
       
   491         
       
   492         /**
       
   493         * Check if the destination element id is already embeded.
       
   494         * Leaves with KErrNotSupported (multiple levels of embedding is not 
       
   495         * supported)
       
   496         */
       
   497         void CheckIfEmbeddedL( TInt aId );
       
   498         
       
   499         
       
   500         static CGulIcon* IconIdL( CCmManagerImpl& aCmMgr,
       
   501                                   CommsDat::TMDBElementId aId );
       
   502                 
       
   503         static CMManager::TProtectionLevel ProtectionLevelL( CCmManagerImpl& aCmMgr,
       
   504                                                   CommsDat::TMDBElementId aId );
       
   505         
       
   506         /**
       
   507         * Removes this destination from the object pool.
       
   508         */
       
   509         IMPORT_C void RemoveFromPool();
       
   510 
       
   511         /**
       
   512         * Increments the reference counter. Used by the object pool.
       
   513         */
       
   514         void IncrementRefCounter();
       
   515         /**
       
   516         * Increments the reference counter. Used by the object pool.
       
   517         */
       
   518         void DecrementRefCounter();
       
   519         /**
       
   520         * Returns the reference counter. Used by the object pool.
       
   521         * @return TInt
       
   522         */
       
   523         TInt GetRefCounter();
       
   524 
       
   525         /**
       
   526         * Returns iData. Used by the object pool and the API oprators.
       
   527         * @return TInt
       
   528         */
       
   529         CCmDestinationData* GetData();
       
   530         /**
       
   531         * Used by the object pool and the API oprators.
       
   532         */
       
   533         void SetData(CCmDestinationData* aData);
       
   534         /**
       
   535         * Indicates if the Id is valid or if this is a new object which sitll
       
   536         * haven't been updated. 
       
   537         * Used by the object pool.
       
   538         * @return TBool
       
   539         */
       
   540         TBool IdIsValid();
       
   541 
       
   542         /**
       
   543         * Returns pointer to embedded destination if there is any
       
   544         * @return CCmDestinationImpl* Pointer to embedded destination
       
   545         * Contains NULL if there is no destination embedded
       
   546         */        
       
   547         CCmDestinationImpl* EmbeddedL();
       
   548         
       
   549         /**
       
   550         * Checks if this destination plus a possible embedded destinaion
       
   551         * contains a connection method which can be used for a connection
       
   552         * Doesn't check VPNs!
       
   553         * @return TBool ETrue if this destination or a destination embedded into
       
   554         * it contains a connection method. Otherwise returns EFalse
       
   555         */            
       
   556         TBool CanUseToConnectL();
       
   557         
       
   558         
       
   559         /**
       
   560         * Reload connection method under this destination so as to
       
   561         * keep synchronization with CommsDat
       
   562         */
       
   563         void ReLoadConnectionMethodsL();
       
   564 
       
   565         /** Epoc constructor 
       
   566         * This should be used only by the object pool
       
   567         */
       
   568         static CCmDestinationImpl* NewL( CCmManagerImpl& aCmMgr,
       
   569                                          const TDesC& aName,
       
   570                                          TUint32 aDestId);
       
   571                                          
       
   572 
       
   573         /**
       
   574         * Returns the Id of this Destination which is used to identify the Destination.
       
   575         * It is the Id saved to Destination Access Point's Tag field.
       
   576         */            
       
   577         TUint32 GetDestinationAPTagId();
       
   578 
       
   579         /**
       
   580         * Checks if this destination already contains the given Connection Method
       
   581         * @param aConnectionMethod Connection Method to be checked whether it 
       
   582         * already exists.
       
   583         * @return TBool ETrue if this Destination contais already the given CM. If the
       
   584         * Destination does not contain the given CM returns EFalse. Otherwise leaves
       
   585         * with system-wide error code.
       
   586         */            
       
   587         TBool CheckIfCMExistsL( CCmPluginBase& aConnectionMethod );
       
   588 
       
   589             
       
   590     //=========================================================================
       
   591     // Construction
       
   592     //
       
   593     private:    
       
   594     
       
   595         /**
       
   596         * Default constructor. 
       
   597         * @param aCmManager connection method manager
       
   598         */
       
   599         CCmDestinationImpl( CCmManagerImpl& aCmMgr );
       
   600 
       
   601         /*
       
   602         * Create a new destination with the specified name
       
   603         */
       
   604         void ConstructL( const TDesC& aName );
       
   605 
       
   606         void ConstructL( const TDesC& aName, TUint32 aDestId );
       
   607 
       
   608         /*
       
   609         * Create a destination and initializes it 
       
   610         * from the commsdat based on the id
       
   611         */
       
   612         void ConstructL( TUint aDestinationId );
       
   613 
       
   614     //=========================================================================
       
   615     // New functions
       
   616     //
       
   617     private:
       
   618                           
       
   619         /**
       
   620         * Check if the destination contains and embedded destination
       
   621         * @since S60 3.2
       
   622         * @return ETrue if the destination contains and embedded destination   
       
   623         */
       
   624         TBool HasEmbeddedL();        
       
   625     
       
   626         /**
       
   627         * - Check if transaction is already opened
       
   628         * - Set iOwnTransaction is not and opens it and
       
   629             put 'this' on cleanup&close stack
       
   630         */
       
   631         void OpenTransactionLC();
       
   632         
       
   633         /**
       
   634         * - Check if the transaction is ours.
       
   635         * - If yes, commits the transaction.
       
   636         * - anyway does nothing
       
   637         * @praram aError - error id
       
   638         */
       
   639         void CommitTransactionL( TInt aError );
       
   640         
       
   641         /**
       
   642         * Rollback transaction.
       
   643         */
       
   644         void RollbackTransaction();
       
   645 
       
   646         /**
       
   647         * Returns the CommsDat session.
       
   648         * Do not close!
       
   649         * @return commsdat session
       
   650         */
       
   651         CommsDat::CMDBSession& Session()const;
       
   652         
       
   653         /**
       
   654         * Find the connection method in iConnMethodArray.
       
   655         * @param aConnectionMethod connection method to be searched for
       
   656         * @return index of the found item
       
   657         */
       
   658         TInt FindConnectionMethodL( const CCmPluginBase& aConnectionMethod );
       
   659         
       
   660         /**
       
   661         * Find the connection method in iConnMethodArray.
       
   662         * @param aConnectionMethod connection method to be searched for
       
   663         * @return index of the found item
       
   664         */
       
   665         TInt FindConnectionMethodL( const CCmPluginBaseEng& aConnectionMethod );
       
   666         
       
   667         /**
       
   668         * Update protection attributes of every connection method if changed.
       
   669         */
       
   670         void UpdateProtectionL();
       
   671 
       
   672         /**
       
   673         * Update every connection method.
       
   674         */
       
   675         void UpdateConnectionMethodsL();
       
   676         
       
   677         /**
       
   678         * Create or update the record of the network table for this 
       
   679         * destination.
       
   680         */
       
   681         void UpdateNetworkRecordL();
       
   682 
       
   683         /**
       
   684         * Update the SNAP table
       
   685         */
       
   686         void UpdateSNAPTableL();
       
   687         
       
   688         /**
       
   689         * Update the SNAP Metadata table
       
   690         */        
       
   691         void UpdateSNAPMetadataTableL();
       
   692         
       
   693         /**
       
   694         * Load network record. Destination id is passed, because
       
   695         * id is from the client application, and destinaion id
       
   696         * is the network id for them. :)
       
   697         * @param aDestinationId network record id
       
   698         */        
       
   699         void LoadNetworkRecordL( TUint32 aDestinationId );
       
   700 
       
   701         /**
       
   702         * Load Destination AP record. Destination id is passed, because
       
   703         * id is from the client application, and destinaion id
       
   704         * is the network id for them. :)
       
   705         * @param aDestinationId network record id
       
   706         */        
       
   707         void LoadDestAPRecordL( TUint32 aDestinationId );
       
   708 
       
   709         /**
       
   710         * Load connection methods of the destination
       
   711         */        
       
   712         void LoadConnectionMethodsL();
       
   713         
       
   714         /**
       
   715         * Load SNAP Metadata table
       
   716         */        
       
   717         void LoadSNAPMetadataTableL();        
       
   718         
       
   719         /**
       
   720         * Create a connection method belonging to the destination
       
   721         * @param aImplementationUid - implementation uid of the connection 
       
   722         * method
       
   723         * @param aParams - plugin init param
       
   724         * @return CCmPluginBaseEng*
       
   725         */        
       
   726         CCmPluginBase* CreateConnectionMethodL( TUid aImplementationUid, 
       
   727                                                    TCmPluginInitParam& aParams );
       
   728                 
       
   729         /**
       
   730         * Compare two records from DNIAP by their priority field.
       
   731         * @param aLeft one record from DN_IAP table.
       
   732         * @param aRight one record from DN_IAP table.
       
   733         * @return
       
   734         *   - negative value, if aLeft is less than aRight;
       
   735         *   - 0,              if aLeft equals to aRight;
       
   736         *   - positive value, if aLeft is greater than aRight.
       
   737         */
       
   738         static TInt SortRecordsByPriority( const CommsDat::CMDBRecordBase& aLeft, 
       
   739                                            const CommsDat::CMDBRecordBase& aRight);
       
   740         
       
   741         /**
       
   742         * Add an item to the Connection Method array based on bearer priority 
       
   743         * table.
       
   744         * @param aItem An item to be added.
       
   745         * @return TInt the index of the added item. The array contains an initial item,
       
   746         * so always SUBTRACT KCmInitIndex to get the connection method index number!!!
       
   747         */        
       
   748         TInt AddToArrayL( CPluginItem* aItem );
       
   749         
       
   750         /**
       
   751         * IAP is considered to be removed from the commsdat by third 
       
   752         * party (someone else external).
       
   753         * Seamlessness entries should also be removed.
       
   754         * @param aIapId Iap was removed        
       
   755         */        
       
   756         void CleanUpSeamlessnessTableL( TUint32 aIapId );
       
   757         
       
   758         /**
       
   759         * Embedded dest is considered to be removed from the commsdat 
       
   760         * by third party (someone else external).
       
   761         * Snap Metadata entries should also be removed.
       
   762         * @param aSnap Id was removed        
       
   763         */          
       
   764         void CleanUpSnapMetadataTableL( TUint32 aSnap );        
       
   765         
       
   766         /**
       
   767         * Embedded dest is considered to be removed from the commsdat 
       
   768         * by third party (someone else external).
       
   769         * Snap Metadata entries should also be removed.
       
   770         * @param aSnap Id was removed        
       
   771         */          
       
   772         void CleanUpEmbeddedL( TUint32 aDestId );        
       
   773         
       
   774         /**
       
   775         * Create and load plugin.
       
   776         * @param item where plugin has to be loaded.
       
   777         */
       
   778         void LoadPluginL( CPluginItem& aItem );
       
   779         
       
   780         
       
   781         /**
       
   782         * Create embedded destination plugin.
       
   783         * @param aItem - plugin item
       
   784         * @param TUint32 destination id
       
   785         */        
       
   786         void CreateEmbeddedDestinationPluginL( CPluginItem& aItem, 
       
   787                                                TInt aDestinationId );
       
   788         /**
       
   789         * Load embedded destination plugin.
       
   790         * @param aItem - plugin item
       
   791         */        
       
   792         void LoadEmbeddedDestinationPluginL( CPluginItem& aItem );
       
   793         
       
   794         /**
       
   795         * Check if there is destination with this name. 
       
   796         * Leaves with KErrAlreadyExists if name already exists
       
   797         * @param aName destination name
       
   798         */        
       
   799         void CheckIfDestinationNameExistL( const TDesC& aName );
       
   800         
       
   801         /**
       
   802         * Set or clear attribute
       
   803         * @aRecord record of which the attribute is to be set or clear
       
   804         * @aAttribute attribute to be set or clear
       
   805         * @aSet ETrue to set
       
   806         */        
       
   807         void SetAttribute( CommsDat::CMDBRecordBase* aRecord, 
       
   808                            TUint32 aAttribute, 
       
   809                            TBool aSet );
       
   810 
       
   811 
       
   812         /**
       
   813         * Delete all connection methods.
       
   814         * @since S60 3.2
       
   815         */
       
   816         void DeleteConnectionMethodsL();
       
   817         
       
   818         /**
       
   819         * Reference to a non-existing IAP found in the SNAP table.
       
   820         * Remove the SNAP record and the metadata record of this
       
   821         * IAP. IAP is most probably deleted by APEngine.
       
   822         * @param aSnapRecord SNAP record point to a non-existing IAP
       
   823         */
       
   824         void DeleteIAPRecordsL( CommsDat::CMDBRecordBase* aSnapRecord );
       
   825         
       
   826         /**
       
   827         * Check if the name of the passed record is the same as the name of 
       
   828         * network one, and update it if not.
       
   829         * @param aRecord record to be checked and updated if needed
       
   830         */
       
   831         void CheckIfNameModifiedL( CCDSnapRecord* aRecord );
       
   832         
       
   833         /**
       
   834         * Checks if there's another SNAP with Internet bit set.
       
   835         * Leaves with KErrAlreadyExists if so.
       
   836         */
       
   837         void CheckIfInternetExistsL();
       
   838         
       
   839         /**
       
   840         * Return the index value of the connection method.
       
   841         * @param aCmId id of the connection method
       
   842         * @return index value in iConnMethodArray
       
   843         */
       
   844         TInt ConnectionMethodIndex( TUint32 aCmId );
       
   845         
       
   846         /**
       
   847         * Retrieves the base of the priority counts in cm list
       
   848         * It is the data of the plugin in case of none VPN.
       
   849         * It is the data of the underlying cm in case of VPN over cm.
       
   850         * It is "wildcard" in case of VPN over destination. 
       
   851         * aRetBearer and aRetExtLevel are not filled in this case 
       
   852         * @param aItem the plugin list item which data is get
       
   853         * @param aRetPrio the default priority of the cm in return
       
   854         * @param aRetBearer the bearer of the cm in return
       
   855         * @param aRetExtLevel the extenson level of the cm in return
       
   856         * @return ETrue if the cm is virtual else EFalse
       
   857         */
       
   858         TBool PrioDataL( CPluginItem* aItem, TUint32& aRetPrio, 
       
   859                         TUint32& aRetBearer, TUint32& aRetExtLevel );
       
   860                         
       
   861                             
       
   862                             
       
   863         /**
       
   864         * Determines the position of the inserted item into the cm list.
       
   865         * This determination is based on the similarity of the bearer types.
       
   866         * The inserted position is just after the last item with the
       
   867         * same bearer type and virtuality - if exist else -1. 
       
   868         * @param aBearerType bearer type od the inserted cm
       
   869         * @param aIsVirtual virtuality of the inserted cm 
       
   870         * @return The position in the cm list where the item should be inserted.
       
   871         * If there is no cm with same bearer type in the list then it
       
   872         * returns -1;
       
   873         */
       
   874         TInt InsertSameMethodL( TUint32 aBearerType, TBool aIsVirtual );
       
   875 
       
   876         /**
       
   877         * Determines the position of the inserted item into the cm list.
       
   878         * This determination is based on the priority and the extension
       
   879         * level of the cm's. 
       
   880         * @param aPrio default bearer type of the inserted cm
       
   881         * @param aExtLevel extension level of the inserted cm 
       
   882         * @return The position in the cm list where the item should be inserted.
       
   883         */
       
   884         TInt InsertPriorityMethodL( TUint32 aPrio, TUint32 aExtLevel );
       
   885                                  
       
   886         /**
       
   887         * Checks if there's another SNAP with the same localised bit set.
       
   888         * Leaves with KErrAlreadyExists if so.
       
   889         */
       
   890         void CheckIfLocalisedDestExistL( TUint32 aValue );
       
   891 
       
   892         /**
       
   893         * Checks if there's another SNAP with the same purpose bit set.
       
   894         * Leaves with KErrAlreadyExists if so.
       
   895         */
       
   896         void CheckIfPurposeExistL( TUint32 aValue );
       
   897 
       
   898         static CGulIcon* IconL( TInt aIconIndex );
       
   899         static CMManager::TProtectionLevel ProtectionLevel( CCDSNAPMetadataRecord* aMetaDataRec );
       
   900 
       
   901         /**
       
   902         * Deletes all the recordsrelated to this Destination to be
       
   903         * deleted.
       
   904         * @param None
       
   905         * @return        
       
   906         */
       
   907         void DeleteRelatedRecordsL( TInt aCount );
       
   908 
       
   909         /**
       
   910         * Checks if this(current) destination is referenced by any
       
   911         * Virtual Connection Method.
       
   912         * @param None
       
   913         * Leaves with KErrLocked if it's referenced.
       
   914         */
       
   915         void CheckIfReferencedByVirtualCML();
       
   916 
       
   917         /**
       
   918         * Initializes the Destination AccessPoint record
       
   919         * deleted.
       
   920         * @param aDestAPRecord Record to be initialized
       
   921         * @return
       
   922         */
       
   923         void InitializeDestAPRecordL();
       
   924 
       
   925         /**
       
   926         * Sets the given (tag)id to the accesspoint record
       
   927         * @param aDestId Id to be set
       
   928         * @return
       
   929         */
       
   930         void SetIdL( TInt aDestId );
       
   931 
       
   932         /**
       
   933         * Checks that there isn't any destination with the given (tag)id.
       
   934         * @param aDestId Id to be checked
       
   935         * @return
       
   936         */
       
   937         void CheckIfDestinationIdExistsL( TUint32 aDestId );
       
   938 
       
   939         /**
       
   940         * Create or update the record of the accesspoint table for this 
       
   941         * destination.
       
   942         */
       
   943         void UpdateDestAPRecordL();
       
   944 
       
   945         /**
       
   946         * Creates an unique (tag)id to the record of the accesspoint table for this 
       
   947         * destination.
       
   948         */
       
   949         TUint32 CreateDestinationAPTagIdL();
       
   950 
       
   951         /**
       
   952         * Sets the default Tier Manager to the accesspoint record for this 
       
   953         * destination.
       
   954         */
       
   955         void SetDefaultTierManagerL();
       
   956 
       
   957         /**
       
   958         * Sets the default Meta Connection Provider to the accesspoint record for this 
       
   959         * destination.
       
   960         */
       
   961         void SetDefaultMCprL();
       
   962 
       
   963         /**
       
   964         * Sets the default Connection Provider to the accesspoint record for this 
       
   965         * destination.
       
   966         */
       
   967         void SetDefaultCprL();
       
   968 
       
   969         /**
       
   970         * Sets the default Subconnection Provider to the accesspoint record for this 
       
   971         * destination.
       
   972         */
       
   973         void SetDefaultSCprL();
       
   974 
       
   975         /**
       
   976         * Sets the default Protocol to the accesspoint record for this 
       
   977         * destination.
       
   978         */
       
   979         void SetDefaultProtocolL();
       
   980         
       
   981     //=========================================================================        
       
   982     // Member variables
       
   983     //
       
   984     private: 
       
   985         CCmManagerImpl&     iCmMgr;         //< Not owned
       
   986         CCmDestinationData* iData;
       
   987     private:
       
   988     
       
   989         friend class CCmManagerImpl;
       
   990     };
       
   991     
       
   992 #endif // DESTINATIONIMPL_H