cmmanager/cmmgr/cmmserver/inc/cmminstancemapping.h
changeset 20 9c97ad6591ae
child 27 489cf6208544
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
       
     1 /*
       
     2 * Copyright (c) 2009-2010 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:
       
    15 * Keeps track of the general destination/connection method structure in
       
    16 * database.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef CMMINSTANCEMAPPING_H_
       
    22 #define CMMINSTANCEMAPPING_H_
       
    23 
       
    24 #include <e32base.h>
       
    25 
       
    26 #include "cmmcache.h"
       
    27 #include "cmmconnmethoditem.h"
       
    28 
       
    29 
       
    30 NONSHARABLE_CLASS( CDestination ) : public CBase
       
    31     {
       
    32 public:
       
    33     static CDestination* NewL();
       
    34     static CDestination* NewLC();
       
    35     ~CDestination();
       
    36 
       
    37 private:
       
    38     CDestination();
       
    39     void ConstructL();
       
    40 
       
    41 public:
       
    42     // The destination ID.
       
    43     TUint32 iId;
       
    44 
       
    45     // Array of connection methods inside this destination. Includes also
       
    46     // embedded destinations.
       
    47     RArray<TCmmConnMethodItem> iConnMethodItemArray;
       
    48 
       
    49     // IDs for unsupported connection methods inside this destination.
       
    50     RArray<TUint32> iUnsupportedConnMethods;
       
    51     };
       
    52 
       
    53 
       
    54 NONSHARABLE_CLASS( CCmmInstanceMapping ) : public CBase
       
    55     {
       
    56 public:
       
    57     /**
       
    58      * NewL.
       
    59      */
       
    60     static CCmmInstanceMapping* NewL( CCmmCache& aCache );
       
    61 
       
    62     /**
       
    63      * NewLC.
       
    64      */
       
    65     static CCmmInstanceMapping* NewLC( CCmmCache& aCache );
       
    66 
       
    67     /**
       
    68      * Destructor.
       
    69      */
       
    70     ~CCmmInstanceMapping();
       
    71 
       
    72 private:
       
    73     /**
       
    74      * Constructor.
       
    75      *
       
    76      * @param aCache database cache object.
       
    77      */
       
    78     CCmmInstanceMapping( CCmmCache& aCache );
       
    79 
       
    80     /**
       
    81      * Second phase constructor.
       
    82      */
       
    83     void ConstructL();
       
    84 
       
    85 public: //TODO, sort methods, they are currently in mixed order in .cpp file.
       
    86     /**
       
    87      * Update the connection method and destination structures to current state.
       
    88      */
       
    89     void RefreshL();
       
    90 
       
    91     /**
       
    92      * Check if the given ID is a valid existing destination ID.
       
    93      */
       
    94     TBool ValidDestinationId( const TUint32& aId ) const;
       
    95 
       
    96     /**
       
    97      * Check if the given ID is a valid existing connection method ID.
       
    98      */
       
    99     TBool ValidConnMethodId( const TUint32& aId ) const;
       
   100 
       
   101     /**
       
   102      * Check from database if the given destination is an embedded destination
       
   103      * in any other destination.
       
   104      */
       
   105     TBool DestinationIsEmbedded( const TUint32& aDestinationId ) const;
       
   106 
       
   107     /**
       
   108      * Check from database if the given destination has an embedded destination.
       
   109      */
       
   110     TBool DestinationHasEmbedded( const TUint32& aDestinationId ) const;
       
   111 
       
   112     /**
       
   113      * Check from database if the given destination is pointed to by any
       
   114      * virtual IAP.
       
   115      */
       
   116     TBool DestinationPointedToByVirtualIap( const TUint32& aDestinationId ) const;
       
   117 
       
   118     /**
       
   119      * Check from database if the given connection method is pointed to by any
       
   120      * virtual IAP.
       
   121      */
       
   122     TBool ConnMethodPointedToByVirtualIap( const TUint32& aConnMethodId ) const;
       
   123 
       
   124     /**
       
   125      * Check if the given connection method is the only connection method in
       
   126      * the given destination and if a virtual IAP points to that destination.
       
   127      */
       
   128     TBool ConnMethodInDestinationButLocked(
       
   129             const TUint32& aConnMethodId,
       
   130             const TUint32& aDestinationId ) const;
       
   131 
       
   132     /**
       
   133      * Get bearer type of connection method matching given ID.
       
   134      * Return KErrNone if ID is found, KErrNotFound if not.
       
   135      */
       
   136     TInt GetConnMethodBearerType( const TUint32& aConnMethodId, TUint32& bearerType ) const;
       
   137 
       
   138     /**
       
   139      * Returns the number of destinations the provided connection method
       
   140      * belongs to.
       
   141      */
       
   142     TInt DestinationsContainingConnMethod( const TUint32& aConnMethodId ) const;
       
   143 
       
   144     /**
       
   145      * Returns all conenction method IDs. Unsupported connection methods are
       
   146      * included if aCheckBearerType is set to EFalse.
       
   147      */
       
   148     void GetAllConnMethodsL(
       
   149             RArray<TUint32>& aConnMethodArray,
       
   150             TBool aCheckBearerType = ETrue ) const;
       
   151 
       
   152     /**
       
   153      * Returns the number of destinations.
       
   154      */
       
   155     TInt GetDestinationCount() const;
       
   156 
       
   157     /**
       
   158      * Returns all the valid destinations.
       
   159      */
       
   160     void GetDestinationsL( RArray<TUint32>& aDestinationArray ) const;
       
   161 
       
   162     /**
       
   163      * Inserts all the valid connection methods inside the given destination
       
   164      * into the provided connection method item array. The array is reset first.
       
   165      */
       
   166     void GetConnMethodsFromDestinationL(
       
   167             const TUint32& aDestinationId,
       
   168             RArray<TCmmConnMethodItem>& aConnMethodArray ) const;
       
   169 
       
   170     /**
       
   171      * Returns ETrue if the provided connection method belongs to any other
       
   172      * destination than the one given.
       
   173      */
       
   174     TBool ConnMethodInOtherDestination(
       
   175             const TUint32& aConnMethodId,
       
   176             const TUint32& aDestinationId );
       
   177 
       
   178     /**
       
   179      * Return the EasyWLAN IAP ID, zero if not found or WLAN not supported.
       
   180      */
       
   181     TUint32 EasyWlanIdL();
       
   182 
       
   183     /**
       
   184      * Find out the internet destination ID. ID is set to 0 if not found.
       
   185      */
       
   186     void InternetDestinationIdL( TUint& aInternetDestinationId );
       
   187 
       
   188     /**
       
   189      * Add a connection method ID to deleted list. Ignores any duplicates. Also
       
   190      * removes the connection method from destination/connection method
       
   191      * structures so Refresh()-call is not needed.
       
   192      */
       
   193     void AddConnMethodToDeletedListL( const TUint& aConnMethodId );
       
   194 
       
   195     /**
       
   196      * Remove a connection method ID from deleted list. Nothing happens if ID
       
   197      * is not found from the list.
       
   198      */
       
   199     void RemoveConnMethodFromDeletedList( const TUint& aConnMethodId );
       
   200 
       
   201     /**
       
   202      * Add a destination ID to deleted list. Ignores any duplicates. Also
       
   203      * removes the destination from destination/connection method structures
       
   204      * so Refresh()-call is not needed.
       
   205      */
       
   206     void AddDestinationToDeletedListL( const TUint& aDestinationId );
       
   207 
       
   208     /**
       
   209      * Remove a destination ID from deleted list. Nothing happens if ID is not
       
   210      * found from the list.
       
   211      */
       
   212     void RemoveDestinationFromDeletedList( const TUint& aDestinationId );
       
   213 
       
   214     /**
       
   215      * Remove the connection method from current destination/connection method
       
   216      * structures. This is a lot faster than calling Refresh().
       
   217      */
       
   218     void RemoveConnMethod( const TUint32& aConnMethodId );
       
   219 
       
   220     /**
       
   221      * Remove the connection method from current destination/connection method
       
   222      * structures. This is a lot faster than calling Refresh(). The ID of any
       
   223      * changed destination is added to the aChangedDestinations-array.
       
   224      */
       
   225     void RemoveConnMethod(
       
   226             const TUint32& aConnMethodId,
       
   227             RArray<TUint32>& aChangedDestinations );
       
   228 
       
   229     /**
       
   230      * Remove the destination from current destination/connection method
       
   231      * structures. This is a lot faster than calling Refresh().
       
   232      */
       
   233     void RemoveDestination( const TUint32& aDestinationId );
       
   234 
       
   235     /**
       
   236      * Remove the connection method from all destinations in the current
       
   237      * destination/connection method structures. This is a lot faster than
       
   238      * calling Refresh(). The ID of any changed destination is added to the
       
   239      * aChangedDestinations-array.
       
   240      */
       
   241     void RemoveConnMethodFromDestinations(
       
   242             const TUint32& aConnMethodId,
       
   243             RArray<TUint32>& aChangedDestinations );
       
   244 
       
   245 private:
       
   246     /**
       
   247      * Reads all connection methods from database.
       
   248      */
       
   249     void ReadAndValidateConnMethodsL();
       
   250 
       
   251     /**
       
   252      * Reads all destinations and the connection methods inside them.
       
   253      */
       
   254     void ReadAndValidateDestinationsL();
       
   255 
       
   256     /**
       
   257      * Returns the reference to shared CommsDat session handle.
       
   258      */
       
   259     CommsDat::CMDBSession& Session() const;
       
   260 
       
   261 private:
       
   262     // The database cache object.
       
   263     CCmmCache& iCache;
       
   264 
       
   265     // All supported connection methods. Does not include any embedded destinations.
       
   266     RArray<TCmmConnMethodItem> iConnMethodItemArray;
       
   267 
       
   268     // IDs for all unsupported connection methods.
       
   269     RArray<TUint32> iUnsupportedConnMethods;
       
   270 
       
   271     // All destinations.
       
   272     RPointerArray<CDestination> iDestinations;
       
   273 
       
   274     // Connection methods that are deleted, but not removed from database yet
       
   275     // because some handles are still open to them and ID needs to be kept
       
   276     // reserved. Kept in unsigned integer order.
       
   277     RArray<TUint> iDeletedConnMethods;
       
   278 
       
   279     // Destinations that are deleted, but not removed from database yet because
       
   280     // some handles are still open to them and ID needs to be kept reserved.
       
   281     // Kept in unsigned integer order.
       
   282     RArray<TUint> iDeletedDestinations;
       
   283 
       
   284     // EasyWLAN IAP ID, KMaxTUint32 if not known.
       
   285     TUint32 iEasyWlanId;
       
   286     };
       
   287 
       
   288 #endif // CMMINSTANCEMAPPING_H_
       
   289 
       
   290 // End of file