callcontinuity/vcchotrigger/inc/vcccchmonitor.h
branchRCL_3
changeset 22 d38647835c2e
parent 0 a4daefaec16c
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2008-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:   CCH monitor class definition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef VCCCCHMONITOR_H
       
    20 #define VCCCCHMONITOR_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <cch.h>
       
    24 
       
    25 #include "vcccchobserver.h"
       
    26 #include "vccunittesting.h"
       
    27 
       
    28 /**
       
    29  *  CCH monitor. Uses CCH to enable/disable CCH services.
       
    30  *
       
    31  *  @code
       
    32  *   MyClass::ConstructL()
       
    33  *       {
       
    34  *       iMyCch = Cch::NewL();
       
    35  *
       
    36  *       iMyService = iMyCch->GetService( iMyServiceId );
       
    37  *
       
    38  *       User::LeaveIfNull( iMyService );
       
    39  *
       
    40  *       iMyService->SetObserver( *this );
       
    41  *
       
    42  *       TInt error = iMyService->Enable( iMyServiceType );
       
    43  *
       
    44  *       if ( error != KErrNone )
       
    45  *           {
       
    46  *           User::Leave( error );
       
    47  *           }
       
    48  *       }
       
    49  *
       
    50  *   MyClass::ServiceStatusChanged(
       
    51  *       TInt aServiceId,
       
    52  *       CCHSubserviceType aType,
       
    53  *       const TCchServiceStatus& aServiceStatus )
       
    54  *       {
       
    55  *       if ( aServiceStatus.Error() != KErrNone )
       
    56  *           {
       
    57  *           HandleError();
       
    58  *           }
       
    59  *       else
       
    60  *           {
       
    61  *           HandleStateChange();
       
    62  *           }
       
    63  *       }
       
    64  *
       
    65  *   MyClass::~MyClass()
       
    66  *       {
       
    67  *       iMyService->Disable( iMyServiceType );
       
    68  *       delete iCch;
       
    69  *       }
       
    70  *
       
    71  *  @endcode
       
    72  *
       
    73  *  @lib vcchotrigger.dll
       
    74  *  @since S60 v3.2
       
    75  */
       
    76 class CVccCchMonitor : public CBase,
       
    77                        public MCchServiceStatusObserver
       
    78     {
       
    79 
       
    80 public:
       
    81 
       
    82     /**
       
    83      * Two-phased constructor.
       
    84      * @param aObserver Observer to be notified when status changes
       
    85      */
       
    86     static CVccCchMonitor* NewL( MVccCchObserver& aObserver );
       
    87 
       
    88     /**
       
    89      * Destructor.
       
    90      */
       
    91     virtual ~CVccCchMonitor();
       
    92 
       
    93     /**
       
    94      * Enable the service and start monitoring
       
    95      * the service state.
       
    96      *
       
    97      * @since S60 v3.2
       
    98      */
       
    99     void EnableServiceL();
       
   100 
       
   101     /**
       
   102      * Disable the service and stop monitoring the
       
   103      * service state
       
   104      *
       
   105      * @since S60 v3.2
       
   106      */
       
   107     void DisableService();
       
   108 
       
   109     /**
       
   110      * Get the last state of the CCH service.
       
   111      *
       
   112      * @since S60 v3.2
       
   113      * @return The status of the service: available or not
       
   114      */
       
   115     MVccCchObserver::TServiceStatus ServiceStatus() const;
       
   116 
       
   117 
       
   118 // from base class MCchServiceStatusObserver
       
   119 
       
   120     /**
       
   121      * From MCchServiceStatusObserver
       
   122      * Signaled when service status or error changes
       
   123      *
       
   124      * @param aServiceId Id of the service
       
   125      * @param aType Service type
       
   126      * @param aServiceStatus Service status
       
   127      */
       
   128     void ServiceStatusChanged(
       
   129             TInt aServiceId,
       
   130             TCCHSubserviceType aType,
       
   131             const TCchServiceStatus& aServiceStatus );
       
   132 
       
   133 private:
       
   134 
       
   135     /**
       
   136      * C++ constructor
       
   137      *
       
   138      * @since S60 v3.2
       
   139      * @param aObserver Observer to be notified when status changes.
       
   140      */
       
   141     CVccCchMonitor( MVccCchObserver& aObserver );
       
   142 
       
   143     /**
       
   144      * Symbian constructor
       
   145      *
       
   146      * @since S60 v3.2
       
   147      */
       
   148     void ConstructL();
       
   149 
       
   150     /**
       
   151      * Notify observer about CCH service status has changed.
       
   152      *
       
   153      * @since S60 v3.2
       
   154      */
       
   155     void NotifyObserver();
       
   156 
       
   157 
       
   158     /**
       
   159      * Enable the service (assioated to the iCchService)
       
   160      *
       
   161      * @since S60 v3.2
       
   162      */
       
   163     void DoEnableServiceL();
       
   164 
       
   165 
       
   166 private: // data
       
   167 
       
   168     /**
       
   169      * Our observer.
       
   170      * Not own
       
   171      */
       
   172     MVccCchObserver& iObserver;
       
   173 
       
   174     /**
       
   175      * Should our obsever to be notified
       
   176      * ETrue: yes, EFalse: no.
       
   177      */
       
   178     TBool iNotifyObserver;
       
   179 
       
   180     /*
       
   181      * CCH
       
   182      * Own.
       
   183      */
       
   184     CCch* iCch;
       
   185 
       
   186     /*
       
   187      * CCH service
       
   188      * Not own.
       
   189      */
       
   190     CCchService* iCchService;
       
   191 
       
   192     /*
       
   193      * Service is reserved for us.
       
   194      */
       
   195     TBool iServiceReserved;
       
   196 
       
   197     /*
       
   198      * Must we disable the service upon exit.
       
   199      */
       
   200     TBool iDisableService;
       
   201 
       
   202     /**
       
   203      * The last state of the CCH service.
       
   204      */
       
   205     TCCHSubserviceState iCurrentCchState;
       
   206 
       
   207     /**
       
   208      * The last error received from the CCH service
       
   209      */
       
   210     TInt iLastCchError;
       
   211 
       
   212     /**
       
   213      * Service id of the VoIP we are using
       
   214      */
       
   215     TInt iServiceId;
       
   216 
       
   217     /*
       
   218      * Current status (own status reported to observer).
       
   219      */
       
   220     MVccCchObserver::TServiceStatus iCurrentStatus;
       
   221 
       
   222 
       
   223     VCC_UNITTEST( UT_CVccCchMonitor )
       
   224     };
       
   225 
       
   226 
       
   227 #endif // VCCCCHMONITOR_H