1 /* |
|
2 * Copyright (c) 2010 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 #include "btindicator.h" |
|
18 #include <QVariant.h> |
|
19 //#include <hbmessagebox.h> |
|
20 //#include <xqaiwrequest.h> |
|
21 #include "btindicatorconstants.h" |
|
22 //#include <XQServiceRequest.h> |
|
23 //#include <cpbasesettingview.h> |
|
24 //#include <cppluginlauncher.h> |
|
25 #define LOC_BLUETOOTH hbTrId("txt_bt_dblist_bluetooth") |
|
26 #define LOC_BLUETOOTH_OFF hbTrId("txt_bt_dblist_bluetooth_val_off") |
|
27 #define LOC_BLUETOOTH_ON_VISIBLE hbTrId("txt_bt_dblist_bluetooth_val_on_and_visible") |
|
28 #define LOC_BLUETOOTH_VISIBLE_CONNECTED hbTrId("txt_bt_dblist_bluetooth_val_visible_and_connected") |
|
29 #define LOC_BLUETOOTH_ON_HIDDEN hbTrId("txt_bt_dblist_bluetooth_val_on_and_hidden") |
|
30 #define LOC_BLUETOOTH_HIDDEN_CONNECTED hbTrId("txt_bt_dblist_bluetooth_val_hidden_and_connected") |
|
31 |
|
32 struct BTIndicatorInfo |
|
33 { |
|
34 QString icon; |
|
35 QString secondaryText; |
|
36 }; |
|
37 |
|
38 static const int BTIndicatorCount = 5; |
|
39 |
|
40 |
|
41 static const BTIndicatorInfo IndicatorInfo[BTIndicatorCount] = { |
|
42 { "qtg_large_bluetooth_off", "LOC_BLUETOOTH_OFF" }, |
|
43 { "qtg_large_bluetooth", "LOC_BLUETOOTH_ON_VISIBLE" }, |
|
44 { "qtg_large_bluetooth_hide","LOC_BLUETOOTH_ON_HIDDEN" }, |
|
45 { "qtg_large_bluetooth_active_connection", "LOC_BT_VISIBLE_CONNECT" }, |
|
46 { "qtg_large_bluetooth_hide_connection","LOC_BT_HIDDEN_CONNECT" } |
|
47 }; |
|
48 |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // BTIndicator::BTIndicator |
|
52 // ---------------------------------------------------------------------------- |
|
53 BTIndicator::BTIndicator(const QString &indicatorType) : |
|
54 HbIndicatorInterface(indicatorType, |
|
55 HbIndicatorInterface::SettingCategory , |
|
56 InteractionActivated) |
|
57 { |
|
58 mIndicatorStatus = 0; |
|
59 } |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // BTIndicator::~BTIndicator |
|
63 // ---------------------------------------------------------------------------- |
|
64 BTIndicator::~BTIndicator() |
|
65 { |
|
66 } |
|
67 |
|
68 |
|
69 // ---------------------------------------------------------------------------- |
|
70 // BTIndicator::handleInteraction |
|
71 // ---------------------------------------------------------------------------- |
|
72 bool BTIndicator::handleInteraction(InteractionType type) |
|
73 { |
|
74 // bool handled = false; |
|
75 if (type == InteractionActivated) |
|
76 { |
|
77 //@TODO need to code for launching the BT Control Panel Plugin is available |
|
78 |
|
79 // launchBTCpSettingView(); |
|
80 } |
|
81 return true; |
|
82 } |
|
83 |
|
84 // ---------------------------------------------------------------------------- |
|
85 // BTIndicator::indicatorData |
|
86 // returns the data and icon that needs to be displayed in the universal pop up and indicator menu |
|
87 // ---------------------------------------------------------------------------- |
|
88 QVariant BTIndicator::indicatorData(int role) const |
|
89 { |
|
90 switch(role) |
|
91 { |
|
92 case PrimaryTextRole: |
|
93 { |
|
94 QString text(LOC_BLUETOOTH); |
|
95 return text; |
|
96 } |
|
97 case SecondaryTextRole: |
|
98 { |
|
99 return IndicatorInfo[mIndicatorStatus].secondaryText;//mSecDisplayName; |
|
100 } |
|
101 case DecorationNameRole: |
|
102 { |
|
103 //QString iconName("qtg_large_bluetooth"); |
|
104 return IndicatorInfo[mIndicatorStatus].icon;//iconName; |
|
105 } |
|
106 case MonoDecorationNameRole : |
|
107 { |
|
108 // QString iconName("qtg_large_bluetooth"); |
|
109 return IndicatorInfo[mIndicatorStatus].icon;//iconName; |
|
110 } |
|
111 |
|
112 default: |
|
113 return QVariant(); |
|
114 } |
|
115 } |
|
116 |
|
117 // ---------------------------------------------------------------------------- |
|
118 // BTIndicator::handleClientRequest |
|
119 // handles client's activate and deactivate request |
|
120 // ---------------------------------------------------------------------------- |
|
121 bool BTIndicator::handleClientRequest( RequestType type, |
|
122 const QVariant ¶meter) |
|
123 { |
|
124 bool handled(false); |
|
125 switch (type) { |
|
126 case RequestActivate: |
|
127 { |
|
128 mSecDisplayName.clear(); |
|
129 /* if(parameter.toInt() == EBTIndicatorOff) |
|
130 mSecDisplayName.append("LOC_BLUETOOTH_OFF"); |
|
131 else if(parameter.toInt() == EBTIndicatorOnVisible) |
|
132 mSecDisplayName.append("LOC_BLUETOOTH_ON_VISIBLE"); |
|
133 else if(parameter.toInt() == EBTIndicatorOnHidden) |
|
134 mSecDisplayName.append("LOC_BLUETOOTH_ON_HIDDEN"); |
|
135 else if(parameter.toInt() == EBTIndicatorVisibleConnected) |
|
136 mSecDisplayName.append("LOC_BT_VISIBLE_CONNECT"); |
|
137 else if(parameter.toInt() == EBTIndicatorHiddenConnected) |
|
138 mSecDisplayName.append("LOC_BT_HIDDEN_CONNECT");*/ |
|
139 mIndicatorStatus = parameter.toInt(); |
|
140 emit dataChanged(); |
|
141 handled = true; |
|
142 } |
|
143 break; |
|
144 default: |
|
145 { |
|
146 mSecDisplayName.clear(); |
|
147 emit deactivate(); |
|
148 } |
|
149 break; |
|
150 } |
|
151 return handled; |
|
152 } |
|
153 |
|
154 |
|
155 /*void BTIndicator::launchBTCpSettingView() |
|
156 { |
|
157 XQAiwRequest *request = mAppMgr.create("obexhighway","com.nokia.symbian.IFileShare","send(QVariant)",true); |
|
158 |
|
159 if (!request) |
|
160 { |
|
161 qDebug("BTIndicator request returned with NULL"); |
|
162 return; |
|
163 } |
|
164 else |
|
165 { |
|
166 connect(request, SIGNAL(requestOk(QVariant)), SLOT(handleReturnValue(QVariant))); |
|
167 connect(request, SIGNAL(requestError(int,QString)), SLOT(handleError(int,QString))); |
|
168 } |
|
169 // Set arguments for request |
|
170 QList<QVariant> args; |
|
171 //c:\resource\qt\plugins\controlpanel\nfccpplugin.qtplugin |
|
172 args << QVariant( "c:\\two.jpg" );//btcpplugin.dll |
|
173 // args << QVariant ( "c:\\two.jpg" ); |
|
174 request->setArguments(args); |
|
175 |
|
176 // Make the request |
|
177 if (!request->send()) |
|
178 { |
|
179 //report error |
|
180 qDebug("BTIndicator::launchBTCpSettingView request not sent"); |
|
181 } |
|
182 |
|
183 delete request; |
|
184 |
|
185 }*/ |
|
186 |
|
187 |
|
188 /*void BTIndicator::handleReturnValue(const QVariant &returnValue) |
|
189 { |
|
190 } |
|
191 |
|
192 void BTIndicator::handleError(int errorCode,const QString &errorMessage) |
|
193 { |
|
194 Q_UNUSED(errorCode); |
|
195 }*/ |
|