cmmanager/cmmgr/cmmserver/inc/cmminstancemapping.h
branchRCL_3
changeset 58 83ca720e2b9a
parent 57 05bc53fe583b
child 62 bb1f80fb7db2
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
     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<TUint> iUnsupportedConnMethods;
       
    51     
       
    52     // The destination metadata.
       
    53     TUint32 iMetadata;
       
    54     };
       
    55 
       
    56 
       
    57 NONSHARABLE_CLASS( CCmmInstanceMapping ) : public CBase
       
    58     {
       
    59 public:
       
    60     /**
       
    61      * NewL.
       
    62      */
       
    63     static CCmmInstanceMapping* NewL( CCmmCache& aCache );
       
    64 
       
    65     /**
       
    66      * NewLC.
       
    67      */
       
    68     static CCmmInstanceMapping* NewLC( CCmmCache& aCache );
       
    69 
       
    70     /**
       
    71      * Destructor.
       
    72      */
       
    73     ~CCmmInstanceMapping();
       
    74 
       
    75 private:
       
    76     /**
       
    77      * Constructor.
       
    78      *
       
    79      * @param aCache database cache object.
       
    80      */
       
    81     CCmmInstanceMapping( CCmmCache& aCache );
       
    82 
       
    83     /**
       
    84      * Second phase constructor.
       
    85      */
       
    86     void ConstructL();
       
    87 
       
    88 public: //TODO, sort methods, they are currently in mixed order in .cpp file.
       
    89     /**
       
    90      * Update the connection method and destination structures to current state.
       
    91      */
       
    92     void RefreshL();
       
    93 
       
    94     /**
       
    95      * Check if the given ID is a valid existing destination ID.
       
    96      */
       
    97     TBool ValidDestinationId( const TUint32 aId ) const;
       
    98 
       
    99     /**
       
   100      * Check if the given ID is a valid existing connection method ID.
       
   101      */
       
   102     TBool ValidConnMethodId( const TUint32 aId ) const;
       
   103 
       
   104     /**
       
   105      * Check if the given ID is a valid existing unsupported connection method
       
   106      * ID.
       
   107      */
       
   108     TBool UnsupportedConnMethodId( const TUint32 aId ) const;
       
   109 
       
   110     /**
       
   111      * Check from database if the given destination is an embedded destination
       
   112      * in any other destination.
       
   113      */
       
   114     TBool DestinationIsEmbedded( const TUint32 aDestinationId ) const;
       
   115 
       
   116     /**
       
   117      * Check from database if the given destination has an embedded destination.
       
   118      */
       
   119     TBool DestinationHasEmbedded( const TUint32 aDestinationId ) const;
       
   120 
       
   121     /**
       
   122      * Check from database if the given destination is pointed to by any
       
   123      * virtual IAP.
       
   124      */
       
   125     TBool DestinationPointedToByVirtualIap( const TUint32 aDestinationId ) const;
       
   126 
       
   127     /**
       
   128      * Check from database if the given connection method is pointed to by any
       
   129      * virtual IAP.
       
   130      */
       
   131     TBool ConnMethodPointedToByVirtualIap( const TUint32 aConnMethodId ) const;
       
   132 
       
   133     /**
       
   134      * Check if the given connection method is the only connection method in
       
   135      * the given destination and if a virtual IAP points to that destination.
       
   136      */
       
   137     TBool ConnMethodInDestinationButLocked(
       
   138             const TUint32 aConnMethodId,
       
   139             const TUint32 aDestinationId ) const;
       
   140 
       
   141     /**
       
   142      * Get bearer type of connection method matching given ID.
       
   143      * Return KErrNone if ID is found, KErrNotFound if not.
       
   144      */
       
   145     TInt GetConnMethodBearerType( const TUint32 aConnMethodId, TUint32& bearerType ) const;
       
   146 
       
   147     /**
       
   148      * Returns the number of destinations the provided connection method
       
   149      * belongs to.
       
   150      */
       
   151     TInt DestinationsContainingConnMethod( const TUint32 aConnMethodId ) const;
       
   152 
       
   153     /**
       
   154      * Returns the destination ids containing the connection method given as
       
   155      * parameter.
       
   156      */
       
   157     void DestinationsContainingConnMethodL(
       
   158             const TUint32 aConnMethodId,
       
   159             RArray<TUint32>& aDestinationIds ) const;
       
   160 
       
   161     /**
       
   162      * Find and return a copy of a connection method item matching the given ID.
       
   163      * Returns KErrNotFound, if the connection method is not found.
       
   164      */
       
   165     TInt GetConnMethodItem(
       
   166             const TUint32 aConnMethodId,
       
   167             TCmmConnMethodItem& aConnMethodItem ) const;
       
   168 
       
   169     /**
       
   170      * Returns all conenction method IDs. Unsupported connection methods are
       
   171      * included if aCheckBearerType is set to EFalse.
       
   172      */
       
   173     void GetAllConnMethodsL(
       
   174             RArray<TUint32>& aConnMethodArray,
       
   175             TBool aCheckBearerType = ETrue ) const;
       
   176 
       
   177     /**
       
   178      * Returns the number of destinations.
       
   179      */
       
   180     TInt GetDestinationCount() const;
       
   181 
       
   182     /**
       
   183      * Returns all the valid destinations.
       
   184      */
       
   185     void GetDestinationsL( RArray<TUint32>& aDestinationArray ) const;
       
   186 
       
   187     /**
       
   188      * Inserts all the valid connection methods inside the given destination
       
   189      * into the provided connection method item array. The array is reset first.
       
   190      */
       
   191     void GetConnMethodsFromDestinationL(
       
   192             const TUint32 aDestinationId,
       
   193             RArray<TCmmConnMethodItem>& aConnMethodArray ) const;
       
   194 
       
   195     /**
       
   196      * Returns ETrue if the provided connection method belongs to any other
       
   197      * destination than the one given.
       
   198      */
       
   199     TBool ConnMethodInOtherDestination(
       
   200             const TUint32 aConnMethodId,
       
   201             const TUint32 aDestinationId );
       
   202 
       
   203     /**
       
   204      * Return the EasyWLAN IAP ID, zero if not found or WLAN not supported.
       
   205      */
       
   206     TUint32 EasyWlanIdL();
       
   207 
       
   208     /**
       
   209      * Find out the internet destination ID. ID is set to 0 if not found.
       
   210      */
       
   211     void InternetDestinationIdL( TUint& aInternetDestinationId );
       
   212 
       
   213     /**
       
   214      * Add a connection method ID to deleted list. Ignores any duplicates. Also
       
   215      * removes the connection method from destination/connection method
       
   216      * structures so Refresh()-call is not needed.
       
   217      */
       
   218     void AddConnMethodToDeletedListL( const TUint aConnMethodId );
       
   219 
       
   220     /**
       
   221      * Remove a connection method ID from deleted list. Nothing happens if ID
       
   222      * is not found from the list.
       
   223      */
       
   224     void RemoveConnMethodFromDeletedList( const TUint aConnMethodId );
       
   225 
       
   226     /**
       
   227      * Add a destination ID to deleted list. Ignores any duplicates. Also
       
   228      * removes the destination from destination/connection method structures
       
   229      * so Refresh()-call is not needed.
       
   230      */
       
   231     void AddDestinationToDeletedListL( const TUint aDestinationId );
       
   232 
       
   233     /**
       
   234      * Remove a destination ID from deleted list. Nothing happens if ID is not
       
   235      * found from the list.
       
   236      */
       
   237     void RemoveDestinationFromDeletedList( const TUint aDestinationId );
       
   238 
       
   239     /**
       
   240      * Remove the connection method from current destination/connection method
       
   241      * structures. This is a lot faster than calling Refresh().
       
   242      */
       
   243     void RemoveConnMethod( const TUint32 aConnMethodId );
       
   244 
       
   245     /**
       
   246      * Remove the connection method from current destination/connection method
       
   247      * structures. This is a lot faster than calling Refresh(). The ID of any
       
   248      * changed destination is added to the aChangedDestinations-array.
       
   249      * Also adds the ID of any changed destinations to the provided array.
       
   250      */
       
   251     void RemoveConnMethod(
       
   252             const TUint32 aConnMethodId,
       
   253             RArray<TUint32>& aChangedDestinations );
       
   254 
       
   255     /**
       
   256      * Remove the destination from current destination/connection method
       
   257      * structures. This is a lot faster than calling Refresh().
       
   258      */
       
   259     void RemoveDestination( const TUint32 aDestinationId );
       
   260 
       
   261     /**
       
   262      * Remove the connection method from all destinations in the current
       
   263      * destination/connection method structures. This is a lot faster than
       
   264      * calling Refresh(). The ID of any changed destination is added to the
       
   265      * aChangedDestinations-array.
       
   266      */
       
   267     void RemoveConnMethodFromDestinations(
       
   268             const TUint32 aConnMethodId,
       
   269             RArray<TUint32>& aChangedDestinations );
       
   270     
       
   271     /**
       
   272      * Get the metadata of the destination identified with given id.
       
   273      */
       
   274     TUint32 DestinationMetadata( const TUint32 aDestinationId ) const;
       
   275 
       
   276 private:
       
   277     /**
       
   278      * Reads all connection methods from database.
       
   279      */
       
   280     void ReadAndValidateConnMethodsL();
       
   281 
       
   282     /**
       
   283      * Reads all destinations and the connection methods inside them.
       
   284      */
       
   285     void ReadAndValidateDestinationsL();
       
   286 
       
   287     /**
       
   288      * Goes through the internal IAP table, checking all virtual IAPs that link
       
   289      * to an IAP. If the linked IAP is not found, the virtual IAP is removed.
       
   290      */
       
   291     void ValidateVirtualIapsLinkingToIaps();
       
   292 
       
   293     /**
       
   294      * Goes through the internal IAP table, checking all virtual IAPs that link
       
   295      * to a SNAP. If the linked SNAP is not found, the virtual IAP is removed.
       
   296      */
       
   297     void ValidateVirtualIapsLinkingToSnaps();
       
   298 
       
   299     /**
       
   300      * Find the destination item matching the provided destination ID.
       
   301      * Returns a pointer to the internal destination item, NULL if not found.
       
   302      */
       
   303     CDestination* GetDestination( const TUint32 aDestinationId ) const;
       
   304 
       
   305     /**
       
   306      * Returns the reference to shared CommsDat session handle.
       
   307      */
       
   308     CommsDat::CMDBSession& Session() const;
       
   309 
       
   310 private:
       
   311     // The database cache object.
       
   312     CCmmCache& iCache;
       
   313 
       
   314     // All supported connection methods. Does not include any embedded destinations.
       
   315     RArray<TCmmConnMethodItem> iConnMethodItemArray;
       
   316 
       
   317     // IDs for all unsupported connection methods.
       
   318     RArray<TUint> iUnsupportedConnMethods;
       
   319 
       
   320     // All destinations.
       
   321     RPointerArray<CDestination> iDestinations;
       
   322 
       
   323     // Connection methods that are deleted, but not removed from database yet
       
   324     // because some handles are still open to them and ID needs to be kept
       
   325     // reserved. Kept in unsigned integer order.
       
   326     RArray<TUint> iDeletedConnMethods;
       
   327 
       
   328     // Destinations that are deleted, but not removed from database yet because
       
   329     // some handles are still open to them and ID needs to be kept reserved.
       
   330     // Kept in unsigned integer order.
       
   331     RArray<TUint> iDeletedDestinations;
       
   332 
       
   333     // EasyWLAN IAP ID, KMaxTUint32 if not known.
       
   334     TUint32 iEasyWlanId;
       
   335     };
       
   336 
       
   337 #endif // CMMINSTANCEMAPPING_H_
       
   338 
       
   339 // End of file