iptel_plat/richcallsettingsengine_api/inc/crcseprofileregistry.h
changeset 0 a4daefaec16c
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  Offers API for storing, getting and updating profiles.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CRCSEPROFILEREGISTRY_H
       
    21 #define CRCSEPROFILEREGISTRY_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <rcseregistrybase.h>
       
    26 #include <crcseprofileentry.h>
       
    27 #include <sipprofileregistryobserver.h>
       
    28 
       
    29 
       
    30 
       
    31 // FORWARD DECLARATION
       
    32 class CSIPManagedProfileRegistry;
       
    33 class CSIPProfile;
       
    34 
       
    35 
       
    36 // CLASS DECLARATION
       
    37 
       
    38 /**
       
    39 *  Offers getting, setting and updating of profiles.
       
    40 *
       
    41 *  @lib RCSE.lib
       
    42 *  @since S60 3.0
       
    43 */
       
    44 class CRCSEProfileRegistry: public CRCSERegistryBase,
       
    45                             public MSIPProfileRegistryObserver
       
    46     {    
       
    47 public:  // Constructors and destructor
       
    48     
       
    49     /**
       
    50     * Two-phased constructor.
       
    51     */
       
    52     IMPORT_C static CRCSEProfileRegistry* NewL();
       
    53 
       
    54     /**
       
    55     * Two-phased constructor.
       
    56     */
       
    57     IMPORT_C static CRCSEProfileRegistry* NewLC();
       
    58     
       
    59     /**
       
    60     * Destructor.
       
    61     */
       
    62     IMPORT_C virtual ~CRCSEProfileRegistry();
       
    63 
       
    64 public: // New functions
       
    65 
       
    66     /**
       
    67     * Search a profile, which provider name setting is same as 
       
    68     * aProviderName. Leaves with KErrNotFound if such profile
       
    69     * is not found. Default values are reseted to aFoundEntry
       
    70     * before the search.
       
    71     *
       
    72     * @since S60 v3.0
       
    73     * @param aProviderName Search criteria for profiles.
       
    74     * @param aFoundEntry A found profile entry, which provider name is 
       
    75     * same than aProviderName.
       
    76     */
       
    77     IMPORT_C void FindL( const TDesC& aProviderName, 
       
    78         CRCSEProfileEntry& aFoundEntry );
       
    79 
       
    80     /**
       
    81     * Search a profile, which profile id is same as aProfileId. 
       
    82     * Leaves with KErrNotFound if such profile is not found.
       
    83     * Default values are reseted to aFoundEntry before the search.
       
    84     *
       
    85     * @since S60 v3.0.
       
    86     * @param aProfileId Search criteria for profiles.
       
    87     * @param aFoundEntry A found profile entry, which provider name is 
       
    88     * same than aProviderName.
       
    89     */
       
    90     IMPORT_C void FindL( TUint32 aProfileId, 
       
    91         CRCSEProfileEntry& aFoundEntry );
       
    92 
       
    93     /**
       
    94     * Gets all profile identifiers which are stored to RCSE. If there are
       
    95     * no profiles stored, aAllIds will contain zero entries.
       
    96     *
       
    97     * @since S60 v3.0
       
    98     * @param aAllIds Array, where the profile identifiers are stored.
       
    99     */
       
   100     IMPORT_C void GetAllIdsL( RArray<TUint32>& aAllIds );
       
   101 
       
   102     /**
       
   103     * Adds new profile entry.
       
   104     *
       
   105     * @since S60 v3.0
       
   106     * @param aNewEntry New entry.
       
   107     * @return Profile identifier of the added profile.
       
   108     */
       
   109     IMPORT_C TUint32 AddL( const CRCSEProfileEntry& aNewEntry );
       
   110 
       
   111     /**
       
   112     * Deletes a profile, which profile id is same than aProfileId. 
       
   113     *
       
   114     * @since S60 v3.0
       
   115     * @param aProfileId Profile identifier
       
   116     */
       
   117     IMPORT_C void DeleteL( TUint32 aProfileId );
       
   118     /**
       
   119     * Updates profile, which profile identifier is same than aProfileId.
       
   120     * Only settings that are set in aUpdateData are updated in profile.
       
   121     * Leaves with KErrNotFound if profile is not found.
       
   122     *
       
   123     * @since S60 v3.0
       
   124     * @param aId Profile identifier.
       
   125     * @param aUpdateData Updated data, which are updated to profile.
       
   126     */
       
   127     IMPORT_C void UpdateL( TUint32 aId, 
       
   128         const CRCSEProfileEntry& aUpdateData );
       
   129 
       
   130     /**
       
   131     * Resets default values for profile. Default profile is a profile, 
       
   132     * which can be used when no other profile is available.
       
   133     *
       
   134     * @since S60 v3.0
       
   135     * @param aDefaultProfile Default profile settings are set to this.
       
   136     */
       
   137     IMPORT_C void GetDefaultProfile( 
       
   138         CRCSEProfileEntry& aDefaultProfile ) const;
       
   139 
       
   140     /**
       
   141     * Search a profiles, where service provider id is same as aServiceId.
       
   142     * Content of aFoundEntries array is deleted before the search.
       
   143     * On return, aFoundEntries is empty if requested entries are not found.
       
   144     *
       
   145     * @since S60 v3.2.
       
   146     * @param aServiceId Search criteria for profiles.
       
   147     * @param aFoundEntries Container for found profiles
       
   148     */
       
   149     IMPORT_C void FindByServiceIdL( TUint32 aServiceId, 
       
   150         RPointerArray<CRCSEProfileEntry>& aFoundEntries );
       
   151 
       
   152     /**
       
   153     * Search a profiles that have requested aSipProfileId.
       
   154     * Content of aFoundEntries array is deleted before the search.
       
   155     * On return, aFoundEntries is empty if requested entries are not found.
       
   156     *
       
   157     * @since S60 v3.2.
       
   158     * @param aSipProfileId Search criteria for profiles.
       
   159     * @param aFoundEntries Container for found profiles
       
   160     */
       
   161     IMPORT_C void FindBySIPProfileIdL( TUint32 aSipProfileId, 
       
   162         RPointerArray<CRCSEProfileEntry>& aFoundEntries );
       
   163 
       
   164     /**
       
   165     * Adds bunch of profile entries to store in one transaction.
       
   166     * Creates new service provider setting entry to service table
       
   167     * if iServiceProviderId has not been set in given profile entry.
       
   168     *
       
   169     * @since S60 v3.2
       
   170     * @param aEntries 
       
   171     */
       
   172     void AddL( RPointerArray<CRCSEProfileEntry>& aEntries );
       
   173 
       
   174 
       
   175     /** 
       
   176     * From MSIPProfileRegistryObserver
       
   177     * SIP profile information event.
       
   178     *
       
   179     * @since S60 v3.1
       
   180     * @param aSIPProfileId id for profile
       
   181     * @param aEvent type of information event
       
   182     */
       
   183     void ProfileRegistryEventOccurred( TUint32 aSIPProfileId,
       
   184                                        TEvent aEvent );
       
   185 
       
   186     /**
       
   187     * From MSIPProfileRegistryObserver
       
   188     * An asynchronous error has occurred related to SIP profile.
       
   189     *
       
   190     * @since S60 v3.1
       
   191     * @param aSIPProfileId the id of failed profile
       
   192     * @param aError a error code
       
   193     * @return none
       
   194     */
       
   195     void ProfileRegistryErrorOccurred( TUint32 aSIPProfileId, 
       
   196                                        TInt aError );
       
   197 
       
   198 
       
   199 private:
       
   200 
       
   201     /**
       
   202     * C++ default constructor.
       
   203     */
       
   204     CRCSEProfileRegistry();
       
   205 
       
   206     /**
       
   207     * By default Symbian 2nd phase constructor is private.
       
   208     */
       
   209     void ConstructL();
       
   210 
       
   211     /**
       
   212     * Do actual search of requested entry.
       
   213     * Leaves with KErrNotFound if such profile is not found.
       
   214     * Default values are reseted to aFoundEntry before the search.
       
   215     *
       
   216     * @since S60 v3.0.
       
   217     * @param aProfileId Search criteria for profiles.
       
   218     * @param aFoundEntry A found profile entry
       
   219     * @leave KErrNotFound if profile doesn't exist.
       
   220     */
       
   221     void FindEntryL( TUint32 aProfileId, CRCSEProfileEntry& aFoundEntry );
       
   222 
       
   223     /**
       
   224     * Adds or updates settings entry to storage depending of the aId
       
   225     * parameter. Entry is stored as new entry if aId parameter have
       
   226     * been set to KNoEntryId, otherwise existing entry is updated.
       
   227     *
       
   228     * @since S60 v3.2
       
   229     * @param aId ID of entry if exists. 
       
   230     * @param aEntry Entry to be added to storage.
       
   231     * @param aUpdate Determines add or update operation.
       
   232     *                New entry is added when value is set to EFalse (default).
       
   233     * @return ID of entry.
       
   234     */
       
   235     void AddOrUpdateEntryL( TUint32& aId, const CRCSEProfileEntry& aEntry );
       
   236 
       
   237     /**
       
   238     * Convert xxx
       
   239     * .
       
   240     *
       
   241     * @since S60 v3.2.
       
   242     * @param aEntry
       
   243     * @param aProperties
       
   244     */
       
   245     void ConvertPropertiesToEntryL( CRCSEProfileEntry& aEntry,
       
   246                                     RIpAppPropArray& aProperties );
       
   247 
       
   248 
       
   249     /**
       
   250     * Convert xxx
       
   251     * .
       
   252     *
       
   253     * @since S60 v3.2.
       
   254     * @param aEntry
       
   255     * @param aProperties
       
   256     */
       
   257     void ConvertEntryToPropertiesL( const CRCSEProfileEntry& aEntry,
       
   258                                     RIpAppPropArray& properties );
       
   259 
       
   260     /**
       
   261     * Extract protocol ids from descriptor. 
       
   262     *
       
   263     * @since S60 v3.2
       
   264     * @param aDes Contains TSettingIds structs.
       
   265     * @param aArray Contains extracted TSettingIds struct when return.
       
   266     */
       
   267     void ExtractProtocoIdsL( const TDesC& aDes, RArray<TSettingIds>& aArray );
       
   268 
       
   269     /**
       
   270     * Validates that linked SIP profiles are up to date.
       
   271     * Removes invalid links and updates entry to data base
       
   272     *
       
   273     * @since S60 v3.1
       
   274     * @param aEntry Profile entry fetched from data base
       
   275     * @return 
       
   276     */
       
   277     void UpdateSIPProfileLinksL( CRCSEProfileEntry& aEntry );
       
   278 
       
   279     /**
       
   280     * Creates and stores service provider settings entry with
       
   281     * default values, when new profile is created.
       
   282     * Service ID of stored service settings is set to profile.
       
   283     *
       
   284     * @since S60 v3.2.
       
   285     * @param aNewEntry New entry.
       
   286     */
       
   287     void CreateDefaultServiceSettingsL( CRCSEProfileEntry& aNewEntry );
       
   288 
       
   289     /**
       
   290     * Deletes service settings and audio codec settings referenced
       
   291     * from profile.
       
   292     *
       
   293     * @since S60 v3.2.
       
   294     * @param aProfileId Id of deleted VoIP profile
       
   295     */
       
   296     void DeleteReferenceSettingsL( TUint32 aProfileId );
       
   297 
       
   298     /**
       
   299     * Checks if Service table exist with rerenced entry name.
       
   300     * @since S60 3.2.
       
   301     * @param aProviderName.
       
   302     */        
       
   303     TBool NameExistsInServiceTableL( const TDesC& aProviderName ) const;
       
   304     
       
   305     /**
       
   306     * Checks if service id is used for profile.
       
   307     * @since S60 3.2.
       
   308     * @param aEntry.
       
   309     */        
       
   310     void LeaveIfServiceIdInUseL( const CRCSEProfileEntry& aEntry );
       
   311 
       
   312     /**
       
   313     * Updates service settings related to aEntry if needed
       
   314     * @since S60 3.2.
       
   315     * @param aEntry.
       
   316     */        
       
   317     void UpdateServiceSettingsL( const CRCSEProfileEntry& aEntry );
       
   318 
       
   319     /**
       
   320     * Updates service id related to given entry id.
       
   321     * @since S60 3.2.
       
   322     * @param aId.
       
   323     * @param aServiceId New service id.
       
   324     */        
       
   325     void UpdateServiceIdL(  TUint32 aId, TUint32 aServiceId );
       
   326 
       
   327     /**
       
   328     * Implementation for cleanup item.
       
   329     * Resets and destroys array of the entries. 
       
   330     * @param anArray RPointerArray pointer.
       
   331     */
       
   332     static void ResetAndDestroyEntries( TAny* anArray );
       
   333 
       
   334     /**
       
   335     * Copies values from a const entry to a modifiable one.
       
   336     * @since S60 3.2.
       
   337     * @param aSourceEntry Entry whose values are to be copied.
       
   338     * @param aDestinationEntry Entry to whom values are copied.
       
   339     */
       
   340     void CopyEntryValues( const CRCSEProfileEntry& aSourceEntry, 
       
   341         CRCSEProfileEntry& aDestinationEntry );
       
   342 private:     // Data
       
   343 
       
   344     /**
       
   345     * SIP registry ( from SIP Profile Client )
       
   346     * Own.
       
   347     */
       
   348     CSIPManagedProfileRegistry* iSIPRegistry;
       
   349 
       
   350     /**
       
   351     * SIP profiles ( from SIP Profile Client )
       
   352     * Own.
       
   353     */
       
   354     RPointerArray<CSIPProfile> iSIPProfiles;
       
   355 
       
   356 
       
   357 private:
       
   358 
       
   359     // For testing
       
   360     #ifdef TEST_EUNIT
       
   361         friend class UT_CRCSEProfileRegistry;
       
   362     #endif                                  
       
   363     };
       
   364 
       
   365 #endif      // CRCSEPROFILEREGISTRY_H   
       
   366             
       
   367 // End of File