|
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 <QMetaType> |
|
19 #include <QImage> |
|
20 //#include <fbs.h> |
|
21 //#include <ecam.h> // CCamera |
|
22 //#include <ecam/ecamadvsettingsintf.h> // CCamera |
|
23 |
|
24 #include "cxesettings.h" |
|
25 #include "cxuifakeautofocuscontrol.h" |
|
26 #include "cxutils.h" |
|
27 #include "cxecameradevicecontrolsymbian.h" // CxeCameraDevice |
|
28 #include "cxesettingsmappersymbian.h" |
|
29 |
|
30 |
|
31 /* |
|
32 * CxeAutoFocusControlSymbian::CxeAutoFocusControlSymbian |
|
33 */ |
|
34 CxuiFakeAutoFocusControl::CxuiFakeAutoFocusControl(CxeCameraDevice &cameraDevice) |
|
35 : CxeAutoFocusControlSymbian(cameraDevice), |
|
36 mCameraDevice( cameraDevice ), |
|
37 mAdvancedSettings( NULL ) |
|
38 { |
|
39 CX_DEBUG_ENTER_FUNCTION(); |
|
40 |
|
41 /*qRegisterMetaType<CxeAutoFocusControl::State>(); |
|
42 |
|
43 initializeStates(); |
|
44 |
|
45 // connect signals from cameraDevice, so we recieve events when camera reference changes |
|
46 QObject::connect( &cameraDevice, |
|
47 SIGNAL(prepareForCameraDelete()), |
|
48 this,SLOT(prepareForCameraDelete()) ); |
|
49 |
|
50 QObject::connect( &cameraDevice, |
|
51 SIGNAL(cameraAllocated()), |
|
52 this,SLOT(cameraAllocated()) ); |
|
53 |
|
54 QObject::connect( &cameraDevice, |
|
55 SIGNAL(prepareForRelease()), |
|
56 this,SLOT(prepareForRelease()) ); |
|
57 |
|
58 initializeResources();*/ |
|
59 |
|
60 CX_DEBUG_EXIT_FUNCTION(); |
|
61 } |
|
62 |
|
63 |
|
64 |
|
65 /* |
|
66 *CxuiFakeAutoFocusControl::initAdvancedSettings |
|
67 */ |
|
68 /*void CxuiFakeAutoFocusControl::initializeResources() |
|
69 { |
|
70 CX_DEBUG_ENTER_FUNCTION(); |
|
71 CX_DEBUG_ASSERT( mCameraDevice.camera() ); |
|
72 |
|
73 mAdvancedSettings = mCameraDevice.advancedSettings(); |
|
74 |
|
75 CX_DEBUG_EXIT_FUNCTION(); |
|
76 }*/ |
|
77 |
|
78 |
|
79 |
|
80 /* |
|
81 * CxuiFakeAutoFocusControl::~CxuiFakeAutoFocusControl |
|
82 */ |
|
83 CxuiFakeAutoFocusControl::~CxuiFakeAutoFocusControl() |
|
84 { |
|
85 CX_DEBUG_ENTER_FUNCTION(); |
|
86 CX_DEBUG_EXIT_FUNCTION(); |
|
87 } |
|
88 |
|
89 |
|
90 /* |
|
91 * Start Autofocus |
|
92 */ |
|
93 int CxuiFakeAutoFocusControl::start() |
|
94 { |
|
95 CX_DEBUG( ("CxuiFakeAutoFocusControl::start() <> state: %d", state() ) ); |
|
96 |
|
97 int err = KErrNone; |
|
98 setState( InProgress ); |
|
99 handleAfEvent( KUidECamEventCameraSettingsOptimalFocusUidValue, err); |
|
100 |
|
101 return(err); |
|
102 } |
|
103 |
|
104 |
|
105 |
|
106 /* |
|
107 * Cancel Autofocus |
|
108 */ |
|
109 void CxuiFakeAutoFocusControl::cancel() |
|
110 { |
|
111 CX_DEBUG( ("CxuiFakeAutoFocusControl::cancel <> state: %d", state() ) ); |
|
112 setState( Canceling ); |
|
113 handleAfEvent( KUidECamEventCameraSettingsOptimalFocusUidValue, KErrNone ); |
|
114 } |
|
115 |
|
116 |
|
117 |
|
118 /* |
|
119 * Set Autofocus mode |
|
120 */ |
|
121 void CxuiFakeAutoFocusControl::setMode(CxeAutoFocusControl::Mode newMode) |
|
122 { |
|
123 CX_DEBUG_ENTER_FUNCTION(); |
|
124 mAfMode = newMode; |
|
125 CX_DEBUG_EXIT_FUNCTION(); |
|
126 } |
|
127 |
|
128 |
|
129 /* |
|
130 * returns Autofocus mode |
|
131 */ |
|
132 |
|
133 CxeAutoFocusControl::Mode CxuiFakeAutoFocusControl::mode() const |
|
134 { |
|
135 return mAfMode; |
|
136 } |
|
137 |
|
138 |
|
139 |
|
140 /* |
|
141 * To check if Autofocus is supported |
|
142 */ |
|
143 bool CxuiFakeAutoFocusControl::supported() const |
|
144 { |
|
145 return true; |
|
146 } |
|
147 |
|
148 CxeAutoFocusControl::State CxuiFakeAutoFocusControl::state() const |
|
149 { |
|
150 return static_cast<State>( stateId() ); |
|
151 } |
|
152 |
|
153 |
|
154 void CxuiFakeAutoFocusControl::handleStateChanged( int newStateId, CxeError::Id error ) |
|
155 { |
|
156 CX_DEBUG_ENTER_FUNCTION(); |
|
157 emit stateChanged(static_cast<State>(newStateId), error); |
|
158 } |
|
159 |
|
160 /* |
|
161 * CxuiFakeAutoFocusControl::handleAfEvent |
|
162 */ |
|
163 void CxuiFakeAutoFocusControl::handleAfEvent(int eventUid, int error) |
|
164 { |
|
165 CX_DEBUG_ENTER_FUNCTION(); |
|
166 |
|
167 switch ( state() ) { |
|
168 case CxeAutoFocusControl::InProgress: { |
|
169 if(eventUid == KUidECamEventCameraSettingsOptimalFocusUidValue ) { |
|
170 CX_DEBUG(("CxuiFakeAutoFocusControl::handleAfEvent <> KUidECamEventCameraSettingsOptimalFocus")); |
|
171 if (KErrNone == error) { |
|
172 setState(CxeAutoFocusControl::Ready); |
|
173 } else { |
|
174 setState(CxeAutoFocusControl::Failed, error); |
|
175 } |
|
176 } |
|
177 break; |
|
178 } |
|
179 case CxeAutoFocusControl::Canceling: { |
|
180 CX_DEBUG(("CxuiFakeAutoFocusControl::handleAfEvent <> Canceling")); |
|
181 // Focus position is not known after cancel |
|
182 setState(CxeAutoFocusControl::Unknown); |
|
183 break; |
|
184 } |
|
185 default: |
|
186 break; |
|
187 } // end switch |
|
188 |
|
189 } |
|
190 |
|
191 int CxuiFakeAutoFocusControl::setFakeState(CxeAutoFocusControl::State aState) |
|
192 { |
|
193 int err = KErrNone; |
|
194 setState(aState); |
|
195 return err; |
|
196 } |
|
197 |
|
198 // end of file |