1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
26 #include "cxesysutil.h" |
26 #include "cxesysutil.h" |
27 #include "cxesettings.h" |
27 #include "cxesettings.h" |
28 #include "cxeerror.h" |
28 #include "cxeerror.h" |
29 #include "cxeerrormappingsymbian.h" |
29 #include "cxeerrormappingsymbian.h" |
30 |
30 |
|
31 #include "OstTraceDefinitions.h" |
|
32 #ifdef OST_TRACE_COMPILER_IN_USE |
|
33 #include "cxefilenamegeneratorsymbianTraces.h" |
|
34 #endif |
|
35 |
31 |
36 |
32 using namespace Cxe; |
37 using namespace Cxe; |
33 |
38 |
34 // =========================================================================== |
39 // =========================================================================== |
35 // Local constants |
40 // Local constants |
77 : mFs(CCoeEnv::Static()->FsSession()), |
82 : mFs(CCoeEnv::Static()->FsSession()), |
78 mSettings(settings), |
83 mSettings(settings), |
79 mCurrentMode(mode) |
84 mCurrentMode(mode) |
80 { |
85 { |
81 CX_DEBUG_ENTER_FUNCTION(); |
86 CX_DEBUG_ENTER_FUNCTION(); |
|
87 OstTrace0(camerax_performance, CXEFILENAMEGENERATOR_1, "msg: e_CX_FILENAMEGENERATOR_NEW 1"); |
82 |
88 |
83 // Set default values (used in case of error retrieving values) |
89 // Set default values (used in case of error retrieving values) |
84 mCurrentMonth = ""; |
90 mCurrentMonth = ""; |
85 mMonthCounterImage = -1; |
91 mMonthCounterImage = -1; |
86 mMonthCounterVideo = -1; |
92 mMonthCounterVideo = -1; |
87 mImageCounter = 0; |
93 mImageCounter = 0; |
88 mVideoCounter = 0; |
94 mVideoCounter = 0; |
89 |
95 |
90 // Retrieve last used counter values from settings |
96 // Retrieve last used counter values from settings |
91 mSettings.get(CxeSettingIds::FNAME_MONTH_FOLDER, mCurrentMonth); |
97 mCurrentMonth = mSettings.get<QString>(CxeSettingIds::FNAME_MONTH_FOLDER, ""); |
92 mSettings.get(CxeSettingIds::FNAME_IMAGE_COUNTER, mImageCounter); |
98 mImageCounter = mSettings.get<int>(CxeSettingIds::FNAME_IMAGE_COUNTER, 0); |
93 mSettings.get(CxeSettingIds::FNAME_VIDEO_COUNTER, mVideoCounter); |
99 mVideoCounter = mSettings.get<int>(CxeSettingIds::FNAME_VIDEO_COUNTER, 0); |
94 |
100 |
|
101 OstTrace0(camerax_performance, CXEFILENAMEGENERATOR_2, "msg: e_CX_FILENAMEGENERATOR_NEW 0"); |
95 CX_DEBUG_EXIT_FUNCTION(); |
102 CX_DEBUG_EXIT_FUNCTION(); |
96 } |
103 } |
97 |
104 |
98 /** |
105 /** |
99 * Destructor |
106 * Destructor |
150 * @return error id, CxeError::None if no error. |
157 * @return error id, CxeError::None if no error. |
151 */ |
158 */ |
152 CxeError::Id CxeFilenameGeneratorSymbian::generateFilename(QString &qfName, const QString &fileExt) |
159 CxeError::Id CxeFilenameGeneratorSymbian::generateFilename(QString &qfName, const QString &fileExt) |
153 { |
160 { |
154 CX_DEBUG_ENTER_FUNCTION(); |
161 CX_DEBUG_ENTER_FUNCTION(); |
|
162 OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_GENERATENAME_1, "msg: e_CX_GENERATE_FILENAME 1"); |
155 |
163 |
156 // Make sure that the path for images/videos exists |
164 // Make sure that the path for images/videos exists |
157 QString path; |
165 QString path; |
158 int err = selectFolder(path); |
166 int err = selectFolder(path); |
159 |
167 |
351 * Returns error code if the folder can't be created. |
360 * Returns error code if the folder can't be created. |
352 */ |
361 */ |
353 int CxeFilenameGeneratorSymbian::selectFolder(QString &suggestedPath) |
362 int CxeFilenameGeneratorSymbian::selectFolder(QString &suggestedPath) |
354 { |
363 { |
355 CX_DEBUG_ENTER_FUNCTION(); |
364 CX_DEBUG_ENTER_FUNCTION(); |
|
365 OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_SELECTFOLDER_1, "msg: e_CX_SELECT_FOLDER 1"); |
356 |
366 |
357 // Compose the path string and select counter based on mode. |
367 // Compose the path string and select counter based on mode. |
358 QString basePath = "%1%2\\"; |
368 QString basePath = "%1%2\\"; |
359 int *monthCounter = &mMonthCounterImage; |
369 int *monthCounter = &mMonthCounterImage; |
360 |
370 |
426 suggestedPath = basePath; |
436 suggestedPath = basePath; |
427 break; |
437 break; |
428 } |
438 } |
429 } |
439 } |
430 |
440 |
|
441 OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_SELECTFOLDER_2, "msg: e_CX_SELECT_FOLDER 0"); |
431 CX_DEBUG_EXIT_FUNCTION(); |
442 CX_DEBUG_EXIT_FUNCTION(); |
432 |
443 |
433 // We fallback to basePath in case of unknown errors, |
444 // We fallback to basePath in case of unknown errors, |
434 // so no error will be reported here. |
445 // so no error will be reported here. |
435 return KErrNone; |
446 return KErrNone; |
442 * @return Symbian error code (internal to class) |
453 * @return Symbian error code (internal to class) |
443 */ |
454 */ |
444 int CxeFilenameGeneratorSymbian::initMonthFolders() |
455 int CxeFilenameGeneratorSymbian::initMonthFolders() |
445 { |
456 { |
446 CX_DEBUG_ENTER_FUNCTION(); |
457 CX_DEBUG_ENTER_FUNCTION(); |
|
458 OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_INITFOLDERS_1, "msg: e_CX_INIT_MONTH_FOLDER 1"); |
447 |
459 |
448 // Month folder: YYYYMM, with suffix: YYYYMMXX |
460 // Month folder: YYYYMM, with suffix: YYYYMMXX |
449 QString monthFolder = QDate::currentDate().toString("yyyyMM"); |
461 QString monthFolder = QDate::currentDate().toString("yyyyMM"); |
450 |
462 |
451 // If the month folder name is different from the last used month folder name |
463 // If the month folder name is different from the last used month folder name |
487 //! @todo: Review error handling |
499 //! @todo: Review error handling |
488 // Report error - can't continue without 'camera' and camera\YYYYMM folders |
500 // Report error - can't continue without 'camera' and camera\YYYYMM folders |
489 CX_DEBUG(("[FATAL] - Could not create month folder, error %d", status)); |
501 CX_DEBUG(("[FATAL] - Could not create month folder, error %d", status)); |
490 } |
502 } |
491 |
503 |
|
504 OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_INITFOLDERS_2, "msg: e_CX_INIT_MONTH_FOLDER 0"); |
492 CX_DEBUG_EXIT_FUNCTION(); |
505 CX_DEBUG_EXIT_FUNCTION(); |
493 return status; |
506 return status; |
494 } |
507 } |
495 |
508 |
496 /** |
509 /** |
594 * Initializes only for appropriate mode (image/video). |
607 * Initializes only for appropriate mode (image/video). |
595 */ |
608 */ |
596 CxeError::Id CxeFilenameGeneratorSymbian::init(Cxe::CameraMode mode) |
609 CxeError::Id CxeFilenameGeneratorSymbian::init(Cxe::CameraMode mode) |
597 { |
610 { |
598 CX_DEBUG_ENTER_FUNCTION(); |
611 CX_DEBUG_ENTER_FUNCTION(); |
|
612 OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_INIT_1, "msg: e_CX_FILENAMEGENERATOR_INIT 1"); |
599 |
613 |
600 mCurrentMode = mode; |
614 mCurrentMode = mode; |
601 int err = KErrNone; |
615 int err = KErrNone; |
602 bool initialized = (mode==ImageMode && !mImagesPath.isEmpty()) || |
616 bool initialized = (mode==ImageMode && !mImagesPath.isEmpty()) || |
603 (mode==VideoMode && !mVideosPath.isEmpty()); |
617 (mode==VideoMode && !mVideosPath.isEmpty()); |
618 // file names can be generated quickly when requested. |
632 // file names can be generated quickly when requested. |
619 err = initMonthFolders(); |
633 err = initMonthFolders(); |
620 } |
634 } |
621 } |
635 } |
622 |
636 |
|
637 OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_INIT_2, "msg: e_CX_FILENAMEGENERATOR_INIT 0"); |
623 CX_DEBUG_EXIT_FUNCTION(); |
638 CX_DEBUG_EXIT_FUNCTION(); |
624 return CxeErrorHandlingSymbian::map(err); |
639 return CxeErrorHandlingSymbian::map(err); |
625 } |
640 } |
626 |
641 |
627 /** |
642 /** |