178 |
178 |
179 if (status == CxeError::None) { |
179 if (status == CxeError::None) { |
180 // Use a dummy "image data item" with empty data and saved state for videos. |
180 // Use a dummy "image data item" with empty data and saved state for videos. |
181 // We just need to harvest the file and provide snapshot to Thumbnail Manager. |
181 // We just need to harvest the file and provide snapshot to Thumbnail Manager. |
182 QByteArray empty; |
182 QByteArray empty; |
183 CxeImageDataItem* item = new CxeImageDataItemSymbian(empty, filename, CxeStillImage::INVALID_ID, CxeImageDataItem::Saved); |
183 CxeImageDataItem* item = new CxeImageDataItemSymbian(empty, |
184 if(item) { |
184 filename, |
|
185 CxeStillImage::INVALID_ID, |
|
186 false, |
|
187 CxeImageDataItem::Saved); |
|
188 if (item) { |
185 save(item); |
189 save(item); |
186 } |
190 } |
187 } |
191 } |
188 CX_DEBUG_EXIT_FUNCTION(); |
192 |
189 } |
193 CX_DEBUG_EXIT_FUNCTION(); |
190 |
194 } |
191 void CxeFileSaveThreadSymbian::handleSnapshotReady(CxeError::Id status, const QPixmap& snapshot, const QString& filename) |
195 |
|
196 /*! |
|
197 * Handles snapshot event from CxeStillCaptureControl and CxeVideoCaptureControl. |
|
198 * |
|
199 * @param status Status of snapshot creation. CxeError::None if no error, otherwise contains the error code |
|
200 * @param snapshot Snapshot as QImage |
|
201 * @param filename Name of the file that the snapshot is from |
|
202 */ |
|
203 void CxeFileSaveThreadSymbian::handleSnapshotReady(CxeError::Id status, const QImage& snapshot, const QString& filename) |
192 { |
204 { |
193 CX_DEBUG_ENTER_FUNCTION(); |
205 CX_DEBUG_ENTER_FUNCTION(); |
194 CX_DEBUG(("[INFO] current thread 0x%x", QThread::currentThreadId())); |
206 CX_DEBUG(("[INFO] current thread 0x%x", QThread::currentThreadId())); |
195 CX_DEBUG(("status = %d filename = %s", status, filename.toAscii().constData())); |
207 CX_DEBUG(("status = %d filename = %s", status, filename.toAscii().constData())); |
196 |
208 |
197 if (status == CxeError::None) { |
209 if (status == CxeError::None) { |
198 // Store snapshot. |
210 // Store snapshot. |
199 if (!snapshot.isNull()) { |
211 if (!snapshot.isNull()) { |
200 // QMutexLocker handles locking and unlocking automaticly. |
212 // QMutexLocker handles locking and unlocking automaticly. |
201 QMutexLocker lock(&mSnapshotsMutex); |
213 QMutexLocker lock(&mSnapshotsMutex); |
202 |
|
203 //!@todo: Store as QImage once TNM API is fixed. |
|
204 mSnapshots.insert(filename, snapshot); |
214 mSnapshots.insert(filename, snapshot); |
205 } |
215 } |
206 } |
216 } |
207 |
217 |
208 CX_DEBUG_EXIT_FUNCTION(); |
218 CX_DEBUG_EXIT_FUNCTION(); |
209 } |
219 } |
210 |
220 |
211 void CxeFileSaveThreadSymbian::handleSnapshotReady(CxeError::Id status, const QPixmap& snapshot, int id) |
221 /*! |
|
222 * Handles snapshot event from CxeStillCaptureControl and CxeVideoCaptureControl. |
|
223 * |
|
224 * @param status Status of snapshot creation. CxeError::None if no error, otherwise contains the error code |
|
225 * @param snapshot Snapshot as QImage |
|
226 * @param id Id of the file that the snapshot is from |
|
227 */ |
|
228 void CxeFileSaveThreadSymbian::handleSnapshotReady(CxeError::Id status, const QImage& snapshot, int id) |
212 { |
229 { |
213 CX_DEBUG_ENTER_FUNCTION(); |
230 CX_DEBUG_ENTER_FUNCTION(); |
214 CX_DEBUG(("[INFO] current thread 0x%x", QThread::currentThreadId())); |
231 CX_DEBUG(("[INFO] current thread 0x%x", QThread::currentThreadId())); |
215 CX_DEBUG(("status = %d id = %d", status, id)); |
232 CX_DEBUG(("status = %d id = %d", status, id)); |
216 // Using id number as "filename" for images as filename is not available |
233 // Using id number as "filename" for images as filename is not available |
314 |
331 |
315 // If snapshot was stored using id as a "filename", replace key with real filename now, |
332 // If snapshot was stored using id as a "filename", replace key with real filename now, |
316 // so we can find the snapshot when harvesting is ready. |
333 // so we can find the snapshot when harvesting is ready. |
317 QString idString(QString::number(item->id())); |
334 QString idString(QString::number(item->id())); |
318 if (mSnapshots.contains(idString)) { |
335 if (mSnapshots.contains(idString)) { |
319 const QPixmap& snapshot(mSnapshots[idString]); |
336 QImage snapshot(mSnapshots[idString]); |
320 mSnapshots.remove(idString); |
337 mSnapshots.remove(idString); |
321 mSnapshots.insert(path, snapshot); |
338 mSnapshots.insert(path, snapshot); |
322 } |
339 } |
323 } |
340 } |
324 |
341 |
325 harvestFile(path); |
342 harvestFile(path, qobject_cast<CxeImageDataItemSymbian*>(item)->isLocationEnabled()); |
326 } |
343 } |
327 |
344 |
328 // Delete item, since we own it |
345 // Delete item, since we own it |
329 delete item; |
346 delete item; |
330 item = NULL; |
347 item = NULL; |
335 |
352 |
336 /** |
353 /** |
337 * Harvest one file. |
354 * Harvest one file. |
338 * @param filename Path of the file to be harvested. |
355 * @param filename Path of the file to be harvested. |
339 */ |
356 */ |
340 void CxeFileSaveThreadSymbian::harvestFile(const QString& filename) |
357 void CxeFileSaveThreadSymbian::harvestFile(const QString& filename, bool addLocation) |
341 { |
358 { |
342 CX_DEBUG_ENTER_FUNCTION(); |
359 CX_DEBUG_ENTER_FUNCTION(); |
343 if (mHarvesterControl) { |
360 if (mHarvesterControl) { |
344 // Synchronize snapshots container access. |
361 // Synchronize snapshots container access. |
345 QMutexLocker lock(&mSnapshotsMutex); |
362 QMutexLocker lock(&mSnapshotsMutex); |
346 |
363 |
347 // harvest file ( filename, add to album, album id ) |
364 // harvest file ( filename, add to album, album id ) |
348 CX_DEBUG(("Requesting harvesting for file: %s", filename.toAscii().constData())); |
365 CX_DEBUG(("Requesting harvesting for file: %s addLocation = %d", filename.toAscii().constData(), addLocation)); |
349 CxeError::Id status = mHarvesterControl->harvestFile(filename, false, MDS_CAPTURED_ALBUM_ID); |
366 CxeError::Id status = mHarvesterControl->harvestFile(filename, addLocation, MDS_CAPTURED_ALBUM_ID); |
350 CX_DEBUG(("Status for starting harvesting: %d", status)); |
367 CX_DEBUG(("Status for starting harvesting: %d", status)); |
351 |
368 |
352 // If there were errors, release any snapshot stored for this file. |
369 // If there were errors, release any snapshot stored for this file. |
353 // Otherwise waiting for the harvesting to complete to |
370 // Otherwise waiting for the harvesting to complete to |
354 // provide the snapshot to Thumbnail Manager. |
371 // provide the snapshot to Thumbnail Manager. |