contentstorage/caclient/stub/inc/caclientproxy.h
author hgs
Tue, 23 Mar 2010 23:17:02 +0200
changeset 85 7feec50967db
child 87 9d806967057c
permissions -rw-r--r--
201003_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
85
7feec50967db 201003_02
hgs
parents:
diff changeset
     1
/*
7feec50967db 201003_02
hgs
parents:
diff changeset
     2
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
7feec50967db 201003_02
hgs
parents:
diff changeset
     3
 * All rights reserved.
7feec50967db 201003_02
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
7feec50967db 201003_02
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
7feec50967db 201003_02
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
7feec50967db 201003_02
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
7feec50967db 201003_02
hgs
parents:
diff changeset
     8
 *
7feec50967db 201003_02
hgs
parents:
diff changeset
     9
 * Initial Contributors:
7feec50967db 201003_02
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
7feec50967db 201003_02
hgs
parents:
diff changeset
    11
 *
7feec50967db 201003_02
hgs
parents:
diff changeset
    12
 * Contributors:
7feec50967db 201003_02
hgs
parents:
diff changeset
    13
 *
7feec50967db 201003_02
hgs
parents:
diff changeset
    14
 * Description: 
7feec50967db 201003_02
hgs
parents:
diff changeset
    15
 *
7feec50967db 201003_02
hgs
parents:
diff changeset
    16
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
    17
7feec50967db 201003_02
hgs
parents:
diff changeset
    18
#ifndef CACLIENTPROXY_H
7feec50967db 201003_02
hgs
parents:
diff changeset
    19
#define CACLIENTPROXY_H
7feec50967db 201003_02
hgs
parents:
diff changeset
    20
7feec50967db 201003_02
hgs
parents:
diff changeset
    21
// INCLUDES
7feec50967db 201003_02
hgs
parents:
diff changeset
    22
#include "canotifier.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    23
7feec50967db 201003_02
hgs
parents:
diff changeset
    24
//FORWARD DECLARATIONS
7feec50967db 201003_02
hgs
parents:
diff changeset
    25
class CaClientNotifierProxy;
7feec50967db 201003_02
hgs
parents:
diff changeset
    26
class CaEntry;
7feec50967db 201003_02
hgs
parents:
diff changeset
    27
class CaQuery;
7feec50967db 201003_02
hgs
parents:
diff changeset
    28
class HsWidgetToken;
7feec50967db 201003_02
hgs
parents:
diff changeset
    29
7feec50967db 201003_02
hgs
parents:
diff changeset
    30
/**
7feec50967db 201003_02
hgs
parents:
diff changeset
    31
 *  CaClientProxy
7feec50967db 201003_02
hgs
parents:
diff changeset
    32
 *
7feec50967db 201003_02
hgs
parents:
diff changeset
    33
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
    34
class CaClientProxy
7feec50967db 201003_02
hgs
parents:
diff changeset
    35
{
7feec50967db 201003_02
hgs
parents:
diff changeset
    36
public:
7feec50967db 201003_02
hgs
parents:
diff changeset
    37
7feec50967db 201003_02
hgs
parents:
diff changeset
    38
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    39
     * Insert into group type.
7feec50967db 201003_02
hgs
parents:
diff changeset
    40
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
    41
    enum InsertType
7feec50967db 201003_02
hgs
parents:
diff changeset
    42
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
    43
        AfterTheLastEntry = -1,
7feec50967db 201003_02
hgs
parents:
diff changeset
    44
        BeforeTheFirstEntry = 0
7feec50967db 201003_02
hgs
parents:
diff changeset
    45
    };
7feec50967db 201003_02
hgs
parents:
diff changeset
    46
7feec50967db 201003_02
hgs
parents:
diff changeset
    47
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    48
     * Default constructor.
7feec50967db 201003_02
hgs
parents:
diff changeset
    49
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
    50
    CaClientProxy();
7feec50967db 201003_02
hgs
parents:
diff changeset
    51
7feec50967db 201003_02
hgs
parents:
diff changeset
    52
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    53
     * Destructor.
7feec50967db 201003_02
hgs
parents:
diff changeset
    54
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
    55
    ~CaClientProxy();
7feec50967db 201003_02
hgs
parents:
diff changeset
    56
7feec50967db 201003_02
hgs
parents:
diff changeset
    57
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    58
     * Update widgets.
7feec50967db 201003_02
hgs
parents:
diff changeset
    59
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
    60
    void updateWidgets();
7feec50967db 201003_02
hgs
parents:
diff changeset
    61
7feec50967db 201003_02
hgs
parents:
diff changeset
    62
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    63
     * Connect to server.
7feec50967db 201003_02
hgs
parents:
diff changeset
    64
     * @return error code.
7feec50967db 201003_02
hgs
parents:
diff changeset
    65
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
    66
    ErrorCode connect();
7feec50967db 201003_02
hgs
parents:
diff changeset
    67
7feec50967db 201003_02
hgs
parents:
diff changeset
    68
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    69
     * Method for adding entries.
7feec50967db 201003_02
hgs
parents:
diff changeset
    70
     * @param entryToAdd entry.
7feec50967db 201003_02
hgs
parents:
diff changeset
    71
     * @param targetEntry entry.
7feec50967db 201003_02
hgs
parents:
diff changeset
    72
     * @return error code.
7feec50967db 201003_02
hgs
parents:
diff changeset
    73
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
    74
    ErrorCode addData(const CaEntry& entryToAdd,
7feec50967db 201003_02
hgs
parents:
diff changeset
    75
        CaEntry& targetEntry);
7feec50967db 201003_02
hgs
parents:
diff changeset
    76
7feec50967db 201003_02
hgs
parents:
diff changeset
    77
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    78
     * Method for removing entries.
7feec50967db 201003_02
hgs
parents:
diff changeset
    79
     * @param entryIdList list of ids.
7feec50967db 201003_02
hgs
parents:
diff changeset
    80
     * @return error code.
7feec50967db 201003_02
hgs
parents:
diff changeset
    81
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
    82
    ErrorCode removeData(const QList<int> &entryIdList);
7feec50967db 201003_02
hgs
parents:
diff changeset
    83
7feec50967db 201003_02
hgs
parents:
diff changeset
    84
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    85
     * Insert entries into group.
7feec50967db 201003_02
hgs
parents:
diff changeset
    86
     * @param groupId group id.
7feec50967db 201003_02
hgs
parents:
diff changeset
    87
     * @param entryIdList list of ids.
7feec50967db 201003_02
hgs
parents:
diff changeset
    88
     * @param beforeEntryId id of item before which the items are inserted.
7feec50967db 201003_02
hgs
parents:
diff changeset
    89
     * @return error code.
7feec50967db 201003_02
hgs
parents:
diff changeset
    90
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
    91
    ErrorCode insertEntriesIntoGroup(int groupId,
7feec50967db 201003_02
hgs
parents:
diff changeset
    92
        const QList<int> &entryIdList, int beforeEntryId);
7feec50967db 201003_02
hgs
parents:
diff changeset
    93
7feec50967db 201003_02
hgs
parents:
diff changeset
    94
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    95
     * Remove entries from group.
7feec50967db 201003_02
hgs
parents:
diff changeset
    96
     * @param groupId group id.
7feec50967db 201003_02
hgs
parents:
diff changeset
    97
     * @param entryIdList list of ids.
7feec50967db 201003_02
hgs
parents:
diff changeset
    98
     * @param calledDirectly true if the function was called directly (not
7feec50967db 201003_02
hgs
parents:
diff changeset
    99
     * from insertEntriesIntoGroup).
7feec50967db 201003_02
hgs
parents:
diff changeset
   100
     * @return error code.
7feec50967db 201003_02
hgs
parents:
diff changeset
   101
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
   102
    ErrorCode removeEntriesFromGroup(int groupId,
7feec50967db 201003_02
hgs
parents:
diff changeset
   103
        const QList<int> &entryIdList,
7feec50967db 201003_02
hgs
parents:
diff changeset
   104
        bool calledDirectly = true);
7feec50967db 201003_02
hgs
parents:
diff changeset
   105
7feec50967db 201003_02
hgs
parents:
diff changeset
   106
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
   107
     * Method for fetching entries.
7feec50967db 201003_02
hgs
parents:
diff changeset
   108
     *
7feec50967db 201003_02
hgs
parents:
diff changeset
   109
     * @param entryIdList list of input ids.
7feec50967db 201003_02
hgs
parents:
diff changeset
   110
     * @param sourceList List of results.
7feec50967db 201003_02
hgs
parents:
diff changeset
   111
     * @return error code
7feec50967db 201003_02
hgs
parents:
diff changeset
   112
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
   113
    ErrorCode getData(const QList<int>& entryIdList, QList<CaEntry*>& sourceList);
7feec50967db 201003_02
hgs
parents:
diff changeset
   114
7feec50967db 201003_02
hgs
parents:
diff changeset
   115
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
   116
     * Method for fetching entries.
7feec50967db 201003_02
hgs
parents:
diff changeset
   117
     *
7feec50967db 201003_02
hgs
parents:
diff changeset
   118
     * @param query query.
7feec50967db 201003_02
hgs
parents:
diff changeset
   119
     * @param sourceList List of results.
7feec50967db 201003_02
hgs
parents:
diff changeset
   120
     * @return error code
7feec50967db 201003_02
hgs
parents:
diff changeset
   121
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
   122
    ErrorCode getData(const CaQuery &query, QList<CaEntry*>& sourceList);
7feec50967db 201003_02
hgs
parents:
diff changeset
   123
7feec50967db 201003_02
hgs
parents:
diff changeset
   124
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
   125
     * Method for fetching entries.
7feec50967db 201003_02
hgs
parents:
diff changeset
   126
     *
7feec50967db 201003_02
hgs
parents:
diff changeset
   127
     * @param query query.
7feec50967db 201003_02
hgs
parents:
diff changeset
   128
     * @param sourceIdList List of results (ids).
7feec50967db 201003_02
hgs
parents:
diff changeset
   129
     * @return error code
7feec50967db 201003_02
hgs
parents:
diff changeset
   130
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
   131
    ErrorCode getEntryIds(const CaQuery &query,
7feec50967db 201003_02
hgs
parents:
diff changeset
   132
        QList<int>& sourceIdList);
7feec50967db 201003_02
hgs
parents:
diff changeset
   133
7feec50967db 201003_02
hgs
parents:
diff changeset
   134
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
   135
     * Method for executing command
7feec50967db 201003_02
hgs
parents:
diff changeset
   136
     *
7feec50967db 201003_02
hgs
parents:
diff changeset
   137
     * @param entry entry on wchich command will be executed
7feec50967db 201003_02
hgs
parents:
diff changeset
   138
     * @param command command to execute
7feec50967db 201003_02
hgs
parents:
diff changeset
   139
     * @return error code
7feec50967db 201003_02
hgs
parents:
diff changeset
   140
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
   141
    ErrorCode executeCommand(const CaEntry& entry,
7feec50967db 201003_02
hgs
parents:
diff changeset
   142
        const QString& command);
7feec50967db 201003_02
hgs
parents:
diff changeset
   143
7feec50967db 201003_02
hgs
parents:
diff changeset
   144
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
   145
     * Method for touching entry.
7feec50967db 201003_02
hgs
parents:
diff changeset
   146
     *
7feec50967db 201003_02
hgs
parents:
diff changeset
   147
     * @param entry entry to touch
7feec50967db 201003_02
hgs
parents:
diff changeset
   148
     * @return error code
7feec50967db 201003_02
hgs
parents:
diff changeset
   149
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
   150
    ErrorCode touch(const CaEntry& entry);
7feec50967db 201003_02
hgs
parents:
diff changeset
   151
    
7feec50967db 201003_02
hgs
parents:
diff changeset
   152
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
   153
     * Method for custom sort.
7feec50967db 201003_02
hgs
parents:
diff changeset
   154
     * @param entryIdList list of ids.
7feec50967db 201003_02
hgs
parents:
diff changeset
   155
     * @param groupId Group id. 
7feec50967db 201003_02
hgs
parents:
diff changeset
   156
     * @return error code.
7feec50967db 201003_02
hgs
parents:
diff changeset
   157
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
   158
    ErrorCode customSort(const QList<int> &entryIdList, int groupId);
7feec50967db 201003_02
hgs
parents:
diff changeset
   159
7feec50967db 201003_02
hgs
parents:
diff changeset
   160
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
   161
     * Generate a list of parent ids of the given entries.
7feec50967db 201003_02
hgs
parents:
diff changeset
   162
     * @param entryIds a list of entries.
7feec50967db 201003_02
hgs
parents:
diff changeset
   163
     * @param parentIds a list of parent ids.
7feec50967db 201003_02
hgs
parents:
diff changeset
   164
     * @return true if the operation is successful.
7feec50967db 201003_02
hgs
parents:
diff changeset
   165
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
   166
    bool GetParentsIds( const QList<int> &entryIds,
7feec50967db 201003_02
hgs
parents:
diff changeset
   167
        QList<int> &parentIds);
7feec50967db 201003_02
hgs
parents:
diff changeset
   168
7feec50967db 201003_02
hgs
parents:
diff changeset
   169
private:
7feec50967db 201003_02
hgs
parents:
diff changeset
   170
    bool hsWidgetExists(int uid);
7feec50967db 201003_02
hgs
parents:
diff changeset
   171
    void addWidgetEntry(const HsWidgetToken &widgetToken);
7feec50967db 201003_02
hgs
parents:
diff changeset
   172
    
7feec50967db 201003_02
hgs
parents:
diff changeset
   173
    void modifyQueryForSortOrder(QString& queryString,
7feec50967db 201003_02
hgs
parents:
diff changeset
   174
        const CaQuery &query, bool parent) const;
7feec50967db 201003_02
hgs
parents:
diff changeset
   175
    bool setIconInDb(CaEntry* entryClone) const;
7feec50967db 201003_02
hgs
parents:
diff changeset
   176
    bool setEntryInDb(CaEntry* entryClone) const;
7feec50967db 201003_02
hgs
parents:
diff changeset
   177
    bool setAttributesInDb(CaEntry* entryClone) const;
7feec50967db 201003_02
hgs
parents:
diff changeset
   178
    void CreateGetParentsIdsQuery(
7feec50967db 201003_02
hgs
parents:
diff changeset
   179
        const QList<int> &entryIds,
7feec50967db 201003_02
hgs
parents:
diff changeset
   180
        const QList<int> &parentIds,
7feec50967db 201003_02
hgs
parents:
diff changeset
   181
        QString &query);
7feec50967db 201003_02
hgs
parents:
diff changeset
   182
        
7feec50967db 201003_02
hgs
parents:
diff changeset
   183
private:
7feec50967db 201003_02
hgs
parents:
diff changeset
   184
    QString mWidgetRegistryPath;
7feec50967db 201003_02
hgs
parents:
diff changeset
   185
};
7feec50967db 201003_02
hgs
parents:
diff changeset
   186
7feec50967db 201003_02
hgs
parents:
diff changeset
   187
#endif // CACLIENTPROXY_H