camerauis/cameraxui/cxengine/src/cxefilenamegeneratorsymbian.cpp
changeset 43 0e652f8f1fbd
parent 19 d9aefe59d544
child 45 24fd82631616
equal deleted inserted replaced
28:3075d9b614e6 43:0e652f8f1fbd
    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
    46 const char CHAR_OFFSET = 'A';
    51 const char CHAR_OFFSET = 'A';
    47 const char DIGIT_OFFSET = '0';
    52 const char DIGIT_OFFSET = '0';
    48 const char MAX_CHAR = 'Z';
    53 const char MAX_CHAR = 'Z';
    49 
    54 
    50 const TInt64 KMinRequiredSpaceImage = 2000000;
    55 const TInt64 KMinRequiredSpaceImage = 2000000;
    51 const TInt64 KMinRequiredSpaceVideo = 4000000;
    56 
       
    57 // Whether there's enough space for video or not is handled lower in the SW stack
       
    58 // so this is set to 0 to fix an error
       
    59 const TInt64 KMinRequiredSpaceVideo = 0;
    52 
    60 
    53 
    61 
    54 
    62 
    55 // ===========================================================================
    63 // ===========================================================================
    56 // Local functions
    64 // Local functions
    74        : mFs(CCoeEnv::Static()->FsSession()),
    82        : mFs(CCoeEnv::Static()->FsSession()),
    75          mSettings(settings),
    83          mSettings(settings),
    76          mCurrentMode(mode)
    84          mCurrentMode(mode)
    77 {
    85 {
    78     CX_DEBUG_ENTER_FUNCTION();
    86     CX_DEBUG_ENTER_FUNCTION();
       
    87     OstTrace0(camerax_performance, CXEFILENAMEGENERATOR_1, "msg: e_CX_FILENAMEGENERATOR_NEW 1");
    79 
    88 
    80     // Set default values (used in case of error retrieving values)
    89     // Set default values (used in case of error retrieving values)
    81     mCurrentMonth = "";
    90     mCurrentMonth = "";
    82     mMonthCounterImage = -1;
    91     mMonthCounterImage = -1;
    83     mMonthCounterVideo = -1;
    92     mMonthCounterVideo = -1;
    87     // Retrieve last used counter values from settings
    96     // Retrieve last used counter values from settings
    88     mSettings.get(CxeSettingIds::FNAME_MONTH_FOLDER, mCurrentMonth);
    97     mSettings.get(CxeSettingIds::FNAME_MONTH_FOLDER, mCurrentMonth);
    89     mSettings.get(CxeSettingIds::FNAME_IMAGE_COUNTER, mImageCounter);
    98     mSettings.get(CxeSettingIds::FNAME_IMAGE_COUNTER, mImageCounter);
    90     mSettings.get(CxeSettingIds::FNAME_VIDEO_COUNTER, mVideoCounter);
    99     mSettings.get(CxeSettingIds::FNAME_VIDEO_COUNTER, mVideoCounter);
    91 
   100 
       
   101     OstTrace0(camerax_performance, CXEFILENAMEGENERATOR_2, "msg: e_CX_FILENAMEGENERATOR_NEW 0");
    92     CX_DEBUG_EXIT_FUNCTION();
   102     CX_DEBUG_EXIT_FUNCTION();
    93 }
   103 }
    94 
   104 
    95 /**
   105 /**
    96  * Destructor
   106  * Destructor
   147  * @return  error id, CxeError::None if no error.
   157  * @return  error id, CxeError::None if no error.
   148  */
   158  */
   149 CxeError::Id CxeFilenameGeneratorSymbian::generateFilename(QString &qfName, const QString &fileExt)
   159 CxeError::Id CxeFilenameGeneratorSymbian::generateFilename(QString &qfName, const QString &fileExt)
   150 {
   160 {
   151     CX_DEBUG_ENTER_FUNCTION();
   161     CX_DEBUG_ENTER_FUNCTION();
       
   162     OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_GENERATENAME_1, "msg: e_CX_GENERATE_FILENAME 1");
   152 
   163 
   153     // Make sure that the path for images/videos exists
   164     // Make sure that the path for images/videos exists
   154     QString path;
   165     QString path;
   155     int err = selectFolder(path);
   166     int err = selectFolder(path);
   156 
   167 
   162         if (!err)  {
   173         if (!err)  {
   163             qfName = path + fileName;
   174             qfName = path + fileName;
   164         }
   175         }
   165     }
   176     }
   166 
   177 
       
   178     OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_GENERATENAME_2, "msg: e_CX_GENERATE_FILENAME 0");
   167     CX_DEBUG_EXIT_FUNCTION();
   179     CX_DEBUG_EXIT_FUNCTION();
   168     return CxeErrorHandlingSymbian::map(err);
   180     return CxeErrorHandlingSymbian::map(err);
   169 }
   181 }
   170 
   182 
   171 /**
   183 /**
   348  * Returns error code if the folder can't be created.
   360  * Returns error code if the folder can't be created.
   349  */
   361  */
   350 int CxeFilenameGeneratorSymbian::selectFolder(QString &suggestedPath)
   362 int CxeFilenameGeneratorSymbian::selectFolder(QString &suggestedPath)
   351 {
   363 {
   352     CX_DEBUG_ENTER_FUNCTION();
   364     CX_DEBUG_ENTER_FUNCTION();
       
   365     OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_SELECTFOLDER_1, "msg: e_CX_SELECT_FOLDER 1");
   353 
   366 
   354     // Compose the path string and select counter based on mode.
   367     // Compose the path string and select counter based on mode.
   355     QString basePath = "%1%2\\";
   368     QString basePath = "%1%2\\";
   356     int *monthCounter = &mMonthCounterImage;
   369     int *monthCounter = &mMonthCounterImage;
   357 
   370 
   423             suggestedPath = basePath;
   436             suggestedPath = basePath;
   424             break;
   437             break;
   425         }
   438         }
   426     }
   439     }
   427 
   440 
       
   441     OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_SELECTFOLDER_2, "msg: e_CX_SELECT_FOLDER 0");
   428     CX_DEBUG_EXIT_FUNCTION();
   442     CX_DEBUG_EXIT_FUNCTION();
   429 
   443 
   430     // We fallback to basePath in case of unknown errors,
   444     // We fallback to basePath in case of unknown errors,
   431     // so no error will be reported here.
   445     // so no error will be reported here.
   432     return KErrNone;
   446     return KErrNone;
   439  * @return Symbian error code (internal to class)
   453  * @return Symbian error code (internal to class)
   440  */
   454  */
   441 int CxeFilenameGeneratorSymbian::initMonthFolders()
   455 int CxeFilenameGeneratorSymbian::initMonthFolders()
   442 {
   456 {
   443     CX_DEBUG_ENTER_FUNCTION();
   457     CX_DEBUG_ENTER_FUNCTION();
       
   458     OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_INITFOLDERS_1, "msg: e_CX_INIT_MONTH_FOLDER 1");
   444 
   459 
   445     // Month folder: YYYYMM, with suffix: YYYYMMXX
   460     // Month folder: YYYYMM, with suffix: YYYYMMXX
   446     QString monthFolder = QDate::currentDate().toString("yyyyMM");
   461     QString monthFolder = QDate::currentDate().toString("yyyyMM");
   447 
   462 
   448     // 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
   484         //! @todo: Review error handling
   499         //! @todo: Review error handling
   485         // Report error - can't continue without 'camera' and camera\YYYYMM folders
   500         // Report error - can't continue without 'camera' and camera\YYYYMM folders
   486         CX_DEBUG(("[FATAL] - Could not create month folder, error %d", status));
   501         CX_DEBUG(("[FATAL] - Could not create month folder, error %d", status));
   487     }
   502     }
   488 
   503 
       
   504     OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_INITFOLDERS_2, "msg: e_CX_INIT_MONTH_FOLDER 0");
   489     CX_DEBUG_EXIT_FUNCTION();
   505     CX_DEBUG_EXIT_FUNCTION();
   490     return status;
   506     return status;
   491 }
   507 }
   492 
   508 
   493 /**
   509 /**
   591  * Initializes only for appropriate mode (image/video).
   607  * Initializes only for appropriate mode (image/video).
   592  */
   608  */
   593 CxeError::Id CxeFilenameGeneratorSymbian::init(Cxe::CameraMode mode)
   609 CxeError::Id CxeFilenameGeneratorSymbian::init(Cxe::CameraMode mode)
   594 {
   610 {
   595     CX_DEBUG_ENTER_FUNCTION();
   611     CX_DEBUG_ENTER_FUNCTION();
       
   612     OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_INIT_1, "msg: e_CX_FILENAMEGENERATOR_INIT 1");
   596 
   613 
   597     mCurrentMode = mode;
   614     mCurrentMode = mode;
   598     int err = KErrNone;
   615     int err = KErrNone;
   599     bool initialized = (mode==ImageMode && !mImagesPath.isEmpty()) ||
   616     bool initialized = (mode==ImageMode && !mImagesPath.isEmpty()) ||
   600                        (mode==VideoMode && !mVideosPath.isEmpty());
   617                        (mode==VideoMode && !mVideosPath.isEmpty());
   615             // file names can be generated quickly when requested.
   632             // file names can be generated quickly when requested.
   616             err = initMonthFolders();
   633             err = initMonthFolders();
   617         }
   634         }
   618     }
   635     }
   619 
   636 
       
   637     OstTrace0(camerax_performance, CXEFILENAMEGENERATORSYMBIAN_INIT_2, "msg: e_CX_FILENAMEGENERATOR_INIT 0");
   620     CX_DEBUG_EXIT_FUNCTION();
   638     CX_DEBUG_EXIT_FUNCTION();
   621     return CxeErrorHandlingSymbian::map(err);
   639     return CxeErrorHandlingSymbian::map(err);
   622 }
   640 }
   623 
   641 
   624 /**
   642 /**