42
|
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 "btindicatorconstants.h"
|
70
|
20 |
|
|
21 |
|
|
22 |
#define LOC_BLUETOOTH hbTrId("txt_bt_dblist_bluetooth")
|
|
23 |
|
|
24 |
const QString BT_APPLICATION("btcpplugin.dll");
|
42
|
25 |
|
|
26 |
struct BTIndicatorInfo
|
70
|
27 |
{
|
|
28 |
QString DecorationIcon;
|
|
29 |
QString MonoDecorationIcon;
|
|
30 |
};
|
42
|
31 |
|
|
32 |
static const int BTIndicatorCount = 5;
|
|
33 |
|
|
34 |
|
|
35 |
static const BTIndicatorInfo IndicatorInfo[BTIndicatorCount] = {
|
70
|
36 |
{ "qtg_large_bluetooth_off", "qtg_status_bluetooth_off" },
|
|
37 |
{ "qtg_large_bluetooth","qtg_status_bluetooth" },
|
|
38 |
{ "qtg_large_bluetooth_hide","qtg_status_bluetooth_hide" },
|
|
39 |
{ "qtg_large_bluetooth_active_connection", "qtg_status_bluetooth_connection"},
|
|
40 |
{ "qtg_large_bluetooth_hide_connection", "qtg_status_bluetooth_hide_connection"}
|
42
|
41 |
};
|
|
42 |
|
|
43 |
|
|
44 |
// ----------------------------------------------------------------------------
|
|
45 |
// BTIndicator::BTIndicator
|
|
46 |
// ----------------------------------------------------------------------------
|
|
47 |
BTIndicator::BTIndicator(const QString &indicatorType) :
|
|
48 |
HbIndicatorInterface(indicatorType,
|
|
49 |
HbIndicatorInterface::SettingCategory ,
|
70
|
50 |
InteractionActivated),mRequest(0),mIndicatorStatus(0),mIndicatorlaunch(false)
|
|
51 |
{
|
|
52 |
mSecondaryText << hbTrId("txt_bt_dblist_bluetooth_val_off")
|
|
53 |
<< hbTrId("txt_bt_dblist_bluetooth_val_on_and_visible")
|
|
54 |
<< hbTrId("txt_bt_dblist_bluetooth_val_on_and_hidden")
|
|
55 |
<< hbTrId("txt_bt_dblist_bluetooth_val_visible_and_connected")
|
|
56 |
<< hbTrId("txt_bt_dblist_bluetooth_val_hidden_and_connected");
|
|
57 |
}
|
42
|
58 |
|
|
59 |
// ----------------------------------------------------------------------------
|
|
60 |
// BTIndicator::~BTIndicator
|
|
61 |
// ----------------------------------------------------------------------------
|
|
62 |
BTIndicator::~BTIndicator()
|
70
|
63 |
{
|
|
64 |
delete mRequest;
|
|
65 |
}
|
42
|
66 |
|
|
67 |
|
|
68 |
// ----------------------------------------------------------------------------
|
|
69 |
// BTIndicator::handleInteraction
|
|
70 |
// ----------------------------------------------------------------------------
|
|
71 |
bool BTIndicator::handleInteraction(InteractionType type)
|
70
|
72 |
{
|
42
|
73 |
if (type == InteractionActivated)
|
70
|
74 |
{
|
|
75 |
/* if(!mIndicatorlaunch)
|
|
76 |
{
|
|
77 |
launchBTCpSettingView();
|
|
78 |
mIndicatorlaunch = true;
|
|
79 |
}*/
|
|
80 |
|
|
81 |
}
|
42
|
82 |
return true;
|
70
|
83 |
}
|
42
|
84 |
|
|
85 |
// ----------------------------------------------------------------------------
|
|
86 |
// BTIndicator::indicatorData
|
|
87 |
// returns the data and icon that needs to be displayed in the universal pop up and indicator menu
|
|
88 |
// ----------------------------------------------------------------------------
|
|
89 |
QVariant BTIndicator::indicatorData(int role) const
|
|
90 |
{
|
70
|
91 |
QVariant data("");
|
42
|
92 |
|
70
|
93 |
if(mIndicatorStatus == 0)
|
|
94 |
{
|
|
95 |
data = QString();
|
|
96 |
}
|
|
97 |
else
|
|
98 |
{
|
|
99 |
switch(role) {
|
|
100 |
case PrimaryTextRole:
|
|
101 |
data = QString(LOC_BLUETOOTH);
|
|
102 |
break;
|
|
103 |
case SecondaryTextRole:
|
|
104 |
data = mSecondaryText[mIndicatorStatus];
|
|
105 |
break;
|
|
106 |
case DecorationNameRole:
|
|
107 |
data = IndicatorInfo[mIndicatorStatus].DecorationIcon;
|
|
108 |
break;
|
|
109 |
case MonoDecorationNameRole :
|
|
110 |
data = IndicatorInfo[mIndicatorStatus].MonoDecorationIcon;
|
|
111 |
break;
|
|
112 |
default:
|
|
113 |
data = QString();
|
|
114 |
break;
|
|
115 |
}
|
|
116 |
}
|
|
117 |
return data;
|
42
|
118 |
}
|
|
119 |
|
|
120 |
// ----------------------------------------------------------------------------
|
|
121 |
// BTIndicator::handleClientRequest
|
|
122 |
// handles client's activate and deactivate request
|
|
123 |
// ----------------------------------------------------------------------------
|
|
124 |
bool BTIndicator::handleClientRequest( RequestType type,
|
|
125 |
const QVariant ¶meter)
|
70
|
126 |
{
|
42
|
127 |
bool handled(false);
|
|
128 |
switch (type) {
|
|
129 |
case RequestActivate:
|
|
130 |
{
|
|
131 |
mIndicatorStatus = parameter.toInt();
|
70
|
132 |
if(( !mIndicatorStatus )&&( !mIndicatorlaunch ))
|
|
133 |
{
|
|
134 |
mSecondaryText = QStringList();
|
|
135 |
emit deactivate();
|
|
136 |
}
|
|
137 |
else
|
|
138 |
{
|
|
139 |
emit dataChanged();
|
|
140 |
}
|
42
|
141 |
handled = true;
|
|
142 |
}
|
|
143 |
break;
|
70
|
144 |
case RequestDeactivate:
|
42
|
145 |
{
|
70
|
146 |
mSecondaryText = QStringList();
|
|
147 |
mIndicatorStatus = 0;
|
42
|
148 |
emit deactivate();
|
|
149 |
}
|
|
150 |
break;
|
70
|
151 |
default:
|
|
152 |
break;
|
42
|
153 |
}
|
|
154 |
return handled;
|
70
|
155 |
}
|
42
|
156 |
|
|
157 |
|
70
|
158 |
void BTIndicator::launchBTCpSettingView()
|
|
159 |
{
|
|
160 |
if(!mRequest)
|
42
|
161 |
{
|
70
|
162 |
mRequest = mAppMgr.create("com.nokia.symbian.ICpPluginLauncher","launchSettingView(QString,QVariant)",false);
|
|
163 |
|
|
164 |
if (!mRequest)
|
|
165 |
{
|
|
166 |
qDebug("BTIndicator request returned with NULL");
|
|
167 |
return;
|
|
168 |
}
|
|
169 |
else
|
|
170 |
{
|
|
171 |
connect(mRequest, SIGNAL(requestOk(QVariant)), SLOT(handleReturnValue(QVariant)));
|
|
172 |
connect(mRequest, SIGNAL(requestError(int,QString)), SLOT(handleError(int,QString)));
|
|
173 |
// Set arguments for request
|
|
174 |
QList<QVariant> args;
|
|
175 |
args << QVariant(BT_APPLICATION);
|
|
176 |
mRequest->setArguments(args);
|
|
177 |
mRequest->setSynchronous(false);
|
|
178 |
}
|
42
|
179 |
}
|
70
|
180 |
// Make the request
|
|
181 |
if (!mRequest->send())
|
42
|
182 |
{
|
|
183 |
//report error
|
|
184 |
qDebug("BTIndicator::launchBTCpSettingView request not sent");
|
|
185 |
}
|
70
|
186 |
|
|
187 |
/* QString service("com.nokia.symbian.ICpPluginLauncher");
|
|
188 |
QString operation("launchSettingView(QString,QVariant)");
|
|
189 |
QList<QVariant> args;
|
|
190 |
XQAiwRequest* request;
|
|
191 |
XQApplicationManager appManager;
|
|
192 |
request = appManager.create(service, operation, false); // not embedded
|
|
193 |
if ( request == NULL )
|
|
194 |
{
|
|
195 |
//Could not create request because of the arguments passed to the create() API.
|
|
196 |
User::Leave(KErrArgument);
|
|
197 |
}
|
|
198 |
args << QVariant("btcpplugin.dll");
|
|
199 |
request->setArguments(args);
|
|
200 |
TInt error = KErrNone;
|
|
201 |
if(!request->send())
|
|
202 |
{
|
|
203 |
// The only likely Symbian error code that can be associated is KErrNotSupported
|
|
204 |
|
|
205 |
}
|
|
206 |
delete request;*/
|
42
|
207 |
|
70
|
208 |
|
|
209 |
}
|
42
|
210 |
|
|
211 |
|
70
|
212 |
void BTIndicator::handleReturnValue(const QVariant &returnValue)
|
42
|
213 |
{
|
70
|
214 |
Q_UNUSED(returnValue);
|
|
215 |
mIndicatorlaunch = false;
|
|
216 |
if(!mIndicatorStatus )
|
|
217 |
{
|
|
218 |
emit deactivate();
|
|
219 |
}
|
42
|
220 |
}
|
|
221 |
|
|
222 |
void BTIndicator::handleError(int errorCode,const QString &errorMessage)
|
70
|
223 |
{
|
42
|
224 |
Q_UNUSED(errorCode);
|
70
|
225 |
Q_UNUSED(errorMessage);
|
|
226 |
mIndicatorlaunch = false;
|
|
227 |
}
|