51
|
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 "avrcpcommand.h"
|
|
17 |
#include "avrcplog.h"
|
|
18 |
|
|
19 |
CAvrcpCommand::CAvrcpCommand(TUint aRemConId,
|
|
20 |
SymbianAvctp::TTransactionLabel aTransactionLabel,
|
|
21 |
const TBTDevAddr& aAddr)
|
|
22 |
: iRemConId(aRemConId)
|
|
23 |
, iTransactionLabel(aTransactionLabel)
|
|
24 |
, iRemoteAddr(aAddr)
|
|
25 |
{
|
|
26 |
LOG_FUNC
|
|
27 |
}
|
|
28 |
|
|
29 |
//------------------------------------------------------------------------------------
|
|
30 |
// Called by handlers, router and bearer
|
|
31 |
//------------------------------------------------------------------------------------
|
|
32 |
|
|
33 |
/** Decrement the users of this command.
|
|
34 |
|
|
35 |
This must be called by users of the command when they
|
|
36 |
no longer require the command to remain in existence.
|
|
37 |
When the number of users reaches zero, the command
|
|
38 |
is deleted.
|
|
39 |
*/
|
|
40 |
void CAvrcpCommand::DecrementUsers()
|
|
41 |
{
|
|
42 |
LOG_FUNC
|
|
43 |
if(--iUsers < 1)
|
|
44 |
{
|
|
45 |
iHandlingLink.Deque();
|
|
46 |
delete this;
|
|
47 |
}
|
|
48 |
}
|
|
49 |
|
|
50 |
/** Increment the users of this command.
|
|
51 |
|
|
52 |
This must be called by users of the command to signify
|
|
53 |
they require it to remain in existence.
|
|
54 |
*/
|
|
55 |
void CAvrcpCommand::IncrementUsers()
|
|
56 |
{
|
|
57 |
LOG_FUNC
|
|
58 |
iUsers++;
|
|
59 |
}
|
|
60 |
|
|
61 |
//------------------------------------------------------------------------------------
|
|
62 |
// Called by bearer
|
|
63 |
//------------------------------------------------------------------------------------
|
|
64 |
|
|
65 |
/** Get info needed by RemCon for this command.
|
|
66 |
|
|
67 |
@param aInterfaceUid On return, the RemCon interface of this command.
|
|
68 |
@param aId On return, the RemCon transaction id of this command.
|
|
69 |
@param aOperationId On return, the RemCon operation id of this command.
|
|
70 |
@param aCommandData On return, the command data for this operation.
|
|
71 |
Ownership is returned.
|
|
72 |
@param aAddr On return, the originating device for this command.
|
|
73 |
*/
|
|
74 |
void CAvrcpCommand::GetCommandInfo(TUid& aInterfaceUid,
|
|
75 |
TUint& aId,
|
|
76 |
TUint& aOperationId,
|
|
77 |
RBuf8& aCommandData,
|
|
78 |
TBTDevAddr& aAddr)
|
|
79 |
{
|
|
80 |
LOG_FUNC
|
|
81 |
aInterfaceUid = iInterfaceUid;
|
|
82 |
aId = iRemConId;
|
|
83 |
aOperationId = iOperationId;
|
|
84 |
|
|
85 |
// RemCon will take ownership of command data
|
|
86 |
aCommandData.Assign(iCommandData);
|
|
87 |
iCommandData.Assign(NULL);
|
|
88 |
|
|
89 |
aAddr = iRemoteAddr;
|
|
90 |
}
|
|
91 |
|
|
92 |
//------------------------------------------------------------------------------------
|
|
93 |
// Called by handlers
|
|
94 |
//------------------------------------------------------------------------------------
|
|
95 |
|
|
96 |
/** Gets the remote associated with this command.
|
|
97 |
This may be the source or the destination, depending
|
|
98 |
on if the originated locally or remotely.
|
|
99 |
|
|
100 |
@return The BT address of the remote device.
|
|
101 |
*/
|
|
102 |
const TBTDevAddr& CAvrcpCommand::RemoteAddress() const
|
|
103 |
{
|
|
104 |
LOG_FUNC
|
|
105 |
return iRemoteAddr;
|
|
106 |
}
|
|
107 |
|
|
108 |
/** Gets the AVCTP transaction label for this command.
|
|
109 |
This is used to match commands with responses.
|
|
110 |
|
|
111 |
@return The AVCTP transaction label for this command.
|
|
112 |
*/
|
|
113 |
SymbianAvctp::TTransactionLabel CAvrcpCommand::TransactionLabel() const
|
|
114 |
{
|
|
115 |
LOG_FUNC
|
|
116 |
return iTransactionLabel;
|
|
117 |
}
|
|
118 |
|
|
119 |
/** Gets the RemCon id of this command.
|
|
120 |
This is used to uniquely identify a transaction to RemCon.
|
|
121 |
|
|
122 |
@return The RemCon command id.
|
|
123 |
*/
|
|
124 |
TUint CAvrcpCommand::RemConCommandId() const
|
|
125 |
{
|
|
126 |
LOG_FUNC
|
|
127 |
return iRemConId;
|
|
128 |
}
|
|
129 |
|
|
130 |
/** Gets the RemCon interface uid of this command.
|
|
131 |
|
|
132 |
This is used with the operation id to uniquely identify an operation to RemCon.
|
|
133 |
|
|
134 |
@param aOperation
|
|
135 |
@return The RemCon operation id.
|
|
136 |
*/
|
|
137 |
const TUid& CAvrcpCommand::RemConInterfaceUid() const
|
|
138 |
{
|
|
139 |
LOG_FUNC
|
|
140 |
return iInterfaceUid;
|
|
141 |
}
|
|
142 |
|
|
143 |
/** Gets the RemCon operation id of this command.
|
|
144 |
|
|
145 |
This is used with the interface uid to uniquely identify an operation to RemCon.
|
|
146 |
|
|
147 |
@param aOperation
|
|
148 |
@return The RemCon operation id.
|
|
149 |
*/
|
|
150 |
TUint CAvrcpCommand::RemConOperationId() const
|
|
151 |
{
|
|
152 |
LOG_FUNC
|
|
153 |
return iOperationId;
|
|
154 |
}
|
|
155 |
|
|
156 |
|
|
157 |
/**
|
|
158 |
Whether the Bearer is aware of this command. If not we shouldn't
|
|
159 |
inform the bearer of responses.
|
|
160 |
*/
|
|
161 |
TBool CAvrcpCommand::KnownToBearer() const
|
|
162 |
{
|
|
163 |
return iKnownToBearer;
|
|
164 |
}
|