29
|
1 |
/*
|
31
|
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".
|
29
|
8 |
*
|
31
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
29
|
11 |
*
|
31
|
12 |
* Contributors:
|
29
|
13 |
*
|
31
|
14 |
* Description: Description: Class for managing an actual user notification or query.
|
|
15 |
* It hides UI framework-specifics in a private class.
|
|
16 |
*
|
29
|
17 |
*/
|
|
18 |
|
|
19 |
#include "bluetoothnotification.h"
|
|
20 |
#include <hb/hbcore/hbsymbianvariant.h>
|
|
21 |
#include "btnotificationmanager.h"
|
|
22 |
#include "btnotifserver.h"
|
|
23 |
#include "bluetoothtrace.h"
|
|
24 |
#include <utf.h> // for debugging
|
|
25 |
|
|
26 |
/** Identifier of Bluetooth device dialog plug-in. */
|
|
27 |
_LIT( KBTDevDialogId, "com.nokia.hb.btdevicedialog/1.0" );
|
|
28 |
/** Key name of result. */
|
|
29 |
_LIT( KBTDevDialogResult, "result" );
|
|
30 |
_LIT( KBTDevDialogInput, "input" );
|
|
31 |
|
57
|
32 |
enum TDialogState
|
|
33 |
{
|
|
34 |
EWaitingForClosing,
|
|
35 |
};
|
|
36 |
|
29
|
37 |
// ======== MEMBER FUNCTIONS ========
|
|
38 |
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
// C++ default constructor
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
//
|
|
43 |
CBluetoothNotification::CBluetoothNotification( CBTNotificationManager* aManager )
|
|
44 |
: iManager( aManager )
|
|
45 |
{
|
57
|
46 |
iActive = NULL;
|
29
|
47 |
}
|
|
48 |
|
|
49 |
|
|
50 |
// ---------------------------------------------------------------------------
|
|
51 |
// Symbian 2nd-phase constructor
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
void CBluetoothNotification::ConstructL()
|
|
55 |
{
|
|
56 |
iNotificationData = CHbSymbianVariantMap::NewL();
|
|
57 |
iDialog = CHbDeviceDialogSymbian::NewL();
|
|
58 |
}
|
|
59 |
|
|
60 |
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
// NewL.
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
//
|
|
65 |
CBluetoothNotification* CBluetoothNotification::NewL(
|
|
66 |
CBTNotificationManager* aManager )
|
|
67 |
{
|
|
68 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
|
69 |
CBluetoothNotification* self = new( ELeave ) CBluetoothNotification( aManager );
|
|
70 |
CleanupStack::PushL( self );
|
|
71 |
self->ConstructL();
|
|
72 |
CleanupStack::Pop( self );
|
|
73 |
BOstraceFunctionExit0( DUMMY_DEVLIST );
|
|
74 |
return self;
|
|
75 |
}
|
|
76 |
|
|
77 |
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
// Destructor
|
|
80 |
// ---------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
CBluetoothNotification::~CBluetoothNotification()
|
|
83 |
{
|
|
84 |
BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
|
57
|
85 |
if(iActive)
|
|
86 |
{
|
|
87 |
if(iActive->IsActive())
|
|
88 |
{
|
|
89 |
iActive->Cancel();
|
|
90 |
}
|
|
91 |
delete iActive;
|
|
92 |
}
|
|
93 |
iClosingTimer.Close();
|
29
|
94 |
delete iDialog;
|
|
95 |
delete iNotificationData;
|
|
96 |
delete iReturnData;
|
|
97 |
BOstraceFunctionExit1( DUMMY_DEVLIST, this )
|
|
98 |
}
|
|
99 |
|
57
|
100 |
|
|
101 |
// ---------------------------------------------------------------------------
|
|
102 |
// Creates new notification data.
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
//
|
|
105 |
CHbSymbianVariantMap* CBluetoothNotification::CreateNotificationDataL()
|
|
106 |
{
|
|
107 |
if(iNotificationData!=NULL)
|
|
108 |
{
|
|
109 |
delete iNotificationData;
|
|
110 |
iNotificationData = NULL;
|
|
111 |
}
|
|
112 |
iNotificationData = CHbSymbianVariantMap::NewL();
|
|
113 |
return iNotificationData;
|
|
114 |
}
|
|
115 |
|
|
116 |
|
29
|
117 |
// ---------------------------------------------------------------------------
|
|
118 |
// Sets the data to be shown to the user.
|
|
119 |
// ---------------------------------------------------------------------------
|
|
120 |
//
|
|
121 |
TInt CBluetoothNotification::SetData( TInt aDataType, const TDesC& aData )
|
|
122 |
{
|
|
123 |
TRAPD( err, SetDataL( aDataType, aData ) );
|
|
124 |
return (int) err;
|
|
125 |
}
|
|
126 |
|
|
127 |
|
|
128 |
// ---------------------------------------------------------------------------
|
|
129 |
// Sets the data to be shown to the user.
|
|
130 |
// ---------------------------------------------------------------------------
|
|
131 |
//
|
|
132 |
TInt CBluetoothNotification::SetData( TInt aDataType, TInt aData )
|
|
133 |
{
|
|
134 |
TRAPD( err, SetDataL( aDataType, aData ) );
|
|
135 |
return (int) err;
|
|
136 |
}
|
|
137 |
|
|
138 |
// ---------------------------------------------------------------------------
|
|
139 |
// Updates the data to be shown to the user.
|
|
140 |
// ---------------------------------------------------------------------------
|
|
141 |
//
|
|
142 |
TInt CBluetoothNotification::Update( const TDesC& aData )
|
|
143 |
{
|
|
144 |
BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
|
57
|
145 |
TRAPD(ret,UpdateDataL( TBluetoothDeviceDialog::EDeviceName, aData ));
|
|
146 |
if(!ret)
|
|
147 |
{
|
|
148 |
int ret = iDialog->Update( *iNotificationData );
|
|
149 |
}
|
29
|
150 |
BOstraceFunctionExit1( DUMMY_DEVLIST, this );
|
|
151 |
return ret;
|
|
152 |
}
|
|
153 |
|
57
|
154 |
// ---------------------------------------------------------------------------
|
|
155 |
// Updates the data to be shown to the user.
|
|
156 |
// ---------------------------------------------------------------------------
|
|
157 |
//
|
|
158 |
TInt CBluetoothNotification::Update( TInt aData )
|
|
159 |
{
|
|
160 |
BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
|
|
161 |
TRAPD(ret,UpdateDataL( TBluetoothDeviceDialog::EAdditionalInt, aData ));
|
|
162 |
if(!ret)
|
|
163 |
{
|
|
164 |
ret = iDialog->Update( *iNotificationData );
|
|
165 |
}
|
|
166 |
BOstraceFunctionExit1( DUMMY_DEVLIST, this );
|
|
167 |
return ret;
|
|
168 |
}
|
29
|
169 |
|
|
170 |
// ---------------------------------------------------------------------------
|
|
171 |
// Show the notification, which means that it is added to the queue.
|
|
172 |
// ---------------------------------------------------------------------------
|
|
173 |
//
|
31
|
174 |
void CBluetoothNotification::ShowL()
|
29
|
175 |
{
|
|
176 |
BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
|
31
|
177 |
SetDataL( TBluetoothDialogParams::EDialogType, iType );
|
|
178 |
SetDataL( TBluetoothDialogParams::EResource, iResourceId );
|
29
|
179 |
delete iReturnData;
|
|
180 |
iReturnData = NULL;
|
31
|
181 |
iReturnData = CHbSymbianVariantMap::NewL();
|
|
182 |
iDialog->Show( KBTDevDialogId(), *iNotificationData, this );
|
|
183 |
BOstraceFunctionExit1( DUMMY_DEVLIST, this );
|
29
|
184 |
}
|
|
185 |
|
|
186 |
// ---------------------------------------------------------------------------
|
|
187 |
// Stop showing the notification.
|
|
188 |
// ---------------------------------------------------------------------------
|
|
189 |
//
|
|
190 |
TInt CBluetoothNotification::Close()
|
|
191 |
{
|
|
192 |
BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
|
|
193 |
iDialog->Cancel();
|
|
194 |
iManager->ReleaseNotification( this );
|
42
|
195 |
BOstraceFunctionExit0( DUMMY_DEVLIST );
|
29
|
196 |
return KErrNone;
|
|
197 |
}
|
|
198 |
|
|
199 |
|
|
200 |
// ---------------------------------------------------------------------------
|
|
201 |
// Sets the data to be shown to the user.
|
|
202 |
// ---------------------------------------------------------------------------
|
|
203 |
//
|
|
204 |
void CBluetoothNotification::SetDataL( TInt aType, const TDesC& aData )
|
|
205 |
{
|
|
206 |
BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
|
|
207 |
TBuf16<6> key;
|
|
208 |
CHbSymbianVariant* value = NULL;
|
|
209 |
switch( aType )
|
|
210 |
{
|
|
211 |
case TBluetoothDialogParams::EAddress:
|
|
212 |
case TBluetoothDeviceDialog::EDeviceName:
|
|
213 |
case TBluetoothDeviceDialog::EAdditionalDesc:
|
|
214 |
case TBluetoothDialogParams::EDialogTitle:
|
|
215 |
key.Num(aType);
|
|
216 |
value = CHbSymbianVariant::NewL( (TAny*) &aData, CHbSymbianVariant::EDes );
|
|
217 |
BtTraceBlock(
|
|
218 |
TBuf<32> buf;
|
|
219 |
switch (aType) {
|
|
220 |
case TBluetoothDialogParams::EAddress:
|
|
221 |
_LIT(KAddress,"EAddress");
|
|
222 |
buf.Append(KAddress);
|
|
223 |
break;
|
|
224 |
case TBluetoothDeviceDialog::EDeviceName:
|
|
225 |
_LIT(KDeviceName,"EDeviceName");
|
|
226 |
buf.Append(KDeviceName);
|
|
227 |
break;
|
|
228 |
case TBluetoothDeviceDialog::EAdditionalDesc:
|
|
229 |
_LIT(KAdditionalDesc,"EAdditionalDesc");
|
|
230 |
buf.Append(KAdditionalDesc);
|
|
231 |
break;
|
|
232 |
}
|
|
233 |
TPtrC p(buf);
|
|
234 |
TPtrC16 *ptr = (TPtrC16 *)value->Data();
|
|
235 |
BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%S]", &p, ptr);
|
|
236 |
);
|
42
|
237 |
User::LeaveIfError(iNotificationData->Add( key, value )); // Takes ownership of value
|
29
|
238 |
break;
|
|
239 |
case TBluetoothDialogParams::EResource:
|
|
240 |
case TBluetoothDeviceDialog::EDeviceClass:
|
|
241 |
case TBluetoothDeviceDialog::EAdditionalInt:
|
|
242 |
PanicServer( EBTNotifPanicBadArgument );
|
|
243 |
break;
|
|
244 |
case TBluetoothDialogParams::ENoParams:
|
|
245 |
case TBluetoothDeviceDialog::ENoParams:
|
|
246 |
default:
|
|
247 |
break;
|
|
248 |
}
|
|
249 |
BOstraceFunctionExit1( DUMMY_DEVLIST, this );
|
|
250 |
}
|
|
251 |
|
57
|
252 |
// ---------------------------------------------------------------------------
|
|
253 |
// Sets the data to be shown to the user.
|
|
254 |
// ---------------------------------------------------------------------------
|
|
255 |
//
|
|
256 |
void CBluetoothNotification::SetDataL( TInt aType, TInt aData )
|
|
257 |
{
|
|
258 |
BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
|
|
259 |
TBuf<6> key;
|
|
260 |
CHbSymbianVariant* value = NULL;
|
|
261 |
switch( aType )
|
|
262 |
{
|
|
263 |
case TBluetoothDialogParams::EDialogType:
|
|
264 |
case TBluetoothDialogParams::EResource:
|
|
265 |
case TBluetoothDialogParams::EDialogTitle:
|
|
266 |
case TBluetoothDeviceDialog::EDeviceClass:
|
|
267 |
case TBluetoothDeviceDialog::EAdditionalInt:
|
|
268 |
key.Num(aType);
|
|
269 |
value = CHbSymbianVariant::NewL( (TAny*) &aData, CHbSymbianVariant::EInt );
|
|
270 |
BtTraceBlock(
|
|
271 |
TBuf<32> buf;
|
|
272 |
switch (aType) {
|
|
273 |
case TBluetoothDialogParams::EDialogType:
|
|
274 |
buf = _L("EDialogType");
|
|
275 |
break;
|
|
276 |
case TBluetoothDialogParams::EResource:
|
|
277 |
buf = _L("EResource");
|
|
278 |
break;
|
|
279 |
case TBluetoothDeviceDialog::EDeviceClass:
|
|
280 |
buf = _L("EDeviceClass");
|
|
281 |
break;
|
|
282 |
case TBluetoothDeviceDialog::EAdditionalInt:
|
|
283 |
buf = _L("EAdditionalInt");
|
|
284 |
break;
|
|
285 |
}
|
|
286 |
TPtrC p(buf);
|
|
287 |
TInt *intPtr = (TInt *)value->Data();
|
|
288 |
BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%d]", &p, *intPtr);
|
|
289 |
);
|
|
290 |
User::LeaveIfError(iNotificationData->Add( key, value )); // Takes ownership of value
|
|
291 |
break;
|
|
292 |
case TBluetoothDialogParams::EAddress:
|
|
293 |
case TBluetoothDeviceDialog::EDeviceName:
|
|
294 |
PanicServer( EBTNotifPanicBadArgument );
|
|
295 |
break;
|
|
296 |
case TBluetoothDialogParams::ENoParams:
|
|
297 |
case TBluetoothDeviceDialog::ENoParams:
|
|
298 |
default:
|
|
299 |
break;
|
|
300 |
}
|
|
301 |
BOstraceFunctionExit1( DUMMY_DEVLIST, this );
|
|
302 |
}
|
29
|
303 |
|
|
304 |
// ---------------------------------------------------------------------------
|
|
305 |
// Sets the data to be shown to the user.
|
|
306 |
// ---------------------------------------------------------------------------
|
|
307 |
//
|
57
|
308 |
void CBluetoothNotification::UpdateDataL( TInt aType, const TDesC& aData )
|
|
309 |
{
|
|
310 |
BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
|
|
311 |
TBuf16<6> key;
|
|
312 |
CHbSymbianVariant* value = NULL;
|
|
313 |
switch( aType )
|
|
314 |
{
|
|
315 |
case TBluetoothDialogParams::EAddress:
|
|
316 |
case TBluetoothDeviceDialog::EDeviceName:
|
|
317 |
case TBluetoothDeviceDialog::EAdditionalDesc:
|
|
318 |
case TBluetoothDialogParams::EDialogTitle:
|
|
319 |
key.Num(aType);
|
|
320 |
value = CHbSymbianVariant::NewL( (TAny*) &aData, CHbSymbianVariant::EDes );
|
|
321 |
BtTraceBlock(
|
|
322 |
TBuf<32> buf;
|
|
323 |
switch (aType) {
|
|
324 |
case TBluetoothDialogParams::EAddress:
|
|
325 |
_LIT(KAddress,"EAddress");
|
|
326 |
buf.Append(KAddress);
|
|
327 |
break;
|
|
328 |
case TBluetoothDeviceDialog::EDeviceName:
|
|
329 |
_LIT(KDeviceName,"EDeviceName");
|
|
330 |
buf.Append(KDeviceName);
|
|
331 |
break;
|
|
332 |
case TBluetoothDeviceDialog::EAdditionalDesc:
|
|
333 |
_LIT(KAdditionalDesc,"EAdditionalDesc");
|
|
334 |
buf.Append(KAdditionalDesc);
|
|
335 |
break;
|
|
336 |
}
|
|
337 |
TPtrC p(buf);
|
|
338 |
TPtrC16 *ptr = (TPtrC16 *)value->Data();
|
|
339 |
BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%S]", &p, ptr);
|
|
340 |
);
|
|
341 |
User::LeaveIfError(iNotificationData->Delete( key));
|
|
342 |
User::LeaveIfError(iNotificationData->Add( key, value )); // Takes ownership of value
|
|
343 |
break;
|
|
344 |
case TBluetoothDialogParams::EResource:
|
|
345 |
case TBluetoothDeviceDialog::EDeviceClass:
|
|
346 |
case TBluetoothDeviceDialog::EAdditionalInt:
|
|
347 |
PanicServer( EBTNotifPanicBadArgument );
|
|
348 |
break;
|
|
349 |
case TBluetoothDialogParams::ENoParams:
|
|
350 |
case TBluetoothDeviceDialog::ENoParams:
|
|
351 |
default:
|
|
352 |
break;
|
|
353 |
}
|
|
354 |
BOstraceFunctionExit1( DUMMY_DEVLIST, this );
|
|
355 |
}
|
|
356 |
|
|
357 |
// ---------------------------------------------------------------------------
|
|
358 |
// Sets the data to be shown to the user.
|
|
359 |
// ---------------------------------------------------------------------------
|
|
360 |
//
|
|
361 |
void CBluetoothNotification::UpdateDataL( TInt aType, TInt aData )
|
29
|
362 |
{
|
|
363 |
BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
|
|
364 |
TBuf<6> key;
|
|
365 |
CHbSymbianVariant* value = NULL;
|
|
366 |
switch( aType )
|
|
367 |
{
|
|
368 |
case TBluetoothDialogParams::EDialogType:
|
|
369 |
case TBluetoothDialogParams::EResource:
|
|
370 |
case TBluetoothDialogParams::EDialogTitle:
|
|
371 |
case TBluetoothDeviceDialog::EDeviceClass:
|
|
372 |
case TBluetoothDeviceDialog::EAdditionalInt:
|
|
373 |
key.Num(aType);
|
|
374 |
value = CHbSymbianVariant::NewL( (TAny*) &aData, CHbSymbianVariant::EInt );
|
|
375 |
BtTraceBlock(
|
|
376 |
TBuf<32> buf;
|
|
377 |
switch (aType) {
|
|
378 |
case TBluetoothDialogParams::EDialogType:
|
|
379 |
buf = _L("EDialogType");
|
|
380 |
break;
|
|
381 |
case TBluetoothDialogParams::EResource:
|
|
382 |
buf = _L("EResource");
|
|
383 |
break;
|
|
384 |
case TBluetoothDeviceDialog::EDeviceClass:
|
|
385 |
buf = _L("EDeviceClass");
|
|
386 |
break;
|
|
387 |
case TBluetoothDeviceDialog::EAdditionalInt:
|
|
388 |
buf = _L("EAdditionalInt");
|
|
389 |
break;
|
|
390 |
}
|
|
391 |
TPtrC p(buf);
|
|
392 |
TInt *intPtr = (TInt *)value->Data();
|
|
393 |
BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%d]", &p, *intPtr);
|
|
394 |
);
|
57
|
395 |
User::LeaveIfError(iNotificationData->Delete(key));
|
42
|
396 |
User::LeaveIfError(iNotificationData->Add( key, value )); // Takes ownership of value
|
29
|
397 |
break;
|
|
398 |
case TBluetoothDialogParams::EAddress:
|
|
399 |
case TBluetoothDeviceDialog::EDeviceName:
|
|
400 |
PanicServer( EBTNotifPanicBadArgument );
|
|
401 |
break;
|
|
402 |
case TBluetoothDialogParams::ENoParams:
|
|
403 |
case TBluetoothDeviceDialog::ENoParams:
|
|
404 |
default:
|
|
405 |
break;
|
|
406 |
}
|
|
407 |
BOstraceFunctionExit1( DUMMY_DEVLIST, this );
|
|
408 |
}
|
|
409 |
|
57
|
410 |
|
29
|
411 |
// ---------------------------------------------------------------------------
|
|
412 |
// From class MHbDeviceDialogObserver.
|
|
413 |
// Callback called when data is received from a device dialog.
|
|
414 |
// ---------------------------------------------------------------------------
|
|
415 |
//
|
|
416 |
void CBluetoothNotification::DataReceived( CHbSymbianVariantMap& aData )
|
|
417 |
{
|
|
418 |
BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
|
|
419 |
BtTraceBlock( debugHbSymbianVariantMap(aData); );
|
31
|
420 |
CHbSymbianVariant* value = NULL;
|
29
|
421 |
for( TInt i = 0; i < aData.Keys().MdcaCount(); i++ )
|
|
422 |
{
|
|
423 |
TPtrC key( aData.Keys().MdcaPoint( i ).Ptr(), aData.Keys().MdcaPoint( i ).Length() );
|
|
424 |
const CHbSymbianVariant* valueRef = aData.Get( key );
|
31
|
425 |
value = NULL;
|
|
426 |
TRAP_IGNORE( value =
|
|
427 |
CHbSymbianVariant::NewL( valueRef->Data(), valueRef->Type() ) );
|
|
428 |
if ( value )
|
|
429 |
{
|
|
430 |
TInt err = iReturnData->Add( key, value );
|
|
431 |
if ( err )
|
|
432 |
{
|
|
433 |
// todo: better exception handing than ignoring this failure?
|
|
434 |
}
|
|
435 |
}
|
29
|
436 |
}
|
42
|
437 |
if( iObserver )
|
|
438 |
{
|
|
439 |
iObserver->MBRDataReceived( aData );
|
|
440 |
}
|
29
|
441 |
BOstraceFunctionExit1( DUMMY_DEVLIST, this );
|
|
442 |
}
|
|
443 |
|
|
444 |
#ifdef BLUETOOTHTRACE_ENABLED
|
|
445 |
|
|
446 |
void CBluetoothNotification::debugHbSymbianVariantMap( CHbSymbianVariantMap& aData)
|
|
447 |
{
|
|
448 |
for( TInt i = 0; i < aData.Keys().MdcaCount(); i++ )
|
|
449 |
{
|
|
450 |
TBuf<128> buf;
|
|
451 |
TPtrC key( aData.Keys().MdcaPoint( i ).Ptr(), aData.Keys().MdcaPoint( i ).Length() );
|
|
452 |
buf = key;
|
|
453 |
buf.Append(_L(" = "));
|
|
454 |
const CHbSymbianVariant* value = aData.Get( key );
|
|
455 |
TBuf<16> nbr;
|
|
456 |
TBuf<32> newBuf;
|
|
457 |
switch (value->Type()) {
|
|
458 |
case CHbSymbianVariant::EInt :
|
|
459 |
buf.Append(_L("[EInt] "));
|
|
460 |
nbr.Num(*((TInt*)value->Data()));
|
|
461 |
buf.Append(nbr);
|
|
462 |
break;
|
|
463 |
case CHbSymbianVariant::EBool :
|
|
464 |
buf.Append(_L("[EBool] "));
|
|
465 |
buf.Append(*((TBool*)value->Data()) ? _L("True") : _L("False"));
|
|
466 |
break;
|
|
467 |
case CHbSymbianVariant::EUint :
|
|
468 |
buf.Append( _L("[EUint] "));
|
|
469 |
nbr.Num(*((TUint*)value->Data()));
|
|
470 |
buf.Append(nbr);
|
|
471 |
break;
|
|
472 |
case CHbSymbianVariant::EReal :
|
|
473 |
buf.Append(_L("[EReal] "));
|
|
474 |
nbr.Num(*((TReal*)value->Data()));
|
|
475 |
buf.Append(nbr);
|
|
476 |
break;
|
|
477 |
case CHbSymbianVariant::EDes : // TDesC
|
|
478 |
buf.Append(_L("[EDes] "));
|
|
479 |
buf.Append(*((TPtrC16 *)value->Data()));
|
|
480 |
break;
|
|
481 |
case CHbSymbianVariant::EBinary : // TDesC8
|
|
482 |
buf.Append(_L("[EBinary] "));
|
|
483 |
// the following function caused problems when converting this function to
|
|
484 |
// a trace function in bluetoothtrace.h
|
|
485 |
CnvUtfConverter::ConvertToUnicodeFromUtf8(newBuf,*((TPtrC8 *)value->Data()) );
|
|
486 |
buf.Append(newBuf);
|
|
487 |
break;
|
|
488 |
case CHbSymbianVariant::EChar : // a TChar
|
|
489 |
buf.Append(_L("[EChar] "));
|
|
490 |
buf.Append(*((TChar *)value->Data()));
|
|
491 |
break;
|
|
492 |
case CHbSymbianVariant::ERect : // a TRect
|
|
493 |
case CHbSymbianVariant::EPoint : // a TPoint
|
|
494 |
case CHbSymbianVariant::ESize : // a TSize
|
|
495 |
case CHbSymbianVariant::EDesArray : // a MDesCArray
|
|
496 |
break;
|
|
497 |
default:
|
|
498 |
break;
|
|
499 |
}
|
|
500 |
TPtrC p(buf);
|
|
501 |
BOstraceExt1( TRACE_DEBUG, DUMMY_DEVLIST, "HbSymbianVariantMap [%S]", &p);
|
|
502 |
}
|
|
503 |
}
|
|
504 |
#endif // BLUETOOTHTRACE_ENABLED
|
|
505 |
// ---------------------------------------------------------------------------
|
|
506 |
// From class MHbDeviceDialogObserver.
|
|
507 |
// Callback called when a device dialog is closed.
|
|
508 |
// ---------------------------------------------------------------------------
|
|
509 |
//
|
|
510 |
void CBluetoothNotification::DeviceDialogClosed( TInt aCompletionCode )
|
|
511 |
{
|
|
512 |
BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aCompletionCode );
|
|
513 |
TPckg<TBool> result( EFalse );
|
|
514 |
TPtrC8 resultPtr( result );
|
|
515 |
const CHbSymbianVariant* value = iReturnData->Get( KBTDevDialogResult );
|
|
516 |
if( value && value->IsValid() )
|
|
517 |
{
|
|
518 |
result() = *value->Value<TBool>();
|
|
519 |
}
|
|
520 |
RBuf8 resultBuf;
|
|
521 |
value = iReturnData->Get( KBTDevDialogInput );
|
|
522 |
if( value && value->IsValid() )
|
|
523 |
{
|
|
524 |
HBufC8* data = value->Value<HBufC8>();
|
|
525 |
if( !resultBuf.Create( data->Length() + result.Length() ) )
|
|
526 |
{
|
|
527 |
resultBuf = *data;
|
|
528 |
resultBuf.Insert( 0, result );
|
|
529 |
resultPtr.Set( resultBuf );
|
|
530 |
}
|
|
531 |
}
|
|
532 |
if( iObserver )
|
|
533 |
{
|
|
534 |
if( aCompletionCode == CHbDeviceDialogSymbian::ECancelledError )
|
|
535 |
{
|
|
536 |
aCompletionCode = KErrCancel;
|
|
537 |
}
|
|
538 |
iObserver->MBRNotificationClosed( aCompletionCode, resultPtr );
|
|
539 |
}
|
31
|
540 |
resultBuf.Close();
|
29
|
541 |
iManager->ReleaseNotification( this );
|
|
542 |
// Note that we might get deleted after releasing ourselves.
|
42
|
543 |
BOstraceFunctionExit0( DUMMY_DEVLIST );
|
29
|
544 |
}
|
|
545 |
|
57
|
546 |
// ---------------------------------------------------------------------------
|
|
547 |
// Activate a timer which will automatically close the dialog when expired.
|
|
548 |
// ---------------------------------------------------------------------------
|
|
549 |
//
|
|
550 |
void CBluetoothNotification::SetCloseTimer(TInt aAfter)
|
|
551 |
{
|
|
552 |
BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aAfter );
|
|
553 |
TRAP_IGNORE(iActive = CBtSimpleActive::NewL(*this, EWaitingForClosing ));
|
|
554 |
User::LeaveIfError( iClosingTimer.CreateLocal() );
|
|
555 |
iClosingTimer.After(iActive->iStatus, aAfter);
|
|
556 |
iActive->GoActive();
|
|
557 |
}
|
|
558 |
|
|
559 |
// ---------------------------------------------------------------------------
|
|
560 |
// From MBtSimpleActiveObserver
|
|
561 |
// ---------------------------------------------------------------------------
|
|
562 |
//
|
|
563 |
void CBluetoothNotification::RequestCompletedL( CBtSimpleActive* aActive, TInt aStatus )
|
|
564 |
{
|
|
565 |
(void)aActive;
|
|
566 |
(void)aStatus;
|
|
567 |
Close();
|
|
568 |
}
|
|
569 |
|
|
570 |
// ---------------------------------------------------------------------------
|
|
571 |
// From MBtSimpleActiveObserver
|
|
572 |
// ---------------------------------------------------------------------------
|
|
573 |
//
|
|
574 |
void CBluetoothNotification::CancelRequest( TInt aRequestId )
|
|
575 |
{
|
|
576 |
(void)aRequestId;
|
|
577 |
// ignore
|
|
578 |
}
|
|
579 |
|
|
580 |
// ---------------------------------------------------------------------------
|
|
581 |
// From MBtSimpleActiveObserver
|
|
582 |
// ---------------------------------------------------------------------------
|
|
583 |
//
|
|
584 |
void CBluetoothNotification::HandleError( CBtSimpleActive* aActive, TInt aError )
|
|
585 |
{
|
|
586 |
(void)aActive;
|
|
587 |
(void)aError;
|
|
588 |
// ignore
|
|
589 |
}
|