1 /* |
|
2 * Copyright (c) 2002-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: Asynchronous File Saving Queue |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef ASYNCHFSQ_H |
|
21 #define ASYNCHFSQ_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <f32file.h> |
|
25 #include <e32base.h> |
|
26 |
|
27 |
|
28 // FOR DEBUGGING |
|
29 #if defined (_DEBUG) |
|
30 #include <e32svr.h> |
|
31 #define LOGTEXT(AAA) RDebug::Print(AAA) |
|
32 #define LOGTEXT2(AAA,BBB) RDebug::Print(AAA,BBB) |
|
33 #define LOGTEXT3(AAA,BBB,CC) RDebug::Print(AAA,BBB,CC) |
|
34 #else |
|
35 #define LOGTEXT(AAA) |
|
36 #define LOGTEXT2(AAA,BBB) |
|
37 #define LOGTEXT3(AAA,BBB,CC) |
|
38 #endif |
|
39 |
|
40 |
|
41 // CONSTANTS |
|
42 |
|
43 // Type of action the FSQ will perform |
|
44 enum TFSQActionType |
|
45 { |
|
46 EFileSave, |
|
47 EWebUpload, |
|
48 EFileSaveAndWebUpload |
|
49 }; |
|
50 |
|
51 // Web service schema definition |
|
52 enum TFSQSchemaType |
|
53 { |
|
54 ENullSchemaType, |
|
55 ENokiaPictureUploadSchema1v0 |
|
56 }; |
|
57 |
|
58 |
|
59 // FORWARD DECLARATIONS |
|
60 class MAsynchFSQObserver; |
|
61 class CAsynchFSQAtom; |
|
62 |
|
63 |
|
64 // CLASS DECLARATIONS |
|
65 |
|
66 /** |
|
67 * CAsynchFSQ observer class. |
|
68 * Mixin base class for the clients of the asynchronous file manager. |
|
69 * |
|
70 * @since 3.2 |
|
71 */ |
|
72 class MAsynchFSQObserver |
|
73 { |
|
74 public: |
|
75 |
|
76 /** |
|
77 * Callback function which gets called after each thread event. |
|
78 * @return void |
|
79 */ |
|
80 virtual void MAsynchFSQEvent( TInt aError ) = 0; |
|
81 |
|
82 }; |
|
83 |
|
84 /** |
|
85 * Asynchronous file manager queue and related operations. |
|
86 * |
|
87 * @since 3.2 |
|
88 */ |
|
89 class CAsynchFSQ : CBase |
|
90 { |
|
91 |
|
92 public: // Constructors and destructor |
|
93 |
|
94 /** |
|
95 * Two-phased constructor. |
|
96 */ |
|
97 IMPORT_C static CAsynchFSQ* NewL(); |
|
98 |
|
99 /** |
|
100 * Destructor. |
|
101 */ |
|
102 virtual ~CAsynchFSQ(); |
|
103 |
|
104 public: // New functions |
|
105 |
|
106 /** |
|
107 * Starts async copy operation |
|
108 */ |
|
109 IMPORT_C TInt SaveAndDestroy( TDesC8& aData, const TDesC& aPath, |
|
110 TBool aOverwrite = ETrue ); |
|
111 |
|
112 /** |
|
113 * Notifies the queue that the client wishes to start the thread manually |
|
114 */ |
|
115 IMPORT_C void SetManualStart( TBool aManualStart ); |
|
116 |
|
117 /** |
|
118 * Starts the saving thread |
|
119 * If iManualStart is not activated, this is essentially a NO-OP |
|
120 */ |
|
121 IMPORT_C TInt Go(); |
|
122 |
|
123 /** |
|
124 * Deletes a file from the file system |
|
125 */ |
|
126 IMPORT_C TInt Delete( const TDesC& aPath ); |
|
127 |
|
128 /** |
|
129 * Renames a file in the file system |
|
130 */ |
|
131 IMPORT_C TInt Rename( const TDesC& aOld, const TDesC& aNew ); |
|
132 |
|
133 /** |
|
134 * Sets the thread priority |
|
135 */ |
|
136 IMPORT_C void SetPriority( TInt aPriority ); |
|
137 |
|
138 /** |
|
139 * Sets the callback |
|
140 */ |
|
141 IMPORT_C void SetCallback( MAsynchFSQObserver* aCallback ); |
|
142 |
|
143 /** |
|
144 * Returns the number of actions left for the queue to perform |
|
145 */ |
|
146 IMPORT_C TInt ActionsLeft(); |
|
147 |
|
148 /** |
|
149 * Cancels any ongoing activity and clears the threads. |
|
150 */ |
|
151 IMPORT_C void Cancel(); |
|
152 |
|
153 /** |
|
154 * Used to indicate a state change from a data atom |
|
155 */ |
|
156 void Notify( TInt aError ); |
|
157 |
|
158 private: |
|
159 |
|
160 /** |
|
161 * C++ default constructor. |
|
162 */ |
|
163 CAsynchFSQ(); |
|
164 |
|
165 /** |
|
166 * By default Symbian 2nd phase constructor is private. |
|
167 */ |
|
168 void ConstructL(); |
|
169 |
|
170 /** |
|
171 * Adds one index to the end of each queue. |
|
172 */ |
|
173 TInt Enqueue( TFSQActionType aActionType, TDesC8& aData, |
|
174 const TDesC& aPath, const TDesC& aURL, |
|
175 TFSQSchemaType aSchema, const TDesC& aUserName, |
|
176 const TDesC& aPassword ); |
|
177 |
|
178 private: // Data |
|
179 |
|
180 // Data queues |
|
181 RPointerArray<CAsynchFSQAtom> iQueue; |
|
182 |
|
183 // Is overwriting allowed? |
|
184 TBool iOverwrite; |
|
185 |
|
186 // Does the client start the activity? |
|
187 TBool iManualStart; |
|
188 |
|
189 // Most recent callback |
|
190 MAsynchFSQObserver* iCallback; |
|
191 |
|
192 // Performance modifiers |
|
193 TInt iPriority; |
|
194 |
|
195 }; |
|
196 |
|
197 #endif // CAsynchFSQ_H |
|