|
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __LOGSERVVIEW_H__ |
|
17 #define __LOGSERVVIEW_H__ |
|
18 |
|
19 #include <logcli.h> |
|
20 #include "LOGQUERY.H" |
|
21 #include "LogCliServShared.h" |
|
22 #include "LogServBackupObserver.h" |
|
23 #include "LogServDatabaseChangeObserver.h" |
|
24 #include "LogServDatabaseTransactionInterface.h" |
|
25 |
|
26 // Classes referenced |
|
27 class CLogPackage; |
|
28 class CLogServViewLockObserver; |
|
29 class CLogServViewChangeManager; |
|
30 class MLogServDatabaseTransactionInterface; |
|
31 class MLogServBackupInterface; |
|
32 |
|
33 /////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
34 ////////////////////// CLogServViewBase ///////////////////////////////////////////////////////////// |
|
35 /////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
36 |
|
37 /** |
|
38 Base class for the view that the LogEng server can create. |
|
39 Implements MLogServBackupObserver and MLogServDatabaseChangeObserver interfaces. |
|
40 |
|
41 @see MLogServBackupObserver |
|
42 @see MLogServDatabaseChangeObserver |
|
43 @internalComponent |
|
44 */ |
|
45 class CLogServViewBase : public CBase, public MLogServBackupObserver, public MLogServDatabaseChangeObserver |
|
46 { |
|
47 public: |
|
48 ~CLogServViewBase(); |
|
49 void RequestChangeNotifications(const RMessage2& aMessage); |
|
50 void RequestChangeNotificationsCancel(); |
|
51 void RequestLockStatusChanges(const RMessage2& aMessage); |
|
52 void RequestLockStatusChangesCancel(); |
|
53 void RequestChangesL(const RMessage2& aMessage); |
|
54 void SetupL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType); |
|
55 virtual TPtrC GetQueryStringL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType)=0; |
|
56 virtual void RemoveL(const RMessage2& aMessage); |
|
57 virtual void ClearDuplicatesL(const RMessage2& aMessage); |
|
58 virtual void SetFlagsL(const RMessage2& aMessage); |
|
59 inline TLogViewId ViewId() const; |
|
60 TInt Count() const; |
|
61 TLogId At(TInt aIndex) const; |
|
62 inline TBool ViewIsReady() const; |
|
63 |
|
64 protected: |
|
65 CLogServViewBase(MLogServDatabaseTransactionInterface& aDatabase, |
|
66 MLogServBackupInterface& aBackupInterface, |
|
67 CLogPackage& aPackage, |
|
68 TLogViewType aType, |
|
69 TLogViewId aViewId, |
|
70 const RMessage2& aMessage); |
|
71 |
|
72 void ConstructL(); |
|
73 static void DestroyList(TAny *aPtr); |
|
74 |
|
75 private: // FROM MLogServDatabaseChangeObserver |
|
76 void DCOHandleChangeEventsL(const CLogChangeDefinition& aChanges); |
|
77 // FROM MLogServBackupObserver |
|
78 void BOHandleEventL(TLogServBackupEvent aEvent); |
|
79 |
|
80 void InitializeColumnsL(RDbRowSet& aRowSet); |
|
81 inline TInt ClientSideCursorPosition() const; |
|
82 // |
|
83 void ResetViewContentsL(RDbRowSet& aRowSet); |
|
84 void PrepareViewContentsL(const TDesC& aSQL); |
|
85 TInt RebuildViewContentsIfNecessary(); |
|
86 void DoHandleChangeEventsL(const CLogChangeDefinition& aChanges); |
|
87 void RebuildViewL(); |
|
88 TBool IsAllowed(TEventOp aEventOp, TUint8 aEventTypeIndex); |
|
89 |
|
90 protected: |
|
91 MLogServDatabaseTransactionInterface& iDatabase; |
|
92 CLogPackage& iPackage; |
|
93 |
|
94 private: |
|
95 MLogServBackupInterface& iBackupInterface; |
|
96 TLogViewType iType;//The type of view that this object represents |
|
97 TLogViewId iViewId;//The id of this view |
|
98 RArray<TLogId> iViewContents;//An array which contains the log ids of all the items in this view |
|
99 TBool iViewContentsReady; |
|
100 HBufC* iSql;//The SQL filter/condition which is used to build this view |
|
101 TBool iRebuildViewContents;//A flag to indicate that we need to rebuild the view because handling a change notification failed (e.g due to OOM). |
|
102 CLogServViewLockObserver* iLockChangeObserver;//Manages lock change events |
|
103 CLogServViewChangeManager* iChangeManager;//Manages change events for this view |
|
104 const RMessage2& iMessage;//Passed in the constructor by the LogServOperationFactory - used to check security |
|
105 /** |
|
106 Data structure for storage of cached security information |
|
107 @internalComponent |
|
108 */ |
|
109 struct SStandardTypeSecurity |
|
110 { |
|
111 TUid eventType; |
|
112 TBool readAccess; |
|
113 TBool writeAccess; |
|
114 }; |
|
115 RArray<SStandardTypeSecurity> iStandardTypeSecurityCache; |
|
116 static TDbColNo iIdColNo; |
|
117 static TDbColNo iTypeColNo; |
|
118 static TDbColNo iFlagColNo[KLogFlagsCount]; |
|
119 |
|
120 }; |
|
121 |
|
122 /** |
|
123 Returns the id of this view |
|
124 */ |
|
125 inline TLogViewId CLogServViewBase::ViewId() const |
|
126 { |
|
127 return iViewId; |
|
128 } |
|
129 |
|
130 /** |
|
131 Is the view ready? |
|
132 */ |
|
133 inline TBool CLogServViewBase::ViewIsReady() const |
|
134 { |
|
135 return (iViewContentsReady && iSql); |
|
136 } |
|
137 |
|
138 /////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
139 ////////////////////// CLogServViewLockObserver //////////////////////////////////////////////////// |
|
140 /////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
141 |
|
142 /** |
|
143 Implements MLogServBackupObserver interface. |
|
144 An instance of this class is data member of CLogServViewBase. |
|
145 It is used every time when the client side requests notification regarding the view status. |
|
146 The view status changes to "locked" during the backup/restore operations. |
|
147 |
|
148 @see CLogServViewBase |
|
149 @see MLogServBackupObserver |
|
150 @internalComponent |
|
151 */ |
|
152 class CLogServViewLockObserver : public CBase, public MLogServBackupObserver |
|
153 { |
|
154 public: |
|
155 static CLogServViewLockObserver* NewL(MLogServBackupInterface& aBackupInterface); |
|
156 ~CLogServViewLockObserver(); |
|
157 void RequestLockStatusChanges(const RMessage2& aMessage); |
|
158 void RequestLockStatusChangesCancel(); |
|
159 |
|
160 private: |
|
161 CLogServViewLockObserver(MLogServBackupInterface& aBackupInterface); |
|
162 void ConstructL(); |
|
163 // FROM MLogServBackupObserver |
|
164 void BOHandleEventL(TLogServBackupEvent aEvent); |
|
165 |
|
166 inline TBool HaveLockStatusChangePointer() const; |
|
167 void CompleteLockStatusChangeMessage(TInt aCompletionCode); |
|
168 |
|
169 private: |
|
170 MLogServBackupInterface& iBackupInterface; |
|
171 RArray<TLogViewLockStatus> iLockEvents;//Holds state changes when the client isn't able to receive them immediately. |
|
172 RMessagePtr2 iLockStatusChangeMessage;//Completed when the view is locked/unlocked |
|
173 |
|
174 }; |
|
175 |
|
176 inline TBool CLogServViewLockObserver::HaveLockStatusChangePointer() const |
|
177 { |
|
178 return (iLockStatusChangeMessage != RMessagePtr2()); |
|
179 } |
|
180 |
|
181 /////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
182 ////////////////////// CLogServViewEvent /////////////////////////////////////////////////////////// |
|
183 /////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
184 |
|
185 /** |
|
186 CLogServViewBase derived class. |
|
187 |
|
188 @see CLogServViewBase |
|
189 @internalComponent |
|
190 */ |
|
191 class CLogServViewEvent : public CLogServViewBase |
|
192 { |
|
193 public: |
|
194 static CLogServViewEvent* NewL(MLogServDatabaseTransactionInterface& aDatabase, |
|
195 MLogServBackupInterface& aBackupInterface, |
|
196 CLogPackage& aPackage, |
|
197 TLogViewId aViewId, |
|
198 const RMessage2& aMessage); |
|
199 |
|
200 TPtrC GetQueryStringL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType); |
|
201 // |
|
202 private: |
|
203 CLogServViewEvent(MLogServDatabaseTransactionInterface& aDatabase, |
|
204 MLogServBackupInterface& aBackupInterface, |
|
205 CLogPackage& aPackage, |
|
206 TLogViewId aViewId, |
|
207 const RMessage2& aMessage); |
|
208 }; |
|
209 |
|
210 |
|
211 /////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
212 ////////////////////// CLogServViewRecent ////////////////////////////////////////////////////////// |
|
213 /////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
214 |
|
215 /** |
|
216 CLogServViewBase derived class. |
|
217 |
|
218 @see CLogServViewBase |
|
219 @internalComponent |
|
220 */ |
|
221 class CLogServViewRecent : public CLogServViewBase |
|
222 { |
|
223 public: |
|
224 static CLogServViewRecent* NewL(MLogServDatabaseTransactionInterface& aDatabase, |
|
225 MLogServBackupInterface& aBackupInterface, |
|
226 CLogPackage& aPackage, |
|
227 TLogViewId aViewId, |
|
228 const RMessage2& aMessage); |
|
229 |
|
230 TPtrC GetQueryStringL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType); |
|
231 void RemoveL(const RMessage2& aMessage); |
|
232 void ClearDuplicatesL(const RMessage2& aMessage); |
|
233 // |
|
234 |
|
235 // |
|
236 private: |
|
237 CLogServViewRecent(MLogServDatabaseTransactionInterface& aDatabase, MLogServBackupInterface& aBackupInterface, CLogPackage& aPackage, TLogViewId aViewId, const RMessage2& aMessage); |
|
238 void InitializeColumns2L(RDbRowSet& aRowSet); |
|
239 // |
|
240 private: |
|
241 TLogRecentList iRecentList; |
|
242 |
|
243 static TDbColNo iIdColNo; |
|
244 static TDbColNo iRecentColNo; |
|
245 static TDbColNo iDuplicateColNo; |
|
246 |
|
247 }; |
|
248 |
|
249 /////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
250 ////////////////////// CLogServViewDuplicate /////////////////////////////////////////////////////// |
|
251 /////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
252 |
|
253 /** |
|
254 CLogServViewBase derived class. |
|
255 |
|
256 @see CLogServViewBase |
|
257 @internalComponent |
|
258 */ |
|
259 class CLogServViewDuplicate : public CLogServViewBase |
|
260 { |
|
261 public: |
|
262 static CLogServViewDuplicate* NewL(MLogServDatabaseTransactionInterface& aDatabase, |
|
263 MLogServBackupInterface& aBackupInterface, |
|
264 CLogPackage& aPackage, |
|
265 TLogViewId aViewId, |
|
266 const RMessage2& aMessage); |
|
267 |
|
268 TPtrC GetQueryStringL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType); |
|
269 void RemoveL(const RMessage2& aMessage); |
|
270 // |
|
271 private: |
|
272 CLogServViewDuplicate(MLogServDatabaseTransactionInterface& aDatabase, |
|
273 MLogServBackupInterface& aBackupInterface, |
|
274 CLogPackage& aPackage, |
|
275 TLogViewId aViewId, |
|
276 const RMessage2& aMessage); |
|
277 // |
|
278 private: |
|
279 TLogId iSourceId; |
|
280 }; |
|
281 |
|
282 #endif |