1 /* |
|
2 * Copyright (c) 2006-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: Wraps remote drive functionality |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include <rsfwmountman.h> |
|
22 #include "CFileManagerRemoteDriveHandler.h" |
|
23 #include "CGflmNavigatorModel.h" |
|
24 #include "CFileManagerEngine.h" |
|
25 #include "CFileManagerPropertySubscriber.h" |
|
26 #include "CFileManagerUtils.h" |
|
27 #include "FileManagerDebug.h" |
|
28 #include "CFileManagerFeatureManager.h" |
|
29 |
|
30 |
|
31 // ======== MEMBER FUNCTIONS ======== |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CFileManagerRemoteDriveHandler::CFileManagerRemoteDriveHandler() |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CFileManagerRemoteDriveHandler::CFileManagerRemoteDriveHandler( |
|
38 CFileManagerEngine& aEngine, |
|
39 CFileManagerUtils& aUtils ) : |
|
40 iEngine( aEngine ), |
|
41 iUtils( aUtils ) |
|
42 { |
|
43 FUNC_LOG |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CFileManagerRemoteDriveHandler::NewL( const CFileManagerEngine& aEngine ) |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CFileManagerRemoteDriveHandler* CFileManagerRemoteDriveHandler::NewL( |
|
51 CFileManagerEngine& aEngine, |
|
52 CFileManagerUtils& aUtils ) |
|
53 { |
|
54 FUNC_LOG |
|
55 |
|
56 CFileManagerRemoteDriveHandler* self = |
|
57 new (ELeave) CFileManagerRemoteDriveHandler( |
|
58 aEngine, aUtils ); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 CleanupStack::Pop( self ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CFileManagerRemoteDriveHandler::~CFileManagerRemoteDriveHandler() |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CFileManagerRemoteDriveHandler::~CFileManagerRemoteDriveHandler() |
|
70 { |
|
71 FUNC_LOG |
|
72 |
|
73 delete iMountMan; |
|
74 delete iSubscriber; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CFileManagerRemoteDriveHandler::ConstructL() |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CFileManagerRemoteDriveHandler::ConstructL() |
|
82 { |
|
83 FUNC_LOG |
|
84 |
|
85 // Check and set value to indicate if the feature is supported |
|
86 iRemoteStorageFwSupported = |
|
87 iEngine.FeatureManager().IsRemoteStorageFwSupported(); |
|
88 if ( !iRemoteStorageFwSupported ) |
|
89 { |
|
90 return; |
|
91 } |
|
92 iMountMan = CRsfwMountMan::NewL( 0, NULL ); |
|
93 #ifdef FILE_MANAGER_MOUNT_REMOTE_DRIVES_ON_STARTUP |
|
94 // Make sure that remote drives are mounted |
|
95 _LIT( KMounterExe, "rsfwbootmounter.exe" ); |
|
96 RProcess mounter; |
|
97 if ( mounter.Create( KMounterExe, KNullDesC ) == KErrNone ) |
|
98 { |
|
99 mounter.Resume(); |
|
100 mounter.Close(); |
|
101 } |
|
102 #endif // FILE_MANAGER_MOUNT_REMOTE_DRIVES_ON_STARTUP |
|
103 iSubscriber = CFileManagerPropertySubscriber::NewL( |
|
104 *this, KRfeServerSecureUid, ERsfwPSKeyConnect ); |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // CFileManagerRemoteDriveHandler::IsConnected() |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 TBool CFileManagerRemoteDriveHandler::IsConnected( const TInt aDrive ) |
|
112 { |
|
113 FUNC_LOG |
|
114 |
|
115 if ( !iRemoteStorageFwSupported ) |
|
116 { |
|
117 return EFalse; |
|
118 } |
|
119 TBool ret( EFalse ); |
|
120 TChar drv( 0 ); |
|
121 if ( RFs::DriveToChar( aDrive, drv ) == KErrNone ) |
|
122 { |
|
123 TRsfwMountInfo info; |
|
124 if ( iMountMan->GetMountInfo( drv, info ) == KErrNone ) |
|
125 { |
|
126 ret = ( info.iMountStatus.iConnectionState == |
|
127 KMountStronglyConnected ); |
|
128 } |
|
129 } |
|
130 return ret; |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CFileManagerRemoteDriveHandler::SetConnection() |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 TInt CFileManagerRemoteDriveHandler::SetConnection( |
|
138 TInt aDrive, TBool aConnect ) |
|
139 { |
|
140 FUNC_LOG |
|
141 |
|
142 if ( !iRemoteStorageFwSupported ) |
|
143 { |
|
144 return KErrNone; |
|
145 } |
|
146 TChar drv( 0 ); |
|
147 TInt err( RFs::DriveToChar( aDrive, drv ) ); |
|
148 if ( err != KErrNone ) |
|
149 { |
|
150 return err; |
|
151 } |
|
152 err = iMountMan->SetMountConnectionStateBlind( |
|
153 drv, |
|
154 aConnect ? KMountStronglyConnected : KMountNotConnected ); |
|
155 if ( err == KErrCancel ) |
|
156 { |
|
157 err = KErrPathNotFound; |
|
158 } |
|
159 return err; |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // CFileManagerRemoteDriveHandler::DeleteSettings() |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 TInt CFileManagerRemoteDriveHandler::DeleteSettings( |
|
167 const TInt aDrive ) |
|
168 { |
|
169 FUNC_LOG |
|
170 |
|
171 if ( !iRemoteStorageFwSupported ) |
|
172 { |
|
173 return KErrNone; |
|
174 } |
|
175 TChar drv( 0 ); |
|
176 TInt err( RFs::DriveToChar( aDrive, drv ) ); |
|
177 if ( err != KErrNone ) |
|
178 { |
|
179 return err; |
|
180 } |
|
181 TRAP( err, iMountMan->DeleteMountEntryL( drv ) ); |
|
182 return err; |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CFileManagerRemoteDriveHandler::PropertyChangedL() |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 void CFileManagerRemoteDriveHandler::PropertyChangedL( |
|
190 const TUid& /*aCategory*/, const TUint /*aKey*/ ) |
|
191 { |
|
192 FUNC_LOG |
|
193 |
|
194 iEngine.DriveAddedOrChangedL(); |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------------------------- |
|
198 // CFileManagerRemoteDriveHandler::RefreshDirectory() |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 TInt CFileManagerRemoteDriveHandler::RefreshDirectory( |
|
202 const TDesC& aFullPath ) |
|
203 { |
|
204 FUNC_LOG |
|
205 |
|
206 if ( !iRemoteStorageFwSupported ) |
|
207 { |
|
208 return KErrNone; |
|
209 } |
|
210 return iMountMan->RefreshDirectory( aFullPath ); |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // CFileManagerRemoteDriveHandler::HasAppRemoteDriveSupport() |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 TBool CFileManagerRemoteDriveHandler::HasAppRemoteDriveSupport( |
|
218 TUid aUid ) |
|
219 { |
|
220 FUNC_LOG |
|
221 |
|
222 if ( !iRemoteStorageFwSupported ) |
|
223 { |
|
224 return EFalse; |
|
225 } |
|
226 if ( aUid == KNullUid ) |
|
227 { |
|
228 return ETrue; |
|
229 } |
|
230 return !iMountMan->IsAppOnBlackList( aUid ); |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // CFileManagerRemoteDriveHandler::CancelTransfer() |
|
235 // --------------------------------------------------------------------------- |
|
236 // |
|
237 void CFileManagerRemoteDriveHandler::CancelTransfer( |
|
238 const TDesC& aFullPath ) |
|
239 { |
|
240 FUNC_LOG |
|
241 |
|
242 if ( !iRemoteStorageFwSupported ) |
|
243 { |
|
244 return; |
|
245 } |
|
246 INFO_LOG1( |
|
247 "CFileManagerRemoteDriveHandler::CancelTransfer=%S", |
|
248 &aFullPath ) |
|
249 iMountMan->CancelRemoteTransfer( aFullPath ); |
|
250 } |
|
251 |
|
252 // End of File |
|