camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakeautofocuscontrol.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-2010 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 
       
    18 #include "cxefakeautofocuscontrol.h"
       
    19 #include "cxutils.h"
       
    20 #include "cxestate.h"
       
    21 
       
    22 /*
       
    23 * CxeFakeAutoFocusControl::CxeFakeAutoFocusControl
       
    24 */
       
    25 CxeFakeAutoFocusControl::CxeFakeAutoFocusControl()
       
    26     : CxeStateMachine("CxeFakeAutoFocusControl")
       
    27 {
       
    28     CX_DEBUG_ENTER_FUNCTION();
       
    29     initializeStates();
       
    30     qRegisterMetaType<CxeAutoFocusControl::State>("CxeAutoFocusControl::State");
       
    31     qRegisterMetaType<CxeAutoFocusControl::Mode>("CxeAutoFocusControl::Mode");
       
    32     CX_DEBUG_EXIT_FUNCTION();
       
    33 }
       
    34 
       
    35 CxeFakeAutoFocusControl::~CxeFakeAutoFocusControl()
       
    36 {
       
    37     CX_DEBUG_IN_FUNCTION();
       
    38 }
       
    39 
       
    40 CxeError::Id CxeFakeAutoFocusControl::start(bool soundEnabled)
       
    41 {
       
    42     CX_DEBUG_IN_FUNCTION();
       
    43     Q_UNUSED(soundEnabled);
       
    44     return CxeError::None;
       
    45 }
       
    46 
       
    47 
       
    48 void CxeFakeAutoFocusControl::cancel()
       
    49 {
       
    50     CX_DEBUG_IN_FUNCTION();
       
    51 }
       
    52 
       
    53 void CxeFakeAutoFocusControl::setMode(CxeAutoFocusControl::Mode newMode)
       
    54 {
       
    55     CX_DEBUG_ENTER_FUNCTION();
       
    56     mAfMode = newMode;
       
    57     CX_DEBUG_EXIT_FUNCTION();
       
    58 }
       
    59 
       
    60 CxeAutoFocusControl::Mode CxeFakeAutoFocusControl::mode() const
       
    61 {
       
    62     return mAfMode;
       
    63 }
       
    64 
       
    65 bool CxeFakeAutoFocusControl::isFixedFocusMode(Mode mode) const
       
    66 {
       
    67     return (mode == CxeAutoFocusControl::Hyperfocal
       
    68          || mode == CxeAutoFocusControl::Infinity);
       
    69 }
       
    70 
       
    71 bool CxeFakeAutoFocusControl::supported() const
       
    72 {
       
    73     return true;
       
    74 }
       
    75 
       
    76 bool CxeFakeAutoFocusControl::isSoundEnabled() const
       
    77 {
       
    78     return true;
       
    79 }
       
    80 
       
    81 CxeAutoFocusControl::State CxeFakeAutoFocusControl::state() const
       
    82 {
       
    83     return static_cast<State>(stateId());
       
    84 }
       
    85 
       
    86 void CxeFakeAutoFocusControl::handleStateChanged(
       
    87         int newStateId, CxeError::Id error)
       
    88 {
       
    89     CX_DEBUG_ENTER_FUNCTION();
       
    90     emit stateChanged(static_cast<State>(newStateId), error);
       
    91     CX_DEBUG_EXIT_FUNCTION();
       
    92 }
       
    93 
       
    94 void CxeFakeAutoFocusControl::setFakeState(CxeAutoFocusControl::State aState)
       
    95 {
       
    96     setState(aState);
       
    97 }
       
    98 
       
    99 void CxeFakeAutoFocusControl::initializeStates()
       
   100 {
       
   101     // The fake state machine has more relaxed state transition checks
       
   102     // for testing purposes.
       
   103     int anyState = (InProgress | Failed | Ready | Unknown | Canceling);
       
   104 
       
   105     // addState(id, name, allowed next states)
       
   106     addState(new CxeState(Unknown , "Unknown", anyState));
       
   107     addState(new CxeState(InProgress , "InProgress", anyState));
       
   108     addState(new CxeState(Failed , "Failed", anyState));
       
   109     addState(new CxeState(Ready , "Ready", anyState));
       
   110     addState(new CxeState(Canceling , "Canceling", anyState));
       
   111 
       
   112     setInitialState(Unknown);
       
   113 }
       
   114 
       
   115 // end of file