callcontinuity/vcc/inc/cvccdirector.h
branchRCL_3
changeset 22 d38647835c2e
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2006-2008 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:   Voice Call Continuity proxy
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CVCCDIRECTOR_H
       
    19 #define CVCCDIRECTOR_H
       
    20 
       
    21 
       
    22 
       
    23 #include <cconvergedcallprovider.h>
       
    24 #include <mccpobserver.h>
       
    25 #include <mccpcsobserver.h>  // MCCPCSObserver
       
    26 #include <mspnotifychangeobserver.h>
       
    27 #include <mccpcall.h>
       
    28 #include <cccpcallparameters.h>
       
    29 
       
    30 #include "mvccengpspropertylistenerobserver.h"
       
    31 #include "ccpdefs.h"
       
    32 
       
    33 //state machine, in order to maintain only one instance
       
    34 #include "tvccstateinit.h"
       
    35 #include "tvccstatecalling.h"
       
    36 #include "tvccstatereleasing.h"
       
    37 #include "tvccstatefailing.h"
       
    38 
       
    39 class CVccPerformer;
       
    40 class CVccHoTrigger;
       
    41 class CVccEngPsPropertyListener;
       
    42 class CVccEngPsProperty;
       
    43 class CSPNotifyChange;
       
    44 class CVccConferenceCall;
       
    45 class CVccDtmfProvider;
       
    46 
       
    47 /**  Service Provider Name */
       
    48 _LIT( KCSPName,"VCC" );
       
    49 
       
    50 /**  VCC implementation UID */
       
    51 const TInt KVCCImplementationUidInt = 0x2000CFAA;
       
    52 
       
    53 /**
       
    54 * Implementation uid of VCC Plugin.
       
    55 */
       
    56 const TUid KVCCImplementationUid = { KVCCImplementationUidInt };
       
    57 
       
    58 /**
       
    59  *  
       
    60  *
       
    61  * Proxies all calls to the relevant call providers
       
    62  * and keeps the house hold.
       
    63  *
       
    64  *  @lib svp.dll
       
    65  *  @since S60 3.2 
       
    66  */
       
    67 class CVccDirector : public CConvergedCallProvider,
       
    68                      public MCCPCSObserver,
       
    69                      public MVccEngPsPropertyListenerObserver,
       
    70                      public MSPNotifyChangeObserver
       
    71 
       
    72     {
       
    73 
       
    74 
       
    75 public:
       
    76 
       
    77     /**
       
    78     * Two-phased constructor.
       
    79     */
       
    80     static CVccDirector* NewL();
       
    81   
       
    82     /**
       
    83     * Destructor.
       
    84     */
       
    85     ~CVccDirector();
       
    86        
       
    87     /**
       
    88     * Gets the instance of the MCCPMonitor
       
    89     * @return Reference to MCCPMonitor
       
    90     */
       
    91     const MCCPCSObserver* CPPObserver() const;
       
    92     
       
    93 // from base class CConvergedCallProvider 
       
    94     
       
    95    	/**
       
    96     * From CConvergedCallProvider
       
    97     * Initializes plug-in. All required parameters must be passed
       
    98     * with this function in order to use services.
       
    99     * Simplifies pluging construct removing need to pass parameters
       
   100     * to ECom interface
       
   101     * 
       
   102     * @since S60 v3.2
       
   103     * @param aMonitor CCP observer
       
   104     * @param aSsObserver SS observer
       
   105     */
       
   106     void InitializeL( const MCCPObserver& aMonitor,
       
   107                       const MCCPSsObserver& aSsObserver );
       
   108 
       
   109     /**
       
   110     * From CConvergedCallProvider
       
   111     * Creates a new session and checks secure status from profile.
       
   112     * 
       
   113     * @since S60 v3.2
       
   114     * @param aParameters Call parameters, SVP uses Service ID parameter
       
   115     * @param aRecipient Recipients address/number
       
   116     * @param aObserver Observer
       
   117     * @return Reference to created MCCPCall object.
       
   118     */
       
   119     MCCPCall* NewCallL( const CCCPCallParameters& aParameters,
       
   120 					    const TDesC& aRecipient,
       
   121 					    const MCCPCallObserver& aObserver );
       
   122                                 
       
   123     /**
       
   124     * From CConvergedCallProvider
       
   125     * Returns Uid of plug-in which is on use.
       
   126     * 
       
   127     * @since S60 v3.2
       
   128     * @return Uid of plug-in
       
   129     */                        
       
   130     const TUid& Uid() const;
       
   131                            
       
   132     /**
       
   133     * From CConvergedCallProvider
       
   134     * Creates a new Emergency call and add user-agent header.
       
   135     * 
       
   136     * @since S60 v3.2
       
   137     * @param aServiceId Service ID, obsolete!
       
   138     * @param aAddress Emergency number
       
   139     * @param aObserver Observer
       
   140     * @return MCCPEmergencyCall
       
   141     */
       
   142     MCCPEmergencyCall* NewEmergencyCallL( const TUint32 aServiceId,
       
   143                                           const TDesC&  aAddress,
       
   144                                           const MCCPCallObserver& aObserver );
       
   145                                           
       
   146     /**
       
   147     * From CConvergedCallProvider
       
   148     * Creates a new conference session.
       
   149     * 
       
   150     * @since S60 v3.2
       
   151     * @param aObserver Observer
       
   152     * @return MCCPConferenceCall
       
   153     */
       
   154     MCCPConferenceCall* NewConferenceL( const TUint32 aServiceId,
       
   155                               const MCCPConferenceCallObserver& aObserver );
       
   156                              
       
   157     /**
       
   158     * From CConvergedCallProvider
       
   159     * Releases call
       
   160     * 
       
   161     * @since S60 v3.2
       
   162     * @param aCall Call to be removed
       
   163     * @return Symbian error code
       
   164     */
       
   165     TInt ReleaseCall( MCCPCall& aCall );
       
   166 
       
   167     /**
       
   168     * From CConvergedCallProvider
       
   169     * Releases emergency call
       
   170     * 
       
   171     * @since S60 v3.2
       
   172     * @param aCall Call to be removed
       
   173     * @return Symbian error code
       
   174     */
       
   175     TInt ReleaseEmergencyCall( MCCPEmergencyCall& aCall );
       
   176 
       
   177     /**
       
   178     * From CConvergedCallProvider
       
   179     * Releases conference call
       
   180     * 
       
   181     * @since S60 v3.2
       
   182     * @param aCall Call to be removed
       
   183     * @return Symbian error code
       
   184     */
       
   185     TInt ReleaseConferenceCall( MCCPConferenceCall& aCall );
       
   186 
       
   187     /**
       
   188     * From CConvergedCallProvider
       
   189     * Get Plug-In capabilities
       
   190     * 
       
   191     * @since Series 60 v3.2
       
   192     * @return TUint32 On return contains the capability flags of plug-In
       
   193     */
       
   194     TUint32 Caps() const;
       
   195     
       
   196 	/**
       
   197     * From CConvergedCallProvider
       
   198 	* Get DTMF provider
       
   199     * 
       
   200 	* @since Series 60 v3.2
       
   201 	* @param aObserver CCP Dtmf observer for informing events
       
   202 	* @return Pointer to MCCPDTMFProvider if succesfull,
       
   203     * NULL if not available
       
   204 	*/
       
   205 	MCCPDTMFProvider* DTMFProviderL( const MCCPDTMFObserver& aObserver );
       
   206 
       
   207 	/**
       
   208     * From CConvergedCallProvider
       
   209 	* Get extension provider
       
   210     * 
       
   211 	* @since Series 60 v3.2
       
   212     * @param aObserver observer for extension(custom) events
       
   213 	* @return Pointer to MCCPExtensionProvider if succesfull,
       
   214     * NULL if not available
       
   215 	*/
       
   216 	MCCPExtensionProvider* ExtensionProviderL(
       
   217             const MCCPExtensionObserver& aObserver );
       
   218 
       
   219     /**
       
   220     * From CConvergedCallProvider
       
   221     * Add an observer for DTMF related events.
       
   222     * Plug-in dependent feature if duplicates or more than one observers 
       
   223     * are allowed or not. Currently CCE will set only one observer.
       
   224     * 
       
   225     * @since S60 v3.2
       
   226     * @param aObserver Observer
       
   227     * @return none
       
   228     * @leave system error if observer adding fails
       
   229     */
       
   230     void AddObserverL( const MCCPDTMFObserver& aObserver );
       
   231 
       
   232     /**
       
   233     * From CConvergedCallProvider
       
   234     * Remove an observer.
       
   235     * 
       
   236     * @since S60 v3.2
       
   237     * @param none
       
   238     * @param aObserver Observer
       
   239     * @return KErrNone if removed succesfully. KErrNotFound if observer
       
   240     * was not found.
       
   241     * Any other system error depending on the error.
       
   242     */
       
   243     TInt RemoveObserver( const MCCPDTMFObserver& aObserver );
       
   244 
       
   245     /**
       
   246     * @see CConvergedCallProvider::GetLifeTime
       
   247     */ 
       
   248     TBool GetLifeTime( TDes8& aLifeTimeInfo );
       
   249     
       
   250     /**
       
   251     * @see CConvergedCallProvider::GetCSInfo
       
   252     */ 
       
   253     TBool GetCSInfo( CSInfo& aCSInfo );
       
   254     
       
   255 // from base class MCCPCSObserver
       
   256 
       
   257         
       
   258    
       
   259     
       
   260     
       
   261 // from base class MCCPObserver (inhereded by MCCPCSObserver)
       
   262 
       
   263     /**
       
   264      * From MCCPObserver (inhereded by MCCPCSObserver)
       
   265      * 
       
   266      * @see MCCPObserver::ErrorOccurred
       
   267      */
       
   268     
       
   269     void ErrorOccurred( TCCPError aError );
       
   270 
       
   271     /** From MCCPObserver (inhereded by MCCPCSObserver)
       
   272     * 
       
   273     * @see MCCPObserver::IncomingCall
       
   274     */
       
   275     
       
   276     void IncomingCall( MCCPCall* aCall, MCCPCall& aTempCall );
       
   277 
       
   278     /**
       
   279      * From MCCPObserver (inhereded by MCCPCSObserver)
       
   280      * 
       
   281      * 
       
   282      * @see MCCPObserver::IncomingCall
       
   283      */
       
   284     
       
   285     void IncomingCall( MCCPCall* aCall );
       
   286 
       
   287     /**
       
   288      * The actual implementation for IncomingCall.
       
   289      */
       
   290 
       
   291     void IncomingCallL( MCCPCall* aCall );
       
   292     
       
   293     /**
       
   294      * From MCCPObserver (inhereded by MCCPCSObserver)
       
   295      * 
       
   296      * @see MCCPObserver::CallCreated
       
   297      */
       
   298     
       
   299     void CallCreated( MCCPCall* aCall,
       
   300             MCCPCall* aOriginator,
       
   301             TBool aAttented );
       
   302 
       
   303     /**
       
   304      * From MCCPCSObserver
       
   305      * see MCCPCSObserver::PluginInitiatedCSMoCallCreated
       
   306      */
       
   307      //void PluginInitiatedCSMoCallCreated( MCCPCall* aCall ) const;
       
   308      void MoCallCreated( MCCPCall& aCall );
       
   309 
       
   310      /**
       
   311       * Notify of conference call that is not requested.
       
   312       * @since S60 3.2
       
   313       * @param aConferenceCall Created conference
       
   314       * @return none
       
   315       */
       
   316      void ConferenceCallCreated( MCCPConferenceCall& aConferenceCall );
       
   317     
       
   318     /**
       
   319      * From MCCPObserver (inhereded by MCCPCSObserver)
       
   320      *
       
   321      * @see MCCPObserver::DataPortName
       
   322      */
       
   323     void DataPortName( TName& aPortName );
       
   324     
       
   325 // from base class MVccEngPsPropertyListenerObserver
       
   326     
       
   327     /**
       
   328      * From MVccEngPsPropertyListenerObserver
       
   329      * Observer interface. Called when a P&S property value 
       
   330      * has been updated.
       
   331      * 
       
   332      * @since S60 v3.2
       
   333      * @param aCategoryId The category uid of the property
       
   334      * @param akeyId The key uid of the property
       
   335      * @param aValue Current value of the property.
       
   336      */ 
       
   337     void PropertyChangedL(
       
   338             const TUid aCategoryId,
       
   339             const TUint aKeyId,
       
   340             const TInt aValue );
       
   341 
       
   342 //from base class MSPNotifyChangeObserver
       
   343     
       
   344     /**
       
   345      * From MSPNotifyChangeObserver.
       
   346      * Handle notify change event from the service provider table observer.
       
   347      * 
       
   348      * @param aServiceId the service ID of added/changed/deleted service
       
   349      * ( only notification about the changes to VCC service are revceived) 
       
   350      */
       
   351     void HandleNotifyChange( TServiceId aServiceId );
       
   352     
       
   353     /**
       
   354      * From MSPNotifyChangeObserver.
       
   355      * Handle error notification received from the service provider table 
       
   356      * observer.
       
   357      * 
       
   358      * @param aError error code
       
   359      * @since S60 3.2
       
   360      */
       
   361     void HandleError( TInt aError );
       
   362     
       
   363     /**
       
   364      * Gets the call type of the currently active call from the performer array.
       
   365      * 
       
   366      * @return Call type of the currently active call, KErrNotFound if no active call
       
   367      * @since S60 3.2
       
   368      */    
       
   369     TInt CurrentCallTypeForDTMF();
       
   370     
       
   371     /**
       
   372      * Gets the call type of the currently active call and returns it's provider.
       
   373      * 
       
   374      * @return CConvergedCallProvider of the active call
       
   375      * @since S60 5.0
       
   376      */   
       
   377     CConvergedCallProvider* GetProvider();
       
   378     
       
   379 private:
       
   380 
       
   381     /**
       
   382     * C++ default constructor.
       
   383     */
       
   384     CVccDirector();
       
   385     
       
   386     /**
       
   387     * Symbian second-phase constructor
       
   388     */    
       
   389     void ConstructL();
       
   390     
       
   391 	/**
       
   392 	* for destroying an array
       
   393 	*/    
       
   394     static void PointerArrayCleanup( TAny* aArray );
       
   395     
       
   396     /**
       
   397  	* Creates call provider array 
       
   398  	*/    
       
   399     void FillCallProviderArrayL();
       
   400 
       
   401     /**
       
   402   	* Checks if given plugin is used by VCC 
       
   403 	* 
       
   404 	* @aparam aPluginId	call provider plugin id
       
   405 	* @return ETrue if plugin is used by VCC
       
   406   	*/    
       
   407     TBool IsVccOwnedPlugin( TInt aPluginId );
       
   408     
       
   409     /**
       
   410    	* Tries to initialize all call provider plugins VCC uses.  
       
   411  	* 
       
   412  	* @param aMonitor CCP observer
       
   413     * @param aSsObserver SS observer
       
   414  	* @return ETrue if all plugins were initialized
       
   415    	*/  
       
   416     TBool Initialize( const MCCPObserver& aMonitor,
       
   417             const MCCPSsObserver& aSsObserver );
       
   418     
       
   419     /**
       
   420     * Tries to initialize the given call provider plugin. 
       
   421     * Leaves if initialization fails.
       
   422   	* 
       
   423   	* @param aMonitor CCP observer
       
   424     * @param aSsObserver SS observer
       
   425     * @param aPlugin	call provider plugin
       
   426     */  
       
   427     void InitializeL( const MCCPObserver& aMonitor,
       
   428             const MCCPSsObserver& aSsObserver, 
       
   429             CConvergedCallProvider& aPlugin );
       
   430     
       
   431     /**
       
   432      *  for checking state of calls and making handover
       
   433      */
       
   434     void SwitchL( const TInt aValue );
       
   435     
       
   436     /**
       
   437      *  Checks are converged call provider plugins initialized
       
   438     */
       
   439     TBool IsPluginInitialized();
       
   440     
       
   441     /*
       
   442      * Starts notifications from service provider table observer.
       
   443      * Is notified about VCC service settings changes. 
       
   444      */
       
   445     void StartSpNotifierL();
       
   446 
       
   447     /*
       
   448      * Stops notifications from service provider table observer. 
       
   449      */
       
   450     void StopSpNotifierL();
       
   451     
       
   452     /*
       
   453      * Triesto initialize call provider plugins used by VCC that
       
   454      * were not initialized .
       
   455      * 
       
   456      * */
       
   457     void RetryInitialization();
       
   458     
       
   459     /*
       
   460      * The leaving-part implementation on ConferenceCallCreated.
       
   461      * @since S60 3.2
       
   462      * @param aConferenceCall Created conference
       
   463      */
       
   464     void CreateConferenceL( MCCPConferenceCall& aConferenceCall );
       
   465     
       
   466    
       
   467     
       
   468 private: // data
       
   469 
       
   470     /**
       
   471      * Implementation UID
       
   472      */
       
   473     TUid iImplementationUid;
       
   474     
       
   475     /**
       
   476      * Array of Call providers
       
   477      * Own.
       
   478      */    
       
   479     RPointerArray <CConvergedCallProvider> iProviders;
       
   480     
       
   481     /*
       
   482      * VCC needs to handle both cs and ps calls.
       
   483      * MCCPCSObserver can do both
       
   484      * Not own.
       
   485      */ 
       
   486     MCCPCSObserver* iCCPObserver;
       
   487     
       
   488     /*
       
   489      *  Supplementary service observer.
       
   490      * Not own.
       
   491      */
       
   492     MCCPSsObserver* iCCPSsObserver;
       
   493     
       
   494      /*
       
   495      * Handle to handover trigger.
       
   496      * Own.
       
   497      */
       
   498     CVccHoTrigger* iHoTrigger;
       
   499     
       
   500     /**
       
   501      * Array of Performers
       
   502      * Own.
       
   503      */   
       
   504    	RPointerArray<CVccPerformer> iPerfArray;
       
   505     
       
   506     /*
       
   507      * Handle to Conference call object.
       
   508      * Own.
       
   509      */
       
   510     CVccConferenceCall* iConference;
       
   511    	
       
   512     /*
       
   513      * Listener for the hand-over commands
       
   514      * Own.
       
   515      */
       
   516    	CVccEngPsPropertyListener* iPropListener; 
       
   517    	
       
   518    	//VCC state machine implementation
       
   519    	TVccStateInit iStateInit;
       
   520 	TVccStateCalling iStateCalling;
       
   521 	TVccStateReleasing iStateReleasing;
       
   522 	TVccStateFailing iStateFailing;
       
   523     
       
   524 	/**
       
   525      * Used for checking in ReleaseCall, that was this ReleaseCall due to
       
   526      * multicall handover situation
       
   527      */ 
       
   528 	TInt iHoKeyValue;
       
   529 	
       
   530 	/**
       
   531      * Notifies service provider setting change
       
   532      * Own
       
   533      */
       
   534     CSPNotifyChange* iSpNotifier;
       
   535     
       
   536     /*
       
   537      * Array of initialized plugins
       
   538      * Own.
       
   539      */    
       
   540     RArray<TInt> iInitialisedPlugins;
       
   541     
       
   542     /**
       
   543      * Proxy object for DTMF providers
       
   544      * Own.
       
   545      */
       
   546     CVccDtmfProvider* iDtmfProvider;
       
   547     
       
   548     /**
       
   549      * Used in initialization logic to inform of
       
   550      * failed converged call provider plugin.
       
   551      */
       
   552     TInt iMandatoryPluginFailedError;
       
   553 
       
   554 	friend class T_CVccDirector;
       
   555     friend class T_CVccDTMFProvider;
       
   556 	};
       
   557 
       
   558 #endif // CVCCDIRECTOR_H