|
1 // Copyright (c) 2004-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 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include <bluetooth/logger.h> |
|
22 #include <e32base.h> |
|
23 #include <remcon/remconextapi1.h> |
|
24 #include <remconabsvoltarget.h> |
|
25 #include <remconabsvoltargetobserver.h> |
|
26 #include <remconinterfaceselector.h> |
|
27 #include "absvolutils.h" |
|
28 |
|
29 #ifdef __FLOG_ACTIVE |
|
30 _LIT8(KLogComponent, LOG_COMPONENT_REMCON_EXTAPI1); |
|
31 #endif |
|
32 |
|
33 EXPORT_C CRemConAbsVolTarget* CRemConAbsVolTarget::NewL(CRemConInterfaceSelector& aInterfaceSelector, |
|
34 MRemConAbsVolTargetObserver& aObserver) |
|
35 { |
|
36 LOG_STATIC_FUNC |
|
37 |
|
38 CRemConAbsVolTarget* self = new(ELeave) CRemConAbsVolTarget(aInterfaceSelector, aObserver); |
|
39 CleanupStack::PushL(self); |
|
40 self->BaseConstructL(); |
|
41 CleanupStack::Pop(self); |
|
42 return self; |
|
43 } |
|
44 |
|
45 CRemConAbsVolTarget::CRemConAbsVolTarget(CRemConInterfaceSelector& aInterfaceSelector, |
|
46 MRemConAbsVolTargetObserver& aObserver) |
|
47 : CRemConInterfaceBase(TUid::Uid(KRemConAbsVolApiUid), |
|
48 KMaxOperationDataSize, |
|
49 aInterfaceSelector, |
|
50 ERemConClientTypeTarget), |
|
51 iObserver(aObserver) |
|
52 { |
|
53 } |
|
54 |
|
55 EXPORT_C CRemConAbsVolTarget::~CRemConAbsVolTarget() |
|
56 { |
|
57 LOG_FUNC |
|
58 } |
|
59 |
|
60 TAny* CRemConAbsVolTarget::GetInterfaceIf(TUid aUid) |
|
61 { |
|
62 TAny* ret = NULL; |
|
63 if ( aUid == TUid::Uid(KRemConInterfaceIf1) ) |
|
64 { |
|
65 ret = reinterpret_cast<TAny*>( |
|
66 static_cast<MRemConInterfaceIf*>(this) |
|
67 ); |
|
68 } |
|
69 |
|
70 return ret; |
|
71 } |
|
72 |
|
73 void CRemConAbsVolTarget::MrcibNewMessage(TUint aOperationId, const TDesC8& aData) |
|
74 { |
|
75 LOG_FUNC |
|
76 LOG1(_L("\taOperationId = 0x%02x"), aOperationId); |
|
77 LOG1(_L("\taData.Length = %d"), aData.Length()); |
|
78 |
|
79 switch ( aOperationId ) |
|
80 { |
|
81 case ERemConGetAbsoluteVolume: |
|
82 iObserver.MrcavtoGetAbsoluteVolume(); |
|
83 break; |
|
84 |
|
85 case ERemConSetAbsoluteVolume: |
|
86 { |
|
87 TUint absVol; |
|
88 TUint maxVol; |
|
89 // 20 is the length of the abs vol data. |
|
90 if(aData.Length()<KRemConExtApi1MinimumDataLength+20) |
|
91 { |
|
92 // Silently drop the message |
|
93 LOG(_L("Warning: Message is dropped due to invalid length!")); |
|
94 __DEBUGGER(); |
|
95 } |
|
96 else if ( GetAbsMaxVol(aData.Mid(KRemConExtApi1MinimumDataLength, 20), absVol, maxVol) == KErrNone ) |
|
97 { |
|
98 iObserver.MrcavtoSetAbsoluteVolume(absVol, maxVol); |
|
99 } |
|
100 break; |
|
101 } |
|
102 |
|
103 default: |
|
104 break; |
|
105 } |
|
106 } |
|
107 |
|
108 EXPORT_C void CRemConAbsVolTarget::GetAbsoluteVolumeResponse(TRequestStatus& aStatus, TUint aAbsVol, TUint aMaxVol, TInt aError) |
|
109 { |
|
110 LOG_FUNC |
|
111 |
|
112 iOutData.Copy((TUint8*)&aError, KRemConExtApi1ResultDataLength); |
|
113 iOutData.AppendFormat(_L8("0x%08x0x%08x"), aAbsVol, aMaxVol); |
|
114 |
|
115 // We pass iNumRemotes even though we're not interested in its value but |
|
116 // RemCon will write to this location so we need it to be somewhere safe. |
|
117 InterfaceSelector().Send(aStatus, |
|
118 TUid::Uid(KRemConAbsVolApiUid), |
|
119 (TUint)ERemConGetAbsoluteVolume, |
|
120 iNumRemotes, |
|
121 ERemConResponse, |
|
122 iOutData); |
|
123 } |
|
124 |
|
125 EXPORT_C void CRemConAbsVolTarget::SetAbsoluteVolumeResponse(TRequestStatus& aStatus, TInt aError) |
|
126 { |
|
127 LOG_FUNC |
|
128 |
|
129 iOutData.Copy((TUint8*)&aError, KRemConExtApi1ResultDataLength); |
|
130 |
|
131 // We pass iNumRemotes even though we're not interested in its value but |
|
132 // RemCon will write to this location so we need it to be somewhere safe. |
|
133 InterfaceSelector().Send(aStatus, |
|
134 TUid::Uid(KRemConAbsVolApiUid), |
|
135 (TUint)ERemConSetAbsoluteVolume, |
|
136 iNumRemotes, |
|
137 ERemConResponse, |
|
138 KNullDesC8()); |
|
139 } |