|
1 /* |
|
2 * Copyright (c) 2007-2007 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: CCFPersistentData class declaration. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CFPERSISTENTDATA_H |
|
20 #define C_CFPERSISTENTDATA_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <e32property.h> |
|
25 #include "cfoperationnode.h" |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class RFs; |
|
29 class CCFPendingPersistencyTask; |
|
30 |
|
31 // CLASS DECLARATION |
|
32 |
|
33 /** |
|
34 * This class implements persistent data for Context Framework Scripts. |
|
35 * |
|
36 * @lib CFScriptEngine |
|
37 * @since S60 v5.0 |
|
38 */ |
|
39 NONSHARABLE_CLASS( CCFPersistentData ) : public CActive |
|
40 { |
|
41 public: // Constructors and destructor |
|
42 |
|
43 /** |
|
44 * Creates a CCFPersistentData object. |
|
45 * @return a pointer to the created instance of CCFPersistentData. |
|
46 */ |
|
47 static CCFPersistentData* NewL( RFs& aFs, |
|
48 const TUid& aOwner, |
|
49 const TDesC& aName ); |
|
50 |
|
51 /** |
|
52 * Creates a CCFPersistentData object. |
|
53 * @return a pointer to the created instance of CCFPersistentData. |
|
54 */ |
|
55 static CCFPersistentData* NewLC( RFs& aFs, |
|
56 const TUid& aOwner, |
|
57 const TDesC& aName ); |
|
58 |
|
59 /** |
|
60 * Destructor. |
|
61 */ |
|
62 ~CCFPersistentData(); |
|
63 |
|
64 public: // From MCFPersistentDataInterface |
|
65 |
|
66 /** |
|
67 * Restores operation data from a persistent file. If the file exists |
|
68 * InternalizeL is called for the operation. |
|
69 * @param aFile is the persistent file containing operation data. |
|
70 * @param aOperation is the operation to be restored. |
|
71 * @return None. |
|
72 */ |
|
73 void RestoreL( const TDesC& aFile, |
|
74 CCFOperationNode& aOperation ); |
|
75 |
|
76 /** |
|
77 * Stores operation data into a persistent file. If the file exists |
|
78 * the old data is replaced by calling ExternalizeL for the operation. |
|
79 * @param aFile is the persistent file for operation data. |
|
80 * @param aOperation is the operation to be stored. |
|
81 * @return None. |
|
82 */ |
|
83 void StoreL( const TDesC& aFile, |
|
84 CCFOperationNode& aOperation ); |
|
85 |
|
86 /** |
|
87 * Delete persistent file. |
|
88 */ |
|
89 void Delete( const TDesC& aFile ); |
|
90 |
|
91 private: |
|
92 |
|
93 // Rstores a persistent data from disk |
|
94 void DoRestoreL( const TDesC& aFile, CCFOperationNode& aOperation ); |
|
95 |
|
96 // Stores a persistent data in to disk |
|
97 void DoStoreL( const TDesC& aFile, CCFOperationNode& aOperation ); |
|
98 |
|
99 // Deletes a persistent file from disk |
|
100 void DoDelete( const TDesC& aFile ); |
|
101 |
|
102 // Process the pending tasks queue |
|
103 void ProcessPendingTasksL(); |
|
104 |
|
105 private: |
|
106 |
|
107 /** |
|
108 * C++ default constructor. |
|
109 */ |
|
110 CCFPersistentData( RFs& aFs, const TUid& aOwner, const TDesC& aName ); |
|
111 |
|
112 /** |
|
113 * By default Symbian 2nd phase constructor is private. |
|
114 */ |
|
115 void ConstructL(); |
|
116 |
|
117 private: // From CActive |
|
118 // Handle completion |
|
119 void RunL(); |
|
120 |
|
121 // How to cancel me |
|
122 void DoCancel(); |
|
123 |
|
124 // Override to handle leaves from RunL(). Default implementation causes |
|
125 // the active scheduler to panic. |
|
126 TInt RunError( TInt aError ); |
|
127 |
|
128 private: // New functions |
|
129 |
|
130 /** |
|
131 * Creates stream name based on owner uid and file name. |
|
132 */ |
|
133 HBufC* CreateStreamName( const TDesC& aFile ); |
|
134 |
|
135 /** |
|
136 * Starts listenging back up events. |
|
137 */ |
|
138 void StartListeningL(); |
|
139 |
|
140 private: // Data |
|
141 |
|
142 // Active file server session. |
|
143 RFs& iFs; |
|
144 |
|
145 // Owner of the script |
|
146 TUid iOwner; |
|
147 |
|
148 // Script name |
|
149 TPtrC iName; |
|
150 |
|
151 // Own: pending persistency tasks |
|
152 RPointerArray<CCFPendingPersistencyTask> iPendingTasks; |
|
153 |
|
154 // is persistency operations allowed |
|
155 TBool iStoreRestoreDenied; |
|
156 |
|
157 // Handler to backup property |
|
158 RProperty iProperty; |
|
159 }; |
|
160 |
|
161 #endif // C_CFPERSISTENTDATA_H |
|
162 |