29
|
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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <btextnotifiers.h>
|
|
20 |
#include <btservices/advancedevdiscoverer.h>
|
|
21 |
#include <btservices/btdevextension.h>
|
|
22 |
#include <hb/hbcore/hbdevicedialogsymbian.h>
|
|
23 |
#include "btnotifdeviceselector.h"
|
|
24 |
|
|
25 |
#include "btnotifserver.h"
|
|
26 |
#include "btnotificationmanager.h"
|
|
27 |
#include "btnotifclientserver.h"
|
57
|
28 |
|
42
|
29 |
// Key description length
|
|
30 |
const TInt KMaxKeyDesCLength = 20;
|
57
|
31 |
const TInt KLastUsedDevices = 5;
|
29
|
32 |
|
|
33 |
// ======== MEMBER FUNCTIONS ========
|
|
34 |
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
// C++ default constructor
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
CBTNotifDeviceSelector::CBTNotifDeviceSelector( CBTNotifServer& aServer )
|
|
40 |
: iServer( aServer )
|
|
41 |
{
|
|
42 |
}
|
|
43 |
|
|
44 |
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
// Symbian 2nd-phase constructor
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
void CBTNotifDeviceSelector::ConstructL()
|
|
50 |
{
|
31
|
51 |
iServer.DevRepository().AddObserverL(this);
|
29
|
52 |
iDiscoverer = CAdvanceDevDiscoverer::NewL( iServer.DevRepository(), *this );
|
|
53 |
}
|
|
54 |
|
|
55 |
// ---------------------------------------------------------------------------
|
|
56 |
// NewL.
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
CBTNotifDeviceSelector* CBTNotifDeviceSelector::NewL( CBTNotifServer& aServer )
|
|
60 |
{
|
|
61 |
CBTNotifDeviceSelector* self = new( ELeave ) CBTNotifDeviceSelector( aServer );
|
|
62 |
CleanupStack::PushL( self );
|
|
63 |
self->ConstructL();
|
|
64 |
CleanupStack::Pop( self );
|
|
65 |
return self;
|
|
66 |
}
|
|
67 |
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
// Destructor
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
CBTNotifDeviceSelector::~CBTNotifDeviceSelector()
|
|
73 |
{
|
31
|
74 |
iServer.DevRepository().RemoveObserver(this);
|
29
|
75 |
if( iNotification )
|
|
76 |
{
|
|
77 |
// Clear the notification callback, we cannot receive them anymore.
|
|
78 |
iNotification->RemoveObserver();
|
|
79 |
iNotification->Close(); // Also dequeues the notification from the queue.
|
|
80 |
iNotification = NULL;
|
|
81 |
}
|
|
82 |
iDevices.ResetAndDestroy();
|
|
83 |
iDevices.Close();
|
|
84 |
delete iDiscoverer;
|
|
85 |
}
|
|
86 |
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
// Process a client message related to notifiers.
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
void CBTNotifDeviceSelector::DispatchNotifierMessageL( const RMessage2& aMessage )
|
|
92 |
{
|
|
93 |
BOstraceFunctionEntryExt ( DUMMY_LIST, this, aMessage.Function() );
|
|
94 |
TInt opcode = aMessage.Function();
|
|
95 |
TInt uid = aMessage.Int0();
|
|
96 |
switch ( opcode )
|
|
97 |
{
|
|
98 |
case EBTNotifCancelNotifier:
|
|
99 |
{
|
|
100 |
// We only accept a cancel message from the same session as the original
|
|
101 |
// request (this is enforced by the RNotifier backend).
|
|
102 |
TInt err( KErrNotFound );
|
|
103 |
if ( !iMessage.IsNull() && opcode == iMessage.Function() &&
|
|
104 |
aMessage.Session() == iMessage.Session() )
|
|
105 |
{
|
|
106 |
iMessage.Complete( KErrCancel );
|
|
107 |
err = KErrNone;
|
|
108 |
}
|
|
109 |
aMessage.Complete( err );
|
|
110 |
break;
|
|
111 |
}
|
|
112 |
case EBTNotifUpdateNotifier:
|
|
113 |
{
|
|
114 |
// not handling so far
|
|
115 |
break;
|
|
116 |
}
|
|
117 |
case EBTNotifStartSyncNotifier:
|
|
118 |
{
|
|
119 |
// synch version of device searching is not supported:
|
|
120 |
aMessage.Complete( KErrNotSupported );
|
|
121 |
break;
|
|
122 |
}
|
|
123 |
case EBTNotifStartAsyncNotifier:
|
|
124 |
{
|
|
125 |
if ( !iMessage.IsNull() )
|
|
126 |
{
|
|
127 |
aMessage.Complete( KErrServerBusy );
|
|
128 |
return;
|
|
129 |
}
|
31
|
130 |
|
|
131 |
iLoadDevices = EFalse;
|
|
132 |
if(iServer.DevRepository().IsInitialized())
|
|
133 |
{
|
|
134 |
iLoadDevices = ETrue;
|
57
|
135 |
iDevices.ResetAndDestroy();
|
31
|
136 |
if(iServer.DevRepository().AllDevices().Count()==0)
|
|
137 |
{
|
|
138 |
PrepareNotificationL(TBluetoothDialogParams::EDeviceSearch, ENoResource);
|
|
139 |
iDiscoverer->DiscoverDeviceL();
|
|
140 |
}
|
|
141 |
else
|
|
142 |
{
|
|
143 |
PrepareNotificationL(TBluetoothDialogParams::EMoreDevice, ENoResource);
|
|
144 |
LoadUsedDevicesL();
|
|
145 |
}
|
|
146 |
}
|
29
|
147 |
iMessage = aMessage;
|
|
148 |
break;
|
|
149 |
}
|
|
150 |
default:
|
|
151 |
{
|
|
152 |
aMessage.Complete( KErrNotSupported );
|
|
153 |
}
|
|
154 |
}
|
|
155 |
BOstraceFunctionExit1( DUMMY_DEVLIST, this );
|
|
156 |
}
|
|
157 |
|
|
158 |
|
|
159 |
// ---------------------------------------------------------------------------
|
|
160 |
// Cancels an outstanding client message related to notifiers.
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
void CBTNotifDeviceSelector::CancelNotifierMessageL( const RMessage2& aMessage )
|
|
164 |
{
|
|
165 |
(void) aMessage;
|
|
166 |
}
|
|
167 |
|
|
168 |
// ---------------------------------------------------------------------------
|
|
169 |
// From class MBTNotificationResult.
|
|
170 |
// Handle a result from a user query.
|
|
171 |
// ---------------------------------------------------------------------------
|
|
172 |
//
|
|
173 |
void CBTNotifDeviceSelector::MBRDataReceived( CHbSymbianVariantMap& aData )
|
|
174 |
{
|
|
175 |
TInt err = KErrCancel;
|
47
|
176 |
if(aData.Keys().MdcaPoint(aData.Keys().MdcaCount()-1).Compare(_L("selectedindex"))==KErrNone)
|
29
|
177 |
{
|
|
178 |
TInt val = *(static_cast<TInt*>(aData.Get(_L("selectedindex"))->Data()));
|
70
|
179 |
BOstrace1( TRACE_DEBUG, DUMMY_DEVLIST, _L("MBRDataReceived, val %d"), val );
|
29
|
180 |
|
|
181 |
if ( !iMessage.IsNull() )
|
|
182 |
{
|
|
183 |
TBTDeviceResponseParamsPckg devParams;
|
|
184 |
if ( val > -1 && val < iDevices.Count() )
|
|
185 |
{
|
47
|
186 |
TRAP(err,SendSelectedDeviceL(aData));
|
42
|
187 |
iNotification->RemoveObserver();
|
31
|
188 |
iNotification->Close(); // Also dequeues the notification from the queue.
|
|
189 |
iNotification = NULL;
|
29
|
190 |
}
|
|
191 |
iMessage.Complete( err );
|
|
192 |
}
|
|
193 |
iDiscoverer->CancelDiscovery();
|
|
194 |
}
|
|
195 |
else if(aData.Keys().MdcaPoint(0).Compare(_L("Stop"))==KErrNone)
|
|
196 |
{
|
|
197 |
iDiscoverer->CancelDiscovery();
|
|
198 |
}
|
|
199 |
else if(aData.Keys().MdcaPoint(0).Compare(_L("Retry"))==KErrNone)
|
|
200 |
{
|
|
201 |
iDiscoverer->CancelDiscovery();
|
|
202 |
iDevices.ResetAndDestroy();
|
31
|
203 |
TRAP_IGNORE( iDiscoverer->DiscoverDeviceL() );
|
|
204 |
|
|
205 |
}
|
|
206 |
else if(aData.Keys().MdcaPoint(0).Compare(_L("MoreDevices"))==KErrNone)
|
|
207 |
{
|
42
|
208 |
iNotification->RemoveObserver();
|
31
|
209 |
iNotification->Close(); // Also dequeues the notification from the queue.
|
|
210 |
iNotification = NULL;
|
|
211 |
iDevices.ResetAndDestroy();
|
|
212 |
TRAP_IGNORE( {
|
|
213 |
PrepareNotificationL(TBluetoothDialogParams::EDeviceSearch, ENoResource);
|
|
214 |
iDiscoverer->DiscoverDeviceL(); } );
|
29
|
215 |
}
|
|
216 |
}
|
|
217 |
|
|
218 |
|
|
219 |
// ---------------------------------------------------------------------------
|
|
220 |
// From class MBTNotificationResult.
|
|
221 |
// The notification is finished.
|
|
222 |
// ---------------------------------------------------------------------------
|
|
223 |
//
|
|
224 |
void CBTNotifDeviceSelector::MBRNotificationClosed( TInt aError, const TDesC8& aData )
|
|
225 |
{
|
|
226 |
(void) aError;
|
|
227 |
(void) aData;
|
|
228 |
iNotification->RemoveObserver();
|
|
229 |
iNotification = NULL;
|
|
230 |
}
|
|
231 |
|
|
232 |
// ---------------------------------------------------------------------------
|
|
233 |
// HandleNextDiscoveryResultL
|
|
234 |
// ---------------------------------------------------------------------------
|
|
235 |
//
|
|
236 |
void CBTNotifDeviceSelector::HandleNextDiscoveryResultL(
|
|
237 |
const TInquirySockAddr& aAddr, const TDesC& aName )
|
|
238 |
{
|
47
|
239 |
CBtDevExtension* devext = GetDeviceFromRepositoryL(aAddr.BTAddr());
|
|
240 |
|
|
241 |
if(!devext)
|
|
242 |
{
|
|
243 |
devext = CBtDevExtension::NewLC( aAddr, aName );
|
|
244 |
}
|
|
245 |
else
|
|
246 |
{
|
|
247 |
CleanupStack::PushL(devext);
|
|
248 |
}
|
29
|
249 |
iDevices.AppendL( devext );
|
47
|
250 |
CleanupStack::Pop( devext );
|
42
|
251 |
|
|
252 |
if(iNotification)
|
|
253 |
{// conditional check required as CAdvanceDevDiscoverer sends discovered devices at times
|
|
254 |
// even after canceldiscovery is issued and notification is set to NULL
|
|
255 |
// this causes EExcDataAbort
|
57
|
256 |
LoadDeviceDetailsL(*devext);
|
42
|
257 |
}
|
29
|
258 |
}
|
|
259 |
|
|
260 |
// ---------------------------------------------------------------------------
|
|
261 |
// HandleDiscoveryCompleted
|
|
262 |
// ---------------------------------------------------------------------------
|
|
263 |
//
|
|
264 |
void CBTNotifDeviceSelector::HandleDiscoveryCompleted( TInt aErr )
|
|
265 |
{
|
|
266 |
(void) aErr;
|
31
|
267 |
CHbSymbianVariantMap* map = iNotification->Data();
|
42
|
268 |
TBuf<KMaxKeyDesCLength> keyStr;
|
31
|
269 |
|
|
270 |
|
|
271 |
//TODO compile fail here we need to send the discovery completed text to the dialog
|
42
|
272 |
//TODO change the hardcoded string
|
31
|
273 |
keyStr.Copy(_L("Search Completed"));
|
|
274 |
CHbSymbianVariant* devEntry( NULL );
|
|
275 |
TRAP_IGNORE( devEntry = CHbSymbianVariant::NewL( (TAny*) &(keyStr),
|
|
276 |
CHbSymbianVariant::EDes ) );
|
|
277 |
if ( devEntry )
|
|
278 |
{
|
|
279 |
map->Add( keyStr, devEntry );
|
|
280 |
iNotification->Update();
|
|
281 |
}
|
|
282 |
else
|
|
283 |
{
|
|
284 |
// todo: Complete client request with error
|
|
285 |
}
|
29
|
286 |
}
|
|
287 |
|
31
|
288 |
// From MBtDeviceRepositoryObserver
|
|
289 |
|
|
290 |
void CBTNotifDeviceSelector::RepositoryInitialized()
|
|
291 |
{
|
|
292 |
iRepositoryInitialized = ETrue;
|
|
293 |
TInt err(KErrNone);
|
|
294 |
if(!iLoadDevices)
|
|
295 |
{
|
|
296 |
iLoadDevices = ETrue;
|
57
|
297 |
iDevices.ResetAndDestroy();
|
31
|
298 |
if(iServer.DevRepository().AllDevices().Count()==0)
|
|
299 |
{
|
|
300 |
TRAP(err, {
|
|
301 |
PrepareNotificationL(TBluetoothDialogParams::EDeviceSearch, ENoResource);
|
|
302 |
iDiscoverer->DiscoverDeviceL(); } );
|
|
303 |
}
|
|
304 |
else
|
|
305 |
{
|
|
306 |
TRAP( err,
|
|
307 |
{PrepareNotificationL(
|
|
308 |
TBluetoothDialogParams::EMoreDevice, ENoResource);
|
|
309 |
LoadUsedDevicesL();
|
|
310 |
} );
|
|
311 |
}
|
|
312 |
}
|
|
313 |
if ( err )
|
|
314 |
{
|
|
315 |
// todo: complete client request
|
|
316 |
}
|
|
317 |
}
|
|
318 |
|
|
319 |
void CBTNotifDeviceSelector::DeletedFromRegistry( const TBTDevAddr& aAddr )
|
|
320 |
{
|
|
321 |
(void) aAddr;
|
|
322 |
}
|
|
323 |
|
|
324 |
void CBTNotifDeviceSelector::AddedToRegistry( const CBtDevExtension& aDev )
|
|
325 |
{
|
|
326 |
(void) aDev;
|
|
327 |
}
|
|
328 |
|
|
329 |
void CBTNotifDeviceSelector::ChangedInRegistry( const CBtDevExtension& aDev, TUint aSimilarity )
|
|
330 |
{
|
|
331 |
(void) aDev;
|
|
332 |
(void) aSimilarity;
|
|
333 |
}
|
|
334 |
|
|
335 |
void CBTNotifDeviceSelector::ServiceConnectionChanged(const CBtDevExtension& aDev, TBool aConnected )
|
|
336 |
{
|
|
337 |
(void) aDev;
|
|
338 |
(void) aConnected;
|
|
339 |
}
|
|
340 |
|
|
341 |
|
29
|
342 |
// ---------------------------------------------------------------------------
|
|
343 |
// Get and configure a notification.
|
|
344 |
// ---------------------------------------------------------------------------
|
|
345 |
//
|
|
346 |
void CBTNotifDeviceSelector::PrepareNotificationL(
|
|
347 |
TBluetoothDialogParams::TBTDialogType aType,
|
|
348 |
TBTDialogResourceId aResourceId )
|
|
349 |
{
|
|
350 |
BOstraceFunctionEntry0( DUMMY_DEVLIST );
|
42
|
351 |
if(iNotification)
|
|
352 |
{
|
|
353 |
iNotification->RemoveObserver();
|
|
354 |
iNotification = NULL;
|
|
355 |
}
|
29
|
356 |
iNotification = iServer.NotificationManager()->GetNotification();
|
|
357 |
User::LeaveIfNull( iNotification ); // For OOM exception, leaves with KErrNoMemory
|
|
358 |
iNotification->SetObserver( this );
|
|
359 |
iNotification->SetNotificationType( aType, aResourceId );
|
|
360 |
|
31
|
361 |
iServer.NotificationManager()->QueueNotificationL( iNotification,CBTNotificationManager::EPriorityHigh );
|
29
|
362 |
BOstraceFunctionExit0( DUMMY_DEVLIST );
|
|
363 |
}
|
31
|
364 |
|
|
365 |
void CBTNotifDeviceSelector::LoadUsedDevicesL()
|
|
366 |
{
|
|
367 |
const RDevExtensionArray& devArray= iServer.DevRepository().AllDevices();
|
|
368 |
for(TInt i=0; i< devArray.Count(); i++ )
|
|
369 |
{
|
57
|
370 |
iDevices.AppendL( devArray[i]->CopyL() );
|
|
371 |
}
|
|
372 |
SortUsedDevicesL();
|
|
373 |
RemoveUnWantedDevices();
|
|
374 |
SendLastUsedDevicesL();
|
|
375 |
SendPairedDevicesL();
|
|
376 |
|
|
377 |
}
|
|
378 |
|
31
|
379 |
|
57
|
380 |
void CBTNotifDeviceSelector::SortUsedDevicesL()
|
|
381 |
{
|
|
382 |
TInt count = iDevices.Count();
|
|
383 |
for(TInt i=0;i<(count-1);i++)
|
|
384 |
{
|
|
385 |
for(TInt j=0;j<(count-(i+1));j++)
|
|
386 |
{
|
|
387 |
if(iDevices[j]->Device().Used().Int64() < iDevices[j+1]->Device().Used().Int64())
|
|
388 |
{
|
|
389 |
CBtDevExtension* devextension = iDevices[j+1];
|
|
390 |
iDevices.Remove(j+1);
|
|
391 |
iDevices.InsertL(devextension,j);
|
|
392 |
}
|
|
393 |
}
|
|
394 |
}
|
|
395 |
}
|
|
396 |
|
47
|
397 |
|
57
|
398 |
void CBTNotifDeviceSelector::RemoveUnWantedDevices()
|
|
399 |
{
|
|
400 |
for(TInt i=(iDevices.Count()-1);i>-1;i--)
|
|
401 |
{
|
|
402 |
TInt classOfDevice = iDevices[i]->Device().DeviceClass().DeviceClass();
|
|
403 |
TBTDeviceClass codClass = TBTDeviceClass( classOfDevice );
|
|
404 |
TUint8 majorDevCls = codClass.MajorDeviceClass();
|
|
405 |
if((majorDevCls ==EMajorDeviceComputer)|| (majorDevCls ==EMajorDevicePhone))
|
|
406 |
{
|
|
407 |
}
|
|
408 |
else
|
|
409 |
{
|
|
410 |
CBtDevExtension* devextension = iDevices[i];
|
|
411 |
iDevices.Remove(i);
|
|
412 |
delete devextension;
|
|
413 |
devextension = NULL;
|
|
414 |
iDevices.Compress();
|
31
|
415 |
}
|
|
416 |
}
|
|
417 |
}
|
47
|
418 |
|
57
|
419 |
void CBTNotifDeviceSelector::SendLastUsedDevicesL()
|
|
420 |
{
|
|
421 |
TInt Count = iDevices.Count();
|
|
422 |
if(Count > KLastUsedDevices)
|
|
423 |
Count = KLastUsedDevices;
|
|
424 |
for(TInt i=0;i < Count;i++)
|
|
425 |
{
|
|
426 |
LoadDeviceDetailsL(*(iDevices[i]));
|
|
427 |
}
|
|
428 |
}
|
47
|
429 |
|
|
430 |
|
57
|
431 |
void CBTNotifDeviceSelector::SendPairedDevicesL()
|
|
432 |
{
|
|
433 |
TInt count = iDevices.Count();
|
|
434 |
if(count > KLastUsedDevices)
|
|
435 |
{
|
|
436 |
for(TInt i = KLastUsedDevices; i< count; i++)
|
|
437 |
{
|
|
438 |
if(isBonded( iDevices[i]->Device()))
|
|
439 |
{
|
|
440 |
LoadDeviceDetailsL(*(iDevices[i]));
|
|
441 |
}
|
|
442 |
}
|
|
443 |
}
|
|
444 |
|
|
445 |
}
|
|
446 |
|
|
447 |
void CBTNotifDeviceSelector::LoadDeviceDetailsL(const CBtDevExtension& aDevice)
|
|
448 |
{
|
|
449 |
TBuf<KBTDevAddrSize * 2> addr;
|
|
450 |
TUint32 classOfDevice;
|
|
451 |
TBool status;
|
|
452 |
|
|
453 |
//TODO Need to create string constants Also try Enum value for device name rather
|
|
454 |
//than hadrdcoded string for key. It was not working previously
|
|
455 |
CHbSymbianVariantMap* map = iNotification->CreateNotificationDataL();
|
|
456 |
AddDataL(map,_L("Name"),(TAny*) &(aDevice.Alias()),CHbSymbianVariant::EDes);
|
|
457 |
|
|
458 |
aDevice.Addr().GetReadable(addr);
|
|
459 |
User::LeaveIfError(iNotification->SetData(TBluetoothDeviceDialog::EAddress,addr));
|
|
460 |
|
|
461 |
classOfDevice = aDevice.Device().DeviceClass().DeviceClass();
|
|
462 |
User::LeaveIfError(iNotification->SetData(TBluetoothDeviceDialog::EDeviceClass,classOfDevice));
|
|
463 |
|
|
464 |
status = isBonded( aDevice.Device());
|
|
465 |
AddDataL(map,_L("Bonded"),&status,CHbSymbianVariant::EBool);
|
|
466 |
|
|
467 |
status = aDevice.Device().GlobalSecurity().Banned();
|
|
468 |
AddDataL(map,_L("Blocked"),&status,CHbSymbianVariant::EBool);
|
|
469 |
|
|
470 |
status = aDevice.Device().GlobalSecurity().NoAuthorise();
|
|
471 |
AddDataL(map,_L("Trusted"),&status,CHbSymbianVariant::EBool);
|
|
472 |
|
|
473 |
status = aDevice.ServiceConnectionStatus() == EBTEngConnected;
|
|
474 |
AddDataL(map,_L("Connected"),&status,CHbSymbianVariant::EBool);
|
|
475 |
iNotification->Update();
|
|
476 |
}
|
|
477 |
|
47
|
478 |
/*!
|
|
479 |
Tells if the given device is bonded.
|
|
480 |
*/
|
57
|
481 |
TBool CBTNotifDeviceSelector::isBonded( const CBTDevice &dev ) const
|
47
|
482 |
{
|
|
483 |
// todo: this has not addresses Just Works pairing mode yet.
|
|
484 |
return dev.IsValidPaired() && dev.IsPaired() &&
|
|
485 |
dev.LinkKeyType() != ELinkKeyUnauthenticatedUpgradable;
|
|
486 |
}
|
|
487 |
|
|
488 |
void CBTNotifDeviceSelector::AddDataL(CHbSymbianVariantMap* aMap, const TDesC& aKey,
|
|
489 |
const TAny* aData, CHbSymbianVariant::TType aDataType)
|
|
490 |
{
|
|
491 |
CHbSymbianVariant* value = CHbSymbianVariant::NewL(aData, aDataType);
|
|
492 |
CleanupStack::PushL( value );
|
|
493 |
User::LeaveIfError( aMap->Add( aKey, value ) ); // aMap takes the ownership of value
|
|
494 |
CleanupStack::Pop( value );
|
|
495 |
}
|
|
496 |
|
|
497 |
// ---------------------------------------------------------------------------
|
|
498 |
// Tells if these two instances are for the same remote device
|
|
499 |
// ---------------------------------------------------------------------------
|
|
500 |
//
|
|
501 |
TBool MatchDeviceAddress(const TBTDevAddr* aAddr, const CBtDevExtension& aDev)
|
|
502 |
{
|
|
503 |
return *aAddr == aDev.Device().BDAddr();
|
|
504 |
}
|
|
505 |
|
|
506 |
|
|
507 |
CBtDevExtension* CBTNotifDeviceSelector::GetDeviceFromRepositoryL( const TBTDevAddr& aAddr )
|
|
508 |
{
|
|
509 |
const RDevExtensionArray& devArray= iServer.DevRepository().AllDevices();
|
|
510 |
|
|
511 |
TInt pos = devArray.Find( aAddr, MatchDeviceAddress);
|
|
512 |
if(pos > -1)
|
|
513 |
{
|
|
514 |
return devArray[pos]->CopyL();
|
|
515 |
}
|
|
516 |
return NULL;
|
|
517 |
}
|
|
518 |
|
|
519 |
|
|
520 |
void CBTNotifDeviceSelector::SendSelectedDeviceL( CHbSymbianVariantMap& aData )
|
|
521 |
{
|
|
522 |
TBTDeviceResponseParamsPckg devParams;
|
|
523 |
TBTDevAddr address;
|
|
524 |
User::LeaveIfError(address.SetReadable(
|
|
525 |
*(static_cast<TDesC*>(aData.Get(_L("deviceaddress"))->Data()))));
|
|
526 |
devParams().SetDeviceAddress( address );
|
|
527 |
devParams().SetDeviceClass(*(static_cast<TUint32*>(aData.Get(_L("deviceclass"))->Data())));
|
|
528 |
devParams().SetDeviceName(*(static_cast<TDesC*>(aData.Get(_L("devicename"))->Data())));
|
|
529 |
User::LeaveIfError(iMessage.Write( EBTNotifSrvReplySlot, devParams ));
|
|
530 |
}
|
|
531 |
|