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 "tsdevicedialogplugin.h" |
|
19 |
|
20 #include <QTranslator> |
|
21 #include <QCoreApplication> |
|
22 #include <QLocale> |
|
23 #include <QtPlugin> |
|
24 |
|
25 #include <QValueSpacePublisher> |
|
26 |
|
27 #include <HbDeviceDialog> |
|
28 #include <HbMainWindow> |
|
29 |
|
30 #include <tspropertydefs.h> |
|
31 |
|
32 #include "tsdevicedialogcontainer.h" |
|
33 #include "tstasksgrid.h" |
|
34 #include "tstasksgriditem.h" |
|
35 #include "tsdocumentloader.h" |
|
36 #include "tsmodel.h" |
|
37 |
|
38 QTM_USE_NAMESPACE |
|
39 |
|
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"; |
|
50 } |
|
51 |
|
52 /*! |
|
53 Constructor. |
|
54 */ |
|
55 TsDeviceDialogPlugin::TsDeviceDialogPlugin() |
|
56 : |
|
57 mModel(0), |
|
58 mStorage(0), |
|
59 mTriedToLoadTranslation(false) |
|
60 { |
|
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(); |
|
66 } |
|
67 |
|
68 TsDeviceDialogPlugin::~TsDeviceDialogPlugin() |
|
69 { |
|
70 } |
|
71 /*! |
|
72 \reimp |
|
73 */ |
|
74 bool TsDeviceDialogPlugin::accessAllowed(const QString &deviceDialogType, |
|
75 const QVariantMap ¶meters, |
|
76 const QVariantMap &securityInfo) const |
|
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 */ |
|
90 HbDeviceDialogInterface * |
|
91 TsDeviceDialogPlugin::createDeviceDialog(const QString &deviceDialogType, |
|
92 const QVariantMap ¶meters) |
|
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); |
|
102 QString translationFile = |
|
103 QString("taskswitcher_%1").arg(QLocale::system().name()); |
|
104 |
|
105 bool translationLoaded(false); |
|
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 |
|
120 |
|
121 Q_ASSERT(translationLoaded); |
|
122 qApp->installTranslator(translator); |
|
123 } |
|
124 |
|
125 // lazy loading of model |
|
126 if (!mModel) { |
|
127 mStorage = new TsTaskMonitor(this); |
|
128 mModel = new TsModel(*mStorage, this); |
|
129 } |
|
130 |
|
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 |
|
137 |
|
138 // create device dialog |
|
139 dialogInterface = new TsDeviceDialogContainer(mModel); |
|
140 } |
|
141 return dialogInterface; |
|
142 } |
|
143 |
|
144 /*! |
|
145 \reimp |
|
146 */ |
|
147 bool TsDeviceDialogPlugin::deviceDialogInfo(const QString &deviceDialogType, |
|
148 const QVariantMap ¶meters, |
|
149 DeviceDialogInfo *info) const |
|
150 { |
|
151 Q_UNUSED(parameters) |
|
152 Q_UNUSED(deviceDialogType) |
|
153 |
|
154 info->group = GenericDeviceDialogGroup; |
|
155 info->flags = SingleInstance; |
|
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 { |
|
182 return 0; |
|
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 |
|