camerauis/cameraxui/cxui/tsrc/cxuifakeviewfindercontrol.cpp
branchRCL_3
changeset 54 bac7acad7cb3
parent 53 61bc0f252b2b
child 57 2c87b2808fd7
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
     1 /*
       
     2 * Copyright (c) 2009 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:
       
    15 *
       
    16 */
       
    17 #include <w32std.h> // RWindow, RWsSession.
       
    18 #include <coemain.h> // CCoeEnv
       
    19 #include <coecntrl.h>
       
    20 #include "cxutils.h"
       
    21 #include "cxecameradevicecontrolsymbian.h" // CxeCameraDevice
       
    22 #include "cxuifakeviewfindercontrol.h"
       
    23 #include "cxesettings.h"
       
    24 #include "cxesettingsmappersymbian.h"
       
    25 
       
    26 
       
    27 /*
       
    28 * CxuiFakeViewfinderControl::CxuiFakeViewfinderControl
       
    29 */
       
    30 CxuiFakeViewfinderControl::CxuiFakeViewfinderControl(
       
    31     CxeCameraDevice &cameraDevice,
       
    32     CxeCameraDeviceControlSymbian &cameraDeviceControl )
       
    33     : CxeViewfinderControlSymbian(cameraDevice, cameraDeviceControl),
       
    34       mCameraDevice(cameraDevice),
       
    35       mCameraDeviceControl(cameraDeviceControl),
       
    36       mWindow(NULL),
       
    37       mDirectViewfinder(NULL),
       
    38       mDirectViewfinderInUse(true)
       
    39 {
       
    40     CX_DEBUG_IN_FUNCTION();
       
    41 }
       
    42 
       
    43 
       
    44 
       
    45 /*
       
    46 * CxuiFakeViewfinderControl::~CxuiFakeViewfinderControl()
       
    47 */
       
    48 CxuiFakeViewfinderControl::~CxuiFakeViewfinderControl()
       
    49 {
       
    50     CX_DEBUG_ENTER_FUNCTION();
       
    51 
       
    52     stop();
       
    53 
       
    54     CX_DEBUG_EXIT_FUNCTION();
       
    55 }
       
    56 
       
    57 
       
    58 /*
       
    59 * Stop viewfinder
       
    60 */
       
    61 void CxuiFakeViewfinderControl::stop()
       
    62 {
       
    63     CX_DEBUG_ENTER_FUNCTION();
       
    64 
       
    65     if (state() == Running) {
       
    66         setState(Ready);
       
    67     }
       
    68 
       
    69     CX_DEBUG_EXIT_FUNCTION();
       
    70 }
       
    71 
       
    72 
       
    73 /**
       
    74  * Start the viewfinder
       
    75  */
       
    76 
       
    77 int CxuiFakeViewfinderControl::start()
       
    78 {
       
    79     CX_DEBUG_ENTER_FUNCTION();
       
    80     TInt err = KErrNone;
       
    81     
       
    82     if (state() == Running) {
       
    83         CX_DEBUG( ( "Viewfinder already running - ignored start()" ) );
       
    84         CX_DEBUG_EXIT_FUNCTION();
       
    85         return 0;
       
    86     }
       
    87 
       
    88     if (state() == Uninitialized) {
       
    89         err = initViewfinder();
       
    90     }
       
    91 
       
    92     // apply any settings here
       
    93 
       
    94     if (!err  && state() == Ready) {
       
    95         setState( Running );
       
    96     }
       
    97 
       
    98     CX_DEBUG(("CxuiFakeViewfinderControl::start symbian error code : %d", err));
       
    99     CX_DEBUG_EXIT_FUNCTION();
       
   100     return err;
       
   101 }
       
   102 
       
   103 
       
   104 /*
       
   105 * Intialize the viewfinder based on the VF mode
       
   106 */ 
       
   107 
       
   108 int CxuiFakeViewfinderControl::initViewfinder()
       
   109 {
       
   110     CX_DEBUG_ENTER_FUNCTION();
       
   111 
       
   112     // For now only direct vf. If there is any need for supporting other VF modes, condition checks
       
   113     // and handling of new states are needed here. 
       
   114     setState(Ready);
       
   115 
       
   116     CX_DEBUG_EXIT_FUNCTION();
       
   117     return KErrNone;
       
   118 }
       
   119 
       
   120 /*
       
   121 * Release Vf, when we change mode or during shutdown or ?
       
   122 */ 
       
   123 
       
   124 void CxuiFakeViewfinderControl::releaseCurrentViewfinder()
       
   125 {
       
   126     CX_DEBUG_ENTER_FUNCTION(); 
       
   127 
       
   128     setState(Uninitialized);
       
   129 
       
   130     CX_DEBUG_EXIT_FUNCTION();
       
   131 }
       
   132 
       
   133 CxeViewfinderControl::State CxuiFakeViewfinderControl::state() const
       
   134 {
       
   135     return static_cast<State>(stateId());
       
   136 }
       
   137 
       
   138 void CxuiFakeViewfinderControl::handleStateChanged(int newStateId, CxeError::Id error)
       
   139 {
       
   140     emit stateChanged(static_cast<State>(newStateId), error);
       
   141 }
       
   142 
       
   143 // end of file