|
1 /* |
|
2 * Copyright (c) 2002-2004 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: Synchronous layer on top of the Access Protocol plug-in API |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CRSFWREMOTEACCESSSYNC_H |
|
20 #define CRSFWREMOTEACCESSSYNC_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 |
|
25 #include "rsfwremoteaccess.h" |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CRsfwRemoteAccess; |
|
29 |
|
30 // CLASS DECLARATION |
|
31 /** |
|
32 * Class for accessing files via a file transport protocol |
|
33 * by using synchronous calls. |
|
34 * |
|
35 * The derived classes are supposed to be registered and instantiated |
|
36 * by using the the ECOM architecture. |
|
37 */ |
|
38 |
|
39 class CRsfwRemoteAccessSync: public CBase, public MRsfwRemoteAccessResponseHandler |
|
40 { |
|
41 public: |
|
42 /** |
|
43 * Two-phased constructor. |
|
44 * |
|
45 * @param aProtocol protocol name, like "http", "https", or "ftp" |
|
46 * @return a pointer to an object instance that implements |
|
47 * this interface by using the given protocol. |
|
48 */ |
|
49 static CRsfwRemoteAccessSync* NewL(const TDesC8& aProtocol, |
|
50 CRsfwRemoteAccess* aRemoteAccess = NULL); |
|
51 |
|
52 ~CRsfwRemoteAccessSync(); |
|
53 |
|
54 /** |
|
55 * Configures the remote access module. |
|
56 * Sets the connection state observer if available |
|
57 * In davaccess creates the WebDAV session class |
|
58 * |
|
59 * @param aRemoteAccess asynchronous accessor (may be NULL) |
|
60 * @param aRsfwRemoteAccessObserver connection event observer |
|
61 * @return error code |
|
62 */ |
|
63 TInt Setup(MRsfwRemoteAccessObserver* aRsfwRemoteAccessObserver); |
|
64 |
|
65 /** |
|
66 * Opens a connection to the server given by aServerName parameter. |
|
67 * |
|
68 * @param aUserName user name for access control (can be empty) |
|
69 * @param aPassword password for access control (can be empty) |
|
70 * @param aServerName the server's DNS name or IP address |
|
71 * @param aPortNumber port number (like 80 for HTTP) |
|
72 * @param aRootDirectory sub directory to be accessed (can be empty) |
|
73 * @param aAuxData auxiliary parameters for connection setup (IAP info) |
|
74 */ |
|
75 TInt Open(const TDesC& aUserName, |
|
76 const TDesC& aPassword, |
|
77 const TDesC& aServerName, |
|
78 TInt aPortNumber, |
|
79 const TDesC& aRootDirectory, |
|
80 const TDesC& aAuxData); |
|
81 |
|
82 /** |
|
83 * Gets contents of the directory given by aPathName parameter. |
|
84 * |
|
85 * @param aPathName path name of the directory |
|
86 * @param aDirEnts an array of directory entries to be filled. |
|
87 */ |
|
88 TInt GetDirectory(const TDesC& aPathName, |
|
89 RPointerArray<CRsfwDirEnt>& aDirEntsp); |
|
90 |
|
91 /** |
|
92 * Gets attributes of the directory given by aPathName parameter. |
|
93 * This function may also be called if the type of the object is |
|
94 * not yet known (e.g., the object could be a file). |
|
95 * |
|
96 * @param aPathName path name of the directory |
|
97 * @param aAttr attribute structure to be filled |
|
98 */ |
|
99 TInt GetDirectoryAttributes(const TDesC& aPathName, |
|
100 CRsfwDirEntAttr*& aAttr); |
|
101 |
|
102 /** |
|
103 * Gets attributes of the file given by aPathName parameter. |
|
104 * |
|
105 * @param aPathName path name of the file |
|
106 * @param aAttr attribute structure to be filled |
|
107 */ |
|
108 TInt GetFileAttributes(const TDesC& aPathName, |
|
109 CRsfwDirEntAttr*& aAttr); |
|
110 |
|
111 /** |
|
112 * Sets attributes of the file or directory given by aPathName parameter. |
|
113 * This function is typically only used for files and even then |
|
114 * the implementation may do nothing since standard file attributes |
|
115 * are implied by the contents of the file or set in conjunction with |
|
116 * other operations on the file system object. |
|
117 * |
|
118 * @param aPathName path name of the file or directory |
|
119 * @param aAttr attribute structure |
|
120 */ |
|
121 TInt SetAttributes(const TDesC& aPathName, |
|
122 CRsfwDirEntAttr& aAttr); |
|
123 |
|
124 /** |
|
125 * Gets a remote file and copies it to a local file. |
|
126 * Note that byte ranges are not be implemented by all |
|
127 * file access protocols. |
|
128 * |
|
129 * @param aRemotePathName path name of the remote file |
|
130 * @param aLocalPathName path name of the local file |
|
131 * @param aOffset offset of the first byte to be accessed |
|
132 * @param aLength length of data to be accessed/was accessed (0=all) |
|
133 * @param aFlags operation flags (see RemoteAccess.h) |
|
134 */ |
|
135 TInt GetFile(const TDesC& aRemotePathName, |
|
136 const TDesC& aLocalPathName, |
|
137 TInt aOffset, |
|
138 TInt* aLength, |
|
139 TUint aFlags); |
|
140 |
|
141 /** |
|
142 * Makes a directory. |
|
143 * |
|
144 * @param aPathName path name of the new directory |
|
145 */ |
|
146 TInt MakeDirectory(const TDesC& aPathName); |
|
147 |
|
148 |
|
149 /** |
|
150 * Creates an empty file on the remote server |
|
151 * |
|
152 * @param aPathName path name of the new file |
|
153 */ |
|
154 TInt CreateFile(const TDesC& aPathName); |
|
155 |
|
156 /** |
|
157 * Puts a file to the server. |
|
158 * |
|
159 * @param aLocalPathName path name of the local file |
|
160 * @param aRemotePathName path name of the remote file |
|
161 */ |
|
162 TInt PutFile(const TDesC& aLocalPathName, |
|
163 const TDesC& aRemotePathName); |
|
164 |
|
165 /** |
|
166 * Deletes a directory. |
|
167 * |
|
168 * @param aPathName path name of the directory to be deleted |
|
169 */ |
|
170 |
|
171 TInt DeleteDirectory(const TDesC& aPathName); |
|
172 |
|
173 /** |
|
174 * Deletes a file. |
|
175 * |
|
176 * @param aPathName path name of the file to be deleted |
|
177 */ |
|
178 TInt DeleteFile(const TDesC& aPathName); |
|
179 |
|
180 |
|
181 /** |
|
182 * Renames a file or a directory. |
|
183 * (may involve movement to another directory). |
|
184 * |
|
185 * @param aSrcPathName path name of the object to be renamed |
|
186 * @param aDstPathName new path name of the object |
|
187 * @param aOverwrite allow overwriting an existing object |
|
188 */ |
|
189 TInt Rename(const TDesC& aSrcPathName, |
|
190 const TDesC& aDstPathName, |
|
191 TBool aOverwrite); |
|
192 |
|
193 /** |
|
194 * Obtains a lock for the given file system object |
|
195 * Note that this function is not be implemented by all |
|
196 * file access protocols (e.g., FTP), some protocols only |
|
197 * implement write locking (e.g., WebDAV). |
|
198 * |
|
199 * @param aPathName path name of the object to be locked |
|
200 * @param aLockFlags indicates whether a write or read lock is requested |
|
201 * @param aTimeout the timeout that is requested and granted |
|
202 * @param aLockToken acquired lock token - the caller gets ownership |
|
203 */ |
|
204 TInt ObtainLock(const TDesC& aPathName, |
|
205 TUint aLockFlags, |
|
206 TUint& aTimeout, |
|
207 TDesC8*& aLockToken |
|
208 ); |
|
209 |
|
210 /** |
|
211 * Releases the lock of the given file system object |
|
212 * Note that this function is not be implemented by all |
|
213 * file access protocols (e.g., FTP). |
|
214 * |
|
215 * @param aPathName path name of the object to be locked |
|
216 */ |
|
217 TInt ReleaseLock(const TDesC& aPathName); |
|
218 |
|
219 /** |
|
220 * Refreshes the lock of the given file system object |
|
221 * Note that this function is not be implemented by all |
|
222 * file access protocols (e.g., FTP). |
|
223 * |
|
224 * @param aPathName path name of the object to be locked |
|
225 * @param aTimeout the timeout that is requested and granted |
|
226 * @param aResponseHandler response handler |
|
227 */ |
|
228 TInt RefreshLock(const TDesC& aPathName, TUint& aTimeout); |
|
229 |
|
230 // from MRemoteAccessResponseHandler |
|
231 virtual void HandleRemoteAccessResponse(TUint aId, TInt aStatus); |
|
232 |
|
233 /** |
|
234 * Sets lock token for the a given resource |
|
235 * This lock token value replaces any previously cached token value |
|
236 * |
|
237 * @param aPathName path name |
|
238 * @param aLockToken lock token |
|
239 * @return error code |
|
240 */ |
|
241 TInt SetLockToken(const TDesC& aPathName, const TDesC8& aLockToken); |
|
242 |
|
243 private: |
|
244 void ConstructL(const TDesC8& aProtocol, |
|
245 CRsfwRemoteAccess* aRemoteAccess = NULL); |
|
246 TInt Epilog(); |
|
247 |
|
248 |
|
249 private: |
|
250 CRsfwRemoteAccess* iRemoteAccess; |
|
251 TBool iOwnRemoteAccess; // whether we own iRemoteAccess |
|
252 CActiveSchedulerWait* iSchedulerWait; |
|
253 TInt iStatus; // operation return status |
|
254 TBool iPending; // is there a pending request |
|
255 }; |
|
256 |
|
257 #endif // CRSFWREMOTEACCESSSYNC_H |
|
258 |
|
259 // End of File |