|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <uricommon.h> |
|
21 #include <uri8.h> |
|
22 #include <uriutils.h> |
|
23 |
|
24 #include "mcemsrpsource.h" |
|
25 #include <mcertpsource.h> |
|
26 #include "mcecommsrpsource.h" |
|
27 #include "mcesession.h" |
|
28 #include "mcemediastream.h" |
|
29 #include "mceclilogs.h" |
|
30 #include "mcemanager.h" |
|
31 #include "mcemessagestream.h" |
|
32 #include "mcecommediastream.h" |
|
33 |
|
34 #define _FLAT_DATA static_cast<CMceComMsrpSource*>( iFlatData ) |
|
35 #define FLAT_DATA( data ) (_FLAT_DATA->data) |
|
36 |
|
37 #define _FLAT_ARRAY_DATA static_cast<CMceComMsrpSource*>(iFlatData) |
|
38 #define FLAT_ARRAY_DATA(iArray,data) (_FLAT_ARRAY_DATA)->iArray.AppendL(data) |
|
39 |
|
40 #define _FLAT_PTRARRAY_DATA static_cast<CMceComMsrpSource*>(iFlatData) |
|
41 #define FLAT_PTRARRAY_DATA(iArray,data) (_FLAT_PTRARRAY_DATA)->iArray->AppendL(data) |
|
42 |
|
43 // ============================ MEMBER FUNCTIONS =============================== |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CMceMsrpSource::NewL |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 EXPORT_C CMceMsrpSource* CMceMsrpSource::NewL() |
|
50 { |
|
51 CMceMsrpSource* self = NewLC(); |
|
52 CleanupStack::Pop(self); |
|
53 return self; |
|
54 } |
|
55 |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CMceMsrpSource::NewLC |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 EXPORT_C CMceMsrpSource* CMceMsrpSource::NewLC() |
|
62 { |
|
63 CMceMsrpSource* self = new (ELeave) CMceMsrpSource(); |
|
64 CleanupStack::PushL(self); |
|
65 self->ConstructL(); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CMceMsrpSourcee::ConstructL |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CMceMsrpSource::ConstructL() |
|
74 { |
|
75 CMceComMsrpSource *source = CMceComMsrpSource::NewLC(); |
|
76 CMceMediaSource::ConstructL(source); |
|
77 CleanupStack::Pop(source); |
|
78 } |
|
79 |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CMceMsrpSourcee::~CMceMsrpSourcee |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 EXPORT_C CMceMsrpSource::~CMceMsrpSource() |
|
86 { |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CMceMsrpSink::CMceMsrpSink |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 CMceMsrpSource::CMceMsrpSource() |
|
94 :CMceMediaSource() |
|
95 { |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CMceMicSource::EnableL |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C void CMceMsrpSource::EnableL() |
|
103 { |
|
104 MCECLI_DEBUG("CMceMsrpSource::EnableL, Entry"); |
|
105 |
|
106 CMceMediaSource::DoEnableL(); |
|
107 |
|
108 MCECLI_DEBUG("CMceMsrpSource::EnableL, Exit"); |
|
109 |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CMceMsrpSource::Disable |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C void CMceMsrpSource::DisableL() |
|
117 { |
|
118 MCECLI_DEBUG("CMceMsrpSource::DisableL, Entry"); |
|
119 |
|
120 CMceMediaSource::DoDisableL(); |
|
121 |
|
122 MCECLI_DEBUG("CMceMsrpSource::DisableL, Exit"); |
|
123 |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CMceMsrpSinke::Path |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 |
|
131 EXPORT_C RPointerArray<TUriC8>& CMceMsrpSource::Path() |
|
132 { |
|
133 return FLAT_DATA(iPath); |
|
134 } |
|
135 |
|
136 |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CMceMsrpSource::SetPath |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 EXPORT_C void CMceMsrpSource::SetPathL( const RPointerArray<TUriC8>& aMsrpPath ) |
|
143 { |
|
144 __ASSERT_ALWAYS(iFlatData!=NULL, User::Leave(KErrArgument)); |
|
145 // destroy the existing entries |
|
146 static_cast<CMceComMsrpSource*>(iFlatData)->iPath.ResetAndDestroy(); |
|
147 for(int i=0;i<aMsrpPath.Count();i++) |
|
148 { |
|
149 TUriParser8* parser = new (ELeave) TUriParser8; |
|
150 CleanupStack::PushL(parser); |
|
151 User::LeaveIfError( parser->Parse(aMsrpPath[i]->UriDes()) ); |
|
152 FLAT_ARRAY_DATA(iPath, parser); |
|
153 CleanupStack::Pop(parser); |
|
154 } |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CMceMsrpSource::AcceptTypes |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 |
|
162 EXPORT_C void CMceMsrpSource::AcceptTypesL(CDesC8ArrayFlat& aAcceptTypes) |
|
163 { |
|
164 __ASSERT_ALWAYS(iFlatData!=NULL, User::Leave(KErrArgument)); |
|
165 for (TInt i=0; i< FLAT_DATA(iAcceptTypes).Count();i++) |
|
166 { |
|
167 aAcceptTypes.AppendL(FLAT_DATA(iAcceptTypes)[i]); |
|
168 } |
|
169 } |
|
170 |
|
171 |
|
172 EXPORT_C void CMceMsrpSource::SetAcceptTypesL( const MDesC8Array& aAcceptTypes ) |
|
173 { |
|
174 __ASSERT_ALWAYS(iFlatData!=NULL, User::Leave(KErrArgument)); |
|
175 // reset the existing entries |
|
176 static_cast<CMceComMsrpSource*>(iFlatData)->iAcceptTypes.Reset(); |
|
177 for(int i=0; i<aAcceptTypes.MdcaCount();i++) |
|
178 { |
|
179 FLAT_ARRAY_DATA(iAcceptTypes, aAcceptTypes.MdcaPoint(i)); |
|
180 } |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CMceMsrpSource::AcceptTypes |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 |
|
188 EXPORT_C TDes8& CMceMsrpSource::AcceptWrappedTypesL() |
|
189 { |
|
190 __ASSERT_ALWAYS(iFlatData!=NULL, User::Leave(KErrArgument)); |
|
191 return FLAT_DATA(iAcceptWrappedTypes); |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CMceMsrpSource::SetAcceptTypesL |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 EXPORT_C void CMceMsrpSource::SetAcceptWrappedTypesL( const TDes8& aAcceptWrappedTypes ) |
|
199 { |
|
200 MCECLI_DEBUG(" \n CMceMsrpSource::SetAcceptWrappedTypesL : Entry"); |
|
201 __ASSERT_ALWAYS(iFlatData!=NULL, User::Leave(KErrArgument)); |
|
202 MCECLI_DEBUG_SVALUE("CMceMsrpSource::SetAcceptWrappedTypesL:", aAcceptWrappedTypes) |
|
203 FLAT_DATA(iAcceptWrappedTypes) = aAcceptWrappedTypes; |
|
204 FLAT_DATA(iWrappedTypes) = ETrue; |
|
205 MCECLI_DEBUG(" \n CMceMsrpSource::SetAcceptWrappedTypesL : Exit"); |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CMceMsrpSource::SetFileSelector |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 EXPORT_C void CMceMsrpSource::SetFileSelectorL(const TDesC& aName, const TDesC8& aFileType, TUint aFileSize ) |
|
213 { |
|
214 __ASSERT_ALWAYS(iFlatData!=NULL, User::Leave(KErrArgument)); |
|
215 FLAT_DATA(iFileShare) = ETrue; |
|
216 if (FLAT_DATA(iFileName) !=NULL ) |
|
217 { |
|
218 delete FLAT_DATA(iFileName); |
|
219 FLAT_DATA(iFileName) = NULL; |
|
220 } |
|
221 FLAT_DATA(iFileName) = aName.Alloc(); |
|
222 |
|
223 FLAT_DATA(iFileSize) = aFileSize; |
|
224 |
|
225 if (FLAT_DATA(iFileType) !=NULL ) |
|
226 { |
|
227 delete FLAT_DATA(iFileType); |
|
228 FLAT_DATA(iFileType) = NULL; |
|
229 } |
|
230 FLAT_DATA(iFileType) = aFileType.Alloc(); |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CMceMsrpSource::SetFileDisposition |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 EXPORT_C void CMceMsrpSource::SetFileDispositionL (const TDes8& aDispositionValue) |
|
238 { |
|
239 __ASSERT_ALWAYS(iFlatData!=NULL, User::Leave(KErrArgument)); |
|
240 FLAT_DATA(iDispositionValue) = aDispositionValue; |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CMceMsrpSource::SetFileTransferId |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 EXPORT_C void CMceMsrpSource::SetFileTransferIdL(TDes8& aId) |
|
248 { |
|
249 __ASSERT_ALWAYS(iFlatData!=NULL, User::Leave(KErrArgument)); |
|
250 //Set Current time as transferid (Which is unique) |
|
251 TTime transferId; |
|
252 transferId.HomeTime(); |
|
253 aId.AppendNum(transferId.Int64()); |
|
254 FLAT_DATA(iFileTransferid) = aId; |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CMceMsrpSource::SetInformationAttr |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 EXPORT_C void CMceMsrpSource::SetInformationAttrL(const TDes8& aInfo) |
|
262 { |
|
263 __ASSERT_ALWAYS(iFlatData!=NULL, User::Leave(KErrArgument)); |
|
264 if (static_cast<CMceComMsrpSource*>(iFlatData)->iSessInfo != NULL) |
|
265 { |
|
266 delete static_cast<CMceComMsrpSource*>(iFlatData)->iSessInfo; |
|
267 static_cast<CMceComMsrpSource*>(iFlatData)->iSessInfo = NULL; |
|
268 } |
|
269 static_cast<CMceComMsrpSource*>(iFlatData)->iSessInfo = aInfo.Alloc(); |
|
270 } |
|
271 |
|
272 |
|
273 // ----------------------------------------------------------------------------- |
|
274 // CMceMsrpSource::InitializeL |
|
275 // ----------------------------------------------------------------------------- |
|
276 // |
|
277 void CMceMsrpSource::InitializeL( CMceMediaStream& aParent ) |
|
278 { |
|
279 MCECLI_DEBUG(" \n CMceMsrpSource::InitializeL : Entry"); |
|
280 CMceMediaSource::InitializeL(aParent); |
|
281 |
|
282 RPointerArray<TUriC8>& msrpPath= Path(); |
|
283 MCECLI_DEBUG_DVALUE("\n CMceMsrpSource::InitializeL: Msrp path count is: ", msrpPath.Count()); |
|
284 if (msrpPath.Count() > 0 ) |
|
285 { |
|
286 SetPortFromPathAttrL(* (msrpPath[msrpPath.Count()-1]) , |
|
287 static_cast<CMceMessageStream&> (aParent) ); |
|
288 } |
|
289 MCECLI_DEBUG("\n CMceMsrpSource::InitializeL : Exit"); |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CMceMsrpSource::InitializeL |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 void CMceMsrpSource::SetPortFromPathAttrL(TUriC8& aMsrpUri, CMceMessageStream& aStream) |
|
297 { |
|
298 __ASSERT_ALWAYS(aStream.Type() == KMceMessage, User::Leave(KErrArgument)); |
|
299 |
|
300 MCECLI_DEBUG("\n CMceMsrpSource::SetHostAddrPortFromPathAttr : Entry"); |
|
301 TUriParser8 parser; |
|
302 TInt parseValue = parser.Parse(aMsrpUri.UriDes()); |
|
303 MCECLI_DEBUG_DVALUE("\n CMceMsrpSource::SetHostAddrPortFromPathAttr: Parsed return value for MSRP URI: ", |
|
304 parseValue); |
|
305 |
|
306 TBuf8<50> host = parser.Extract(EUriHost); |
|
307 TBuf8<10> portBuf = parser.Extract(EUriPort); |
|
308 TInt Port; |
|
309 |
|
310 TBuf16<10> portBuf16; |
|
311 portBuf16.Copy(portBuf); |
|
312 TLex lex(portBuf16); |
|
313 lex.Val(Port); // returns the port value |
|
314 // Set media port |
|
315 aStream.SetLocalMediaPortL(Port); |
|
316 if (aStream.BoundStream()) |
|
317 { |
|
318 aStream.BoundStreamL().SetLocalMediaPortL(Port); |
|
319 } |
|
320 MCECLI_DEBUG_DVALUE("\n CMceMsrpSource::SetHostAddrPortFromPathAttr: Media port is : ", |
|
321 Port); |
|
322 MCECLI_DEBUG("\n CMceMsrpSource::SetHostAddrPortFromPathAttr : Exit"); |
|
323 } |
|
324 |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // CMceMsrpSource::InitializeL |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 EXPORT_C void CMceMsrpSource::SetPathToSaveReceivedFile(const TDesC16& aFilePath) |
|
331 { |
|
332 if (FLAT_DATA(iFilePath) != NULL ) |
|
333 { |
|
334 delete FLAT_DATA(iFilePath); |
|
335 FLAT_DATA(iFilePath) = NULL; |
|
336 } |
|
337 FLAT_DATA(iFilePath) = aFilePath.Alloc(); |
|
338 } |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // CMceMsrpSource::InitializeL |
|
342 // ----------------------------------------------------------------------------- |
|
343 // |
|
344 EXPORT_C void CMceMsrpSource::EnableFileTransferProgressNotifications(TBool enableFlag) |
|
345 { |
|
346 FLAT_DATA(iFTProgressNotification) = enableFlag; |
|
347 } |