wvsettings20/IMPSSrc/CIMPSSAPCenRep.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2005 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:  IMPS SAP Settings Store implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CIMPSSAPCENREP_H
       
    20 #define CIMPSSAPCENREP_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <commdb.h>
       
    25 
       
    26 #include "impssapsettings.h"
       
    27 
       
    28 //Encryption & decryption passwords has been removed
       
    29 //401-1808 - Ease of Instant Messaging SERVER customization
       
    30 
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 
       
    34 class CRepository;
       
    35 class CIMPSSAPSettings;
       
    36 class CIMPSSAPSettingsList;
       
    37 class CIMPSSAPNotifier;
       
    38 class MIMPSSAPObserver;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43 *  Implementation for CIMPSSAPSettingsStore.
       
    44 *  Uses central repository for storing SAP data.
       
    45 *
       
    46 *  @see CIMPSSAPSettingStore
       
    47 *  @lib WVSAPSettings.dll
       
    48 *  @since 3.0
       
    49 */
       
    50 NONSHARABLE_CLASS( CIMPSSAPCenRep ): public CBase
       
    51     {
       
    52 public:  // Constructors and destructor
       
    53 
       
    54     /**
       
    55     * Two-phased constructor.
       
    56     * @param aPriority Priority for active object based store event
       
    57     *        notifier. This determines priority of notifying store
       
    58     *        event observers.
       
    59     */
       
    60     static CIMPSSAPCenRep* NewL( TInt aPriority );
       
    61     static CIMPSSAPCenRep* NewLC( TInt aPriority );
       
    62 
       
    63     /**
       
    64     * Destructor.
       
    65     */
       
    66     virtual ~CIMPSSAPCenRep();
       
    67 
       
    68 
       
    69 public: // Implemented methods for CIMPSSAPSettingsStore
       
    70 
       
    71     /**
       
    72      * @see CIMPSAPSettingsStore for description of these methods.
       
    73      *
       
    74      * @since 3.0
       
    75      */
       
    76 
       
    77     // Observer support
       
    78 
       
    79     void AddObserverL( MIMPSSAPObserver* aObserver, TIMPSAccessGroup aGroup );
       
    80     void RemoveObserver( MIMPSSAPObserver* aObserver );
       
    81 
       
    82     // SAP Settings related
       
    83 
       
    84     TUint32 StoreNewSAPL( CIMPSSAPSettings* aSAPSettings, TIMPSAccessGroup aGroup );
       
    85     void GetSAPL( TUint32 aUid, CIMPSSAPSettings* aSAPSettings );
       
    86     void DoGetSAPL( TUint32 aUid, CIMPSSAPSettings* aSAPSettings );
       
    87     TInt SAPCountL( TIMPSAccessGroup aGroup );
       
    88     void DeleteSAPL( TUint32 aUid );
       
    89     void UpdateOldSAPL( CIMPSSAPSettings* aSAPSettings, TUint32 aUid );
       
    90     void PopulateSAPSettingsListL( CIMPSSAPSettingsList& aList,
       
    91                                    TIMPSAccessGroup aGroup,
       
    92                                    TBool aAscending = ETrue );
       
    93 
       
    94     // Default SAP
       
    95 
       
    96     void GetDefaultL( TUint32& aUid, TIMPSAccessGroup aGroup );
       
    97     void GetDefaultL( CIMPSSAPSettings* aSAPSettings, TIMPSAccessGroup aGroup );
       
    98     void SetToDefaultL( TUint32 aUid, TIMPSAccessGroup aGroup );
       
    99 
       
   100 private: //Constructors
       
   101 
       
   102     /**
       
   103     * C++ default constructor.
       
   104     */
       
   105     CIMPSSAPCenRep();
       
   106 
       
   107     /**
       
   108     * By default Symbian 2nd phase constructor is private.
       
   109     *
       
   110     * @param aPriority Priority for active object based store event
       
   111     *        notifier. This determines priority of notifying store
       
   112     *        event observers.
       
   113     */
       
   114     void ConstructL( TInt aPriority );
       
   115 
       
   116 private: //Helper methods
       
   117 
       
   118     /**
       
   119      * Calculates cenrep Id for a setting using bitmasks.
       
   120      *
       
   121      * @param aSetting The enumerated setting value to use in calculation
       
   122      * @param aUid Uid of the SAP.
       
   123      * @param aGroup Access group of the SAP
       
   124      * @return The calculated Id
       
   125      * @since 3.0
       
   126      */
       
   127     TUint32 MaskedId( TInt aSetting, TUint32 aUid, TIMPSAccessGroup aGroup );
       
   128 
       
   129     /**
       
   130      * Checks if SAP with given name already exists.
       
   131      *
       
   132      * @param aSAPName Name of the SAP to be checked
       
   133      * @param aUid SAP's name in SAP with this Uid is allowed to be duplicate
       
   134      *		  to enable updating of existing SAPs
       
   135      * @param aGroup Access group which within the check is made
       
   136      * @return ETrue if name already exists, otherwise EFalse
       
   137      * @since 3.0
       
   138      */
       
   139 
       
   140     TBool SAPNameExistsL( const TDesC& aSAPName, TUint32 aUid, TIMPSAccessGroup aGroup );
       
   141 
       
   142     /**
       
   143      * Checks if SAP exists in the central repository. Leaves
       
   144      * wíth KErrNotFound if SAP does not exist.
       
   145      *
       
   146      * @param aUid Uid to check
       
   147      * @since 3.0
       
   148      */
       
   149 
       
   150     void SAPExistsL( TUint32 aUid );
       
   151 
       
   152     /**
       
   153      * Gets new unique uid for storing new SAP.
       
   154      *
       
   155      * @return New Uid, leaves with KErrInUse if all Uids are in use
       
   156      * @since 3.0
       
   157      */
       
   158 
       
   159     TUint32 NewUidL();
       
   160 
       
   161     /**
       
   162      * Gets SAP access group .
       
   163      *
       
   164      * @param aUid Uid of the SAP for getting access group
       
   165      * @return SAP access group
       
   166      * @since 3.0
       
   167      */
       
   168 
       
   169     TIMPSAccessGroup SAPTypeL( TUint32 aUid );
       
   170 
       
   171     /**
       
   172      * Gets SAP protection level.
       
   173      *
       
   174      * @param aUid Uid of the SAP for getting protection
       
   175      * @param aGroup SAP's access group
       
   176      * @return SAP protection level
       
   177      * @since 3.0
       
   178      */
       
   179 
       
   180     TIMPSSAPProtection SAPProtectionL( TUint32 aUid, TIMPSAccessGroup aGroup );
       
   181 
       
   182     /**
       
   183      * Sets up default SAP ids if they do not exist in the repository.
       
   184      *
       
   185      * @since 3.0
       
   186      */
       
   187 
       
   188     void SetUpDefaultsL();
       
   189 
       
   190     /**
       
   191      * Finds existing SAP ids from desired access group and populates them
       
   192      * to an array.
       
   193      *
       
   194      * @param aGroup desired access group
       
   195      * @param aFoundSAPs array for storing found SAP ids
       
   196      * @since 3.0
       
   197      */
       
   198 
       
   199     void FindSAPsFromAccessGroupL( TIMPSAccessGroup aGroup,
       
   200                                    RArray<TUint32>& aFoundSAPs );
       
   201 
       
   202     /**
       
   203      * Starts new transaction if there is no ongoing transaction.
       
   204      *
       
   205      * @param aMode Transaction mode
       
   206      * @since 3.0
       
   207      */
       
   208 
       
   209 		TBool StartOwnTransactionL( TInt aMode );
       
   210 
       
   211     /**
       
   212      * Converts Access Point Name into AP value
       
   213      * Configurability req.
       
   214      * 401-1808 - Ease of Instant Messaging SERVER customization
       
   215      * @param aAPName - AP name
       
   216      * @return AP Number in the Commnection DB
       
   217      * @since 5.0
       
   218      */
       
   219 
       
   220     TUint32 DoGetAccessPointsL( const TDesC& aAPName );
       
   221 
       
   222 
       
   223     /**
       
   224      * Converts Access Point Number into AP Name value
       
   225      * Configurability req.
       
   226      * 401-1808 - Ease of Instant Messaging SERVER customization
       
   227      * @param aAP - AP Number in the Commnection DB
       
   228      * @return HBufC AP name, Caller should free this data.
       
   229      * @since 5.0
       
   230      */
       
   231     HBufC* DoGetAccessPointsNameL( const TUint32 aAP );
       
   232 
       
   233 		/**
       
   234 		* Reset iInTransaction state by invoke ReSetTransactionFlag(). 
       
   235 		* This happens when iRepository is not committed and leave occurred.
       
   236 		* @param aAP - Instance of this class
       
   237 		*/		
       
   238 		static void ReSetTransactionState(TAny* aPtr);
       
   239 
       
   240 		/**
       
   241 		* Reset iInTransaction flag
       
   242 		*/	
       
   243 		void ReSetTransactionFlag();
       
   244 
       
   245     /**
       
   246      * Unit test class is a friend class.
       
   247      */
       
   248     friend class T_CIMPSSAPSecurity;	// CSI: 36 #
       
   249 
       
   250 private:    // Data
       
   251     CRepository* iRepository; // Handle to central repository session (own)
       
   252     CIMPSSAPNotifier* iNotifier; // SAP Settings notifier (own)
       
   253     CCommsDatabase* iCommsDatabase; //Accesses the communications database
       
   254     TBool iInTransaction;
       
   255     };
       
   256 
       
   257 #endif      // CIMPSSAPCENREP_H
       
   258 
       
   259 // End of File