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 <remconaddress.h>
|
|
17 |
#include <remcon/avrcpspec.h>
|
|
18 |
#include "avrcpinternalinterface.h"
|
|
19 |
#include "avrcplog.h"
|
|
20 |
#include "avrcputils.h"
|
|
21 |
#include "browsecommand.h"
|
|
22 |
#include "browsingframe.h"
|
|
23 |
#include "mediabrowse.h"
|
|
24 |
#include "nowplaying.h"
|
|
25 |
|
|
26 |
TInt CBrowseCommand::HandleSetBrowsedPlayer()
|
|
27 |
{
|
|
28 |
LOG_FUNC
|
|
29 |
|
|
30 |
TPtrC8 payload;
|
|
31 |
AvrcpBrowsing::BrowsingFrame::Payload(iFrame, payload);
|
|
32 |
if (payload.Length() < KMinLengthSetBrowsedPlayerPdu)
|
|
33 |
{
|
|
34 |
return KErrAvrcpAirInvalidCommand;
|
|
35 |
}
|
|
36 |
|
|
37 |
iOperationId = ESetBrowsedPlayerOperationId;
|
|
38 |
iInterfaceUid = TUid::Uid(KRemConMediaBrowseApiUid);
|
|
39 |
|
|
40 |
RRemConSetBrowsedPlayerRequest request;
|
|
41 |
request.iPlayerId = static_cast<TUint16>(payload[0]) << 8;
|
|
42 |
request.iPlayerId |= payload[1];
|
|
43 |
request.iMaxResponse = iMaxResponse;
|
|
44 |
TBuf8<KMediaBrowseOutBufMaxLength> buf;
|
|
45 |
// Only reason for WriteL to leave is insufficently large buffer
|
|
46 |
TRAP_IGNORE(request.WriteL(buf));
|
|
47 |
TInt err = AppendIncomingPayload(buf);
|
|
48 |
return (err == KErrNone) ? KErrAvrcpFurtherProcessingRequired : err;
|
|
49 |
}
|
|
50 |
|
|
51 |
TInt CBrowseCommand::HandleGetFolderItems()
|
|
52 |
{
|
|
53 |
LOG_FUNC
|
|
54 |
|
|
55 |
TPtrC8 payload;
|
|
56 |
AvrcpBrowsing::BrowsingFrame::Payload(iFrame, payload);
|
|
57 |
if (payload.Length() < KMinLengthGetFolderItemsPdu)
|
|
58 |
{
|
|
59 |
return KErrAvrcpAirInvalidCommand;
|
|
60 |
}
|
|
61 |
|
|
62 |
TInt err = KErrAvrcpInvalidScope;
|
|
63 |
switch(iFrame[3])
|
|
64 |
{
|
|
65 |
case AvrcpBrowsing::KMediaPlayerScope:
|
|
66 |
{
|
|
67 |
iOperationId = EAvrcpInternalGetFolderItems;
|
|
68 |
iInterfaceUid = TUid::Uid(KUidAvrcpInternalInterface);
|
|
69 |
err = (AppendIncomingPayload(payload) == KErrNone) ? KErrAvrcpInternalCommand : err;
|
|
70 |
break;
|
|
71 |
}
|
|
72 |
case AvrcpBrowsing::KVirtualFilesystemScope:
|
|
73 |
case AvrcpBrowsing::KSearchScope:
|
|
74 |
case AvrcpBrowsing::KNowPlayingScope:
|
|
75 |
{
|
|
76 |
iOperationId = EGetFolderItemsOperationId;
|
|
77 |
iInterfaceUid = TUid::Uid(KRemConMediaBrowseApiUid);
|
|
78 |
err = AppendIncomingPayload(payload);
|
|
79 |
break;
|
|
80 |
}
|
|
81 |
};
|
|
82 |
|
|
83 |
return err;
|
|
84 |
}
|
|
85 |
|
|
86 |
TInt CBrowseCommand::HandleChangePath()
|
|
87 |
{
|
|
88 |
LOG_FUNC
|
|
89 |
|
|
90 |
TPtrC8 payload;
|
|
91 |
AvrcpBrowsing::BrowsingFrame::Payload(iFrame, payload);
|
|
92 |
if (payload.Length() < KMinLengthChangePathPdu)
|
|
93 |
{
|
|
94 |
return KErrAvrcpAirInvalidCommand;
|
|
95 |
}
|
|
96 |
|
|
97 |
iOperationId = EChangePathOperationId;
|
|
98 |
iInterfaceUid = TUid::Uid(KRemConMediaBrowseApiUid);
|
|
99 |
return AppendIncomingPayload(payload);
|
|
100 |
}
|
|
101 |
|
|
102 |
TInt CBrowseCommand::HandleGetItemAttributes()
|
|
103 |
{
|
|
104 |
LOG_FUNC
|
|
105 |
|
|
106 |
TPtrC8 payload;
|
|
107 |
AvrcpBrowsing::BrowsingFrame::Payload(iFrame, payload);
|
|
108 |
if (payload.Length() < KMinLengthGetItemAttributesPdu)
|
|
109 |
{
|
|
110 |
return KErrAvrcpAirInvalidCommand;
|
|
111 |
}
|
|
112 |
|
|
113 |
iInterfaceUid = TUid::Uid(KRemConMediaBrowseApiUid);
|
|
114 |
iOperationId = EGetItemAttributesOperationId;
|
|
115 |
return AppendIncomingPayload(payload);
|
|
116 |
}
|
|
117 |
|
|
118 |
TInt CBrowseCommand::HandleSearch()
|
|
119 |
{
|
|
120 |
LOG_FUNC
|
|
121 |
|
|
122 |
TPtrC8 payload;
|
|
123 |
AvrcpBrowsing::BrowsingFrame::Payload(iFrame, payload);
|
|
124 |
if (payload.Length() < KMinLengthSearchPdu)
|
|
125 |
{
|
|
126 |
return KErrAvrcpAirInvalidCommand;
|
|
127 |
}
|
|
128 |
|
|
129 |
iOperationId = ESearchOperationId;
|
|
130 |
iInterfaceUid = TUid::Uid(KRemConMediaBrowseApiUid);
|
|
131 |
return AppendIncomingPayload(payload);
|
|
132 |
}
|
|
133 |
|
|
134 |
/** Allocate correct space and append the payload to iCommandData
|
|
135 |
*/
|
|
136 |
TInt CBrowseCommand::AppendIncomingPayload(const TPtrC8& aPayload)
|
|
137 |
{
|
|
138 |
iCommandData.Close();
|
|
139 |
if (iCommandData.Create(aPayload.Length()) != KErrNone)
|
|
140 |
{
|
|
141 |
return KErrAvrcpAirInternalError;
|
|
142 |
}
|
|
143 |
|
|
144 |
iCommandData.Append(aPayload);
|
|
145 |
|
|
146 |
return KErrNone;
|
|
147 |
}
|
|
148 |
|
|
149 |
TInt CBrowseCommand::HandleUnknownPdu()
|
|
150 |
{
|
|
151 |
iFrame.Close();
|
|
152 |
TInt err = iFrame.CreateMax(KMinLengthGeneralReject);
|
|
153 |
if(!err)
|
|
154 |
{
|
|
155 |
iFrame[0] = AvrcpBrowsing::EGeneralReject;
|
|
156 |
iFrame[1] = (KMinLengthGeneralReject - AvrcpBrowsing::KHeaderLength) >> 8;
|
|
157 |
iFrame[2] = (KMinLengthGeneralReject - AvrcpBrowsing::KHeaderLength);
|
|
158 |
iFrame[3] = KErrAvrcpAirInvalidCommand - KErrAvrcpAirBase;
|
|
159 |
}
|
|
160 |
return err ? err : KErrAvrcpHandledInternallyRespondNow;
|
|
161 |
}
|