|
1 /* |
|
2 * Copyright (c) 2003-2006 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: Factory class for a file system. Allows creating |
|
15 * objects derived from CMountCB, CFileCB, CDirCB and CFormatCB. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "rsfwfilesystem.h" |
|
21 #include <f32ver.h> |
|
22 #include "rsfwfsfilecb.h" |
|
23 #include "rsfwfsdircb.h" |
|
24 #include "rsfwfsmountcb.h" |
|
25 #include "rsfwfsformatcb.h" |
|
26 #include "rsfwinterface.h" |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // static constructor |
|
31 CRsfwFileSystem* CRsfwFileSystem::New() |
|
32 { |
|
33 // non-leaving new, NULL returned for failed creation |
|
34 CRsfwFileSystem *self = new CRsfwFileSystem; |
|
35 return self; |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CRsfwFileSystem::CRsfwFileSystem |
|
40 // C++ default constructor can NOT contain any code, that |
|
41 // might leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CRsfwFileSystem::CRsfwFileSystem() |
|
45 { |
|
46 } |
|
47 |
|
48 // Destructor |
|
49 CRsfwFileSystem::~CRsfwFileSystem() |
|
50 { |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CRsfwFileSystem::Install |
|
55 // Installs the file system. |
|
56 |
|
57 // The function sets the name of the file system object through a call |
|
58 // to CObject::SetName(), thus making it accessible, internally, |
|
59 // using FileSystems->FindByFullName(). This enables the file server |
|
60 // to find and handle installed file systems. The function also sets |
|
61 // unique identifier for the file system and the file system version. |
|
62 // The version is determined by the file system implementation. |
|
63 // It is used in calls to CFileSystem::QueryVersionSupported(). |
|
64 // |
|
65 // (other items were commented in a header). |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 TInt CRsfwFileSystem::Install() |
|
69 { |
|
70 |
|
71 iVersion = TVersion(KF32MajorVersionNumber, |
|
72 KF32MinorVersionNumber, |
|
73 KF32BuildVersionNumber); |
|
74 |
|
75 TTime timeID; |
|
76 timeID.HomeTime(); |
|
77 iUniqueID = I64LOW(timeID.Int64()); |
|
78 |
|
79 return (SetName(&KRemoteFSName)); |
|
80 |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CRsfwFileSystem::Remove |
|
85 // This is called just before the file system object is destroyed, and allows |
|
86 // any clean up to be carried out. |
|
87 // (other items were commented in a header). |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 TInt CRsfwFileSystem::Remove() |
|
91 { |
|
92 |
|
93 return KErrNone; |
|
94 |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CRsfwFileSystem::NewMountL |
|
99 // Creates a new remote mount control block, a CMountCB derived object. |
|
100 // On success, a pointer to the new mount object is returned, |
|
101 // otherwise the function leaves. |
|
102 // |
|
103 // This function is defined as a const function in the base class CFileSystem. |
|
104 // However, we need to pass to the mount class modifiable pointers to |
|
105 // the shared memory chunks used in the parameter passing. That's why we need |
|
106 // to cast away const. |
|
107 // |
|
108 // (other items were commented in a header). |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 CMountCB* CRsfwFileSystem::NewMountL() const |
|
112 { |
|
113 |
|
114 return const_cast<CRsfwFileSystem*>(this)->NewRemoteFsMountL(); |
|
115 |
|
116 } |
|
117 |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CRsfwFileSystem::NewFileL |
|
121 // Creates a new remote file control block, i.e. a CFileCB derived object. |
|
122 // On success, a pointer to the new file object is returned, |
|
123 // otherwise the function leaves. |
|
124 // (other items were commented in a header). |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 CFileCB* CRsfwFileSystem::NewFileL() const |
|
128 { |
|
129 return new(ELeave) CRsfwFsFileCB(); |
|
130 } |
|
131 |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CRsfwFileSystem::NewDirL |
|
135 // Creates a new remote directory control block, i.e. a CDirCB derived object. |
|
136 // On success, a pointer to the new directory control block is returned, |
|
137 // otherwise the function leaves. |
|
138 // (other items were commented in a header). |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 CDirCB* CRsfwFileSystem::NewDirL() const |
|
142 { |
|
143 return(CRsfwFsDirCB::NewL()); |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CRsfwFileSystem::NewFormatL |
|
148 // Creates a new remote volume format control block, i.e. a CFormatCB derived object. |
|
149 // On success, a pointer to the new volume format control block is returned, |
|
150 // otherwise the function leaves. |
|
151 // (other items were commented in a header). |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 CFormatCB* CRsfwFileSystem::NewFormatL() const |
|
155 { |
|
156 return new(ELeave) CRsfwFsFormatCB(); |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CRsfwFileSystem::DriveInfo |
|
161 // Retrieves drive information. |
|
162 // The function assumes that we are not handling different local drives, and |
|
163 // sets anInfo.iMediaAtt, anInfo.iDriveAtt and anInfo.iType to values "sensible" |
|
164 // for remote drives discarding the specified drive number. For local drives |
|
165 // the function would obtain the necessary information by calling the appropriate |
|
166 // TBusLocalDrive::Caps() function using the argument aDriveNumber. |
|
167 |
|
168 // Note that and anInfo.iBatteryState will already have been |
|
169 // set by the calling function. |
|
170 |
|
171 // (other items were commented in a header). |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 void CRsfwFileSystem::DriveInfo( |
|
175 TDriveInfo& anInfo, |
|
176 TInt /* aDriveNumber */) const |
|
177 { |
|
178 |
|
179 anInfo.iType = EMediaRemote; |
|
180 anInfo.iMediaAtt = KMediaAttVariableSize; |
|
181 anInfo.iDriveAtt = KDriveAttRemote; |
|
182 |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CRsfwFileSystem::NewRemoteFsMountL |
|
187 // Creates a new remote mount control block, a CMountCB derived object. |
|
188 // On success, a pointer to the new mount object is returned, |
|
189 // otherwise the function leaves. |
|
190 // (other items were commented in a header). |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 CMountCB* CRsfwFileSystem::NewRemoteFsMountL() |
|
194 { |
|
195 |
|
196 return CRsfwFsMountCB::NewL(); |
|
197 |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CRsfwFileSystem::DefaultPath |
|
202 // Returns the default path for the file system. |
|
203 // Always returns "C:\\". |
|
204 // |
|
205 // Each session with the file server has a current session path. |
|
206 // When a new session is opened, its session path is set to the default path |
|
207 // of the file server. At file server start-up, this default path is set to the |
|
208 // default path returned by the local file system. |
|
209 // The default implementation in the base class raises an "Fserv fault" 31 panic. |
|
210 // |
|
211 // (other items were commented in a header). |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 TInt CRsfwFileSystem::DefaultPath( |
|
215 TDes& aPath) const |
|
216 { |
|
217 |
|
218 _LIT(KDefaultPath, "C:\\"); |
|
219 aPath = KDefaultPath; |
|
220 return (KErrNone); |
|
221 |
|
222 } |
|
223 |