contentstorage/caclient/s60/src/caobjectadapter.cpp
author hgs
Fri, 11 Jun 2010 16:13:51 +0300
changeset 98 d2f833ab7940
parent 93 82b66994846c
child 99 7aaf39b772ac
permissions -rw-r--r--
201023
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)2008 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:  ?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
#include <e32std.h>
7feec50967db 201003_02
hgs
parents:
diff changeset
    19
#include <exception>
7feec50967db 201003_02
hgs
parents:
diff changeset
    20
#include <e32base.h>
86
hgs
parents: 85
diff changeset
    21
#include <badesca.h>
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    22
#include <AknIconUtils.h>
7feec50967db 201003_02
hgs
parents:
diff changeset
    23
#include <fbs.h>
86
hgs
parents: 85
diff changeset
    24
#include <bitdev.h>
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    25
#include <QPixmap>
86
hgs
parents: 85
diff changeset
    26
#include <HbIcon>
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    27
#include <QBitmap>
7feec50967db 201003_02
hgs
parents:
diff changeset
    28
#include <QDebug>
89
hgs
parents: 88
diff changeset
    29
#include <XQConversions>
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    30
7feec50967db 201003_02
hgs
parents:
diff changeset
    31
#include "cadef.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    32
#include "caobjectadapter.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    33
#include "cainnerentry.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    34
#include "caentry_p.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    35
#include "cainnerquery.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    36
#include "caquery.h"
92
hgs
parents: 89
diff changeset
    37
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    38
#include "canotifierfilter.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    39
#include "cainnernotifierfilter.h"
89
hgs
parents: 88
diff changeset
    40
#include "caclient_defines.h"
87
hgs
parents: 86
diff changeset
    41
89
hgs
parents: 88
diff changeset
    42
// ---------------------------------------------------------------------------
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    43
//
89
hgs
parents: 88
diff changeset
    44
