contentstorage/srvsrc/castorageproxy.cpp
changeset 86 e492551a0d54
parent 85 7feec50967db
child 93 82b66994846c
equal deleted inserted replaced
85:7feec50967db 86:e492551a0d54
    34 CCaStorageProxy::CCaStorageProxy()
    34 CCaStorageProxy::CCaStorageProxy()
    35     {
    35     {
    36     }
    36     }
    37 
    37 
    38 // ---------------------------------------------------------------------------
    38 // ---------------------------------------------------------------------------
    39 // 
    39 //
    40 // ---------------------------------------------------------------------------
    40 // ---------------------------------------------------------------------------
    41 //
    41 //
    42 void CCaStorageProxy::ConstructL()
    42 void CCaStorageProxy::ConstructL()
    43     {
    43     {
    44     iStorage = CaStorageFactory::NewDatabaseL();
    44     iStorage = CaStorageFactory::NewDatabaseL();
    85         RPointerArray<CCaInnerEntry>& aResultContainer )
    85         RPointerArray<CCaInnerEntry>& aResultContainer )
    86     {
    86     {
    87     iStorage->GetEntriesL( aQuery, aResultContainer );
    87     iStorage->GetEntriesL( aQuery, aResultContainer );
    88     }
    88     }
    89 
    89 
    90 // -----------------------------------------------------------------------------
    90 // ---------------------------------------------------------------------------
    91 // 
    91 //
    92 // --------------- --------------------------------------------------------------
    92 // ---------------------------------------------------------------------------
    93 //
    93 //
    94 EXPORT_C void CCaStorageProxy::GetEntriesIdsL(const CCaInnerQuery* aQuery,
    94 EXPORT_C void CCaStorageProxy::GetEntriesIdsL(const CCaInnerQuery* aQuery,
    95         RArray<TInt>& aResultIdArray)
    95         RArray<TInt>& aResultIdArray)
    96     {
    96     {
    97     iStorage->GetEntriesIdsL( aQuery, aResultIdArray );
    97     iStorage->GetEntriesIdsL( aQuery, aResultIdArray );
    98     }
    98     }
    99 
    99 
   100 // -----------------------------------------------------------------------------
   100 // ---------------------------------------------------------------------------
   101 // 
   101 //
   102 // --------------- --------------------------------------------------------------
   102 // ---------------------------------------------------------------------------
   103 //
   103 //
   104 EXPORT_C void CCaStorageProxy::AddL( CCaInnerEntry* aEntry, TBool aUpdate )
   104 EXPORT_C void CCaStorageProxy::AddL( CCaInnerEntry* aEntry, TBool aUpdate )
   105     {
   105     {
   106     TChangeType changeType = EAddChangeType;
   106     TChangeType changeType = EAddChangeType;
   107     RArray<TInt> parentArray;
   107     RArray<TInt> parentArray;
   121         iHandlerNotifier[i]->EntryChanged( aEntry, changeType, parentArray );
   121         iHandlerNotifier[i]->EntryChanged( aEntry, changeType, parentArray );
   122         }
   122         }
   123     CleanupStack::PopAndDestroy( &parentArray );
   123     CleanupStack::PopAndDestroy( &parentArray );
   124     }
   124     }
   125 
   125 
   126 // -----------------------------------------------------------------------------
   126 // ---------------------------------------------------------------------------
   127 // 
   127 //
   128 // --------------- --------------------------------------------------------------
   128 // ---------------------------------------------------------------------------
   129 //
   129 //
   130 EXPORT_C void CCaStorageProxy::RemoveL( const RArray<TInt>& aEntryIds )
   130 EXPORT_C void CCaStorageProxy::RemoveL( const RArray<TInt>& aEntryIds )
   131     {
   131     {
   132     CCaInnerQuery* query = CCaInnerQuery::NewLC();
   132     CCaInnerQuery* query = CCaInnerQuery::NewLC();
   133     query->SetIdsL( aEntryIds );
   133     query->SetIdsL( aEntryIds );
   143     iStorage->RemoveL( aEntryIds );
   143     iStorage->RemoveL( aEntryIds );
   144     for( TInt i( 0 ); i < resultContainer.Count(); i++ )
   144     for( TInt i( 0 ); i < resultContainer.Count(); i++ )
   145         {
   145         {
   146         for( TInt j( 0 ); j < iHandlerNotifier.Count(); j++ )
   146         for( TInt j( 0 ); j < iHandlerNotifier.Count(); j++ )
   147             {
   147             {
   148             iHandlerNotifier[j]->EntryChanged( resultContainer[i], 
   148             iHandlerNotifier[j]->EntryChanged( resultContainer[i],
   149                     ERemoveChangeType, parentArray );
   149                     ERemoveChangeType, parentArray );
   150             }
   150             }
   151         }
   151         }
   152     CleanupStack::PopAndDestroy( &parentArray );
   152     CleanupStack::PopAndDestroy( &parentArray );
   153     CleanupStack::PopAndDestroy( &resultContainer );
   153     CleanupStack::PopAndDestroy( &resultContainer );
   154     CleanupStack::PopAndDestroy( query );
   154     CleanupStack::PopAndDestroy( query );
   155     }
   155     }
   156 
   156 
   157 // -----------------------------------------------------------------------------
   157 // ---------------------------------------------------------------------------
   158 // 
   158 //
   159 // --------------- --------------------------------------------------------------
   159 // ---------------------------------------------------------------------------
   160 //
   160 //
   161 EXPORT_C void CCaStorageProxy::OrganizeL( const RArray<TInt>& aEntryIds,
   161 EXPORT_C void CCaStorageProxy::OrganizeL( const RArray<TInt>& aEntryIds,
   162         TCaOperationParams aParams )
   162         TCaOperationParams aParams )
   163     {
   163     {
   164     iStorage->OrganizeL( aEntryIds, aParams );
   164     iStorage->OrganizeL( aEntryIds, aParams );
   171         iHandlerNotifier[i]->GroupContentChanged( parentArray );
   171         iHandlerNotifier[i]->GroupContentChanged( parentArray );
   172         }
   172         }
   173     CleanupStack::PopAndDestroy( &parentArray );
   173     CleanupStack::PopAndDestroy( &parentArray );
   174     }
   174     }
   175 
   175 
   176 // -----------------------------------------------------------------------------
   176 // ---------------------------------------------------------------------------
   177 // 
   177 //
   178 // ------------------------------------------------------------------------------
   178 // ---------------------------------------------------------------------------
   179 //
   179 //
   180 EXPORT_C void CCaStorageProxy::TouchL( CCaInnerEntry* aEntry )
   180 EXPORT_C void CCaStorageProxy::TouchL( CCaInnerEntry* aEntry )
   181     {
   181     {
   182     CCaInnerQuery* touchQuery = CCaInnerQuery::NewLC();
   182     CCaInnerQuery* touchQuery = CCaInnerQuery::NewLC();
   183     
   183 
   184     TInt entryId = aEntry->GetId();
   184     TInt entryId = aEntry->GetId();
   185     
   185 
   186     if ( entryId == 0 && aEntry->GetUid() != 0)
   186     if ( entryId == 0 && aEntry->GetUid() != 0)
   187         {
   187         {
   188         CCaInnerQuery* idQuery = CCaInnerQuery::NewLC();
   188         CCaInnerQuery* idQuery = CCaInnerQuery::NewLC();
   189         idQuery->SetUid( static_cast<TUint>( aEntry->GetUid()) );
   189         idQuery->SetUid( static_cast<TUint>( aEntry->GetUid()) );
   190         
   190 
   191         RArray<TInt> idArray;
   191         RArray<TInt> idArray;
   192         CleanupClosePushL( idArray );
   192         CleanupClosePushL( idArray );
   193         
   193 
   194         iStorage->GetEntriesIdsL( idQuery, idArray );
   194         iStorage->GetEntriesIdsL( idQuery, idArray );
   195         
   195 
   196         if (idArray.Count() == 1 )
   196         if (idArray.Count() == 1 )
   197             {
   197             {
   198             entryId = idArray[0];
   198             entryId = idArray[0];
   199             aEntry->SetId( entryId );
   199             aEntry->SetId( entryId );
   200             } 
   200             }
   201         
   201 
   202         CleanupStack::PopAndDestroy( &idArray );        
   202         CleanupStack::PopAndDestroy( &idArray );
   203         CleanupStack::PopAndDestroy( idQuery );  
   203         CleanupStack::PopAndDestroy( idQuery );
   204         }
   204         }
   205     
   205 
   206     RArray<TInt> id;
   206     RArray<TInt> id;
   207     CleanupClosePushL( id );
   207     CleanupClosePushL( id );
   208     id.AppendL( entryId );
   208     id.AppendL( entryId );
   209     touchQuery->SetIdsL( id );
   209     touchQuery->SetIdsL( id );
   210     RPointerArray<CCaInnerEntry> resultArray;
   210     RPointerArray<CCaInnerEntry> resultArray;
   222             RArray<TInt> parentArray;
   222             RArray<TInt> parentArray;
   223             CleanupClosePushL( parentArray );
   223             CleanupClosePushL( parentArray );
   224             iStorage->GetParentsIdsL( id, parentArray );
   224             iStorage->GetParentsIdsL( id, parentArray );
   225             for( TInt i = 0; i < iHandlerNotifier.Count(); i++ )
   225             for( TInt i = 0; i < iHandlerNotifier.Count(); i++ )
   226                 {
   226                 {
   227                 iHandlerNotifier[i]->EntryChanged( resultArray[0], EUpdateChangeType,
   227                 iHandlerNotifier[i]->EntryChanged( resultArray[0],
       
   228                         EUpdateChangeType,
   228                         parentArray );
   229                         parentArray );
   229                 }
   230                 }
   230             CleanupStack::PopAndDestroy( &parentArray );
   231             CleanupStack::PopAndDestroy( &parentArray );
   231             }
   232             }
   232         }
   233         }
   233     CleanupStack::PopAndDestroy( &resultArray );
   234     CleanupStack::PopAndDestroy( &resultArray );
   234     CleanupStack::PopAndDestroy( &id );
   235     CleanupStack::PopAndDestroy( &id );
   235     CleanupStack::PopAndDestroy( touchQuery );
   236     CleanupStack::PopAndDestroy( touchQuery );
   236     }
   237     }
   237 
   238 
   238 // -----------------------------------------------------------------------------
   239 // ---------------------------------------------------------------------------
   239 // 
   240 //
   240 // ------------------------------------------------------------------------------
   241 // ---------------------------------------------------------------------------
   241 //
   242 //
   242 EXPORT_C void CCaStorageProxy::GetLocalizationsL(
   243 EXPORT_C void CCaStorageProxy::GetLocalizationsL(
   243         RPointerArray<CCaLocalizationEntry>& aResultArray )
   244         RPointerArray<CCaLocalizationEntry>& aResultArray )
   244     {
   245     {
   245     iStorage->GetLocalizationsL( aResultArray );
   246     iStorage->GetLocalizationsL( aResultArray );
   246     }
   247     }
   247 
   248 
   248 // -----------------------------------------------------------------------------
   249 // ---------------------------------------------------------------------------
   249 // 
   250 //
   250 // ------------------------------------------------------------------------------
   251 // ---------------------------------------------------------------------------
   251 //
   252 //
   252 EXPORT_C void CCaStorageProxy::LocalizeEntryL(
   253 EXPORT_C void CCaStorageProxy::LocalizeEntryL(
   253         CCaLocalizationEntry& aLocalization )
   254         CCaLocalizationEntry& aLocalization )
   254     {
   255     {
   255     iStorage->LocalizeEntryL( aLocalization );
   256     iStorage->LocalizeEntryL( aLocalization );
   256     }
   257     }
   257 
   258 
   258 // -----------------------------------------------------------------------------
   259 // ---------------------------------------------------------------------------
   259 // 
   260 //
   260 // ------------------------------------------------------------------------------
   261 // ---------------------------------------------------------------------------
   261 //
   262 //
   262 EXPORT_C void CCaStorageProxy::DbPropertyL( const TDesC& aProperty,
   263 EXPORT_C void CCaStorageProxy::DbPropertyL( const TDesC& aProperty,
   263         TDes& aPropertyValue )
   264         TDes& aPropertyValue )
   264     {
   265     {
   265     iStorage->DbPropertyL( aProperty, aPropertyValue );
   266     iStorage->DbPropertyL( aProperty, aPropertyValue );
   266     }
   267     }
   267 
   268 
   268 // -----------------------------------------------------------------------------
   269 // ---------------------------------------------------------------------------
   269 // 
   270 //
   270 // ------------------------------------------------------------------------------
   271 // ---------------------------------------------------------------------------
   271 //
   272 //
   272 EXPORT_C void CCaStorageProxy::SetDBPropertyL( const TDesC& aProperty,
   273 EXPORT_C void CCaStorageProxy::SetDBPropertyL( const TDesC& aProperty,
   273         const TDesC& aPropertyValue )
   274         const TDesC& aPropertyValue )
   274     {
   275     {
   275     iStorage->SetDBPropertyL( aProperty, aPropertyValue );
   276     iStorage->SetDBPropertyL( aProperty, aPropertyValue );
   276     }
   277     }
   277 
   278 
   278 // -----------------------------------------------------------------------------
   279 // ---------------------------------------------------------------------------
   279 // 
   280 //
   280 // ------------------------------------------------------------------------------
   281 // ---------------------------------------------------------------------------
   281 //
   282 //
   282 EXPORT_C void CCaStorageProxy::CustomSortL( const RArray<TInt>& aEntryIds,
   283 EXPORT_C void CCaStorageProxy::CustomSortL( const RArray<TInt>& aEntryIds,
   283         const TInt aGroupId )
   284         const TInt aGroupId )
   284     {
   285     {
   285     iStorage->CustomSortL( aEntryIds, aGroupId );
   286     iStorage->CustomSortL( aEntryIds, aGroupId );
   286     
   287 
   287     RArray<TInt> parentArray;
   288     RArray<TInt> parentArray;
   288     CleanupClosePushL( parentArray );
   289     CleanupClosePushL( parentArray );
   289     parentArray.AppendL( aGroupId );
   290     parentArray.AppendL( aGroupId );
   290     for( TInt i = 0; i < iHandlerNotifier.Count(); i++ )
   291     for( TInt i = 0; i < iHandlerNotifier.Count(); i++ )
   291         {
   292         {
   292         iHandlerNotifier[i]->GroupContentChanged( parentArray );
   293         iHandlerNotifier[i]->GroupContentChanged( parentArray );
   293         }
   294         }
   294     CleanupStack::PopAndDestroy( &parentArray );
   295     CleanupStack::PopAndDestroy( &parentArray );
   295     }
   296     }
   296 
   297 
       
   298 // ---------------------------------------------------------------------------
       
   299 //
       
   300 // ---------------------------------------------------------------------------
       
   301 //
       
   302 EXPORT_C void CCaStorageProxy::LoadDataBaseFromRomL()
       
   303     {
       
   304     iStorage->LoadDataBaseFromRomL();
       
   305     }
       
   306 
   297 // ---------------------------------------------------------
   307 // ---------------------------------------------------------
   298 // 
   308 //
   299 // ---------------------------------------------------------
   309 // ---------------------------------------------------------
   300 //
   310 //
   301 void CCaStorageProxy::AddSessionL( MCaSessionNorifier* aHandlerNotifier )
   311 void CCaStorageProxy::AddSessionL( MCaSessionNorifier* aHandlerNotifier )
   302     {
   312     {
   303     __ASSERT_ALWAYS( iHandlerNotifier.Find( aHandlerNotifier ) == KErrNotFound,
   313     __ASSERT_ALWAYS(
       
   314             iHandlerNotifier.Find( aHandlerNotifier ) == KErrNotFound,
   304             User::Invariant() );
   315             User::Invariant() );
   305     iHandlerNotifier.AppendL( aHandlerNotifier );
   316     iHandlerNotifier.AppendL( aHandlerNotifier );
   306     }
   317     }
   307 
   318 
   308 // ---------------------------------------------------------
   319 // ---------------------------------------------------------
   309 // 
   320 //
   310 // ---------------------------------------------------------
   321 // ---------------------------------------------------------
   311 //
   322 //
   312 void CCaStorageProxy::RemoveSession( MCaSessionNorifier* aHandlerNotifier )
   323 void CCaStorageProxy::RemoveSession( MCaSessionNorifier* aHandlerNotifier )
   313     {
   324     {
   314     TInt i = iHandlerNotifier.Find( aHandlerNotifier );
   325     TInt i = iHandlerNotifier.Find( aHandlerNotifier );