contentstorage/caclient/stub/inc/caclientproxy.h
changeset 60 f62f87b200ec
child 66 32469d7d46ff
equal deleted inserted replaced
4:1a2a00e78665 60:f62f87b200ec
       
     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  * Description:
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef CACLIENTPROXY_H
       
    19 #define CACLIENTPROXY_H
       
    20 
       
    21 // INCLUDES
       
    22 #include "canotifier.h"
       
    23 
       
    24 //FORWARD DECLARATIONS
       
    25 class CaClientNotifierProxy;
       
    26 class CaEntry;
       
    27 class CaQuery;
       
    28 class HsWidgetToken;
       
    29 
       
    30 /**
       
    31  *  CaClientProxy
       
    32  *
       
    33  */
       
    34 class CaClientProxy
       
    35 {
       
    36 public:
       
    37 
       
    38     /**
       
    39      * Insert into group type.
       
    40      */
       
    41     enum InsertType {
       
    42         AfterTheLastEntry = -1,
       
    43         BeforeTheFirstEntry = 0
       
    44     };
       
    45 
       
    46     /**
       
    47      * Default constructor.
       
    48      */
       
    49     CaClientProxy();
       
    50 
       
    51     /**
       
    52      * Destructor.
       
    53      */
       
    54     ~CaClientProxy();
       
    55 
       
    56     /**
       
    57      * Update widgets.
       
    58      */
       
    59     void updateWidgets();
       
    60 
       
    61     /**
       
    62      * Connect to server.
       
    63      * @return error code.
       
    64      */
       
    65     ErrorCode connect();
       
    66 
       
    67     /**
       
    68      * Method for adding entries.
       
    69      * @param entryToAdd entry.
       
    70      * @param targetEntry entry.
       
    71      * @return error code.
       
    72      */
       
    73     ErrorCode addData(const CaEntry &entryToAdd,
       
    74                       CaEntry &targetEntry);
       
    75 
       
    76     /**
       
    77      * Method for removing entries.
       
    78      * @param entryIdList list of ids.
       
    79      * @return error code.
       
    80      */
       
    81     ErrorCode removeData(const QList<int> &entryIdList);
       
    82 
       
    83     /**
       
    84      * Insert entries into group.
       
    85      * @param groupId group id.
       
    86      * @param entryIdList list of ids.
       
    87      * @param beforeEntryId id of item before which the items are inserted.
       
    88      * @return error code.
       
    89      */
       
    90     ErrorCode insertEntriesIntoGroup(int groupId,
       
    91                                      const QList<int> &entryIdList, int beforeEntryId);
       
    92 
       
    93     /**
       
    94      * Remove entries from group.
       
    95      * @param groupId group id.
       
    96      * @param entryIdList list of ids.
       
    97      * @param calledDirectly true if the function was called directly (not
       
    98      * from insertEntriesIntoGroup).
       
    99      * @return error code.
       
   100      */
       
   101     ErrorCode removeEntriesFromGroup(int groupId,
       
   102                                      const QList<int> &entryIdList,
       
   103                                      bool calledDirectly = true);
       
   104 
       
   105     /**
       
   106      * Method for fetching entries.
       
   107      *
       
   108      * @param entryIdList list of input ids.
       
   109      * @param sourceList List of results.
       
   110      * @return error code
       
   111      */
       
   112     ErrorCode getData(const QList<int>& entryIdList, QList<CaEntry *>& sourceList);
       
   113 
       
   114     /**
       
   115      * Method for fetching entries.
       
   116      *
       
   117      * @param query query.
       
   118      * @param sourceList List of results.
       
   119      * @return error code
       
   120      */
       
   121     ErrorCode getData(const CaQuery &query, QList<CaEntry *>& sourceList);
       
   122 
       
   123     /**
       
   124      * Method for fetching entries.
       
   125      *
       
   126      * @param query query.
       
   127      * @param sourceIdList List of results (ids).
       
   128      * @return error code
       
   129      */
       
   130     ErrorCode getEntryIds(const CaQuery &query,
       
   131                           QList<int>& sourceIdList);
       
   132 
       
   133     /**
       
   134      * Method for executing command
       
   135      *
       
   136      * @param entry entry on wchich command will be executed
       
   137      * @param command command to execute
       
   138      * @return error code
       
   139      */
       
   140     ErrorCode executeCommand(const CaEntry &entry,
       
   141                              const QString &command);
       
   142 
       
   143     /**
       
   144      * Method for touching entry.
       
   145      *
       
   146      * @param entry entry to touch
       
   147      * @return error code
       
   148      */
       
   149     ErrorCode touch(const CaEntry &entry);
       
   150 
       
   151     /**
       
   152      * Method for custom sort.
       
   153      * @param entryIdList list of ids.
       
   154      * @param groupId Group id.
       
   155      * @return error code.
       
   156      */
       
   157     ErrorCode customSort(const QList<int> &entryIdList, int groupId);
       
   158 
       
   159     /**
       
   160      * Generate a list of parent ids of the given entries.
       
   161      * @param entryIds a list of entries.
       
   162      * @param parentIds a list of parent ids.
       
   163      * @return true if the operation is successful.
       
   164      */
       
   165     bool GetParentsIds(const QList<int> &entryIds,
       
   166                        QList<int> &parentIds);
       
   167 
       
   168 private:
       
   169     bool hsWidgetExists(int uid);
       
   170     void addWidgetEntry(const HsWidgetToken &widgetToken);
       
   171 
       
   172     void modifyQueryForSortOrder(QString &queryString,
       
   173                                  const CaQuery &query, bool parent) const;
       
   174     bool setIconInDb(CaEntry *entryClone) const;
       
   175     bool setEntryInDb(CaEntry *entryClone) const;
       
   176     bool setAttributesInDb(CaEntry *entryClone) const;
       
   177     void CreateGetParentsIdsQuery(
       
   178         const QList<int> &entryIds,
       
   179         const QList<int> &parentIds,
       
   180         QString &query);
       
   181 
       
   182 private:
       
   183     QString mWidgetRegistryPath;
       
   184 };
       
   185 
       
   186 #endif // CACLIENTPROXY_H