contentstorage/srvsrc/castorageproxy.cpp
author hgs
Mon, 18 Oct 2010 10:44:15 +0300
changeset 127 7b66bc3c6dc9
parent 125 26079c1bb561
permissions -rw-r--r--
201041
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:
7feec50967db 201003_02
hgs
parents:
diff changeset
    15
 *
7feec50967db 201003_02
hgs
parents:
diff changeset
    16
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
    17
98
hgs
parents: 94
diff changeset
    18
#include <driveinfo.h>
hgs
parents: 94
diff changeset
    19
#include <hbtextresolversymbian.h>
hgs
parents: 94
diff changeset
    20
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    21
#include "castorage.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    22
#include "castorageproxy.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    23
#include "castoragefactory.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    24
#include "cainnerentry.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    25
#include "cainnerquery.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    26
#include "caarraycleanup.inl"
7feec50967db 201003_02
hgs
parents:
diff changeset
    27
#include "calocalizationentry.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    28
#include "casrvsession.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    29
7feec50967db 201003_02
hgs
parents:
diff changeset
    30
7feec50967db 201003_02
hgs
parents:
diff changeset
    31
7feec50967db 201003_02
hgs
parents:
diff changeset
    32
// ---------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    33
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    34
// ---------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    35
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    36
CCaStorageProxy::CCaStorageProxy()
7feec50967db 201003_02
hgs
parents:
diff changeset
    37
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
    38
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
    39
7feec50967db 201003_02
hgs
parents:
diff changeset
    40
// ---------------------------------------------------------------------------
86
hgs
parents: 85
diff changeset
    41
//
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    42
// ---------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    43
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    44
void CCaStorageProxy::ConstructL()
7feec50967db 201003_02
hgs
parents:
diff changeset
    45
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
    46
    iStorage = CaStorageFactory::NewDatabaseL();
7feec50967db 201003_02
hgs
parents:
diff changeset
    47
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
    48
7feec50967db 201003_02
hgs
parents:
diff changeset
    49
// ---------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    50
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    51
// ---------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    52
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    53
CCaStorageProxy* CCaStorageProxy::NewL()
7feec50967db 201003_02
hgs
parents:
diff changeset
    54
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
    55
    CCaStorageProxy* self = CCaStorageProxy::NewLC();
7feec50967db 201003_02
hgs
parents:
diff changeset
    56
    CleanupStack::Pop( self );
7feec50967db 201003_02
hgs
parents:
diff changeset
    57
    return self;
7feec50967db 201003_02
hgs
parents:
diff changeset
    58
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
    59
7feec50967db 201003_02
hgs
parents:
diff changeset
    60
// ---------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    61
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    62
// ---------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    63
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    64
CCaStorageProxy* CCaStorageProxy::NewLC()
7feec50967db 201003_02
hgs
parents:
diff changeset
    65
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
    66
    CCaStorageProxy* self = new ( ELeave ) CCaStorageProxy();
7feec50967db 201003_02
hgs
parents:
diff changeset
    67
    CleanupStack::PushL( self );
7feec50967db 201003_02
hgs
parents:
diff changeset
    68
    self->ConstructL();
7feec50967db 201003_02
hgs
parents:
diff changeset
    69
    return self;
7feec50967db 201003_02
hgs
parents:
diff changeset
    70
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
    71
7feec50967db 201003_02
hgs
parents:
diff changeset
    72
