57
|
1 |
/*
|
70
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
57
|
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 |
|
|
19 |
#include "btdeviceinfowidget.h"
|
|
20 |
#include "bluetoothdevicedialogs.h"
|
|
21 |
#include "btdevicedialogpluginerrors.h"
|
|
22 |
#include <btuiiconutil.h>
|
70
|
23 |
#include <HbLabel>
|
57
|
24 |
|
|
25 |
const int timeOut = 30000;
|
|
26 |
|
|
27 |
BtDeviceInfoWidget::BtDeviceInfoWidget(const QVariantMap ¶meters)
|
|
28 |
:mLastError(NoError)
|
|
29 |
{
|
|
30 |
constructDialog(parameters);
|
|
31 |
}
|
|
32 |
|
|
33 |
BtDeviceInfoWidget::~BtDeviceInfoWidget()
|
|
34 |
{
|
|
35 |
|
|
36 |
}
|
|
37 |
|
|
38 |
bool BtDeviceInfoWidget::setDeviceDialogParameters(const QVariantMap ¶meters)
|
|
39 |
{
|
|
40 |
Q_UNUSED(parameters);
|
|
41 |
return true;
|
|
42 |
}
|
|
43 |
|
|
44 |
int BtDeviceInfoWidget::deviceDialogError() const
|
|
45 |
{
|
|
46 |
return mLastError;
|
|
47 |
}
|
|
48 |
|
|
49 |
void BtDeviceInfoWidget::closeDeviceDialog(bool byClient)
|
|
50 |
{
|
|
51 |
Q_UNUSED(byClient);
|
|
52 |
mMessageBox->close();
|
|
53 |
emit deviceDialogClosed();
|
|
54 |
}
|
|
55 |
|
|
56 |
HbPopup* BtDeviceInfoWidget::deviceDialogWidget() const
|
|
57 |
{
|
|
58 |
return mMessageBox;
|
|
59 |
}
|
|
60 |
|
|
61 |
QObject* BtDeviceInfoWidget::signalSender() const
|
|
62 |
{
|
|
63 |
return const_cast<BtDeviceInfoWidget*>(this);
|
|
64 |
}
|
|
65 |
|
|
66 |
bool BtDeviceInfoWidget::constructDialog(const QVariantMap ¶meters)
|
|
67 |
{
|
|
68 |
QString keyStrDialogTitle, keyStrResource;
|
|
69 |
keyStrDialogTitle.setNum(TBluetoothDialogParams::EDialogTitle);
|
|
70 |
QVariantMap::const_iterator i = parameters.constFind(keyStrDialogTitle);
|
|
71 |
|
|
72 |
keyStrResource.setNum(TBluetoothDialogParams::EResource);
|
|
73 |
QVariantMap::const_iterator j = parameters.constFind(keyStrResource);
|
|
74 |
|
|
75 |
if(i != parameters.end())
|
|
76 |
{
|
|
77 |
int dialogTitle = parameters.value(QString::number(TBluetoothDialogParams::EDialogTitle)).toInt();
|
|
78 |
|
|
79 |
switch(dialogTitle)
|
|
80 |
{
|
|
81 |
case TBluetoothDialogParams::EBTAddress:
|
|
82 |
{
|
|
83 |
mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
|
|
84 |
QString textStr(hbTrId("txt_bt_info_bluetooth_device_address_1"));
|
|
85 |
QString deviceAddr(parameters.value(QString::number(TBluetoothDeviceDialog::ELocalAddress)).toString());
|
|
86 |
mMessageBox->setText(textStr.arg(deviceAddr));
|
|
87 |
HbIcon icon(QString("qtg_large_bluetooth"));
|
|
88 |
mMessageBox->setIcon(icon);
|
|
89 |
mMessageBox->setTimeout(timeOut);
|
70
|
90 |
connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
|
57
|
91 |
}break;
|
|
92 |
//TODO: Remove this piece of code if notifier is used in toggle
|
|
93 |
case TBluetoothDialogParams::EOfflineQuery:
|
|
94 |
{
|
|
95 |
mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
|
|
96 |
mMessageBox->setText(hbTrId("txt_bt_info_trun_bluetooth_on_ini_offline_mode"));
|
|
97 |
mMessageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
|
|
98 |
HbIcon icon(QString("qtg_large_bluetooth"));
|
|
99 |
mMessageBox->setIcon(icon);
|
|
100 |
mMessageBox->setTimeout(timeOut);
|
|
101 |
connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
|
|
102 |
}break;
|
|
103 |
|
|
104 |
case TBluetoothDialogParams::ERecvFailed:
|
|
105 |
{
|
|
106 |
mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
|
|
107 |
QString textStr(hbTrId("txt_bt_dpophead_receiving_failed"));
|
|
108 |
QString devName(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString());
|
|
109 |
mMessageBox->setText(textStr.arg(devName));
|
|
110 |
int classOfDevice = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
|
|
111 |
HbIcon icon = getBadgedDeviceTypeIcon(classOfDevice);
|
|
112 |
mMessageBox->setIcon(icon);
|
|
113 |
mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
|
70
|
114 |
connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
|
57
|
115 |
}break;
|
|
116 |
|
|
117 |
case TBluetoothDialogParams::ESendFailed:
|
|
118 |
{
|
|
119 |
mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
|
|
120 |
QString textStr(hbTrId("txt_bt_dpophead_sending_failed"));
|
|
121 |
QString devName(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString());
|
|
122 |
mMessageBox->setText(textStr.arg(devName));
|
|
123 |
int classOfDevice = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
|
|
124 |
HbIcon icon = getBadgedDeviceTypeIcon(classOfDevice);
|
|
125 |
mMessageBox->setIcon(icon);
|
|
126 |
mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
|
70
|
127 |
connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
|
57
|
128 |
}break;
|
|
129 |
|
|
130 |
case TBluetoothDialogParams::EMemoryFull:
|
|
131 |
{
|
|
132 |
mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning);
|
|
133 |
QString textStr(hbTrId("txt_error_info_memory_full_delete_data"));
|
|
134 |
QString driveLetter(parameters.value(QString::number(TBluetoothDeviceDialog::EDriveLetter)).toChar());
|
|
135 |
QString driveName(parameters.value(QString::number(TBluetoothDeviceDialog::EDriveName)).toString());
|
|
136 |
mMessageBox->setText(textStr.arg(driveLetter).arg(driveName));
|
|
137 |
mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
|
70
|
138 |
connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
|
57
|
139 |
}break;
|
|
140 |
|
|
141 |
case TBluetoothDialogParams::EDriveNotFound:
|
|
142 |
{
|
|
143 |
mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning);
|
|
144 |
mMessageBox->setText(hbTrId("txt_bt_info_file_not_fould_memory_card_has_been_r"));
|
|
145 |
mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
|
70
|
146 |
connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
|
57
|
147 |
}break;
|
|
148 |
|
|
149 |
case TBluetoothDialogParams::EFileMoved:
|
|
150 |
{
|
|
151 |
mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning);
|
|
152 |
mMessageBox->setText(hbTrId("txt_bt_info_file_not_fould_it_may_be_removed_or_d"));
|
|
153 |
mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
|
70
|
154 |
connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
|
57
|
155 |
}break;
|
|
156 |
|
|
157 |
case TBluetoothDialogParams::EUnsupportedImages:
|
|
158 |
{
|
|
159 |
mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
|
|
160 |
QString textStr(parameters.value(QString::number(TBluetoothDeviceDialog::EAdditionalDesc)).toString());
|
|
161 |
mMessageBox->setText(textStr);
|
|
162 |
mMessageBox->setStandardButtons(HbMessageBox::Continue| HbMessageBox::Cancel);
|
|
163 |
int classOfDevice = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
|
|
164 |
HbIcon icon = getBadgedDeviceTypeIcon(classOfDevice);
|
|
165 |
mMessageBox->setIcon(icon);
|
|
166 |
mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
|
|
167 |
connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
|
|
168 |
}break;
|
70
|
169 |
|
|
170 |
case TBluetoothDialogParams::ECannotUseSAPTemporarily:
|
|
171 |
{
|
|
172 |
mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
|
|
173 |
mMessageBox->setText(hbTrId("txt_bt_info_sim_access_profile_is_used_next_time_t"));
|
|
174 |
mMessageBox->setDismissPolicy(HbPopup::TapOutside);
|
|
175 |
mMessageBox->setTimeout(HbPopup::StandardTimeout);
|
|
176 |
connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
|
|
177 |
}break;
|
|
178 |
|
|
179 |
case TBluetoothDialogParams::ENoSimInDevice:
|
|
180 |
{
|
|
181 |
mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
|
|
182 |
mMessageBox->setHeadingWidget(new HbLabel(hbTrId("txt_bt_title_no_sim_card_in_the_device")));
|
|
183 |
mMessageBox->setText(hbTrId("txt_bt_info_do_you_still_want_to_enable_sim_access"));
|
|
184 |
mMessageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
|
|
185 |
mMessageBox->setDismissPolicy(HbPopup::TapOutside);
|
|
186 |
mMessageBox->setTimeout(HbPopup::StandardTimeout);
|
|
187 |
connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
|
|
188 |
}break;
|
|
189 |
|
|
190 |
case TBluetoothDialogParams::EUnableToUseSAP:
|
|
191 |
{
|
|
192 |
mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
|
|
193 |
mMessageBox->setHeadingWidget(new HbLabel(hbTrId("txt_bt_title_unable_to_enter_sim_access_profile")));
|
|
194 |
mMessageBox->setText(hbTrId("txt_bt_info_try_entering_the_sim_access_profile_ag"));
|
|
195 |
mMessageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
|
|
196 |
mMessageBox->setDismissPolicy(HbPopup::TapOutside);
|
|
197 |
mMessageBox->setTimeout(HbPopup::StandardTimeout);
|
|
198 |
connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
|
|
199 |
}break;
|
57
|
200 |
|
|
201 |
default:
|
|
202 |
mLastError = UnknownDeviceDialogError;
|
|
203 |
break;
|
|
204 |
}
|
|
205 |
}
|
|
206 |
|
|
207 |
else if(j != parameters.end())
|
|
208 |
{
|
|
209 |
int resourceType = parameters.value(QString::number(TBluetoothDialogParams::EResource)).toInt();
|
|
210 |
|
|
211 |
switch(resourceType)
|
|
212 |
{
|
|
213 |
case EIssueOfflineQuery:
|
|
214 |
{
|
|
215 |
mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
|
|
216 |
mMessageBox->setText(hbTrId("txt_bt_info_trun_bluetooth_on_ini_offline_mode"));
|
|
217 |
mMessageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
|
|
218 |
HbIcon icon(QString("qtg_large_bluetooth"));
|
|
219 |
mMessageBox->setIcon(icon);
|
|
220 |
mMessageBox->setTimeout(timeOut);
|
|
221 |
connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
|
|
222 |
}break;
|
|
223 |
|
|
224 |
default:
|
|
225 |
mLastError = UnknownDeviceDialogError;
|
|
226 |
break;
|
|
227 |
}
|
|
228 |
}
|
|
229 |
|
|
230 |
else
|
|
231 |
{
|
|
232 |
mLastError = UnknownDeviceDialogError;
|
|
233 |
}
|
|
234 |
|
|
235 |
if(!mLastError)
|
|
236 |
{
|
|
237 |
mMessageBox->setAttribute(Qt::WA_DeleteOnClose);
|
|
238 |
return true;
|
|
239 |
}
|
|
240 |
|
|
241 |
return false;
|
|
242 |
}
|
|
243 |
|
|
244 |
void BtDeviceInfoWidget::messageBoxClosed(int action)
|
|
245 |
{
|
|
246 |
QVariantMap data;
|
70
|
247 |
if((action == HbMessageBox::Yes) || (action == HbMessageBox::Continue) || (action == HbMessageBox::Ok))
|
57
|
248 |
{
|
|
249 |
data.insert(QString("actionResult"), QVariant(true));
|
|
250 |
}
|
|
251 |
else if((action == HbMessageBox::No) || (action == HbMessageBox::Cancel))
|
|
252 |
{
|
|
253 |
data.insert(QString("actionResult"), QVariant(false));
|
|
254 |
}
|
|
255 |
emit deviceDialogData(data);
|
|
256 |
emit deviceDialogClosed();
|
|
257 |
}
|