29
|
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: BtDeviceDialogWidget class implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "btdevicedialognotifwidget.h"
|
|
20 |
#include "btdevicedialogplugintrace.h"
|
|
21 |
#include <bluetoothdevicedialogs.h>
|
|
22 |
#include <hbaction.h>
|
|
23 |
#include <hbdialog.h>
|
|
24 |
#include "btdevicedialogpluginerrors.h"
|
42
|
25 |
#include <btuiiconutil.h>
|
29
|
26 |
/*!
|
|
27 |
class Constructor
|
|
28 |
*/
|
|
29 |
BtDeviceDialogNotifWidget::BtDeviceDialogNotifWidget( const QVariantMap ¶meters )
|
|
30 |
{
|
|
31 |
TRACE_ENTRY
|
|
32 |
// set properties
|
|
33 |
mLastError = NoError;
|
|
34 |
mShowEventReceived = false;
|
42
|
35 |
mNotificationDialog = new HbNotificationDialog();
|
29
|
36 |
resetProperties();
|
42
|
37 |
constructNotifDialog(parameters);
|
29
|
38 |
TRACE_EXIT
|
|
39 |
}
|
|
40 |
|
|
41 |
/*!
|
42
|
42 |
class Constructor
|
|
43 |
*/
|
|
44 |
BtDeviceDialogNotifWidget::~BtDeviceDialogNotifWidget()
|
|
45 |
{
|
|
46 |
TRACE_ENTRY
|
|
47 |
delete mNotificationDialog;
|
|
48 |
return;
|
|
49 |
}
|
|
50 |
|
|
51 |
/*!
|
29
|
52 |
Set parameters, implementation of interface
|
|
53 |
Invoked when HbDeviceDialog::update calls.
|
|
54 |
*/
|
|
55 |
bool BtDeviceDialogNotifWidget::setDeviceDialogParameters(
|
|
56 |
const QVariantMap ¶meters)
|
|
57 |
{
|
|
58 |
TRACE_ENTRY
|
|
59 |
mLastError = NoError;
|
|
60 |
processParam(parameters);
|
|
61 |
TRACE_EXIT
|
|
62 |
return true;
|
|
63 |
}
|
|
64 |
|
|
65 |
/*!
|
|
66 |
Get error, implementation of interface
|
|
67 |
*/
|
|
68 |
int BtDeviceDialogNotifWidget::deviceDialogError() const
|
|
69 |
{
|
|
70 |
TRACE_ENTRY
|
|
71 |
TRACE_EXIT
|
|
72 |
return mLastError;
|
|
73 |
}
|
|
74 |
|
|
75 |
/*!
|
|
76 |
Close notification, implementation of interface
|
|
77 |
*/
|
|
78 |
void BtDeviceDialogNotifWidget::closeDeviceDialog(bool byClient)
|
|
79 |
{
|
|
80 |
TRACE_ENTRY
|
|
81 |
Q_UNUSED(byClient);
|
|
82 |
// Closed by client or internally by server -> no action to be transmitted.
|
|
83 |
mSendAction = false;
|
42
|
84 |
mNotificationDialog->close();
|
|
85 |
// If show event has been received, close is signalled from hide event. If not,
|
29
|
86 |
// hide event does not come and close is signalled from here.
|
|
87 |
if (!mShowEventReceived) {
|
|
88 |
emit deviceDialogClosed();
|
|
89 |
}
|
|
90 |
TRACE_EXIT
|
|
91 |
}
|
|
92 |
|
|
93 |
/*!
|
|
94 |
Return display widget, implementation of interface
|
|
95 |
*/
|
42
|
96 |
HbPopup *BtDeviceDialogNotifWidget::deviceDialogWidget() const
|
29
|
97 |
{
|
|
98 |
TRACE_ENTRY
|
|
99 |
TRACE_EXIT
|
42
|
100 |
return mNotificationDialog;
|
|
101 |
}
|
|
102 |
|
|
103 |
QObject* BtDeviceDialogNotifWidget::signalSender() const
|
|
104 |
{
|
29
|
105 |
return const_cast<BtDeviceDialogNotifWidget*>(this);
|
42
|
106 |
}
|
29
|
107 |
|
|
108 |
/*!
|
|
109 |
Construct display widget
|
|
110 |
*/
|
42
|
111 |
bool BtDeviceDialogNotifWidget::constructNotifDialog(const QVariantMap ¶meters)
|
29
|
112 |
{
|
|
113 |
TRACE_ENTRY
|
|
114 |
// analyze the parameters to compose the properties of the message box widget
|
|
115 |
processParam(parameters);
|
42
|
116 |
connect(mNotificationDialog, SIGNAL(finished(HbAction*)), this, SLOT(NotifClosed(HbAction*)));
|
29
|
117 |
TRACE_EXIT
|
|
118 |
return true;
|
|
119 |
}
|
|
120 |
|
|
121 |
/*!
|
|
122 |
Take parameter values and generate relevant property of this widget
|
|
123 |
*/
|
|
124 |
void BtDeviceDialogNotifWidget::processParam(const QVariantMap ¶meters)
|
|
125 |
{
|
|
126 |
TRACE_ENTRY
|
42
|
127 |
QString keyStr, prompt,title;
|
|
128 |
QVariant classOfDevice;
|
29
|
129 |
keyStr.setNum( TBluetoothDialogParams::EResource );
|
|
130 |
// Validate if the resource item exists.
|
|
131 |
QVariantMap::const_iterator i = parameters.constFind( keyStr );
|
|
132 |
// item of ResourceId is not found, can't continue.
|
|
133 |
if ( i == parameters.constEnd() ) {
|
|
134 |
mLastError = UnknownDeviceDialogError;
|
|
135 |
return;
|
|
136 |
}
|
42
|
137 |
HbIcon icon;
|
29
|
138 |
QVariant param = parameters.value( keyStr );
|
|
139 |
int key = param.toInt();
|
|
140 |
switch ( key ) {
|
|
141 |
case EPairingSuccess:
|
42
|
142 |
title = QString(hbTrId( "txt_bt_dpophead_paired" ));
|
|
143 |
prompt = QString( hbTrId( "txt_bt_dpopinfo_paired_to_1" ) );
|
|
144 |
classOfDevice = parameters.value(QString::number( TBluetoothDeviceDialog::EDeviceClass ));
|
|
145 |
icon = getBadgedDeviceTypeIcon(classOfDevice.toInt());
|
|
146 |
mNotificationDialog->setIcon(icon);
|
29
|
147 |
break;
|
42
|
148 |
// todo: remove this Unpaired notification if not used
|
|
149 |
case EUnpairedDevice:
|
|
150 |
title = QString(hbTrId( "txt_bt_dpophead_unpaired" ));
|
|
151 |
prompt = QString( hbTrId( "txt_bt_dpopinfo_with_1" ) );
|
|
152 |
classOfDevice = parameters.value(QString::number( TBluetoothDeviceDialog::EDeviceClass ));
|
|
153 |
icon = getBadgedDeviceTypeIcon(classOfDevice.toInt());
|
|
154 |
mNotificationDialog->setIcon(icon);
|
|
155 |
break;
|
29
|
156 |
case EVisibilityTimeout:
|
42
|
157 |
title = QString(hbTrId( "txt_bt_dpophead_bluetooth" ));
|
|
158 |
prompt = QString( hbTrId( "txt_bt_dpopinfo_is_now_hidden" ) );
|
|
159 |
mNotificationDialog->setIcon(HbIcon("qtg_large_bluetooth"));
|
29
|
160 |
break;
|
|
161 |
default:
|
|
162 |
mLastError = ParameterError;
|
|
163 |
break;
|
|
164 |
}
|
|
165 |
int repls = prompt.count( QString( "%" ) );
|
|
166 |
if ( repls > 0 ) {
|
|
167 |
QVariant name = parameters.value( QString::number( TBluetoothDeviceDialog::EDeviceName ) );
|
|
168 |
prompt = prompt.arg( name.toString() );
|
|
169 |
}
|
42
|
170 |
mNotificationDialog->setTitle( title );
|
|
171 |
mNotificationDialog->setText( prompt );
|
29
|
172 |
TRACE_EXIT
|
|
173 |
}
|
|
174 |
|
|
175 |
/*!
|
|
176 |
Reset properties to default values
|
|
177 |
*/
|
|
178 |
void BtDeviceDialogNotifWidget::resetProperties()
|
|
179 |
{
|
|
180 |
TRACE_ENTRY
|
|
181 |
mSendAction = true;
|
|
182 |
TRACE_EXIT
|
|
183 |
return;
|
|
184 |
}
|
|
185 |
|
42
|
186 |
void BtDeviceDialogNotifWidget::NotifClosed(HbAction *action)
|
29
|
187 |
{
|
42
|
188 |
Q_UNUSED(action);
|
29
|
189 |
emit deviceDialogClosed();
|
42
|
190 |
mSendAction = false;
|
29
|
191 |
}
|
|
192 |
|