filemanager/src/inc/fmutils_s60.cpp
author hgs
Thu, 05 Aug 2010 11:30:07 +0800
changeset 33 328cf6fbe40c
parent 32 39cf9ced4cc4
child 40 4167eb56f30d
permissions -rw-r--r--
201031
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*     Zhiqiang Yang <zhiqiang.yang@nokia.com>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* 
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
* Description:
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*     The source file of the file manager utilities
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
*/
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include "fmutils.h"
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include "fms60utils.h"
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include "fmcommon.h"
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
#include <QRegExp>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <coemain.h>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <driveinfo.h>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include <e32property.h>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include <coreapplicationuisdomainpskeys.h>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include <f32file.h>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include <apgcli.h>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include <pathinfo.h>
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    33
#include <CDirectoryLocalizer.h>
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
#include <XQConversions>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
#include <QStringList>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#include <QFileInfoList>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#include <QDir>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
#include <QFile>
33
hgs
parents: 32
diff changeset
    39
#include <QIODevice>
hgs
parents: 32
diff changeset
    40
#include <XQConversions>
25
hgs
parents: 16
diff changeset
    41
#include <hbglobal.h>
hgs
parents: 16
diff changeset
    42
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
#include <xqaiwrequest.h>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
#include <xqappmgr.h>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
25
hgs
parents: 16
diff changeset
    46
#include <shareui.h>
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
#define BURCONFIGFILE  "z:/private/2002BCC0/burconfig.xml"
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
33
hgs
parents: 32
diff changeset
    50
hgs
parents: 32
diff changeset
    51
/*!
hgs
parents: 32
diff changeset
    52
    Used to get drive type for convenience.
hgs
parents: 32
diff changeset
    53
*/
hgs
parents: 32
diff changeset
    54
