convergedconnectionhandler/cchserver/inc/cchservicehandler.h
changeset 0 a4daefaec16c
child 9 bddb6d4447db
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2007-2009 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:  CCCHServiceHandler declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CCHSERVICEHANDLER_H
       
    20 #define C_CCHSERVICEHANDLER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 #include <mspnotifychangeobserver.h>
       
    26 
       
    27 #include "cchserviceinfo.h"
       
    28 #include "cchsubserviceinfo.h"
       
    29 #include "cchservicenotifier.h"
       
    30 #include "cchclientserver.h"
       
    31 #include "cchcommdbwatcherobserver.h"
       
    32 #include "cchphonestartupmonitor.h"
       
    33 
       
    34 // CONSTANTS
       
    35 // None
       
    36 
       
    37 // MACROS
       
    38 // None
       
    39 
       
    40 // FUNCTION PROTOTYPES
       
    41 // None
       
    42 
       
    43 // FORWARD DECLARATIONS
       
    44 class CCCHServiceInfo;
       
    45 class CCCHServerBase;
       
    46 class CCCHSubserviceInfo;
       
    47 class CSPNotifyChange;
       
    48 class CCchUIHandler;
       
    49 class CCchWlanExtension;
       
    50 class CCCHCommDbWatcher;
       
    51 class CCCHPhoneStartupMonitor;
       
    52 
       
    53 // DATA TYPES
       
    54 typedef RPointerArray<CCCHServiceInfo> RServiceArray;
       
    55 
       
    56 // CLASS DECLARATION
       
    57 
       
    58 /**
       
    59  *  CCCHServiceHandler declaration
       
    60  *  Handles services and service related components
       
    61  *  @lib cchserver.exe
       
    62  *  @since S60 3.2
       
    63  */
       
    64 NONSHARABLE_CLASS( CCCHServiceHandler ) : public CBase,
       
    65                                           private MCCHServiceNotifier,
       
    66                                           private MSPNotifyChangeObserver,
       
    67                                           private MCCHCommDbWatcherObserver
       
    68     {
       
    69 
       
    70 public: // Constructors and destructor
       
    71 
       
    72     /**
       
    73     * Two-phased constructor.
       
    74     */
       
    75     static CCCHServiceHandler* NewL( CCCHServerBase& aServer );
       
    76 
       
    77     /**
       
    78      * Two-phased constructor.
       
    79      */
       
    80     static CCCHServiceHandler* NewLC( CCCHServerBase& aServer );
       
    81 
       
    82     /**
       
    83      * Destructor.
       
    84      */
       
    85     virtual ~CCCHServiceHandler();
       
    86 
       
    87 public: // New functions
       
    88 
       
    89     /**
       
    90      * Initialize object
       
    91      * @since S60 3.2
       
    92      */
       
    93     void InitServiceHandlerL();
       
    94 
       
    95     /**
       
    96      * Update service and subservice's state
       
    97      * @since S60 3.2
       
    98      * @param aReadSettingTable If ETrue class reads and updates 
       
    99      * all services from Service Provider Settings
       
   100      */
       
   101     void UpdateL( TBool aReadSettingTable = EFalse );
       
   102 
       
   103     /**
       
   104      * Enables service
       
   105      * @since S60 3.2
       
   106      * @param aServiceSelection Service to enable
       
   107      * @param aConnectivityCheck Is value is True Connectivity Plug-in will
       
   108      * make test call to check is the connection truly working.
       
   109      * @return General symbian error code.
       
   110      */
       
   111     TInt EnableService( const TServiceSelection aServiceSelection,
       
   112                         const TBool aConnectivityCheck );
       
   113 
       
   114     /**
       
   115      * Disables service
       
   116      * @since S60 3.2
       
   117      * @param aServiceSelection Service to disable
       
   118      * @return General symbian error code.
       
   119      */
       
   120     TInt DisableService( const TServiceSelection aServiceSelection );
       
   121 
       
   122     /**
       
   123      * Set new connection information to Service
       
   124      * @since S60 3.2
       
   125      * @param aServiceConnInfo Connection information
       
   126      * @return General symbian error code.
       
   127      */
       
   128     TInt SetConnectionInfo( const TServiceConnectionInfo aServiceConnInfo );
       
   129 
       
   130     /**
       
   131      * Get connection information from Service
       
   132      * @since S60 3.2
       
   133      * @param aServiceSelection Selected Service
       
   134      * @param aServiceConnInfo On completion contains Service's 
       
   135      * connection infomation
       
   136      * @return General symbian error code.
       
   137      */
       
   138     TInt GetConnectionInfo( TServiceConnectionInfo& aServiceConnInfo );
       
   139 
       
   140     /**
       
   141      * Is any service's startup-flag set to true
       
   142      * @since S60 3.2
       
   143      * @return ETrue if startup-flag is set to true
       
   144      */
       
   145     TBool IsStartupFlagSet() const;
       
   146     
       
   147     /**
       
   148      * Subservice's enable at startup info setter. 
       
   149      * Method does not change value for permanently. 
       
   150      * CCCHSPSHandler::SetLoadAtStartUpL sets value for permanently. 
       
   151      * @since S60 3.2
       
   152      * @param aServiceSelection Service which owns startup flag
       
   153      * @param aLoadAtStartUp New startup flag
       
   154      * @return KErrNotFound if service or subservice does not exist
       
   155      */
       
   156     TInt SetStartupFlag( const TServiceSelection aServiceSelection, 
       
   157         TBool aLoadAtStartUp ) const;
       
   158     
       
   159     /**
       
   160      * Load Plug-ins
       
   161      * @since S60 3.2
       
   162      */
       
   163     void LoadPluginsL();
       
   164     
       
   165     /**
       
   166      * Unloads Plug-in(s) of certain service; if all
       
   167      * subservices in one plugin are disabled, those are unloaded.
       
   168      * @since S60 3.2
       
   169      */
       
   170     void UnloadDisabledPluginsL( );
       
   171     
       
   172     /**
       
   173      * Checks if certain subservice exists in certain state
       
   174      * @param aType Subservice type
       
   175      * @param aState Subservice state to be checked
       
   176      * @since S60 3.2
       
   177      */
       
   178     TBool Exists( TCCHSubserviceType aType, 
       
   179                   TCCHSubserviceState aState,
       
   180                   TInt aError ) const;
       
   181                                   
       
   182     /**
       
   183      * Count of Services
       
   184      * @since S60 3.2
       
   185      * @param aMessage IPC message;
       
   186      */
       
   187     void ServiceCountL( RMessage2 aMessage ) const;
       
   188     
       
   189     /**
       
   190      * Get all services and subservices.
       
   191      * @since S60 3.2
       
   192      * @param aMessage IPC message
       
   193      */
       
   194     void GetServicesL( RMessage2 aMessage ) const;
       
   195 
       
   196     /** 
       
   197      * Get state of service or subservice of a certain service
       
   198      * @since S60 3.2
       
   199      * @param aMessage IPC message
       
   200      * @return General symbian error code.
       
   201      */
       
   202     TInt GetServiceState( const RMessage2 aMessage );
       
   203 
       
   204     /** 
       
   205      * Get state of service
       
   206      * @since S60 3.2
       
   207      * @param aServiceId Service which to be checked
       
   208      * @return A state of the service.
       
   209      */
       
   210     TCCHSubserviceState CCCHServiceHandler::ServiceState(
       
   211             const TUint aServiceId );
       
   212     
       
   213     /** 
       
   214      * Get info of service or subservice of a certain service
       
   215      * @since S60 3.2
       
   216      * @param aMessage IPC message
       
   217      * @return General symbian error code.
       
   218      */
       
   219     TInt GetServiceInfo( const RMessage2 aMessage );
       
   220 
       
   221     /** 
       
   222      * Reserves the service for exclusive use
       
   223      * @since S60 3.2
       
   224      * @param aMessage IPC message
       
   225      * @return General symbian error code.
       
   226      */
       
   227     TInt ReserveService( const RMessage2 aMessage );
       
   228 
       
   229     /** 
       
   230      * Frees the exclusive service reservation
       
   231      * @since S60 3.2
       
   232      * @param aMessage IPC message
       
   233      * @return General symbian error code.
       
   234      */
       
   235     TInt FreeService( const RMessage2& aMessage );
       
   236     
       
   237     /** 
       
   238      * Is the service exclusively reserved?
       
   239      * @since S60 3.2
       
   240      * @param aMessage IPC message
       
   241      * @return ETrue if service is reserved for exclusive use.
       
   242      */
       
   243     void IsReserved( RMessage2 aMessage ) const;
       
   244     
       
   245     /**
       
   246      * Service exist
       
   247      * @since S60 3.2
       
   248      * @param aSelection Checked Service
       
   249      * @return TInt index if found else KErrNotFound 
       
   250      */
       
   251     TInt ServiceExist( TServiceSelection aSelection ) const;
       
   252     
       
   253     /**
       
   254      * Find service by service id
       
   255      * @since S60 3.2
       
   256      * @param serviceId
       
   257      * @return TInt position within the iServices array or KErrNotFound
       
   258      */
       
   259     TInt FindService( TUint32 aServiceId ) const;
       
   260     
       
   261     /**
       
   262      * Subscribe to service change notifies
       
   263      * @since S60 3.2
       
   264      */
       
   265     void EnableNotifyChange();
       
   266     
       
   267     /**
       
   268      * Cancel service change notifies
       
   269      * @since S60 3.2
       
   270      */
       
   271     void DisableNotifyChange();
       
   272         
       
   273     /**
       
   274      * Get all subservice types which uses given Plug-in uid.
       
   275      * @since S60 3.2
       
   276      * @param aServiceId Service which to be checked
       
   277      * @param aSubserviceTypes On completion contains subservice types.
       
   278      */
       
   279     void GetSubserviceTypesL( const TUint aServiceId, 
       
   280         RArray<TCCHSubserviceType>& aSubserviceTypes ) const;
       
   281     
       
   282     /**
       
   283      * Disables Wlan scan if needed
       
   284      */
       
   285     void DisableWlanScan();
       
   286     
       
   287     /**
       
   288      * Handle restart situation, all services and subservices
       
   289      * goes to disabled state.
       
   290      */
       
   291     void HandleRestartL();
       
   292     
       
   293 protected: // From base classes
       
   294     
       
   295     /**
       
   296      * Determines if we should start recovery
       
   297      * @since S60 3.2
       
   298      * @param aServiceId Service which state has changed
       
   299      * @param aError Subservice's error. 
       
   300      * @return ETrue if recovery is needed
       
   301      */
       
   302 
       
   303     TBool IsRecoveryNeeded( const TCCHSubserviceState aState, 
       
   304                             TInt aError );
       
   305                                
       
   306     /**
       
   307      * Service state notifier.
       
   308      * @since S60 3.2
       
   309      * @param aServiceId Service which state has changed
       
   310      * @param aSubService Subservice's type. 
       
   311      * @param aState A new state of the service.
       
   312      */
       
   313     void StateChangedL( const TUint aServiceId,
       
   314                         const TCCHSubserviceType aSubService,
       
   315                         const TCCHSubserviceState aState,
       
   316                         const TInt aError );
       
   317         
       
   318     /**
       
   319      * Handle notify change event.
       
   320      * From MSPNotifyChangeObserver;
       
   321      *
       
   322      * @since S60 3.2
       
   323      * @param aServiceId The service ID of changed service
       
   324      */
       
   325     void HandleNotifyChange( TServiceId aServiceId );
       
   326     
       
   327     /**
       
   328      * Handle error
       
   329      * 
       
   330      * @since S60 3.2
       
   331      */
       
   332     void HandleError( TInt aError );
       
   333     
       
   334 private:
       
   335 
       
   336     /**
       
   337      * C++ default constructor.
       
   338      */
       
   339     CCCHServiceHandler( CCCHServerBase& aServer );
       
   340     
       
   341     /**
       
   342      * By default Symbian 2nd phase constructor is private.
       
   343      */
       
   344     void ConstructL();
       
   345 
       
   346     /**
       
   347      * Add service to service array
       
   348      * @since S60 3.2
       
   349      * @param aService service information
       
   350      */
       
   351     void AddServiceL( TCCHService& aService );
       
   352     
       
   353     /**
       
   354      * Counts how many Service contains this kind of Subservice
       
   355      * @since S60 3.2
       
   356      * @param aType Subservice's type
       
   357      * @return TInt Count of Service
       
   358      */
       
   359     TInt ServiceCount( const TCCHSubserviceType aType ) const;
       
   360 
       
   361     /**
       
   362      * Starts connection recovery timer
       
   363      * @param aFunction The function to call after the time out
       
   364      */
       
   365     void StartConnectionRecoveryTimer( TInt (*aFunction)(TAny* aPtr) );
       
   366 
       
   367     /**
       
   368      * Cancels the connection recovery timer
       
   369      */
       
   370     void CancelConnectionRecoveryTimer();
       
   371     
       
   372     /**
       
   373      * Connection recovery callback
       
   374      * @param aSelf this object
       
   375      */
       
   376     static TInt ConnectionRecoveryEvent( TAny* aSelf );
       
   377     
       
   378     /**
       
   379      * Handles connection recovery event
       
   380      */
       
   381     void HandleConnectionRecovery();
       
   382     
       
   383     /**
       
   384      * Starts plugin unload timer
       
   385      * @param aFunction The function to call after the time out
       
   386      */
       
   387     void StartPluginUnloadTimer();
       
   388 
       
   389     /**
       
   390      * Cancels the connection recovery timer
       
   391      */
       
   392     void CancelPluginUnloadTimer();
       
   393     
       
   394     /**
       
   395      * Plugin unload callback
       
   396      * @param aSelf this object
       
   397      */
       
   398     static TInt PluginUnloadEvent( TAny* aSelf );
       
   399     
       
   400     /**
       
   401      * Handles plugin unload event
       
   402      */
       
   403     void HandlePluginUnload();
       
   404         
       
   405     /**
       
   406      * From MCCHCommDbWatcherObserver, handles commsdb events
       
   407      */
       
   408     void HandleWLANIapAdded( TInt aSNAPId );
       
   409     
       
   410     /**
       
   411      * Checks if there is wlan iap used, second part
       
   412      */
       
   413     TBool UsesWlanIap( const TServiceSelection& aServiceSelection );
       
   414     
       
   415     /**
       
   416      * Checks if there is wlan iap used
       
   417      */
       
   418     TBool HasWlanIap( const TServiceSelection& aServiceSelection );
       
   419     
       
   420     /**
       
   421      * Checks if IAP or SNAP is defined for certain subservice
       
   422      */
       
   423     TBool IsConnectionDefinedL( const TServiceSelection& aServiceSelection );
       
   424     
       
   425     /**
       
   426      * Checks if IAP or SNAP is defined for certain service
       
   427      */
       
   428     TBool IsServiceConnectivityDefinedL( const TServiceSelection& aServiceSelection );
       
   429     
       
   430 private: // data
       
   431 
       
   432     /**
       
   433      * Handle to server
       
   434      */
       
   435     CCCHServerBase&                 iServer;
       
   436 
       
   437     /**
       
   438      * Service array
       
   439      */
       
   440     RServiceArray                   iServices;
       
   441     
       
   442     /**
       
   443      * Pointer to CSPNotifyChange
       
   444      */
       
   445     CSPNotifyChange*                iNotifier;
       
   446     
       
   447     /**
       
   448      * Service id array
       
   449      */
       
   450     RIdArray                        iServiceIds;
       
   451     
       
   452     /**
       
   453      * UI handler to show VoIP small icon etc.
       
   454      */
       
   455     CCchUIHandler*                  iCchUIHandler;
       
   456     
       
   457     /**
       
   458      * Phone startup monitor. Owned.
       
   459      */
       
   460     CCchPhoneStartupMonitor *       iPhoneStartupMonitor;
       
   461     
       
   462     /**
       
   463      * Connection recovery timer. Owned.
       
   464      */
       
   465     CPeriodic* iConnectionRecoveryTimer;
       
   466     
       
   467     /**
       
   468      * Plugin unload timer. Owned.
       
   469      */
       
   470     CPeriodic* iPluginUnloadTimer;
       
   471     
       
   472     /**
       
   473      * Recovery trial counter
       
   474      */
       
   475     TInt iConnectionRecoveryTry;
       
   476     
       
   477     /**
       
   478      * Services that require recovery
       
   479      */
       
   480     RArray<TServiceSelection> iServicesInRecovery;
       
   481     
       
   482     /**
       
   483      * Recovery intervals
       
   484      */
       
   485     RArray<TInt> iRecoveryInterval;
       
   486     
       
   487     /**
       
   488      * WLAN extension
       
   489      */
       
   490     CCchWlanExtension* iWlanExtension;
       
   491     
       
   492     /**
       
   493      * CommsDb watcher
       
   494      */
       
   495     CCCHCommDbWatcher* iCommDbWatcher;
       
   496     
       
   497     /**
       
   498      * Disable SPSettings notifications
       
   499      */
       
   500     TBool iCancelNotify;
       
   501     };
       
   502 
       
   503 #endif // C_CCHSERVICEHANDLER_H
       
   504 
       
   505 // End of file