filemanager/src/fmbkupenginewrapper/inc/fmbackupsettings.h
branchRCL_3
changeset 39 65326cf895ed
parent 38 491b3ed49290
child 42 f5c50b8af68c
equal deleted inserted replaced
38:491b3ed49290 39:65326cf895ed
     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  * 
       
    15  * Description:
       
    16  *      The header file of the backup seetings of file manager
       
    17  */
       
    18 #ifndef FMBACKUPSETTINGS_H
       
    19 #define FMBACKUPSETTINGS_H
       
    20 
       
    21 #include "fmbkupengine_global.h"
       
    22 
       
    23 #include <QTime>
       
    24 #include <QString>
       
    25 #include <QList>
       
    26 
       
    27 #include <hbglobal.h>
       
    28 
       
    29 class FmBkupEngine;
       
    30 
       
    31 // CLASS DECLARATION
       
    32 /**
       
    33  *  This class is used for storing backup entry which used in backup view
       
    34  *  Each row in backup view is a single entry
       
    35  *
       
    36  */
       
    37 class FmBackupEntry
       
    38 {
       
    39 public:
       
    40     /**  Backup setting type */
       
    41     enum TSettingType
       
    42     {
       
    43         ENone = 0,
       
    44         EContents,
       
    45         EScheduling,
       
    46         EWeekday,
       
    47         ETime,
       
    48         ETarget,
       
    49         EBackupdate
       
    50     };
       
    51 
       
    52 public:
       
    53     FmBackupEntry( const QString& title, const QString& tips, const TSettingType type ) :
       
    54         mTitle( title ), mTips( tips ), mType( type )
       
    55     {
       
    56     }
       
    57     ~FmBackupEntry( void )
       
    58     {
       
    59     }
       
    60 
       
    61     FmBackupEntry( const FmBackupEntry &other )
       
    62     { 
       
    63         mTitle = other.mTitle;
       
    64         mTips  = other.mTips;
       
    65         mType  = other.mType;
       
    66     }
       
    67 
       
    68     FmBackupEntry &operator =( const FmBackupEntry &other )
       
    69     {
       
    70         if( this == &other ){
       
    71             return *this;
       
    72         }
       
    73 
       
    74         mTitle = other.mTitle;
       
    75         mTips  = other.mTips;
       
    76         mType  = other.mType;
       
    77         return *this;
       
    78     } 
       
    79 
       
    80     QString title()
       
    81     {
       
    82         return mTitle;
       
    83     }
       
    84 
       
    85     QString tips()
       
    86     {
       
    87         return mTips;
       
    88     }
       
    89 
       
    90     FmBackupEntry::TSettingType type()
       
    91     {
       
    92         return mType;
       
    93     }
       
    94 
       
    95 
       
    96 private:
       
    97     /**
       
    98      * first label for item in backup view
       
    99      */
       
   100     QString mTitle;
       
   101 
       
   102     /**
       
   103      * second label for item in backup view
       
   104      */
       
   105     QString mTips;
       
   106 
       
   107     /**
       
   108      * type for item in backup view
       
   109      */
       
   110     TSettingType mType;
       
   111 };
       
   112 
       
   113 // CLASS DECLARATION
       
   114 /**
       
   115  *  This class is used for storing backup settings
       
   116  *
       
   117  */
       
   118 class FMBKUPENGINE_EXPORT FmBackupSettings
       
   119 {
       
   120 public:
       
   121     enum TFileManagerBackupContentMask
       
   122     {
       
   123         EFileManagerBackupContentAll = 0x1,
       
   124         EFileManagerBackupContentSettings = 0x2,
       
   125         EFileManagerBackupContentMessages = 0x4,
       
   126         EFileManagerBackupContentContacts = 0x8,
       
   127         EFileManagerBackupContentCalendar = 0x10,
       
   128         EFileManagerBackupContentBookmarks = 0x20,
       
   129         EFileManagerBackupContentUserFiles = 0x40,
       
   130         EFileManagerBackupContentFirst = 0x2,
       
   131         EFileManagerBackupContentLast = 0x40
       
   132     };
       
   133 
       
   134     /** Contains the possible values of KFileManagerBackupScheduling key. */
       
   135     enum TFileManagerBackupSchedule
       
   136     {
       
   137         EFileManagerBackupScheduleNever = 0,
       
   138         EFileManagerBackupScheduleDaily,
       
   139         EFileManagerBackupScheduleWeekly
       
   140     };
       
   141 
       
   142     /** Contains the possible values of KFileManagerBackupScheduling key. */
       
   143     enum TFileManagerBackupWeekday
       
   144     {
       
   145         EFileManagerBackupWeekdayMonday = 0,
       
   146         EFileManagerBackupWeekdayTuesday,
       
   147         EFileManagerBackupWeekdayWednesday,
       
   148         EFileManagerBackupWeekdayThursday,
       
   149         EFileManagerBackupWeekdayFriday,
       
   150         EFileManagerBackupWeekdaySaturday,
       
   151         EFileManagerBackupWeekdaySunday,
       
   152     };
       
   153 
       
   154 public:
       
   155     explicit FmBackupSettings( FmBkupEngine *aFmBkupEngine );
       
   156     ~FmBackupSettings( void );
       
   157 
       
   158 
       
   159    /**
       
   160      * Sets backup contents
       
   161      * @param aContent Content bitmask
       
   162      */
       
   163     void setContent( const quint32 aContent );
       
   164 
       
   165     /**
       
   166      * Sets backup scheduling
       
   167      * @param aScheduling Scheduling type
       
   168      */
       
   169     void setScheduling( const TFileManagerBackupSchedule aScheduling );
       
   170 
       
   171     /**
       
   172      * Sets backup weekday
       
   173      * @param weekday Backup weekday
       
   174      */
       
   175     void setWeekday( const TFileManagerBackupWeekday weekday );
       
   176 
       
   177     /**
       
   178      * Sets backup time
       
   179      * @param aTime Time from 00:00
       
   180      */
       
   181     void setTime( const QTime& aTime );
       
   182 
       
   183     /**
       
   184      * Sets backup target drive
       
   185      * @param aDrive Target drive (See TDriveNumber)
       
   186      */
       
   187     void setTargetDrive( const QString& aDrive );
       
   188 
       
   189     /**
       
   190      * Gets backup contents
       
   191      * @return Content bitmask
       
   192      * @see TFileManagerBackupContentMask
       
   193      */
       
   194     quint32 content() const;
       
   195 
       
   196     /**
       
   197      * Gets backup scheduling
       
   198      * @return Scheduling type
       
   199      */
       
   200     FmBackupSettings::TFileManagerBackupSchedule scheduling() const;
       
   201 
       
   202     /**
       
   203      * Gets backup weekday
       
   204      * @return Backup weekday
       
   205      */
       
   206     FmBackupSettings::TFileManagerBackupWeekday weekday() const;
       
   207 
       
   208     /**
       
   209      * Gets backup time
       
   210      * @return Backup time
       
   211      */
       
   212     const QTime& time() const;
       
   213 
       
   214     /**
       
   215      * Gets backup target drive
       
   216      * @return Backup time
       
   217      */
       
   218     QString targetDrive() const;
       
   219 
       
   220     /**
       
   221      * Gets available backup target drive
       
   222      * if targetDrive exist, return targetDrive
       
   223      * otherwise return other first available backup drive
       
   224      * @return Available backup target drive, empty QString for null
       
   225      */
       
   226     QString availableTargetDrive() const;
       
   227     
       
   228     /**
       
   229      * Loads saved backup settings
       
   230      */
       
   231     void load();
       
   232 
       
   233     /**
       
   234      * Saves backup settings
       
   235      */
       
   236     void save();
       
   237 
       
   238     /**
       
   239      * get backup entry list
       
   240      * @return backup entry list
       
   241      */
       
   242     QList< FmBackupEntry* > backupEntryList();
       
   243 
       
   244     /**
       
   245      * Gets String from single content bit
       
   246      * @param aContent content bit
       
   247      * @return Textid
       
   248      */
       
   249     static QString contentToString( const quint32 content );
       
   250 
       
   251     
       
   252     /**
       
   253      * Gets String from weekday
       
   254      * @param weekday 
       
   255      * @return string 
       
   256      */
       
   257     static QString weekdayToString( const TFileManagerBackupWeekday weekday );
       
   258 
       
   259     /**
       
   260      * Gets String from scheduling
       
   261      * @param scheduling
       
   262      * @return string 
       
   263      */
       
   264     QString schedulingToString( const TFileManagerBackupSchedule scheduling );
       
   265     /**
       
   266      * Gets String from targetDrive
       
   267      * @param targetDrive drive name string
       
   268      * @return string
       
   269      */
       
   270     QString targetDriveToString( const QString& targetDrive );
       
   271     
       
   272     /**
       
   273      * Updates the backup date
       
   274      */
       
   275     void updateBackupDate();
       
   276 private:
       
   277     /**
       
   278      * Gets the count of contents selected
       
   279      */
       
   280     int contentsSelected() const;
       
   281 
       
   282     FmBackupEntry* CreateEntry( const QString& title, const QString& tips, const FmBackupEntry::TSettingType type );
       
   283 
       
   284     ///////////////////////////////////////////////////////////////////////
       
   285     /**
       
   286      * Creates backup setting entry from all contents bit
       
   287      */
       
   288     FmBackupEntry* createContentsEntry();
       
   289 
       
   290     /**
       
   291      * Creates backup setting entry from scheduling
       
   292      */
       
   293     FmBackupEntry* createSchedulingEntry();
       
   294 
       
   295     /**
       
   296      * Creates backup setting entry from weekday
       
   297      */
       
   298     FmBackupEntry* createWeekdayEntry();
       
   299 
       
   300     /**
       
   301      * Creates backup setting entry from time
       
   302      */
       
   303     FmBackupEntry* createTimeEntry();
       
   304 
       
   305     /**
       
   306      * Creates backup setting entry from time
       
   307      */
       
   308     FmBackupEntry* createTargetDriveEntry();
       
   309 
       
   310     /**
       
   311      * Creates backup date entry
       
   312      */
       
   313     FmBackupEntry* createBackupDateEntry();
       
   314     
       
   315     void refreshList();
       
   316     void resetAndDestoryBackupEntry();
       
   317 private:
       
   318    /**
       
   319      * Content bitmask
       
   320      * @see TFileManagerBackupContentMask
       
   321      */
       
   322     quint32 mContent;
       
   323 
       
   324     /**
       
   325      * Scheduling type
       
   326      */
       
   327     TFileManagerBackupSchedule mScheduling;
       
   328 
       
   329     /**
       
   330      * Scheduled backup weekday
       
   331      */
       
   332     TFileManagerBackupWeekday mWeekday;
       
   333 
       
   334     /**
       
   335      * Scheduled backup time from 00:00
       
   336      */
       
   337     QTime mTime;
       
   338 
       
   339     /**
       
   340      * Backup target drive
       
   341      */
       
   342     QString mTargetDrive;
       
   343 
       
   344     /**
       
   345      * Backup date
       
   346      */
       
   347     QDate mDate;
       
   348     
       
   349     /**
       
   350      * Backup setting list items
       
   351      */
       
   352     QList< FmBackupEntry* > mBackupEntryList;
       
   353     
       
   354     
       
   355     FmBkupEngine *mBkupEngine;
       
   356 };
       
   357 
       
   358 #endif //FMBACKUPSETTINGS_H