|
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 |
|
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 CX_DEBUG_EXIT_FUNCTION(); |
|
31 } |
|
32 |
|
33 CxeFakeAutoFocusControl::~CxeFakeAutoFocusControl() |
|
34 { |
|
35 CX_DEBUG_IN_FUNCTION(); |
|
36 } |
|
37 |
|
38 CxeError::Id CxeFakeAutoFocusControl::start() |
|
39 { |
|
40 CX_DEBUG_IN_FUNCTION(); |
|
41 return CxeError::None; |
|
42 } |
|
43 |
|
44 |
|
45 void CxeFakeAutoFocusControl::cancel() |
|
46 { |
|
47 CX_DEBUG_IN_FUNCTION(); |
|
48 } |
|
49 |
|
50 void CxeFakeAutoFocusControl::setMode(CxeAutoFocusControl::Mode newMode) |
|
51 { |
|
52 CX_DEBUG_ENTER_FUNCTION(); |
|
53 mAfMode = newMode; |
|
54 CX_DEBUG_EXIT_FUNCTION(); |
|
55 } |
|
56 |
|
57 CxeAutoFocusControl::Mode CxeFakeAutoFocusControl::mode() const |
|
58 { |
|
59 return mAfMode; |
|
60 } |
|
61 |
|
62 bool CxeFakeAutoFocusControl::supported() const |
|
63 { |
|
64 return true; |
|
65 } |
|
66 |
|
67 CxeAutoFocusControl::State CxeFakeAutoFocusControl::state() const |
|
68 { |
|
69 return static_cast<State>(stateId()); |
|
70 } |
|
71 |
|
72 void CxeFakeAutoFocusControl::handleStateChanged( |
|
73 int newStateId, CxeError::Id error) |
|
74 { |
|
75 CX_DEBUG_ENTER_FUNCTION(); |
|
76 emit stateChanged(static_cast<State>(newStateId), error); |
|
77 CX_DEBUG_EXIT_FUNCTION(); |
|
78 } |
|
79 |
|
80 void CxeFakeAutoFocusControl::setFakeState(CxeAutoFocusControl::State aState) |
|
81 { |
|
82 setState(aState); |
|
83 } |
|
84 |
|
85 void CxeFakeAutoFocusControl::initializeStates() |
|
86 { |
|
87 // The fake state machine has more relaxed state transition checks |
|
88 // for testing purposes. |
|
89 int anyState = (InProgress | Failed | Ready | Unknown | Canceling); |
|
90 |
|
91 // addState(id, name, allowed next states) |
|
92 addState(new CxeState(Unknown , "Unknown", anyState)); |
|
93 addState(new CxeState(InProgress , "InProgress", anyState)); |
|
94 addState(new CxeState(Failed , "Failed", anyState)); |
|
95 addState(new CxeState(Ready , "Ready", anyState)); |
|
96 addState(new CxeState(Canceling , "Canceling", anyState)); |
|
97 |
|
98 setInitialState(Unknown); |
|
99 } |
|
100 |
|
101 // end of file |