|
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: BtDeviceOkOnlyDialogWidget class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "btdeviceokonlydialogwidget.h" |
|
20 #include "btdevicedialogplugintrace.h" |
|
21 #include <bluetoothdevicedialogs.h> |
|
22 #include <hbaction.h> |
|
23 #include <hbdialog.h> |
|
24 #include <hblabel.h> |
|
25 #include "btdevicedialogpluginerrors.h" |
|
26 |
|
27 /*! |
|
28 class Constructor |
|
29 */ |
|
30 BtDeviceOkOnlyDialogWidget::BtDeviceOkOnlyDialogWidget( |
|
31 HbMessageBox::MessageBoxType type, const QVariantMap ¶meters) |
|
32 { |
|
33 TRACE_ENTRY |
|
34 // set properties |
|
35 mLastError = NoError; |
|
36 mShowEventReceived = false; |
|
37 mMessageBox = new HbMessageBox(type); |
|
38 resetProperties(); |
|
39 constructQueryDialog(parameters); |
|
40 TRACE_EXIT |
|
41 } |
|
42 |
|
43 /*! |
|
44 Set parameters, implementation of interface |
|
45 Invoked when HbDeviceDialog::update calls. |
|
46 */ |
|
47 bool BtDeviceOkOnlyDialogWidget::setDeviceDialogParameters( |
|
48 const QVariantMap ¶meters) |
|
49 { |
|
50 TRACE_ENTRY |
|
51 mLastError = NoError; |
|
52 processParam(parameters); |
|
53 TRACE_EXIT |
|
54 return true; |
|
55 } |
|
56 |
|
57 /*! |
|
58 Get error, implementation of interface |
|
59 */ |
|
60 int BtDeviceOkOnlyDialogWidget::deviceDialogError() const |
|
61 { |
|
62 TRACE_ENTRY |
|
63 TRACE_EXIT |
|
64 return mLastError; |
|
65 } |
|
66 |
|
67 /*! |
|
68 Close notification, implementation of interface |
|
69 */ |
|
70 void BtDeviceOkOnlyDialogWidget::closeDeviceDialog(bool byClient) |
|
71 { |
|
72 TRACE_ENTRY |
|
73 Q_UNUSED(byClient); |
|
74 // Closed by client or internally by server -> no action to be transmitted. |
|
75 mMessageBox->close(); |
|
76 // If show event has been received, close is signalled from hide event. If not, |
|
77 // hide event does not come and close is signalled from here. |
|
78 if (!mShowEventReceived) { |
|
79 emit deviceDialogClosed(); |
|
80 } |
|
81 TRACE_EXIT |
|
82 } |
|
83 |
|
84 /*! |
|
85 Return display widget, implementation of interface |
|
86 */ |
|
87 HbDialog *BtDeviceOkOnlyDialogWidget::deviceDialogWidget() const |
|
88 { |
|
89 TRACE_ENTRY |
|
90 TRACE_EXIT |
|
91 return mMessageBox; |
|
92 } |
|
93 |
|
94 QObject *BtDeviceOkOnlyDialogWidget::signalSender() const |
|
95 { |
|
96 return const_cast<BtDeviceOkOnlyDialogWidget*>(this); |
|
97 } |
|
98 |
|
99 /*! |
|
100 Construct display widget |
|
101 */ |
|
102 bool BtDeviceOkOnlyDialogWidget::constructQueryDialog(const QVariantMap ¶meters) |
|
103 { |
|
104 TRACE_ENTRY |
|
105 // analyze the parameters to compose the properties of the message box widget |
|
106 processParam(parameters); |
|
107 |
|
108 connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*))); |
|
109 |
|
110 TRACE_EXIT |
|
111 return true; |
|
112 } |
|
113 |
|
114 |
|
115 /*! |
|
116 Take parameter values and generate relevant property of this widget |
|
117 */ |
|
118 void BtDeviceOkOnlyDialogWidget::processParam(const QVariantMap ¶meters) |
|
119 { |
|
120 TRACE_ENTRY |
|
121 QString keyStr, prompt; |
|
122 QVariant param; |
|
123 keyStr.setNum( TBluetoothDialogParams::EDialogType ); |
|
124 // Validate if the resource item exists. |
|
125 QVariantMap::const_iterator i = parameters.constFind( keyStr ); |
|
126 // item of ResourceId is not found, can't continue. |
|
127 if ( i == parameters.constEnd() ) { |
|
128 mLastError = UnknownDeviceDialogError; |
|
129 return; |
|
130 } |
|
131 |
|
132 param = parameters.value( keyStr ); |
|
133 int key = param.toInt(); |
|
134 switch ( key ) { |
|
135 case TBluetoothDialogParams::bt_053_d_unable_to_use_no_sim: |
|
136 // Todo : Update this string ID when we have it |
|
137 prompt = QString( hbTrId( "txt_bt_title_unable_to_enter_sim_access_profile" ) ); |
|
138 break; |
|
139 case TBluetoothDialogParams::bt_053_d_unable_to_use: |
|
140 prompt = QString( hbTrId( "txt_bt_title_unable_to_enter_sim_access_profile" ) ); |
|
141 break; |
|
142 default: |
|
143 mLastError = ParameterError; |
|
144 break; |
|
145 } |
|
146 mMessageBox->setStandardButtons( HbMessageBox::Ok); |
|
147 mMessageBox->setText( prompt ); |
|
148 TRACE_EXIT |
|
149 } |
|
150 |
|
151 /*! |
|
152 Reset properties to default values |
|
153 */ |
|
154 void BtDeviceOkOnlyDialogWidget::resetProperties() |
|
155 { |
|
156 TRACE_ENTRY |
|
157 // set to default values |
|
158 mMessageBox->setModal(true); |
|
159 mMessageBox->setTimeout(HbDialog::StandardTimeout); |
|
160 mMessageBox->setDismissPolicy(HbDialog::NoDismiss); |
|
161 TRACE_EXIT |
|
162 return; |
|
163 } |
|
164 |
|
165 |
|
166 void BtDeviceOkOnlyDialogWidget::messageBoxClosed(HbAction* action) |
|
167 { |
|
168 TRACE_ENTRY |
|
169 Q_UNUSED(action); |
|
170 QVariantMap data; |
|
171 data.insert( QString( "result" ), QVariant(true)); |
|
172 emit deviceDialogData(data); |
|
173 emit deviceDialogClosed(); |
|
174 TRACE_EXIT |
|
175 } |