filemanager/src/inc/fmutils_win.cpp
author hgs
Wed, 29 Sep 2010 10:37:03 +0800
changeset 46 d58987eac7e8
parent 37 15bc28c9dd51
permissions -rw-r--r--
201037
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 on windows
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
37
hgs
parents: 16
diff changeset
    19
#include "fmutils.h"
hgs
parents: 16
diff changeset
    20
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <windows.h>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <QDir>
37
hgs
parents: 16
diff changeset
    24
#include <QUrl>
hgs
parents: 16
diff changeset
    25
#include <QVariant>
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <QFileInfo>
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <QDesktopServices>
37
hgs
parents: 16
diff changeset
    28
hgs
parents: 16
diff changeset
    29
#include <hbglobal.h>
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#define BURCONFIGFILE  "burconfig.xml"
37
hgs
parents: 16
diff changeset
    32
const int KMaxFileName=0x100;
hgs
parents: 16
diff changeset
    33
const int KMaxPath=0x100;
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
46
hgs
parents: 37
diff changeset
    35
// EDriveA means number of A drive
hgs
parents: 37
diff changeset
    36
const int EDriveA = 0;
hgs
parents: 37
diff changeset
    37
37
hgs
parents: 16
diff changeset
    38
FmDriverInfo FmUtils::queryDriverInfo( const QString &driveName )
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
    quint64 size = 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
    quint64 freeSize = 0;
37
hgs
parents: 16
diff changeset
    42
    QString drive = driveName;
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
    
37
hgs
parents: 16
diff changeset
    44
    drive.replace( '/', "\\" );
hgs
parents: 16
diff changeset
    45
    if ( drive.right(1) != "\\" ) {
hgs
parents: 16
diff changeset
    46
        drive.append( "\\" );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
    }
37
hgs
parents: 16
diff changeset
    48
    GetDiskFreeSpaceEx( (LPCWSTR)drive.constData(),
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
                        (PULARGE_INTEGER)&freeSize,
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
                        (PULARGE_INTEGER)&size,
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
                        0 );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
    TCHAR volumeName[MAX_PATH + 1] = { 0 };
37
hgs
parents: 16
diff changeset
    54
    GetVolumeInformation( (LPCWSTR)drive.constData(),
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
                          &volumeName[0],
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
                          MAX_PATH + 1,
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
                          0,
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
                          0,
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
                          0,
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
                          0,
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
                          0 );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    63
    quint32 state( 0 );
37
hgs
parents: 16
diff changeset
    64
    quint32 drvStatus = GetDriveType( (LPCWSTR)drive.constData() );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
    if ( drvStatus == DRIVE_REMOVABLE  ) {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
        state |= FmDriverInfo::EDriveRemovable;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
37
hgs
parents: 16
diff changeset
    69
	if( !(state&FmDriverInfo::EDriveNotPresent) && !(state&FmDriverInfo::EDriveLocked) &&
hgs
parents: 16
diff changeset
    70
		!(state&FmDriverInfo::EDriveCorrupted) ) {
hgs
parents: 16
diff changeset
    71
		state |= FmDriverInfo::EDriveAvailable;
hgs
parents: 16
diff changeset
    72
	}
hgs
parents: 16
diff changeset
    73
    return FmDriverInfo( size, freeSize, driveName, QString::fromWCharArray( &volumeName[0] ), state );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
}
37
hgs
parents: 16
diff changeset
    75
hgs
parents: 16
diff changeset
    76
