sipplugins/sippsipsettingsui/inc/gssipmodel.h
changeset 0 307788aac0a8
child 14 532ef74cdfa0
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2003 - 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:  SIP Settings model.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef GS_SIP_MODEL_H
       
    20 #define GS_SIP_MODEL_H
       
    21 
       
    22 // INCLUDES
       
    23 
       
    24 #include <e32base.h>
       
    25 #include "tsipsettingsdata.h"
       
    26 #include "mgssipprofilehandler.h"
       
    27 #include <sipprofileregistryobserver.h>
       
    28 #include <sipmanagedprofile.h>
       
    29 #include <sipmanagedprofileregistry.h>
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 
       
    33 class CGSPluginInterface;
       
    34 class CSIPManagedProfileRegistry;
       
    35 class MSIPProfileRegistryObserver;
       
    36 class CGSSIPAppShutter; 
       
    37 
       
    38 // CLASS DECLARATION
       
    39 /**
       
    40 *  CGSSIPModel model class
       
    41 *  @since 3.0
       
    42 *  model class for all SIP Settings
       
    43 */
       
    44 class CGSSIPModel 
       
    45     : public CBase,
       
    46       public MSIPProfileRegistryObserver,
       
    47       public MGSSIPProfileHandler
       
    48     {
       
    49     public:  // Constructors and destructor
       
    50         
       
    51         /**
       
    52         * Two-phased constructor.
       
    53         * @return Pointer to created instance
       
    54         */
       
    55         static CGSSIPModel* NewL();
       
    56         
       
    57         /**
       
    58         * Destructor.
       
    59         */
       
    60         virtual ~CGSSIPModel();
       
    61     
       
    62     public: // New functions
       
    63     
       
    64         /**
       
    65         * Creates the SIP profile engine       
       
    66         * @param aAppUi for CGSSIPPSettingsPlugin UI
       
    67         */
       
    68         void CreateEngineL( CGSPluginInterface* aAppUi );                        
       
    69         
       
    70         /**
       
    71         * Sets flag to quit the application after save has occured
       
    72         */
       
    73         void QuitAfterSave();
       
    74         
       
    75         /**
       
    76         * Returns pointer to the profile based on id
       
    77         * @param aId Profile id
       
    78         * @return Pointer to returned profile
       
    79         */
       
    80         CSIPManagedProfile* Profile( TUint aId );
       
    81 
       
    82         /**
       
    83         * Checks if profile can be deleted.
       
    84         * @param aIndex Index to the deleted profile
       
    85         * @param aIsUse ETrue if profile is in use
       
    86         * @param aDefault ETrue if profile is default profile 
       
    87         * @param aLocked ETrue if profile is locked 
       
    88         */
       
    89         void CheckProfileForDeleteL( 
       
    90             TInt aIndex, TBool& aIsUse, TBool& aDefault, TBool& aLocked );
       
    91 
       
    92         /**
       
    93         * Checks is profile in use.
       
    94         * @param aProfileId for SIP profile id
       
    95         * @return ETrue if profile is in use 
       
    96         */
       
    97         TBool CheckIsProfileInUseL( TUint32 aProfileId );
       
    98 
       
    99     public: // Functions from base classes
       
   100 
       
   101         /** 
       
   102         * from MSIPProfileRegistryObserver 
       
   103         * SIP profile information event
       
   104         * @param aProfileId is id for profile
       
   105         * @param aEvent type of information event
       
   106 		*/
       
   107 		void ProfileRegistryEventOccurred(
       
   108 		    TUint32 aSIPProfileId, TEvent aEvent );
       
   109         
       
   110         /** 
       
   111         * SIP profile creation event
       
   112         * @param aSIPProfileId id of new SIP Profile
       
   113 		*/
       
   114 		void ProfileCreatedL( TUint32 aSIPProfileId );
       
   115 
       
   116 		/** 
       
   117 		* SIP profile information update event
       
   118 		* @param aSIPProfileId id of updated SIP Profile
       
   119 		*/
       
   120 		void ProfileUpdatedL( TUint32 aSIPProfileId );
       
   121 
       
   122 		/**
       
   123 		* SIP profile registration status changed event
       
   124 		* @param aSIPProfileId id of profile which registration 
       
   125 		*        status has been changed.
       
   126 		*/
       
   127 		void ProfileRegistrationStatusChanged( TUint32 aSIPProfileId );
       
   128 
       
   129 		/**		
       
   130         * SIP profile destruction event.
       
   131         * @param aSIPProfileId id of profile which was destroyed
       
   132 		*/
       
   133 		void ProfileDestroyed( TUint32 aSIPProfileId );
       
   134 		
       
   135         /**
       
   136         * Added profile index in the profiles list
       
   137         * @return profile index
       
   138         */
       
   139         TInt AddedProfileIndex();
       
   140 
       
   141 		/**
       
   142         * from MSIPProfileRegistryObserver
       
   143 		* An asynchronous error has occurred related to SIP profile		
       
   144         * @param aSIPProfileId the id of failed profile 
       
   145 		* @param aError a error code
       
   146 		*/
       
   147 		void ProfileRegistryErrorOccurred(				    
       
   148 		    TUint32 aSIPProfileId,
       
   149 		    TInt aError);
       
   150 
       
   151         /**
       
   152         * from MGSSIPProfileHandler
       
   153         * Sets the default profile        
       
   154         * @param aIndex Index on the array table of the profile that is going
       
   155         *               to be a new default profile        
       
   156         */
       
   157         void SetDefaultProfileL( TInt aIndex );
       
   158 
       
   159         /**
       
   160         * from MGSSIPProfileHandler
       
   161         * Gets the index of the default profile
       
   162         * @return KErrNotFound, if one does not exist, otherwise index to profile
       
   163         */
       
   164         TInt DefaultProfileIndex();
       
   165 
       
   166         /**
       
   167         * from MGSSIPProfileHandler
       
   168         * Returns pointer to the profile array, does not change ownership
       
   169         * @return Pointer to the profile array
       
   170         */
       
   171         CArrayPtr<CSIPManagedProfile>* ProfileArray();
       
   172         
       
   173         /**
       
   174         * from MGSSIPProfileHandler
       
   175         * Starts modifying a profile, copies profile's data to iProfileData
       
   176         * @param aIndex index on the array table        
       
   177         * @return Ok to move to the next view?
       
   178         */
       
   179         TBool EditProfileL( TInt aIndex );
       
   180 
       
   181         /**
       
   182         * from MGSSIPProfileHandler
       
   183         * Starts editing a profile that is based on existing one. 
       
   184         * @param aCopiedIndex index on the array table of the copied profile       
       
   185         */
       
   186         void CreateAndEditProfileL( TInt aCopiedIndex );
       
   187         
       
   188         /**
       
   189         * from MGSSIPProfileHandler
       
   190         * Deletes a profile from permanent storage
       
   191         */
       
   192         void DeleteProfileL( TInt aIndex );
       
   193 
       
   194         /**
       
   195         * from MGSSIPProfileHandler
       
   196         * Checks if there has been an error in registration
       
   197         * @param aIndex Index to the table
       
   198         * @return Error has happened in registration or then not
       
   199         */
       
   200         TBool ErrorInRegistration( TInt aIndex );
       
   201         
       
   202         /**
       
   203         * from MGSSIPProfileHandler
       
   204         * Returns pointer to profile data structure for modifying it directly
       
   205         * @return Pointer to iProfileData
       
   206         */
       
   207         TSIPSettingsData* ProfileData();
       
   208         
       
   209         /**
       
   210         * from MGSSIPProfileHandler
       
   211         * Saves profile's changes or returns EFalse if no changes are present.        
       
   212         * @return EFalse if no changes (not saved then), otherwise engine
       
   213         *         starts saving the modifications
       
   214         */
       
   215         TBool SaveProfileL();
       
   216         
       
   217         /**
       
   218         * from MGSSIPProfileHandler
       
   219         * Returns list of different profile service types
       
   220         * @return list of types
       
   221         */
       
   222         RArray<TSIPProfileTypeInfo>* TypeListL();
       
   223 
       
   224         /**
       
   225         * Checks that there are no duplicate profile names.
       
   226         * @param aProfileId for current profile to be checked.
       
   227         * @param aName for profile name to be checked.
       
   228         * @param aCreatedFromExistingProfile to inform if the profile
       
   229         * was created from existing profile and language specific
       
   230         * number conversions must be done.
       
   231         */
       
   232         void CheckDuplicateNameL( TInt32 aProfileId, TDes& aName,  
       
   233                            TBool aCreatedFromExistingProfile = EFalse);  
       
   234 
       
   235     protected:  // New functions
       
   236         
       
   237         /**
       
   238         * Reads the profile array from SIP Profile Client
       
   239         */        
       
   240         void ReadArrayFromEngineL();
       
   241 
       
   242         /**
       
   243         * Copies profile from CSIPManagedProfile to iProfileData for modifications
       
   244         * @param aIndex The index to the array to be copied
       
   245         */
       
   246         void CopyToProfileDataStructL( TInt aIndex );    
       
   247 
       
   248         /**
       
   249         * Fills the data structure with default values
       
   250         */
       
   251         void FillDataStructWithDefaultValsL();
       
   252 
       
   253         /**
       
   254         * Checks if user has made any modfications to the existing profile
       
   255         * @return ETrue if user has modified the profile
       
   256         */
       
   257         TBool CheckForModificationsL();
       
   258 
       
   259         /**
       
   260         * Copies data from iProfileData to the actual CSIPManagedProfile
       
   261         * @return Profile where the stuff was copied to..
       
   262         */
       
   263         CSIPManagedProfile* CopyDataToProfileL();
       
   264 
       
   265         /**        
       
   266         * Replaces one profile with another on the array; only cloned profiles
       
   267         * should be replaced
       
   268         * @param aIndex   Index on the table of the array that is replaced
       
   269         * @param aProfile The profile that replaces existing profile
       
   270         */
       
   271         void ReplaceProfileL( TInt aId, CSIPManagedProfile* aProfile );
       
   272 
       
   273         /**
       
   274         * Reads profile list from the engine; if reading fails,
       
   275         * keeps the old list safe and returns it
       
   276         */
       
   277         void ReadProfileListFromEngineSafeL();
       
   278 
       
   279         /**
       
   280         * Calls app ui to udpate the lists; might also trigger exit
       
   281         * @param aCmd Command that is passed to view
       
   282         */
       
   283         void UpdateListCmd( TInt aCmd = EGSCmdUpdateList );
       
   284 
       
   285     private:
       
   286 
       
   287         /**
       
   288         * C++ default constructor.
       
   289         */
       
   290         CGSSIPModel();
       
   291 
       
   292         /**
       
   293         * By default Symbian 2nd phase constructor is private.
       
   294         */
       
   295         void ConstructL();            
       
   296 
       
   297         /**
       
   298         * For deleting RPointerArray in case of leave
       
   299         */
       
   300         static void ResetAndDestroy( TAny* aPointerArray );   
       
   301         
       
   302         /**
       
   303         * For deleting allocated RArray in case of leave
       
   304         * @param aArray An array to be destroyed.
       
   305         */
       
   306         static void CloseAndDestroy( TAny* aArray );     
       
   307 
       
   308     private:    // Data
       
   309     
       
   310         // The profile's data, which is manipulated
       
   311         TSIPSettingsData iProfileData;
       
   312 
       
   313         // Instance to the engine
       
   314         CSIPManagedProfileRegistry* iEngine;
       
   315         
       
   316         // Array of all the profiles
       
   317         CArrayPtrFlat<CSIPManagedProfile>* iProfiles;
       
   318 
       
   319         // Temporary pointer storage for a new profile before
       
   320         // placing it to the permanent storage
       
   321         CSIPManagedProfile* iNewProfile;
       
   322         
       
   323         // Flag indicating if one should quit after save
       
   324         TBool iQuitAfterSave;
       
   325         
       
   326         // For quitting app asynchronously after save
       
   327         CGSSIPAppShutter* iAppShutter;
       
   328         
       
   329         // Instance to plugin UI
       
   330         CGSPluginInterface* iAppUi;
       
   331         
       
   332         //Index of new profile in the list
       
   333         TInt iAddedProfileIndex;
       
   334     };
       
   335 
       
   336 #endif      // GS_SIP_MODEL_H   
       
   337             
       
   338 // End of File