// ---------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    73
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    74
// ---------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    75
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    76
CCaStorageProxy::~CCaStorageProxy()
7feec50967db 201003_02
hgs
parents:
diff changeset
    77
    {
125
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
    78
    iTitleUserColName.Close();
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    79
    delete iStorage;
7feec50967db 201003_02
hgs
parents:
diff changeset
    80
    iHandlerNotifier.Close();
7feec50967db 201003_02
hgs
parents:
diff changeset
    81
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
    82
7feec50967db 201003_02
hgs
parents:
diff changeset
    83
// ---------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    84
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    85
// ---------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    86
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    87
EXPORT_C void CCaStorageProxy::GetEntriesL(const CCaInnerQuery* aQuery,
7feec50967db 201003_02
hgs
parents:
diff changeset
    88
        RPointerArray<CCaInnerEntry>& aResultContainer )
7feec50967db 201003_02
hgs
parents:
diff changeset
    89
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
    90
    iStorage->GetEntriesL( aQuery, aResultContainer );
125
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
    91
    if( aResultContainer.Count() == 1 
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
    92
            && aResultContainer[0]->
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
    93
            GetEntryTypeName().Compare( KCaTypeCollection ) == KErrNone )
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
    94
        {
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
    95
        TPtrC titleName;
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
    96
        if( !aResultContainer[0]->FindAttribute( KCaAttrTitleName, titleName ) )
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
    97
            {
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
    98
            AddTitleNameL( aResultContainer[0] );
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
    99
            }
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   100
        }
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   101
    
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   102
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   103
86
hgs
parents: 85
diff changeset
   104
// ---------------------------------------------------------------------------
hgs
parents: 85
diff changeset
   105
//
hgs
parents: 85
diff changeset
   106
// ---------------------------------------------------------------------------
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   107
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   108
EXPORT_C void CCaStorageProxy::GetEntriesIdsL(const CCaInnerQuery* aQuery,
7feec50967db 201003_02
hgs
parents:
diff changeset
   109
        RArray<TInt>& aResultIdArray)
7feec50967db 201003_02
hgs
parents:
diff changeset
   110
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   111
    iStorage->GetEntriesIdsL( aQuery, aResultIdArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   112
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   113
86
hgs
parents: 85
diff changeset
   114
// ---------------------------------------------------------------------------
hgs
parents: 85
diff changeset
   115
//
hgs
parents: 85
diff changeset
   116
// ---------------------------------------------------------------------------
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   117
//
93
hgs
parents: 86
diff changeset
   118
EXPORT_C void CCaStorageProxy::AddL( CCaInnerEntry* aEntry,
hgs
parents: 86
diff changeset
   119
    TBool aUpdate,
hgs
parents: 86
diff changeset
   120
    TItemAppearance aItemAppearanceChange )
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   121
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   122
    TChangeType changeType = EAddChangeType;
7feec50967db 201003_02
hgs
parents:
diff changeset
   123
    RArray<TInt> parentArray;
7feec50967db 201003_02
hgs
parents:
diff changeset
   124
    CleanupClosePushL( parentArray );
127
hgs
parents: 125
diff changeset
   125
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   126
    if( aEntry->GetId() > 0 )
7feec50967db 201003_02
hgs
parents:
diff changeset
   127
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   128
        changeType = EUpdateChangeType;
7feec50967db 201003_02
hgs
parents:
diff changeset
   129
        RArray<TInt> id;
7feec50967db 201003_02
hgs
parents:
diff changeset
   130
        CleanupClosePushL( id );
7feec50967db 201003_02
hgs
parents:
diff changeset
   131
        id.AppendL( aEntry->GetId() );
98
hgs
parents: 94
diff changeset
   132
        if (aItemAppearanceChange == EItemUninstallProgressChanged)
hgs
parents: 94
diff changeset
   133
            {
127
hgs
parents: 125
diff changeset
   134
            // no need to search for parent parents for uninstall
98
hgs
parents: 94
diff changeset
   135
            // progress change
hgs
parents: 94
diff changeset
   136
            iStorage->GetParentsIdsL( id, parentArray, EFalse );
hgs
parents: 94
diff changeset
   137
            }
hgs
parents: 94
diff changeset
   138
        else
hgs
parents: 94
diff changeset
   139
            {
hgs
parents: 94
diff changeset
   140
            iStorage->GetParentsIdsL( id, parentArray );
hgs
parents: 94
diff changeset
   141
            }
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   142
        CleanupStack::PopAndDestroy( &id );
7feec50967db 201003_02
hgs
parents:
diff changeset
   143
        }
93
hgs
parents: 86
diff changeset
   144
hgs
parents: 86
diff changeset
   145
    if( aItemAppearanceChange==EItemDisappeared )
hgs
parents: 86
diff changeset
   146
        {
hgs
parents: 86
diff changeset
   147
        changeType = ERemoveChangeType;
hgs
parents: 86
diff changeset
   148
        }
hgs
parents: 86
diff changeset
   149
    else if( aItemAppearanceChange==EItemAppeared )
hgs
parents: 86
diff changeset
   150
        {
hgs
parents: 86
diff changeset
   151
        changeType = EAddChangeType;
hgs
parents: 86
diff changeset
   152
        }
127
hgs
parents: 125
diff changeset
   153
98
hgs
parents: 94
diff changeset
   154
    // do not update entry in db with uninstall progress
hgs
parents: 94
diff changeset
   155
    if (aItemAppearanceChange != EItemUninstallProgressChanged)
hgs
parents: 94
diff changeset
   156
        {
hgs
parents: 94
diff changeset
   157
        RPointerArray<CCaLocalizationEntry> localizations;
hgs
parents: 94
diff changeset
   158
	    CleanupResetAndDestroyPushL( localizations );
hgs
parents: 94
diff changeset
   159
        CCaLocalizationEntry* tempLocalization = NULL;
127
hgs
parents: 125
diff changeset
   160
        if( aEntry->isLocalized( CCaInnerEntry::ENameLocalized ) )
98
hgs
parents: 94
diff changeset
   161
            {
hgs
parents: 94
diff changeset
   162
            tempLocalization = LocalizeTextL( aEntry );
hgs
parents: 94
diff changeset
   163
            if( tempLocalization )
hgs
parents: 94
diff changeset
   164
                {
hgs
parents: 94
diff changeset
   165
                localizations.Append( tempLocalization );
hgs
parents: 94
diff changeset
   166
                tempLocalization = NULL;
hgs
parents: 94
diff changeset
   167
                }
hgs
parents: 94
diff changeset
   168
            }
hgs
parents: 94
diff changeset
   169
        if( aEntry->isLocalized( CCaInnerEntry::EDescriptionLocalized ) )
hgs
parents: 94
diff changeset
   170
            {
hgs
parents: 94
diff changeset
   171
            tempLocalization = LocalizeDescriptionL( aEntry );
hgs
parents: 94
diff changeset
   172
            if (tempLocalization)
hgs
parents: 94
diff changeset
   173
                {
hgs
parents: 94
diff changeset
   174
                localizations.Append(tempLocalization);
hgs
parents: 94
diff changeset
   175
                tempLocalization = NULL;
hgs
parents: 94
diff changeset
   176
                }
hgs
parents: 94
diff changeset
   177
            }
127
hgs
parents: 125
diff changeset
   178
98
hgs
parents: 94
diff changeset
   179
        iStorage->AddL( aEntry, aUpdate );
127
hgs
parents: 125
diff changeset
   180
98
hgs
parents: 94
diff changeset
   181
        for( TInt j =0; j < localizations.Count(); j++ )
hgs
parents: 94
diff changeset
   182
            {
hgs
parents: 94
diff changeset
   183
            localizations[j]->SetRowId( aEntry->GetId() );
hgs
parents: 94
diff changeset
   184
            AddLocalizationL( *( localizations[j] ) );
hgs
parents: 94
diff changeset
   185
            }
hgs
parents: 94
diff changeset
   186
		if( localizations.Count() > 0 )
hgs
parents: 94
diff changeset
   187
            {
hgs
parents: 94
diff changeset
   188
            HbTextResolverSymbian::Init( _L(""), KLocalizationFilepathZ );
hgs
parents: 94
diff changeset
   189
            }
hgs
parents: 94
diff changeset
   190
		 CleanupStack::PopAndDestroy( &localizations );
hgs
parents: 94
diff changeset
   191
        }
127
hgs
parents: 125
diff changeset
   192
    aEntry->SetParentIdsL( parentArray );    
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   193
    for( TInt i = 0; i < iHandlerNotifier.Count(); i++ )
7feec50967db 201003_02
hgs
parents:
diff changeset
   194
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   195
        iHandlerNotifier[i]->EntryChanged( aEntry, changeType, parentArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   196
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   197
    CleanupStack::PopAndDestroy( &parentArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   198
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   199
86
hgs
parents: 85
diff changeset
   200
// ---------------------------------------------------------------------------
hgs
parents: 85
diff changeset
   201
//
hgs
parents: 85
diff changeset
   202
// ---------------------------------------------------------------------------
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   203
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   204
EXPORT_C void CCaStorageProxy::RemoveL( const RArray<TInt>& aEntryIds )
7feec50967db 201003_02
hgs
parents:
diff changeset
   205
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   206
    CCaInnerQuery* query = CCaInnerQuery::NewLC();
7feec50967db 201003_02
hgs
parents:
diff changeset
   207
    query->SetIdsL( aEntryIds );
7feec50967db 201003_02
hgs
parents:
diff changeset
   208
    RPointerArray<CCaInnerEntry> resultContainer;
7feec50967db 201003_02
hgs
parents:
diff changeset
   209
    CleanupResetAndDestroyPushL( resultContainer );
7feec50967db 201003_02
hgs
parents:
diff changeset
   210
    RArray<TInt> parentArray;
7feec50967db 201003_02
hgs
parents:
diff changeset
   211
    CleanupClosePushL( parentArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   212
    if( aEntryIds.Count() > 0 )
7feec50967db 201003_02
hgs
parents:
diff changeset
   213
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   214
        iStorage->GetEntriesL( query, resultContainer );
7feec50967db 201003_02
hgs
parents:
diff changeset
   215
        iStorage->GetParentsIdsL( aEntryIds, parentArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   216
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   217
    iStorage->RemoveL( aEntryIds );
7feec50967db 201003_02
hgs
parents:
diff changeset
   218
    for( TInt i( 0 ); i < resultContainer.Count(); i++ )
7feec50967db 201003_02
hgs
parents:
diff changeset
   219
        {
127
hgs
parents: 125
diff changeset
   220
        resultContainer[i]->SetParentIdsL( parentArray );
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   221
        for( TInt j( 0 ); j < iHandlerNotifier.Count(); j++ )
7feec50967db 201003_02
hgs
parents:
diff changeset
   222
            {
86
hgs
parents: 85
diff changeset
   223
            iHandlerNotifier[j]->EntryChanged( resultContainer[i],
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   224
                    ERemoveChangeType, parentArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   225
            }
7feec50967db 201003_02
hgs
parents:
diff changeset
   226
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   227
    CleanupStack::PopAndDestroy( &parentArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   228
    CleanupStack::PopAndDestroy( &resultContainer );
7feec50967db 201003_02
hgs
parents:
diff changeset
   229
    CleanupStack::PopAndDestroy( query );
7feec50967db 201003_02
hgs
parents:
diff changeset
   230
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   231
86
hgs
parents: 85
diff changeset
   232
// ---------------------------------------------------------------------------
hgs
parents: 85
diff changeset
   233
//
hgs
parents: 85
diff changeset
   234
// ---------------------------------------------------------------------------
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   235
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   236
EXPORT_C void CCaStorageProxy::OrganizeL( const RArray<TInt>& aEntryIds,
7feec50967db 201003_02
hgs
parents:
diff changeset
   237
        TCaOperationParams aParams )
7feec50967db 201003_02
hgs
parents:
diff changeset
   238
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   239
    iStorage->OrganizeL( aEntryIds, aParams );
7feec50967db 201003_02
hgs
parents:
diff changeset
   240
    RArray<TInt> parentArray;
7feec50967db 201003_02
hgs
parents:
diff changeset
   241
    CleanupClosePushL( parentArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   242
    parentArray.AppendL( aParams.iGroupId );
7feec50967db 201003_02
hgs
parents:
diff changeset
   243
    iStorage->GetParentsIdsL( parentArray, parentArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   244
    for( TInt i = 0; i < iHandlerNotifier.Count(); i++ )
7feec50967db 201003_02
hgs
parents:
diff changeset
   245
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   246
        iHandlerNotifier[i]->GroupContentChanged( parentArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   247
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   248
    CleanupStack::PopAndDestroy( &parentArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   249
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   250
86
hgs
parents: 85
diff changeset
   251
// ---------------------------------------------------------------------------
hgs
parents: 85
diff changeset
   252
//
hgs
parents: 85
diff changeset
   253
// ---------------------------------------------------------------------------
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   254
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   255
EXPORT_C void CCaStorageProxy::TouchL( CCaInnerEntry* aEntry )
7feec50967db 201003_02
hgs
parents:
diff changeset
   256
    {
127
hgs
parents: 125
diff changeset
   257
    if( aEntry->GetId() == 0 && aEntry->GetUid() != 0 )
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   258
        {
127
hgs
parents: 125
diff changeset
   259
        CCaInnerQuery* query = CCaInnerQuery::NewLC();
hgs
parents: 125
diff changeset
   260
        query->SetUid( static_cast<TUint>( aEntry->GetUid()) );
hgs
parents: 125
diff changeset
   261
        query->SetFlagsOn( ERemovable );
hgs
parents: 125
diff changeset
   262
        query->SetFlagsOff( EUsed );
86
hgs
parents: 85
diff changeset
   263
127
hgs
parents: 125
diff changeset
   264
        RPointerArray<CCaInnerEntry> resultArray;
hgs
parents: 125
diff changeset
   265
        CleanupClosePushL( resultArray );
hgs
parents: 125
diff changeset
   266
        iStorage->GetEntriesL( query, resultArray );
hgs
parents: 125
diff changeset
   267
        if( resultArray.Count() == 1 )
hgs
parents: 125
diff changeset
   268
            {
hgs
parents: 125
diff changeset
   269
            PrivateTouchL( resultArray[0] );
hgs
parents: 125
diff changeset
   270
            }
hgs
parents: 125
diff changeset
   271
        else
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   272
            {
127
hgs
parents: 125
diff changeset
   273
            User::Leave( KErrNotFound );
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   274
            }
127
hgs
parents: 125
diff changeset
   275
        CleanupStack::PopAndDestroy( &resultArray );
hgs
parents: 125
diff changeset
   276
        CleanupStack::PopAndDestroy( query );
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   277
        }
127
hgs
parents: 125
diff changeset
   278
    else if( aEntry->GetId() > 0 )
hgs
parents: 125
diff changeset
   279
        {
hgs
parents: 125
diff changeset
   280
        PrivateTouchL( aEntry );
hgs
parents: 125
diff changeset
   281
        }
hgs
parents: 125
diff changeset
   282
    else
hgs
parents: 125
diff changeset
   283
        {
hgs
parents: 125
diff changeset
   284
        User::Leave( KErrArgument );
hgs
parents: 125
diff changeset
   285
        }
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   286
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   287
86
hgs
parents: 85
diff changeset
   288
// ---------------------------------------------------------------------------
hgs
parents: 85
diff changeset
   289
//
hgs
parents: 85
diff changeset
   290
// ---------------------------------------------------------------------------
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   291
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   292
EXPORT_C void CCaStorageProxy::GetLocalizationsL(
7feec50967db 201003_02
hgs
parents:
diff changeset
   293
        RPointerArray<CCaLocalizationEntry>& aResultArray )
7feec50967db 201003_02
hgs
parents:
diff changeset
   294
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   295
    iStorage->GetLocalizationsL( aResultArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   296
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   297
86
hgs
parents: 85
diff changeset
   298
// ---------------------------------------------------------------------------
hgs
parents: 85
diff changeset
   299
//
hgs
parents: 85
diff changeset
   300
// ---------------------------------------------------------------------------
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   301
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   302
EXPORT_C void CCaStorageProxy::LocalizeEntryL(
7feec50967db 201003_02
hgs
parents:
diff changeset
   303
        CCaLocalizationEntry& aLocalization )
7feec50967db 201003_02
hgs
parents:
diff changeset
   304
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   305
    iStorage->LocalizeEntryL( aLocalization );
7feec50967db 201003_02
hgs
parents:
diff changeset
   306
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   307
86
hgs
parents: 85
diff changeset
   308
// ---------------------------------------------------------------------------
hgs
parents: 85
diff changeset
   309
//
hgs
parents: 85
diff changeset
   310
// ---------------------------------------------------------------------------
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   311
//
94
hgs
parents: 93
diff changeset
   312
EXPORT_C void CCaStorageProxy::AddLocalizationL(
hgs
parents: 93
diff changeset
   313
		const CCaLocalizationEntry& aLocalization)
hgs
parents: 93
diff changeset
   314
	{
hgs
parents: 93
diff changeset
   315
	iStorage->AddLocalizationL(aLocalization);
hgs
parents: 93
diff changeset
   316
	}
hgs
parents: 93
diff changeset
   317
hgs
parents: 93
diff changeset
   318
// ---------------------------------------------------------------------------
hgs
parents: 93
diff changeset
   319
//
hgs
parents: 93
diff changeset
   320
// ---------------------------------------------------------------------------
hgs
parents: 93
diff changeset
   321
//
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   322
EXPORT_C void CCaStorageProxy::DbPropertyL( const TDesC& aProperty,
7feec50967db 201003_02
hgs
parents:
diff changeset
   323
        TDes& aPropertyValue )
7feec50967db 201003_02
hgs
parents:
diff changeset
   324
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   325
    iStorage->DbPropertyL( aProperty, aPropertyValue );
7feec50967db 201003_02
hgs
parents:
diff changeset
   326
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   327
86
hgs
parents: 85
diff changeset
   328
// ---------------------------------------------------------------------------
hgs
parents: 85
diff changeset
   329
//
hgs
parents: 85
diff changeset
   330
// ---------------------------------------------------------------------------
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   331
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   332
EXPORT_C void CCaStorageProxy::SetDBPropertyL( const TDesC& aProperty,
7feec50967db 201003_02
hgs
parents:
diff changeset
   333
        const TDesC& aPropertyValue )
7feec50967db 201003_02
hgs
parents:
diff changeset
   334
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   335
    iStorage->SetDBPropertyL( aProperty, aPropertyValue );
7feec50967db 201003_02
hgs
parents:
diff changeset
   336
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   337
86
hgs
parents: 85
diff changeset
   338
// ---------------------------------------------------------------------------
hgs
parents: 85
diff changeset
   339
//
hgs
parents: 85
diff changeset
   340
// ---------------------------------------------------------------------------
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   341
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   342
EXPORT_C void CCaStorageProxy::CustomSortL( const RArray<TInt>& aEntryIds,
7feec50967db 201003_02
hgs
parents:
diff changeset
   343
        const TInt aGroupId )
7feec50967db 201003_02
hgs
parents:
diff changeset
   344
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   345
    iStorage->CustomSortL( aEntryIds, aGroupId );
86
hgs
parents: 85
diff changeset
   346
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   347
    RArray<TInt> parentArray;
7feec50967db 201003_02
hgs
parents:
diff changeset
   348
    CleanupClosePushL( parentArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   349
    parentArray.AppendL( aGroupId );
102
hgs
parents: 99
diff changeset
   350
    iStorage->GetParentsIdsL( parentArray, parentArray );
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   351
    for( TInt i = 0; i < iHandlerNotifier.Count(); i++ )
7feec50967db 201003_02
hgs
parents:
diff changeset
   352
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   353
        iHandlerNotifier[i]->GroupContentChanged( parentArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   354
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   355
    CleanupStack::PopAndDestroy( &parentArray );
7feec50967db 201003_02
hgs
parents:
diff changeset
   356
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   357
107
hgs
parents: 102
diff changeset
   358
// ---------------------------------------------------------------------------
hgs
parents: 102
diff changeset
   359
//
hgs
parents: 102
diff changeset
   360
// ---------------------------------------------------------------------------
hgs
parents: 102
diff changeset
   361
//
98
hgs
parents: 94
diff changeset
   362
#ifdef COVERAGE_MEASUREMENT
hgs
parents: 94
diff changeset
   363
#pragma CTC SKIP
hgs
parents: 94
diff changeset
   364
#endif //COVERAGE_MEASUREMENT (calls another method)
107
hgs
parents: 102
diff changeset
   365
hgs
parents: 102
diff changeset
   366
EXPORT_C void CCaStorageProxy::SaveDatabaseL()
hgs
parents: 102
diff changeset
   367
    {
hgs
parents: 102
diff changeset
   368
    iStorage->SaveDatabaseL();
hgs
parents: 102
diff changeset
   369
    }
hgs
parents: 102
diff changeset
   370
#ifdef COVERAGE_MEASUREMENT
hgs
parents: 102
diff changeset
   371
#pragma CTC ENDSKIP
hgs
parents: 102
diff changeset
   372
#endif //COVERAGE_MEASUREMENT
hgs
parents: 102
diff changeset
   373
hgs
parents: 102
diff changeset
   374
86
hgs
parents: 85
diff changeset
   375
// ---------------------------------------------------------------------------
hgs
parents: 85
diff changeset
   376
//
hgs
parents: 85
diff changeset
   377
// ---------------------------------------------------------------------------
hgs
parents: 85
diff changeset
   378
//
107
hgs
parents: 102
diff changeset
   379
#ifdef COVERAGE_MEASUREMENT
hgs
parents: 102
diff changeset
   380
#pragma CTC SKIP
hgs
parents: 102
diff changeset
   381
#endif //COVERAGE_MEASUREMENT (calls another method)
hgs
parents: 102
diff changeset
   382
86
hgs
parents: 85
diff changeset
   383
EXPORT_C void CCaStorageProxy::LoadDataBaseFromRomL()
hgs
parents: 85
diff changeset
   384
    {
hgs
parents: 85
diff changeset
   385
    iStorage->LoadDataBaseFromRomL();
hgs
parents: 85
diff changeset
   386
    }
98
hgs
parents: 94
diff changeset
   387
#ifdef COVERAGE_MEASUREMENT
hgs
parents: 94
diff changeset
   388
#pragma CTC ENDSKIP
hgs
parents: 94
diff changeset
   389
#endif //COVERAGE_MEASUREMENT
86
hgs
parents: 85
diff changeset
   390
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   391
// ---------------------------------------------------------
86
hgs
parents: 85
diff changeset
   392
//
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   393
// ---------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   394
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   395
void CCaStorageProxy::AddSessionL( MCaSessionNorifier* aHandlerNotifier )
7feec50967db 201003_02
hgs
parents:
diff changeset
   396
    {
86
hgs
parents: 85
diff changeset
   397
    __ASSERT_ALWAYS(
hgs
parents: 85
diff changeset
   398
            iHandlerNotifier.Find( aHandlerNotifier ) == KErrNotFound,
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   399
            User::Invariant() );
7feec50967db 201003_02
hgs
parents:
diff changeset
   400
    iHandlerNotifier.AppendL( aHandlerNotifier );
7feec50967db 201003_02
hgs
parents:
diff changeset
   401
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   402
7feec50967db 201003_02
hgs
parents:
diff changeset
   403
// ---------------------------------------------------------
86
hgs
parents: 85
diff changeset
   404
//
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   405
// ---------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   406
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   407
void CCaStorageProxy::RemoveSession( MCaSessionNorifier* aHandlerNotifier )
7feec50967db 201003_02
hgs
parents:
diff changeset
   408
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   409
    TInt i = iHandlerNotifier.Find( aHandlerNotifier );
7feec50967db 201003_02
hgs
parents:
diff changeset
   410
    if( i != KErrNotFound )
7feec50967db 201003_02
hgs
parents:
diff changeset
   411
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   412
        iHandlerNotifier.Remove( i );
7feec50967db 201003_02
hgs
parents:
diff changeset
   413
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   414
    }
98
hgs
parents: 94
diff changeset
   415
hgs
parents: 94
diff changeset
   416
// ---------------------------------------------------------
hgs
parents: 94
diff changeset
   417
//
hgs
parents: 94
diff changeset
   418
// ---------------------------------------------------------
hgs
parents: 94
diff changeset
   419
//
hgs
parents: 94
diff changeset
   420
CCaLocalizationEntry* CCaStorageProxy::LocalizeTextL( CCaInnerEntry* aEntry )
hgs
parents: 94
diff changeset
   421
    {
hgs
parents: 94
diff changeset
   422
	CCaLocalizationEntry* result = NULL;
hgs
parents: 94
diff changeset
   423
	TInt textLength = aEntry->GetText().Length();
125
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   424
	if( textLength > 0 )
98
hgs
parents: 94
diff changeset
   425
		{
hgs
parents: 94
diff changeset
   426
		TChar delimiter = '/'; // cannot add it as global
hgs
parents: 94
diff changeset
   427
		RBuf title;
hgs
parents: 94
diff changeset
   428
		CleanupClosePushL( title );
hgs
parents: 94
diff changeset
   429
		title.CreateL( aEntry->GetText() );
hgs
parents: 94
diff changeset
   430
		TInt pos = title.LocateReverse( delimiter );
hgs
parents: 94
diff changeset
   431
		if ( pos > 0 && pos + 1 < textLength )   // 1 is for delimiters
hgs
parents: 94
diff changeset
   432
			{
127
hgs
parents: 125
diff changeset
   433
			TPtrC16 logString = title.Mid( pos + 1 );
125
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   434
			TInt qmFileNameLength = 
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   435
			        textLength - charsToFilename - 1 - logString.Length();
98
hgs
parents: 94
diff changeset
   436
			TPtrC16 qmFile = title.Mid( charsToFilename, qmFileNameLength );
hgs
parents: 94
diff changeset
   437
			if ( InitializeTranslatorL( qmFile ) )
hgs
parents: 94
diff changeset
   438
				{
127
hgs
parents: 125
diff changeset
   439
			    result = CCaLocalizationEntry::NewLC();
125
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   440
				HBufC* translatedString = 
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   441
				        HbTextResolverSymbian::LoadLC( logString );
98
hgs
parents: 94
diff changeset
   442
				if ( translatedString->Compare( logString ) )
hgs
parents: 94
diff changeset
   443
					{
hgs
parents: 94
diff changeset
   444
					result->SetStringIdL( logString );
hgs
parents: 94
diff changeset
   445
					aEntry->SetTextL( *translatedString );
hgs
parents: 94
diff changeset
   446
					if( translatedString )
hgs
parents: 94
diff changeset
   447
						{
hgs
parents: 94
diff changeset
   448
					    CleanupStack::PopAndDestroy( translatedString );
hgs
parents: 94
diff changeset
   449
						}
hgs
parents: 94
diff changeset
   450
					result->SetTableNameL( KLocalizationCaEntry );
hgs
parents: 94
diff changeset
   451
					result->SetAttributeNameL( KLocalizationEnText );
hgs
parents: 94
diff changeset
   452
					result->SetQmFilenameL( qmFile );
hgs
parents: 94
diff changeset
   453
					result->SetRowId( aEntry->GetId() ? 0 : aEntry->GetId() ); // must be added when present
99
hgs
parents: 98
diff changeset
   454
					CleanupStack::Pop( result );
98
hgs
parents: 94
diff changeset
   455
					}
127
hgs
parents: 125
diff changeset
   456
				else
98
hgs
parents: 94
diff changeset
   457
					{
99
hgs
parents: 98
diff changeset
   458
					CleanupStack::PopAndDestroy(translatedString);
hgs
parents: 98
diff changeset
   459
					CleanupStack::PopAndDestroy(result);
hgs
parents: 98
diff changeset
   460
					result = NULL;
98
hgs
parents: 94
diff changeset
   461
					}
hgs
parents: 94
diff changeset
   462
				}
hgs
parents: 94
diff changeset
   463
			}
hgs
parents: 94
diff changeset
   464
		CleanupStack::PopAndDestroy( &title );
hgs
parents: 94
diff changeset
   465
		}
hgs
parents: 94
diff changeset
   466
	return result;
hgs
parents: 94
diff changeset
   467
	}
hgs
parents: 94
diff changeset
   468
hgs
parents: 94
diff changeset
   469
// ---------------------------------------------------------
hgs
parents: 94
diff changeset
   470
//
hgs
parents: 94
diff changeset
   471
// ---------------------------------------------------------
hgs
parents: 94
diff changeset
   472
//
hgs
parents: 94
diff changeset
   473
CCaLocalizationEntry* CCaStorageProxy::LocalizeDescriptionL( CCaInnerEntry* aEntry )
hgs
parents: 94
diff changeset
   474
    {
hgs
parents: 94
diff changeset
   475
	CCaLocalizationEntry* result = NULL;
hgs
parents: 94
diff changeset
   476
	TInt dscLength = aEntry->GetDescription().Length();
125
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   477
	if( dscLength )
98
hgs
parents: 94
diff changeset
   478
		{
hgs
parents: 94
diff changeset
   479
		TChar delimiter = '/'; // cannot add it as global
hgs
parents: 94
diff changeset
   480
		RBuf description;
hgs
parents: 94
diff changeset
   481
		CleanupClosePushL( description );
hgs
parents: 94
diff changeset
   482
		description.CreateL( aEntry->GetDescription() );
hgs
parents: 94
diff changeset
   483
		TInt pos = description.LocateReverse( delimiter );
hgs
parents: 94
diff changeset
   484
		if ( pos > 0 && pos + 1 < dscLength )   // 1 is for delimiters
hgs
parents: 94
diff changeset
   485
			{
hgs
parents: 94
diff changeset
   486
			TPtrC16 logString = description.Mid(pos + 1);
hgs
parents: 94
diff changeset
   487
			TInt qmFileNameLength = dscLength - charsToFilename - 1 - logString.Length();
hgs
parents: 94
diff changeset
   488
			TPtrC16 qmFile = description.Mid(charsToFilename, qmFileNameLength);
hgs
parents: 94
diff changeset
   489
			if ( InitializeTranslatorL( qmFile ) )
hgs
parents: 94
diff changeset
   490
				{
hgs
parents: 94
diff changeset
   491
			    result = CCaLocalizationEntry::NewLC();
hgs
parents: 94
diff changeset
   492
				HBufC* translatedString = HbTextResolverSymbian::LoadLC( logString );
hgs
parents: 94
diff changeset
   493
				if ( translatedString->Compare( logString ) )
hgs
parents: 94
diff changeset
   494
					{
hgs
parents: 94
diff changeset
   495
					result->SetStringIdL( logString );
hgs
parents: 94
diff changeset
   496
					aEntry->SetDescriptionL( *translatedString );
hgs
parents: 94
diff changeset
   497
					CleanupStack::PopAndDestroy( translatedString );
hgs
parents: 94
diff changeset
   498
					result->SetTableNameL( KLocalizationCaEntry );
hgs
parents: 94
diff changeset
   499
					result->SetAttributeNameL( KLocalizationEnDescription );
hgs
parents: 94
diff changeset
   500
					result->SetQmFilenameL( qmFile );
hgs
parents: 94
diff changeset
   501
					result->SetRowId( aEntry->GetId() ? 0 : aEntry->GetId() ); // must be added when present
99
hgs
parents: 98
diff changeset
   502
					CleanupStack::Pop( result );
98
hgs
parents: 94
diff changeset
   503
					}
127
hgs
parents: 125
diff changeset
   504
				else
98
hgs
parents: 94
diff changeset
   505
					{
hgs
parents: 94
diff changeset
   506
				    CleanupStack::PopAndDestroy( translatedString );
99
hgs
parents: 98
diff changeset
   507
				    CleanupStack::PopAndDestroy( result );
hgs
parents: 98
diff changeset
   508
				    result = NULL;
98
hgs
parents: 94
diff changeset
   509
					}
127
hgs
parents: 125
diff changeset
   510
98
hgs
parents: 94
diff changeset
   511
				}
hgs
parents: 94
diff changeset
   512
			}
hgs
parents: 94
diff changeset
   513
		CleanupStack::PopAndDestroy( &description );
hgs
parents: 94
diff changeset
   514
		}
127
hgs
parents: 125
diff changeset
   515
98
hgs
parents: 94
diff changeset
   516
	return result;
hgs
parents: 94
diff changeset
   517
	}
hgs
parents: 94
diff changeset
   518
hgs
parents: 94
diff changeset
   519
// ---------------------------------------------------------
hgs
parents: 94
diff changeset
   520
//
hgs
parents: 94
diff changeset
   521
// ---------------------------------------------------------
hgs
parents: 94
diff changeset
   522
//
125
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   523
void CCaStorageProxy::AddTitleNameL( CCaInnerEntry* aEntry )
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   524
    {
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   525
    if( !iTitleUserColName.Length() )
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   526
        {
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   527
        if ( InitializeTranslatorL( KCaQmFile ) )
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   528
            {
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   529
            HBufC* translatedString = 
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   530
                    HbTextResolverSymbian::LoadLC( KDefaultLocTitleName );
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   531
            if ( translatedString->Compare( KDefaultLocTitleName ) )
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   532
                {
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   533
                iTitleUserColName.CreateL( *translatedString );
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   534
                }
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   535
            CleanupStack::PopAndDestroy( translatedString );
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   536
            }
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   537
        }
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   538
    if( iTitleUserColName.Length() )
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   539
        {
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   540
        aEntry->AddAttributeL( KCaAttrTitleName, iTitleUserColName );
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   541
        }
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   542
    }
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   543
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   544
// ---------------------------------------------------------
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   545
//
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   546
// ---------------------------------------------------------
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   547
//
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   548
TBool CCaStorageProxy::InitializeTranslatorL( const TDesC& aQmFilename )
98
hgs
parents: 94
diff changeset
   549
    {
hgs
parents: 94
diff changeset
   550
	TBool result = HbTextResolverSymbian::Init( aQmFilename, KLocalizationFilepathC );
hgs
parents: 94
diff changeset
   551
	if ( !result )
hgs
parents: 94
diff changeset
   552
		{
127
hgs
parents: 125
diff changeset
   553
		// this should not be called too often
98
hgs
parents: 94
diff changeset
   554
		TChar currentDriveLetter;
hgs
parents: 94
diff changeset
   555
		TDriveList driveList;
hgs
parents: 94
diff changeset
   556
		RFs fs;
125
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   557
		CleanupClosePushL( fs );
98
hgs
parents: 94
diff changeset
   558
		User::LeaveIfError( fs.Connect() );
hgs
parents: 94
diff changeset
   559
		User::LeaveIfError( fs.DriveList( driveList ) );
hgs
parents: 94
diff changeset
   560
hgs
parents: 94
diff changeset
   561
		RBuf path;
hgs
parents: 94
diff changeset
   562
		CleanupClosePushL( path );
hgs
parents: 94
diff changeset
   563
		path.CreateL( KLocalizationFilepath().Length() + 1 );
hgs
parents: 94
diff changeset
   564
hgs
parents: 94
diff changeset
   565
		for ( TInt driveNr = EDriveY; driveNr >= EDriveA; driveNr-- )
hgs
parents: 94
diff changeset
   566
			{
hgs
parents: 94
diff changeset
   567
			if ( driveList[driveNr] )
hgs
parents: 94
diff changeset
   568
				{
hgs
parents: 94
diff changeset
   569
				User::LeaveIfError(fs.DriveToChar( driveNr, currentDriveLetter ));
hgs
parents: 94
diff changeset
   570
				path.Append( currentDriveLetter );
hgs
parents: 94
diff changeset
   571
				path.Append( KLocalizationFilepath );
hgs
parents: 94
diff changeset
   572
				if (HbTextResolverSymbian::Init( aQmFilename, path ))
hgs
parents: 94
diff changeset
   573
					{
hgs
parents: 94
diff changeset
   574
				    result = ETrue;
hgs
parents: 94
diff changeset
   575
					break;
hgs
parents: 94
diff changeset
   576
					}
hgs
parents: 94
diff changeset
   577
				}
hgs
parents: 94
diff changeset
   578
			path.Zero();
hgs
parents: 94
diff changeset
   579
			}
hgs
parents: 94
diff changeset
   580
		CleanupStack::PopAndDestroy( &path );
125
26079c1bb561 201039_01
hgs
parents: 107
diff changeset
   581
		CleanupStack::PopAndDestroy( &fs );
127
hgs
parents: 125
diff changeset
   582
98
hgs
parents: 94
diff changeset
   583
		if( !result )
hgs
parents: 94
diff changeset
   584
			{
hgs
parents: 94
diff changeset
   585
		    result = HbTextResolverSymbian::Init( aQmFilename, KLocalizationFilepathZ );
hgs
parents: 94
diff changeset
   586
			}
hgs
parents: 94
diff changeset
   587
		}
hgs
parents: 94
diff changeset
   588
	return result;
hgs
parents: 94
diff changeset
   589
	}
127
hgs
parents: 125
diff changeset
   590
hgs
parents: 125
diff changeset
   591
// ---------------------------------------------------------
hgs
parents: 125
diff changeset
   592
//
hgs
parents: 125
diff changeset
   593
// ---------------------------------------------------------
hgs
parents: 125
diff changeset
   594
//
hgs
parents: 125
diff changeset
   595
void CCaStorageProxy::PrivateTouchL( CCaInnerEntry* aEntry )
hgs
parents: 125
diff changeset
   596
    {
hgs
parents: 125
diff changeset
   597
    iStorage->TouchL( aEntry->GetId(), aEntry->GetFlags() & ERemovable );
hgs
parents: 125
diff changeset
   598
    for( TInt i = 0; i < iHandlerNotifier.Count(); i++ )
hgs
parents: 125
diff changeset
   599
        {
hgs
parents: 125
diff changeset
   600
        iHandlerNotifier[i]->EntryTouched( aEntry->GetId() );
hgs
parents: 125
diff changeset
   601
        }
hgs
parents: 125
diff changeset
   602
    if( !( aEntry->GetFlags() & EUsed ) &&
hgs
parents: 125
diff changeset
   603
            ( aEntry->GetFlags() & ERemovable ) )
hgs
parents: 125
diff changeset
   604
        {
hgs
parents: 125
diff changeset
   605
        RArray<TInt> id;
hgs
parents: 125
diff changeset
   606
        CleanupClosePushL( id );
hgs
parents: 125
diff changeset
   607
        id.AppendL( aEntry->GetId() );
hgs
parents: 125
diff changeset
   608
        RArray<TInt> parentArray;
hgs
parents: 125
diff changeset
   609
        CleanupClosePushL( parentArray );
hgs
parents: 125
diff changeset
   610
        iStorage->GetParentsIdsL( id, parentArray );
hgs
parents: 125
diff changeset
   611
        aEntry->SetParentIdsL( parentArray );
hgs
parents: 125
diff changeset
   612
        for( TInt i = 0; i < iHandlerNotifier.Count(); i++ )
hgs
parents: 125
diff changeset
   613
            {
hgs
parents: 125
diff changeset
   614
            aEntry->SetFlags( 
hgs
parents: 125
diff changeset
   615
                    aEntry->GetFlags() | EUsed );
hgs
parents: 125
diff changeset
   616
            iHandlerNotifier[i]->EntryChanged( aEntry,
hgs
parents: 125
diff changeset
   617
                    EUpdateChangeType,
hgs
parents: 125
diff changeset
   618
                    parentArray );
hgs
parents: 125
diff changeset
   619
            }
hgs
parents: 125
diff changeset
   620
        CleanupStack::PopAndDestroy( &parentArray );
hgs
parents: 125
diff changeset
   621
        CleanupStack::PopAndDestroy( &id );
hgs
parents: 125
diff changeset
   622
        }
hgs
parents: 125
diff changeset
   623
    }