qtinternetradio/irqfavoritesdb/inc/irqfavoritesdb.h
changeset 3 ee64f059b8e1
parent 0 09774dfdd46b
child 8 3b03c28289e6
equal deleted inserted replaced
2:2e1adbfc62af 3:ee64f059b8e1
    16 */
    16 */
    17 #ifndef IRQFAVORITESDB_H
    17 #ifndef IRQFAVORITESDB_H
    18 #define IRQFAVORITESDB_H
    18 #define IRQFAVORITESDB_H
    19 
    19 
    20 #include <QObject>
    20 #include <QObject>
    21 #include <pspresetobserver.h> 
       
    22 
    21 
    23 class CIRFavoritesDb;
    22 #include "irqfavoritesdbexporter.h"
       
    23 
    24 class IRQPreset;
    24 class IRQPreset;
       
    25 class IRQFavoritesDBPrivate;
    25 
    26 
    26 class IRQFavoritesDB : public QObject, public MPSPresetObserver
    27 class IRQFAVORITES_DLL_EXPORT IRQFavoritesDB : public QObject
    27 {
    28 {
    28 Q_OBJECT
    29 Q_OBJECT
    29 public:
    30 public:
       
    31     enum PSReason
       
    32     {
       
    33         PSCreated,
       
    34         PSDeleted,
       
    35         PSModified
       
    36     };
       
    37     
       
    38 public:
    30 
    39 
    31     IMPORT_C IRQFavoritesDB();
    40     IRQFavoritesDB();
    32 
    41 
    33     ~IRQFavoritesDB();
    42     ~IRQFavoritesDB();
    34 
    43 
    35     /* add a preset 
    44     /* add a preset 
    36      * @param IRQPreset& the isds preset,
    45      * @param IRQPreset& the isds preset,
    37      * @return  errcode
    46      * @return  errcode
    38      */
    47      */
    39     IMPORT_C int addPreset(const IRQPreset& aPreset);
    48     int addPreset(const IRQPreset& aPreset);
    40 
    49 
    41     /* add a preset manually
    50     /* add a preset manually
    42      * @return  errcode
    51      * @return  errcode
    43      * @param 
    52      * @param 
    44      */
    53      */
    45     IMPORT_C int addPreset(const QString& aName, const QString& aURL);
    54     int addPreset(const QString& aName, const QString& aURL);
    46 
    55 
    47     /* get a preset uniq id
    56     /* get a preset uniq id
    48      * @return 
    57      * @return 
    49      * @param
    58      * @param
    50      */
    59      */
    51     IMPORT_C int getUniqId(int aNum);
    60     int getUniqId(int aNum) const;
       
    61     
    52     /* delete a preset by uniq id
    62     /* delete a preset by uniq id
    53      * @return errcode
    63      * @return errcode
    54      * @param
    64      * @param
    55      */
    65      */
    56     IMPORT_C int deletePreset(int aUniqId);
    66     int deletePreset(int aUniqId);
       
    67     
    57     /* search a preset by uniqpresetId / isdspresetid
    68     /* search a preset by uniqpresetId / isdspresetid
    58      * warning: the function needs further checking
    69      * warning: the function needs further checking
    59      *  @return errcode
    70      *  @return errcode
    60      */
    71      */
    61     IMPORT_C int searchPreset(int aUniqPresetId, int aIsdsPresetId);
    72     int searchPreset(int aUniqPresetId, int aIsdsPresetId);
    62 
    73 
    63     /* get the previouse preset index in the internal list
    74     /* get the previouse preset index in the internal list
    64      * @return the index
    75      * @return the index
    65      */
    76      */
    66     IMPORT_C int getPreviousPreset(int aIndex);
    77     int getPreviousPreset(int aIndex);
    67 
    78 
    68     /* get the next preset index
    79     /* get the next preset index
    69      * @return the index
    80      * @return the index
    70      */
    81      */
    71     IMPORT_C int getNextPreset(int aIndex); 
    82     int getNextPreset(int aIndex); 
    72 
    83 
    73     /* replace with new preset
    84     /* replace with new preset
    74      * @return errcode 
    85      * @return errcode 
    75      */
    86      */
    76     IMPORT_C int replacePreset(const IRQPreset& aNewPreset);
    87     int replacePreset(const IRQPreset& aNewPreset);
    77 
    88 
    78     /* @return errcode
    89     /* @return errcode
    79      */
    90      */
    80     IMPORT_C int replaceUserDefinedPreset(const IRQPreset& aNewPreset);
    91     int replaceUserDefinedPreset(const IRQPreset& aNewPreset);
    81 
    92 
    82     /* change the preset type to user defined
    93     /* change the preset type to user defined
    83      * @return errcode
    94      * @return errcode
    84      */
    95      */
    85     IMPORT_C int makePresetUserDefined(int aChannelId,
    96     int makePresetUserDefined(int aChannelId, int aUserDefinedChannelId);
    86             int aUserDefinedChannelId);
       
    87 
    97 
    88     /* get the empty preset left count
    98     /* get the empty preset left count
    89      * @return the count of empty presets left 
    99      * @return the count of empty presets left 
    90      */
   100      */
    91     IMPORT_C int emptyPresetCount() const;
   101     int emptyPresetCount() const;
    92 
   102 
    93     /* get the max preset count supported now
   103     /* get the max preset count supported now
    94      * @return errcode 
   104      * @return errcode 
    95      */
   105      */
    96     IMPORT_C int maxPresetCount();
   106     int maxPresetCount();
    97 
   107 
    98     /* the interface is not used currently.
   108     /* the interface is not used currently.
    99      **/
   109      **/
   100     IMPORT_C void setMoveStatus(bool aStatus);
   110     void setMoveStatus(bool aStatus);
   101 
   111 
   102     /* the interface is not used currently 
   112     /* the interface is not used currently 
   103      */
   113      */
   104     IMPORT_C bool getMoveStatus();
   114     bool getMoveStatus();
   105 
   115 
   106     /* for CIRPreset is just an interface so we can wrapper it into the IRQPreset.
   116     /* for CIRPreset is just an interface so we can wrapper it into the IRQPreset.
   107      * the interface get the IRQPreset list. The upper layer will free all the items
   117      * the interface get the IRQPreset list. The upper layer will free all the items
   108      * in the list and the list self*/
   118      * in the list and the list self*/
   109     IMPORT_C QList<IRQPreset*>* getPresets() const;
   119     QList<IRQPreset*>* getPresets() const;
   110 
   120 
   111     /*
   121     /*
   112      * Increase the played times of the preset if it's in the favorites
   122      * Increase the played times of the preset if it's in the favorites
   113      */
   123      */
   114     IMPORT_C void increasePlayedTimes(const IRQPreset &aPreset);
   124     void increasePlayedTimes(const IRQPreset &aPreset);
   115     
   125     
   116     /*
       
   117      * get the CIRFavoritesDb 
       
   118      */
       
   119     IMPORT_C CIRFavoritesDb * getCIRFavoriteDB() const;
       
   120 
       
   121 signals:
   126 signals:
   122     /*
   127     /*
   123      * the signal will triggered when we receive the message that preset is changed
   128      * the signal will triggered when we receive the message that preset is changed
   124      */
   129      */
   125     void presetChanged(int aId, TUid aDataHandler,
   130     void presetChanged(int aId, int aDataHandler, PSReason aReason);
   126             MPSPresetObserver::TPSReason aType);
       
   127 
   131 
   128 private:
   132 private:
   129     CIRFavoritesDb * iIRFavoritesDb;
   133     IRQFavoritesDBPrivate * const d_ptr;
   130     void addPresetL(const IRQPreset& aPreset, int& aRetValue);
       
   131     void replacePresetL(const IRQPreset& aNewPreset);
       
   132     void replaceUserDefinedPresetL(const IRQPreset& aNewPreset);
       
   133     void increasePlayedTimesL(const IRQPreset &aPreset);
       
   134     
   134     
   135 private:
   135     Q_DISABLE_COPY(IRQFavoritesDB)
   136     /* from MPSPresetObserver */
   136     
   137     void HandlePresetChangedL(TInt aId, TUid aDataHandler,
   137     friend class IRQFavoritesDBPrivate;
   138             MPSPresetObserver::TPSReason aType);
       
   139 };
   138 };
       
   139 
   140 #endif
   140 #endif