int FmUtils::removeDrivePwd( const QString &driveName,  const QString &Pwd )
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
{
37
hgs
parents: 16
diff changeset
    78
    Q_UNUSED( driveName );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
    Q_UNUSED( Pwd );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
    return 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
37
hgs
parents: 16
diff changeset
    83
int FmUtils::unlockDrive( const QString &driveName,  const QString &Pwd )
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
{
37
hgs
parents: 16
diff changeset
    85
    Q_UNUSED( driveName );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
    Q_UNUSED( Pwd );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
    return 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
37
hgs
parents: 16
diff changeset
    90
int FmUtils::checkDrivePwd( const QString &driveName, const QString &pwd)
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    91
{
37
hgs
parents: 16
diff changeset
    92
    Q_UNUSED( driveName );
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    93
    Q_UNUSED( pwd );
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    94
    return 0;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    95
}
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
    96
37
hgs
parents: 16
diff changeset
    97
int FmUtils::setDrivePwd( const QString &driveName, const QString &oldPwd, const QString &newPwd)
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
{
37
hgs
parents: 16
diff changeset
    99
    Q_UNUSED( driveName );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
    Q_UNUSED( oldPwd );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
    Q_UNUSED( newPwd );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
    return 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
void FmUtils::emptyPwd( QString &pwd )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
    Q_UNUSED( pwd );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
37
hgs
parents: 16
diff changeset
   110
int FmUtils::renameDrive( const QString &driveName, const QString &newVolumeName)
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
{
37
hgs
parents: 16
diff changeset
   112
    Q_UNUSED( driveName );
hgs
parents: 16
diff changeset
   113
    foreach( const QChar &ch, newVolumeName )
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   114
    {
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   115
        // If not alphadigit or space, return error
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   116
        if( !ch.isLetterOrNumber() && !ch.isSpace() )
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   117
        {
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   118
            return FmErrBadName;
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   119
        }   
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   120
    }
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
    return 0;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
37
hgs
parents: 16
diff changeset
   124
int FmUtils::ejectDrive( const QString &driveName )
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
{
37
hgs
parents: 16
diff changeset
   126
    Q_UNUSED( driveName );
hgs
parents: 16
diff changeset
   127
	return FmErrNone; 
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
37
hgs
parents: 16
diff changeset
   130
bool FmUtils::checkDriveAccessFilter( const QString &driveName )
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
{
37
hgs
parents: 16
diff changeset
   132
    Q_UNUSED( driveName );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
    return true;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
QString FmUtils::checkDriveToFolderFilter( const QString &path )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
{
37
hgs
parents: 16
diff changeset
   138
    Q_UNUSED( path );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
    return path;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
QString FmUtils::checkFolderToDriveFilter( const QString &path )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
{
37
hgs
parents: 16
diff changeset
   145
    Q_UNUSED( path );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
    return path;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
37
hgs
parents: 16
diff changeset
   150
int FmUtils::isPathAccessabel( const QString &path )
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
{
37
hgs
parents: 16
diff changeset
   152
    Q_UNUSED( path );
hgs
parents: 16
diff changeset
   153
    return FmErrNone;
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
bool FmUtils::isDriveAvailable( const QString &path )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
{
37
hgs
parents: 16
diff changeset
   158
    Q_UNUSED( path );
hgs
parents: 16
diff changeset
   159
	return true;
hgs
parents: 16
diff changeset
   160
}
hgs
parents: 16
diff changeset
   161
hgs
parents: 16
diff changeset
   162
bool FmUtils::isDefaultFolder( const QString &folderPath  )
hgs
parents: 16
diff changeset
   163
{
hgs
parents: 16
diff changeset
   164
    Q_UNUSED( folderPath );
hgs
parents: 16
diff changeset
   165
    return false;
hgs
parents: 16
diff changeset
   166
}
hgs
parents: 16
diff changeset
   167
hgs
parents: 16
diff changeset
   168
void FmUtils::createDefaultFolders( const QString &driveName )
hgs
parents: 16
diff changeset
   169
{
hgs
parents: 16
diff changeset
   170
    Q_UNUSED( driveName );
hgs
parents: 16
diff changeset
   171
}
hgs
parents: 16
diff changeset
   172
hgs
parents: 16
diff changeset
   173
/*!
46
hgs
parents: 37
diff changeset
   174
    return localized file name by \a path, empty string returned for non-localized path.
hgs
parents: 37
diff changeset
   175
    In Symbian system, default folders will be localized.
hgs
parents: 37
diff changeset
   176
    So localize also can be used to check if a path is a default folder
hgs
parents: 37
diff changeset
   177
    Do not need localize on windows.
hgs
parents: 37
diff changeset
   178
    \sa isDefaultFolder
hgs
parents: 37
diff changeset
   179
*/
hgs
parents: 37
diff changeset
   180
QString FmUtils::localize( const QString &path )
hgs
parents: 37
diff changeset
   181
{
hgs
parents: 37
diff changeset
   182
    Q_UNUSED( path );
hgs
parents: 37
diff changeset
   183
    return QString();
hgs
parents: 37
diff changeset
   184
}
hgs
parents: 37
diff changeset
   185
hgs
parents: 37
diff changeset
   186
/*!
37
hgs
parents: 16
diff changeset
   187
    set the \a desFile attributes as the same with \a srcFile
hgs
parents: 16
diff changeset
   188
*/
hgs
parents: 16
diff changeset
   189
int FmUtils::setFileAttributes( const QString &srcFile, const QString &desFile )
hgs
parents: 16
diff changeset
   190
{
hgs
parents: 16
diff changeset
   191
    Q_UNUSED( srcFile );
hgs
parents: 16
diff changeset
   192
    Q_UNUSED( desFile );
hgs
parents: 16
diff changeset
   193
    return FmErrNone;
hgs
parents: 16
diff changeset
   194
}
hgs
parents: 16
diff changeset
   195
hgs
parents: 16
diff changeset
   196
/*!
hgs
parents: 16
diff changeset
   197
    judge whether there is enough space on \a targetDrive for \a size.
hgs
parents: 16
diff changeset
   198
    return true if has, false if not.
hgs
parents: 16
diff changeset
   199
*/
hgs
parents: 16
diff changeset
   200
bool FmUtils::hasEnoughSpace( const QString &targetDrive, qint64 size )
hgs
parents: 16
diff changeset
   201
{
hgs
parents: 16
diff changeset
   202
    Q_UNUSED( targetDrive );
hgs
parents: 16
diff changeset
   203
    Q_UNUSED( size );
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
    return true;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
37
hgs
parents: 16
diff changeset
   207
/*!
hgs
parents: 16
diff changeset
   208
    move one file insice the same drive, from \a source to \a target.
hgs
parents: 16
diff changeset
   209
    return KErrNone if successful, otherwise one of the other system-wide error codes.
hgs
parents: 16
diff changeset
   210
*/
hgs
parents: 16
diff changeset
   211
int FmUtils::moveInsideDrive( const QString &source, const QString &target )
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
{
37
hgs
parents: 16
diff changeset
   213
    Q_UNUSED( source );
hgs
parents: 16
diff changeset
   214
    Q_UNUSED( target );
hgs
parents: 16
diff changeset
   215
    return FmErrNone;
14
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
int FmUtils::launchFile( const QString &filePath )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
    if( QDesktopServices::openUrl( QUrl::fromLocalFile( filePath ) ) ) {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
        return FmErrNone;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
    } else {
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
        return FmErrGeneral;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
    }
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
}
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
QString FmUtils::getBurConfigPath( QString appPath )
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
{
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
    QFileInfo fileInfo( appPath );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
    QString testString = fileInfo.absolutePath();
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
    QString path = fillPathWithSplash( fileInfo.absolutePath() );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
    path = path + QString( "src/filemanager/" );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
    path = path + QString( BURCONFIGFILE );
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
    return path;
1957042d8c7e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
}
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   236
37
hgs
parents: 16
diff changeset
   237
QString FmUtils::getFileType( const QString &filePath  )
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   238
{
37
hgs
parents: 16
diff changeset
   239
    Q_UNUSED( filePath );
hgs
parents: 16
diff changeset
   240
    return QString( "" );
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   241
}
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   242
37
hgs
parents: 16
diff changeset
   243
bool FmUtils::isDriveC( const QString &driveName )
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   244
{
37
hgs
parents: 16
diff changeset
   245
	if( driveName.contains(Drive_C,Qt::CaseInsensitive) ){
hgs
parents: 16
diff changeset
   246
        return true;
hgs
parents: 16
diff changeset
   247
    }
hgs
parents: 16
diff changeset
   248
    else{
hgs
parents: 16
diff changeset
   249
        return false;
hgs
parents: 16
diff changeset
   250
    }
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   251
}
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   252
37
hgs
parents: 16
diff changeset
   253
int FmUtils::getMaxFileNameLength()
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   254
{
37
hgs
parents: 16
diff changeset
   255
    return KMaxFileName;
16
ada7962b4308 Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
   256
}
37
hgs
parents: 16
diff changeset
   257
hgs
parents: 16
diff changeset
   258
bool FmUtils::checkMaxPathLength( const QString& path )
hgs
parents: 16
diff changeset
   259
{
hgs
parents: 16
diff changeset
   260
    if( path.length() > KMaxPath ) {
hgs
parents: 16
diff changeset
   261
        return false;
hgs
parents: 16
diff changeset
   262
    }
hgs
parents: 16
diff changeset
   263
    return true;
hgs
parents: 16
diff changeset
   264
}
46
hgs
parents: 37
diff changeset
   265
hgs
parents: 37
diff changeset
   266
void FmUtils::setSystem( bool isSystem )
hgs
parents: 37
diff changeset
   267
{
hgs
parents: 37
diff changeset
   268
    Q_UNUSED( isSystem );
hgs
parents: 37
diff changeset
   269
}
hgs
parents: 37
diff changeset
   270
hgs
parents: 37
diff changeset
   271
QString FmUtils::numberToDriveName( int drive )
hgs
parents: 37
diff changeset
   272
{
hgs
parents: 37
diff changeset
   273
    QChar driveChar( drive - EDriveA + 'A' );
hgs
parents: 37
diff changeset
   274
    QString driveName = QString( driveChar ) + ':';
hgs
parents: 37
diff changeset
   275
    return driveName;
hgs
parents: 37
diff changeset
   276
}