|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <MceInSession.h> |
|
22 #include <MceMediaStream.h> |
|
23 #include <MCEAudioStream.h> |
|
24 #include <MCEAudioCodec.h> |
|
25 |
|
26 #include "MCEConstants.h" |
|
27 #include "TCmdGetSessionId.h" |
|
28 #include "CTcMCEContext.h" |
|
29 #include "CTcMCEReceived.h" |
|
30 |
|
31 void TCmdGetSessionId::ExecuteL() |
|
32 { |
|
33 |
|
34 // -- Setup --------- |
|
35 |
|
36 // Connection selection |
|
37 |
|
38 // -- Execution ------ |
|
39 |
|
40 // Get an item off the receive queue (waits until timeout if none is present) |
|
41 |
|
42 TInt timeout = ExtractIntegerL( KParamTimeout, KDefaultReceiveTimeout, |
|
43 EFalse ); |
|
44 TBool update = ExtractBooleanL( KParamSessionUpdate, EFalse ); |
|
45 |
|
46 CTcMCEReceived* item; |
|
47 |
|
48 if (update) |
|
49 { |
|
50 item = &(iContext.ReceivedUpdatedSessionItemL( timeout )); |
|
51 } |
|
52 else |
|
53 { |
|
54 item = &(iContext.ReceivedSessionItemL( timeout )); |
|
55 } |
|
56 |
|
57 |
|
58 if ( !item->InSession() ) |
|
59 { |
|
60 if ( item->Error() != KErrNone ) |
|
61 { |
|
62 AddIdResponseL( KSessionId, item->Session() ); |
|
63 AddIntegerResponseL( KResponseError, item->Error() ); |
|
64 } |
|
65 else |
|
66 { |
|
67 User::Leave(KErrNotFound); |
|
68 } |
|
69 } |
|
70 |
|
71 |
|
72 CMceSession::TState state = item->InSession()->State(); |
|
73 CTcStructure* structure; |
|
74 do |
|
75 { |
|
76 structure = FindStructureL( KParamSessionModifier, EFalse ); |
|
77 if( structure ) |
|
78 { |
|
79 //structure contains a list of name-value pairs |
|
80 for (int i=0; i < structure->Count(); i++) |
|
81 { |
|
82 CTcNameValue* itemVal = structure->ItemL( i ); |
|
83 //sessionMod->SetModifierL( itemVal->NameAsIntL(), itemVal->ValueAsIntL() ); |
|
84 item->InSession()->SetModifierL( itemVal->NameAsIntL(), itemVal->ValueAsIntL() ); |
|
85 |
|
86 //checking |
|
87 TMceSessionModifier nameInt = itemVal->NameAsIntL(); |
|
88 TUint valueInt = itemVal->ValueAsIntL(); |
|
89 item->InSession()->GetModifierL( nameInt, valueInt ); |
|
90 |
|
91 //sending response output |
|
92 |
|
93 AddIntegerResponseL( KParamSessionModifier, valueInt ); |
|
94 |
|
95 } |
|
96 iContext.List().RemoveParameter( KParamSessionModifier ); |
|
97 |
|
98 } |
|
99 } while( structure ); |
|
100 // -- Response creation -------- |
|
101 |
|
102 // Add Session |
|
103 AddIdResponseL( KSessionId, *(item->InSession()) ); |
|
104 |
|
105 // Add Headers |
|
106 AddHeadersL( item->Headers() ); |
|
107 |
|
108 // Add Session state |
|
109 AddIntegerResponseL( KResponseState, state ); |
|
110 AddTextualSessionStateL( state ); |
|
111 |
|
112 // Add Originator and Recipient |
|
113 AddTextResponseL( KResponseOriginator, item->InSession()->Originator() ); |
|
114 AddTextResponseL( KResponseRecipient, item->InSession()->Recipient() ); |
|
115 |
|
116 // Add Body |
|
117 if (item->Body()) |
|
118 { |
|
119 if (item->Body()->Length() > 0) |
|
120 { |
|
121 AddTextResponseL(KResponseBody, *(item->Body())); |
|
122 } |
|
123 } |
|
124 |
|
125 // Add ContentType |
|
126 if (item->ContentType()) |
|
127 { |
|
128 if (item->ContentType()->Length() > 0) |
|
129 { |
|
130 AddTextResponseL(KResponseContentType, *(item->ContentType())); |
|
131 } |
|
132 |
|
133 } |
|
134 |
|
135 |
|
136 // Find and add streams |
|
137 |
|
138 CDesC8Array* streams = new(ELeave)CDesC8ArraySeg(1); |
|
139 CleanupStack::PushL( streams ); |
|
140 |
|
141 const RPointerArray<CMceMediaStream>& streamPtrs = |
|
142 item->InSession()->Streams(); |
|
143 |
|
144 for (TInt streamIndex=0; streamIndex < streamPtrs.Count(); streamIndex++) |
|
145 { |
|
146 // Add to registry by reference and fetch name |
|
147 iContext.Registry().AddObjectL( *(streamPtrs[streamIndex]) ); |
|
148 TBuf8< KTcMaxObjectName > streamId = |
|
149 iContext.Registry().ObjectNameL( streamPtrs[streamIndex] ); |
|
150 streams->AppendL( streamId ); |
|
151 } |
|
152 |
|
153 if ( streams->Count() > 0 ) |
|
154 { |
|
155 AddArrayResponseL( KResponseStreams, *streams ); |
|
156 } |
|
157 |
|
158 CleanupStack::PopAndDestroy( streams ); |
|
159 |
|
160 } |
|
161 |
|
162 TBool TCmdGetSessionId::Match( const TTcIdentifier& aId ) |
|
163 { |
|
164 return TTcMceCommandBase::Match( aId, _L8("GetSessionId") ); |
|
165 } |
|
166 |
|
167 TTcCommandBase* TCmdGetSessionId::CreateL( MTcTestContext& aContext ) |
|
168 { |
|
169 return new( ELeave ) TCmdGetSessionId( aContext ); |
|
170 } |
|
171 |