1 /* |
|
2 * Copyright (c) 2008 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: CUPnPFileSharingEngine class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // Include Files |
|
21 #include "contentmanager.h" |
|
22 #include "msengine.h" |
|
23 #include "msengineao.h" |
|
24 #include "msdebug.h" |
|
25 |
|
26 |
|
27 // -------------------------------------------------------------------------- |
|
28 // CMSEngine::CMSEngine |
|
29 // -------------------------------------------------------------------------- |
|
30 // |
|
31 CMSEngine::CMSEngine() |
|
32 { |
|
33 LOG( _L("[MediaServant ENG]\t CMSEngine::CMSEngine") ); |
|
34 } |
|
35 |
|
36 |
|
37 // -------------------------------------------------------------------------- |
|
38 // CMSEngine::NewLC |
|
39 // -------------------------------------------------------------------------- |
|
40 // |
|
41 EXPORT_C CMSEngine* CMSEngine::NewLC() |
|
42 { |
|
43 LOG( _L("[MediaServant ENG]\t CMSEngine::NewLC") ); |
|
44 |
|
45 CMSEngine* self = new (ELeave) CMSEngine; |
|
46 CleanupStack::PushL( self ); |
|
47 self->ConstructL(); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // -------------------------------------------------------------------------- |
|
52 // CMSEngine::NewL |
|
53 // -------------------------------------------------------------------------- |
|
54 // |
|
55 EXPORT_C CMSEngine* CMSEngine::NewL() |
|
56 { |
|
57 LOG( _L("[MediaServant ENG]\t CMSEngine::NewL") ); |
|
58 |
|
59 CMSEngine* self = CMSEngine::NewLC(); |
|
60 CleanupStack::Pop( self ); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // -------------------------------------------------------------------------- |
|
65 // CMSEngine::ConstructL |
|
66 // -------------------------------------------------------------------------- |
|
67 // |
|
68 void CMSEngine::ConstructL() |
|
69 { |
|
70 LOG( _L("[MediaServant ENG]\t CMSEngine::ConstructL") ); |
|
71 |
|
72 // Open Content manager server |
|
73 OpenServerSession(); |
|
74 |
|
75 // Create active object |
|
76 iAO = CMSEngineAO::NewL( this ); |
|
77 } |
|
78 |
|
79 // -------------------------------------------------------------------------- |
|
80 // CMSEngine::~CMSEngine |
|
81 // -------------------------------------------------------------------------- |
|
82 // |
|
83 CMSEngine::~CMSEngine() |
|
84 { |
|
85 LOG( _L("[MediaServant ENG]\t CMSEngine::~CMSEngine") ); |
|
86 |
|
87 TCmServerState state; |
|
88 ServerState( state ); |
|
89 |
|
90 if ( state != ECmServerStateIdle ) |
|
91 { |
|
92 LOG( _L( "[MediaServant]\t CMSEngine::\ |
|
93 ~CMSEngine cancel operation" ) ); |
|
94 |
|
95 // notify server that observer is shutting down |
|
96 if( iAO ) |
|
97 { |
|
98 iAO->ApplicationExit(); |
|
99 } |
|
100 } |
|
101 |
|
102 // Close Content manager server |
|
103 CloseServerSession(); |
|
104 |
|
105 delete iAO; |
|
106 } |
|
107 |
|
108 // -------------------------------------------------------------------------- |
|
109 // CMSEngine::ScanMediaServersL |
|
110 // -------------------------------------------------------------------------- |
|
111 // |
|
112 EXPORT_C TInt CMSEngine::ScanMediaServersL() |
|
113 { |
|
114 LOG( _L("[MediaServant ENG]\t CMSEngine::ScanMediaServersL") ); |
|
115 |
|
116 TInt error = iAO->ScanMediaServersL(); |
|
117 |
|
118 return error; |
|
119 } |
|
120 |
|
121 // -------------------------------------------------------------------------- |
|
122 // CMSEngine::ExecuteSyncL |
|
123 // -------------------------------------------------------------------------- |
|
124 // |
|
125 EXPORT_C TInt CMSEngine::ExecuteSyncL() |
|
126 { |
|
127 LOG( _L("[MediaServant ENG]\t CMSEngine::ExecuteSyncL") ); |
|
128 |
|
129 // Fill will be started when store is ready. |
|
130 TInt error = iAO->ExecuteStoreL(); |
|
131 |
|
132 return error; |
|
133 } |
|
134 |
|
135 // -------------------------------------------------------------------------- |
|
136 // CMSEngine::ExecuteStorePreProcessingL |
|
137 // -------------------------------------------------------------------------- |
|
138 // |
|
139 EXPORT_C TInt CMSEngine::ExecuteStorePreProcessingL() |
|
140 { |
|
141 LOG( _L("[MediaServant ENG]\t CMSEngine::ExecuteStorePreProcessingL") ); |
|
142 |
|
143 TInt error = iAO->ExecuteStorePreProcessingL(); |
|
144 |
|
145 return error; |
|
146 } |
|
147 |
|
148 // -------------------------------------------------------------------------- |
|
149 // CMSEngine::ExecuteFillPreProcessingL |
|
150 // -------------------------------------------------------------------------- |
|
151 // |
|
152 EXPORT_C TInt CMSEngine::ExecuteFillPreProcessingL() |
|
153 { |
|
154 LOG( _L("[MediaServant ENG]\t CMSEngine::ExecuteFillPreProcessingL") ); |
|
155 |
|
156 TInt error = iAO->ExecuteFillPreProcessingL(); |
|
157 |
|
158 return error; |
|
159 } |
|
160 |
|
161 // -------------------------------------------------------------------------- |
|
162 // CMSEngine::GetStoreListItemsL |
|
163 // -------------------------------------------------------------------------- |
|
164 // |
|
165 EXPORT_C RPointerArray<CCmBaseListItem>* CMSEngine::GetStoreListItemsL( |
|
166 TDesC8& aRuleName) |
|
167 { |
|
168 LOG(_L("[MediaServant ENG]\t CMSEngine::GetStoreListItemsL")); |
|
169 |
|
170 RPointerArray<CCmBaseListItem>* storeListItems = NULL; |
|
171 if ( &iCMServer ) |
|
172 { |
|
173 storeListItems = iCMServer.ListItemsL( aRuleName, ECmServiceStore ); |
|
174 } |
|
175 |
|
176 return storeListItems; |
|
177 } |
|
178 |
|
179 // -------------------------------------------------------------------------- |
|
180 // CMSEngine::GetFillListItemsL |
|
181 // -------------------------------------------------------------------------- |
|
182 // |
|
183 EXPORT_C RPointerArray<CCmBaseListItem>* CMSEngine::GetFillListItemsL( |
|
184 TDesC8& aRuleName) |
|
185 { |
|
186 LOG(_L("[MediaServant ENG]\t CMSEngine::GetFillListItemsL")); |
|
187 |
|
188 RPointerArray<CCmBaseListItem>* fillListItems = NULL; |
|
189 |
|
190 fillListItems = iCMServer.ListItemsL( aRuleName, ECmServiceFill ); |
|
191 |
|
192 return fillListItems; |
|
193 } |
|
194 |
|
195 // -------------------------------------------------------------------------- |
|
196 // CMSEngine::StopOperation |
|
197 // -------------------------------------------------------------------------- |
|
198 // |
|
199 EXPORT_C void CMSEngine::StopOperation() |
|
200 { |
|
201 LOG( _L("[MediaServant ENG]\t CMSEngine::StopOperation") ); |
|
202 |
|
203 iAO->StopOperation(); |
|
204 } |
|
205 |
|
206 // -------------------------------------------------------------------------- |
|
207 // CMSEngine::FillRulesL |
|
208 // -------------------------------------------------------------------------- |
|
209 // |
|
210 EXPORT_C CCmFillRuleContainer* CMSEngine::FillRulesL() |
|
211 { |
|
212 LOG( _L("[MediaServant ENG]\t CMSEngine::FillRulesL") ); |
|
213 |
|
214 return ( iCMServer.FillRulesL() ); |
|
215 } |
|
216 |
|
217 // -------------------------------------------------------------------------- |
|
218 // CMSEngine::StoreRulesL |
|
219 // -------------------------------------------------------------------------- |
|
220 // |
|
221 EXPORT_C CCmStoreRuleContainer* CMSEngine::StoreRulesL() |
|
222 { |
|
223 LOG( _L("[MediaServant ENG]\t CMSEngine::StoreRulesL") ); |
|
224 |
|
225 return ( iCMServer.StoreRulesL() ); |
|
226 } |
|
227 |
|
228 // -------------------------------------------------------------------------- |
|
229 // CMSEngine::SetStoreRulesL |
|
230 // -------------------------------------------------------------------------- |
|
231 // |
|
232 EXPORT_C void CMSEngine::SetStoreRulesL( CCmStoreRuleContainer* aStoreRules ) |
|
233 { |
|
234 LOG( _L("[MediaServant ENG]\t CMSEngine::SetStoreRulesL") ); |
|
235 |
|
236 iCMServer.SetStoreRulesL( *aStoreRules ); |
|
237 } |
|
238 |
|
239 // -------------------------------------------------------------------------- |
|
240 // CMSEngine::SetFillRulesL |
|
241 // -------------------------------------------------------------------------- |
|
242 // |
|
243 EXPORT_C void CMSEngine::SetFillRulesL( CCmFillRuleContainer* aFillRules ) |
|
244 { |
|
245 LOG( _L("[MediaServant ENG]\t CMSEngine::SetFillRulesL") ); |
|
246 |
|
247 iCMServer.SetFillRulesL( *aFillRules ); |
|
248 } |
|
249 |
|
250 // -------------------------------------------------------------------------- |
|
251 // CMSEngine::GetFilledFilesSize |
|
252 // Get filled files size |
|
253 // -------------------------------------------------------------------------- |
|
254 // |
|
255 EXPORT_C void CMSEngine::GetFilledFilesSize( TInt64& aSize, const TInt aID ) |
|
256 { |
|
257 LOG( _L("[MediaServant ENG]\t CMSEngine::GetFilledFilesSize") ); |
|
258 |
|
259 iCMServer.GetFilledFilesSize( aSize, aID ); |
|
260 } |
|
261 |
|
262 // CMSEngine::ServerState |
|
263 // -------------------------------------------------------------------------- |
|
264 // |
|
265 EXPORT_C void CMSEngine::ServerState( TCmServerState& aState ) |
|
266 { |
|
267 LOG( _L("[MediaServant ENG]\t CMSEngine::ServerState") ); |
|
268 |
|
269 aState = iCMServer.ServerState(); |
|
270 } |
|
271 |
|
272 // ------------------------------------------------------------------------- |
|
273 // CMSEngine::ServiceState |
|
274 // -------------------------------------------------------------------------- |
|
275 EXPORT_C TCmServiceState CMSEngine::ServiceState( const TCmService aService ) |
|
276 { |
|
277 LOG( _L("[MediaServant ENG]\t CMSEngine::ServiceState") ); |
|
278 |
|
279 TCmServiceState state; |
|
280 |
|
281 state = iCMServer.ServiceState( aService ); |
|
282 |
|
283 return state; |
|
284 } |
|
285 |
|
286 // ------------------------------------------------------------------------- |
|
287 // CMSEngine::SetServiceState |
|
288 // -------------------------------------------------------------------------- |
|
289 EXPORT_C TInt CMSEngine::SetServiceState( const TCmService aService, |
|
290 TCmServiceState aState ) |
|
291 { |
|
292 LOG( _L("[MediaServant ENG]\t CMSEngine::SetServiceState") ); |
|
293 |
|
294 TInt error = iCMServer.SetServiceState( aService, aState ); |
|
295 |
|
296 return error; |
|
297 } |
|
298 |
|
299 // -------------------------------------------------------------------------- |
|
300 // CMSEngine::MediaServersL |
|
301 // -------------------------------------------------------------------------- |
|
302 // |
|
303 EXPORT_C RPointerArray<CCmMediaServerFull>* |
|
304 CMSEngine::GetMediaServersL() |
|
305 { |
|
306 LOG(_L("[MediaServant ENG]\t CMSEngine::GetMediaServersL")); |
|
307 |
|
308 return ( iCMServer.MediaserversL() ); |
|
309 } |
|
310 |
|
311 // -------------------------------------------------------------------------- |
|
312 // CMSEngine::SetMediaServersL |
|
313 // -------------------------------------------------------------------------- |
|
314 // |
|
315 EXPORT_C TInt CMSEngine::SetMediaServersL( |
|
316 RPointerArray<CCmMediaServerFull>& aMediaServers ) |
|
317 { |
|
318 |
|
319 LOG( _L("[MediaServant ENG]\t CMSEngine::SetMediaServersL") ); |
|
320 |
|
321 TInt error = iCMServer.SetMediaserversL( aMediaServers ); |
|
322 |
|
323 return error; |
|
324 } |
|
325 |
|
326 |
|
327 // -------------------------------------------------------------------------- |
|
328 // CMSEngine::DeleteDeletedMediaserversL |
|
329 // -------------------------------------------------------------------------- |
|
330 // |
|
331 EXPORT_C void CMSEngine::DeleteDeletedMediaserversL() |
|
332 { |
|
333 LOG( _L("[MediaServant ENG]\t CMSEngine::DeleteDeletedMediaserversL") ); |
|
334 |
|
335 iCMServer.DeleteDeletedMediaserversL(); |
|
336 } |
|
337 |
|
338 |
|
339 // -------------------------------------------------------------------------- |
|
340 // CMSEngine::DeleteFilledFiles |
|
341 // -------------------------------------------------------------------------- |
|
342 // |
|
343 EXPORT_C TInt CMSEngine::DeleteFilledFilesL() |
|
344 { |
|
345 LOG( _L("[MediaServant ENG]\t CMSEngine::DeleteFilledFilesL") ); |
|
346 |
|
347 TInt error = iAO->DeleteFilledFilesL(); |
|
348 |
|
349 return error; |
|
350 } |
|
351 |
|
352 // -------------------------------------------------------------------------- |
|
353 // CMSEngine::GetItemCountsL |
|
354 // -------------------------------------------------------------------------- |
|
355 // |
|
356 EXPORT_C TInt CMSEngine::GetItemCountsL( const TCmService aService, |
|
357 const TDesC8& aListName, |
|
358 TInt& aCount, |
|
359 TInt64& aSize ) const |
|
360 { |
|
361 LOG( _L("[MediaServant ENG]\t CMSEngine::GetItemCountsL") ); |
|
362 |
|
363 TInt error = iCMServer.GetItemCountsL( aService, |
|
364 aListName, |
|
365 aCount, |
|
366 aSize ); |
|
367 |
|
368 return error; |
|
369 } |
|
370 |
|
371 // -------------------------------------------------------------------------- |
|
372 // CMSEngine::GetFilteredMetadataL |
|
373 // -------------------------------------------------------------------------- |
|
374 // |
|
375 EXPORT_C void CMSEngine::GetFilteredMetadataL( |
|
376 CCmSqlPropertyCollector*& aCollector ) |
|
377 { |
|
378 LOG(_L("[MediaServant ENG]\t CMSEngine::GetFilteredMetadataL")); |
|
379 |
|
380 iAO->GetFilteredMetadataL( aCollector ); |
|
381 } |
|
382 |
|
383 // -------------------------------------------------------------------------- |
|
384 // CMSEngine::PreProcessFillList |
|
385 // -------------------------------------------------------------------------- |
|
386 // |
|
387 EXPORT_C TInt CMSEngine::PreProcessFillListL( const TDesC8& aListName ) const |
|
388 { |
|
389 LOG( _L("[MediaServant ENG]\t CMSEngine::PreProcessFillList") ); |
|
390 |
|
391 TInt error = iAO->PreProcessFillListL( aListName ); |
|
392 |
|
393 return error; |
|
394 } |
|
395 |
|
396 // -------------------------------------------------------------------------- |
|
397 // CMSEngine::UpdateFillListsL |
|
398 // -------------------------------------------------------------------------- |
|
399 // |
|
400 EXPORT_C void CMSEngine::UpdateFillListsL() const |
|
401 { |
|
402 LOG( _L("[MediaServant ENG]\t CMSEngine::UpdateFillListsL") ); |
|
403 |
|
404 iAO->UpdateFillListsL(); |
|
405 } |
|
406 |
|
407 // -------------------------------------------------------------------------- |
|
408 // CMSEngine::DeleteMetaDataL |
|
409 // -------------------------------------------------------------------------- |
|
410 // |
|
411 EXPORT_C void CMSEngine::DeleteMetadataL() const |
|
412 { |
|
413 LOG( _L("[MediaServant ENG]\t CMSEngine::DeleteMetaDataL") ); |
|
414 |
|
415 iAO->DeleteMetadataL(); |
|
416 } |
|
417 |
|
418 // -------------------------------------------------------------------------- |
|
419 // CMSEngine::GetAppWizardState |
|
420 // -------------------------------------------------------------------------- |
|
421 // |
|
422 EXPORT_C TBool CMSEngine::GetAppWizardState( TInt& /*aErrorCode*/ ) |
|
423 { |
|
424 LOG( _L("[MediaServant ENG]\t CMSEngine::GetAppWizardState") ); |
|
425 |
|
426 TBool retVal = iCMServer.AppWizardState(); |
|
427 |
|
428 return retVal; |
|
429 } |
|
430 |
|
431 |
|
432 // -------------------------------------------------------------------------- |
|
433 // CMSEngine::SetAppWizardStateL |
|
434 // -------------------------------------------------------------------------- |
|
435 // |
|
436 EXPORT_C TInt CMSEngine::SetAppWizardState() |
|
437 { |
|
438 LOG( _L("[MediaServant ENG]\t CMSEngine::SetAppWizardState") ); |
|
439 |
|
440 TInt retVal = iCMServer.SetAppWizardState(); |
|
441 |
|
442 return retVal; |
|
443 } |
|
444 |
|
445 // -------------------------------------------------------------------------- |
|
446 // CMSEngine::SetObserver |
|
447 // -------------------------------------------------------------------------- |
|
448 // |
|
449 EXPORT_C void CMSEngine::SetObserver( MMSEngineObserver* aObserver ) |
|
450 { |
|
451 LOG( _L("[MediaServant ENG]\t CMSEngine::SetObserver") ); |
|
452 |
|
453 iAO->SetObserver( aObserver ); |
|
454 } |
|
455 |
|
456 // -------------------------------------------------------------------------- |
|
457 // CMSEngine::LastSyncTime |
|
458 // -------------------------------------------------------------------------- |
|
459 // |
|
460 EXPORT_C TTime CMSEngine::LastSyncTime() const |
|
461 { |
|
462 LOG( _L("[MediaServant ENG]\t CMSEngine::LastSyncTime") ); |
|
463 |
|
464 return ( iCMServer.LastSyncTime() ); |
|
465 } |
|
466 |
|
467 // -------------------------------------------------------------------------- |
|
468 // CMSEngine::SetFillFileStatusesL |
|
469 // -------------------------------------------------------------------------- |
|
470 // |
|
471 EXPORT_C void CMSEngine::SetFillFileStatusesL( |
|
472 const RPointerArray<CCmBaseListItem>* aItems ) |
|
473 { |
|
474 LOG( _L("[MediaServant ENG]\t CMSEngine::SetFillFileStatusesL") ); |
|
475 |
|
476 iCMServer.SetFillFileStatusesL( *aItems ); |
|
477 } |
|
478 |
|
479 // -------------------------------------------------------------------------- |
|
480 // CMSEngine::GetTransferInfo |
|
481 // -------------------------------------------------------------------------- |
|
482 // |
|
483 EXPORT_C void CMSEngine::GetTransferInfo( const TCmService aService, |
|
484 TInt& aItemCount, |
|
485 TInt& aTimeInSec ) const |
|
486 { |
|
487 LOG( _L("[MediaServant ENG]\t CMSEngine::GetTransferInfo") ); |
|
488 |
|
489 iCMServer.GetTransferInfo( aService, |
|
490 aItemCount, |
|
491 aTimeInSec ); |
|
492 } |
|
493 |
|
494 // -------------------------------------------------------------------------- |
|
495 // CMSEngine::SetDrivesL |
|
496 // -------------------------------------------------------------------------- |
|
497 // |
|
498 EXPORT_C void CMSEngine::SetDrivesL( RPointerArray<CCmDriveInfo> aDrives ) |
|
499 { |
|
500 LOG( _L("[MediaServant ENG]\t CMSEngine::SetDrivesL") ); |
|
501 |
|
502 iCMServer.SetDrivesL( aDrives ); |
|
503 } |
|
504 |
|
505 |
|
506 // -------------------------------------------------------------------------- |
|
507 // CMSEngine::GetDrivesL |
|
508 // -------------------------------------------------------------------------- |
|
509 // |
|
510 EXPORT_C void CMSEngine::GetDrivesL( RPointerArray<CCmDriveInfo>& aDrives ) |
|
511 { |
|
512 LOG( _L("[MediaServant ENG]\t CMSEngine::GetDrivesL") ); |
|
513 |
|
514 iCMServer.GetDrivesL( aDrives ); |
|
515 } |
|
516 |
|
517 // -------------------------------------------------------------------------- |
|
518 // CMSEngine::DriveSelectionStatus |
|
519 // -------------------------------------------------------------------------- |
|
520 // |
|
521 EXPORT_C TBool CMSEngine::DriveSelectionStatus() |
|
522 { |
|
523 LOG(_L("[MediaServant ENG]\t CMSEngine::DriveSelectionStatus")); |
|
524 |
|
525 return iCMServer.DriveSelectionStatus(); |
|
526 } |
|
527 |
|
528 // -------------------------------------------------------------------------- |
|
529 // CMSEngine::OpenServerSession |
|
530 // -------------------------------------------------------------------------- |
|
531 // |
|
532 TInt CMSEngine::OpenServerSession() |
|
533 { |
|
534 LOG( _L("[MediaServant ENG]\t CMSEngine::OpenServerSession") ); |
|
535 TInt error = iCMServer.Connect(); |
|
536 return error; |
|
537 } |
|
538 |
|
539 // -------------------------------------------------------------------------- |
|
540 // CMSEngine::CloseServerSession |
|
541 // -------------------------------------------------------------------------- |
|
542 // |
|
543 TInt CMSEngine::CloseServerSession() |
|
544 { |
|
545 LOG( _L("[MediaServant ENG]\t CMSEngine::CloseServerSession") ); |
|
546 |
|
547 return ( iCMServer.Close() ); |
|
548 } |
|
549 |
|
550 // End of file |
|