31
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0""
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include "cputility.h"
|
32
|
18 |
#include <QString>
|
|
19 |
#include <QDir>
|
|
20 |
#include <QFileInfo>
|
31
|
21 |
#include "cpbasepath.h"
|
32
|
22 |
#include <cppluginloader.h>
|
|
23 |
#include <cpplugininterface.h>
|
31
|
24 |
#include <cppluginplatinterface.h>
|
32
|
25 |
#include <cplogger.h>
|
31
|
26 |
#include <cpsettingformentryitemdata.h>
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
QStringList CpUtility::drives()
|
|
31 |
{
|
|
32 |
static QStringList drives;
|
|
33 |
|
|
34 |
if (drives.empty()) {
|
32
|
35 |
CPFW_LOG("device drives:");
|
31
|
36 |
#ifdef WIN32
|
|
37 |
drives.append("C:");
|
32
|
38 |
CPFW_LOG("C:");
|
31
|
39 |
#else
|
|
40 |
QFileInfoList fileInfoList = QDir::drives();
|
|
41 |
foreach(const QFileInfo &fileInfo,fileInfoList) {
|
|
42 |
QString str = fileInfo.filePath();
|
|
43 |
if (str.length() > 2) {
|
|
44 |
str = str.left(2);
|
|
45 |
}
|
|
46 |
drives.append(str);
|
32
|
47 |
CPFW_LOG(str);
|
31
|
48 |
}
|
32
|
49 |
#endif
|
31
|
50 |
}
|
|
51 |
|
|
52 |
return drives;
|
|
53 |
}
|
|
54 |
|
32
|
55 |
static QStringList directoriesFromAllDrives(const QString &baseDir)
|
31
|
56 |
{
|
|
57 |
QStringList dirs;
|
|
58 |
|
|
59 |
QStringList drives = CpUtility::drives();
|
|
60 |
foreach(const QString &drive,drives) {
|
|
61 |
QString dir = drive + baseDir + QDir::separator();
|
|
62 |
if (QFileInfo(dir).exists()) {
|
|
63 |
dirs.append(dir);
|
32
|
64 |
CPFW_LOG(dir);
|
31
|
65 |
}
|
|
66 |
}
|
|
67 |
|
|
68 |
return dirs;
|
|
69 |
}
|
|
70 |
|
32
|
71 |
QStringList CpUtility::pluginDirectories()
|
31
|
72 |
{
|
|
73 |
static QStringList dirs;
|
|
74 |
if (dirs.empty()) {
|
32
|
75 |
CPFW_LOG("ControlPanel plugin derectories:")
|
|
76 |
dirs = directoriesFromAllDrives(CP_PLUGIN_PATH);
|
31
|
77 |
}
|
|
78 |
return dirs;
|
|
79 |
}
|
|
80 |
|
32
|
81 |
QStringList CpUtility::applicationPluginDirectories()
|
31
|
82 |
{
|
|
83 |
static QStringList dirs;
|
|
84 |
if (dirs.empty()) {
|
32
|
85 |
CPFW_LOG("ControlPanel application plugin derectories:");
|
|
86 |
// dirs = directoriesFromAllDrives(CP_APPLICATION_PLUGIN_PATH);
|
|
87 |
}
|
|
88 |
return dirs;
|
|
89 |
}
|
|
90 |
|
|
91 |
|
|
92 |
QStringList CpUtility::configFileDirectories()
|
|
93 |
{
|
|
94 |
static QStringList dirs;
|
|
95 |
if (dirs.empty()) {
|
|
96 |
CPFW_LOG("ControlPanel configuration file derectories:");
|
|
97 |
dirs = directoriesFromAllDrives(CP_PLUGIN_CONFIG_PATH);
|
31
|
98 |
}
|
|
99 |
return dirs;
|
|
100 |
}
|
|
101 |
|