20
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2010 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: File Transfer Controller implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
|
|
21 |
#include <pathinfo.h>
|
|
22 |
#include <stringresourcereader.h>
|
|
23 |
#include <bautils.h>
|
|
24 |
#include <driveinfo.h>
|
|
25 |
#include <sconftp.rsg>
|
|
26 |
#include <centralrepository.h>
|
|
27 |
#include <sysutildomaincrkeys.h>
|
|
28 |
|
|
29 |
#include "debug.h"
|
|
30 |
#include "sconftp.h"
|
|
31 |
#include "sconfshandler.h"
|
|
32 |
#include "sconinboxhandler.h"
|
|
33 |
#include "sconconsts.h"
|
|
34 |
|
|
35 |
const TInt KPackageSize = 65536;
|
|
36 |
|
|
37 |
// ============================= MEMBER FUNCTIONS ===============================
|
|
38 |
|
|
39 |
|
|
40 |
// -----------------------------------------------------------------------------
|
|
41 |
// CreateCSConFTPL()
|
|
42 |
// Entry to CSConFTP
|
|
43 |
// -----------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
EXPORT_C CSConFTP* CreateCSConFTPL()
|
|
46 |
{
|
|
47 |
TRACE_FUNC;
|
|
48 |
return CSConFTP::NewL();
|
|
49 |
}
|
|
50 |
|
|
51 |
// -----------------------------------------------------------------------------
|
|
52 |
// CSConFTP::NewL()
|
|
53 |
// Two-phase constructor
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CSConFTP* CSConFTP::NewL()
|
|
57 |
{
|
|
58 |
TRACE_FUNC_ENTRY;
|
|
59 |
CSConFTP* self = new (ELeave) CSConFTP();
|
|
60 |
CleanupStack::PushL( self );
|
|
61 |
self->ConstructL();
|
|
62 |
CleanupStack::Pop( self );
|
|
63 |
TRACE_FUNC_EXIT;
|
|
64 |
return self;
|
|
65 |
}
|
|
66 |
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
// CSConFTP::~CSConFTP()
|
|
69 |
// Destructor
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
CSConFTP::~CSConFTP()
|
|
73 |
{
|
|
74 |
TRACE_FUNC_ENTRY;
|
|
75 |
delete iSConInboxHandler;
|
|
76 |
iSConInboxHandler = NULL;
|
|
77 |
delete iSConFsHandler;
|
|
78 |
iSConFsHandler = NULL;
|
|
79 |
delete iBuffer;
|
|
80 |
iBuffer = NULL;
|
|
81 |
|
|
82 |
iFs.Delete( iTempFileName );
|
|
83 |
iFs.Close();
|
|
84 |
TRACE_FUNC_EXIT;
|
|
85 |
}
|
|
86 |
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
// CSConFTP::GetFolderObjectL( CObexBufObject*& aObjectList )
|
|
89 |
// Gets object that contains folder listing from inbox or file system
|
|
90 |
// -----------------------------------------------------------------------------
|
|
91 |
//
|
|
92 |
TInt CSConFTP::GetFolderObjectL( CObexBufObject*& aObjectList )
|
|
93 |
{
|
|
94 |
TRACE_FUNC_ENTRY;
|
|
95 |
|
|
96 |
TInt ret( KErrNone );
|
|
97 |
TInt offset = 0;
|
|
98 |
TChar driveLetter;
|
|
99 |
TBuf8<KSConDriveNameLength> tmpBuf8;
|
|
100 |
|
|
101 |
iBuffer->Reset();
|
|
102 |
|
|
103 |
//default folder list - lists all available drives, inbox
|
|
104 |
if( iPathName.Length() == 0 )
|
|
105 |
{
|
|
106 |
TInt devDriveCount = 0;
|
|
107 |
TInt mmcDriveCount = 0;
|
|
108 |
|
|
109 |
iBuffer->ResizeL( KSConXmlDocBegin().Length() );
|
|
110 |
iBuffer->Write( offset, KSConXmlDocBegin );
|
|
111 |
offset += KSConXmlDocBegin().Length();
|
|
112 |
|
|
113 |
//Write all drivers to folderlisting object
|
|
114 |
TDriveList driveList;
|
|
115 |
// Get all drives that are visible to the user.
|
|
116 |
TInt driveCount;
|
|
117 |
User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveList, driveCount ) );
|
|
118 |
|
|
119 |
for( TInt i = EDriveA; i < KMaxDrives; i++ )
|
|
120 |
{
|
|
121 |
if( driveList[i] )
|
|
122 |
{
|
|
123 |
TUint driveStatus;
|
|
124 |
User::LeaveIfError( DriveInfo::GetDriveStatus( iFs, i, driveStatus ) );
|
|
125 |
LOGGER_WRITE_1( "DriveInfo for drive: %d", i);
|
|
126 |
|
|
127 |
if( !(driveStatus & DriveInfo::EDrivePresent )
|
|
128 |
|| driveStatus & DriveInfo::EDriveCorrupt
|
|
129 |
|| (driveStatus & DriveInfo::EDriveRemote) )
|
|
130 |
{
|
|
131 |
LOGGER_WRITE_1( "skip drive %d", i);
|
|
132 |
continue;
|
|
133 |
}
|
|
134 |
|
|
135 |
User::LeaveIfError( iFs.DriveToChar( i, driveLetter ) );
|
|
136 |
|
|
137 |
//Letter to uppercase form.
|
|
138 |
driveLetter.UpperCase();
|
|
139 |
|
|
140 |
//Folder begin
|
|
141 |
iBuffer->ExpandL( offset,
|
|
142 |
KSConXmlFolderNameBegin().Length() );
|
|
143 |
iBuffer->Write( offset, KSConXmlFolderNameBegin );
|
|
144 |
offset += KSConXmlFolderNameBegin().Length();
|
|
145 |
|
|
146 |
iBuffer->ExpandL( offset, KSConDriveCName().Length() );
|
|
147 |
|
|
148 |
tmpBuf8.Delete( 0, tmpBuf8.Length() );
|
|
149 |
tmpBuf8.Append( driveLetter );
|
|
150 |
tmpBuf8.Append( KDriveDelimiter );
|
|
151 |
|
|
152 |
iBuffer->Write( offset, tmpBuf8 );
|
|
153 |
offset += KSConDriveNameLength;
|
|
154 |
|
|
155 |
//permission
|
|
156 |
iBuffer->ExpandL( offset,
|
|
157 |
KSConXmlUserAttributes().Length() );
|
|
158 |
iBuffer->Write( offset, KSConXmlUserAttributes );
|
|
159 |
offset += KSConXmlUserAttributes().Length();
|
|
160 |
if( driveStatus & DriveInfo::EDriveInternal && devDriveCount==0 )
|
|
161 |
{
|
|
162 |
//permission always R for first internal drive
|
|
163 |
iBuffer->ExpandL( offset,
|
|
164 |
KSConXmlUserEntryReadOnly().Length() );
|
|
165 |
iBuffer->Write( offset, KSConXmlUserEntryReadOnly );
|
|
166 |
offset += KSConXmlUserEntryReadOnly().Length();
|
|
167 |
}
|
|
168 |
else
|
|
169 |
{
|
|
170 |
//permission always RW
|
|
171 |
iBuffer->ExpandL( offset,
|
|
172 |
KSConXmlUserEntryDrive().Length() );
|
|
173 |
iBuffer->Write( offset, KSConXmlUserEntryDrive );
|
|
174 |
offset += KSConXmlUserEntryDrive().Length();
|
|
175 |
}
|
|
176 |
|
|
177 |
//memory type
|
|
178 |
iBuffer->ExpandL( offset,
|
|
179 |
KSConXmlMemoryType().Length() );
|
|
180 |
iBuffer->Write( offset, KSConXmlMemoryType );
|
|
181 |
offset += KSConXmlMemoryType().Length();
|
|
182 |
if( driveStatus & DriveInfo::EDriveInternal )
|
|
183 |
{
|
|
184 |
LOGGER_WRITE( "DriveInfo::EDriveInternal" );
|
|
185 |
// DEV type
|
|
186 |
devDriveCount++;
|
|
187 |
if( devDriveCount > 1 )
|
|
188 |
{
|
|
189 |
// DEV2
|
|
190 |
TBuf8<KSConMemTypeMaxLength> memType;
|
|
191 |
memType.Copy( KSConMemoryTypeDev );
|
|
192 |
memType.AppendNum(devDriveCount);
|
|
193 |
iBuffer->ExpandL( offset, memType.Length() );
|
|
194 |
iBuffer->Write( offset, memType );
|
|
195 |
offset += memType.Length();
|
|
196 |
}
|
|
197 |
else
|
|
198 |
{
|
|
199 |
// DEV
|
|
200 |
iBuffer->ExpandL( offset,
|
|
201 |
KSConMemoryTypeDev().Length() );
|
|
202 |
iBuffer->Write( offset, KSConMemoryTypeDev );
|
|
203 |
offset += KSConMemoryTypeDev().Length();
|
|
204 |
}
|
|
205 |
}
|
|
206 |
if( driveStatus & DriveInfo::EDriveRemovable )
|
|
207 |
{
|
|
208 |
LOGGER_WRITE( "DriveInfo::EDriveRemovable" );
|
|
209 |
// MMC type
|
|
210 |
mmcDriveCount++;
|
|
211 |
if( mmcDriveCount > 1 )
|
|
212 |
{
|
|
213 |
// MMC2
|
|
214 |
TBuf8<KSConMemTypeMaxLength> memType;
|
|
215 |
memType.Copy( KSConMemoryTypeMmc );
|
|
216 |
memType.AppendNum(mmcDriveCount);
|
|
217 |
iBuffer->ExpandL( offset, memType.Length() );
|
|
218 |
iBuffer->Write( offset, memType );
|
|
219 |
offset += memType.Length();
|
|
220 |
}
|
|
221 |
else
|
|
222 |
{
|
|
223 |
// MMC
|
|
224 |
iBuffer->ExpandL( offset,
|
|
225 |
KSConMemoryTypeMmc().Length() );
|
|
226 |
iBuffer->Write( offset, KSConMemoryTypeMmc );
|
|
227 |
offset += KSConMemoryTypeMmc().Length();
|
|
228 |
}
|
|
229 |
}
|
|
230 |
|
|
231 |
//memory label
|
|
232 |
iBuffer->ExpandL( offset,
|
|
233 |
KSConXmlMemoryLabel().Length() );
|
|
234 |
iBuffer->Write( offset, KSConXmlMemoryLabel );
|
|
235 |
offset += KSConXmlMemoryLabel().Length();
|
|
236 |
|
|
237 |
TInt err( KErrNotFound );
|
|
238 |
TBuf8<KMaxFileName> volumeName;
|
|
239 |
if( driveStatus & DriveInfo::EDriveRemovable || devDriveCount == 1 )
|
|
240 |
{
|
|
241 |
// get Volume name for C-drive(Phone) and E-drive(MMC)
|
|
242 |
err = GetVolumeNameL( i, volumeName );
|
|
243 |
}
|
|
244 |
else
|
|
245 |
{
|
|
246 |
// Get localized name for DEV2 (Mass memory)
|
|
247 |
//Read memory string and convert it
|
|
248 |
TFileName file( KSConResourceName );
|
|
249 |
|
|
250 |
BaflUtils::NearestLanguageFile( iFs, file );
|
|
251 |
|
|
252 |
CStringResourceReader* reader = CStringResourceReader::NewL( file );
|
|
253 |
|
|
254 |
CnvUtfConverter::ConvertFromUnicodeToUtf8( volumeName,
|
|
255 |
reader->ReadResourceString( R_SECON_VALUE_MASS_STORAGE ) );
|
|
256 |
|
|
257 |
delete reader;
|
|
258 |
err = KErrNone;
|
|
259 |
}
|
|
260 |
|
|
261 |
if ( err == KErrNone )
|
|
262 |
{
|
|
263 |
iBuffer->ExpandL( offset,
|
|
264 |
volumeName.Length() );
|
|
265 |
iBuffer->Write( offset, volumeName );
|
|
266 |
offset += volumeName.Length();
|
|
267 |
}
|
|
268 |
|
|
269 |
//Write the end of filelist to folderlisting object
|
|
270 |
iBuffer->ExpandL( offset, KSConXmlFileEnd().Length() );
|
|
271 |
iBuffer->Write( offset, KSConXmlFileEnd );
|
|
272 |
offset += KSConXmlFileEnd().Length();
|
|
273 |
}
|
|
274 |
}
|
|
275 |
//Write the end of folderlist to folderlisting object
|
|
276 |
iBuffer->ExpandL( offset, KSConXmlFolderListEnd().Length() );
|
|
277 |
iBuffer->Write( offset, KSConXmlFolderListEnd );
|
|
278 |
iBuffer->Compress();
|
|
279 |
}
|
|
280 |
else
|
|
281 |
{
|
|
282 |
if( IsCurrentVolumeOK() )
|
|
283 |
{
|
|
284 |
ret = iSConFsHandler->ParseFolderListL( iBuffer, iPathName, iCurrentDriveTypeNumber );
|
|
285 |
}
|
|
286 |
else
|
|
287 |
{
|
|
288 |
ret = KErrNotFound;
|
|
289 |
}
|
|
290 |
}
|
|
291 |
|
|
292 |
//Put data to aObjectList
|
|
293 |
delete aObjectList;
|
|
294 |
aObjectList = NULL;
|
|
295 |
|
|
296 |
aObjectList = CObexBufObject::NewL( iBuffer );
|
|
297 |
aObjectList->SetTypeL( KSConFolderListType );
|
|
298 |
aObjectList->SetLengthL( iBuffer->Size() );
|
|
299 |
|
|
300 |
LOGGER_WRITE_1( "CSConFTP::GetFolderObjectL( CObexBufObject*& aObjectList ) : returned %d", ret );
|
|
301 |
return ret;
|
|
302 |
}
|
|
303 |
|
|
304 |
// -----------------------------------------------------------------------------
|
|
305 |
// CSConFTP::GetFileObjectL( CObexFileObject*& aFileObject )
|
|
306 |
// Gets object that contains a file from file system
|
|
307 |
// -----------------------------------------------------------------------------
|
|
308 |
//
|
|
309 |
TInt CSConFTP::GetFileObjectL( CObexFileObject*& aFileObject )
|
|
310 |
{
|
|
311 |
TRACE_FUNC_ENTRY;
|
|
312 |
|
|
313 |
TInt ret( KErrNone );
|
|
314 |
|
|
315 |
if( aFileObject->Name().Length() == 0 )
|
|
316 |
{
|
|
317 |
return KErrBadName;
|
|
318 |
}
|
|
319 |
|
|
320 |
// check is current drive ok
|
|
321 |
if( iPathName.Length() > 0 )
|
|
322 |
{
|
|
323 |
TPath path( KSConAllowedPath );
|
|
324 |
path.Append( KPathDelimiter );
|
|
325 |
if( iPathName.CompareF( path ) != 0 )
|
|
326 |
{
|
|
327 |
// was normal path (not KSConAllowedPath)
|
|
328 |
if( !IsCurrentVolumeOK() )
|
|
329 |
{
|
|
330 |
return KErrNotFound;
|
|
331 |
}
|
|
332 |
}
|
|
333 |
}
|
|
334 |
|
|
335 |
HBufC* nameBuf = HBufC::NewLC( KMaxFileName );
|
|
336 |
TPtr namePtr = nameBuf->Des();
|
|
337 |
namePtr.Append( aFileObject->Name() );
|
|
338 |
|
|
339 |
if( namePtr.LocateReverse( KPathDelimiter ) == namePtr.Length()-1 )
|
|
340 |
{
|
|
341 |
namePtr.Delete( namePtr.Length()-1, 1 );
|
|
342 |
}
|
|
343 |
|
|
344 |
ret = iSConFsHandler->GetFileObjectL( aFileObject, iPathName, namePtr );
|
|
345 |
|
|
346 |
CleanupStack::PopAndDestroy( nameBuf );
|
|
347 |
|
|
348 |
LOGGER_WRITE_1( "CSConFTP::GetFileObjectL() : returned %d", ret );
|
|
349 |
return ret;
|
|
350 |
}
|
|
351 |
|
|
352 |
// -----------------------------------------------------------------------------
|
|
353 |
// CSConFTP::PutFileObjectInitL( CObexBufObject*& aObject,
|
|
354 |
// CBufFlat*& aBuffer )
|
|
355 |
// Initializes the receiving from the client.
|
|
356 |
// -----------------------------------------------------------------------------
|
|
357 |
//
|
|
358 |
TInt CSConFTP::PutFileObjectInitL( CObexBufObject*& aObject,
|
|
359 |
CBufFlat*& aBuffer )
|
|
360 |
{
|
|
361 |
TRACE_FUNC_ENTRY;
|
|
362 |
TInt ret( KErrNone );
|
|
363 |
|
|
364 |
RFile file;
|
|
365 |
|
|
366 |
TBool lowMemory = IsCurrentDiskSpaceBelowCritical();
|
|
367 |
|
|
368 |
//if Inbox then save temp file to default drive
|
|
369 |
if( iPathName.Length() == 0 )
|
|
370 |
{
|
|
371 |
//When proprietary profile (PC Suite), doesn't allow to use Inbox
|
|
372 |
if( iProfile == EProprietary )
|
|
373 |
{
|
|
374 |
LOGGER_WRITE( "CSConFTP::PutFileObjectInitL() : iProfile EProprietary" );
|
|
375 |
ret = file.Temp( iFs, PathInfo::PhoneMemoryRootPath(), iTempFileName,
|
|
376 |
EFileWrite | EFileShareExclusive );
|
|
377 |
file.Close();
|
|
378 |
|
|
379 |
if( ret == KErrNone )
|
|
380 |
{
|
|
381 |
CreateObexBufObjectL( aObject, aBuffer );
|
|
382 |
}
|
|
383 |
}
|
|
384 |
else
|
|
385 |
{
|
|
386 |
LOGGER_WRITE( "CSConFTP::PutFileObjectInitL() : not EProprietary" );
|
|
387 |
if( lowMemory )
|
|
388 |
{
|
|
389 |
// do not even try to save
|
|
390 |
LOGGER_WRITE( "CSConFTP::PutFileObjectInitL() : disk full" );
|
|
391 |
ret = KErrNoMemory;
|
|
392 |
}
|
|
393 |
else
|
|
394 |
{
|
|
395 |
ret = iSConInboxHandler->CreateInboxAttachmentL( aObject, aBuffer );
|
|
396 |
}
|
|
397 |
}
|
|
398 |
|
|
399 |
return ret;
|
|
400 |
}
|
|
401 |
else
|
|
402 |
{
|
|
403 |
LOGGER_WRITE_1("iPathName: %S", &iPathName);
|
|
404 |
// check is current drive ok
|
|
405 |
if( !IsCurrentVolumeOK() )
|
|
406 |
{
|
|
407 |
LOGGER_WRITE( "CSConFTP::PutFileObjectInitL() : drive not visible" );
|
|
408 |
ret = KErrNotFound;
|
|
409 |
}
|
|
410 |
else
|
|
411 |
{
|
|
412 |
ret = file.Temp( iFs, iPathName, iTempFileName, EFileWrite |
|
|
413 |
EFileShareExclusive );
|
|
414 |
}
|
|
415 |
}
|
|
416 |
|
|
417 |
file.Close();
|
|
418 |
|
|
419 |
if( ret == KErrNone )
|
|
420 |
{
|
|
421 |
CreateObexBufObjectL( aObject, aBuffer );
|
|
422 |
|
|
423 |
if( lowMemory )
|
|
424 |
{
|
|
425 |
// return error. it's up to pccon/ftp plugin howto handle it..
|
|
426 |
LOGGER_WRITE( "CSConFTP::PutFileObjectInitL() : low memory" );
|
|
427 |
ret = KErrNoMemory;
|
|
428 |
}
|
|
429 |
}
|
|
430 |
|
|
431 |
LOGGER_WRITE_1( "CSConFTP::PutFileObjectInitL( CObexBufObject*& aObject, CBufFlat*& aBuffer ) : returned %d", ret );
|
|
432 |
return ret;
|
|
433 |
}
|
|
434 |
|
|
435 |
void CSConFTP::CreateObexBufObjectL( CObexBufObject*& aObject, CBufFlat*& aBuffer )
|
|
436 |
{
|
|
437 |
delete aObject;
|
|
438 |
aObject = NULL;
|
|
439 |
aObject = CObexBufObject::NewL( NULL );
|
|
440 |
|
|
441 |
delete aBuffer;
|
|
442 |
aBuffer = NULL;
|
|
443 |
|
|
444 |
aBuffer = CBufFlat::NewL( KSConBufferSize );
|
|
445 |
aBuffer->ResizeL( KSConBufferSize );
|
|
446 |
|
|
447 |
TObexFilenameBackedBuffer bufferdetails( *aBuffer, iTempFileName,
|
|
448 |
CObexBufObject::EDoubleBuffering );
|
|
449 |
TRAPD( err, aObject->SetDataBufL( bufferdetails ));
|
|
450 |
if ( err == KErrNoMemory )
|
|
451 |
{
|
|
452 |
LOGGER_WRITE( "KErrNoMemory, Using singe buffer strategy");
|
|
453 |
// If fails, use singe buffer strategy to save RAM
|
|
454 |
TObexFilenameBackedBuffer lowMemBufferdetails( *aBuffer, iTempFileName,
|
|
455 |
CObexBufObject::ESingleBuffering );
|
|
456 |
aObject->SetDataBufL( lowMemBufferdetails );
|
|
457 |
}
|
|
458 |
}
|
|
459 |
|
|
460 |
// -----------------------------------------------------------------------------
|
|
461 |
// CSConFTP::PutFileObjectFinalizeL( CObexBufObject*& aObject )
|
|
462 |
// Stores the relayed file object to inbox or file system.
|
|
463 |
// -----------------------------------------------------------------------------
|
|
464 |
//
|
|
465 |
TInt CSConFTP::PutFileObjectFinalizeL( CObexBufObject*& aObject )
|
|
466 |
{
|
|
467 |
TRACE_FUNC_ENTRY;
|
|
468 |
TInt ret( KErrNone );
|
|
469 |
|
|
470 |
// if iPathName is not defined trying to save to inbox, no need to call IsCurrentVolumeOK()
|
|
471 |
if( iPathName.Length() > 0 && !IsCurrentVolumeOK() )
|
|
472 |
{
|
|
473 |
// Memory card removed
|
|
474 |
LOGGER_WRITE( "CSConFTP::PutFileObjectFinalizeL() : disk err, return KErrNotFound" );
|
|
475 |
return KErrNotFound;
|
|
476 |
}
|
|
477 |
else if ( iPathName.Length() + aObject->Name().Length() > KMaxFileName )
|
|
478 |
{
|
|
479 |
LOGGER_WRITE( "CSConFTP::PutFileObjectFinalizeL() : Too long filename, return KErrBadName");
|
|
480 |
return KErrBadName;
|
|
481 |
}
|
|
482 |
|
|
483 |
TBool lowMemory = IsCurrentDiskSpaceBelowCritical();
|
|
484 |
if ( lowMemory )
|
|
485 |
{
|
|
486 |
LOGGER_WRITE( "CSConFTP::PutFileObjectFinalizeL() : Low memory, return KErrNoMemory");
|
|
487 |
return KErrNoMemory;
|
|
488 |
}
|
|
489 |
|
|
490 |
HBufC* fullPathBuf = HBufC::NewLC( KMaxFileName );
|
|
491 |
TPtr fullPathPtr = fullPathBuf->Des();
|
|
492 |
fullPathPtr.Copy( iPathName );
|
|
493 |
fullPathPtr.Append( aObject->Name() );
|
|
494 |
|
|
495 |
// Save to inbox if path is not set.
|
|
496 |
if( iPathName.Length() == 0 )
|
|
497 |
{
|
|
498 |
LOGGER_WRITE( "CSConFTP::PutFileObjectFinalizeL before SaveObjectToInbox" );
|
|
499 |
ret = iSConInboxHandler->SaveObjToInboxL( aObject );
|
|
500 |
LOGGER_WRITE_1( "CSConFTP::PutFileObjectFinalize SaveObjectToInbox returned %d", ret );
|
|
501 |
}
|
|
502 |
else if( iPathName.CompareF( K_C_ROOT ) == 0 )
|
|
503 |
{
|
|
504 |
// Saving to root of C:\ is not allowed
|
|
505 |
ret = KErrAccessDenied;
|
|
506 |
}
|
|
507 |
//Save to file system
|
|
508 |
else
|
|
509 |
{
|
|
510 |
TTime time = aObject->Time();
|
|
511 |
|
|
512 |
// UTC offset
|
|
513 |
time -= User::UTCOffset();
|
|
514 |
|
|
515 |
delete aObject;
|
|
516 |
aObject = NULL;
|
|
517 |
|
|
518 |
ret = iSConFsHandler->SaveFileObjectL( fullPathPtr, time,
|
|
519 |
iTempFileName );
|
|
520 |
}
|
|
521 |
|
|
522 |
CleanupStack::PopAndDestroy( fullPathBuf );
|
|
523 |
|
|
524 |
LOGGER_WRITE_1( "CSConFTP::PutFileObjectFinalizeL( CObexBufObject*& aObject ) : returned %d", ret );
|
|
525 |
|
|
526 |
return ret;
|
|
527 |
}
|
|
528 |
|
|
529 |
// -----------------------------------------------------------------------------
|
|
530 |
// CSConFTP::SetPathL( const TPtrC aPath, const TUint8 aFlags )
|
|
531 |
// Changes the current path. The path can point to inbox or file system
|
|
532 |
// -----------------------------------------------------------------------------
|
|
533 |
//
|
|
534 |
TInt CSConFTP::SetPathL( const TPtrC aPath, const TUint8 aFlags )
|
|
535 |
{
|
|
536 |
TRACE_FUNC_ENTRY;
|
|
537 |
LOGGER_WRITE_1( "aPath: %S", &aPath );
|
|
538 |
TInt ret( KErrNone );
|
|
539 |
|
|
540 |
if( ( aPath.Length() > 0 && aFlags != KSConSetPathRoot )
|
|
541 |
|| ( iPathName.Length() == KDriveLength && aFlags == KSConSetPathBack) )
|
|
542 |
{
|
|
543 |
// check is current drive ok
|
|
544 |
if( !IsCurrentVolumeOK() )
|
|
545 |
{
|
|
546 |
LOGGER_WRITE( "CSConFTP::SetPathL() : drive not found" );
|
|
547 |
return KErrNotFound;
|
|
548 |
}
|
|
549 |
}
|
|
550 |
|
|
551 |
ret = KErrNotFound;
|
|
552 |
|
|
553 |
//path forward, deny access to forbidden directories and drives
|
|
554 |
if( aPath.Length() > 0
|
|
555 |
&& ( iPathName.Length() + aPath.Length() < KMaxFileName )
|
|
556 |
&& ( aFlags == KSConSetPathForward || aFlags == KSConSetPathDontCreate ) )
|
|
557 |
{
|
|
558 |
ret = SetPathForwardL( aPath, aFlags );
|
|
559 |
}
|
|
560 |
//path backward
|
|
561 |
else if( aFlags == KSConSetPathBack )
|
|
562 |
{
|
|
563 |
ret = SetPathBackwardL( aPath );
|
|
564 |
}
|
|
565 |
//path root
|
|
566 |
else if( aPath.Length() == 0 && aFlags == KSConSetPathRoot )
|
|
567 |
{
|
|
568 |
LOGGER_WRITE( "CSConFTP::SetPathL() : KSConSetPathRoot" );
|
|
569 |
if( iPathName.Length() > 0 )
|
|
570 |
{
|
|
571 |
iPathName.Delete( 0, iPathName.Length() );
|
|
572 |
}
|
|
573 |
iCurrentDrive = KErrNotFound;
|
|
574 |
ret = KErrNone;
|
|
575 |
}
|
|
576 |
|
|
577 |
if( ret == KErrNone )
|
|
578 |
{
|
|
579 |
// drive may have changed, update info
|
|
580 |
UpdateDriveTypeInfoL();
|
|
581 |
}
|
|
582 |
|
|
583 |
LOGGER_WRITE_1( "CSConFTP::CSConFTP::SetPathL( const TPtrC aPath, const TUint8 aFlags ) : returned %d", ret );
|
|
584 |
return ret;
|
|
585 |
}
|
|
586 |
|
|
587 |
// -----------------------------------------------------------------------------
|
|
588 |
// CSConFTP::SetPathForwardL( const TPtrC aPath, const TUint8 aFlags )
|
|
589 |
// Set path forward
|
|
590 |
// -----------------------------------------------------------------------------
|
|
591 |
//
|
|
592 |
TInt CSConFTP::SetPathForwardL( const TPtrC aPath, const TUint8 aFlags )
|
|
593 |
{
|
|
594 |
TRACE_FUNC_ENTRY;
|
|
595 |
TInt ret(KErrNone);
|
|
596 |
HBufC* fullPath = HBufC::NewLC( KMaxFileName );
|
|
597 |
TPtr fullPathPtr = fullPath->Des();
|
|
598 |
|
|
599 |
if( iPathName.Length() == 0 )
|
|
600 |
{
|
|
601 |
fullPathPtr.Copy( aPath );
|
|
602 |
}
|
|
603 |
else
|
|
604 |
{
|
|
605 |
fullPathPtr.Copy( iPathName );
|
|
606 |
fullPathPtr.Append( aPath );
|
|
607 |
}
|
|
608 |
LOGGER_WRITE_1( "fullPathPtr: %S", &fullPathPtr );
|
|
609 |
// now fullpath is new path
|
|
610 |
// check validity
|
|
611 |
if( fullPathPtr.Length() < 2 || fullPathPtr[1] != KDriveDelimiter )
|
|
612 |
{
|
|
613 |
LOGGER_WRITE( "CSConFTP::SetPathForwardL() : not valid name" );
|
|
614 |
CleanupStack::PopAndDestroy( fullPath );
|
|
615 |
return KErrNotFound;
|
|
616 |
}
|
|
617 |
|
|
618 |
if( fullPathPtr.CompareF( KSConAllowedPath ) == 0 )
|
|
619 |
{
|
|
620 |
// Always access to PC Suite configuration file on ROM
|
|
621 |
LOGGER_WRITE( "CSConFTP::SetPathForwardL() : KSConAllowedPath" );
|
|
622 |
iPathName.Copy( fullPathPtr );
|
|
623 |
if( iPathName[iPathName.Length()-1] != KPathDelimiter )
|
|
624 |
{
|
|
625 |
iPathName.Append( KPathDelimiter );
|
|
626 |
}
|
|
627 |
|
|
628 |
CleanupStack::PopAndDestroy( fullPath );
|
|
629 |
return KErrNone;
|
|
630 |
}
|
|
631 |
|
|
632 |
// check drive
|
|
633 |
TInt driveNumber;
|
|
634 |
TInt err = iFs.CharToDrive( fullPathPtr[0], driveNumber );
|
|
635 |
if( err != KErrNone || !IsDriveVisible( driveNumber ) )
|
|
636 |
{
|
|
637 |
LOGGER_WRITE( "CSConFTP::SetPathForwardL() : drive err" );
|
|
638 |
CleanupStack::PopAndDestroy( fullPath );
|
|
639 |
return KErrNotFound;
|
|
640 |
}
|
|
641 |
|
|
642 |
// check folder and create it if needed
|
|
643 |
if( fullPathPtr.Length() > 2 )
|
|
644 |
{
|
|
645 |
TBool isFolder = EFalse;
|
|
646 |
err = BaflUtils::IsFolder( iFs, fullPathPtr, isFolder );
|
|
647 |
if( err != KErrNone )
|
|
648 |
{
|
|
649 |
isFolder = EFalse;
|
|
650 |
}
|
|
651 |
LOGGER_WRITE_1( "CSConFTP::SetPathForwardL() IsFolder: %d", (TInt)isFolder );
|
|
652 |
|
|
653 |
if( !isFolder )
|
|
654 |
{
|
|
655 |
//if "Don't create" is 1
|
|
656 |
if( aFlags & 2 )
|
|
657 |
{
|
|
658 |
ret = KErrNotFound;
|
|
659 |
}
|
|
660 |
else
|
|
661 |
{
|
|
662 |
CreateFolderL( fullPathPtr );
|
|
663 |
ret = KErrNone;
|
|
664 |
}
|
|
665 |
}
|
|
666 |
else
|
|
667 |
{
|
|
668 |
ret = KErrNone;
|
|
669 |
}
|
|
670 |
}
|
|
671 |
else
|
|
672 |
{
|
|
673 |
ret = KErrNone;
|
|
674 |
}
|
|
675 |
|
|
676 |
if( ret == KErrNone )
|
|
677 |
{
|
|
678 |
iPathName.Copy( fullPathPtr );
|
|
679 |
|
|
680 |
if( iPathName[iPathName.Length()-1] != KPathDelimiter )
|
|
681 |
{
|
|
682 |
iPathName.Append( KPathDelimiter );
|
|
683 |
}
|
|
684 |
}
|
|
685 |
|
|
686 |
CleanupStack::PopAndDestroy( fullPath );
|
|
687 |
LOGGER_WRITE_1( "CSConFTP::SetPathForwardL() : end, ret: %d", ret );
|
|
688 |
return ret;
|
|
689 |
|
|
690 |
}
|
|
691 |
|
|
692 |
// -----------------------------------------------------------------------------
|
|
693 |
// CSConFTP::SetPathBackwardL( const TPtrC aPath )
|
|
694 |
// Set path backward
|
|
695 |
// -----------------------------------------------------------------------------
|
|
696 |
//
|
|
697 |
TInt CSConFTP::SetPathBackwardL( const TPtrC aPath )
|
|
698 |
{
|
|
699 |
TRACE_FUNC_ENTRY;
|
|
700 |
TInt ret(KErrNotFound);
|
|
701 |
if( iPathName.Length() == 0 )
|
|
702 |
{
|
|
703 |
// already in root, exit
|
|
704 |
LOGGER_WRITE( "CSConFTP::SetPathBackwardL() : already in root" );
|
|
705 |
LOGGER_WRITE_1( "CSConFTP::SetPathBackwardL() : end, ret: %d", ret );
|
|
706 |
return ret;
|
|
707 |
}
|
|
708 |
TInt pos;
|
|
709 |
TBool isFolder(EFalse);
|
|
710 |
HBufC* fullPath = HBufC::NewLC( KMaxFileName );
|
|
711 |
TPtr fullPathPtr = fullPath->Des();
|
|
712 |
|
|
713 |
//no directory/folder name
|
|
714 |
if( aPath.Length() == 0 )
|
|
715 |
{
|
|
716 |
LOGGER_WRITE( "CSConFTP::SetPathBackwardL() : no new path, goto parent" );
|
|
717 |
iPathName.Delete( iPathName.Length()-1, 1 );
|
|
718 |
pos = iPathName.LocateReverse( KPathDelimiter );
|
|
719 |
iPathName.Delete( pos+1, iPathName.Length()-pos );
|
|
720 |
ret = KErrNone;
|
|
721 |
}
|
|
722 |
//if folder name
|
|
723 |
else if( aPath.Locate( KDriveDelimiter ) != 1 && iPathName.Length() > KDriveLength )
|
|
724 |
{
|
|
725 |
LOGGER_WRITE( "CSConFTP::SetPathBackwardL() : goto parent and new path" );
|
|
726 |
fullPathPtr.Copy( iPathName );
|
|
727 |
fullPathPtr.Delete( fullPathPtr.Length()-1, 1 );
|
|
728 |
pos = fullPathPtr.LocateReverse( KPathDelimiter );
|
|
729 |
fullPathPtr.Delete( pos+1, fullPathPtr.Length()-pos );
|
|
730 |
fullPathPtr.Append( aPath );
|
|
731 |
|
|
732 |
if( fullPathPtr.CompareF( KSConAllowedPath ) == 0 )
|
|
733 |
{
|
|
734 |
// Always access to PC Suite configuration file on ROM
|
|
735 |
isFolder = ETrue;
|
|
736 |
}
|
|
737 |
else
|
|
738 |
{
|
|
739 |
TInt driveNumber;
|
|
740 |
TInt err = iFs.CharToDrive(fullPathPtr[0], driveNumber);
|
|
741 |
if( err != KErrNone )
|
|
742 |
{
|
|
743 |
LOGGER_WRITE( "CSConFTP::SetPathForwardL() : drive err" );
|
|
744 |
isFolder = EFalse;
|
|
745 |
}
|
|
746 |
else if( !IsDriveVisible(driveNumber) )
|
|
747 |
{
|
|
748 |
isFolder = EFalse;
|
|
749 |
}
|
|
750 |
else
|
|
751 |
{
|
|
752 |
// drive ok, check folder.
|
|
753 |
err = BaflUtils::IsFolder( iFs, fullPathPtr, isFolder );
|
|
754 |
if( err != KErrNone )
|
|
755 |
{
|
|
756 |
isFolder = EFalse;
|
|
757 |
}
|
|
758 |
}
|
|
759 |
}
|
|
760 |
|
|
761 |
if( isFolder )
|
|
762 |
{
|
|
763 |
iPathName.Copy( fullPathPtr );
|
|
764 |
|
|
765 |
if( aPath.LocateReverse( KPathDelimiter ) != aPath.Length()-1 )
|
|
766 |
{
|
|
767 |
iPathName.Append( KPathDelimiter );
|
|
768 |
}
|
|
769 |
|
|
770 |
ret = KErrNone;
|
|
771 |
}
|
|
772 |
else
|
|
773 |
{
|
|
774 |
ret = KErrNotFound;
|
|
775 |
}
|
|
776 |
|
|
777 |
}
|
|
778 |
//drive
|
|
779 |
else if( aPath.Locate( KDriveDelimiter ) == 1 )
|
|
780 |
{
|
|
781 |
fullPathPtr.Copy( aPath );
|
|
782 |
if( fullPathPtr.LocateReverse( KPathDelimiter )
|
|
783 |
!= fullPathPtr.Length()-1 )
|
|
784 |
{
|
|
785 |
fullPathPtr.Append( KPathDelimiter );
|
|
786 |
}
|
|
787 |
|
|
788 |
TFileName tempPath( KSConAllowedPath );
|
|
789 |
tempPath.Append(KPathDelimiter);
|
|
790 |
if( fullPathPtr.CompareF( tempPath ) == 0 )
|
|
791 |
{
|
|
792 |
// Always access to PC Suite configuration file on ROM
|
|
793 |
isFolder = ETrue;
|
|
794 |
}
|
|
795 |
else
|
|
796 |
{
|
|
797 |
TInt driveNumber;
|
|
798 |
TInt err = iFs.CharToDrive(fullPathPtr[0], driveNumber);
|
|
799 |
if( err != KErrNone )
|
|
800 |
{
|
|
801 |
LOGGER_WRITE( "CSConFTP::SetPathForwardL() : drive err" );
|
|
802 |
isFolder = EFalse;
|
|
803 |
}
|
|
804 |
else if( !IsDriveVisible(driveNumber) )
|
|
805 |
{
|
|
806 |
isFolder = EFalse;
|
|
807 |
}
|
|
808 |
else
|
|
809 |
{
|
|
810 |
// drive ok, check folder.
|
|
811 |
err = BaflUtils::IsFolder( iFs, fullPathPtr, isFolder );
|
|
812 |
if( err != KErrNone )
|
|
813 |
{
|
|
814 |
isFolder = EFalse;
|
|
815 |
}
|
|
816 |
}
|
|
817 |
}
|
|
818 |
|
|
819 |
if( isFolder )
|
|
820 |
{
|
|
821 |
iPathName.Copy( fullPathPtr );
|
|
822 |
|
|
823 |
if( aPath.LocateReverse( KPathDelimiter ) != aPath.Length()-1 )
|
|
824 |
{
|
|
825 |
iPathName.Append( KPathDelimiter );
|
|
826 |
}
|
|
827 |
|
|
828 |
ret = KErrNone;
|
|
829 |
}
|
|
830 |
else
|
|
831 |
{
|
|
832 |
ret = KErrNotFound;
|
|
833 |
}
|
|
834 |
}
|
|
835 |
CleanupStack::PopAndDestroy( fullPath );
|
|
836 |
LOGGER_WRITE_1( "CSConFTP::SetPathBackwardL() : end, ret: %d", ret );
|
|
837 |
return ret;
|
|
838 |
}
|
|
839 |
|
|
840 |
// -----------------------------------------------------------------------------
|
|
841 |
// CSConFTP::CreateFolderL( const TPtrC aFolderName )
|
|
842 |
// Creates a new folder to file system
|
|
843 |
// -----------------------------------------------------------------------------
|
|
844 |
//
|
|
845 |
TInt CSConFTP::CreateFolderL( const TPtrC aFolderName )
|
|
846 |
{
|
|
847 |
TRACE_FUNC_ENTRY;
|
|
848 |
LOGGER_WRITE_1( "aFolderName: %S", &aFolderName );
|
|
849 |
TInt ret( KErrNone );
|
|
850 |
if( aFolderName.Length() == 0 )
|
|
851 |
{
|
|
852 |
return KErrArgument;
|
|
853 |
}
|
|
854 |
|
|
855 |
HBufC* pathBuf = HBufC::NewLC( KMaxFileName );
|
|
856 |
TPtr pathBufPtr = pathBuf->Des();
|
|
857 |
//absolute folder path
|
|
858 |
if( aFolderName.Length() > 1 && aFolderName[1] == KDriveDelimiter )
|
|
859 |
{
|
|
860 |
if ( iPathName.Length()>0 )
|
|
861 |
{
|
|
862 |
LOGGER_WRITE( "CSConFTP::CreateFolderL() : KErrBadName" );
|
|
863 |
CleanupStack::PopAndDestroy( pathBuf );
|
|
864 |
return KErrBadName;
|
|
865 |
}
|
|
866 |
pathBufPtr.Copy( aFolderName );
|
|
867 |
}
|
|
868 |
else
|
|
869 |
{
|
|
870 |
pathBufPtr.Copy( iPathName );
|
|
871 |
pathBufPtr.Append( aFolderName );
|
|
872 |
}
|
|
873 |
|
|
874 |
if( !iFs.IsValidName( pathBufPtr ) )
|
|
875 |
{
|
|
876 |
ret = KErrBadName;
|
|
877 |
}
|
|
878 |
else
|
|
879 |
{
|
|
880 |
// check drive
|
|
881 |
TInt driveNumber;
|
|
882 |
ret = iFs.CharToDrive(pathBufPtr[0], driveNumber);
|
|
883 |
if( ret != KErrNone || !IsDriveVisible(driveNumber) )
|
|
884 |
{
|
|
885 |
LOGGER_WRITE( "CSConFTP::CreateFolderL() : drive err" );
|
|
886 |
ret = KErrNotFound;
|
|
887 |
}
|
|
888 |
}
|
|
889 |
|
|
890 |
if ( ret == KErrNone )
|
|
891 |
{
|
|
892 |
if( pathBufPtr.LocateReverse( KPathDelimiter ) != pathBufPtr.Length()-1 )
|
|
893 |
{
|
|
894 |
pathBufPtr.Append( KPathDelimiter );
|
|
895 |
}
|
|
896 |
ret = iSConFsHandler->CreateFolderL( pathBufPtr );
|
|
897 |
}
|
|
898 |
|
|
899 |
if( ret == KErrNone || ret == KErrAlreadyExists )
|
|
900 |
{
|
|
901 |
ret = SetPathL( aFolderName, KSConSetPathForward );
|
|
902 |
}
|
|
903 |
|
|
904 |
CleanupStack::PopAndDestroy( pathBuf );
|
|
905 |
|
|
906 |
LOGGER_WRITE_1( "CSConFTP::CreateFolderL( const TPtrC aFolderName ) : returned %d", ret );
|
|
907 |
|
|
908 |
return ret;
|
|
909 |
}
|
|
910 |
|
|
911 |
// -----------------------------------------------------------------------------
|
|
912 |
// CSConFTP::DeleteObjectL( const TPtrC aObjectName )
|
|
913 |
// Deletes file/folder from inbox or file system
|
|
914 |
// -----------------------------------------------------------------------------
|
|
915 |
//
|
|
916 |
TInt CSConFTP::DeleteObjectL( const TPtrC aObjectName )
|
|
917 |
{
|
|
918 |
TRACE_FUNC_ENTRY;
|
|
919 |
LOGGER_WRITE_1( "aObjectName: %S", &aObjectName );
|
|
920 |
TInt ret( KErrNone );
|
|
921 |
TFileName tmpTarget;
|
|
922 |
HBufC* targetBuf = HBufC::NewLC( KMaxFileName );
|
|
923 |
TPtr target = targetBuf->Des();
|
|
924 |
|
|
925 |
//absolute folder path
|
|
926 |
if( aObjectName.Length() > 1 && aObjectName[1] == KDriveDelimiter )
|
|
927 |
{
|
|
928 |
if ( iPathName.Length()>0 )
|
|
929 |
{
|
|
930 |
LOGGER_WRITE( "CSConFTP::DeleteObjectL() : KErrBadName" );
|
|
931 |
CleanupStack::PopAndDestroy( targetBuf );
|
|
932 |
return KErrBadName;
|
|
933 |
}
|
|
934 |
target.Copy( aObjectName );
|
|
935 |
}
|
|
936 |
else
|
|
937 |
{
|
|
938 |
target.Copy( iPathName );
|
|
939 |
target.Append( aObjectName );
|
|
940 |
}
|
|
941 |
|
|
942 |
if( !iFs.IsValidName( target ) )
|
|
943 |
{
|
|
944 |
ret = KErrBadName;
|
|
945 |
}
|
|
946 |
else
|
|
947 |
{
|
|
948 |
TInt driveNumber;
|
|
949 |
ret = iFs.CharToDrive(target[0], driveNumber);
|
|
950 |
if( ret != KErrNone || !IsDriveVisible(driveNumber) )
|
|
951 |
{
|
|
952 |
LOGGER_WRITE( "CSConFTP::DeleteObjectL() : drive err" );
|
|
953 |
ret = KErrNotFound;
|
|
954 |
}
|
|
955 |
}
|
|
956 |
|
|
957 |
|
|
958 |
if ( ret == KErrNone )
|
|
959 |
{
|
|
960 |
ret = iSConFsHandler->DeleteObjectL( target );
|
|
961 |
}
|
|
962 |
|
|
963 |
CleanupStack::PopAndDestroy( targetBuf );
|
|
964 |
|
|
965 |
LOGGER_WRITE_1( "CSConFTP::DeleteObjectL( const TPtrC aObjectName ) : returned %d", ret );
|
|
966 |
return ret;
|
|
967 |
}
|
|
968 |
|
|
969 |
// -----------------------------------------------------------------------------
|
|
970 |
// CSConFTP::GetPath( TDes& aPath )
|
|
971 |
// Gets the current path
|
|
972 |
// -----------------------------------------------------------------------------
|
|
973 |
//
|
|
974 |
TInt CSConFTP::GetPath( TDes& aPath )
|
|
975 |
{
|
|
976 |
TRACE_FUNC;
|
|
977 |
aPath.Copy( iPathName );
|
|
978 |
return KErrNone;
|
|
979 |
}
|
|
980 |
|
|
981 |
// -----------------------------------------------------------------------------
|
|
982 |
// CSConFTP::AbortFileTransfer( CObexBufObject*& aObject )
|
|
983 |
// Abort file transfer
|
|
984 |
// -----------------------------------------------------------------------------
|
|
985 |
//
|
|
986 |
TInt CSConFTP::AbortFileTransfer( CObexBufObject*& aObject )
|
|
987 |
{
|
|
988 |
TRACE_FUNC_ENTRY;
|
|
989 |
TInt err( KErrNone );
|
|
990 |
|
|
991 |
if( iPathName.Length() == 0 )
|
|
992 |
{
|
|
993 |
iSConInboxHandler->AbortInboxOperation( aObject );
|
|
994 |
}
|
|
995 |
|
|
996 |
//aObject has to be deleted, otherwise the temp file is locked
|
|
997 |
delete aObject;
|
|
998 |
aObject = NULL;
|
|
999 |
|
|
1000 |
err = iFs.Delete( iTempFileName );
|
|
1001 |
|
|
1002 |
LOGGER_WRITE_1( "CSConFTP::AbortFileTransfer( CObexBufObject*& aObject ) : iFs.Delete() err: %d", err );
|
|
1003 |
return err;
|
|
1004 |
}
|
|
1005 |
|
|
1006 |
// -----------------------------------------------------------------------------
|
|
1007 |
// CSConFTP::SetProfile( TInt aProfile )
|
|
1008 |
// Set used transfer profile
|
|
1009 |
// -----------------------------------------------------------------------------
|
|
1010 |
//
|
|
1011 |
void CSConFTP::SetProfile( TSConProfile aProfile )
|
|
1012 |
{
|
|
1013 |
TRACE_FUNC;
|
|
1014 |
iProfile = aProfile;
|
|
1015 |
}
|
|
1016 |
|
|
1017 |
// -----------------------------------------------------------------------------
|
|
1018 |
// CSConFTP::SetBackupStarted( TBool aValue )
|
|
1019 |
// Set backup status
|
|
1020 |
// -----------------------------------------------------------------------------
|
|
1021 |
//
|
|
1022 |
void CSConFTP::SetBackupStarted( TBool aValue )
|
|
1023 |
{
|
|
1024 |
TRACE_FUNC;
|
|
1025 |
iBackupStarted = aValue;
|
|
1026 |
}
|
|
1027 |
|
|
1028 |
// -----------------------------------------------------------------------------
|
|
1029 |
// CSConFTP::SetUsedMedia( TSConUsedMedia aMedia )
|
|
1030 |
// Set the used media information
|
|
1031 |
// -----------------------------------------------------------------------------
|
|
1032 |
//
|
|
1033 |
void CSConFTP::SetUsedMedia( TSConUsedMedia aMedia )
|
|
1034 |
{
|
|
1035 |
TRACE_FUNC;
|
|
1036 |
iMedia = aMedia;
|
|
1037 |
}
|
|
1038 |
|
|
1039 |
// -----------------------------------------------------------------------------
|
|
1040 |
// CSConFTP::IsCurrentDiskSpaceBelowCritical( TUint32 aFilesize )
|
|
1041 |
// Check is current disk space below critical level.
|
|
1042 |
// -----------------------------------------------------------------------------
|
|
1043 |
//
|
|
1044 |
TBool CSConFTP::IsCurrentDiskSpaceBelowCritical( TUint32 aFilesize )
|
|
1045 |
{
|
|
1046 |
TRACE_FUNC_ENTRY;
|
|
1047 |
LOGGER_WRITE_1( "aFilesize: %d", aFilesize );
|
|
1048 |
TInt drive;
|
|
1049 |
TInt err;
|
|
1050 |
|
|
1051 |
if( iCurrentDrive != KErrNotFound )
|
|
1052 |
{
|
|
1053 |
drive = iCurrentDrive;
|
|
1054 |
}
|
|
1055 |
else
|
|
1056 |
{
|
|
1057 |
LOGGER_WRITE( "CSConFTP::IsCurrentDiskSpaceBelowCritical() : drive not specified, use default drive" );
|
|
1058 |
err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, drive );
|
|
1059 |
if( err )
|
|
1060 |
{
|
|
1061 |
LOGGER_WRITE_1( "CSConFTP::IsCurrentDiskSpaceBelowCriticaL() : DriveInfo::GetDefaultDrive err %d", err );
|
|
1062 |
return ETrue; //exit
|
|
1063 |
}
|
|
1064 |
}
|
|
1065 |
|
|
1066 |
// check disk space
|
|
1067 |
LOGGER_WRITE_1( "drive: %d", drive );
|
|
1068 |
TVolumeInfo volumeInfo;
|
|
1069 |
err = iFs.Volume(volumeInfo, drive);
|
|
1070 |
if( err != KErrNone )
|
|
1071 |
{
|
|
1072 |
LOGGER_WRITE_1( "CSConFTP::IsCurrentDiskSpaceBelowCritical() : iFs.Volume err %d", err );
|
|
1073 |
LOGGER_WRITE( "CSConFTP::IsCurrentDiskSpaceBelowCritical() : End" );
|
|
1074 |
return ETrue; //exit
|
|
1075 |
}
|
|
1076 |
LOGGER_WRITE_1( "volumeInfo.iFree: %Ld", volumeInfo.iFree );
|
|
1077 |
TBool diskLevelCritical( EFalse );
|
|
1078 |
if ( volumeInfo.iFree - aFilesize <= iCriticalDiskLevel )
|
|
1079 |
{
|
|
1080 |
// Can not write the data, there's not enough free space on disk.
|
|
1081 |
diskLevelCritical = ETrue;
|
|
1082 |
}
|
|
1083 |
|
|
1084 |
LOGGER_WRITE_1( "CSConFTP::IsCurrentDiskSpaceBelowCritical() : ret %d",
|
|
1085 |
(TInt)diskLevelCritical );
|
|
1086 |
return diskLevelCritical;
|
|
1087 |
}
|
|
1088 |
|
|
1089 |
// -----------------------------------------------------------------------------
|
|
1090 |
// CSConFTP::ReadWBXMLDataL( CBufFlat*& aBuffer )
|
|
1091 |
// Read received ConML protocol packet
|
|
1092 |
// -----------------------------------------------------------------------------
|
|
1093 |
//
|
|
1094 |
TInt CSConFTP::ReadWBXMLDataL( CBufFlat*& aBuffer )
|
|
1095 |
{
|
|
1096 |
TRACE_FUNC_ENTRY;
|
|
1097 |
TInt ret( KErrNone );
|
|
1098 |
|
|
1099 |
RFile file;
|
|
1100 |
TInt fileSize;
|
|
1101 |
|
|
1102 |
ret = file.Open( iFs, iTempFileName, EFileRead|EFileShareAny );
|
|
1103 |
CleanupClosePushL( file );
|
|
1104 |
if( ret == KErrNone )
|
|
1105 |
{
|
|
1106 |
file.Size( fileSize );
|
|
1107 |
|
|
1108 |
delete aBuffer;
|
|
1109 |
aBuffer = NULL;
|
|
1110 |
|
|
1111 |
HBufC8* wbxmlDataBuf = HBufC8::NewLC( fileSize );
|
|
1112 |
TPtr8 wbxmlDataPtr = wbxmlDataBuf->Des();
|
|
1113 |
|
|
1114 |
file.Read( wbxmlDataPtr );
|
|
1115 |
|
|
1116 |
aBuffer = CBufFlat::NewL( KSConBufSize );
|
|
1117 |
aBuffer->ExpandL( 0, fileSize );
|
|
1118 |
aBuffer->Write( 0, wbxmlDataPtr );
|
|
1119 |
|
|
1120 |
CleanupStack::PopAndDestroy( wbxmlDataBuf );
|
|
1121 |
}
|
|
1122 |
CleanupStack::PopAndDestroy( &file );
|
|
1123 |
LOGGER_WRITE_1( "CSConFTP::ReadWBXMLData( CBufFlat*& aBuffer ) : WBXML packet size: %d", fileSize );
|
|
1124 |
|
|
1125 |
LOGGER_WRITE_1( "CSConFTP::ReadWBXMLData( CBufFlat*& aBuffer ) : returned %d", ret );
|
|
1126 |
return ret;
|
|
1127 |
}
|
|
1128 |
|
|
1129 |
// -----------------------------------------------------------------------------
|
|
1130 |
// CSConFTP::DeleteTempFile()
|
|
1131 |
// Delete OBEX stack's temp file
|
|
1132 |
// -----------------------------------------------------------------------------
|
|
1133 |
//
|
|
1134 |
void CSConFTP::DeleteTempFile()
|
|
1135 |
{
|
|
1136 |
TRACE_FUNC_ENTRY;
|
|
1137 |
iFs.Delete( iTempFileName );
|
|
1138 |
TRACE_FUNC_EXIT;
|
|
1139 |
}
|
|
1140 |
|
|
1141 |
// -----------------------------------------------------------------------------
|
|
1142 |
// CSConFTP::MoveFile()
|
|
1143 |
// Move file/folder
|
|
1144 |
// -----------------------------------------------------------------------------
|
|
1145 |
//
|
|
1146 |
TInt CSConFTP::MoveFile(const TDesC& aSource, const TDesC& aTarget)
|
|
1147 |
{
|
|
1148 |
TRACE_FUNC_ENTRY;
|
|
1149 |
TInt err;
|
|
1150 |
TFileName tmpSource;
|
|
1151 |
TFileName tmpTarget;
|
|
1152 |
err = GetAbsolutePath( aSource, tmpSource );
|
|
1153 |
if( err == KErrNone )
|
|
1154 |
{
|
|
1155 |
err = GetAbsolutePath( aTarget, tmpTarget );
|
|
1156 |
}
|
|
1157 |
|
|
1158 |
if( err == KErrNone )
|
|
1159 |
{
|
|
1160 |
TInt sourceDrive;
|
|
1161 |
TInt targetDrive;
|
|
1162 |
|
|
1163 |
err = iFs.CharToDrive( tmpSource[0], sourceDrive );
|
|
1164 |
TInt err2 = iFs.CharToDrive( tmpTarget[0], targetDrive );
|
|
1165 |
|
|
1166 |
if( err != KErrNone || err2 != KErrNone
|
|
1167 |
|| !IsDriveVisible( sourceDrive )
|
|
1168 |
|| !IsDriveVisible( targetDrive ) )
|
|
1169 |
{
|
|
1170 |
// drive not visible to user
|
|
1171 |
err = KErrNotFound;
|
|
1172 |
}
|
|
1173 |
}
|
|
1174 |
|
|
1175 |
if( err == KErrNone )
|
|
1176 |
{
|
|
1177 |
TRAP( err,
|
|
1178 |
iSConFsHandler->DoCopyOrMoveFileL( tmpSource, tmpTarget, EFalse ) );
|
|
1179 |
}
|
|
1180 |
|
|
1181 |
LOGGER_WRITE_1( "CSConFTP::MoveFile() : end, err: %d", err );
|
|
1182 |
return err;
|
|
1183 |
}
|
|
1184 |
|
|
1185 |
// -----------------------------------------------------------------------------
|
|
1186 |
// CSConFTP::CopyFile()
|
|
1187 |
// Copy file/folder
|
|
1188 |
// -----------------------------------------------------------------------------
|
|
1189 |
//
|
|
1190 |
TInt CSConFTP::CopyFile(const TDesC& aSource, const TDesC& aTarget)
|
|
1191 |
{
|
|
1192 |
TRACE_FUNC_ENTRY;
|
|
1193 |
TInt err;
|
|
1194 |
TFileName tmpSource;
|
|
1195 |
TFileName tmpTarget;
|
|
1196 |
err = GetAbsolutePath( aSource, tmpSource );
|
|
1197 |
if (err == KErrNone)
|
|
1198 |
{
|
|
1199 |
err = GetAbsolutePath( aTarget, tmpTarget );
|
|
1200 |
}
|
|
1201 |
|
|
1202 |
if( err == KErrNone )
|
|
1203 |
{
|
|
1204 |
TInt sourceDrive;
|
|
1205 |
TInt targetDrive;
|
|
1206 |
|
|
1207 |
err = iFs.CharToDrive( tmpSource[0], sourceDrive );
|
|
1208 |
TInt err2 = iFs.CharToDrive( tmpTarget[0], targetDrive );
|
|
1209 |
|
|
1210 |
if( err != KErrNone || err2 != KErrNone
|
|
1211 |
|| !IsDriveVisible( sourceDrive )
|
|
1212 |
|| !IsDriveVisible( targetDrive ) )
|
|
1213 |
{
|
|
1214 |
// drive not visible to user
|
|
1215 |
err = KErrNotFound;
|
|
1216 |
}
|
|
1217 |
}
|
|
1218 |
|
|
1219 |
if (err == KErrNone)
|
|
1220 |
{
|
|
1221 |
TRAP( err,
|
|
1222 |
iSConFsHandler->DoCopyOrMoveFileL( tmpSource, tmpTarget, ETrue ) );
|
|
1223 |
}
|
|
1224 |
|
|
1225 |
LOGGER_WRITE_1( "CSConFTP::CopyFile() : end, ret: %d", err );
|
|
1226 |
return err;
|
|
1227 |
}
|
|
1228 |
|
|
1229 |
// -----------------------------------------------------------------------------
|
|
1230 |
// CSConFTP::SetReadOnly()
|
|
1231 |
// Set read-only permissions to file or folder
|
|
1232 |
// -----------------------------------------------------------------------------
|
|
1233 |
//
|
|
1234 |
TInt CSConFTP::SetReadOnly(const TDesC& aTarget, const TBool aReadOnly)
|
|
1235 |
{
|
|
1236 |
TRACE_FUNC_ENTRY;
|
|
1237 |
TInt err;
|
|
1238 |
TFileName tmpTarget;
|
|
1239 |
err = GetAbsolutePath( aTarget, tmpTarget );
|
|
1240 |
if( err != KErrNone )
|
|
1241 |
{
|
|
1242 |
return err;
|
|
1243 |
}
|
|
1244 |
else
|
|
1245 |
{
|
|
1246 |
TInt targetDrive;
|
|
1247 |
err = iFs.CharToDrive( tmpTarget[0], targetDrive );
|
|
1248 |
|
|
1249 |
if( err != KErrNone
|
|
1250 |
|| !IsDriveVisible( targetDrive ) )
|
|
1251 |
{
|
|
1252 |
// drive not visible to user
|
|
1253 |
return KErrNotFound;
|
|
1254 |
}
|
|
1255 |
}
|
|
1256 |
|
|
1257 |
TBool isFolder(EFalse);
|
|
1258 |
err = BaflUtils::IsFolder( iFs, tmpTarget, isFolder );
|
|
1259 |
if ( err == KErrNone && isFolder )
|
|
1260 |
{
|
|
1261 |
tmpTarget.Append(KPathDelimiter);
|
|
1262 |
}
|
|
1263 |
if ( !iSConFsHandler->IsFolderVisible( tmpTarget ) )
|
|
1264 |
{
|
|
1265 |
// folder is not visible to user
|
|
1266 |
err = KErrAccessDenied;
|
|
1267 |
}
|
|
1268 |
else
|
|
1269 |
{
|
|
1270 |
if( aReadOnly )
|
|
1271 |
{
|
|
1272 |
err = iFs.SetAtt( tmpTarget, KEntryAttReadOnly, KEntryAttArchive );
|
|
1273 |
}
|
|
1274 |
else
|
|
1275 |
{
|
|
1276 |
err = iFs.SetAtt( tmpTarget, KEntryAttNormal, KEntryAttReadOnly );
|
|
1277 |
}
|
|
1278 |
}
|
|
1279 |
|
|
1280 |
LOGGER_WRITE_1( "CSConFTP::SetReadOnly() : ret: %d", err );
|
|
1281 |
return err;
|
|
1282 |
}
|
|
1283 |
|
|
1284 |
// -----------------------------------------------------------------------------
|
|
1285 |
// CSConFTP::SetHidden()
|
|
1286 |
// Set hidden permissions to file or folder
|
|
1287 |
// -----------------------------------------------------------------------------
|
|
1288 |
//
|
|
1289 |
TInt CSConFTP::SetHidden( const TDesC& /*aTarget*/, const TBool /*aHidden*/ )
|
|
1290 |
{
|
|
1291 |
// This is currently not supported.
|
|
1292 |
LOGGER_WRITE("CSConFTP::SetHidden return KErrNotSupported");
|
|
1293 |
return KErrNotSupported;
|
|
1294 |
}
|
|
1295 |
|
|
1296 |
// -----------------------------------------------------------------------------
|
|
1297 |
// CSConFTP::GetAbsolutePath()
|
|
1298 |
// Get absolute path from relative file/folder
|
|
1299 |
// -----------------------------------------------------------------------------
|
|
1300 |
//
|
|
1301 |
TInt CSConFTP::GetAbsolutePath( const TDesC& aFolderName, TDes &aFullPath )
|
|
1302 |
{
|
|
1303 |
if (aFolderName.Length() == 0)
|
|
1304 |
{
|
|
1305 |
return KErrBadName;
|
|
1306 |
}
|
|
1307 |
//absolute folder path
|
|
1308 |
if( aFolderName.Length() > 1 && aFolderName[1] == KDriveDelimiter )
|
|
1309 |
{
|
|
1310 |
aFullPath.Copy( aFolderName );
|
|
1311 |
}
|
|
1312 |
// relative to the root folder
|
|
1313 |
else if( aFolderName[0] == KPathDelimiter )
|
|
1314 |
{
|
|
1315 |
if( iPathName.Length() < 2 )
|
|
1316 |
{
|
|
1317 |
return KErrBadName;
|
|
1318 |
}
|
|
1319 |
aFullPath.Copy( iPathName.Left(2) );
|
|
1320 |
aFullPath.Append( aFolderName );
|
|
1321 |
}
|
|
1322 |
// relative to the current folder
|
|
1323 |
else
|
|
1324 |
{
|
|
1325 |
aFullPath.Copy( iPathName );
|
|
1326 |
if( aFullPath.LocateReverse( KPathDelimiter ) != aFullPath.Length()-1 )
|
|
1327 |
{
|
|
1328 |
aFullPath.Append( KPathDelimiter );
|
|
1329 |
}
|
|
1330 |
aFullPath.Append( aFolderName );
|
|
1331 |
// no need to check internal root, because iPathName is real target.
|
|
1332 |
}
|
|
1333 |
|
|
1334 |
return KErrNone;
|
|
1335 |
}
|
|
1336 |
|
|
1337 |
// -----------------------------------------------------------------------------
|
|
1338 |
// CSConFTP::CSConFTP()
|
|
1339 |
// Default constructor
|
|
1340 |
// -----------------------------------------------------------------------------
|
|
1341 |
//
|
|
1342 |
CSConFTP::CSConFTP() : iProfile( EStandard ), iCurrentDrive( KErrNotFound )
|
|
1343 |
{
|
|
1344 |
}
|
|
1345 |
|
|
1346 |
// -----------------------------------------------------------------------------
|
|
1347 |
// CSConFTP::ConstructL()
|
|
1348 |
// Initializes member data
|
|
1349 |
// -----------------------------------------------------------------------------
|
|
1350 |
//
|
|
1351 |
void CSConFTP::ConstructL()
|
|
1352 |
{
|
|
1353 |
TRACE_FUNC_ENTRY;
|
|
1354 |
|
|
1355 |
iBuffer = CBufFlat::NewL( KSConBufSize );
|
|
1356 |
User::LeaveIfError( iFs.Connect() );
|
|
1357 |
iSConFsHandler = CSConFsHandler::NewL( iFs );
|
|
1358 |
iSConInboxHandler = CSConInboxHandler::NewL();
|
|
1359 |
|
|
1360 |
CRepository* repository = CRepository::NewLC( KCRUidDiskLevel );
|
|
1361 |
User::LeaveIfError( repository->Get( KDiskCriticalThreshold, iCriticalDiskLevel ) );
|
|
1362 |
CleanupStack::PopAndDestroy( repository );
|
|
1363 |
// inlcude package size
|
|
1364 |
iCriticalDiskLevel += KPackageSize;
|
|
1365 |
LOGGER_WRITE_1( "criticalLevel: %d", iCriticalDiskLevel );
|
|
1366 |
|
|
1367 |
TRACE_FUNC_EXIT;
|
|
1368 |
}
|
|
1369 |
|
|
1370 |
// -----------------------------------------------------------------------------
|
|
1371 |
// CSConFTP::GetVolumeNameL()
|
|
1372 |
// Get volume name
|
|
1373 |
// -----------------------------------------------------------------------------
|
|
1374 |
//
|
|
1375 |
TInt CSConFTP::GetVolumeNameL(const TInt aDriveNumber, TDes8& aVolumeName)
|
|
1376 |
{
|
|
1377 |
TRACE_FUNC_ENTRY;
|
|
1378 |
TVolumeInfo volumeInfo;
|
|
1379 |
TInt ret = iFs.Volume( volumeInfo, aDriveNumber );
|
|
1380 |
|
|
1381 |
if ( ret == KErrNone)
|
|
1382 |
{
|
|
1383 |
CnvUtfConverter::ConvertFromUnicodeToUtf8( aVolumeName,
|
|
1384 |
volumeInfo.iName );
|
|
1385 |
//Replace special characters
|
|
1386 |
for( TInt i = 0; i < aVolumeName.Length(); i++ )
|
|
1387 |
{
|
|
1388 |
switch( aVolumeName[i] )
|
|
1389 |
{
|
|
1390 |
case '&':
|
|
1391 |
aVolumeName.Delete( i, 1 );
|
|
1392 |
aVolumeName.Insert( i, KReplace1 );
|
|
1393 |
break;
|
|
1394 |
case '<':
|
|
1395 |
aVolumeName.Delete( i, 1 );
|
|
1396 |
aVolumeName.Insert( i, KReplace2 );
|
|
1397 |
break;
|
|
1398 |
case '>':
|
|
1399 |
aVolumeName.Delete( i, 1 );
|
|
1400 |
aVolumeName.Insert( i, KReplace3 );
|
|
1401 |
break;
|
|
1402 |
case '"':
|
|
1403 |
aVolumeName.Delete( i, 1 );
|
|
1404 |
aVolumeName.Insert( i, KReplace4 );
|
|
1405 |
break;
|
|
1406 |
case '\'':
|
|
1407 |
aVolumeName.Delete( i, 1 );
|
|
1408 |
aVolumeName.Insert( i, KReplace5 );
|
|
1409 |
break;
|
|
1410 |
default:
|
|
1411 |
break;
|
|
1412 |
}
|
|
1413 |
}
|
|
1414 |
|
|
1415 |
//No name
|
|
1416 |
if( aVolumeName.Length() == 0 )
|
|
1417 |
{
|
|
1418 |
LOGGER_WRITE( "Volume has no name, use default localized name" );
|
|
1419 |
//Read memory string and convert it
|
|
1420 |
TFileName file( KSConResourceName );
|
|
1421 |
|
|
1422 |
BaflUtils::NearestLanguageFile( iFs, file );
|
|
1423 |
|
|
1424 |
CStringResourceReader* reader = CStringResourceReader::NewL( file );
|
|
1425 |
CleanupStack::PushL( reader );
|
|
1426 |
TUint driveStatus;
|
|
1427 |
User::LeaveIfError( DriveInfo::GetDriveStatus( iFs, aDriveNumber, driveStatus ) );
|
|
1428 |
if( driveStatus & DriveInfo::EDriveRemovable )
|
|
1429 |
{
|
|
1430 |
// read default MMC name
|
|
1431 |
CnvUtfConverter::ConvertFromUnicodeToUtf8( aVolumeName,
|
|
1432 |
reader->ReadResourceString( R_SECON_VALUE_MMC ) );
|
|
1433 |
}
|
|
1434 |
else
|
|
1435 |
{
|
|
1436 |
// read default DEV name
|
|
1437 |
CnvUtfConverter::ConvertFromUnicodeToUtf8( aVolumeName,
|
|
1438 |
reader->ReadResourceString( R_SECON_VALUE_DEVICE ) );
|
|
1439 |
}
|
|
1440 |
CleanupStack::PopAndDestroy( reader );
|
|
1441 |
}
|
|
1442 |
}
|
|
1443 |
LOGGER_WRITE_1("GetVolumeNameL returned: %d", ret);
|
|
1444 |
return ret;
|
|
1445 |
}
|
|
1446 |
|
|
1447 |
// -----------------------------------------------------------------------------
|
|
1448 |
// CSConFTP::IsDriveVisible()
|
|
1449 |
// Check is drive visible for user
|
|
1450 |
// -----------------------------------------------------------------------------
|
|
1451 |
//
|
|
1452 |
TBool CSConFTP::IsDriveVisible( const TInt aDriveNumber )
|
|
1453 |
{
|
|
1454 |
TUint driveStatus;
|
|
1455 |
TInt err = DriveInfo::GetDriveStatus( iFs, aDriveNumber, driveStatus);
|
|
1456 |
if( err )
|
|
1457 |
{
|
|
1458 |
LOGGER_WRITE_1( "CSConFTP::IsDriveVisible() : DriveInfo::GetDriveStatus err: %d", err );
|
|
1459 |
return EFalse;
|
|
1460 |
}
|
|
1461 |
if( driveStatus & DriveInfo::EDriveRemote )
|
|
1462 |
{
|
|
1463 |
LOGGER_WRITE( "CSConFTP::IsDriveVisible() : remote drive" );
|
|
1464 |
return EFalse;
|
|
1465 |
}
|
|
1466 |
if( !(driveStatus & DriveInfo::EDriveUserVisible) )
|
|
1467 |
{
|
|
1468 |
LOGGER_WRITE( "CSConFTP::IsDriveVisible() : not visible" );
|
|
1469 |
return EFalse;
|
|
1470 |
}
|
|
1471 |
if( !(driveStatus & DriveInfo::EDrivePresent ) )
|
|
1472 |
{
|
|
1473 |
LOGGER_WRITE( "CSConFTP::IsDriveVisible() : not present" );
|
|
1474 |
return EFalse;
|
|
1475 |
}
|
|
1476 |
if( driveStatus & DriveInfo::EDriveCorrupt )
|
|
1477 |
{
|
|
1478 |
LOGGER_WRITE( "CSConFTP::IsDriveVisible() : corrupted" );
|
|
1479 |
return EFalse;
|
|
1480 |
}
|
|
1481 |
else
|
|
1482 |
{
|
|
1483 |
return ETrue;
|
|
1484 |
}
|
|
1485 |
}
|
|
1486 |
|
|
1487 |
// -----------------------------------------------------------------------------
|
|
1488 |
// CSConFTP::UpdateDriveTypeInfoL()
|
|
1489 |
// Test is current volume still ok.
|
|
1490 |
// -----------------------------------------------------------------------------
|
|
1491 |
//
|
|
1492 |
TBool CSConFTP::IsCurrentVolumeOK()
|
|
1493 |
{
|
|
1494 |
if( iCurrentDrive == KErrNotFound )
|
|
1495 |
{
|
|
1496 |
LOGGER_WRITE( "CSConFTP::IsCurrentVolumeOK() : not set" );
|
|
1497 |
return EFalse;
|
|
1498 |
}
|
|
1499 |
|
|
1500 |
TUint driveStatus;
|
|
1501 |
TInt err = DriveInfo::GetDriveStatus( iFs, iCurrentDrive, driveStatus);
|
|
1502 |
if( err )
|
|
1503 |
{
|
|
1504 |
LOGGER_WRITE_1( "CSConFTP::IsCurrentVolumeOK() : DriveInfo::GetDriveStatus err: %d", err );
|
|
1505 |
return EFalse;
|
|
1506 |
}
|
|
1507 |
if( !(driveStatus & DriveInfo::EDrivePresent ))
|
|
1508 |
{
|
|
1509 |
LOGGER_WRITE( "CSConFTP::IsCurrentVolumeOK() : not present" );
|
|
1510 |
return EFalse;
|
|
1511 |
}
|
|
1512 |
if( driveStatus & DriveInfo::EDriveCorrupt )
|
|
1513 |
{
|
|
1514 |
LOGGER_WRITE( "CSConFTP::IsCurrentVolumeOK() : corrupted" );
|
|
1515 |
return EFalse;
|
|
1516 |
}
|
|
1517 |
else
|
|
1518 |
{
|
|
1519 |
return ETrue;
|
|
1520 |
}
|
|
1521 |
}
|
|
1522 |
|
|
1523 |
// -----------------------------------------------------------------------------
|
|
1524 |
// CSConFTP::UpdateDriveTypeInfoL()
|
|
1525 |
// Updates drive information (iCurrentDrive and iCurrentDriveTypeNumber)
|
|
1526 |
// -----------------------------------------------------------------------------
|
|
1527 |
//
|
|
1528 |
void CSConFTP::UpdateDriveTypeInfoL()
|
|
1529 |
{
|
|
1530 |
TRACE_FUNC_ENTRY;
|
|
1531 |
TInt driveNumber;
|
|
1532 |
iCurrentDriveTypeNumber = 0;
|
|
1533 |
|
|
1534 |
if( iPathName.Length() == 0 )
|
|
1535 |
{
|
|
1536 |
LOGGER_WRITE( "CSConFTP::UpdateDriveTypeInfoL() : drive not specified" );
|
|
1537 |
iCurrentDrive = KErrNotFound;
|
|
1538 |
return;
|
|
1539 |
}
|
|
1540 |
|
|
1541 |
User::LeaveIfError( iFs.CharToDrive(iPathName[0], driveNumber) );
|
|
1542 |
iCurrentDrive = driveNumber;
|
|
1543 |
|
|
1544 |
TUint driveStatus;
|
|
1545 |
User::LeaveIfError( DriveInfo::GetDriveStatus( iFs, iCurrentDrive, driveStatus ) );
|
|
1546 |
// if true, search internal drives, else search removable drives
|
|
1547 |
TBool searchInternalDrives = (driveStatus & DriveInfo::EDriveInternal);
|
|
1548 |
|
|
1549 |
TInt driveCount;
|
|
1550 |
TDriveList driveList;
|
|
1551 |
|
|
1552 |
User::LeaveIfError( DriveInfo::GetUserVisibleDrives( iFs, driveList, driveCount ) );
|
|
1553 |
|
|
1554 |
for( TInt i = EDriveA; i <= iCurrentDrive; i++ )
|
|
1555 |
{
|
|
1556 |
if( driveList[i] )
|
|
1557 |
{
|
|
1558 |
TUint driveStatus;
|
|
1559 |
User::LeaveIfError( DriveInfo::GetDriveStatus( iFs, i, driveStatus ) );
|
|
1560 |
|
|
1561 |
if( !(driveStatus & DriveInfo::EDrivePresent )
|
|
1562 |
|| driveStatus & DriveInfo::EDriveCorrupt )
|
|
1563 |
{
|
|
1564 |
LOGGER_WRITE( "not present or corrupted" );
|
|
1565 |
continue;
|
|
1566 |
}
|
|
1567 |
|
|
1568 |
if( driveStatus & DriveInfo::EDriveInternal )
|
|
1569 |
{
|
|
1570 |
if( searchInternalDrives )
|
|
1571 |
{
|
|
1572 |
iCurrentDriveTypeNumber++;
|
|
1573 |
}
|
|
1574 |
}
|
|
1575 |
else if( driveStatus & DriveInfo::EDriveRemovable )
|
|
1576 |
{
|
|
1577 |
if( !searchInternalDrives )
|
|
1578 |
{
|
|
1579 |
iCurrentDriveTypeNumber++;
|
|
1580 |
}
|
|
1581 |
}
|
|
1582 |
}
|
|
1583 |
}
|
|
1584 |
TRACE_FUNC_EXIT;
|
|
1585 |
}
|
|
1586 |
|
|
1587 |
// End of file
|
|
1588 |
|