42
|
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 |
#include "btnotifutil.h"
|
|
18 |
#include <btservices/btdevrepository.h>
|
|
19 |
#include <btmanclient.h>
|
|
20 |
#include "bluetoothtrace.h"
|
|
21 |
|
|
22 |
// ---------------------------------------------------------------------------
|
|
23 |
// If aDevExt contains a valid friendly name, the friendly name will be displayed;
|
|
24 |
// Otherwise, if the given name from the parameter of a notifier request is valid,
|
|
25 |
// the given name will be displayed;
|
|
26 |
// Otherwise, If aDevExt contains a valid device name, the name will be displayed;
|
|
27 |
// Otherwise, the a name will be created by this function.
|
|
28 |
// ---------------------------------------------------------------------------
|
|
29 |
//
|
|
30 |
void TBTNotifUtil::GetDeviceUiNameL( TDes& aNameBuf,
|
|
31 |
const CBtDevExtension* aDevExt,
|
|
32 |
const TDesC& aNameInParam,
|
|
33 |
const TBTDevAddr& aAddr)
|
|
34 |
{
|
|
35 |
CBtDevExtension* tempDev( NULL );
|
|
36 |
TPtrC namePtr;
|
|
37 |
if ( aDevExt &&
|
|
38 |
aDevExt->Device().IsValidFriendlyName() &&
|
|
39 |
aDevExt->Device().FriendlyName().Length() != 0 )
|
|
40 |
{
|
|
41 |
// We always use the friendly name regardless of
|
|
42 |
// the device-name of the device is available or not.
|
|
43 |
namePtr.Set( aDevExt->Device().FriendlyName() );
|
|
44 |
}
|
|
45 |
else
|
|
46 |
{
|
|
47 |
// this will take care of name formating. Either the
|
|
48 |
// name from iNameInParam or the address will be
|
|
49 |
// the alias:
|
|
50 |
tempDev = CBtDevExtension::NewLC( aAddr, aNameInParam );
|
|
51 |
namePtr.Set( tempDev->Alias() );
|
|
52 |
}
|
|
53 |
// Make sure no overflow:
|
|
54 |
if ( aNameBuf.MaxLength() < namePtr.Length() )
|
|
55 |
{
|
|
56 |
aNameBuf.Copy( namePtr.Left( aNameBuf.MaxLength() ) );
|
|
57 |
}
|
|
58 |
else
|
|
59 |
{
|
|
60 |
aNameBuf.Copy( namePtr );
|
|
61 |
}
|
|
62 |
if ( tempDev )
|
|
63 |
{
|
|
64 |
CleanupStack::PopAndDestroy( tempDev );
|
|
65 |
}
|
|
66 |
}
|
|
67 |
|
|
68 |
|