|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "eirpublisherlocalname.h" |
|
17 #include "linkutil.h" |
|
18 #include <bluetooth/eirpublisherbase.h> |
|
19 #include <bluetooth/logger.h> |
|
20 |
|
21 #ifdef __FLOG_ACTIVE |
|
22 _LIT8(KLogComponent, LOG_COMPONENT_EIRMANAGER); |
|
23 #endif |
|
24 |
|
25 |
|
26 //********************************** |
|
27 // CEirPublisherLocalName |
|
28 //********************************** |
|
29 /** |
|
30 Provides functionality to publish Local Name to EIR. |
|
31 **/ |
|
32 CEirPublisherLocalName* CEirPublisherLocalName::NewL() |
|
33 { |
|
34 LOG_STATIC_FUNC |
|
35 CEirPublisherLocalName* self = new (ELeave) CEirPublisherLocalName(); |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(); |
|
38 CleanupStack::Pop(); |
|
39 return self; |
|
40 } |
|
41 |
|
42 CEirPublisherLocalName::CEirPublisherLocalName() |
|
43 : CEirPublisherBase(EEirTagName) |
|
44 { |
|
45 LOG_FUNC |
|
46 } |
|
47 |
|
48 CEirPublisherLocalName::~CEirPublisherLocalName() |
|
49 { |
|
50 LOG_FUNC |
|
51 delete iPublishBuf; |
|
52 } |
|
53 |
|
54 void CEirPublisherLocalName::ConstructL() |
|
55 { |
|
56 LOG_FUNC |
|
57 CEirPublisherBase::ConstructL(); |
|
58 } |
|
59 |
|
60 void CEirPublisherLocalName::UpdateName(const TDesC8& aName) |
|
61 { |
|
62 LOG_FUNC |
|
63 // Check aName isn't longer than 248 characters |
|
64 __ASSERT_DEBUG(aName.Length() <= 248, Panic(EEIRPublisherUpdateNameTooLong)); |
|
65 iLocalName = aName; |
|
66 iPublisher->PublishData(aName.Size()); |
|
67 } |
|
68 |
|
69 |
|
70 // From MEirPublisherNotifier |
|
71 void CEirPublisherLocalName::MepnSpaceAvailable(TUint aBytesAvailable) |
|
72 { |
|
73 LOG_FUNC |
|
74 // Delete memory from last time this was called |
|
75 delete iPublishBuf, iPublishBuf = NULL; |
|
76 |
|
77 TUint8 namelen = iLocalName.Length(); |
|
78 TUint avail = aBytesAvailable; |
|
79 avail = avail < namelen ? avail : namelen; |
|
80 |
|
81 if (avail < namelen) |
|
82 { |
|
83 // Truncate the device name to space available |
|
84 iPublishBuf = iLocalName.Left(avail).Alloc(); |
|
85 if(iPublishBuf) |
|
86 { |
|
87 iPublisher->SetData(*iPublishBuf, EEirDataPartial); |
|
88 } |
|
89 } |
|
90 else |
|
91 { |
|
92 // Zero-length device names will be published as "complete" |
|
93 // as defined in the specification, volume 3, part C, 8.1 |
|
94 iPublishBuf = iLocalName.Alloc(); |
|
95 if(iPublishBuf) |
|
96 { |
|
97 iPublisher->SetData(*iPublishBuf, EEirDataComplete); |
|
98 } |
|
99 } |
|
100 // Final case to handle if OOM occurs. |
|
101 if(!iPublishBuf) |
|
102 { |
|
103 iPublisher->SetData(KNullDesC8(), EEirDataPartial); |
|
104 } |
|
105 } |
|
106 |
|
107 void CEirPublisherLocalName::MepnSetDataError(TInt /*aResult*/) |
|
108 { |
|
109 LOG_FUNC |
|
110 } |