// ---------------------------------------------------------------------------
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    45
void CaObjectAdapter::convertL(const CaEntry &fromEntry,
87
hgs
parents: 86
diff changeset
    46
                               CCaInnerEntry &toEntry)
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    47
{
7feec50967db 201003_02
hgs
parents:
diff changeset
    48
    toEntry.SetId(fromEntry.id());
7feec50967db 201003_02
hgs
parents:
diff changeset
    49
89
hgs
parents: 88
diff changeset
    50
    toEntry.SetTextL(
98
hgs
parents: 93
diff changeset
    51
        XQConversions::qStringToS60Desc(fromEntry.text())->Des(),
hgs
parents: 93
diff changeset
    52
        fromEntry.isLocalized(NameLocalized));
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    53
89
hgs
parents: 88
diff changeset
    54
    toEntry.SetDescriptionL(
98
hgs
parents: 93
diff changeset
    55
        XQConversions::qStringToS60Desc(fromEntry.description())->Des(),
hgs
parents: 93
diff changeset
    56
        fromEntry.isLocalized(DescriptionLocalized));
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    57
7feec50967db 201003_02
hgs
parents:
diff changeset
    58
    toEntry.SetEntryTypeNameL(
89
hgs
parents: 88
diff changeset
    59
        XQConversions::qStringToS60Desc(fromEntry.entryTypeName())->Des());
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    60
87
hgs
parents: 86
diff changeset
    61
    toEntry.SetFlags(static_cast<TUint>(fromEntry.flags()));
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    62
87
hgs
parents: 86
diff changeset
    63
    toEntry.SetRole(static_cast<TUint>(fromEntry.role()));
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    64
7feec50967db 201003_02
hgs
parents:
diff changeset
    65
    const CaIconDescription fromIconDescription =
7feec50967db 201003_02
hgs
parents:
diff changeset
    66
        fromEntry.iconDescription();
7feec50967db 201003_02
hgs
parents:
diff changeset
    67
7feec50967db 201003_02
hgs
parents:
diff changeset
    68
    toEntry.SetIconDataL(
89
hgs
parents: 88
diff changeset
    69
        XQConversions::qStringToS60Desc(
hgs
parents: 88
diff changeset
    70
            fromIconDescription.filename())->Des(),
hgs
parents: 88
diff changeset
    71
        XQConversions::qStringToS60Desc(
hgs
parents: 88
diff changeset
    72
            fromIconDescription.skinId())->Des(),
hgs
parents: 88
diff changeset
    73
        XQConversions::qStringToS60Desc(
hgs
parents: 88
diff changeset
    74
            fromIconDescription.applicationId())->Des());
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    75
7feec50967db 201003_02
hgs
parents:
diff changeset
    76
    const QMap<QString, QString> attributesMap = fromEntry.attributes();
7feec50967db 201003_02
hgs
parents:
diff changeset
    77
87
hgs
parents: 86
diff changeset
    78
    foreach(QString key, attributesMap.keys()) {
89
hgs
parents: 88
diff changeset
    79
        if (key == APPLICATION_UID_ATTRIBUTE_NAME) {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    80
            const TInt32 uid = attributesMap.value(key).toInt();
7feec50967db 201003_02
hgs
parents:
diff changeset
    81
            toEntry.SetUid(uid);
87
hgs
parents: 86
diff changeset
    82
        } else {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    83
            toEntry.AddAttributeL(
89
hgs
parents: 88
diff changeset
    84
                XQConversions::qStringToS60Desc(key)->Des(),
hgs
parents: 88
diff changeset
    85
                XQConversions::qStringToS60Desc(
hgs
parents: 88
diff changeset
    86
                    attributesMap.value(key))->Des());
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    87
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
    88
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
    89
}
7feec50967db 201003_02
hgs
parents:
diff changeset
    90
7feec50967db 201003_02
hgs
parents:
diff changeset
    91
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    92
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    93
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    94
void CaObjectAdapter::convertL(const CaQuery &fromQuery,
87
hgs
parents: 86
diff changeset
    95
                               CCaInnerQuery &toQuery)
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    96
{
7feec50967db 201003_02
hgs
parents:
diff changeset
    97
    toQuery.SetParentId(fromQuery.parentId());
7feec50967db 201003_02
hgs
parents:
diff changeset
    98
7feec50967db 201003_02
hgs
parents:
diff changeset
    99
    toQuery.SetFlagsOn(static_cast<TUint>(fromQuery.flagsOn()));
7feec50967db 201003_02
hgs
parents:
diff changeset
   100
7feec50967db 201003_02
hgs
parents:
diff changeset
   101
    toQuery.SetFlagsOff(static_cast<TUint>(fromQuery.flagsOff()));
7feec50967db 201003_02
hgs
parents:
diff changeset
   102
7feec50967db 201003_02
hgs
parents:
diff changeset
   103
    toQuery.SetRole(static_cast<TInt>(fromQuery.entryRoles()));
7feec50967db 201003_02
hgs
parents:
diff changeset
   104
7feec50967db 201003_02
hgs
parents:
diff changeset
   105
    toQuery.SetCount(fromQuery.count());
7feec50967db 201003_02
hgs
parents:
diff changeset
   106
7feec50967db 201003_02
hgs
parents:
diff changeset
   107
    const QStringList list = fromQuery.entryTypeNames();
7feec50967db 201003_02
hgs
parents:
diff changeset
   108
7feec50967db 201003_02
hgs
parents:
diff changeset
   109
    CDesC16ArrayFlat *sourceList =
87
hgs
parents: 86
diff changeset
   110
        new(ELeave)CDesC16ArrayFlat(KDefaultGranularity);
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   111
    CleanupStack::PushL(sourceList);
7feec50967db 201003_02
hgs
parents:
diff changeset
   112
87
hgs
parents: 86
diff changeset
   113
    foreach(const QString str, list) {
89
hgs
parents: 88
diff changeset
   114
        sourceList->AppendL(XQConversions::qStringToS60Desc(str)->Des());
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   115
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   116
7feec50967db 201003_02
hgs
parents:
diff changeset
   117
    toQuery.SetEntryTypeNames(sourceList);
7feec50967db 201003_02
hgs
parents:
diff changeset
   118
7feec50967db 201003_02
hgs
parents:
diff changeset
   119
    CleanupStack::Pop(sourceList);
7feec50967db 201003_02
hgs
parents:
diff changeset
   120
7feec50967db 201003_02
hgs
parents:
diff changeset
   121
    // mapping sort enums
7feec50967db 201003_02
hgs
parents:
diff changeset
   122
    SortAttribute sortAttr;
7feec50967db 201003_02
hgs
parents:
diff changeset
   123
    Qt::SortOrder sortOrder;
7feec50967db 201003_02
hgs
parents:
diff changeset
   124
    fromQuery.getSort(sortAttr, sortOrder);
7feec50967db 201003_02
hgs
parents:
diff changeset
   125
    toQuery.SetSort(CaObjectAdapter::getSortCode(sortAttr, sortOrder));
89
hgs
parents: 88
diff changeset
   126
88
hgs
parents: 87
diff changeset
   127
    const QMap<QString, QString> attributesMap = fromQuery.attributes();
hgs
parents: 87
diff changeset
   128
hgs
parents: 87
diff changeset
   129
    foreach(QString key, attributesMap.keys()) {
92
hgs
parents: 89
diff changeset
   130
        if (key == APPLICATION_UID_ATTRIBUTE_NAME) {
hgs
parents: 89
diff changeset
   131
            const TInt32 uid = attributesMap.value(key).toInt();
hgs
parents: 89
diff changeset
   132
            toQuery.SetUid(uid);
hgs
parents: 89
diff changeset
   133
        }
hgs
parents: 89
diff changeset
   134
        else {
hgs
parents: 89
diff changeset
   135
            toQuery.AddAttributeL(
hgs
parents: 89
diff changeset
   136
                XQConversions::qStringToS60Desc(key)->Des(),
hgs
parents: 89
diff changeset
   137
                XQConversions::qStringToS60Desc(
hgs
parents: 89
diff changeset
   138
                    attributesMap.value(key))->Des());
hgs
parents: 89
diff changeset
   139
        }
88
hgs
parents: 87
diff changeset
   140
    }
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   141
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   142
7feec50967db 201003_02
hgs
parents:
diff changeset
   143
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   144
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   145
//----------------------------------------------------------------------------
89
hgs
parents: 88
diff changeset
   146
void CaObjectAdapter::convert(
hgs
parents: 88
diff changeset
   147
        const CCaInnerEntry &fromEntry, CaEntry &toEntry)
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   148
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   149
    toEntry.setId(fromEntry.GetId());
7feec50967db 201003_02
hgs
parents:
diff changeset
   150
98
hgs
parents: 93
diff changeset
   151
    toEntry.setText(XQConversions::s60DescToQString(fromEntry.GetText()),
hgs
parents: 93
diff changeset
   152
            fromEntry.isLocalized(CCaInnerEntry::ENameLocalized));
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   153
89
hgs
parents: 88
diff changeset
   154
    toEntry.setDescription(
98
hgs
parents: 93
diff changeset
   155
        XQConversions::s60DescToQString(fromEntry.GetDescription()),
hgs
parents: 93
diff changeset
   156
        fromEntry.isLocalized(CCaInnerEntry::EDescriptionLocalized));
89
hgs
parents: 88
diff changeset
   157
    toEntry.setEntryTypeName(
hgs
parents: 88
diff changeset
   158
        XQConversions::s60DescToQString(fromEntry.GetEntryTypeName()));
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   159
7feec50967db 201003_02
hgs
parents:
diff changeset
   160
    toEntry.setFlags(static_cast<EntryFlag>(fromEntry.GetFlags()));
7feec50967db 201003_02
hgs
parents:
diff changeset
   161
7feec50967db 201003_02
hgs
parents:
diff changeset
   162
    // take care of converting icon attributes
92
hgs
parents: 89
diff changeset
   163
    const CCaInnerIconDescription* innerIcon = fromEntry.Icon();
hgs
parents: 89
diff changeset
   164
    CaIconDescription iconDescription;
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   165
92
hgs
parents: 89
diff changeset
   166
    iconDescription.setId(innerIcon->Id());
89
hgs
parents: 88
diff changeset
   167
    iconDescription.setFilename(
92
hgs
parents: 89
diff changeset
   168
        XQConversions::s60DescToQString(innerIcon->FileName()));
89
hgs
parents: 88
diff changeset
   169
    iconDescription.setSkinId(
92
hgs
parents: 89
diff changeset
   170
        XQConversions::s60DescToQString(innerIcon->SkinId()));
89
hgs
parents: 88
diff changeset
   171
    iconDescription.setApplicationId(
92
hgs
parents: 89
diff changeset
   172
        XQConversions::s60DescToQString(innerIcon->ApplicationId()));
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   173
7feec50967db 201003_02
hgs
parents:
diff changeset
   174
    toEntry.setIconDescription(iconDescription);
7feec50967db 201003_02
hgs
parents:
diff changeset
   175
7feec50967db 201003_02
hgs
parents:
diff changeset
   176
    const RCaEntryAttrArray &attributesArray = fromEntry.GetAttributes();
7feec50967db 201003_02
hgs
parents:
diff changeset
   177
89
hgs
parents: 88
diff changeset
   178
    if (toEntry.entryTypeName() == APPLICATION_ENTRY_TYPE_NAME
hgs
parents: 88
diff changeset
   179
            || toEntry.entryTypeName() == WIDGET_ENTRY_TYPE_NAME) {
hgs
parents: 88
diff changeset
   180
        toEntry.setAttribute(APPLICATION_UID_ATTRIBUTE_NAME,
hgs
parents: 88
diff changeset
   181
            QString::number(fromEntry.GetUid()));
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   182
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   183
7feec50967db 201003_02
hgs
parents:
diff changeset
   184
    const int attributesArrayCount = attributesArray.Count();
7feec50967db 201003_02
hgs
parents:
diff changeset
   185
7feec50967db 201003_02
hgs
parents:
diff changeset
   186
    for (int i = 0; i < attributesArrayCount; ++i) {
7feec50967db 201003_02
hgs
parents:
diff changeset
   187
        const CCaEntryAttribute *const attribute = attributesArray[i];
89
hgs
parents: 88
diff changeset
   188
        toEntry.setAttribute(
hgs
parents: 88
diff changeset
   189
            XQConversions::s60DescToQString(attribute->Name()),
hgs
parents: 88
diff changeset
   190
            XQConversions::s60DescToQString(attribute->Value()));
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   191
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   192
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   193
7feec50967db 201003_02
hgs
parents:
diff changeset
   194
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   195
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   196
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   197
void CaObjectAdapter::convertL(const CaNotifierFilter &notifierFilter,
87
hgs
parents: 86
diff changeset
   198
                               CCaInnerNotifierFilter &source)
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   199
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   200
    source.SetParentId(static_cast<TInt>(notifierFilter.getParentId()));
7feec50967db 201003_02
hgs
parents:
diff changeset
   201
7feec50967db 201003_02
hgs
parents:
diff changeset
   202
    RArray<TInt> idsList;
7feec50967db 201003_02
hgs
parents:
diff changeset
   203
    CleanupClosePushL(idsList);
7feec50967db 201003_02
hgs
parents:
diff changeset
   204
    CaObjectAdapter::convertL(notifierFilter.getIds(), idsList);
7feec50967db 201003_02
hgs
parents:
diff changeset
   205
    source.SetIdsL(idsList);
7feec50967db 201003_02
hgs
parents:
diff changeset
   206
7feec50967db 201003_02
hgs
parents:
diff changeset
   207
    CleanupStack::PopAndDestroy(&idsList);
7feec50967db 201003_02
hgs
parents:
diff changeset
   208
7feec50967db 201003_02
hgs
parents:
diff changeset
   209
    switch (notifierFilter.getEntryRole()) {
7feec50967db 201003_02
hgs
parents:
diff changeset
   210
    case static_cast<TUint>(ItemEntryRole):
7feec50967db 201003_02
hgs
parents:
diff changeset
   211
        source.SetEntryRole(EItemEntryRole);
7feec50967db 201003_02
hgs
parents:
diff changeset
   212
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   213
    case static_cast<TUint>(GroupEntryRole):
7feec50967db 201003_02
hgs
parents:
diff changeset
   214
        source.SetEntryRole(EGroupEntryRole);
7feec50967db 201003_02
hgs
parents:
diff changeset
   215
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   216
    default:
7feec50967db 201003_02
hgs
parents:
diff changeset
   217
        source.SetEntryRole(ENoneEntryRole);
7feec50967db 201003_02
hgs
parents:
diff changeset
   218
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   219
    }
87
hgs
parents: 86
diff changeset
   220
    CDesC16ArrayFlat *typeNames = new(ELeave) CDesC16ArrayFlat(
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   221
        KDefaultGranularity);
7feec50967db 201003_02
hgs
parents:
diff changeset
   222
    CleanupStack::PushL(typeNames);
7feec50967db 201003_02
hgs
parents:
diff changeset
   223
7feec50967db 201003_02
hgs
parents:
diff changeset
   224
    const QStringList stringList = notifierFilter.getTypeNames();
7feec50967db 201003_02
hgs
parents:
diff changeset
   225
7feec50967db 201003_02
hgs
parents:
diff changeset
   226
    foreach(QString str, stringList) {
89
hgs
parents: 88
diff changeset
   227
        typeNames->AppendL(XQConversions::qStringToS60Desc(str)->Des());
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   228
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   229
7feec50967db 201003_02
hgs
parents:
diff changeset
   230
    source.SetTypeNames(typeNames);
7feec50967db 201003_02
hgs
parents:
diff changeset
   231
7feec50967db 201003_02
hgs
parents:
diff changeset
   232
    CleanupStack::Pop(typeNames);
7feec50967db 201003_02
hgs
parents:
diff changeset
   233
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   234
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   235
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   236
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   237
void CaObjectAdapter::convertL(
7feec50967db 201003_02
hgs
parents:
diff changeset
   238
    const RPointerArray<CCaInnerEntry> &fromEntriesArray,
92
hgs
parents: 89
diff changeset
   239
    QList< QSharedPointer<CaEntry> > &toEntryList)
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   240
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   241
    for (int i = 0; i < fromEntriesArray.Count(); ++i) {
92
hgs
parents: 89
diff changeset
   242
        const QSharedPointer<CaEntry> toEntry (new CaEntry(
hgs
parents: 89
diff changeset
   243
            static_cast<EntryRole>(fromEntriesArray[i]->GetRole())));
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   244
7feec50967db 201003_02
hgs
parents:
diff changeset
   245
        CaObjectAdapter::convert(*fromEntriesArray[i], *toEntry);
7feec50967db 201003_02
hgs
parents:
diff changeset
   246
7feec50967db 201003_02
hgs
parents:
diff changeset
   247
        toEntryList << toEntry;
7feec50967db 201003_02
hgs
parents:
diff changeset
   248
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   249
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   250
7feec50967db 201003_02
hgs
parents:
diff changeset
   251
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   252
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   253
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   254
void CaObjectAdapter::convertL(const QList<int> &entryIdList,
87
hgs
parents: 86
diff changeset
   255
                               RArray<TInt> &source)
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   256
{
87
hgs
parents: 86
diff changeset
   257
    foreach(int id, entryIdList) {
hgs
parents: 86
diff changeset
   258
        source.AppendL(static_cast<TInt>(id));
hgs
parents: 86
diff changeset
   259
    }
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   260
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   261
7feec50967db 201003_02
hgs
parents:
diff changeset
   262
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   263
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   264
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   265
void CaObjectAdapter::convertL(const RArray<TInt> &innerEntryIdList,
87
hgs
parents: 86
diff changeset
   266
                               QList<int> &idList)
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   267
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   268
    for (TInt i = 0; i < innerEntryIdList.Count(); ++i) {
7feec50967db 201003_02
hgs
parents:
diff changeset
   269
        idList.append(innerEntryIdList[i]);
7feec50967db 201003_02
hgs
parents:
diff changeset
   270
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   271
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   272
7feec50967db 201003_02
hgs
parents:
diff changeset
   273
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   274
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   275
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   276
ErrorCode CaObjectAdapter::convertErrorCode(int internalErrorCode)
7feec50967db 201003_02
hgs
parents:
diff changeset
   277
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   278
    ErrorCode error(NoErrorCode);
7feec50967db 201003_02
hgs
parents:
diff changeset
   279
    switch (internalErrorCode) {
7feec50967db 201003_02
hgs
parents:
diff changeset
   280
    case KErrNone:
7feec50967db 201003_02
hgs
parents:
diff changeset
   281
        error = NoErrorCode;
7feec50967db 201003_02
hgs
parents:
diff changeset
   282
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   283
    case KErrNotFound:
7feec50967db 201003_02
hgs
parents:
diff changeset
   284
        error = NotFoundErrorCode;
7feec50967db 201003_02
hgs
parents:
diff changeset
   285
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   286
    case KErrNoMemory:
7feec50967db 201003_02
hgs
parents:
diff changeset
   287
        error = OutOfMemoryErrorCode;
7feec50967db 201003_02
hgs
parents:
diff changeset
   288
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   289
    case KErrArgument:
7feec50967db 201003_02
hgs
parents:
diff changeset
   290
        error = BadArgumentErrorCode;
7feec50967db 201003_02
hgs
parents:
diff changeset
   291
        break;
93
hgs
parents: 92
diff changeset
   292
    case KErrServerTerminated:
hgs
parents: 92
diff changeset
   293
        error = ServerTerminated;
hgs
parents: 92
diff changeset
   294
        break;
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   295
    default:
7feec50967db 201003_02
hgs
parents:
diff changeset
   296
        error = UnknownErrorCode;
7feec50967db 201003_02
hgs
parents:
diff changeset
   297
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   298
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   299
    return error;
7feec50967db 201003_02
hgs
parents:
diff changeset
   300
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   301
7feec50967db 201003_02
hgs
parents:
diff changeset
   302
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   303
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   304
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   305
void CaObjectAdapter::convert(
7feec50967db 201003_02
hgs
parents:
diff changeset
   306
    CaNotifierPrivate::NotifierType src,
7feec50967db 201003_02
hgs
parents:
diff changeset
   307
    CCaInnerNotifierFilter::TNotifierType &dest)
7feec50967db 201003_02
hgs
parents:
diff changeset
   308
{
87
hgs
parents: 86
diff changeset
   309
    switch (src) {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   310
    case CaNotifierPrivate::EntryChangedWithIdNotifierType:
7feec50967db 201003_02
hgs
parents:
diff changeset
   311
        dest = CCaInnerNotifierFilter::EEntryChangedWithId;
7feec50967db 201003_02
hgs
parents:
diff changeset
   312
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   313
    case CaNotifierPrivate::EntryChangedWithEntryNotifierType:
7feec50967db 201003_02
hgs
parents:
diff changeset
   314
        dest = CCaInnerNotifierFilter::EEntryChangedWithEntry;
7feec50967db 201003_02
hgs
parents:
diff changeset
   315
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   316
    case CaNotifierPrivate::EntryTouchedNotifierType:
7feec50967db 201003_02
hgs
parents:
diff changeset
   317
        dest = CCaInnerNotifierFilter::EEntryTouched;
7feec50967db 201003_02
hgs
parents:
diff changeset
   318
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   319
    case CaNotifierPrivate::GroupContentChangedNotifierType:
7feec50967db 201003_02
hgs
parents:
diff changeset
   320
        dest = CCaInnerNotifierFilter::EGroupContentChanged;
7feec50967db 201003_02
hgs
parents:
diff changeset
   321
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   322
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   323
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   324
7feec50967db 201003_02
hgs
parents:
diff changeset
   325
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   326
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   327
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   328
void CaObjectAdapter::convert(
7feec50967db 201003_02
hgs
parents:
diff changeset
   329
    TChangeType src, ChangeType &dest)
7feec50967db 201003_02
hgs
parents:
diff changeset
   330
{
87
hgs
parents: 86
diff changeset
   331
    switch (src) {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   332
    case EAddChangeType:
7feec50967db 201003_02
hgs
parents:
diff changeset
   333
        dest = AddChangeType;
7feec50967db 201003_02
hgs
parents:
diff changeset
   334
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   335
    case ERemoveChangeType:
7feec50967db 201003_02
hgs
parents:
diff changeset
   336
        dest = RemoveChangeType;
7feec50967db 201003_02
hgs
parents:
diff changeset
   337
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   338
    case EUpdateChangeType:
7feec50967db 201003_02
hgs
parents:
diff changeset
   339
        dest = UpdateChangeType;
7feec50967db 201003_02
hgs
parents:
diff changeset
   340
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   341
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   342
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   343
7feec50967db 201003_02
hgs
parents:
diff changeset
   344
CCaInnerQuery::TSortAttribute CaObjectAdapter::getSortCode(
7feec50967db 201003_02
hgs
parents:
diff changeset
   345
    SortAttribute sortAttribute, Qt::SortOrder sortOrder)
7feec50967db 201003_02
hgs
parents:
diff changeset
   346
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   347
    CCaInnerQuery::TSortAttribute sortCode(CCaInnerQuery::Default);
7feec50967db 201003_02
hgs
parents:
diff changeset
   348
7feec50967db 201003_02
hgs
parents:
diff changeset
   349
    switch (sortAttribute) {
87
hgs
parents: 86
diff changeset
   350
    case NameSortAttribute: {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   351
        sortCode = (sortOrder == Qt::AscendingOrder) ? CCaInnerQuery::Name
87
hgs
parents: 86
diff changeset
   352
                   : CCaInnerQuery::NameDesc;
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   353
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   354
    }
87
hgs
parents: 86
diff changeset
   355
    case CreatedTimestampSortAttribute: {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   356
        sortCode = (sortOrder == Qt::AscendingOrder)
87
hgs
parents: 86
diff changeset
   357
                   ? CCaInnerQuery::CreatedTimestamp
hgs
parents: 86
diff changeset
   358
                   : CCaInnerQuery::CreatedTimestampDesc;
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   359
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   360
    }
87
hgs
parents: 86
diff changeset
   361
    case MostUsedSortAttribute: {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   362
        sortCode = (sortOrder == Qt::AscendingOrder)
87
hgs
parents: 86
diff changeset
   363
                   ? CCaInnerQuery::MostUsed : CCaInnerQuery::MostUsedDesc;
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   364
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   365
    }
87
hgs
parents: 86
diff changeset
   366
    case LastUsedSortAttribute: {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   367
        sortCode = (sortOrder == Qt::AscendingOrder)
87
hgs
parents: 86
diff changeset
   368
                   ? CCaInnerQuery::LastUsed : CCaInnerQuery::LastUsedDesc;
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   369
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   370
    }
87
hgs
parents: 86
diff changeset
   371
    case DefaultSortAttribute: {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   372
        sortCode = (sortOrder == Qt::AscendingOrder)
87
hgs
parents: 86
diff changeset
   373
                   ? CCaInnerQuery::Default : CCaInnerQuery::DefaultDesc;
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   374
        break;
7feec50967db 201003_02
hgs
parents:
diff changeset
   375
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   376
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   377
7feec50967db 201003_02
hgs
parents:
diff changeset
   378
    return sortCode;
7feec50967db 201003_02
hgs
parents:
diff changeset
   379
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   380
7feec50967db 201003_02
hgs
parents:
diff changeset
   381
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   382
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   383
//----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   384
void CaObjectAdapter::setId(CaEntry &entry,
87
hgs
parents: 86
diff changeset
   385
                            int id)
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   386
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   387
    entry.setId(id);
7feec50967db 201003_02
hgs
parents:
diff changeset
   388
}