|
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 mEngine = CreateProfileEngineExtended2L(); |
|
84 return this; |
|
85 } |
|
86 |
|
87 /*! |
|
88 The error returns indicator error to HbIndicatorPluginInterface. |
|
89 */ |
|
90 int CpSilenceIndicatorPlugin::error() const |
|
91 { |
|
92 return mError; |
|
93 } |
|
94 |
|
95 /*! |
|
96 The handleInteraction is used launch WLAN list view. |
|
97 */ |
|
98 bool CpSilenceIndicatorPlugin::handleInteraction(InteractionType type) |
|
99 { |
|
100 bool handled = false; |
|
101 switch (type) { |
|
102 case InteractionActivated: |
|
103 // set silence mode or disable silence mode |
|
104 bool isSilence = false; |
|
105 TRAP(mError, |
|
106 isSilence = mEngine->SilenceModeL(); |
|
107 mEngine->SetSilenceModeL(!isSilence); |
|
108 ) |
|
109 emit dataChanged(); |
|
110 handled = true; |
|
111 break; |
|
112 default: |
|
113 break; |
|
114 } |
|
115 return handled; |
|
116 } |
|
117 |
|
118 /*! |
|
119 The handleClientRequest handles client request to change indicators paramters. |
|
120 */ |
|
121 bool CpSilenceIndicatorPlugin::handleClientRequest(RequestType type, const QVariant ¶meter) |
|
122 { |
|
123 Q_UNUSED(parameter) |
|
124 bool handled(false); |
|
125 switch (type) { |
|
126 case RequestActivate: |
|
127 TRAP(mError, mEngine->SetSilenceModeL(true);) |
|
128 handled = true; |
|
129 emit dataChanged(); |
|
130 break; |
|
131 |
|
132 case RequestDeactivate: |
|
133 TRAP(mError, mEngine->SetSilenceModeL(false);) |
|
134 handled = true; |
|
135 emit dataChanged(); |
|
136 break; |
|
137 default: |
|
138 break; |
|
139 } |
|
140 |
|
141 return handled; |
|
142 } |
|
143 |
|
144 /*! |
|
145 The indicatorData takes care of showing indicator's data. |
|
146 */ |
|
147 QVariant CpSilenceIndicatorPlugin::indicatorData(int role) const |
|
148 { |
|
149 QVariant variant; |
|
150 switch (role) { |
|
151 // this is the statusbar icon, which is shown only when silence mode is on |
|
152 case MonoDecorationNameRole: |
|
153 if (mEngine->SilenceModeL()) { |
|
154 variant = HbIcon("qtg_status_profile_silent"); |
|
155 } else { |
|
156 variant = HbIcon(); |
|
157 } |
|
158 break; |
|
159 default: |
|
160 break; |
|
161 } |
|
162 return variant; |
|
163 } |