camerauis/cameraapp/generic/src/CamCallStateAo.cpp
branchRCL_3
changeset 54 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 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:  Listens for changes to phone call state*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32base.h>
       
    21 #include <e32std.h>
       
    22 #include <eikenv.h>
       
    23 
       
    24 #include "CamUtility.h"
       
    25 #include "CamCallStateAo.h"
       
    26 #include "CamPanic.h"
       
    27 
       
    28 // EXTERNAL DATA STRUCTURES
       
    29 
       
    30 // EXTERNAL FUNCTION PROTOTYPES  
       
    31 
       
    32 // CONSTANTS
       
    33 
       
    34 // MACROS
       
    35 
       
    36 // LOCAL CONSTANTS AND MACROS
       
    37 
       
    38 // MODULE DATA STRUCTURES
       
    39 
       
    40 // LOCAL FUNCTION PROTOTYPES
       
    41 
       
    42 // FORWARD DECLARATIONS
       
    43 
       
    44 // ============================ MEMBER FUNCTIONS ===============================
       
    45 #ifdef _DEBUG
       
    46 void ExpandStateDebug( TPSCTsyCallState aVal )
       
    47     {
       
    48     switch ( aVal )
       
    49         {   
       
    50     case EPSCTsyCallStateUninitialized:
       
    51         PRINT(_L("Camera    CCamCallStateAo::RunL NEW STATUS => Uninit") );
       
    52         break;
       
    53     case EPSCTsyCallStateNone:
       
    54         PRINT(_L("Camera    CCamCallStateAo::RunL NEW STATUS => NONE") );
       
    55         break;
       
    56     case EPSCTsyCallStateAlerting:
       
    57         PRINT(_L("Camera    CCamCallStateAo::RunL NEW STATUS => ALERTING") );
       
    58         break;
       
    59     case EPSCTsyCallStateRinging:
       
    60         PRINT(_L("Camera    CCamCallStateAo::RunL NEW STATUS => RINGING") );
       
    61         break;
       
    62     case EPSCTsyCallStateDialling:
       
    63         PRINT(_L("Camera    CCamCallStateAo::RunL NEW STATUS => DIALLING") );
       
    64         break;
       
    65     case EPSCTsyCallStateAnswering:
       
    66         PRINT(_L("Camera    CCamCallStateAo::RunL NEW STATUS => ANSWERING") );
       
    67         break;
       
    68     case EPSCTsyCallStateDisconnecting:
       
    69         PRINT(_L("Camera    CCamCallStateAo::RunL NEW STATUS => DISCONNECTING") );
       
    70         break;
       
    71     case EPSCTsyCallStateConnected:
       
    72         PRINT(_L("Camera    CCamCallStateAo::RunL NEW STATUS => CONNECTED") );
       
    73         break;
       
    74     case EPSCTsyCallStateHold:
       
    75         PRINT(_L("Camera    CCamCallStateAo::RunL NEW STATUS => HOLD") );
       
    76         break;
       
    77         }
       
    78     }
       
    79 #endif // _DEBUG
       
    80 
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CCamCallStateAo::CCamCallStateAo
       
    84 // C++ default constructor can NOT contain any code, that might leave.
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 CCamCallStateAo::CCamCallStateAo( MCamCallStateObserver* aObserver ) : CActive( EPriorityStandard )
       
    88     {            
       
    89     PRINT( _L("Camera => CCamCallStateAo::CCamCallStateAo") );
       
    90     __ASSERT_DEBUG( aObserver != NULL, CamPanic(ECamPanicNullImage) );
       
    91     CActiveScheduler::Add( this );
       
    92     
       
    93     iObserver = aObserver;
       
    94     }
       
    95     
       
    96     
       
    97 // -----------------------------------------------------------------------------
       
    98 // CCamCallStateAo::NewL
       
    99 // Two-phased constructor.
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 CCamCallStateAo* CCamCallStateAo::NewL( MCamCallStateObserver* aObserver )
       
   103     {
       
   104     CCamCallStateAo* self = new( ELeave ) CCamCallStateAo( aObserver );
       
   105     CleanupStack::PushL( self );
       
   106     self->ConstructL();
       
   107     CleanupStack::Pop( self );
       
   108     return self;
       
   109     }
       
   110 
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // CCamSelfTimer::ConstructL
       
   114 // Symbian 2nd phase constructor can leave.
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 void CCamCallStateAo::ConstructL()
       
   118     {
       
   119     PRINT( _L("Camera => CCamCallStateAo::ConstructL") );
       
   120     
       
   121     TInt ret = iProperty.Attach( KPSUidCtsyCallInformation, KCTsyCallState );
       
   122     PRINT1( _L("CCamCallStateAo::ConstructL attaching property ret %d"), ret );
       
   123            
       
   124     if ( ret == KErrNone )
       
   125         {   
       
   126         // Will subscribe to the attribute required 
       
   127         RunL();
       
   128         }
       
   129     else
       
   130         {   
       
   131         // If an error occurred, we can't get call state info which we really need
       
   132         // so leave
       
   133         User::Leave( ret );
       
   134         }
       
   135     
       
   136     PRINT( _L("Camera <= CCamCallStateAo::ConstructL") );
       
   137     }
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // CCamCallStateAo::~CCamCallStateAo
       
   141 // Destructor
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 CCamCallStateAo::~CCamCallStateAo()
       
   145   {
       
   146   PRINT( _L("Camera => ~CCamCallStateAo") );
       
   147   Cancel();
       
   148   PRINT( _L("Camera <= ~CCamCallStateAo") );
       
   149   }
       
   150 
       
   151     
       
   152 // -----------------------------------------------------------------------------
       
   153 // CCamCallStateAo::DoCancel
       
   154 // Cancels an outstanding request
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 void CCamCallStateAo::DoCancel()
       
   158     {
       
   159     iProperty.Close();
       
   160     }
       
   161     
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 // CCamCallStateAo::RunL
       
   165 // Called when a request has completed.  
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 void CCamCallStateAo::RunL()
       
   169     {
       
   170     PRINT(_L("Camera => CCamCallStateAo::RunL") );
       
   171     iProperty.Subscribe( iStatus );
       
   172     PRINT(_L("Camera    CCamCallStateAo::RunL subscribed") );
       
   173 
       
   174     SetActive();
       
   175     PRINT(_L("Camera    CCamCallStateAo::RunL set active") );
       
   176 
       
   177     TInt val = KErrNotFound;
       
   178     TInt ret = iProperty.Get( val );
       
   179 
       
   180     if ( val != KErrNotFound && ret != KErrNotFound )
       
   181         {
       
   182         TPSCTsyCallState callState = static_cast<TPSCTsyCallState>( val );
       
   183 #ifdef _DEBUG
       
   184         ExpandStateDebug( callState );
       
   185 #endif
       
   186         PRINT(_L("Camera    CCamCallStateAo::RunL calling callback") );
       
   187         iObserver->CallStateChanged( callState, ret );
       
   188         PRINT(_L("Camera    CCamCallStateAo::RunL returned from callback") );
       
   189         }
       
   190     else
       
   191         {
       
   192         iObserver->CallStateChanged( EPSCTsyCallStateUninitialized, ret );
       
   193         }
       
   194     PRINT(_L("Camera <= CCamCallStateAo::RunL") );
       
   195     }
       
   196     
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CCamCallStateAo::RunError
       
   200 // Called when an error has occurred.
       
   201 // -----------------------------------------------------------------------------
       
   202 //
       
   203 TInt CCamCallStateAo::RunError( TInt aError )
       
   204     {
       
   205     iObserver->CallStateChanged( EPSCTsyCallStateUninitialized, aError );    
       
   206     return KErrNone;
       
   207     }
       
   208 
       
   209 //  End of File