FmDriverInfo::DriveType FmDriverInfo::driveType()
hgs
parents: 32
diff changeset
    55
{
hgs
parents: 32
diff changeset
    56
    FmDriverInfo::DriveType driveType;
hgs
parents: 32
diff changeset
    57
    if( mDriveState & FmDriverInfo::EDriveRemovable ) {
hgs
parents: 32
diff changeset
    58
        if( mDriveState & FmDriverInfo::EDriveMassStorage ) {
hgs
parents: 32
diff changeset
    59
            driveType = FmDriverInfo::EDriveTypeMassStorage;
hgs
parents: 32
diff changeset
    60
        } else if( mDriveState & FmDriverInfo::EDriveUsbMemory ) {
hgs
parents: 32
diff changeset
    61
            driveType = FmDriverInfo::EDriveTypeUsbMemory;
hgs
parents: 32
diff changeset
    62
        } else if( mDriveState & FmDriverInfo::EDriveRemote ){
hgs
parents: 32
diff changeset
    63
            driveType = FmDriverInfo::EDriveTypeRemote;
hgs
parents: 32
diff changeset
    64
        } else {
hgs
parents: 32
diff changeset
    65
            driveType = FmDriverInfo::EDriveTypeMemoryCard;
hgs
parents: 32
diff changeset
    66
        }
hgs
parents: 32
diff changeset
    67
    } else if( mDriveState & FmDriverInfo::EDriveRom ) {
hgs
parents: 32
diff changeset
    68
        driveType = FmDriverInfo::EDriveTypeRom;
hgs
parents: 32
diff changeset
    69
    } else if( mDriveState & FmDriverInfo::EDriveRam ) {
hgs
parents: 32
diff changeset
    70
        driveType = FmDriverInfo::EDriveTypeRam;
hgs
parents: 32
diff changeset
    71
    } else {
hgs
parents: 32
diff changeset
    72
        driveType = FmDriverInfo::EDriveTypePhoneMemory;
hgs
parents: 32
diff changeset
    73
    }
hgs
parents: 32
diff changeset
    74
    
hgs
parents: 32
diff changeset
    75
    return driveType;
hgs
parents: 32
diff changeset
    76
}
hgs
parents: 32
diff changeset
    77
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
QString FmUtils::getDriveNameFromPath( const QString &path )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
{
25
hgs
parents: 16
diff changeset
    80
    // fillPathWithSplash make sure path length will be at least 3 if it is not empty.
hgs
parents: 16
diff changeset
    81
    QString checkedPath( fillPathWithSplash( path ) );
hgs
parents: 16
diff changeset
    82
    if( checkedPath.length() < 3 ) {
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
        return QString();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
    }
25
hgs
parents: 16
diff changeset
    85
    return checkedPath.left( 3 );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    88
QString FmUtils::getDriveLetterFromPath( const QString &path )
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    89
{
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    90
	if( path.length() <2 ) {
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    91
        return QString();
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    92
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    93
    return path.left( 1 );
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    94
}
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    95
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
FmDriverInfo FmUtils::queryDriverInfo( const QString &driverName )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
{
25
hgs
parents: 16
diff changeset
    98
    if( driverName.isEmpty() ) {
hgs
parents: 16
diff changeset
    99
        return FmDriverInfo( 0, 0, driverName, QString(), FmDriverInfo::EDriveNotPresent );
hgs
parents: 16
diff changeset
   100
    }
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   101
    CCoeEnv *env = CCoeEnv::Static();
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   102
    RFs& fs = env->FsSession();
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   103
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   104
    TVolumeInfo volumeInfo;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   105
    TInt drive = 0;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   106
    drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   107
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   108
    quint32 state( 0 );
25
hgs
parents: 16
diff changeset
   109
    int volumeInfoErr( KErrNone );
hgs
parents: 16
diff changeset
   110
    int driveInfoErr( KErrNone );
hgs
parents: 16
diff changeset
   111
    int errorCode( KErrNone );
hgs
parents: 16
diff changeset
   112
    volumeInfoErr = fs.Volume( volumeInfo, drive );
hgs
parents: 16
diff changeset
   113
    errorCode = volumeInfoErr;
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   114
    QString volumeName( (QChar*)( volumeInfo.iName.Des().Ptr() ), volumeInfo.iName.Length() );
25
hgs
parents: 16
diff changeset
   115
    
hgs
parents: 16
diff changeset
   116
    TDriveInfo driveInfo;
hgs
parents: 16
diff changeset
   117
    if( volumeInfoErr == KErrNone ) {
hgs
parents: 16
diff changeset
   118
        driveInfo = volumeInfo.iDrive;
hgs
parents: 16
diff changeset
   119
    } else {
hgs
parents: 16
diff changeset
   120
        driveInfoErr = fs.Drive( driveInfo, drive );
hgs
parents: 16
diff changeset
   121
        if( driveInfoErr != KErrNone ) {
hgs
parents: 16
diff changeset
   122
            errorCode = driveInfoErr;
hgs
parents: 16
diff changeset
   123
        }
hgs
parents: 16
diff changeset
   124
    }
hgs
parents: 16
diff changeset
   125
    
27
hgs
parents: 25
diff changeset
   126
    if( volumeInfoErr == KErrNone || driveInfoErr == KErrNone ) {
25
hgs
parents: 16
diff changeset
   127
        //TDriveInfo driveInfo = volumeInfo.iDrive;
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   128
    
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   129
        quint32 drvStatus( 0 );
25
hgs
parents: 16
diff changeset
   130
        int err = DriveInfo::GetDriveStatus( fs, drive, drvStatus );
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   131
        if( err == KErrNone ) {
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   132
            
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   133
            if ( ( drvStatus & DriveInfo::EDriveInternal ) &&
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   134
                 ( drvStatus & DriveInfo::EDriveExternallyMountable ) ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   135
                // Handle mass storage bits here
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   136
        
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   137
                state |= FmDriverInfo::EDriveMassStorage | FmDriverInfo::EDriveRemovable;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   138
            }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   139
        
25
hgs
parents: 16
diff changeset
   140
            if ( drvStatus & DriveInfo::EDriveUsbMemory )
hgs
parents: 16
diff changeset
   141
                {
hgs
parents: 16
diff changeset
   142
                state |= FmDriverInfo::EDriveUsbMemory;
hgs
parents: 16
diff changeset
   143
                }
33
hgs
parents: 32
diff changeset
   144
            
hgs
parents: 32
diff changeset
   145
            if ( drvStatus & DriveInfo::EDriveRemote )
hgs
parents: 32
diff changeset
   146
                {
hgs
parents: 32
diff changeset
   147
                state |= FmDriverInfo::EDriveRemote;
hgs
parents: 32
diff changeset
   148
                }
hgs
parents: 32
diff changeset
   149
            
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   150
            if ( drvStatus & DriveInfo::EDriveRom ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   151
                state |= FmDriverInfo::EDriveRom;  
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   152
            }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   153
            
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   154
            if ( drvStatus & DriveInfo::EDriveRam ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   155
                state |= FmDriverInfo::EDriveRam;  
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   156
            }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   157
        
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   158
            if ( driveInfo.iMediaAtt & KMediaAttFormattable ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   159
                state |= FmDriverInfo::EDriveFormattable;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   160
            }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   161
            if ( driveInfo.iMediaAtt & KMediaAttWriteProtected ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   162
                state |= FmDriverInfo::EDriveWriteProtected;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   163
            }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   164
            if ( driveInfo.iMediaAtt & KMediaAttHasPassword ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   165
                state |= FmDriverInfo::EDrivePasswordProtected;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   166
            }    
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   167
            if ( driveInfo.iMediaAtt & KMediaAttLocked ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   168
                state |= FmDriverInfo::EDriveLocked;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   169
            }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   170
        
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   171
            if ( driveInfo.iDriveAtt & KDriveAttRemovable ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   172
                state |= FmDriverInfo::EDriveRemovable;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   173
        
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   174
                if ( drvStatus & DriveInfo::EDriveSwEjectable ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   175
                    state |= FmDriverInfo::EDriveEjectable;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   176
                }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   177
            }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   178
            
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   179
            if( driveInfo.iType == EMediaNotPresent ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   180
                state |= FmDriverInfo::EDriveNotPresent;    
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   181
            }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   182
        }
25
hgs
parents: 16
diff changeset
   183
        // If memory card is not ready but type is present,
hgs
parents: 16
diff changeset
   184
        // then check if it is reserved.
hgs
parents: 16
diff changeset
   185
        if( err == KErrNone && volumeInfoErr == KErrNotReady &&
hgs
parents: 16
diff changeset
   186
            driveInfo.iType != EMediaNotPresent )
hgs
parents: 16
diff changeset
   187
            {
hgs
parents: 16
diff changeset
   188
            // Check USB file transfer state
hgs
parents: 16
diff changeset
   189
            TInt prop( ECoreAppUIsUSBFileTransferUninitialized );
hgs
parents: 16
diff changeset
   190
            RProperty::Get(
hgs
parents: 16
diff changeset
   191
                KPSUidCoreApplicationUIs,
hgs
parents: 16
diff changeset
   192
                KCoreAppUIsUSBFileTransfer, prop );
hgs
parents: 16
diff changeset
   193
            if ( prop == ECoreAppUIsUSBFileTransferActive )
hgs
parents: 16
diff changeset
   194
                {
hgs
parents: 16
diff changeset
   195
                errorCode = KErrInUse; // Reserved for file transfer
hgs
parents: 16
diff changeset
   196
                }
hgs
parents: 16
diff changeset
   197
            }
hgs
parents: 16
diff changeset
   198
        if( err!= KErrNone )
hgs
parents: 16
diff changeset
   199
            {
hgs
parents: 16
diff changeset
   200
            errorCode = err;
hgs
parents: 16
diff changeset
   201
            }
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   202
    }
25
hgs
parents: 16
diff changeset
   203
hgs
parents: 16
diff changeset
   204
    // handle error code
hgs
parents: 16
diff changeset
   205
    // volumeInfoErr will occur while drive is lock,corrupted...
hgs
parents: 16
diff changeset
   206
    // driveInfoErr can not be promoted for locked, corrupted drive.
hgs
parents: 16
diff changeset
   207
    // so we can not use driveInfoErr to justify EDriveAvailable
hgs
parents: 16
diff changeset
   208
    switch( errorCode )
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   209
    {
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   210
    case KErrNone:
25
hgs
parents: 16
diff changeset
   211
        // this drive could be used as it is not be locked, or corrupt.
hgs
parents: 16
diff changeset
   212
        state |= FmDriverInfo::EDriveAvailable; 
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   213
        break;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   214
    case KErrLocked:
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   215
        state |= FmDriverInfo::EDriveLocked;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   216
        break;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   217
    case KErrCorrupt:
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   218
        state |= FmDriverInfo::EDriveCorrupted;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   219
        break;
25
hgs
parents: 16
diff changeset
   220
    case KErrInUse:
hgs
parents: 16
diff changeset
   221
        state |= FmDriverInfo::EDriveInUse;
hgs
parents: 16
diff changeset
   222
        break;
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   223
    default: // other errors
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   224
        state |= FmDriverInfo::EDriveNotPresent;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   225
        break;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   226
    }
25
hgs
parents: 16
diff changeset
   227
    QString logString ( "FmUtils::queryDriverInfo_" + driverName + 
hgs
parents: 16
diff changeset
   228
            "_volumeInfoErr:" + QString::number( volumeInfoErr ) +
hgs
parents: 16
diff changeset
   229
            "_driveInfoErr:" + QString::number( driveInfoErr ) +
hgs
parents: 16
diff changeset
   230
            "_errorCode:" + QString::number( errorCode ) + 
hgs
parents: 16
diff changeset
   231
            "_driveSatus:" + QString::number( state ) );
32
hgs
parents: 27
diff changeset
   232
    FM_LOG( logString );
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   233
    return FmDriverInfo( volumeInfo.iSize, volumeInfo.iFree, driverName, volumeName, state );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
QString FmUtils::formatStorageSize( quint64 size )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
	if ( size < 1000 ) {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
		return QString::number( size ) + " B";
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
	} else if ( size < 1000 * 1000 ) {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
		return QString::number( size / 1024.0, 'f', 2 ) + " KB";
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
	} else if ( size < 1000 * 1000 * 1000 ) {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
		return QString::number( size / (1024.0 * 1024.0), 'f', 1 ) + " MB";
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
	} else {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
	    return QString::number( size / ( 1024.0 * 1024.0 * 1024.0 ), 'f', 1 ) + " GB";	    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
	}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
int FmUtils::removeDrivePwd( const QString &driverName,  const QString &Pwd )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
{
33
hgs
parents: 32
diff changeset
   251
    if( driverName.isEmpty() || Pwd.length() > FmMaxLengthofDrivePassword ) {
25
hgs
parents: 16
diff changeset
   252
        return FmErrWrongParam;
hgs
parents: 16
diff changeset
   253
    }
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
    QString logString = "Drive name:" + driverName;
32
hgs
parents: 27
diff changeset
   255
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
    logString = "Password:" + Pwd;
32
hgs
parents: 27
diff changeset
   257
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
    CCoeEnv *env = CCoeEnv::Static();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
	RFs& fs = env->FsSession();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
    TInt drive = 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
33
hgs
parents: 32
diff changeset
   264
    drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
    HBufC* password16 = XQConversions::qStringToS60Desc( Pwd );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
    TMediaPassword password;   
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
    TPtr ptrPassword16( password16->Des() );  
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
    FmS60Utils::ConvertCharsToPwd( ptrPassword16, password );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
    int err( fs.ClearPassword( drive, password ) );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
    logString = "Drive:" + QString::number( drive );
32
hgs
parents: 27
diff changeset
   274
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
    logString = "Clear password error:" + QString::number( err );
32
hgs
parents: 27
diff changeset
   277
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
33
hgs
parents: 32
diff changeset
   279
    delete password16;
hgs
parents: 32
diff changeset
   280
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   281
    if( err == KErrNone ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   282
        return FmErrNone;   
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   283
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   284
    else if( err == KErrAccessDenied ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   285
        return FmErrAccessDenied;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   286
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   287
    else{
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   288
        return FmErrUnKnown;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   289
    }
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
int FmUtils::unlockDrive( const QString &driverName,  const QString &Pwd )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
{
33
hgs
parents: 32
diff changeset
   294
    if( driverName.isEmpty() || Pwd.length() > FmMaxLengthofDrivePassword ) {
25
hgs
parents: 16
diff changeset
   295
        return FmErrWrongParam;
hgs
parents: 16
diff changeset
   296
    }
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
    QString logString = "Drive name:" + driverName;
32
hgs
parents: 27
diff changeset
   298
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
    logString = "Password:" + Pwd;
32
hgs
parents: 27
diff changeset
   300
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
    CCoeEnv *env = CCoeEnv::Static();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
	RFs& fs = env->FsSession();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
    TInt drive = 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
	drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
    HBufC* password16 = XQConversions::qStringToS60Desc( Pwd );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
    TMediaPassword password;   
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
    TPtr ptrPassword16( password16->Des() );  
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
    FmS60Utils::ConvertCharsToPwd( ptrPassword16, password );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
    int err( fs.UnlockDrive( drive, password, ETrue) );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
    logString = "Drive:" + QString::number( drive );
32
hgs
parents: 27
diff changeset
   316
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
    logString = "Unlock drive error:" + QString::number( err );
32
hgs
parents: 27
diff changeset
   318
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
33
hgs
parents: 32
diff changeset
   320
    delete password16;
hgs
parents: 32
diff changeset
   321
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   322
    if( err == KErrNone ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   323
        return FmErrNone;   
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   324
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   325
    else if( err == KErrAccessDenied ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   326
        return FmErrAccessDenied;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   327
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   328
    else if( err == KErrAlreadyExists ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   329
        return FmErrAlreadyExists;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   330
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   331
    else if( err == KErrNotSupported ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   332
        return FmErrNotSupported;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   333
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   334
    else{
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   335
        return FmErrUnKnown;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   336
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   337
}
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   338
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   339
int FmUtils::checkDrivePwd( const QString &driverName, const QString &pwd )
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   340
{
33
hgs
parents: 32
diff changeset
   341
    if( driverName.isEmpty() || pwd.length() > FmMaxLengthofDrivePassword ) {
25
hgs
parents: 16
diff changeset
   342
        return FmErrWrongParam;
hgs
parents: 16
diff changeset
   343
    }
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   344
    QString logString = "checkDrivePwd Drive name:" + driverName;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   345
    logString += " password:" + pwd;
32
hgs
parents: 27
diff changeset
   346
    FM_LOG( logString );
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   347
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   348
    return setDrivePwd( driverName, pwd, pwd );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
int FmUtils::setDrivePwd( const QString &driverName, const QString &oldPwd, const QString &newPwd)
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
{
33
hgs
parents: 32
diff changeset
   353
    if( driverName.isEmpty() || 
hgs
parents: 32
diff changeset
   354
        oldPwd.length() > FmMaxLengthofDrivePassword || newPwd.length() > FmMaxLengthofDrivePassword  ) {
25
hgs
parents: 16
diff changeset
   355
        return FmErrWrongParam;
hgs
parents: 16
diff changeset
   356
    }
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   357
    QString logString = "setDrivePwd Drive name:" + driverName ;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   358
    logString += " Old password:" + oldPwd;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   359
    logString += " New password:" + newPwd;
32
hgs
parents: 27
diff changeset
   360
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
    CCoeEnv *env = CCoeEnv::Static();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
	RFs& fs = env->FsSession();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
    TInt drive = 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
	drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
	
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
    HBufC* newPassword16 = XQConversions::qStringToS60Desc( newPwd);
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
    HBufC* oldPassword16 = XQConversions::qStringToS60Desc( oldPwd );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
    TMediaPassword oldPassword;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
    TMediaPassword newPassword;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
    TPtr ptrNewPassword16( newPassword16->Des() );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
    TPtr ptrOldPassword16( oldPassword16->Des() );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
    FmS60Utils::ConvertCharsToPwd( ptrNewPassword16, newPassword );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
    FmS60Utils::ConvertCharsToPwd( ptrOldPassword16, oldPassword );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
    int err( fs.LockDrive( drive, oldPassword, newPassword, ETrue ) );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
    logString = "Drive:" + QString::number( drive );
32
hgs
parents: 27
diff changeset
   383
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
    logString = "Password set error:" + QString::number( err );
32
hgs
parents: 27
diff changeset
   385
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
33
hgs
parents: 32
diff changeset
   387
    delete newPassword16;
hgs
parents: 32
diff changeset
   388
    delete oldPassword16;
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   389
    if( err == KErrNone ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   390
        return FmErrNone;   
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   391
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   392
    else if( err == KErrNotSupported ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   393
        return FmErrNotSupported;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   394
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   395
    else{
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   396
        return FmErrUnKnown;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   397
    }
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
void FmUtils::emptyPwd( QString &pwd )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
{
33
hgs
parents: 32
diff changeset
   402
    TBuf< FmMaxLengthofDrivePassword > nullPwd;
hgs
parents: 32
diff changeset
   403
    nullPwd.FillZ( nullPwd.MaxLength() );
hgs
parents: 32
diff changeset
   404
    nullPwd.Zero();
hgs
parents: 32
diff changeset
   405
    pwd = XQConversions::s60DescToQString( nullPwd );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
int FmUtils::renameDrive( const QString &driverName, const QString &newVolumeName)
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
{
25
hgs
parents: 16
diff changeset
   410
    if( driverName.isEmpty() ) {
hgs
parents: 16
diff changeset
   411
        return FmErrWrongParam;
hgs
parents: 16
diff changeset
   412
    }
hgs
parents: 16
diff changeset
   413
    foreach( const QChar &ch, newVolumeName )
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   414
    {
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   415
        bool a = ch.isSpace();
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   416
        bool b = ch.isLetterOrNumber();
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   417
        // If not alphadigit or space, return error
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   418
        if( !ch.isLetterOrNumber() && !ch.isSpace() )
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   419
        {
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   420
            return FmErrBadName;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   421
        }   
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   422
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   423
        
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
    CCoeEnv *env = CCoeEnv::Static();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
	RFs& fs = env->FsSession();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
    TInt drive = 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
	drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
    TPtr newName ( ( XQConversions::qStringToS60Desc( newVolumeName ) )->Des() );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
    int err( fs.SetVolumeLabel( newName, drive ));
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
    QString logString = "Rename error:" + QString::number( err );
32
hgs
parents: 27
diff changeset
   435
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   437
    if( err == KErrNone ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   438
        return FmErrNone;   
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   439
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   440
    else if( err == KErrNotReady ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   441
        return FmErrNotReady;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   442
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   443
    else{
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   444
        return FmErrUnKnown;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   445
    }
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
25
hgs
parents: 16
diff changeset
   448
int FmUtils::ejectDrive( const QString &driverName )
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
{
25
hgs
parents: 16
diff changeset
   450
    if( driverName.isEmpty() ) {
hgs
parents: 16
diff changeset
   451
        return FmErrWrongParam;
hgs
parents: 16
diff changeset
   452
    }
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   453
    QString logString = "FmUtils::ejectDrive start";
32
hgs
parents: 27
diff changeset
   454
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
    TInt drive = 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
	drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
    const int KDriveShift = 16;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   461
    // Let SysAp handle eject
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
    RProperty::Set(
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
        KPSUidCoreApplicationUIs,
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
        KCoreAppUIsMmcRemovedWithoutEject,
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
        ECoreAppUIsEjectCommandUsedToDrive | ( drive << KDriveShift )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
        );
25
hgs
parents: 16
diff changeset
   467
    return FmErrNone;
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
QString FmUtils::getFileType( const QString &filePath  )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
    RApaLsSession apaSession;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
    TDataType dataType;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
    TUid appUid;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
    TBuf<128> mimeTypeBuf;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   477
        
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   478
    int err = apaSession.Connect();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
    if ( err == KErrNone ){   
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
        err = apaSession.AppForDocument( XQConversions::qStringToS60Desc( filePath )->Des(), 
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
                                         appUid, dataType );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
        
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
        if( err == KErrNone ){
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
            mimeTypeBuf.Copy(dataType.Des8());
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
        }  
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
    apaSession.Close();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
    return XQConversions::s60DescToQString( mimeTypeBuf );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
quint64 FmUtils::getDriveDetailsResult( const QString &folderPath, const QString &extension )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
    int err;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
    RFs fs;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
    err = fs.Connect();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
    
33
hgs
parents: 32
diff changeset
   500
    QString string( fillPathWithSplash( folderPath ) );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
    TPtrC desFolderPath( XQConversions::qStringToS60Desc( string )->Des() );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
    TPtrC ptrExtension( XQConversions::qStringToS60Desc( extension )->Des() );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
    CDir* results = 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
    TParse parse;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
    quint64 size = 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
    const TInt pathlength = ptrExtension.Length() + desFolderPath.Length();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
    if ( pathlength > KMaxFileName ){
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
        err = KErrNotFound;   
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
    else{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
        err = fs.Parse( ptrExtension, desFolderPath, parse );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
        err = fs.GetDir( parse.FullName(), KEntryAttMaskSupported|KEntryAttAllowUid, 
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
            ESortNone, results );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
        
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
        TDesC des = parse.FullName();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
        
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
        if (err == KErrNotFound)
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
            {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
            return 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
            }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
    if ( results ){
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
        CleanupStack::PushL(results);
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
        // Go through all files in the list and tell subclass
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
        TFileName file;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
        const TInt count = results->Count();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
        for( TInt i=0; i<count; ++i ){
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
            const TEntry& entry = (*results)[i];
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
            file = desFolderPath;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
            file += entry.iName;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
            size += entry.iSize;          
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
        }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
        CleanupStack::PopAndDestroy(results);
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
    fs.Close();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
    return size;  
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
bool FmUtils::isDriveC( const QString &driverName )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
{
25
hgs
parents: 16
diff changeset
   550
    if( driverName.isEmpty() ) {
hgs
parents: 16
diff changeset
   551
        return false;
hgs
parents: 16
diff changeset
   552
    }
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
    TInt drive = 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
    drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
    if( drive == EDriveC ){
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
        return true;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
    else{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
        return false;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
   
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   564
bool FmUtils::isDrive( const QString &path )
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   565
{
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   566
   bool ret( false );
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   567
   if( path.length() <= 3 && path.length() >=2 ) {
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   568
       ret = true;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   569
   }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   570
   
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   571
   return ret;   
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   572
}
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   573
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
void FmUtils::createDefaultFolders( const QString &driverName )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
{
25
hgs
parents: 16
diff changeset
   576
    if( driverName.isEmpty() ) {
hgs
parents: 16
diff changeset
   577
        return;
hgs
parents: 16
diff changeset
   578
    }
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
    int err;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
    TInt drive = 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
    drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
    RFs fs;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
    err = fs.Connect();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   586
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
    if( err != KErrNone ){
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
        return;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   589
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   590
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   591
    quint32 drvStatus( 0 );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   592
    err = DriveInfo::GetDriveStatus( fs, drive, drvStatus );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   593
    if ( !( drvStatus & DriveInfo::EDriveUserVisible ) ||
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
        ( drvStatus & ( DriveInfo::EDriveRemote |
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   595
                        DriveInfo::EDriveReadOnly |
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
                        DriveInfo::EDriveUsbMemory ) ) ){
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   597
            return; 
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
        }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   600
    TEntry entry;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   601
    CDesCArray* array = PathInfo::GetListOfPathsLC( drive );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   602
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   603
    TInt count( array->MdcaCount() );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   604
    for ( TInt i( 0 ); i < count; ++i )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   605
        {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   606
        TPtrC fullPath( array->MdcaPoint( i ) );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   607
        TBool allow( ETrue );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   608
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   609
        if ( drvStatus & DriveInfo::EDriveRemovable )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   610
            {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   611
            // Filter few folder types from physically removable memory cards
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   612
            TInt pathType( PathInfo::PathType( fullPath ) );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   613
            switch( pathType )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
                {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   615
                case PathInfo::EGamesPath: // FALL THROUGH
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   616
                case PathInfo::EInstallsPath: // FALL THROUGH
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
                case PathInfo::EGsmPicturesPath: // FALL THROUGH
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   618
                case PathInfo::EMmsBackgroundImagesPath: // FALL THROUGH
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   619
                case PathInfo::EPresenceLogosPath:
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   620
                    {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   621
                    allow = EFalse;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   622
                    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   623
                default:
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   624
                    {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   625
                    break;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   626
                    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   627
                }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   628
            }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   629
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
        if ( allow ){
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   631
            fs.MkDirAll( fullPath ); // Ignore error
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   632
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
            if ( fs.Entry( fullPath, entry ) == KErrNone ){
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   634
                if( entry.IsHidden() ){
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   635
                // If setting fails, File Manager can still go on
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   636
                    fs.SetEntry(
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   637
                         fullPath, entry.iModified, 0, KEntryAttHidden );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   638
                }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   639
            }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
        }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   641
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   642
    CleanupStack::PopAndDestroy( array );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   643
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   644
33
hgs
parents: 32
diff changeset
   645
/*!
hgs
parents: 32
diff changeset
   646
    fill splash in the end of \a filePath if the path is not a file
hgs
parents: 32
diff changeset
   647
    All "/" and "\" will be changed to QDir::separator
hgs
parents: 32
diff changeset
   648
    \sa formatPath only changed "/" and "\" to QDir::separator
hgs
parents: 32
diff changeset
   649
*/
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   650
QString FmUtils::fillPathWithSplash( const QString &filePath )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   651
{
25
hgs
parents: 16
diff changeset
   652
	QString newFilePath;
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   653
    if( filePath.isEmpty() ) {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   654
        return newFilePath;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   655
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   656
33
hgs
parents: 32
diff changeset
   657
    newFilePath = formatPath( filePath );
25
hgs
parents: 16
diff changeset
   658
    
hgs
parents: 16
diff changeset
   659
    if( newFilePath.right( 1 )!= QDir::separator() ){
hgs
parents: 16
diff changeset
   660
        newFilePath.append( QDir::separator() );
hgs
parents: 16
diff changeset
   661
    }
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   662
    return newFilePath;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   663
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   664
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
QString FmUtils::removePathSplash( const QString &filePath )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   667
    QString newFilePath( filePath );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   668
    if( filePath.right( 1 ) == QChar( '/' ) || filePath.right(1) == QString( "\\" ) ) {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   669
        newFilePath = filePath.left( filePath.length() - 1 );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   670
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
    return newFilePath;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
25
hgs
parents: 16
diff changeset
   674
// filter un-accessable drive
hgs
parents: 16
diff changeset
   675
bool FmUtils::checkDriveAccessFilter( const QString &driveName )
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
{
25
hgs
parents: 16
diff changeset
   677
    if( driveName.isEmpty() ) {
hgs
parents: 16
diff changeset
   678
        return false;
hgs
parents: 16
diff changeset
   679
    }
hgs
parents: 16
diff changeset
   680
    FmDriverInfo driveInfo = queryDriverInfo( driveName );
hgs
parents: 16
diff changeset
   681
    if( ( driveInfo.driveState()& FmDriverInfo::EDriveRam ) ||
hgs
parents: 16
diff changeset
   682
        ( driveInfo.driveState()& FmDriverInfo::EDriveRom ) ) {
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   683
        return false;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   684
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   685
    return true;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   686
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   687
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   688
QString FmUtils::checkDriveToFolderFilter( const QString &path )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   689
{
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   690
    /*
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   691
    QFileInfo fileInfo( path );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   692
    if( !fileInfo.exists() ) {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   693
            return QString();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   694
        }
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   695
    */
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   696
    QString checkedPath = fillPathWithSplash( path );
25
hgs
parents: 16
diff changeset
   697
    if( checkedPath.compare( Drive_C, Qt::CaseInsensitive ) == 0 ) {
hgs
parents: 16
diff changeset
   698
        checkedPath += QString( "data" ) + QDir::separator();
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   699
        return checkedPath;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   700
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   701
    return path;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   702
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   703
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   704
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   705
QString FmUtils::checkFolderToDriveFilter( const QString &path )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   706
{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   707
    QString logString;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   708
    logString = QString( "checkFolderToDriveFilter: " ) + path;
32
hgs
parents: 27
diff changeset
   709
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   710
    QString checkedPath = fillPathWithSplash( path );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   711
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   712
    logString = QString( "checkFolderToDriveFilter_fillPathWithSplash: " ) + checkedPath;
32
hgs
parents: 27
diff changeset
   713
    FM_LOG( logString );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   714
    
25
hgs
parents: 16
diff changeset
   715
    if( checkedPath.compare( Folder_C_Data, Qt::CaseInsensitive ) == 0 ) {
32
hgs
parents: 27
diff changeset
   716
        FM_LOG( QString( " change from c:/data/ to C:/" ) );
25
hgs
parents: 16
diff changeset
   717
        return Drive_C;
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   718
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   719
    return path;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   720
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   721
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   722
25
hgs
parents: 16
diff changeset
   723
int FmUtils::isPathAccessabel( const QString &path )
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   724
{
25
hgs
parents: 16
diff changeset
   725
    // Used to check if path is accessable, very important feature
27
hgs
parents: 25
diff changeset
   726
    // and will return filemanager error.
32
hgs
parents: 27
diff changeset
   727
    FM_LOG( QString( "isPathAccessabel:" ) + path );
25
hgs
parents: 16
diff changeset
   728
    if( path.isEmpty() ) {
hgs
parents: 16
diff changeset
   729
        return FmErrPathNotExist;
hgs
parents: 16
diff changeset
   730
    }
27
hgs
parents: 25
diff changeset
   731
hgs
parents: 25
diff changeset
   732
    // used to filter locked/ejected/corrupted drive
hgs
parents: 25
diff changeset
   733
    // check if drive is available, no matter if it is a drive, a folder, or a file.
hgs
parents: 25
diff changeset
   734
    if( !isDriveAvailable( path ) ) {
32
hgs
parents: 27
diff changeset
   735
        FM_LOG( QString( "isPathAccessabel false: path is drive and not available" ) );
25
hgs
parents: 16
diff changeset
   736
        return FmErrDriveNotAvailable;
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   737
    }
27
hgs
parents: 25
diff changeset
   738
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   739
    QFileInfo fileInfo( path );
25
hgs
parents: 16
diff changeset
   740
    if( fileInfo.absoluteFilePath().contains( Drive_C, Qt::CaseInsensitive ) &&
hgs
parents: 16
diff changeset
   741
        !fileInfo.absoluteFilePath().contains( Folder_C_Data, Qt::CaseInsensitive ) ) {
32
hgs
parents: 27
diff changeset
   742
        FM_LOG( QString( "isPathAccessabel false: path contain C and not in data folder" ) );
25
hgs
parents: 16
diff changeset
   743
        return FmErrPathDenied;
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   744
    }
25
hgs
parents: 16
diff changeset
   745
    if( !checkDriveAccessFilter( FmUtils::getDriveNameFromPath( fileInfo.absoluteFilePath() ) ) ){
hgs
parents: 16
diff changeset
   746
        return FmErrDriveDenied;
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   747
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   748
    if( !fileInfo.exists() ) {
32
hgs
parents: 27
diff changeset
   749
        FM_LOG( QString( "isPathAccessabel false: path not exist" ) );
25
hgs
parents: 16
diff changeset
   750
        return FmErrPathNotExist;
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   751
    }
32
hgs
parents: 27
diff changeset
   752
    FM_LOG( QString( "isPathAccessabel FmErrNone" ) );
25
hgs
parents: 16
diff changeset
   753
    return FmErrNone;
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   754
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   755
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   756
// only used to check drive, when MMC is not inserted, also return false
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   757
bool FmUtils::isDriveAvailable( const QString &path )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   758
{
32
hgs
parents: 27
diff changeset
   759
    FM_LOG( QString( "isDriveAvailable:" ) + path );
25
hgs
parents: 16
diff changeset
   760
    if( path.isEmpty() ) {
hgs
parents: 16
diff changeset
   761
        return false;
hgs
parents: 16
diff changeset
   762
    }
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   763
    FmDriverInfo::DriveState driveState = queryDriverInfo( path ).driveState();
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   764
    if( ( driveState & FmDriverInfo::EDriveAvailable ) ) {
32
hgs
parents: 27
diff changeset
   765
        FM_LOG( QString( "isDriveAvailable true" ) );
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   766
        return true;
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   767
    }
32
hgs
parents: 27
diff changeset
   768
    FM_LOG( QString( "isDriveAvailable false" ) );
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   769
    return false;
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   770
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   771
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   772
void FmUtils::getDriveList( QStringList &driveList, bool isHideUnAvailableDrive )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   773
{
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   774
    if( isHideUnAvailableDrive ) {
32
hgs
parents: 27
diff changeset
   775
        FM_LOG( QString( "getDriveList HideUnAvailableDrive_true" ) );
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   776
    } else {
32
hgs
parents: 27
diff changeset
   777
        FM_LOG( QString( "getDriveList HideUnAvailableDrive_false" ) );
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   778
    }
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
    QFileInfoList infoList = QDir::drives();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
    foreach( QFileInfo fileInfo, infoList ) {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   782
        QString driveName = fileInfo.absolutePath();
25
hgs
parents: 16
diff changeset
   783
        if( checkDriveAccessFilter( driveName ) ) {
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   784
            if( !isHideUnAvailableDrive ) {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   785
                driveList.append( driveName );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   786
            }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   787
            else if ( isDriveAvailable( driveName ) ) {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   788
                driveList.append( driveName );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   789
            }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   790
        }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   791
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   792
    return;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   793
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   794
33
hgs
parents: 32
diff changeset
   795
/*!
hgs
parents: 32
diff changeset
   796
    fill volume name for \a driveName, with drive letter at the front, for example, C: Phone memory
hgs
parents: 32
diff changeset
   797
    if \a isFillWithDefaultVolume is true, default volume is provided for non-volume drive.
hgs
parents: 32
diff changeset
   798
*/
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   799
QString FmUtils::fillDriveVolume( QString driveName, bool isFillWithDefaultVolume )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   800
{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   801
    QString ret;
25
hgs
parents: 16
diff changeset
   802
    if( driveName.isEmpty() ) {
hgs
parents: 16
diff changeset
   803
        return ret;
hgs
parents: 16
diff changeset
   804
    }
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   805
    QString tempDriveName = fillPathWithSplash( driveName );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   806
25
hgs
parents: 16
diff changeset
   807
    QString checkedDriveName( removePathSplash( driveName ) );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   808
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   809
    FmDriverInfo driverInfo = FmUtils::queryDriverInfo( tempDriveName );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   810
    QString volumeName = driverInfo.volumeName();
33
hgs
parents: 32
diff changeset
   811
    
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   812
    if( volumeName.isEmpty() && isFillWithDefaultVolume ){
33
hgs
parents: 32
diff changeset
   813
        switch ( driverInfo.driveType() )
hgs
parents: 32
diff changeset
   814
            {
hgs
parents: 32
diff changeset
   815
            case FmDriverInfo::EDriveTypeMassStorage:
hgs
parents: 32
diff changeset
   816
                ret = hbTrId( "txt_fmgr_dblist_1_mass_storage" ).arg( checkedDriveName );
hgs
parents: 32
diff changeset
   817
                break;
hgs
parents: 32
diff changeset
   818
            case FmDriverInfo::EDriveTypeUsbMemory:
hgs
parents: 32
diff changeset
   819
                ret = hbTrId( "txt_fmgr_dblist_1_usb_memory" ).arg( checkedDriveName );
hgs
parents: 32
diff changeset
   820
                break;
hgs
parents: 32
diff changeset
   821
            case FmDriverInfo::EDriveTypeMemoryCard:
hgs
parents: 32
diff changeset
   822
                ret = hbTrId( "txt_fmgr_dblist_1_memory_card" ).arg( checkedDriveName );
hgs
parents: 32
diff changeset
   823
                break;
hgs
parents: 32
diff changeset
   824
            case FmDriverInfo::EDriveTypePhoneMemory:
25
hgs
parents: 16
diff changeset
   825
                ret = hbTrId( "txt_fmgr_dblist_1_device_memory" ).arg( checkedDriveName );
33
hgs
parents: 32
diff changeset
   826
                break;
hgs
parents: 32
diff changeset
   827
            default:
hgs
parents: 32
diff changeset
   828
                Q_ASSERT_X( false, "FmUtils::fillDriveVolume", "please handle drive type");
hgs
parents: 32
diff changeset
   829
                break;
hgs
parents: 32
diff changeset
   830
            }    
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   831
    }
25
hgs
parents: 16
diff changeset
   832
    
hgs
parents: 16
diff changeset
   833
    if( ret.isEmpty() ) {
33
hgs
parents: 32
diff changeset
   834
        // ret is not got. fill ret as default method
25
hgs
parents: 16
diff changeset
   835
        // txt_fmgr_dblist_1_2 is not correct, can not use.
hgs
parents: 16
diff changeset
   836
        ret = hbTrId( "%1 %2" ).arg( checkedDriveName ).arg( volumeName );
hgs
parents: 16
diff changeset
   837
    }
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   838
    return ret;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   839
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   840
33
hgs
parents: 32
diff changeset
   841
hgs
parents: 32
diff changeset
   842
/*!
hgs
parents: 32
diff changeset
   843
    return volume name for \a driveName. without drive letter at the front.
hgs
parents: 32
diff changeset
   844
    \a defaultName is set true if default volume name is return for volume name
hgs
parents: 32
diff changeset
   845
*/
hgs
parents: 32
diff changeset
   846
QString FmUtils::getVolumeNameWithDefaultNameIfNull( const QString &diskName, bool &defaultName )
hgs
parents: 32
diff changeset
   847
{
hgs
parents: 32
diff changeset
   848
    FmDriverInfo driverInfo = FmUtils::queryDriverInfo( diskName );
hgs
parents: 32
diff changeset
   849
          
hgs
parents: 32
diff changeset
   850
    QString volumeName = driverInfo.volumeName();    
hgs
parents: 32
diff changeset
   851
    //save the volume status, whether it is default name
hgs
parents: 32
diff changeset
   852
    defaultName = false;
hgs
parents: 32
diff changeset
   853
    //volume name may be null if not set, it will be set at least for one time in the following while cycling.
hgs
parents: 32
diff changeset
   854
    if ( volumeName.isEmpty() ) {
hgs
parents: 32
diff changeset
   855
        defaultName = true;
hgs
parents: 32
diff changeset
   856
        switch ( driverInfo.driveType() )
hgs
parents: 32
diff changeset
   857
            {
hgs
parents: 32
diff changeset
   858
            case FmDriverInfo::EDriveTypeMassStorage:
hgs
parents: 32
diff changeset
   859
                volumeName = hbTrId("Mass storage"); 
hgs
parents: 32
diff changeset
   860
                break;
hgs
parents: 32
diff changeset
   861
            case FmDriverInfo::EDriveTypeUsbMemory:
hgs
parents: 32
diff changeset
   862
                volumeName = hbTrId("USB memory"); 
hgs
parents: 32
diff changeset
   863
                break;
hgs
parents: 32
diff changeset
   864
            case FmDriverInfo::EDriveTypeMemoryCard:
hgs
parents: 32
diff changeset
   865
                volumeName = hbTrId("Memory card");
hgs
parents: 32
diff changeset
   866
                break;
hgs
parents: 32
diff changeset
   867
            case FmDriverInfo::EDriveTypePhoneMemory:
hgs
parents: 32
diff changeset
   868
                volumeName = hbTrId("Device memory");
hgs
parents: 32
diff changeset
   869
                break;
hgs
parents: 32
diff changeset
   870
            default:
hgs
parents: 32
diff changeset
   871
                Q_ASSERT_X( false, "FmUtils::getVolumeNameWithDefaultNameIfNull", "please handle drive type" );
hgs
parents: 32
diff changeset
   872
                break;
hgs
parents: 32
diff changeset
   873
            }   
hgs
parents: 32
diff changeset
   874
    }
hgs
parents: 32
diff changeset
   875
    return volumeName;
hgs
parents: 32
diff changeset
   876
}
hgs
parents: 32
diff changeset
   877
25
hgs
parents: 16
diff changeset
   878
int FmUtils::launchFile( const QString &filePath )
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   879
{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   880
    QFile file( filePath );
25
hgs
parents: 16
diff changeset
   881
    if( !file.exists() ) {
hgs
parents: 16
diff changeset
   882
        return false;
hgs
parents: 16
diff changeset
   883
    }
hgs
parents: 16
diff changeset
   884
        
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   885
    XQApplicationManager mAiwMgr;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   886
    XQAiwRequest *request = mAiwMgr.create(file);
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   887
    if ( request == 0 ) {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   888
        // No handlers for the URI
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   889
        return FmErrUnKnown;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   890
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   891
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   892
    // Set function parameters
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   893
    QList<QVariant> args;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   894
    args << file.fileName();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   895
    request->setArguments(args);
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   896
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   897
    // Send the request
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   898
    bool res = request->send();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   899
    if  (!res) 
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   900
    {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   901
       // Request failed. 
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   902
      int error = request->lastError();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   903
      
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   904
      delete request;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   905
      return FmErrUnKnown;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   906
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   907
    
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   908
    delete request;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   909
    return FmErrNone;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   910
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   911
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   912
void FmUtils::sendFiles( QStringList &filePathList )
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   913
{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   914
    ShareUi shareui;
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   915
    shareui.send( filePathList, false );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   916
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   917
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   918
QString FmUtils::getBurConfigPath( QString appPath )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   919
{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   920
    Q_UNUSED( appPath );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   921
    QString path( BURCONFIGFILE );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   922
    return path;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   923
}
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   924
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   925
bool FmUtils::isPathEqual( const QString &pathFst, const QString &pathLast )
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   926
{
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   927
    QString fst( fillPathWithSplash( pathFst ) );
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   928
    QString last( fillPathWithSplash( pathLast ) );
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   929
    if( fst.compare( last, Qt::CaseInsensitive ) == 0 ) {
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   930
        return true;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   931
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   932
    return false;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   933
}
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   934
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   935
bool FmUtils::isDefaultFolder( const QString &folderPath  )
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   936
{
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   937
    TPtrC desFolderPath( XQConversions::qStringToS60Desc( folderPath )->Des() );
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   938
    
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   939
    TInt pathType( PathInfo::PathType( desFolderPath ) );
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   940
    switch( pathType ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   941
       case PathInfo::ENotSystemPath:{
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   942
           QString locString( Localize( folderPath ) );
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   943
            if ( locString.isEmpty() ){
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   944
                return false;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   945
            }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   946
            return true;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   947
            }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   948
        case PathInfo::EPhoneMemoryRootPath: // FALL THROUGH
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   949
        case PathInfo::EMemoryCardRootPath: // FALL THROUGH
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   950
        case PathInfo::ERomRootPath:{
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   951
            return false;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   952
        }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   953
        // Accept other folders
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   954
        default:{
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   955
            return true;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   956
        }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   957
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   958
}
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   959
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   960
QString FmUtils::Localize( const QString &path )
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   961
{
33
hgs
parents: 32
diff changeset
   962
    QString locPath = fillPathWithSplash( path );
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   963
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   964
    TPtrC desPath( XQConversions::qStringToS60Desc( locPath )->Des() );
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   965
    CDirectoryLocalizer *localizer = CDirectoryLocalizer::NewL();
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   966
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   967
    localizer->SetFullPath( desPath );
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   968
    if( localizer->IsLocalized() ){   
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   969
        return XQConversions::s60DescToQString( localizer->LocalizedName() );
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   970
    }
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   971
    
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   972
    return QString();
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   973
}
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   974
33
hgs
parents: 32
diff changeset
   975
/*!
hgs
parents: 32
diff changeset
   976
    All "/" and "\" in \a path will be changed to QDir::separator
hgs
parents: 32
diff changeset
   977
    \sa fillPathWithSplash, fillPathWithSplash will append QDir::separator in the end if path is no a file
hgs
parents: 32
diff changeset
   978
*/
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   979
QString FmUtils::formatPath( const QString &path  )
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   980
{
25
hgs
parents: 16
diff changeset
   981
    QString formatPath;
33
hgs
parents: 32
diff changeset
   982
    if( path.isEmpty() ) {
hgs
parents: 32
diff changeset
   983
        return formatPath;
hgs
parents: 32
diff changeset
   984
    }
hgs
parents: 32
diff changeset
   985
    
25
hgs
parents: 16
diff changeset
   986
	foreach( QChar ch, path ) {
hgs
parents: 16
diff changeset
   987
		if( ch == QChar('\\') || ch == QChar('/') ) {
hgs
parents: 16
diff changeset
   988
			formatPath.append( QDir::separator() );
hgs
parents: 16
diff changeset
   989
		} else {
hgs
parents: 16
diff changeset
   990
			formatPath.append( ch );
hgs
parents: 16
diff changeset
   991
		}
hgs
parents: 16
diff changeset
   992
    }
hgs
parents: 16
diff changeset
   993
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   994
    return formatPath;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   995
}
25
hgs
parents: 16
diff changeset
   996
hgs
parents: 16
diff changeset
   997
int FmUtils::getMaxFileNameLength()
hgs
parents: 16
diff changeset
   998
{
hgs
parents: 16
diff changeset
   999
    return KMaxFileName;
hgs
parents: 16
diff changeset
  1000
}
hgs
parents: 16
diff changeset
  1001
hgs
parents: 16
diff changeset
  1002
bool FmUtils::checkMaxPathLength( const QString& path )
hgs
parents: 16
diff changeset
  1003
{
hgs
parents: 16
diff changeset
  1004
    if( path.length() > KMaxPath ) {
hgs
parents: 16
diff changeset
  1005
        return false;
hgs
parents: 16
diff changeset
  1006
    }
hgs
parents: 16
diff changeset
  1007
    return true;
hgs
parents: 16
diff changeset
  1008
}
27
hgs
parents: 25
diff changeset
  1009
25
hgs
parents: 16
diff changeset
  1010
bool FmUtils::checkFolderFileName( const QString& name )
hgs
parents: 16
diff changeset
  1011
{
27
hgs
parents: 25
diff changeset
  1012
    // trim space firest, because there may be some spaces after "." ,  it is also not valid
hgs
parents: 25
diff changeset
  1013
    QString trimmedName( name.trimmed() );
hgs
parents: 25
diff changeset
  1014
	if( trimmedName.isEmpty() ) {
hgs
parents: 25
diff changeset
  1015
		return false;
hgs
parents: 25
diff changeset
  1016
	}
hgs
parents: 25
diff changeset
  1017
    if( trimmedName.endsWith( QChar('.'),  Qt::CaseInsensitive ) ) {
25
hgs
parents: 16
diff changeset
  1018
        return false;
hgs
parents: 16
diff changeset
  1019
    }
27
hgs
parents: 25
diff changeset
  1020
    if( trimmedName.contains( QChar('\\'), Qt::CaseInsensitive ) ||
hgs
parents: 25
diff changeset
  1021
        trimmedName.contains( QChar('/'),  Qt::CaseInsensitive ) ||
hgs
parents: 25
diff changeset
  1022
        trimmedName.contains( QChar(':'),  Qt::CaseInsensitive ) ||
hgs
parents: 25
diff changeset
  1023
        trimmedName.contains( QChar('*'),  Qt::CaseInsensitive ) ||
hgs
parents: 25
diff changeset
  1024
        trimmedName.contains( QChar('?'),  Qt::CaseInsensitive ) ||
hgs
parents: 25
diff changeset
  1025
        trimmedName.contains( QChar('\"'), Qt::CaseInsensitive ) ||
hgs
parents: 25
diff changeset
  1026
        trimmedName.contains( QChar('<'),  Qt::CaseInsensitive ) ||
hgs
parents: 25
diff changeset
  1027
        trimmedName.contains( QChar('>'),  Qt::CaseInsensitive ) ||
hgs
parents: 25
diff changeset
  1028
        trimmedName.contains( QChar('|'),  Qt::CaseInsensitive ) ){
25
hgs
parents: 16
diff changeset
  1029
        return false;
hgs
parents: 16
diff changeset
  1030
    }
27
hgs
parents: 25
diff changeset
  1031
    // use orignal name to exam max size of file name
25
hgs
parents: 16
diff changeset
  1032
    if( name.length() > KMaxFileName ) {
hgs
parents: 16
diff changeset
  1033
        return false;
hgs
parents: 16
diff changeset
  1034
    }
hgs
parents: 16
diff changeset
  1035
    return true;
hgs
parents: 16
diff changeset
  1036
}
hgs
parents: 16
diff changeset
  1037
27
hgs
parents: 25
diff changeset
  1038
bool FmUtils::checkNewFolderOrFile( const QString &fileName, const QString &path, QString &errString )
25
hgs
parents: 16
diff changeset
  1039
{
27
hgs
parents: 25
diff changeset
  1040
    // first check if fileName is valid, then check if path length is valid, and check if file/foler is existed at last
25
hgs
parents: 16
diff changeset
  1041
    QFileInfo fileInfo( path );
hgs
parents: 16
diff changeset
  1042
    bool ret( true );   
27
hgs
parents: 25
diff changeset
  1043
    if (!FmUtils::checkFolderFileName( fileName ) ) {
25
hgs
parents: 16
diff changeset
  1044
        errString = hbTrId( "Invalid file or folder name!" );
hgs
parents: 16
diff changeset
  1045
        ret = false;
hgs
parents: 16
diff changeset
  1046
    } else if( !FmUtils::checkMaxPathLength( path ) ) {
hgs
parents: 16
diff changeset
  1047
        errString = hbTrId( "the path you specified is too long!" );
hgs
parents: 16
diff changeset
  1048
        ret = false;
hgs
parents: 16
diff changeset
  1049
    } else if (fileInfo.exists()) {
hgs
parents: 16
diff changeset
  1050
        errString = hbTrId( "%1 already exist!" ).arg( fileInfo.fileName() );
hgs
parents: 16
diff changeset
  1051
        ret = false;
hgs
parents: 16
diff changeset
  1052
    }
hgs
parents: 16
diff changeset
  1053
    return ret;
hgs
parents: 16
diff changeset
  1054
}
27
hgs
parents: 25
diff changeset
  1055
33
hgs
parents: 32
diff changeset
  1056
/*!
hgs
parents: 32
diff changeset
  1057
    Check if \a dest is sub level path of \a src
hgs
parents: 32
diff changeset
  1058
    Used to check True/False when copy a folder to itself or its subfolder
hgs
parents: 32
diff changeset
  1059
    For example, c:\data\test is sub path of c:\data.
hgs
parents: 32
diff changeset
  1060
    But c:\data123\test is not sub path of c:\data.
hgs
parents: 32
diff changeset
  1061
    So after got right part of path, the first char must be \ or /
hgs
parents: 32
diff changeset
  1062
*/
hgs
parents: 32
diff changeset
  1063
bool FmUtils::isSubLevelPath( const QString &src, const QString &dest )
27
hgs
parents: 25
diff changeset
  1064
{
33
hgs
parents: 32
diff changeset
  1065
    FM_LOG("FmUtils::isSubFolder: src=" + src + " dest=" + dest);
hgs
parents: 32
diff changeset
  1066
    QString checkedSrc( FmUtils::fillPathWithSplash( src ) );
hgs
parents: 32
diff changeset
  1067
    QString checkedDest( FmUtils::fillPathWithSplash( dest ) );
hgs
parents: 32
diff changeset
  1068
    
hgs
parents: 32
diff changeset
  1069
    if( checkedDest.contains( checkedSrc, Qt::CaseInsensitive) &&
hgs
parents: 32
diff changeset
  1070
            checkedDest.length() > checkedSrc.length() ) {
hgs
parents: 32
diff changeset
  1071
        // for example c:\data\ vs c:\data\123\ 
hgs
parents: 32
diff changeset
  1072
        FM_LOG("FmUtils::isSubFolder: true");
hgs
parents: 32
diff changeset
  1073
        return true;
27
hgs
parents: 25
diff changeset
  1074
    }
33
hgs
parents: 32
diff changeset
  1075
    // for example c:\data\ vs c:\data\ 
hgs
parents: 32
diff changeset
  1076
    // for example c:\data\ vs c:\data123\ 
hgs
parents: 32
diff changeset
  1077
hgs
parents: 32
diff changeset
  1078
    FM_LOG("FmUtils::isSubFolder: false");
hgs
parents: 32
diff changeset
  1079
    return false;
27
hgs
parents: 25
diff changeset
  1080
}
33
hgs
parents: 32
diff changeset
  1081
hgs
parents: 32
diff changeset
  1082
/*!
hgs
parents: 32
diff changeset
  1083
    set the \a desFile attributes as the same with \a srcFile
hgs
parents: 32
diff changeset
  1084
*/
hgs
parents: 32
diff changeset
  1085
int FmUtils::setFileAttributes( const QString &srcFile, const QString &desFile )
hgs
parents: 32
diff changeset
  1086
{
hgs
parents: 32
diff changeset
  1087
    RFs fsSession;
hgs
parents: 32
diff changeset
  1088
    User::LeaveIfError( fsSession.Connect() ); 
hgs
parents: 32
diff changeset
  1089
    CleanupClosePushL( fsSession );
hgs
parents: 32
diff changeset
  1090
    RFile64 src;
hgs
parents: 32
diff changeset
  1091
    RFile64 des;
hgs
parents: 32
diff changeset
  1092
    HBufC *buf1 = XQConversions::qStringToS60Desc( removePathSplash( formatPath( srcFile ) ) );
hgs
parents: 32
diff changeset
  1093
    HBufC *buf2 = XQConversions::qStringToS60Desc( removePathSplash( formatPath( desFile ) ) );
hgs
parents: 32
diff changeset
  1094
    User::LeaveIfError( src.Open( fsSession, *buf1, EFileRead | EFileShareReadersOnly ) );
hgs
parents: 32
diff changeset
  1095
    User::LeaveIfError( des.Open( fsSession, *buf2, EFileWrite | EFileShareExclusive ) );
hgs
parents: 32
diff changeset
  1096
    TTime mod;
hgs
parents: 32
diff changeset
  1097
    int err = src.Modified( mod );;
hgs
parents: 32
diff changeset
  1098
    if ( err == FmErrNone ) {
hgs
parents: 32
diff changeset
  1099
        err = des.SetModified( mod );    
hgs
parents: 32
diff changeset
  1100
    }
hgs
parents: 32
diff changeset
  1101
    TUint att( 0 );
hgs
parents: 32
diff changeset
  1102
    if ( err == FmErrNone ) {
hgs
parents: 32
diff changeset
  1103
        err = src.Att( att );        
hgs
parents: 32
diff changeset
  1104
    }
hgs
parents: 32
diff changeset
  1105
    if ( err == FmErrNone ) {
hgs
parents: 32
diff changeset
  1106
        des.SetAtt( att, ( ~att ) & KEntryAttMaskSupported );
hgs
parents: 32
diff changeset
  1107
    }    
hgs
parents: 32
diff changeset
  1108
    src.Close();
hgs
parents: 32
diff changeset
  1109
    des.Close();
hgs
parents: 32
diff changeset
  1110
    fsSession.Close();
hgs
parents: 32
diff changeset
  1111
    CleanupStack::PopAndDestroy(); // fsSession
hgs
parents: 32
diff changeset
  1112
    return err;
hgs
parents: 32
diff changeset
  1113
}