1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
20 #include "btdevicedialogplugintrace.h" |
20 #include "btdevicedialogplugintrace.h" |
21 #include <bluetoothdevicedialogs.h> |
21 #include <bluetoothdevicedialogs.h> |
22 #include <hbaction.h> |
22 #include <hbaction.h> |
23 #include <hbdialog.h> |
23 #include <hbdialog.h> |
24 #include <hblabel.h> |
24 #include <hblabel.h> |
|
25 #include <hbparameterlengthlimiter.h> |
25 #include "btdevicedialogpluginerrors.h" |
26 #include "btdevicedialogpluginerrors.h" |
26 #include <Bluetooth\hci\hcitypes.h> |
27 #include <Bluetooth\hci\hcitypes.h> |
27 |
28 |
28 const int MaxPasskeyLength = 6; |
29 const int MaxPasskeyLength = 6; |
29 |
30 |
161 Take parameter values and generate relevant property of this widget |
162 Take parameter values and generate relevant property of this widget |
162 */ |
163 */ |
163 void BtDeviceDialogQueryWidget::processParam(const QVariantMap ¶meters) |
164 void BtDeviceDialogQueryWidget::processParam(const QVariantMap ¶meters) |
164 { |
165 { |
165 TRACE_ENTRY |
166 TRACE_ENTRY |
166 QString keyStr, prompt,title; |
167 QString keyStr, prompt,title,devName; |
167 int status = -1; |
168 int status = -1; |
168 QVariant name,param,addval,passkeyinputstatus; |
169 QVariant param,addval,passkeyinputstatus; |
169 keyStr.setNum( TBluetoothDialogParams::EResource ); |
170 keyStr.setNum( TBluetoothDialogParams::EResource ); |
170 // Validate if the resource item exists. |
171 // Validate if the resource item exists. |
171 QVariantMap::const_iterator i = parameters.constFind( keyStr ); |
172 QVariantMap::const_iterator i = parameters.constFind( keyStr ); |
172 // item of ResourceId is not found, can't continue. |
173 // item of ResourceId is not found, can't continue. |
173 if ( i == parameters.constEnd() ) { |
174 if ( i == parameters.constEnd() ) { |
178 // a passkey entry completed event from the remote side |
179 // a passkey entry completed event from the remote side |
179 mSendPasskeyEntryCompletedAction = false; |
180 mSendPasskeyEntryCompletedAction = false; |
180 |
181 |
181 param = parameters.value( keyStr ); |
182 param = parameters.value( keyStr ); |
182 int key = param.toInt(); |
183 int key = param.toInt(); |
|
184 |
|
185 keyStr.setNum( TBluetoothDeviceDialog::EDeviceName ); |
|
186 i = parameters.constFind( keyStr ); |
|
187 if ( i != parameters.constEnd() ) |
|
188 { |
|
189 devName = QString(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString()); |
|
190 } |
|
191 |
183 switch ( key ) { |
192 switch ( key ) { |
184 case ENumericComparison: |
193 case ENumericComparison: |
185 prompt = QString( hbTrId( "txt_bt_info_does_this_code_match_the_code_on_1" ) ); |
194 prompt = HbParameterLengthLimiter(hbTrId("txt_bt_info_does_this_code_match_the_code_on_1" )).arg(devName); |
186 break; |
195 break; |
187 case EPasskeyDisplay: |
196 case EPasskeyDisplay: |
188 prompt = QString( hbTrId( "txt_bt_info_enter_the_following_code_to_the_1" ) ); |
197 prompt = HbParameterLengthLimiter(hbTrId("txt_bt_info_enter_the_following_code_to_the_1" )).arg(devName); |
189 break; |
198 break; |
190 case EPairingFailureRetry: |
199 case EPairingFailureRetry: |
191 prompt = QString( hbTrId( "txt_bt_info_pairing_with_1_failed_either_the_pas" ) ); |
200 prompt = HbParameterLengthLimiter(hbTrId("txt_bt_info_pairing_with_1_failed_either_the_pas" )).arg(devName); |
192 break; |
201 break; |
193 case EPairingFailureOk: |
202 case EPairingFailureOk: |
194 prompt = QString( hbTrId( "txt_bt_info_unable_to_pair_with_1" ) ); |
203 prompt = HbParameterLengthLimiter(hbTrId("txt_bt_info_unable_to_pair_with_1" )).arg(devName); |
195 break; |
204 break; |
196 // Input dialogs |
205 // Input dialogs |
197 case EPinInput: |
206 case EPinInput: |
198 case EObexPasskeyInput: |
207 case EObexPasskeyInput: |
199 // NULL parameters |
208 // NULL parameters |
201 case EUnusedResource: |
210 case EUnusedResource: |
202 default: |
211 default: |
203 mLastError = ParameterError; |
212 mLastError = ParameterError; |
204 break; |
213 break; |
205 } |
214 } |
206 int repls = prompt.count( QString( "%" ) ); |
215 if(key != EPairingFailureRetry && key != EPairingFailureOk) |
207 if ( repls > 0 ) { |
216 { |
208 name = parameters.value( QString::number( TBluetoothDeviceDialog::EDeviceName ) ); |
217 addval = parameters.value( QString::number( TBluetoothDeviceDialog::EAdditionalDesc ) ); |
209 prompt = prompt.arg( name.toString() ); |
218 // todo: Formating the prompt need to be discussed with UI designer |
210 if(key != EPairingFailureRetry && key != EPairingFailureOk) |
219 // The passcode could be displayed on a separate row if it the label did support |
211 { |
220 // the use of newline escape character. |
212 addval = parameters.value( QString::number( TBluetoothDeviceDialog::EAdditionalDesc ) ); |
221 prompt.append(tr("\n")); // insert 1 newlines for clarity |
213 // todo: Formating the prompt need to be discussed with UI designer |
222 prompt.append(addval.toString()); |
214 // The passcode could be displayed on a separate row if it the label did support |
223 if(key == EPasskeyDisplay) |
215 // the use of newline escape character. |
224 { |
216 prompt.append(tr("\n")); // insert 1 newlines for clarity |
225 prompt.append("\n"); |
217 prompt.append(addval.toString()); |
226 bool ret = false; |
218 if(key == EPasskeyDisplay) |
227 passkeyinputstatus = parameters.value( QString::number( TBluetoothDeviceDialog::EAdditionalInt )); |
|
228 status = passkeyinputstatus.toInt(&ret); |
|
229 if(ret) |
219 { |
230 { |
220 prompt.append("\n"); |
231 prompt.append(GetPasskeyEntryStatusString(status)); |
221 bool ret = false; |
|
222 passkeyinputstatus = parameters.value( QString::number( TBluetoothDeviceDialog::EAdditionalInt )); |
|
223 status = passkeyinputstatus.toInt(&ret); |
|
224 if(ret) |
|
225 { |
|
226 prompt.append(GetPasskeyEntryStatusString(status)); |
|
227 } |
|
228 } |
232 } |
229 } |
233 } |
230 } |
234 title = HbParameterLengthLimiter(hbTrId("txt_bt_title_pairing_with_1")).arg(devName); |
231 // set property value to this dialog widget |
|
232 if(key != EPairingFailureRetry && key != EPairingFailureOk) |
|
233 { |
|
234 title = QString(hbTrId("txt_bt_title_pairing_with_1")); |
|
235 title = title.arg(name.toString()); |
|
236 mMessageBox->setHeadingWidget(new HbLabel(title)); |
235 mMessageBox->setHeadingWidget(new HbLabel(title)); |
237 mMessageBox->setIconVisible(false); |
236 mMessageBox->setIconVisible(false); |
238 if(key == EPasskeyDisplay) |
237 if(key == EPasskeyDisplay) |
239 { |
238 { |
240 mMessageBox->setStandardButtons(HbMessageBox::Cancel); |
239 mMessageBox->setStandardButtons(HbMessageBox::Cancel); |