activityfw/storage/server/inc/afstorage.h
changeset 104 9b022b1f357c
child 107 b34d53f6acdf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/activityfw/storage/server/inc/afstorage.h	Tue Jul 06 14:37:10 2010 +0300
@@ -0,0 +1,116 @@
+/*
+* Copyright (c) 2009 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:
+*
+*/
+#ifndef AFSTORAGE_H
+#define AFSTORAGE_H
+
+#define __E32SVR_H__
+
+#include <e32std.h>
+#include <e32base.h>
+#include <d32dbms.h>    // RDbStoreDatabase
+#include <s32file.h>    // CFileStore & CPermanentFileStore
+#include "afentry.h"
+
+class CAfStorage : public CBase
+    {
+public:
+    ~CAfStorage();
+
+    static CAfStorage* NewL(RFs& session);
+
+    void AddActivityL(CAfEntry &entry);
+    
+    void UpdateActivityL(CAfEntry &entry);
+
+    void DeleteActivityL(CAfEntry &entry);
+
+    void DeleteActivitiesL(CAfEntry &entry);
+
+    void ActivitiesL(RPointerArray<CAfEntry> &dst);
+
+    void ActivitiesL(RPointerArray<CAfEntry> &dst, TInt appId);
+    
+    void ActivityL(RPointerArray<CAfEntry> &dst, CAfEntry &src);
+
+    RFs& Fs();
+
+    static void ThumbnailPathL(RBuf &dst, 
+                               RFs& fileSystem, 
+                               TInt uid, 
+                               const TDesC &activityName,
+                               TBool persistent);
+
+    static void StoragePathL(RBuf &dst, 
+                             RFs& fileSystem, 
+                             TBool persistent);
+    static void AppStoragePathL(RBuf &dst, 
+                                RFs& fileSystem,
+                                TInt uid,
+                                TBool persistent);
+private:
+    static HBufC8* Md5HexDigestL(const TDesC8 &string);
+    
+private:
+    CAfStorage(RFs& session);
+
+    void ConstructL();
+
+    void CreateDbL(const TDesC& databaseFile);
+
+    void OpenDbL(const TDesC& databaseFile);
+
+    void CreateTableL();
+
+    void DeleteNonPersistentActivitiesL();
+
+    void GetActivitiesL(const TDesC& dst);
+
+    HBufC* SelectRowLC(TInt appId, const TDesC& actId) const;
+
+    HBufC* SelectRowsLC(TInt appId) const;
+
+    HBufC* DeleteRowLC(TInt appId, const TDesC& actId) const;
+    
+    HBufC* DeleteRowsLC(TInt appId) const;
+
+    HBufC* BuildQueryLC(const TDesC& format, TInt appId, const TDesC& actId) const;
+    
+    void ActivitiesL(RPointerArray<CAfEntry>& dst, 
+                     const TDesC& query, 
+                     CAfEntry::AccessRights rights,
+                     TInt limit = 0);
+
+    void ActivitiesL(RPointerArray<CAfEntry>& dst, 
+                     RDbView& query, 
+                     CAfEntry::AccessRights rights,
+                     TInt limit = 0);
+
+    void GetActivityForUpdateL(RDbView& query, TInt appId, const TDesC& actId);
+
+    void ReadDataL(RBuf& dst, RDbRowSet& src, TInt offset) const;
+
+    void ExternalizeDataL(RDbRowSet &dst,const CAfEntry & src, TInt offset) const;
+
+    void InternalizeDataL(CAfEntry &dst, RDbRowSet& src, TInt offset) const;
+
+private:
+    RFs& mFsSession;
+    RDbStoreDatabase mActDb;/* For database operations                 */
+    CFileStore* mFileStore;  /* For creating and opening database files */
+};
+
+#endif //AFSTORAGE_H