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: Main class in Store manager component |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32property.h> |
|
20 #include "upnpavdevice.h" |
|
21 #include "upnpavcontroller.h" |
|
22 #include "upnpavdevicelist.h" |
|
23 #include <utf.h> |
|
24 #include "cmserviceobserver.h" |
|
25 #include "cmsmfilemngr.h" |
|
26 #include "cmsmtransferengine.h" |
|
27 #include "cmstorelistitem.h" |
|
28 #include "cmdmmain.h" |
|
29 #include "cmmmmain.h" |
|
30 #include "cmsmmain.h" |
|
31 #include "msdebug.h" |
|
32 |
|
33 // One file transfered |
|
34 const TInt KCmOneFile = 1; |
|
35 const TInt KCmSmClfRefreshInterval = 15000000; |
|
36 const TInt KCmSmOneSecond = 1000000; |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CCmSmMain::NewL |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CCmSmMain* CCmSmMain::NewL( |
|
43 MCmServiceObserver* aObserver, CMdESession& aSession, |
|
44 CCmDmMain* aDBManager, CCmMmMain* aMemManager ) |
|
45 { |
|
46 LOG(_L("[STORE MNGR]\t CCmSmMain::NewL() start")); |
|
47 CCmSmMain* self = CCmSmMain::NewLC( aObserver, aSession, |
|
48 aDBManager, aMemManager ); |
|
49 CleanupStack::Pop( self ); |
|
50 LOG(_L("[STORE MNGR]\t CCmSmMain::NewL() end")); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CCmSmMain::NewLC |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CCmSmMain* CCmSmMain::NewLC( |
|
59 MCmServiceObserver* aObserver, CMdESession& aSession, |
|
60 CCmDmMain* aDBManager, CCmMmMain* aMemManager ) |
|
61 { |
|
62 LOG(_L("[STORE MNGR]\t CCmSmMain::NewLC() start")); |
|
63 CCmSmMain* self = new ( ELeave ) CCmSmMain( aObserver, aDBManager, |
|
64 aMemManager ); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL( aSession, aDBManager ); |
|
67 LOG(_L("[STORE MNGR]\t CCmSmMain::NewLC() end")); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CCmSmMain::~CCmSmMain |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CCmSmMain::~CCmSmMain() |
|
76 { |
|
77 LOG(_L("[STORE MNGR]\t CCmSmMain::~CCmSmMain() start")); |
|
78 Cancel(); |
|
79 delete iCmSmTransferEngine; |
|
80 delete iCmSmFileMngr; |
|
81 DeleteDevices(); |
|
82 iItems.ResetAndDestroy(); |
|
83 iItems.Close(); |
|
84 iItemIds.Reset(); |
|
85 iItemIds.Close(); |
|
86 delete iPeriodic; |
|
87 LOG(_L("[STORE MNGR]\t CCmSmMain::~CCmSmMain() end")); |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CCmSmMain::CCmSmMain |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 CCmSmMain::CCmSmMain( MCmServiceObserver* aObserver, CCmDmMain* aDBManager, |
|
95 CCmMmMain* aMemManager ) |
|
96 : CActive( EPriorityStandard ), iObserver( aObserver ), |
|
97 iMemManager( aMemManager ), iDbManager( aDBManager ) |
|
98 { |
|
99 LOG(_L("[STORE MNGR]\t CCmSmMain::CCmSmMain")); |
|
100 |
|
101 CActiveScheduler::Add( this ); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CCmSmMain::ConstructL |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 void CCmSmMain::ConstructL( CMdESession& aSession, CCmDmMain* aDBManager ) |
|
109 { |
|
110 LOG(_L("[STORE MNGR]\t CCmSmMain::ConstructL() start")); |
|
111 iService = ECmServiceNone; |
|
112 iCmSmTransferEngine = |
|
113 CCmSmTransferEngine::NewL( this, aDBManager, iItems, iItemIds ); |
|
114 iCmSmFileMngr = |
|
115 CCmSmFileMngr::NewL( this, aSession, aDBManager, iItems ); |
|
116 LOG(_L("[STORE MNGR]\t CCmSmMain::ConstructL() end")); |
|
117 iProgressInfo.iService = ECmServiceStore; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // CCmSmMain::StartStoreL |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 void CCmSmMain::StartStoreL() |
|
125 { |
|
126 LOG(_L("[STORE MNGR]\t CCmSmMain::StartStoreL()")); |
|
127 if( iService == ECmServiceAutomStoreListProcess ) |
|
128 { |
|
129 iCmSmFileMngr->CancelOperation(); |
|
130 } |
|
131 iCancelOnGoing = EFalse; |
|
132 iService = ECmServiceStore; |
|
133 iMemManager->SetObserver( *this ); |
|
134 iDeviceIndex = KErrNone; |
|
135 iProgressInfo.iService = ECmServiceStore; |
|
136 iProgressInfo.iProcessedItems = KErrNone; |
|
137 iProgressInfo.iTotalItems = iCmSmFileMngr->StoreItemCount() + |
|
138 iCmSmFileMngr->FillItemCount(); |
|
139 SendProgressInfo( KErrNone ); |
|
140 ChangeState( ECmSmGetMediaServers ); |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // CCmSmMain::CancelOperation |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 void CCmSmMain::CancelOperation() |
|
148 { |
|
149 LOG(_L("[STORE MNGR]\t CCmSmMain::CancelOperation()")); |
|
150 // If some files need to be removed or shrinked do it now |
|
151 iCancelOnGoing = ETrue; |
|
152 iItems.ResetAndDestroy(); |
|
153 iItems.Close(); |
|
154 iItemIds.Reset(); |
|
155 iItemIds.Close(); |
|
156 iCmSmFileMngr->CancelOperation(); |
|
157 iCmSmTransferEngine->CancelOperation(); |
|
158 iObserver->ServiceExecuted( iService, KErrCancel ); |
|
159 // Service finished. Reset progress info. |
|
160 iProgressInfo.iService = ECmServiceNone; |
|
161 iService = ECmServiceNone; |
|
162 SendProgressInfo( KErrNone ); |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------------------------- |
|
166 // CCmSmMain::PreProcessLists |
|
167 // --------------------------------------------------------------------------- |
|
168 // |
|
169 void CCmSmMain::PreProcessLists() |
|
170 { |
|
171 LOG(_L("[STORE MNGR]\t CCmSmMain::PreProcessLists")); |
|
172 |
|
173 iCancelOnGoing = EFalse; |
|
174 if( iService == ECmServiceAutomStoreListProcess ) |
|
175 { |
|
176 iCmSmFileMngr->CancelOperation(); |
|
177 iCmSmFileMngr->SetProcessingStatus( ECmSmProcessingFilesStarted ); |
|
178 } |
|
179 else |
|
180 { |
|
181 ChangeState( ECmSmStartFileProcessing ); |
|
182 } |
|
183 |
|
184 iService = ECmServicePreProcessingStore; |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // CCmSmMain::GetColItemsL |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 void CCmSmMain::GetColItemsL( TCmMediaType aMedia, |
|
192 CDesCArray& aArray ) |
|
193 { |
|
194 LOG(_L("[STORE MNGR]\t CCmSmMain::GetColItemsL")); |
|
195 |
|
196 iCancelOnGoing = EFalse; |
|
197 if( iService == ECmServiceAutomStoreListProcess ) |
|
198 { |
|
199 iCmSmFileMngr->CancelOperation(); |
|
200 } |
|
201 iService = ECmServiceGetStoreFields; |
|
202 iCmSmFileMngr->ProcessAlbumList( aMedia, aArray ); |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CCmSmMain::GetColItemsL |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 void CCmSmMain::GetColItemsL( TCmMediaType /*aMedia*/, |
|
210 CCmSqlPropertyContainer& /*aPropertys*/ ) |
|
211 { |
|
212 LOG(_L("[STORE MNGR]\t CCmSmMain::GetColItemsL")); |
|
213 |
|
214 iService = ECmServiceGetFillFields; |
|
215 ChangeState( ECmSmFinishing ); |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // CCmSmMain::SetAvController |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 void CCmSmMain::SetAvController( MUPnPAVController* aAVController ) |
|
223 { |
|
224 LOG(_L("[STORE MNGR]\t CCmSmMain::SetAvController")); |
|
225 |
|
226 iCmSmTransferEngine->SetAvController(aAVController); |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------------------------- |
|
230 // CCmSmMain::FileProcessingStatus |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 void CCmSmMain::FileProcessingStatus( TCmSmFileProcessingStatus aStatus ) |
|
234 { |
|
235 LOG(_L("[STORE MNGR]\t CCmSmMain::FileProcessingStatus()")); |
|
236 |
|
237 CancelMdETimer(); |
|
238 switch(aStatus) |
|
239 { |
|
240 case ECmSmProcessingFilesStarted: |
|
241 { |
|
242 if( iService == ECmServicePreProcessingStore ) |
|
243 { |
|
244 ChangeState( ECmSmStartFileProcessing ); |
|
245 } |
|
246 break; |
|
247 } |
|
248 case ECmSmProcessingFilesReady: |
|
249 { |
|
250 break; |
|
251 } |
|
252 case ECmSmProcessingCanceled: |
|
253 { |
|
254 break; |
|
255 } |
|
256 case ECmSmNoStoreRulesSelected: |
|
257 { |
|
258 if( iService == ECmServiceAutomStoreListProcess ) |
|
259 { |
|
260 // Do not complete message |
|
261 } |
|
262 else |
|
263 { |
|
264 ChangeState( ECmSmFinishing ); |
|
265 } |
|
266 break; |
|
267 } |
|
268 case ECmSmPreProcessingReady: |
|
269 { |
|
270 if( iService == ECmServiceAutomStoreListProcess ) |
|
271 { |
|
272 // Do not complete message |
|
273 } |
|
274 else |
|
275 { |
|
276 iObserver->ServiceExecuted( iService, KErrNone ); |
|
277 } |
|
278 iService = ECmServiceNone; |
|
279 break; |
|
280 } |
|
281 case ECmSmRefreshError: |
|
282 { |
|
283 if( iService == ECmServiceAutomStoreListProcess ) |
|
284 { |
|
285 // Do not complete message |
|
286 } |
|
287 else |
|
288 { |
|
289 iObserver->ServiceExecuted( iService, |
|
290 KErrGeneral ); |
|
291 } |
|
292 iService = ECmServiceNone; |
|
293 break; |
|
294 } |
|
295 case ECmSmAlbumProcessingReady: |
|
296 { |
|
297 if( iService == ECmServiceAutomStoreListProcess ) |
|
298 { |
|
299 // Do not complete message |
|
300 } |
|
301 else |
|
302 { |
|
303 iObserver->ServiceExecuted( iService, KErrNone ); |
|
304 } |
|
305 iService = ECmServiceNone; |
|
306 break; |
|
307 } |
|
308 case ECmSmContentChanged: |
|
309 { |
|
310 // If timer start up fails => wait next content change event |
|
311 TRAPD( err, StartMdETimerL() ); |
|
312 if( err ) |
|
313 { |
|
314 TRACE(Print(_L("[STORE MNGR]\t StartMdETimerL err = %d"), |
|
315 err )); |
|
316 } |
|
317 break; |
|
318 } |
|
319 default: |
|
320 { |
|
321 break; |
|
322 } |
|
323 } |
|
324 |
|
325 } |
|
326 |
|
327 // --------------------------------------------------------------------------- |
|
328 // CCmSmMain::TransferStatus |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 void CCmSmMain::TransferStatus( TCmSmTransferStatus aStatus ) |
|
332 { |
|
333 LOG(_L("[STORE MNGR]\t CCmSmMain::TransferStatus()")); |
|
334 switch( aStatus ) |
|
335 { |
|
336 case ECmSmTransferCompleted: |
|
337 { |
|
338 TTime storeFinished; |
|
339 storeFinished.HomeTime(); |
|
340 TTimeIntervalMicroSeconds usecsFrom = |
|
341 storeFinished.MicroSecondsFrom(iStoreStarted); |
|
342 TInt64 timeinsecs((TInt64)( usecsFrom.Int64() / KCmSmOneSecond )); |
|
343 TRACE(Print(_L("[STORE MNGR]\t Store took = %ld seconds"), |
|
344 timeinsecs )); |
|
345 |
|
346 iCmSmFileMngr->UpdateTransferHistoryData( timeinsecs, |
|
347 iCmSmTransferEngine->DataAmount(), (TUint8)iId ); |
|
348 ChangeState( ECmSmManageFiles ); |
|
349 break; |
|
350 } |
|
351 case ECmSmAborted: |
|
352 { |
|
353 ChangeState( ECmSmStartCopying ); |
|
354 break; |
|
355 } |
|
356 case ECmSmTransferCanceled: |
|
357 { |
|
358 break; |
|
359 } |
|
360 case ECmSmFileTransferred: |
|
361 { |
|
362 SendProgressInfo( KCmOneFile ); |
|
363 break; |
|
364 } |
|
365 case ECmSmFileTransferFailed: |
|
366 { |
|
367 // File transferring failed => skip file |
|
368 SendProgressInfo( KCmOneFile ); |
|
369 break; |
|
370 } |
|
371 case ECmSmWlanLost: |
|
372 { |
|
373 if( iDevices ) |
|
374 { |
|
375 iDevices->ResetAndDestroy(); |
|
376 delete iDevices; |
|
377 iDevices = NULL; |
|
378 } |
|
379 iItemIds.Reset(); |
|
380 iItemIds.Close(); |
|
381 iCmSmFileMngr->ResetArrays(); |
|
382 iObserver->ServiceExecuted( iService, KErrGeneral ); |
|
383 iProgressInfo.iService = ECmServiceNone; |
|
384 iService = ECmServiceNone; |
|
385 SendProgressInfo( KErrNone ); |
|
386 break; |
|
387 } |
|
388 case ECmSmTransferContinued: |
|
389 { |
|
390 ChangeState( ECmSmContinueCopying ); |
|
391 break; |
|
392 } |
|
393 default: |
|
394 { |
|
395 break; |
|
396 } |
|
397 } |
|
398 } |
|
399 |
|
400 #ifdef _DEBUG |
|
401 // --------------------------------------------------------------------------- |
|
402 // CCmSmMain::LogServers |
|
403 // --------------------------------------------------------------------------- |
|
404 // |
|
405 void CCmSmMain::LogServers() |
|
406 { |
|
407 LOG(_L("[STORE MNGR]\t CCmSmMain::LogServers")); |
|
408 |
|
409 for( TInt i = 0; i < iDevices->Count(); i++ ) |
|
410 { |
|
411 TBuf<KMaxName>temp; |
|
412 if((*iDevices)[i]) |
|
413 { |
|
414 if( &(*iDevices)[i]->Uuid() ) |
|
415 { |
|
416 if( (*iDevices)[i]->Uuid().Length() < KMaxName ) |
|
417 { |
|
418 temp.Copy( (*iDevices)[i]->Uuid() ); |
|
419 TRACE(Print(_L("[STORE MNGR]\t FOUND DEVICE %d = %S"), |
|
420 i+1, &temp )); |
|
421 } |
|
422 temp.Zero(); |
|
423 } |
|
424 } |
|
425 } |
|
426 } |
|
427 #endif |
|
428 |
|
429 // --------------------------------------------------------------------------- |
|
430 // CCmSmMain::SendProgressInfo |
|
431 // --------------------------------------------------------------------------- |
|
432 // |
|
433 void CCmSmMain::SendProgressInfo( TInt aProgress ) |
|
434 { |
|
435 TRACE( Print( _L( |
|
436 "[STORE MNGR]\t CCmSmMain::SendProgressInfo( %d )"), |
|
437 aProgress)); |
|
438 |
|
439 iProgressInfo.iProcessedItems += aProgress; |
|
440 TRAPD( error, iCmSmFileMngr->GetStoreFileCountNoDuplicatesL( |
|
441 iProgressInfo.iItemsToTransferPerService ) ); |
|
442 if ( error ) |
|
443 { |
|
444 TRACE( Print( _L( "[STORE MNGR]\t GetStoreFileCountNoDuplicatesL \ |
|
445 failed with error %d"), error ) ); |
|
446 } |
|
447 TCmProgressInfoPckg progressPckg( iProgressInfo ); |
|
448 |
|
449 TRACE( Print( _L( |
|
450 "[STORE MNGR]\t processed: %d total %d"), |
|
451 iProgressInfo.iProcessedItems, iProgressInfo.iTotalItems)); |
|
452 |
|
453 TInt err = RProperty::Set( KCmPropertyCat, KCmProperty, progressPckg ); |
|
454 |
|
455 TRACE( Print( _L("[STORE MNGR]\t RProperty::Set returned %d"), err)); |
|
456 } |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // CCmSmMain::ManageFileL |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 void CCmSmMain::ManageFileL() |
|
463 { |
|
464 LOG(_L("[STORE MNGR]\t CCmSmMain::ManageFileL")); |
|
465 |
|
466 if( KErrNone < iCmSmTransferEngine->FilesToBeRemoved().Count() ) |
|
467 { |
|
468 iMemManager->DeleteFilesL( iCmSmTransferEngine->FilesToBeRemoved() ); |
|
469 } |
|
470 else if ( KErrNone < iCmSmTransferEngine->FilesToBeShrinked().Count() ) |
|
471 { |
|
472 TRAPD( err, iMemManager->ShrinkImagesL( |
|
473 iCmSmTransferEngine->FilesToBeShrinked() ) ); |
|
474 if( err ) |
|
475 { |
|
476 ChangeState( ECmSmStartCopying ); |
|
477 } |
|
478 } |
|
479 else if( iCancelOnGoing ) |
|
480 { |
|
481 ChangeState( ECmSmFinishCanceling ); |
|
482 } |
|
483 else |
|
484 { |
|
485 // Store to next server... |
|
486 ChangeState( ECmSmStartCopying ); |
|
487 } |
|
488 } |
|
489 |
|
490 // --------------------------------------------------------------------------- |
|
491 // CCmSmMain::DeleteCompleteL |
|
492 // --------------------------------------------------------------------------- |
|
493 // |
|
494 void CCmSmMain::DeleteCompleteL( TInt /*aErr*/ ) |
|
495 { |
|
496 LOG(_L("[STORE MNGR]\t CCmSmMain::DeleteCompleteL")); |
|
497 |
|
498 iCmSmTransferEngine->DeleteToBeRemoved(); |
|
499 ManageFileL(); |
|
500 } |
|
501 |
|
502 // --------------------------------------------------------------------------- |
|
503 // CCmSmMain::ShrinkCompleteL |
|
504 // --------------------------------------------------------------------------- |
|
505 // |
|
506 void CCmSmMain::ShrinkCompleteL( TInt /*aErr*/ ) |
|
507 { |
|
508 LOG(_L("[STORE MNGR]\t CCmSmMain::ShrinkCompleteL")); |
|
509 |
|
510 iCmSmTransferEngine->DeleteToBeShrinked(); |
|
511 ManageFileL(); |
|
512 } |
|
513 |
|
514 // --------------------------------------------------------------------------- |
|
515 // CCmSmMain::ChangeState |
|
516 // --------------------------------------------------------------------------- |
|
517 // |
|
518 void CCmSmMain::ChangeState( |
|
519 TCmSmMainSequencer aStatus ) |
|
520 { |
|
521 LOG(_L("[STORE MNGR]\t CCmSmMain::ChangeState")); |
|
522 |
|
523 __ASSERT_DEBUG(!IsActive(),\ |
|
524 User::Panic( KCmSmManager, KErrInUse )); |
|
525 SetActive(); |
|
526 TRequestStatus* pStatus = &iStatus; |
|
527 User::RequestComplete( pStatus, aStatus ); |
|
528 } |
|
529 |
|
530 // --------------------------------------------------------------------------- |
|
531 // CCmSmMain::StartMdETimerL |
|
532 // --------------------------------------------------------------------------- |
|
533 // |
|
534 void CCmSmMain::StartMdETimerL() |
|
535 { |
|
536 LOG( _L("[STORE MNGR] CCmSmMain::StartMdETimerL start")); |
|
537 |
|
538 if( iPeriodic ) |
|
539 { |
|
540 iPeriodic->Cancel(); |
|
541 } |
|
542 else |
|
543 { |
|
544 iPeriodic = CPeriodic::NewL( CActive::EPriorityIdle ); |
|
545 } |
|
546 iPeriodic->Start( KCmSmClfRefreshInterval, KCmSmClfRefreshInterval, |
|
547 TCallBack( CheckItems, this ) ); |
|
548 LOG( _L("[STORE MNGR] CCmSmMain::StartMdETimerL end")); |
|
549 } |
|
550 |
|
551 // --------------------------------------------------------------------------- |
|
552 // CCmSmMain::CancelMdETimer |
|
553 // --------------------------------------------------------------------------- |
|
554 // |
|
555 void CCmSmMain::CancelMdETimer() |
|
556 { |
|
557 LOG( _L("[STORE MNGR] CCmSmMain::CancelMdETimer start")); |
|
558 |
|
559 if( iPeriodic ) |
|
560 { |
|
561 iPeriodic->Cancel(); |
|
562 } |
|
563 LOG( _L("[STORE MNGR] CCmSmMain::CancelMdETimer end")); |
|
564 } |
|
565 |
|
566 // ----------------------------------------------------------------------------- |
|
567 // CCmSmMain::CheckItems |
|
568 // ----------------------------------------------------------------------------- |
|
569 // |
|
570 TInt CCmSmMain::CheckItems( TAny* aPtr ) |
|
571 { |
|
572 LOG( _L("[STORE MNGR] CCmSmMain::CheckItems")); |
|
573 |
|
574 return ( (CCmSmMain*)aPtr)->CheckItemsChanged(); |
|
575 } |
|
576 |
|
577 // ----------------------------------------------------------------------------- |
|
578 // CCmSmMain::CheckItemsChanged |
|
579 // ----------------------------------------------------------------------------- |
|
580 // |
|
581 TInt CCmSmMain::CheckItemsChanged( ) |
|
582 { |
|
583 LOG(_L("[STORE MNGR]\t CCmSmMain::CheckItemsChanged")); |
|
584 |
|
585 TInt restart( 1 ); |
|
586 if( iService == ECmServiceNone ) |
|
587 { |
|
588 LOG( _L("[STORE MNGR] Starting autom. store list process...")); |
|
589 iService = ECmServiceAutomStoreListProcess; |
|
590 iCmSmFileMngr->StartProcessing(); |
|
591 } |
|
592 else |
|
593 { |
|
594 LOG( _L("[STORE MNGR] Store manager busy wait another x mins...")); |
|
595 restart = 0; |
|
596 } |
|
597 return restart; |
|
598 } |
|
599 |
|
600 // --------------------------------------------------------------------------- |
|
601 // CCmSmMain::DeleteDevices |
|
602 // --------------------------------------------------------------------------- |
|
603 // |
|
604 void CCmSmMain::DeleteDevices() |
|
605 { |
|
606 LOG(_L("[STORE MNGR]\t CCmSmMain::DeleteDevices")); |
|
607 |
|
608 if ( iDevices ) |
|
609 { |
|
610 iDevices->ResetAndDestroy(); |
|
611 delete iDevices; |
|
612 iDevices = NULL; |
|
613 } |
|
614 } |
|
615 |
|
616 // --------------------------------------------------------------------------- |
|
617 // CCmSmMain::RunL |
|
618 // --------------------------------------------------------------------------- |
|
619 // |
|
620 void CCmSmMain::RunL() |
|
621 { |
|
622 TRACE(Print(_L("[STORE MNGR]\t CCmSmMain::RunL status = %d"), |
|
623 iStatus.Int() )); |
|
624 |
|
625 switch( iStatus.Int() ) |
|
626 { |
|
627 case ECmSmGetMediaServers: |
|
628 { |
|
629 DeleteDevices(); |
|
630 TRAPD( err, iCmSmTransferEngine->GetMediaServersL( iDevices ) ); |
|
631 TRACE(Print(_L("[STORE MNGR]\t GetMediaServersL err = %d"), |
|
632 err )); |
|
633 if( err || 0 == iDevices->Count() ) |
|
634 { |
|
635 iObserver->ServiceExecuted( iService, KErrNotFound ); |
|
636 iService = ECmServiceNone; |
|
637 } |
|
638 else |
|
639 { |
|
640 #ifdef _DEBUG |
|
641 LogServers(); |
|
642 #endif |
|
643 iDeviceIndex = 0; |
|
644 // Load store list into memory |
|
645 iCmSmFileMngr->LoadStoreFileListL(); |
|
646 iCmSmTransferEngine->ResetFileArrays(); |
|
647 ChangeState( ECmSmStartCopying ); |
|
648 } |
|
649 break; |
|
650 } |
|
651 case ECmSmStartFileProcessing: |
|
652 { |
|
653 if( iService == ECmServicePreProcessingStore ) |
|
654 { |
|
655 iCmSmFileMngr->StartProcessing(); |
|
656 } |
|
657 break; |
|
658 } |
|
659 case ECmSmStartCopying: |
|
660 { |
|
661 LOG(_L("[STORE MNGR]\t CCmSmMain::DeleteDevices \ |
|
662 start file copy")); |
|
663 |
|
664 iStoreStarted.HomeTime(); |
|
665 if( iDeviceIndex < iDevices->Count()) |
|
666 { |
|
667 iCmSmFileMngr->GetItemsL( iItemIds, |
|
668 (*iDevices)[iDeviceIndex]->Uuid(), iId ); |
|
669 if( KErrNone < iItemIds.Count() ) |
|
670 { |
|
671 LOG(_L("[STORE MNGR]\t CCmSmMain::DeleteDevices \ |
|
672 files to be copied")); |
|
673 iCmSmTransferEngine->CopyFilesL( (TUint8)iId, |
|
674 (*iDevices)[iDeviceIndex] ); |
|
675 } |
|
676 else |
|
677 { |
|
678 // Jump to next device |
|
679 LOG(_L("[STORE MNGR]\t CCmSmMain::DeleteDevices \ |
|
680 undefined mediaserver - no items")); |
|
681 ChangeState( ECmSmStartCopying ); |
|
682 } |
|
683 iDeviceIndex++; |
|
684 } |
|
685 else |
|
686 { |
|
687 iCmSmFileMngr->DeleteItems( |
|
688 iCmSmTransferEngine->ToBeDeleted() ); |
|
689 iCmSmFileMngr->UpdateStoreFileListL(); |
|
690 iDbManager->SetProgressInfo( iProgressInfo.iProcessedItems, |
|
691 iProgressInfo.iTotalItems ); |
|
692 DeleteDevices(); |
|
693 iItemIds.Reset(); |
|
694 iItemIds.Close(); |
|
695 iCmSmFileMngr->ResetArrays(); |
|
696 iObserver->ServiceExecuted( iService, KErrNone ); |
|
697 iService = ECmServiceNone; |
|
698 } |
|
699 break; |
|
700 } |
|
701 case ECmSmContinueCopying: |
|
702 { |
|
703 iCmSmTransferEngine->ContinueCopyFilesL(); |
|
704 break; |
|
705 } |
|
706 case ECmSmFinishing: |
|
707 { |
|
708 LOG(_L("[STORE MNGR]\t CCmSmMain::DeleteDevices no \ |
|
709 rules selected")); |
|
710 iObserver->ServiceExecuted( iService, |
|
711 KErrNone ); |
|
712 iService = ECmServiceNone; |
|
713 break; |
|
714 } |
|
715 case ECmSmManageFiles: |
|
716 { |
|
717 ManageFileL(); |
|
718 break; |
|
719 } |
|
720 case ECmSmFinishCanceling: |
|
721 { |
|
722 iCancelOnGoing = EFalse; |
|
723 // Before canceling update content of the db |
|
724 if( KErrNone < iItems.Count() ) |
|
725 { |
|
726 iCmSmFileMngr->DeleteItems( |
|
727 iCmSmTransferEngine->ToBeDeleted() ); |
|
728 iCmSmFileMngr->UpdateStoreFileListL(); |
|
729 } |
|
730 if( IsActive() ) |
|
731 { |
|
732 Cancel(); |
|
733 } |
|
734 break; |
|
735 } |
|
736 default: |
|
737 { |
|
738 LOG(_L("[STORE MNGR]\t CCmSmMain::DeleteDevices \ |
|
739 no defined status")); |
|
740 break; |
|
741 } |
|
742 } |
|
743 } |
|
744 |
|
745 // --------------------------------------------------------------------------- |
|
746 // CCmSmMain::Close |
|
747 // --------------------------------------------------------------------------- |
|
748 // |
|
749 void CCmSmMain::Close() |
|
750 { |
|
751 LOG(_L("[STORE MNGR]\t CCmSmMain::Close")); |
|
752 |
|
753 delete this; |
|
754 } |
|
755 |
|
756 // --------------------------------------------------------------------------- |
|
757 // CCmSmMain::DoCancel |
|
758 // --------------------------------------------------------------------------- |
|
759 // |
|
760 void CCmSmMain::DoCancel() |
|
761 { |
|
762 TRACE(Print(_L("[STORE MNGR]\t CCmSmMain::DoCancel()"))); |
|
763 } |
|
764 |
|
765 // --------------------------------------------------------------------------- |
|
766 // CCmSmMain::RunError |
|
767 // --------------------------------------------------------------------------- |
|
768 // |
|
769 TInt CCmSmMain::RunError( TInt aError ) |
|
770 { |
|
771 TRACE(Print(_L("[STORE MNGR]\t RunError aError = %d"), aError )); |
|
772 return aError; |
|
773 } |
|
774 |
|
775 // End of file |
|
776 |
|
777 |
|
778 |
|