contentstorage/caclient/s60/inc/caclientproxy.h
changeset 60 f62f87b200ec
child 61 8e5041d13c84
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 #include <QMutex>
       
    22 
       
    23 // INCLUDES
       
    24 #include "cadef.h"
       
    25 #include "caclientsession.h"
       
    26 #include "canotifier.h"
       
    27 
       
    28 //FORWARD DECLARATIONS
       
    29 class CCaHandlerEngine;
       
    30 class CaClientNotifierProxy;
       
    31 class CaEntry;
       
    32 class CaQuery;
       
    33 class CaNotifierFilter;
       
    34 
       
    35 /**
       
    36  *  CaClientProxy
       
    37  *
       
    38  */
       
    39 class CaClientProxy
       
    40 {
       
    41 public:
       
    42 
       
    43     /**
       
    44      * Insert into group type.
       
    45      */
       
    46     enum InsertType {
       
    47         AfterTheLastEntry = -1,
       
    48         BeforeTheFirstEntry = 0
       
    49     };
       
    50 
       
    51     /**
       
    52      * Default constructor.
       
    53      */
       
    54     CaClientProxy();
       
    55 
       
    56     /**
       
    57      * Destructor.
       
    58      */
       
    59     ~CaClientProxy();
       
    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      * @return error code.
       
    98      */
       
    99     ErrorCode removeEntriesFromGroup(int groupId,
       
   100                                      const QList<int> &entryIdList);
       
   101 
       
   102     /**
       
   103      * Method for fetching entries.
       
   104      *
       
   105      * @param entryIdList list of input ids.
       
   106      * @param sourceList List of results.
       
   107      * @return error code
       
   108      */
       
   109     ErrorCode getData(const QList<int> &entryIdList, QList<CaEntry *> &sourceList);
       
   110 
       
   111     /**
       
   112      * Method for fetching entries.
       
   113      *
       
   114      * @param query query.
       
   115      * @param sourceList List of results.
       
   116      * @return error code
       
   117      */
       
   118     ErrorCode getData(const CaQuery &query, QList<CaEntry *> &sourceList);
       
   119 
       
   120     /**
       
   121      * Method for fetching entries.
       
   122      *
       
   123      * @param query query.
       
   124      * @param sourceIdList List of results (ids).
       
   125      * @return error code
       
   126      */
       
   127     ErrorCode getEntryIds(const CaQuery &query,
       
   128                           QList<int> &sourceIdList);
       
   129 
       
   130     /**
       
   131      * Method for executing command
       
   132      *
       
   133      * @param entry entry on wchich command will be executed
       
   134      * @param command command to execute
       
   135      * @return error code
       
   136      */
       
   137     ErrorCode executeCommand(const CaEntry &entry,
       
   138                              const QString &command);
       
   139 
       
   140     /**
       
   141      * Method for touching entry.
       
   142      *
       
   143      * @param aEntry entry to touch
       
   144      * @return error code
       
   145      */
       
   146     ErrorCode touch(const CaEntry &aEntry);
       
   147 
       
   148     /**
       
   149      * Method for custom sort.
       
   150      * @param entryIdList list of ids.
       
   151      * @param groupId Group id.
       
   152      * @return error code.
       
   153      */
       
   154     ErrorCode customSort(const QList<int> &entryIdList, int groupId);
       
   155 
       
   156 private:
       
   157 
       
   158     /**
       
   159      * Method for adding entries. Symbian specific.
       
   160      * @param entryToAdd
       
   161      * @param targetEntry
       
   162      *
       
   163      */
       
   164     void addDataL(const CaEntry &entryToAdd,
       
   165                   CaEntry &targetEntry);
       
   166 
       
   167     /**
       
   168      * Method for removing entries. Symbian specific.
       
   169      * @param entryIdList list of ids of entries to remove
       
   170      *
       
   171      */
       
   172     void removeDataL(const QList<int> &entryIdList);
       
   173 
       
   174     /**
       
   175      * Method for inserting entries
       
   176      * @param groupId id of a group where entries will be inserted
       
   177      * @param entryIdList list of entries ids to insert
       
   178      * @param beforeEntryId id of entry in the group that points to place
       
   179      * where entries will be inserted
       
   180      *
       
   181      */
       
   182     void insertEntriesIntoGroupL(int groupId,
       
   183                                  const QList<int> &entryIdList, int beforeEntryId);
       
   184 
       
   185     /**
       
   186      * Method for removing entries from a group
       
   187      * @param groupId id of a group where entries will be removed
       
   188      * @param entryIdList list of entries ids to remove
       
   189      *
       
   190      */
       
   191     void removeEntriesFromGroupL(int groupId,
       
   192                                  const QList<int> &entryIdList);
       
   193 
       
   194     /**
       
   195      * Method for fetching entries. Symbian specific.
       
   196      * @param entryIdList list of ids
       
   197      * @param sourceList list of entries.
       
   198      */
       
   199     void getDataL(const QList<int> &entryIdList,
       
   200                   QList<CaEntry *> &sourceList);
       
   201 
       
   202     /**
       
   203      * Method for fetching entries. Symbian specific.
       
   204      * @param entryIdList list of ids
       
   205      * @param sourceList list of entries.
       
   206      */
       
   207     void getDataL(const CaQuery &query,
       
   208                   QList<CaEntry *> &sourceList);
       
   209 
       
   210     /**
       
   211      * Method for fetching entries. Symbian specific.
       
   212      * @param query query.
       
   213      * @param sourceList list of ids.
       
   214      */
       
   215     void getEntryIdsL(const CaQuery &query,
       
   216                       QList<int> &sourceIdList);
       
   217 
       
   218     /**
       
   219      * Method for fetching entries. Symbian specific.
       
   220      * @param entry entry
       
   221      * @param command command.
       
   222      */
       
   223     void executeCommandL(const CaEntry &entry,
       
   224                          const QString &command);
       
   225 
       
   226     /**
       
   227      * Touch.
       
   228      * @param aEntry entry to be touched.
       
   229      */
       
   230     void touchL(const CaEntry &aEntry);
       
   231 
       
   232     /**
       
   233      * Custom Sort.
       
   234      * @param aEntry entry to be touched.
       
   235      */
       
   236     void customSortL(const QList<int> &entryIdList, int groupId);
       
   237 
       
   238 private:
       
   239     // Session to server.
       
   240     // Own.
       
   241     RCaClientSession mSession;
       
   242 
       
   243     // Engine handler.
       
   244     // Own.
       
   245     CCaHandlerEngine *mHandler;
       
   246 
       
   247     // Mutex to serialize access to mSessions.
       
   248     QMutex mMutex;
       
   249 };
       
   250 
       
   251 #endif // CACLIENTPROXY_H