93
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#ifndef ACTIVITYSTORAGE_H
|
|
18 |
#define ACTIVITYSTORAGE_H
|
|
19 |
|
|
20 |
#define __E32SVR_H__
|
|
21 |
|
|
22 |
#include <e32std.h>
|
|
23 |
#include <e32base.h>
|
|
24 |
#include <d32dbms.h> // RDbStoreDatabase
|
|
25 |
#include <s32file.h> // CFileStore & CPermanentFileStore
|
|
26 |
|
|
27 |
/**
|
|
28 |
* CActivityStorage
|
|
29 |
*
|
|
30 |
*/
|
|
31 |
class CActivityStorage : public CBase
|
|
32 |
{
|
|
33 |
public:
|
|
34 |
/**
|
|
35 |
* Destructor.
|
|
36 |
*/
|
|
37 |
~CActivityStorage();
|
|
38 |
|
|
39 |
/**
|
|
40 |
* Two-phased constructor.
|
|
41 |
* @param session - initialized session to file system
|
|
42 |
*/
|
|
43 |
static CActivityStorage* NewL(RFs& session);
|
|
44 |
|
|
45 |
/**
|
|
46 |
* Register new activity
|
|
47 |
* @param appId - application id
|
|
48 |
* @param actId - activity id
|
|
49 |
* @param data - activity data
|
|
50 |
*/
|
|
51 |
void AddActivityL(TInt appId,const TDesC8& actId, const TDesC8& data);
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Update activity
|
|
55 |
* @param appId - application id
|
|
56 |
* @param actId - activity id
|
|
57 |
* @param data - activity data
|
|
58 |
*/
|
|
59 |
void UpdateActivityL(TInt appId,const TDesC8& actId, const TDesC8& data);
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Delete activity
|
|
63 |
* @param appId - application id
|
|
64 |
* @param actId - activity id
|
|
65 |
*/
|
|
66 |
void DeleteActivityL(TInt appId,const TDesC8& actId);
|
|
67 |
|
|
68 |
/**
|
|
69 |
* Delete activity
|
|
70 |
* @param appId - application id
|
|
71 |
*/
|
|
72 |
void DeleteActivitiesL(TInt appId);
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Serialize all activity into the buffer
|
|
76 |
* @param dst - destination buffer
|
|
77 |
*/
|
|
78 |
void ActivitiesL(RBuf8 &dst);
|
|
79 |
|
|
80 |
/**
|
|
81 |
* Serialize application activity into the buffer
|
|
82 |
* @param dst - destination buffer
|
|
83 |
* @param appId - application id
|
|
84 |
*/
|
|
85 |
void ActivitiesL(RBuf8 &dst, TInt appId);
|
|
86 |
|
|
87 |
private:
|
|
88 |
/**
|
|
89 |
* Constructor for performing 1st stage construction
|
|
90 |
* @param session - initialized session to file system
|
|
91 |
*/
|
|
92 |
CActivityStorage(RFs& session);
|
|
93 |
|
|
94 |
/**
|
|
95 |
* EPOC default constructor for performing 2nd stage construction
|
|
96 |
*/
|
|
97 |
void ConstructL();
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Create database and its structure
|
|
101 |
* @param databaseFile - database file path
|
|
102 |
*/
|
|
103 |
void CreateDbL(const TDesC& databaseFile);
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Open database
|
|
107 |
* @param databaseFile - database file path
|
|
108 |
*/
|
|
109 |
void OpenDbL(const TDesC& databaseFile);
|
|
110 |
|
|
111 |
/**
|
|
112 |
* Create database structure
|
|
113 |
*/
|
|
114 |
void CreateTableL();
|
|
115 |
|
|
116 |
/**
|
|
117 |
* Serialize activity into buffer
|
|
118 |
* @param dst - destination buffer
|
|
119 |
*/
|
|
120 |
void GetActivitiesL(const TDesC& dst);
|
|
121 |
|
|
122 |
/**
|
|
123 |
* Format query to select activity row
|
|
124 |
* @param appId - application id
|
|
125 |
* @param actId - activity id
|
|
126 |
* @return formated sql query
|
|
127 |
*/
|
|
128 |
HBufC* SelectRowLC(TInt appId, const TDesC8& actId) const;
|
|
129 |
|
|
130 |
/**
|
|
131 |
* Format query to select activities for application
|
|
132 |
* @param appId - application id
|
|
133 |
* @return formated sql query
|
|
134 |
*/
|
|
135 |
HBufC* SelectRowsLC(TInt appId) const;
|
|
136 |
|
|
137 |
/**
|
|
138 |
* Format query to delete activity
|
|
139 |
* @param appId - application id
|
|
140 |
* @param actId - activity id
|
|
141 |
* @return formated sql query
|
|
142 |
*/
|
|
143 |
HBufC* DeleteRowLC(TInt appId, const TDesC8& actId) const;
|
|
144 |
|
|
145 |
/**
|
|
146 |
* Format query to delete activities for application
|
|
147 |
* @param appId - application id
|
|
148 |
* @return formated sql query
|
|
149 |
*/
|
|
150 |
HBufC* DeleteRowsLC(TInt appId) const;
|
|
151 |
|
|
152 |
/**
|
|
153 |
* Format sql query
|
|
154 |
* @format - sql format string
|
|
155 |
* @param appId - application id
|
|
156 |
* @param actId - activity id
|
|
157 |
* @return formated sql query
|
|
158 |
*/
|
|
159 |
HBufC* BuildQueryLC(const TDesC& format, TInt appId, const TDesC8& actId) const;
|
|
160 |
|
|
161 |
/**
|
|
162 |
* Count require buffer size to serialize activity query result
|
|
163 |
* @param data - sql query result
|
|
164 |
* @return reuired buffer size to seriazlie activity
|
|
165 |
*/
|
|
166 |
TInt DataSizeL(RDbRowSet& data)const;
|
|
167 |
|
|
168 |
/**
|
|
169 |
* Serialize activity query result to preallocated buffer
|
|
170 |
* @param dst - preallocated buffer
|
|
171 |
* @param view - sql query result
|
|
172 |
*/
|
|
173 |
void ExternalizeL(TDes8& dst, RDbRowSet& view)const;
|
|
174 |
|
|
175 |
/**
|
|
176 |
* Execute sql query and result serialize into buffer
|
|
177 |
* @param dst - destination result buffer
|
|
178 |
* @param query - sql activity query
|
|
179 |
*/
|
|
180 |
void ActivitiesL(RBuf8& dst, const TDesC& query);
|
|
181 |
|
|
182 |
/**
|
|
183 |
* Get activity for update
|
|
184 |
* @param query - destination query result
|
|
185 |
* @param appId - application id
|
|
186 |
* @param actId - activity id
|
|
187 |
*/
|
|
188 |
void GetActivityForUpdateL(RDbView& query, TInt appId, const TDesC8& actId);
|
|
189 |
|
|
190 |
private:
|
|
191 |
RFs& mFsSession;
|
|
192 |
RDbStoreDatabase mActDb;/* For database operations */
|
|
193 |
CFileStore* mFileStore; /* For creating and opening database files */
|
|
194 |
};
|
|
195 |
|
|
196 |
#endif // ACTIVITYSTORAGE_H
|