40
|
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 <QLocale>
|
|
20 |
#include <QtCore/qplugin.h>
|
|
21 |
#include <QtCore/QString>
|
|
22 |
#include <QtCore/QVariant>
|
|
23 |
#include <QtCore/QMetaType>
|
|
24 |
|
|
25 |
#include <HbLabel>
|
|
26 |
#include <hbglobal.h>
|
|
27 |
#include <hbapplication.h>
|
|
28 |
#include <hbindicatorplugininterface.h>
|
|
29 |
#include <hbindicatorinterface.h>
|
|
30 |
#include <hbtranslator.h>
|
|
31 |
#include "cpsilenceindicatorplugin.h"
|
|
32 |
#include <MProfileEngineExtended2.h>
|
|
33 |
#include <w32std.h>
|
|
34 |
|
|
35 |
Q_EXPORT_PLUGIN(CpSilenceIndicatorPlugin)
|
|
36 |
|
|
37 |
const static QString IndicatorType("com.nokia.hb.indicator.controlpanel.cpsilenceindicatorplugin/1.0");
|
|
38 |
|
|
39 |
|
|
40 |
/*!
|
|
41 |
SilenceIndicatorPlugin constructor.
|
|
42 |
*/
|
|
43 |
CpSilenceIndicatorPlugin::CpSilenceIndicatorPlugin() :
|
|
44 |
HbIndicatorInterface(IndicatorType, SettingCategory, InteractionActivated),
|
|
45 |
mError(0)
|
|
46 |
{
|
|
47 |
mIndicatorTypes << IndicatorType;
|
|
48 |
}
|
|
49 |
|
|
50 |
/*!
|
|
51 |
SilenceIndicatorPlugin destructor.
|
|
52 |
*/
|
|
53 |
CpSilenceIndicatorPlugin::~CpSilenceIndicatorPlugin()
|
|
54 |
{
|
|
55 |
}
|
|
56 |
|
|
57 |
/*!
|
|
58 |
The indicatorTypes returns type of indicator. In this case it is CpSilenceIndicatorPlugin.
|
|
59 |
*/
|
|
60 |
QStringList CpSilenceIndicatorPlugin::indicatorTypes() const
|
|
61 |
{
|
|
62 |
return mIndicatorTypes;
|
|
63 |
}
|
|
64 |
|
|
65 |
/*!
|
|
66 |
The handleClientRequest handles client request to change indicators parameters.
|
|
67 |
*/
|
|
68 |
bool CpSilenceIndicatorPlugin::accessAllowed(const QString &indicatorType,
|
|
69 |
const QVariantMap &securityInfo) const
|
|
70 |
{
|
|
71 |
Q_UNUSED(indicatorType)
|
|
72 |
Q_UNUSED(securityInfo)
|
|
73 |
return true;
|
|
74 |
}
|
|
75 |
|
|
76 |
/*!
|
|
77 |
The createIndicator creates indicator plugin instance.
|
|
78 |
*/
|
|
79 |
HbIndicatorInterface* CpSilenceIndicatorPlugin::createIndicator(
|
|
80 |
const QString &indicatorType)
|
|
81 |
{
|
|
82 |
Q_UNUSED(indicatorType)
|
|
83 |
// Install localization
|
|
84 |
HbTranslator translator("control_panel");
|
|
85 |
translator.loadCommon();
|
|
86 |
mEngine = CreateProfileEngineExtended2L();
|
|
87 |
return this;
|
|
88 |
}
|
|
89 |
|
|
90 |
/*!
|
|
91 |
The error returns indicator error to HbIndicatorPluginInterface.
|
|
92 |
*/
|
|
93 |
int CpSilenceIndicatorPlugin::error() const
|
|
94 |
{
|
|
95 |
return mError;
|
|
96 |
}
|
|
97 |
|
|
98 |
/*!
|
|
99 |
The handleInteraction is used to emit dataChange signal.
|
|
100 |
*/
|
|
101 |
bool CpSilenceIndicatorPlugin::handleInteraction(InteractionType type)
|
|
102 |
{
|
|
103 |
bool handled = false;
|
|
104 |
switch (type) {
|
|
105 |
case InteractionActivated:
|
|
106 |
emit dataChanged();
|
|
107 |
handled = true;
|
|
108 |
break;
|
|
109 |
default:
|
|
110 |
break;
|
|
111 |
}
|
|
112 |
return handled;
|
|
113 |
}
|
|
114 |
|
|
115 |
/*!
|
|
116 |
The handleClientRequest handles client request to change indicators paramters.
|
|
117 |
*/
|
|
118 |
bool CpSilenceIndicatorPlugin::handleClientRequest(RequestType type, const QVariant ¶meter)
|
|
119 |
{
|
|
120 |
Q_UNUSED(parameter)
|
|
121 |
bool handled(false);
|
|
122 |
switch (type) {
|
|
123 |
case RequestActivate:
|
|
124 |
case RequestDeactivate:
|
|
125 |
handled = true;
|
|
126 |
emit dataChanged();
|
|
127 |
break;
|
|
128 |
default:
|
|
129 |
break;
|
|
130 |
}
|
|
131 |
|
|
132 |
return handled;
|
|
133 |
}
|
|
134 |
|
|
135 |
/*!
|
|
136 |
The indicatorData takes care of showing indicator's data.
|
|
137 |
*/
|
|
138 |
QVariant CpSilenceIndicatorPlugin::indicatorData(int role) const
|
|
139 |
{
|
|
140 |
QVariant variant;
|
|
141 |
switch (role) {
|
|
142 |
// this is the statusbar icon, which is shown only when silence mode is on
|
|
143 |
case MonoDecorationNameRole:
|
|
144 |
if (mEngine->SilenceModeL()) {
|
|
145 |
variant = QString("qtg_status_profile_silent");
|
|
146 |
} else {
|
|
147 |
variant = QString();
|
|
148 |
}
|
|
149 |
break;
|
|
150 |
default:
|
|
151 |
break;
|
|
152 |
}
|
|
153 |
return variant;
|
|
154 |
}
|