contentstorage/srvinc/castorageproxy.h
changeset 60 f62f87b200ec
child 73 4bc7b118b3df
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contentstorage/srvinc/castorageproxy.h	Fri Mar 19 09:35:23 2010 +0200
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Interface for CA database implementations
+ *
+ */
+
+#ifndef CASTORAGEPROXY_H
+#define CASTORAGEPROXY_H
+
+#include "caoperationparams.h"
+
+
+// FORWARD DECLARATIONS
+class CCaStorage;
+class CCaInnerQuery;
+class CCaInnerEntry;
+class CCaLocalizationEntry;
+class MCaSessionNorifier;
+
+/**
+ * Interface for CA database implementations.
+ *
+ */
+class CCaStorageProxy: public CBase
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     */
+    static CCaStorageProxy* NewL();
+
+    /**
+     * Two-phased constructor.
+     */
+    static CCaStorageProxy* NewLC();
+
+    /**
+     * Destructor.
+     */
+    ~CCaStorageProxy();
+
+    /**
+     * Localizes one entry attribute
+     *
+     * @param aLocalization information about one localization row.
+     */
+    IMPORT_C void LocalizeEntryL( CCaLocalizationEntry& aLocalization );
+
+    /**
+     * Fetches localization data from database
+     *
+     * @param aResultContainer Target for results.
+     */
+    IMPORT_C void GetLocalizationsL(
+            RPointerArray<CCaLocalizationEntry>& aResultContainer );
+
+    /**
+     * Fetches data from storage.
+     * @param aQuery Query filter for entries to be fetched.
+     * @param aResult Result entry container.
+     */
+    IMPORT_C void GetEntriesL( const CCaInnerQuery* aQuery,
+            RPointerArray<CCaInnerEntry>& aResultContainer );
+
+    /**
+     * Fetches entry ids from storage.
+     * @param aQuery Query filter for entries' ids to be fetched.
+     * @param aResultIdArray Result entry id array.
+     */
+    IMPORT_C void GetEntriesIdsL( const CCaInnerQuery* aQuery,
+            RArray<TInt>& aResultIdArray );
+
+    /**
+     * Adds or Updates data to storage.
+     * In case when data is added the input aEntry serves
+     * also as an output entry.
+     * @param aEntry Entry data.
+     * @param aUpdate is entry updated by a client
+     */
+    IMPORT_C void AddL( CCaInnerEntry* aEntry, TBool aUpdate = EFalse );
+
+    /**
+     * Removes entries from storage.
+     * @param aEntryIds Ids of entries to be removed.
+     */
+    IMPORT_C void RemoveL( const RArray<TInt>& aEntryIds );
+
+    /**
+     * Organizes entries in storage.
+     * @param aEntryIds Entry ids to be organized
+     * (insert, remove, append, prepend are possible).
+     * @param aParams Organize parameters.
+     */
+    IMPORT_C void OrganizeL( const RArray<TInt>& aEntryIds,
+            TCaOperationParams aParams );
+
+    /**
+     * Executes touch specific actions on storage.
+     * Should be called when e.g. entry is clicked.
+     * @param aEntry entry to be touched
+     */
+    IMPORT_C void TouchL( CCaInnerEntry* aEntry );
+
+    /**
+     * Get database property on storage.
+     *
+     * @param aProperty The property to get.
+     * @param aPropertyValue The value of property.
+     */
+    IMPORT_C void DbPropertyL( const TDesC& aProperty, TDes& aPropertyValue );
+
+    /**
+     * Set property action on storage.
+     *
+     * @param aProperty The property to set.
+     * @param aPropertyValue The value of property.
+     */
+    IMPORT_C void SetDBPropertyL( const TDesC& aProperty,
+            const TDesC& aPropertyValue );
+
+    /**
+     * Organizes data within a group in custom order in storage.
+     *
+     * @param aEntryIds Ids of entries in custom order.
+     * @param aGroupId Group to sort.
+     */
+    IMPORT_C void CustomSortL( const RArray<TInt>& aEntryIds,
+            const TInt aGroupId );
+
+    /**
+     * Loads data base from rom.
+     */
+    IMPORT_C void LoadDataBaseFromRomL();
+
+    /**
+     * Add a session. Ownership not taken, this object only keeps a list of
+     * sessions that are dependent on its engine.
+     * @param aSession Session.
+     */
+    void AddSessionL( MCaSessionNorifier* aHandlerNotifier );
+
+    /**
+     * Remove a session. Safe to call if not added.
+     * When no more sessions remain dependent on this object, timed
+     * self-deletion is scheduled.
+     */
+    void RemoveSession( MCaSessionNorifier* aHandlerNotifier );
+
+private:
+
+    /**
+     * Perform the second phase construction of a CCpStorageEngine object.
+     */
+    void ConstructL();
+
+    /**
+     * C++ default constructor.
+     */
+    CCaStorageProxy();
+
+private:
+    //Data
+
+    /**
+     * Data storage. Own.
+     */
+    CCaStorage* iStorage;
+
+    /**
+     * Sessions using this engine. Own.
+     */
+    RPointerArray<MCaSessionNorifier> iHandlerNotifier;
+    };
+
+#endif //CASTORAGEPROXY_H