13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 #include <QObject> // For Q_OS_SYMBIAN define |
|
19 #if defined(Q_OS_SYMBIAN) |
|
20 #include <locationtrailpskeys.h> |
|
21 #endif |
|
22 |
18 #include "cxutils.h" |
23 #include "cxutils.h" |
19 #include "cxestate.h" |
24 #include "cxestate.h" |
20 #include "cxesettings.h" |
25 #include "cxesettings.h" |
21 #include "cxenamespace.h" |
26 #include "cxenamespace.h" |
22 #include "cxestillcapturecontrol.h" |
27 #include "cxestillcapturecontrol.h" |
23 #include "cxevideocapturecontrol.h" |
28 #include "cxevideocapturecontrol.h" |
24 #include "cxegeotaggingtrailprivate.h" |
29 #include "cxegeotaggingtrailprivate.h" |
25 |
30 |
26 #include <locationtrailpskeys.h> |
31 #include "OstTraceDefinitions.h" |
27 |
32 #ifdef OST_TRACE_COMPILER_IN_USE |
|
33 #include "cxegeotaggingtrailprivateTraces.h" |
|
34 #endif |
28 |
35 |
29 |
36 |
30 namespace |
37 namespace |
31 { |
38 { |
32 // in milliseconds |
39 // in milliseconds |
35 |
42 |
36 |
43 |
37 /*! |
44 /*! |
38 * Constructor |
45 * Constructor |
39 */ |
46 */ |
40 CxeGeoTaggingTrailPrivate::CxeGeoTaggingTrailPrivate(CxeStillCaptureControl &stillControl, |
47 CxeGeoTaggingTrailPrivate::CxeGeoTaggingTrailPrivate(CxeStillCaptureControl &stillControl, |
41 CxeVideoCaptureControl &videoControl, |
48 CxeVideoCaptureControl &videoControl, |
42 CxeSettings &settings) |
49 CxeSettings &settings) |
43 : CxeStateMachine("CxeGeoTaggingTrailPrivate"), |
50 : CxeStateMachine("CxeGeoTaggingTrailPrivate"), |
44 mStillCaptureControl(stillControl), |
51 mStillCaptureControl(stillControl), |
45 mVideoCaptureControl(videoControl), |
52 mVideoCaptureControl(videoControl), |
54 |
61 |
55 #if defined(Q_OS_SYMBIAN) |
62 #if defined(Q_OS_SYMBIAN) |
56 |
63 |
57 QVariant locationTrailState; |
64 QVariant locationTrailState; |
58 // Get initial location trail state. |
65 // Get initial location trail state. |
59 mSettings.get(KPSUidLocationTrail.iUid, KLocationTrailState, |
66 mSettings.get(KPSUidLocationTrail.iUid, KLocationTrailState, |
60 Cxe::PublishAndSubscribe, locationTrailState); |
67 Cxe::PublishAndSubscribe, locationTrailState); |
61 |
68 |
62 connect(&mSettings, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant)), |
69 connect(&mSettings, SIGNAL(settingValueChanged(long int, unsigned long int, QVariant)), |
63 this, SLOT(handleGeoTaggingPropertyEvent(long int, unsigned long int, QVariant))); |
70 this, SLOT(handleGeoTaggingPropertyEvent(long int, unsigned long int, QVariant))); |
64 |
71 |
65 #endif |
72 #endif |
66 |
73 |
67 connect(&mSettings, SIGNAL(settingValueChanged(const QString&,QVariant)), |
74 connect(&mSettings, SIGNAL(settingValueChanged(const QString&,QVariant)), |
68 this, SLOT(handleSettingValueChanged(const QString&,QVariant))); |
75 this, SLOT(handleSettingValueChanged(const QString&,QVariant))); |
69 |
76 |
70 connect(&mStopLocationTrailTimer, SIGNAL(timeout()), |
77 connect(&mStopLocationTrailTimer, SIGNAL(timeout()), |
71 this, SLOT(timeout()), Qt::UniqueConnection); |
78 this, SLOT(timeout()), Qt::UniqueConnection); |
72 |
79 |
73 CX_DEBUG_EXIT_FUNCTION(); |
80 CX_DEBUG_EXIT_FUNCTION(); |
74 } |
81 } |
75 |
82 |
76 /*! |
83 /*! |
77 * Destructor |
84 * Destructor |
91 * Start location trail. |
98 * Start location trail. |
92 */ |
99 */ |
93 void CxeGeoTaggingTrailPrivate::start() |
100 void CxeGeoTaggingTrailPrivate::start() |
94 { |
101 { |
95 CX_DEBUG_ENTER_FUNCTION(); |
102 CX_DEBUG_ENTER_FUNCTION(); |
|
103 OstTrace0(camerax_performance, CXEGEOTAGGINGTRAIL_START_1, "msg: e_CX_START_GEOTAGGING 1"); |
96 |
104 |
97 #if defined(Q_OS_SYMBIAN) |
105 #if defined(Q_OS_SYMBIAN) |
98 |
106 |
99 int err = KErrNone; |
107 int err = KErrNone; |
100 int settingValue = Cxe::GeoTaggingOff; |
108 int settingValue = Cxe::GeoTaggingOff; |
101 mSettings.get(CxeSettingIds::GEOTAGGING, settingValue); |
109 mSettings.get(CxeSettingIds::GEOTAGGING, settingValue); |
102 |
110 |
103 if (settingValue == Cxe::GeoTaggingOn) { |
111 if (settingValue == Cxe::GeoTaggingOn) { |
104 // geotagging setting is ON, trying to start location trail |
112 // geotagging setting is ON, trying to start location trail |
105 if (state() == CxeGeoTaggingTrail::NotConnected) { |
113 if (state() == CxeGeoTaggingTrail::NotConnected) { |
106 err = mLocationTrail.Connect(); |
114 err = mLocationTrail.Connect(); |
107 if (!err) { |
115 if (!err) { |
108 CX_DEBUG(("CxeGeoTaggingTrail <> location trail connected")); |
116 CX_DEBUG(("CxeGeoTaggingTrail <> location trail connected")); |
109 setState(CxeGeoTaggingTrail::Connected); |
117 setState(CxeGeoTaggingTrail::Connected); |
110 } |
118 } |
111 } |
119 } |
112 |
120 |
113 if (state() == CxeGeoTaggingTrail::Connected && !err) { |
121 if (state() == CxeGeoTaggingTrail::Connected && !err) { |
114 err = mLocationTrail.StartLocationTrail(RLocationTrail::ECaptureAll); |
122 err = mLocationTrail.StartLocationTrail(RLocationTrail::ECaptureAll); |
115 if (!err) { |
123 if (!err) { |
116 CX_DEBUG(("CxeGeoTaggingTrail <> starting location trail")); |
124 CX_DEBUG(("CxeGeoTaggingTrail <> starting location trail")); |
117 mStopLocationTrailTimer.stop(); // stop location timer. |
125 mStopLocationTrailTimer.stop(); // stop location timer. |
120 } |
128 } |
121 |
129 |
122 if (err) { |
130 if (err) { |
123 CX_DEBUG(("CxeGeoTaggingTrailPrivate::start <> FAILED: error = %d ", err)); |
131 CX_DEBUG(("CxeGeoTaggingTrailPrivate::start <> FAILED: error = %d ", err)); |
124 stop(true); |
132 stop(true); |
125 } |
133 } |
126 } else { |
134 } else { |
127 // geotagging setting off, do nothing. |
135 // geotagging setting off, do nothing. |
128 CX_DEBUG(("CxeGeoTaggingTrail <> start -- Geotagging setting OFF, do nothing..")); |
136 CX_DEBUG(("CxeGeoTaggingTrail <> start -- Geotagging setting OFF, do nothing..")); |
129 } |
137 } |
130 |
138 |
131 #endif |
139 #endif |
|
140 OstTrace0(camerax_performance, CXEGEOTAGGINGTRAIL_START_2, "msg: e_CX_START_GEOTAGGING 0"); |
132 |
141 |
133 CX_DEBUG_EXIT_FUNCTION(); |
142 CX_DEBUG_EXIT_FUNCTION(); |
134 } |
143 } |
135 |
144 |
136 |
145 |
141 * @ param closeSession, indicates if we are willing to close the location utility session. |
150 * @ param closeSession, indicates if we are willing to close the location utility session. |
142 */ |
151 */ |
143 void CxeGeoTaggingTrailPrivate::stop(bool closeSession) |
152 void CxeGeoTaggingTrailPrivate::stop(bool closeSession) |
144 { |
153 { |
145 CX_DEBUG_ENTER_FUNCTION(); |
154 CX_DEBUG_ENTER_FUNCTION(); |
|
155 OstTrace0(camerax_performance, CXEGEOTAGGINGTRAIL_STOP_1, "msg: e_CX_STOP_GEOTAGGING 1"); |
146 |
156 |
147 #if defined(Q_OS_SYMBIAN) |
157 #if defined(Q_OS_SYMBIAN) |
148 |
158 |
149 bool ok2StopTrail = canStopTrail(); |
159 bool ok2StopTrail = canStopTrail(); |
150 |
160 |
156 // stop location trail timer. |
166 // stop location trail timer. |
157 mStopLocationTrailTimer.stop(); |
167 mStopLocationTrailTimer.stop(); |
158 mLocationTrail.StopLocationTrail(); |
168 mLocationTrail.StopLocationTrail(); |
159 setState(CxeGeoTaggingTrail::Connected); |
169 setState(CxeGeoTaggingTrail::Connected); |
160 } |
170 } |
161 |
171 |
162 if (closeSession && state() == CxeGeoTaggingTrail::Connected) { |
172 if (closeSession && state() == CxeGeoTaggingTrail::Connected) { |
163 CX_DEBUG(("CxeGeoTaggingTrailPrivate <> disconnect location trail utility")); |
173 CX_DEBUG(("CxeGeoTaggingTrailPrivate <> disconnect location trail utility")); |
164 mLocationTrail.Close(); |
174 mLocationTrail.Close(); |
165 setState(CxeGeoTaggingTrail::NotConnected); |
175 setState(CxeGeoTaggingTrail::NotConnected); |
166 } |
176 } |
185 */ |
195 */ |
186 bool CxeGeoTaggingTrailPrivate::canStopTrail() const |
196 bool CxeGeoTaggingTrailPrivate::canStopTrail() const |
187 { |
197 { |
188 // checking still capture control states |
198 // checking still capture control states |
189 bool ok = mStillCaptureControl.state() != CxeStillCaptureControl::Capturing; |
199 bool ok = mStillCaptureControl.state() != CxeStillCaptureControl::Capturing; |
190 |
200 |
191 // Still side OK, checking video capture control states |
201 // Still side OK, checking video capture control states |
192 if (ok) { |
202 if (ok) { |
193 ok = (mVideoCaptureControl.state() != CxeVideoCaptureControl::Recording && |
203 ok = (mVideoCaptureControl.state() != CxeVideoCaptureControl::Recording && |
194 mVideoCaptureControl.state() != CxeVideoCaptureControl::Paused && |
204 mVideoCaptureControl.state() != CxeVideoCaptureControl::Paused && |
195 mVideoCaptureControl.state() != CxeVideoCaptureControl::Stopping); |
205 mVideoCaptureControl.state() != CxeVideoCaptureControl::Stopping); |
205 * stopping of location trail. |
215 * stopping of location trail. |
206 */ |
216 */ |
207 void CxeGeoTaggingTrailPrivate::timeout() |
217 void CxeGeoTaggingTrailPrivate::timeout() |
208 { |
218 { |
209 CX_DEBUG_ENTER_FUNCTION(); |
219 CX_DEBUG_ENTER_FUNCTION(); |
210 |
220 |
211 // stop the pending location trail utility |
221 // stop the pending location trail utility |
212 stop(mPendingStopTrailSession); |
222 stop(mPendingStopTrailSession); |
213 |
223 |
214 CX_DEBUG_EXIT_FUNCTION(); |
224 CX_DEBUG_EXIT_FUNCTION(); |
215 } |
225 } |
216 |
226 |
217 |
227 |
218 |
228 |
222 * Check if the geotagging setting has changed. |
232 * Check if the geotagging setting has changed. |
223 */ |
233 */ |
224 void CxeGeoTaggingTrailPrivate::handleSettingValueChanged(const QString& settingId, QVariant newValue) |
234 void CxeGeoTaggingTrailPrivate::handleSettingValueChanged(const QString& settingId, QVariant newValue) |
225 { |
235 { |
226 CX_DEBUG_ENTER_FUNCTION(); |
236 CX_DEBUG_ENTER_FUNCTION(); |
227 |
237 |
228 if (settingId == CxeSettingIds::GEOTAGGING) { |
238 if (settingId == CxeSettingIds::GEOTAGGING) { |
229 if (newValue.toInt() == Cxe::GeoTaggingOn) { |
239 if (newValue.toInt() == Cxe::GeoTaggingOn) { |
230 // setting is turned ON, start location trail |
240 // setting is turned ON, start location trail |
231 start(); |
241 start(); |
232 } else { |
242 } else { |
257 #if defined(Q_OS_SYMBIAN) |
267 #if defined(Q_OS_SYMBIAN) |
258 |
268 |
259 if (uid == KPSUidLocationTrail.iUid && key == KLocationTrailState) { |
269 if (uid == KPSUidLocationTrail.iUid && key == KLocationTrailState) { |
260 CX_DEBUG(("Location trail: new state = %d ", value.toInt())); |
270 CX_DEBUG(("Location trail: new state = %d ", value.toInt())); |
261 |
271 |
262 RLocationTrail::TTrailState newState = |
272 RLocationTrail::TTrailState newState = |
263 static_cast<RLocationTrail::TTrailState>(value.toInt()); |
273 static_cast<RLocationTrail::TTrailState>(value.toInt()); |
264 |
274 |
265 if (newState == RLocationTrail::ETrailStarted) { |
275 if (newState == RLocationTrail::ETrailStarted) { |
266 CX_DEBUG(("CxeGeoTaggingTrail <> location trail started, data available.")); |
276 CX_DEBUG(("CxeGeoTaggingTrail <> location trail started, data available.")); |
267 setState(CxeGeoTaggingTrail::DataAvailable); |
277 setState(CxeGeoTaggingTrail::DataAvailable); |
291 * slot called when state is changed. |
301 * slot called when state is changed. |
292 */ |
302 */ |
293 void CxeGeoTaggingTrailPrivate::handleStateChanged(int newStateId, CxeError::Id error) |
303 void CxeGeoTaggingTrailPrivate::handleStateChanged(int newStateId, CxeError::Id error) |
294 { |
304 { |
295 emit stateChanged(static_cast<CxeGeoTaggingTrail::State> (newStateId), error); |
305 emit stateChanged(static_cast<CxeGeoTaggingTrail::State> (newStateId), error); |
296 |
306 |
297 } |
307 } |
298 |
308 |
299 |
309 |
300 /*! |
310 /*! |
301 * Initialize states for geotaggingtrail |
311 * Initialize states for geotaggingtrail |
302 */ |
312 */ |
303 void CxeGeoTaggingTrailPrivate::initializeStates() |
313 void CxeGeoTaggingTrailPrivate::initializeStates() |
304 { |
314 { |
305 // addState( id, name, allowed next states ) |
315 // addState( id, name, allowed next states ) |
306 addState(new CxeState(CxeGeoTaggingTrail::NotConnected, "NotConnected", CxeGeoTaggingTrail::Connected)); |
316 addState(new CxeState(CxeGeoTaggingTrail::NotConnected, "NotConnected", CxeGeoTaggingTrail::Connected)); |
307 |
317 |
308 addState(new CxeState(CxeGeoTaggingTrail::Connected, "Connected", CxeGeoTaggingTrail::TrailStarted | |
318 addState(new CxeState(CxeGeoTaggingTrail::Connected, "Connected", CxeGeoTaggingTrail::TrailStarted | |
309 CxeGeoTaggingTrail::NotConnected)); |
319 CxeGeoTaggingTrail::NotConnected)); |
310 |
320 |
311 addState(new CxeState(CxeGeoTaggingTrail::TrailStarted, "TrailStarted", CxeGeoTaggingTrail::DataAvailable | |
321 addState(new CxeState(CxeGeoTaggingTrail::TrailStarted, "TrailStarted", CxeGeoTaggingTrail::DataAvailable | |
312 CxeGeoTaggingTrail::Connected | |
322 CxeGeoTaggingTrail::Connected | |
313 CxeGeoTaggingTrail::NotConnected)); |
323 CxeGeoTaggingTrail::NotConnected)); |
314 |
324 |
315 addState(new CxeState(CxeGeoTaggingTrail::DataAvailable, "DataAvailable", CxeGeoTaggingTrail::Connected | |
325 addState(new CxeState(CxeGeoTaggingTrail::DataAvailable, "DataAvailable", CxeGeoTaggingTrail::Connected | |
316 CxeGeoTaggingTrail::NotConnected)); |
326 CxeGeoTaggingTrail::NotConnected)); |
317 |
327 |
318 |
328 |
319 setInitialState(CxeGeoTaggingTrail::NotConnected); |
329 setInitialState(CxeGeoTaggingTrail::NotConnected); |
320 } |
330 } |
321 |
331 |
322 // end of file |
332 // end of file |