camappengine/Engine/Src/CaeCallbackActive.cpp
branchRCL_3
changeset 20 e3cdd00b5ae3
parent 19 18fa9327a158
child 21 27fe719c32e6
equal deleted inserted replaced
19:18fa9327a158 20:e3cdd00b5ae3
     1 /*
       
     2 * Copyright (c) 2003,2004 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:  Active object for calling Camera Application Engine methods 
       
    15 *                indirectly from callbacks
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CaeCallbackActive.h"
       
    22 #include "CaeEngineImp.h"
       
    23 
       
    24 
       
    25 // ================= MEMBER FUNCTIONS =======================
       
    26 
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // CCaeCallbackActive::CCaeCallbackActive()
       
    30 // C++ constructor.
       
    31 // Adds the object to the Active Scheduler.
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 CCaeCallbackActive::CCaeCallbackActive( 
       
    35     CCaeEngineImp& aCamAppEngine )
       
    36 : CActive( EPriorityStandard ), iCamAppEngine( aCamAppEngine )
       
    37     {
       
    38     CActiveScheduler::Add( this );
       
    39     }
       
    40 
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CCaeCallbackActive::CCaeCallbackActive()
       
    44 // Destructor. 
       
    45 // Cancels operation and closes the timer.
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CCaeCallbackActive::~CCaeCallbackActive()
       
    49     {
       
    50     Cancel();
       
    51     iTimer.Close();
       
    52     }
       
    53 
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CCaeCallbackActive::NewLC()
       
    57 // Symbian OS two-phased constructor.
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 CCaeCallbackActive* CCaeCallbackActive::NewLC( 
       
    61     CCaeEngineImp& aCamAppEngine )
       
    62     {
       
    63     CCaeCallbackActive* self = new( ELeave ) CCaeCallbackActive( aCamAppEngine );
       
    64 
       
    65     CleanupStack::PushL( self );
       
    66     self->ConstructL();
       
    67     return self;
       
    68     }
       
    69 
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // CCaeCallbackActive::NewL()
       
    73 // Symbian OS two-phased constructor.
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 CCaeCallbackActive* CCaeCallbackActive::NewL( 
       
    77     CCaeEngineImp& aCamAppEngine )
       
    78     {
       
    79     CCaeCallbackActive* self = NewLC( aCamAppEngine );
       
    80     CleanupStack::Pop( self );
       
    81     return self;
       
    82     }
       
    83 
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CCaeCallbackActive::ConstructL()
       
    87 // Symbian OS 2nd phase constructor that can leave.
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 void CCaeCallbackActive::ConstructL()
       
    91     {
       
    92     User::LeaveIfError( iTimer.CreateLocal() );
       
    93     }
       
    94 
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CCaeCallbackActive::PowerOn()
       
    98 // Switches camera power on.
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 void CCaeCallbackActive::PowerOn()
       
   102     {
       
   103     LOGTEXT( _L( "Cae: CCaeCallbackActive::PowerOn() entering" ) );
       
   104 
       
   105     _LIT( KPowerOnPanic, "CCaeCallbackActive::PowerOn");
       
   106     __ASSERT_ALWAYS( !IsActive(), User::Panic( KPowerOnPanic, 1 ) );
       
   107 
       
   108     iRequest = CCaeCallbackActive::ERequestPowerOn;
       
   109 
       
   110     SetActive();
       
   111     TRequestStatus* statusPtr = &iStatus;
       
   112     User::RequestComplete( statusPtr, KErrNone );
       
   113 
       
   114     LOGTEXT( _L( "Cae: CCaeCallbackActive::PowerOn() returning" ) );
       
   115     }
       
   116 
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // CCaeCallbackActive::RunL()
       
   120 // Calls Camera Application Engine operation.
       
   121 // ---------------------------------------------------------------------------
       
   122 //
       
   123 void CCaeCallbackActive::RunL()
       
   124     {
       
   125     LOGTEXT( _L( "Cae: CCaeCallbackActive::RunL() entering" ) );
       
   126 
       
   127     switch ( iRequest ) 
       
   128         {
       
   129         case CCaeCallbackActive::ERequestPowerOn:
       
   130             // Call Camera Application Engine to switch camera power on.
       
   131             iCamAppEngine.PowerOn();
       
   132             break;
       
   133         default:
       
   134             break;
       
   135         }
       
   136 
       
   137     LOGTEXT( _L( "Cae: CCaeCallbackActive::RunL() returning" ) );
       
   138     }
       
   139 
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // CCaeCallbackActive::DoCancel()
       
   143 // Cancels request.
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 void CCaeCallbackActive::DoCancel()
       
   147     {
       
   148     iTimer.Cancel();
       
   149     iRequest = CCaeCallbackActive::ERequestDefault;
       
   150     }
       
   151 
       
   152 
       
   153 // End of File