|
1 /** @file |
|
2 * Copyright (c) 2005-2006 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: Media Server Client |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "upnpmediaserverclient.h" |
|
21 #include "upnpmediaserverglobals.h" |
|
22 #include "upnpmediaserversettings.h" |
|
23 #include "upnpicon.h" |
|
24 |
|
25 // Number of message slots to reserve for this client server session. |
|
26 const TUint KMediaServerMessageSlots = 10; |
|
27 const TInt KMediaServerRetryCount = 2; |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // RUpnpMediaServerClient::RUpnpMediaServerClient |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 EXPORT_C RUpnpMediaServerClient::RUpnpMediaServerClient() |
|
36 :RUpnpSessionBase() |
|
37 { |
|
38 iAddressPkg = NULL; |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // RUpnpMediaServerClient::RUpnpMediaServerClient |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C void RUpnpMediaServerClient::Close() |
|
46 { |
|
47 delete iAddressPkg; |
|
48 iAddressPkg = NULL; |
|
49 RSessionBase::Close(); |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // RUpnpMediaServerClient::Connect |
|
54 // Connect to Media Server session. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C TInt RUpnpMediaServerClient::Connect() |
|
58 { |
|
59 return RUpnpSessionBase::Connect( KMediaServerName, |
|
60 TVersion( KMediaServerMajorVersionNumber, |
|
61 KMediaServerMinorVersionNumber, |
|
62 KMediaServerBuildVersionNumber ), |
|
63 KMediaServerMessageSlots, |
|
64 KMediaServerRetryCount, |
|
65 KMediaServerFilename, |
|
66 KServerUid3 ); |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // RUpnpMediaServerClient::Status |
|
71 // Gets media server operational status |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 EXPORT_C TInt RUpnpMediaServerClient::Status(TInt& aStat) |
|
75 { |
|
76 TPckgBuf<TInt> statusBuf(aStat); |
|
77 TIpcArgs args(&statusBuf); |
|
78 TInt error = SendReceive(EMediaServerStatus, args); |
|
79 aStat = statusBuf(); |
|
80 return error; |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // RUpnpMediaServerClient::Start |
|
85 // Client requests server to terminate its process |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C TInt RUpnpMediaServerClient::Start() |
|
89 { |
|
90 return SendReceive( EMediaServerStart ); |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // RUpnpMediaServerClient::Start |
|
95 // Client requests server to terminate its process (asynchonous version) |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 EXPORT_C void RUpnpMediaServerClient::Start(TRequestStatus& aStatus) |
|
99 { |
|
100 SendReceive( EMediaServerStart,aStatus); |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // RUpnpMediaServerClient::Start |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 EXPORT_C TInt RUpnpMediaServerClient::StartOffline() |
|
108 { |
|
109 return SendReceive( EMediaServerStartOffline); |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // RUpnpMediaServerClient::Stop |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C TInt RUpnpMediaServerClient::Stop() |
|
117 { |
|
118 return SendReceive( EMediaServerStop ); |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // RUpnpMediaServerClient::Stop |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 EXPORT_C TInt RUpnpMediaServerClient::Stop( TServerStopMode aMode ) |
|
126 { |
|
127 TInt error = 0; |
|
128 if ( aMode == EStopSilent) |
|
129 { |
|
130 error = SendReceive( EMediaServerStopSilent ); |
|
131 } |
|
132 else if ( aMode == EStopNormal) |
|
133 { |
|
134 error = SendReceive( EMediaServerStop ); |
|
135 } |
|
136 return error; |
|
137 } |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // RUpnpMediaServerClient::Stop |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 EXPORT_C TInt RUpnpMediaServerClient::Restart() |
|
144 { |
|
145 return SendReceive( EMediaServerRestart ); |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // RUpnpMediaServerClient::Stop |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 EXPORT_C TInt RUpnpMediaServerClient::GetAddress(TInetAddr& aAddr) |
|
153 { |
|
154 TPckg<TInetAddr> pkg(aAddr); |
|
155 TIpcArgs args(&pkg); |
|
156 return SendReceive( EMediaServerGetIpAndPort, args ); |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // RUpnpMediaServerClient::Stop |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 EXPORT_C void RUpnpMediaServerClient::GetAddressL(TInetAddr& aAddr, |
|
164 TRequestStatus& aStatus) |
|
165 { |
|
166 delete iAddressPkg; |
|
167 iAddressPkg = NULL; |
|
168 iAddressPkg = new (ELeave) TPckg<TInetAddr>(aAddr); |
|
169 TIpcArgs args(iAddressPkg); |
|
170 SendReceive( EMediaServerGetIpAndPort, args, aStatus ); |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // RUpnpMediaServerClient::SetUploadDirectoryL |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 EXPORT_C void RUpnpMediaServerClient::SetUploadDirectoryL( const TDesC& aPath, |
|
178 TRequestStatus& aStatus ) |
|
179 { |
|
180 CUpnpMediaServerSettings* settings = CUpnpMediaServerSettings::NewL(); |
|
181 CleanupStack::PushL( settings ); |
|
182 User::LeaveIfError( settings->Set(UpnpMediaServerSettings::EUploadDirectory, aPath) ); |
|
183 CleanupStack::PopAndDestroy( settings ); |
|
184 |
|
185 TIpcArgs args; |
|
186 args.Set(0, &aPath); |
|
187 SendReceive( EMediaServerSetUploadDirectory, args, aStatus ); |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // RUpnpMediaServerClient::ShareItem |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 void RUpnpMediaServerClient::GetSharedItem( TInt aItemId, |
|
195 TDes8& aRcvdBufSize, |
|
196 TRequestStatus& aStatus ) |
|
197 { |
|
198 TIpcArgs args(aItemId, &aRcvdBufSize); |
|
199 SendReceive(EMediaServerGetSharedItem, args, aStatus); |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // RUpnpMediaServerClient::ShareItemL |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 void RUpnpMediaServerClient::GetSharedItemResult(TDes8& aResult, |
|
207 TRequestStatus& aStatus) |
|
208 { |
|
209 TIpcArgs args(&aResult); |
|
210 SendReceive(EMediaServerGetSharedItemResult, args, aStatus); |
|
211 } |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // RUpnpMediaServerClient::ShareContainer |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 void RUpnpMediaServerClient::GetSharedContainer( TInt aContainerId, |
|
218 TDes8& aRcvdBufSize, |
|
219 TRequestStatus& aStatus ) |
|
220 { |
|
221 TIpcArgs args(aContainerId, &aRcvdBufSize); |
|
222 SendReceive(EMediaServerGetSharedContainer, args, aStatus); |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // RUpnpMediaServerClient::ShareContainer |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 void RUpnpMediaServerClient::GetSharedContainerResult(TDes8& aResult, |
|
230 TRequestStatus& aStatus) |
|
231 { |
|
232 TIpcArgs args(&aResult); |
|
233 SendReceive(EMediaServerGetSharedContainerResult, args, aStatus); |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // RUpnpMediaServerClient::ShareItem |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 void RUpnpMediaServerClient::ShareItem( TDes8& aSend, |
|
241 TDes8& aRcvdBufSize, |
|
242 TRequestStatus& aStatus) |
|
243 { |
|
244 TIpcArgs args(&aSend, &aRcvdBufSize); |
|
245 SendReceive(EMediaServerShareItem, args, aStatus); |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // RUpnpMediaServerClient::AddIcon |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 EXPORT_C void RUpnpMediaServerClient::AddIcon( CUpnpIcon* aIcon, TRequestStatus& aStatus) |
|
253 { |
|
254 TIpcArgs args(&aIcon->GetIconBufferPtr()); |
|
255 SendReceive(EMediaServerAddIcon, args, aStatus); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // RUpnpMediaServerClient::UpdateIcon |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 EXPORT_C void RUpnpMediaServerClient::UpdateIcon( TDes8& aSend, CUpnpIcon* aIcon, |
|
263 TRequestStatus& aStatus ) |
|
264 { |
|
265 TIpcArgs args(&aIcon->GetIconBufferPtr(), &aSend); |
|
266 SendReceive(EMediaServerUpdateIcon, args, aStatus); |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // RUpnpMediaServerClient::RemoveIcon |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 EXPORT_C void RUpnpMediaServerClient::RemoveIcon( TDes8& aSend, TRequestStatus& aStatus) |
|
274 { |
|
275 TIpcArgs args(&aSend); |
|
276 SendReceive(EMediaServerRemoveIcon, args, aStatus); |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // RUpnpMediaServerClient::RemoveIcons |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 EXPORT_C void RUpnpMediaServerClient::RemoveIcons( TRequestStatus& aStatus) |
|
284 { |
|
285 TIpcArgs args(NULL); |
|
286 SendReceive(EMediaServerRemoveIcons, args, aStatus); |
|
287 } |
|
288 |
|
289 // ----------------------------------------------------------------------------- |
|
290 // RUpnpMediaServerClient::ShareItemResult |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 void RUpnpMediaServerClient::ShareItemResult( TDes8& aResult, |
|
294 TRequestStatus& aStatus) |
|
295 { |
|
296 TIpcArgs args(&aResult); |
|
297 SendReceive(EMediaServerShareItemResult, args, aStatus); |
|
298 } |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // RUpnpMediaServerClient::ShareContainer |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 void RUpnpMediaServerClient::ShareContainer( TDes8& aSend, |
|
305 TDes8& aRcvdBufSize, |
|
306 TRequestStatus& aStatus) |
|
307 { |
|
308 TIpcArgs args(&aSend, &aRcvdBufSize); |
|
309 SendReceive(EMediaServerShareContainer, args, aStatus); |
|
310 } |
|
311 |
|
312 // ----------------------------------------------------------------------------- |
|
313 // RUpnpMediaServerClient::ShareContainerResult |
|
314 // ----------------------------------------------------------------------------- |
|
315 // |
|
316 void RUpnpMediaServerClient::ShareContainerResult( TDes8& aResult, |
|
317 TRequestStatus& aStatus) |
|
318 { |
|
319 TIpcArgs args(&aResult); |
|
320 SendReceive(EMediaServerShareContainerResult, args, aStatus); |
|
321 } |
|
322 |
|
323 // ----------------------------------------------------------------------------- |
|
324 // RUpnpMediaServerClient::ShareItemL |
|
325 // ----------------------------------------------------------------------------- |
|
326 // |
|
327 void RUpnpMediaServerClient::ShareItemList( TDes8& aSend, |
|
328 TDes8& aRcvdBufSize, |
|
329 TRequestStatus& aStatus) |
|
330 { |
|
331 TIpcArgs args(&aSend, &aRcvdBufSize); |
|
332 SendReceive(EMediaServerShareItemList, args, aStatus); |
|
333 } |
|
334 |
|
335 // ----------------------------------------------------------------------------- |
|
336 // RUpnpMediaServerClient::ShareItemListResult |
|
337 // ----------------------------------------------------------------------------- |
|
338 // |
|
339 void RUpnpMediaServerClient::ShareItemListResult( TDes8& aResult, |
|
340 TDes8& aExecStatus, |
|
341 TRequestStatus& aStatus) |
|
342 { |
|
343 TIpcArgs args(&aResult, &aExecStatus); |
|
344 SendReceive(EMediaServerShareItemListResult, args, aStatus); |
|
345 } |
|
346 |
|
347 // ----------------------------------------------------------------------------- |
|
348 // RUpnpMediaServerClient::UnShareRoot |
|
349 // ----------------------------------------------------------------------------- |
|
350 // |
|
351 void RUpnpMediaServerClient::UnshareRoot(TRequestStatus& aStatus) |
|
352 { |
|
353 SendReceive(EMediaServerUnshareRoot, aStatus); |
|
354 } |
|
355 |
|
356 // ----------------------------------------------------------------------------- |
|
357 // RUpnpMediaServerClient::UnShareItemL |
|
358 // ----------------------------------------------------------------------------- |
|
359 // |
|
360 void RUpnpMediaServerClient::UnshareItem(TInt aItemId, TRequestStatus& aStatus) |
|
361 { |
|
362 TIpcArgs args(aItemId); |
|
363 SendReceive(EMediaServerUnshareItem, args, aStatus); |
|
364 } |
|
365 |
|
366 // ----------------------------------------------------------------------------- |
|
367 // RUpnpMediaServerClient::UnShareContainerL |
|
368 // ----------------------------------------------------------------------------- |
|
369 // |
|
370 void RUpnpMediaServerClient::UnshareContainer(TInt aItemId, TRequestStatus& aStatus) |
|
371 { |
|
372 TIpcArgs args(aItemId); |
|
373 SendReceive(EMediaServerUnshareContainer, args, aStatus); |
|
374 } |
|
375 |
|
376 // ----------------------------------------------------------------------------- |
|
377 // RUpnpMediaServerClient::UnshareItemListL |
|
378 // ----------------------------------------------------------------------------- |
|
379 void RUpnpMediaServerClient::UnshareItemListL(TDes8& aSend, TDes8& aExecStatus, |
|
380 TRequestStatus& aStatus) |
|
381 { |
|
382 TIpcArgs args(&aSend, &aExecStatus); |
|
383 SendReceive(EMediaServerUnshareItemList, args, aStatus); |
|
384 } |
|
385 |
|
386 // ----------------------------------------------------------------------------- |
|
387 // RUpnpMediaServerClient::GetSharedItemList |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 void RUpnpMediaServerClient::GetSharedItemList(TInt aContainerId, TDes8& aSend, |
|
391 TDes8& aRcvdBufSize, TRequestStatus& aStatus) |
|
392 { |
|
393 TIpcArgs args(aContainerId, &aSend, &aRcvdBufSize); |
|
394 SendReceive(EMediaServerGetSharedItemList, args, aStatus); |
|
395 } |
|
396 // ----------------------------------------------------------------------------- |
|
397 // RUpnpMediaServerClient::GetSharedItemList |
|
398 // ----------------------------------------------------------------------------- |
|
399 // |
|
400 void RUpnpMediaServerClient::GetSharedContainerList(TInt aContainerId, TDes8& aSend, |
|
401 TDes8& aRcvdBufSize, TRequestStatus& aStatus) |
|
402 { |
|
403 TIpcArgs args(aContainerId, &aSend, &aRcvdBufSize); |
|
404 SendReceive(EMediaServerGetSharedContainerList, args, aStatus); |
|
405 } |
|
406 // ----------------------------------------------------------------------------- |
|
407 // RUpnpMediaServerClient::GetSharedItemList |
|
408 // ----------------------------------------------------------------------------- |
|
409 // |
|
410 void RUpnpMediaServerClient::GetSharedItemListResult(TDes8& aResult, TDes8& aTotalMatches, |
|
411 TRequestStatus& aStatus) |
|
412 { |
|
413 TIpcArgs args(&aResult, &aTotalMatches); |
|
414 SendReceive(EMediaServerGetSharedItemListResult, args, aStatus); |
|
415 } |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
|
418 // RUpnpMediaServerClient::GetSharedContainerList |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 void RUpnpMediaServerClient::GetSharedContainerListResult(TDes8& aResult, TDes8& aTotalMatches, |
|
422 TRequestStatus& aStatus) |
|
423 { |
|
424 TIpcArgs args(&aResult, &aTotalMatches); |
|
425 SendReceive(EMediaServerGetSharedContainerListResult, args, aStatus); |
|
426 } |
|
427 |
|
428 // ----------------------------------------------------------------------------- |
|
429 // RUpnpMediaServerClient::ShareReference |
|
430 // ----------------------------------------------------------------------------- |
|
431 // |
|
432 void RUpnpMediaServerClient::ShareReference( TDes8& aSend, |
|
433 TDes8& aRcvdBufSize, |
|
434 TRequestStatus& aStatus ) |
|
435 { |
|
436 TIpcArgs args(&aSend, &aRcvdBufSize); |
|
437 SendReceive(EMediaServerShareReference, args, aStatus); |
|
438 } |
|
439 |
|
440 // ----------------------------------------------------------------------------- |
|
441 // RUpnpMediaServerClient::ShareReferenceList |
|
442 // ----------------------------------------------------------------------------- |
|
443 // |
|
444 void RUpnpMediaServerClient::ShareReferenceList( TDes8& aSend, |
|
445 TDes8& aRcvdBufSize, |
|
446 TRequestStatus& aStatus ) |
|
447 { |
|
448 TIpcArgs args(&aSend, &aRcvdBufSize); |
|
449 SendReceive(EMediaServerShareReferenceList, args, aStatus); |
|
450 } |
|
451 |
|
452 // ----------------------------------------------------------------------------- |
|
453 // RUpnpMediaServerClient::SubscribeEvents |
|
454 // ----------------------------------------------------------------------------- |
|
455 // |
|
456 void RUpnpMediaServerClient::SubscribeEvents(TRequestStatus& aStatus) |
|
457 { |
|
458 SendReceive(EMediaServerSubscribeEvents, aStatus); |
|
459 } |
|
460 |
|
461 // ----------------------------------------------------------------------------- |
|
462 // RUpnpMediaServerClient::UnsubscribeEvents |
|
463 // ----------------------------------------------------------------------------- |
|
464 // |
|
465 void RUpnpMediaServerClient::UnsubscribeEvents() |
|
466 { |
|
467 SendReceive(EMediaServerUnsubscribeEvents); |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // RUpnpMediaServerClient::ListenTransferEvent |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 void RUpnpMediaServerClient::ListenTransferEvent(TDes8& aEventSize, TRequestStatus& aStatus) |
|
475 { |
|
476 TIpcArgs args(&aEventSize); |
|
477 SendReceive(EMediaServerListenTransferEvent, args, aStatus); |
|
478 } |
|
479 |
|
480 // ----------------------------------------------------------------------------- |
|
481 // RUpnpMediaServerClient::GetTransferEventBody |
|
482 // ----------------------------------------------------------------------------- |
|
483 // |
|
484 void RUpnpMediaServerClient::GetTransferEventBody(TDes8& aResult, TRequestStatus& aStatus) |
|
485 { |
|
486 TIpcArgs args(&aResult); |
|
487 SendReceive(EMediaServerGetTransferEventBody, args, aStatus); |
|
488 } |
|
489 |
|
490 // ----------------------------------------------------------------------------- |
|
491 // RUpnpMediaServerClient::Status |
|
492 // Notify about media server operational status |
|
493 // ----------------------------------------------------------------------------- |
|
494 // |
|
495 void RUpnpMediaServerClient::StatusChangeNotify( TRequestStatus& aStatus ) |
|
496 { |
|
497 SendReceive( EMediaServerStatusChange, TIpcArgs(), aStatus ); |
|
498 } |
|
499 |
|
500 // ----------------------------------------------------------------------------- |
|
501 // RUpnpMediaServerClient::CancelStatusChanged |
|
502 // Cancel notification to ms status |
|
503 // ----------------------------------------------------------------------------- |
|
504 // |
|
505 void RUpnpMediaServerClient::CancelStatusChangeNotify() |
|
506 { |
|
507 SendReceive( EMediaServerStatusChangeCancel ); |
|
508 } |
|
509 |