1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
12 // |
12 // |
13 // Description: |
13 // Description: |
14 // |
14 // |
15 |
15 |
16 #include "eirpublishertxpowerlevel.h" |
16 #include "eirpublishertxpowerlevel.h" |
17 #include <bluetooth/eirpublisherbase.h> |
17 #include "eirmanserver.h" |
18 |
18 |
19 //********************************** |
19 //********************************** |
20 // CEirPublisherTxPowerLevel |
20 // CEirPublisherTxPowerLevel |
21 //********************************** |
21 //********************************** |
22 /** |
22 /** |
23 Provides functionality to publish transmission power level to EIR. |
23 Provides functionality to publish transmission power level to EIR. |
24 **/ |
24 **/ |
25 CEirPublisherTxPowerLevel* CEirPublisherTxPowerLevel::NewL() |
25 CEirPublisherTxPowerLevel* CEirPublisherTxPowerLevel::NewL(CEirManServer& aServer) |
26 { |
26 { |
27 CEirPublisherTxPowerLevel* self = new (ELeave) CEirPublisherTxPowerLevel(); |
27 CEirPublisherTxPowerLevel* self = new (ELeave) CEirPublisherTxPowerLevel(); |
28 CleanupStack::PushL(self); |
28 CleanupStack::PushL(self); |
29 self->ConstructL(); |
29 self->ConstructL(aServer); |
30 CleanupStack::Pop(); |
30 CleanupStack::Pop(); |
31 return self; |
31 return self; |
32 } |
32 } |
33 |
33 |
34 CEirPublisherTxPowerLevel::CEirPublisherTxPowerLevel() |
34 CEirPublisherTxPowerLevel::CEirPublisherTxPowerLevel() |
35 : CEirPublisherBase(EEirTagTxPowerLevel) |
|
36 { |
35 { |
37 } |
36 } |
38 |
37 |
39 void CEirPublisherTxPowerLevel::ConstructL() |
38 void CEirPublisherTxPowerLevel::ConstructL(CEirManServer& aServer) |
40 { |
39 { |
41 CEirPublisherBase::ConstructL(); |
40 iSession = aServer.NewInternalSessionL(*this); |
|
41 iSession->RegisterTag(EEirTagTxPowerLevel); |
42 } |
42 } |
43 |
43 |
44 CEirPublisherTxPowerLevel::~CEirPublisherTxPowerLevel() |
44 CEirPublisherTxPowerLevel::~CEirPublisherTxPowerLevel() |
45 { |
45 { |
|
46 delete iSession; |
|
47 } |
|
48 |
|
49 void CEirPublisherTxPowerLevel::MeisnRegisterComplete(TInt aResult) |
|
50 { |
|
51 if (aResult == KErrNone) |
|
52 { |
|
53 iTagRegistered = ETrue; |
|
54 if (iTxPowerLevelPublished) |
|
55 { |
|
56 iSession->NewData(KSizeOfTxPowerLevelData); |
|
57 } |
|
58 } |
46 } |
59 } |
47 |
60 |
48 void CEirPublisherTxPowerLevel::UpdateTxPowerLevel(TInt8 aTxPowerLevel) |
61 void CEirPublisherTxPowerLevel::UpdateTxPowerLevel(TInt8 aTxPowerLevel) |
49 { |
62 { |
50 iTxPowerLevel = aTxPowerLevel; |
63 iTxPowerLevel = aTxPowerLevel; |
51 iPublisher->PublishData(KSizeOfTxPowerLevelData); |
64 iTxPowerLevelPublished = ETrue; |
|
65 if (iTagRegistered) |
|
66 { |
|
67 iSession->NewData(KSizeOfTxPowerLevelData); |
|
68 } |
52 } |
69 } |
53 |
70 |
54 // From MEirPublisherNotifier |
71 // From MEirPublisherNotifier |
55 void CEirPublisherTxPowerLevel::MepnSpaceAvailable(TUint aBytesAvailable) |
72 void CEirPublisherTxPowerLevel::MeisnSpaceAvailable(TUint aBytesAvailable) |
56 { |
73 { |
57 if (aBytesAvailable >= KSizeOfTxPowerLevelData) |
74 if (aBytesAvailable >= KSizeOfTxPowerLevelData) |
58 { |
75 { |
59 // only publish TxPowerLevel if enough space |
76 // only publish TxPowerLevel if enough space |
60 iPublishBuf.Zero(); |
77 iPublishBuf.Zero(); |
61 iPublishBuf.Append(iTxPowerLevel); |
78 iPublishBuf.Append(iTxPowerLevel); |
62 iPublisher->SetData(iPublishBuf, EEirDataComplete); |
79 iSession->SetData(iPublishBuf, EEirDataComplete); |
63 } |
80 } |
64 else |
81 else |
65 { |
82 { |
66 // Otherwise publish zero length string |
83 // Otherwise publish zero length string |
67 iPublishBuf.Zero(); |
84 iPublishBuf.Zero(); |
68 iPublisher->SetData(iPublishBuf, EEirDataPartial); |
85 iSession->SetData(iPublishBuf, EEirDataPartial); |
69 } |
86 } |
70 } |
87 } |
71 |
88 |
72 void CEirPublisherTxPowerLevel::MepnSetDataError(TInt /*aResult*/) |
89 void CEirPublisherTxPowerLevel::MeisnSetDataError(TInt /* aError */) |
73 { |
90 { |
|
91 |
74 } |
92 } |