camerauis/cameraapp/generic/src/cameracontroller/camcameracontrolleractive.cpp
branchRCL_3
changeset 24 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
23:61bc0f252b2b 24: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:  CCamCameraControllerActive class implementation.
       
    15 *                
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <e32base.h>
       
    21 #include "camcameracontroller.pan"
       
    22 #include "camlogging.h"
       
    23 #include "camcameracontroller.h"
       
    24 #include "camcameracontrolleractive.h"
       
    25 
       
    26 using namespace NCamCameraController;
       
    27 
       
    28 
       
    29 // ===========================================================================
       
    30 // Costructors and destructor
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // 2 phase constructor <<static>>
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 CCamCameraControllerActive* 
       
    37 CCamCameraControllerActive::NewL( CCamCameraController& aController, 
       
    38                                   TInt                  aPriority   )
       
    39   {
       
    40   CCamCameraControllerActive* self = 
       
    41       new (ELeave) CCamCameraControllerActive( aController, aPriority );
       
    42 
       
    43   CleanupStack::PushL( self );
       
    44   self->ConstructL();
       
    45   CleanupStack::Pop( self );
       
    46 
       
    47   return self;
       
    48   }
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // Destructor <<virtual>>
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 CCamCameraControllerActive::~CCamCameraControllerActive()
       
    56   {
       
    57   PRINT( _L("Camera => ~CCamCameraControllerActive") );
       
    58   Cancel();
       
    59   PRINT( _L("Camera <= ~CCamCameraControllerActive") );
       
    60   }
       
    61 
       
    62   
       
    63 // ---------------------------------------------------------------------------
       
    64 // 2nd phase constructor
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void 
       
    68 CCamCameraControllerActive::ConstructL()
       
    69   {
       
    70   CActiveScheduler::Add( this );
       
    71   }
       
    72 
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // 1st phase constructor
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 CCamCameraControllerActive
       
    79 ::CCamCameraControllerActive( CCamCameraController& aController, 
       
    80                               TInt                  aPriority   )
       
    81   : CActive( aPriority ),
       
    82     iController( aController )
       
    83   {
       
    84   }
       
    85     
       
    86 // ===========================================================================
       
    87 // From CActive
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // DoCancel <<virtual>> 
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 void 
       
    94 CCamCameraControllerActive::DoCancel()
       
    95   {
       
    96   HandleError( KErrCancel );
       
    97   }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // RunL <<virtual>>
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 void 
       
   104 CCamCameraControllerActive::RunL()
       
   105   {
       
   106   PRINT( _L("Camera => CCamCameraControllerActive::RunL") );
       
   107   User::LeaveIfError( iStatus.Int() );
       
   108 
       
   109   TInt more = iController.ProcessNextRequestL();
       
   110   
       
   111   if( more )
       
   112     {
       
   113     IssueRequest();
       
   114     }
       
   115   else
       
   116     {
       
   117     // No more callbacks needed atleast for now.    
       
   118     }
       
   119   PRINT( _L("Camera <= CCamCameraControllerActive::RunL") );
       
   120   }
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // RunError <<virtual>>
       
   124 //
       
   125 // Called when leave occurs in RunL
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 TInt 
       
   129 CCamCameraControllerActive::RunError( TInt aError )
       
   130   {
       
   131   PRINT1( _L("Camera => CCamCameraControllerActive::RunError, error:%d"), aError );
       
   132 
       
   133   HandleError( aError );
       
   134   
       
   135   PRINT( _L("Camera <= CCamCameraControllerActive::RunError") );
       
   136   return KErrNone;
       
   137   }
       
   138 
       
   139 // ===========================================================================
       
   140 // New methods
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 // IssueRequest
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 void
       
   147 CCamCameraControllerActive::IssueRequest()
       
   148   {
       
   149   PRINT( _L("Camera => CCamCameraControllerActive::IssueRequest") );
       
   150 
       
   151   __ASSERT_ALWAYS( !IsActive(), Panic( ECamCameraControllerBusy ) );
       
   152 
       
   153   // Set RunL to be called as soon as possible  
       
   154   TRequestStatus* status = &iStatus;
       
   155   User::RequestComplete( status, KErrNone );
       
   156   SetActive();
       
   157 
       
   158   PRINT( _L("Camera <= CCamCameraControllerActive::IssueRequest") );
       
   159   }
       
   160 
       
   161 
       
   162 // ---------------------------------------------------------------------------
       
   163 // HandleError
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 void 
       
   167 CCamCameraControllerActive::HandleError( TInt aStatus )
       
   168   {
       
   169   iController.EndSequence( aStatus );
       
   170   }
       
   171 
       
   172 // ===========================================================================
       
   173 // end of file