99
|
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 |
|
|
18 |
#include <QTranslator>
|
|
19 |
#include <QCoreApplication>
|
|
20 |
#include <QLocale>
|
|
21 |
#include <QtPlugin>
|
|
22 |
|
|
23 |
#include <qservicemanager.h>
|
|
24 |
|
|
25 |
#include <hbdevicedialog.h>
|
|
26 |
#include <HbMainWindow>
|
|
27 |
|
|
28 |
#include "tsdevicedialogplugin.h"
|
|
29 |
#include "tsdevicedialogcontainer.h"
|
|
30 |
#include "tstasksgrid.h"
|
|
31 |
#include "tstasksgriditem.h"
|
|
32 |
#include "tsdocumentloader.h"
|
|
33 |
#include "tsmodel.h"
|
|
34 |
|
|
35 |
/*!
|
|
36 |
\class TsDeviceDialogPlugin
|
|
37 |
\ingroup group_tsdevicedialogplugin
|
|
38 |
\brief TaskSwitcher Device Dialog Plug-in.
|
|
39 |
*/
|
|
40 |
|
|
41 |
namespace
|
|
42 |
{
|
|
43 |
const char KTranslationPath[] = "resource/qt/translations";
|
|
44 |
const char KTsDialogType[] = "com.nokia.taskswitcher.tsdevicedialogplugin/1.0";
|
|
45 |
}
|
|
46 |
|
|
47 |
/*!
|
|
48 |
Constructor.
|
|
49 |
*/
|
|
50 |
TsDeviceDialogPlugin::TsDeviceDialogPlugin() : mError(0), mModel(0), mStorage(0), mTriedToLoadTranslation(false)
|
|
51 |
{
|
|
52 |
}
|
|
53 |
|
|
54 |
TsDeviceDialogPlugin::~TsDeviceDialogPlugin()
|
|
55 |
{
|
|
56 |
delete mModel;
|
|
57 |
}
|
|
58 |
/*!
|
|
59 |
\reimp
|
|
60 |
*/
|
|
61 |
bool TsDeviceDialogPlugin::accessAllowed(const QString &deviceDialogType, const QVariantMap ¶meters, const QVariantMap &securityInfo) const
|
|
62 |
{
|
|
63 |
Q_UNUSED(deviceDialogType)
|
|
64 |
Q_UNUSED(parameters)
|
|
65 |
Q_UNUSED(securityInfo)
|
|
66 |
|
|
67 |
// This plugin doesn't perform operations that may compromise security.
|
|
68 |
// All clients are allowed to use it.
|
|
69 |
return true;
|
|
70 |
}
|
|
71 |
|
|
72 |
/*!
|
|
73 |
\reimp
|
|
74 |
*/
|
|
75 |
HbDeviceDialogInterface *TsDeviceDialogPlugin::createDeviceDialog(const QString &deviceDialogType, const QVariantMap ¶meters)
|
|
76 |
{
|
|
77 |
Q_UNUSED(parameters)
|
|
78 |
HbDeviceDialogInterface *dialogInterface(0);
|
|
79 |
if (deviceDialogType == QString(KTsDialogType)) {
|
|
80 |
// lazy loading of translation
|
|
81 |
if (!mTriedToLoadTranslation) {
|
|
82 |
mTriedToLoadTranslation = true;
|
|
83 |
|
|
84 |
QTranslator *translator = new QTranslator(this);
|
|
85 |
QString translationFile = QString("taskswitcher_%1").arg(QLocale::system().name());
|
|
86 |
|
|
87 |
bool translationLoaded(false);
|
|
88 |
#ifdef Q_OS_SYMBIAN
|
|
89 |
translationLoaded = translator->load(translationFile, QString("z:/") + KTranslationPath);
|
|
90 |
if (!translationLoaded) {
|
|
91 |
translationLoaded = translator->load(translationFile, QString("c:/") + KTranslationPath);
|
|
92 |
}
|
|
93 |
#else
|
|
94 |
translationLoaded = translator->load(translationFile, QString(KTranslationPath));
|
|
95 |
#endif //Q_OS_SYMBIAN
|
|
96 |
|
|
97 |
Q_ASSERT(translationLoaded);
|
|
98 |
qApp->installTranslator(translator);
|
|
99 |
}
|
|
100 |
|
|
101 |
// lazy loading of model
|
|
102 |
if (0 == mModel) {
|
|
103 |
mStorage = new TsTaskMonitor(this);
|
|
104 |
if (0 == mStorage) {
|
|
105 |
return 0; // provider of running application list is critical
|
|
106 |
}
|
|
107 |
|
|
108 |
QtMobility::QServiceManager serviceManager;
|
|
109 |
QObject *activityManager(serviceManager.loadInterface("com.nokia.qt.activities.ActivityManager"));
|
|
110 |
if (activityManager) {
|
|
111 |
activityManager->setParent(this); //make it autodestructed
|
|
112 |
} else {
|
|
113 |
activityManager = this; //activity plugin is not present. provide invalid instance because its not critical functionality.
|
|
114 |
//QMetaObject::invokeMethod is safe to use in such a case.
|
|
115 |
}
|
|
116 |
mModel = new TsModel(*mStorage, *activityManager);
|
|
117 |
}
|
|
118 |
|
|
119 |
dialogInterface = new TsDeviceDialogContainer(mModel);
|
|
120 |
}
|
|
121 |
return dialogInterface;
|
|
122 |
}
|
|
123 |
|
|
124 |
/*!
|
|
125 |
\reimp
|
|
126 |
*/
|
|
127 |
bool TsDeviceDialogPlugin::deviceDialogInfo(const QString &deviceDialogType, const QVariantMap ¶meters, DeviceDialogInfo *info) const
|
|
128 |
{
|
|
129 |
Q_UNUSED(parameters)
|
|
130 |
Q_UNUSED(deviceDialogType)
|
|
131 |
|
|
132 |
info->group = GenericDeviceDialogGroup;
|
102
|
133 |
info->flags = SingleInstance;
|
99
|
134 |
info->priority = DefaultPriority;
|
|
135 |
|
|
136 |
return true;
|
|
137 |
}
|
|
138 |
|
|
139 |
/*!
|
|
140 |
\reimp
|
|
141 |
*/
|
|
142 |
QStringList TsDeviceDialogPlugin::deviceDialogTypes() const
|
|
143 |
{
|
|
144 |
return QStringList(QString(KTsDialogType));
|
|
145 |
}
|
|
146 |
|
|
147 |
/*!
|
|
148 |
\reimp
|
|
149 |
*/
|
|
150 |
HbDeviceDialogPlugin::PluginFlags TsDeviceDialogPlugin::pluginFlags() const
|
|
151 |
{
|
|
152 |
return PluginFlags(PreloadPlugin | KeepPluginLoaded);
|
|
153 |
}
|
|
154 |
|
|
155 |
/*!
|
|
156 |
\reimp
|
|
157 |
*/
|
|
158 |
int TsDeviceDialogPlugin::error() const
|
|
159 |
{
|
|
160 |
return mError;
|
|
161 |
}
|
|
162 |
|
|
163 |
#ifdef COVERAGE_MEASUREMENT
|
|
164 |
#pragma CTC SKIP
|
|
165 |
#endif //COVERAGE_MEASUREMENT
|
|
166 |
|
|
167 |
Q_EXPORT_PLUGIN2(tsdevicedialogplugin, TsDeviceDialogPlugin)
|
|
168 |
|
|
169 |
#ifdef COVERAGE_MEASUREMENT
|
|
170 |
#pragma CTC ENDSKIP
|
|
171 |
#endif //COVERAGE_MEASUREMENT
|