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 |
|
112
|
18 |
#include "tsdevicedialogplugin.h"
|
|
19 |
|
99
|
20 |
#include <QTranslator>
|
|
21 |
#include <QCoreApplication>
|
|
22 |
#include <QLocale>
|
|
23 |
#include <QtPlugin>
|
112
|
24 |
|
|
25 |
#include <QValueSpacePublisher>
|
|
26 |
|
|
27 |
#include <HbDeviceDialog>
|
99
|
28 |
#include <HbMainWindow>
|
|
29 |
|
112
|
30 |
#include <tspropertydefs.h>
|
|
31 |
|
99
|
32 |
#include "tsdevicedialogcontainer.h"
|
|
33 |
#include "tstasksgrid.h"
|
|
34 |
#include "tstasksgriditem.h"
|
|
35 |
#include "tsdocumentloader.h"
|
|
36 |
#include "tsmodel.h"
|
|
37 |
|
112
|
38 |
QTM_USE_NAMESPACE
|
|
39 |
|
99
|
40 |
/*!
|
|
41 |
\class TsDeviceDialogPlugin
|
|
42 |
\ingroup group_tsdevicedialogplugin
|
|
43 |
\brief TaskSwitcher Device Dialog Plug-in.
|
|
44 |
*/
|
|
45 |
|
|
46 |
namespace
|
|
47 |
{
|
|
48 |
const char KTranslationPath[] = "resource/qt/translations";
|
|
49 |
const char KTsDialogType[] = "com.nokia.taskswitcher.tsdevicedialogplugin/1.0";
|
116
|
50 |
}
|
|
51 |
|
99
|
52 |
/*!
|
|
53 |
Constructor.
|
|
54 |
*/
|
107
|
55 |
TsDeviceDialogPlugin::TsDeviceDialogPlugin()
|
116
|
56 |
:
|
|
57 |
mModel(0),
|
|
58 |
mStorage(0),
|
|
59 |
mTriedToLoadTranslation(false)
|
99
|
60 |
{
|
119
|
61 |
// ensure the visibility property is set to false, so the TaskSwitcher
|
|
62 |
// in case when hbdevicedialogappserver crashes when TS is visible.
|
|
63 |
QValueSpacePublisher visibilityPublisher(TsProperty::KTsPath);
|
|
64 |
visibilityPublisher.setValue(TsProperty::KVisibilityPath, static_cast<int>(false));
|
|
65 |
visibilityPublisher.sync();
|
99
|
66 |
}
|
|
67 |
|
|
68 |
TsDeviceDialogPlugin::~TsDeviceDialogPlugin()
|
|
69 |
{
|
|
70 |
}
|
|
71 |
/*!
|
|
72 |
\reimp
|
|
73 |
*/
|
116
|
74 |
bool TsDeviceDialogPlugin::accessAllowed(const QString &deviceDialogType,
|
|
75 |
const QVariantMap ¶meters,
|
107
|
76 |
const QVariantMap &securityInfo) const
|
99
|
77 |
{
|
|
78 |
Q_UNUSED(deviceDialogType)
|
|
79 |
Q_UNUSED(parameters)
|
|
80 |
Q_UNUSED(securityInfo)
|
|
81 |
|
|
82 |
// This plugin doesn't perform operations that may compromise security.
|
|
83 |
// All clients are allowed to use it.
|
|
84 |
return true;
|
|
85 |
}
|
|
86 |
|
|
87 |
/*!
|
|
88 |
\reimp
|
|
89 |
*/
|
116
|
90 |
HbDeviceDialogInterface *
|
|
91 |
TsDeviceDialogPlugin::createDeviceDialog(const QString &deviceDialogType,
|
107
|
92 |
const QVariantMap ¶meters)
|
99
|
93 |
{
|
|
94 |
Q_UNUSED(parameters)
|
|
95 |
HbDeviceDialogInterface *dialogInterface(0);
|
|
96 |
if (deviceDialogType == QString(KTsDialogType)) {
|
|
97 |
// lazy loading of translation
|
|
98 |
if (!mTriedToLoadTranslation) {
|
|
99 |
mTriedToLoadTranslation = true;
|
|
100 |
|
|
101 |
QTranslator *translator = new QTranslator(this);
|
116
|
102 |
QString translationFile =
|
107
|
103 |
QString("taskswitcher_%1").arg(QLocale::system().name());
|
116
|
104 |
|
99
|
105 |
bool translationLoaded(false);
|
116
|
106 |
#ifdef Q_OS_SYMBIAN
|
|
107 |
translationLoaded =
|
|
108 |
translator->load(translationFile,
|
|
109 |
QString("z:/") + KTranslationPath);
|
|
110 |
if (!translationLoaded) {
|
|
111 |
translationLoaded =
|
|
112 |
translator->load(translationFile,
|
|
113 |
QString("c:/") + KTranslationPath);
|
|
114 |
}
|
|
115 |
#else
|
|
116 |
translationLoaded =
|
|
117 |
translator->load(translationFile,
|
|
118 |
QString(KTranslationPath));
|
|
119 |
#endif //Q_OS_SYMBIAN
|
99
|
120 |
|
|
121 |
Q_ASSERT(translationLoaded);
|
|
122 |
qApp->installTranslator(translator);
|
|
123 |
}
|
116
|
124 |
|
99
|
125 |
// lazy loading of model
|
112
|
126 |
if (!mModel) {
|
99
|
127 |
mStorage = new TsTaskMonitor(this);
|
119
|
128 |
mModel = new TsModel(*mStorage, this);
|
99
|
129 |
}
|
116
|
130 |
|
112
|
131 |
// ensure the dismiss request property is set to false
|
|
132 |
|
|
133 |
QValueSpacePublisher dismissRequestPublisher(TsProperty::KTsPath);
|
|
134 |
dismissRequestPublisher.setValue(TsProperty::KDismissRequestPath, static_cast<int>(false));
|
|
135 |
dismissRequestPublisher.sync();
|
|
136 |
|
116
|
137 |
|
112
|
138 |
// create device dialog
|
99
|
139 |
dialogInterface = new TsDeviceDialogContainer(mModel);
|
|
140 |
}
|
|
141 |
return dialogInterface;
|
|
142 |
}
|
|
143 |
|
|
144 |
/*!
|
|
145 |
\reimp
|
|
146 |
*/
|
116
|
147 |
bool TsDeviceDialogPlugin::deviceDialogInfo(const QString &deviceDialogType,
|
|
148 |
const QVariantMap ¶meters,
|
107
|
149 |
DeviceDialogInfo *info) const
|
99
|
150 |
{
|
|
151 |
Q_UNUSED(parameters)
|
|
152 |
Q_UNUSED(deviceDialogType)
|
|
153 |
|
|
154 |
info->group = GenericDeviceDialogGroup;
|
102
|
155 |
info->flags = SingleInstance;
|
99
|
156 |
info->priority = DefaultPriority;
|
|
157 |
|
|
158 |
return true;
|
|
159 |
}
|
|
160 |
|
|
161 |
/*!
|
|
162 |
\reimp
|
|
163 |
*/
|
|
164 |
QStringList TsDeviceDialogPlugin::deviceDialogTypes() const
|
|
165 |
{
|
|
166 |
return QStringList(QString(KTsDialogType));
|
|
167 |
}
|
|
168 |
|
|
169 |
/*!
|
|
170 |
\reimp
|
|
171 |
*/
|
|
172 |
HbDeviceDialogPlugin::PluginFlags TsDeviceDialogPlugin::pluginFlags() const
|
|
173 |
{
|
|
174 |
return PluginFlags(PreloadPlugin | KeepPluginLoaded);
|
|
175 |
}
|
|
176 |
|
|
177 |
/*!
|
|
178 |
\reimp
|
|
179 |
*/
|
|
180 |
int TsDeviceDialogPlugin::error() const
|
|
181 |
{
|
107
|
182 |
return 0;
|
99
|
183 |
}
|
|
184 |
|
|
185 |
#ifdef COVERAGE_MEASUREMENT
|
|
186 |
#pragma CTC SKIP
|
|
187 |
#endif //COVERAGE_MEASUREMENT
|
|
188 |
|
|
189 |
Q_EXPORT_PLUGIN2(tsdevicedialogplugin, TsDeviceDialogPlugin)
|
|
190 |
|
|
191 |
#ifdef COVERAGE_MEASUREMENT
|
|
192 |
#pragma CTC ENDSKIP
|
|
193 |
#endif //COVERAGE_MEASUREMENT
|