cmmanager/cmmgr/cmmserver/inc/cmmdestinationstruct.h
changeset 20 9c97ad6591ae
child 23 7ec726f93df1
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 * Cache side object representing a destination.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CMMDESTINATIONSTRUCT_H_
       
    21 #define CMMDESTINATIONSTRUCT_H_
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <commsdattypesv1_1.h>
       
    25 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    26 #include <commsdattypesv1_1_partner.h>
       
    27 #include <commsdattypesv1_1_internal.h>
       
    28 #include <commsdattypeinfov1_1_internal.h>
       
    29 #endif
       
    30 
       
    31 #include "cmmserverdefs.h"
       
    32 
       
    33 class CCmmTransactionHandler;
       
    34 class CCmmDestinationInstance;
       
    35 class CCmmCache;
       
    36 class CCDSNAPMetadataRecord;
       
    37 
       
    38 
       
    39 NONSHARABLE_CLASS( CCmmDestinationStruct ) : public CBase
       
    40     {
       
    41 public:
       
    42     static CCmmDestinationStruct* NewL(
       
    43             CCmmCache* aCache,
       
    44             CCmmTransactionHandler* aTransactionHandler,
       
    45             const TUint32& aId );
       
    46     static CCmmDestinationStruct* NewL(
       
    47             CCmmCache* aCache,
       
    48             CCmmTransactionHandler* aTransactionHandler,
       
    49             const TDesC& aName,
       
    50             const TUint32& aId );
       
    51 
       
    52     static CCmmDestinationStruct* NewLC(
       
    53             CCmmCache* aCache,
       
    54             CCmmTransactionHandler* aTransactionHandler,
       
    55             const TUint32& aId );
       
    56     static CCmmDestinationStruct* NewLC(
       
    57             CCmmCache* aCache,
       
    58             CCmmTransactionHandler* aTransactionHandler,
       
    59             const TDesC& aName,
       
    60             const TUint32& aId );
       
    61 
       
    62     virtual ~CCmmDestinationStruct();
       
    63 
       
    64 private:
       
    65     CCmmDestinationStruct( CCmmCache* aCache, CCmmTransactionHandler* aTransactionHandler );
       
    66 
       
    67     // Opens an existing destination, based on ID.
       
    68     void ConstructL( const TUint32& aDestinationId );
       
    69 
       
    70     // Creates a new destination. With name and optionally also with ID.
       
    71     void ConstructL( const TDesC& aName, const TUint32& aId );
       
    72 
       
    73 public:
       
    74     void SetId( const TUint32& aId );
       
    75     TUint32 GetId() const;
       
    76 
       
    77     /**
       
    78      * Get the destination ID from network record. To get a valid ID, this must
       
    79      * be called only during or after a call to UpdateL().
       
    80      */
       
    81     TUint32 GetRealId() const;
       
    82     TDesC& GetDestinationNameL();
       
    83 
       
    84     /**
       
    85      * Gets the current status of this destination struct.
       
    86      */
       
    87     TCmmDestinationStatus GetStatus() const;
       
    88     TInt GetReferenceCount() const;
       
    89 
       
    90     /**
       
    91      * Sets a new status value.
       
    92      */
       
    93     void SetStatus( const TCmmDestinationStatus& aStatus );
       
    94 
       
    95     /**
       
    96      * Set the record status for all records.
       
    97      */
       
    98     void SetStatusForAllRecords( const TCmmRecordStatus& aStatus );
       
    99 
       
   100     void CreateSessionInstanceL( //TODO, rename to CreateDestinationInstanceL ?
       
   101             CCmmDestinationInstance& aDestinationInstance );
       
   102     void RefreshDestinationInstanceL(
       
   103             CCmmDestinationInstance& aDestinationInstance );
       
   104     void LoadRecordL(
       
   105             CCmmDestinationInstance& aDestinationInstance,
       
   106             TCmmDbRecords aRecordType );
       
   107     void UpdateL(
       
   108             CCmmDestinationInstance& aDestinationInstance,
       
   109             CCmmCache* aCache );
       
   110     void DeleteL();
       
   111     TInt SessionInstanceClosed(); //TODO, rename to DestinationInstanceClosed ?
       
   112 
       
   113     /**
       
   114      * Called after this destination has been updated and database transaction
       
   115      * has completed successfully. Sets the internal state of this destination
       
   116      * structure to reflect the new valid state.
       
   117      */
       
   118     void UpdateSuccessful();
       
   119 
       
   120 private:
       
   121     void InitializeDestApRecordL();
       
   122     void SetDefaultTierManagerL();
       
   123     void SetDefaultMCprL();
       
   124     void SetDefaultCprL();
       
   125     void SetDefaultSCprL();
       
   126     void SetDefaultProtocolL();
       
   127     CommsDat::CCDRecordBase* CopyRecordL(
       
   128             TCmmDbRecords aRecordType,
       
   129             CommsDat::CCDRecordBase* aSource );
       
   130 
       
   131 private:
       
   132     // Database cache.
       
   133     CCmmCache* iCache; // Not owned.
       
   134 
       
   135     // The transaction handler.
       
   136     CCmmTransactionHandler* iTransactionHandler; // Not owned.
       
   137 
       
   138     // The access point record.
       
   139     CommsDat::CCDAccessPointRecord* iDestApRecord; // Owned.
       
   140     // The network record.
       
   141     CommsDat::CCDNetworkRecord* iNetworkRecord; // Owned.
       
   142     // The metadata record.
       
   143     CCDSNAPMetadataRecord* iMetadataRecord; // Owned.
       
   144 
       
   145     // Record status variables.
       
   146     TCmmRecordStatus iDestApRecordStatus;
       
   147     TCmmRecordStatus iNetworkRecordStatus;
       
   148     TCmmRecordStatus iMetadataRecordStatus;
       
   149 
       
   150     // Counts number of session side objects referring to this destination.
       
   151     TInt iReferenceCounter;
       
   152 
       
   153     // Destination status.
       
   154     TCmmDestinationStatus iStatus;
       
   155 
       
   156     // Destination ID. If real ID is not available, contains a temporary ID.
       
   157     TUint32 iId;
       
   158 
       
   159     // Destination name for newly created destination.
       
   160     // Only valid until destination is saved to database (status is ECmmDestinationStatusNotSaved).
       
   161     HBufC* iName; // Owned.
       
   162     };
       
   163 
       
   164 #endif // CMMDESTINATIONSTRUCT_H_
       
   165 
       
   166 // End of file