26
|
1 |
/*
|
|
2 |
* Copyright (c) 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: Wait note dialog for scanning
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <e32base.h>
|
|
20 |
#include <StringLoader.h>
|
|
21 |
#include <avkon.mbg>
|
|
22 |
#include <aknconsts.h>
|
|
23 |
#include <StringLoader.h>
|
|
24 |
#include <aknnotedialog.h>
|
|
25 |
#include <featmgr.h>
|
|
26 |
#include <driveinfo.h>
|
|
27 |
|
|
28 |
#include <mpxlog.h>
|
|
29 |
#include <mpxcollectionframeworkdefs.h>
|
|
30 |
#include <mpxcollectionmessagedefs.h>
|
|
31 |
#include <mpxcollectionmessage.h>
|
|
32 |
#include <mpxwaitnotedialog.rsg>
|
|
33 |
#include <mpxharvesterutility.h>
|
|
34 |
#include <mpxcollectionutility.h>
|
|
35 |
#include <mpxmessagegeneraldefs.h>
|
|
36 |
#include <mpxcollectionplugin.hrh>
|
|
37 |
#include <mpxcollectionmessagedefs.h>
|
|
38 |
#include <mpxmessagecontainerdefs.h>
|
|
39 |
#include <mpxmediageneraldefs.h>
|
|
40 |
#include <mpxcommandgeneraldefs.h>
|
|
41 |
#include <mpxcollectioncommanddefs.h>
|
|
42 |
#include "mpxscanningdialog.h"
|
|
43 |
|
|
44 |
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
// Default Constructor
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
CMPXScanningWaitDialog::CMPXScanningWaitDialog( MMPXWaitNoteObserver* aObs,
|
|
50 |
TWaitNoteType aType ) :
|
|
51 |
CMPXWaitNoteDialog( aObs, aType )
|
|
52 |
{
|
|
53 |
iNumItemsAdded = 0;
|
|
54 |
iTotalNewTracks = 0;
|
|
55 |
iInitialCount = 0;
|
|
56 |
isCollectionDBChanged = EFalse;
|
|
57 |
iAsyncEvent = ECmdIdle;
|
|
58 |
iRefreshEnd = EFalse;
|
|
59 |
|
|
60 |
}
|
|
61 |
|
|
62 |
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
// 2nd Phased constructor
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
void CMPXScanningWaitDialog::ConstructL()
|
|
68 |
{
|
|
69 |
MPX_DEBUG1("CMPXScanningWaitDialog::ConstructL <---");
|
|
70 |
BaseConstructL();
|
|
71 |
|
|
72 |
TCallBack callback( CMPXScanningWaitDialog::AsyncCallHarvesterEventL, this );
|
|
73 |
iAsyncCallBack = new (ELeave) CAsyncCallBack( CActive::EPriorityHigh );
|
|
74 |
iAsyncCallBack->Set( callback );
|
|
75 |
MPX_DEBUG1("CMPXScanningWaitDialog::ConstructL --->");
|
|
76 |
}
|
|
77 |
|
|
78 |
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
// Two Phased constructor
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
CMPXScanningWaitDialog* CMPXScanningWaitDialog::NewL( MMPXWaitNoteObserver* aObs,
|
|
84 |
TWaitNoteType aType )
|
|
85 |
{
|
|
86 |
CMPXScanningWaitDialog* self = new(ELeave)CMPXScanningWaitDialog( aObs,
|
|
87 |
aType );
|
|
88 |
CleanupStack::PushL( self );
|
|
89 |
self->ConstructL();
|
|
90 |
CleanupStack::Pop( self );
|
|
91 |
return self;
|
|
92 |
}
|
|
93 |
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
// Virtual destructor
|
|
96 |
// ---------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
CMPXScanningWaitDialog::~CMPXScanningWaitDialog()
|
|
99 |
{
|
|
100 |
if( iHarvesterUtil )
|
|
101 |
{
|
|
102 |
iHarvesterUtil->Close();
|
|
103 |
}
|
|
104 |
iHarvesterUtil = NULL;
|
|
105 |
delete iAsyncCallBack;
|
|
106 |
iAsyncCallBack = NULL;
|
|
107 |
}
|
|
108 |
|
|
109 |
// ---------------------------------------------------------------------------
|
|
110 |
// CMPXScanningWaitDialog::PreNoteDisplayHandleL()
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
void CMPXScanningWaitDialog::PreNoteDisplayHandleL()
|
|
114 |
{
|
|
115 |
// CBA
|
|
116 |
SetCBAL( R_MPX_WAITNOTE_SOFTKEYS_EMPTY_STOP );
|
|
117 |
|
|
118 |
// Text
|
|
119 |
HBufC* text = NULL;
|
|
120 |
if( iWaitNoteType == EMPXScanningNote )
|
|
121 |
{
|
|
122 |
text = StringLoader::LoadLC( R_MPX_SCANNING_DB_TXT );
|
|
123 |
}
|
|
124 |
else if( iWaitNoteType == EMPXRefreshingNote )
|
|
125 |
{
|
|
126 |
text = StringLoader::LoadLC( R_MPX_REFRESHING_DB_TXT, 0 );
|
|
127 |
}
|
|
128 |
else // iWaitNoteType == EMPXCorruptScanningNote
|
|
129 |
{
|
|
130 |
text = StringLoader::LoadLC( R_MPX_REPAIRING_CORRUPT_DB );
|
|
131 |
}
|
|
132 |
|
|
133 |
SetTextL( *text );
|
|
134 |
CleanupStack::PopAndDestroy( text );
|
|
135 |
|
|
136 |
// Icon
|
|
137 |
TNoteIconInfo icon( (TInt)EMbmAvkonQgn_note_progress,
|
|
138 |
(TInt)EMbmAvkonQgn_note_progress_mask,
|
|
139 |
TFileName(KAvkonBitmapFile) );
|
|
140 |
SetIconL( icon );
|
|
141 |
|
|
142 |
// If we are repairing a corrupt db, we first clean up the old ones
|
|
143 |
//
|
|
144 |
if( iWaitNoteType == EMPXCorruptScanningNote )
|
|
145 |
{
|
|
146 |
HandleDatabaseCorruptionL();
|
|
147 |
}
|
|
148 |
|
|
149 |
// Start the scanning in harvester
|
|
150 |
// Just to be faster, lets just create a small async callback and then
|
|
151 |
// call ScanL
|
|
152 |
if( !iAsyncCallBack->IsActive() )
|
|
153 |
{
|
|
154 |
iAsyncEvent = ECmdScan;
|
|
155 |
iCancelScan = EFalse;
|
|
156 |
iAsyncCallBack->CallBack();
|
|
157 |
}
|
|
158 |
}
|
|
159 |
|
|
160 |
// ---------------------------------------------------------------------------
|
|
161 |
// CMPXScanningWaitDialog::PostNoteHandleL()
|
|
162 |
// ---------------------------------------------------------------------------
|
|
163 |
//
|
|
164 |
void CMPXScanningWaitDialog::PostNoteHandleL( TInt aButtonId )
|
|
165 |
{
|
|
166 |
MPX_DEBUG1("CMPXScanningWaitDialog::PostNoteHandleL --->");
|
|
167 |
|
|
168 |
MPX_DEBUG1(" BUGHUNT: cover display");
|
|
169 |
TInt textRsc( KErrNotFound );
|
|
170 |
|
|
171 |
HBufC* text = NULL;
|
|
172 |
if( aButtonId == EAknSoftkeyCancel )
|
|
173 |
{
|
|
174 |
// cancel scan in harvester
|
|
175 |
// Just to be faster, lets just create a small async callback and then
|
|
176 |
// call CancelScanL
|
|
177 |
if( !iAsyncCallBack->IsActive() )
|
|
178 |
{
|
|
179 |
iAsyncEvent = ECmdCancleScan;
|
|
180 |
iAsyncCallBack->CallBack();
|
|
181 |
}
|
|
182 |
else
|
|
183 |
{
|
|
184 |
iCancelScan = ETrue;
|
|
185 |
}
|
|
186 |
|
|
187 |
if (!iRefreshEnd)
|
|
188 |
{
|
|
189 |
// When stop refreshing library, prompt a process waiting dialog.
|
|
190 |
// Inform user to wait for the updating library.
|
|
191 |
HBufC* waitText = StringLoader::LoadLC( R_MPX_UPDATING_LIBRARY_TXT );
|
|
192 |
DisplayProcessWaitDialogL( R_MPX_GENERIC_WAIT_NOTE, *waitText );
|
|
193 |
CleanupStack::PopAndDestroy( waitText );
|
|
194 |
}
|
|
195 |
}
|
|
196 |
else if( iScanningError >= KErrNone )
|
|
197 |
{
|
|
198 |
// Show completed scan note
|
|
199 |
//
|
|
200 |
if( iWaitNoteType == EMPXScanningNote ||
|
|
201 |
iWaitNoteType == EMPXCorruptScanningNote )
|
|
202 |
{
|
|
203 |
if ( isCollectionDBChanged )
|
|
204 |
{
|
|
205 |
text = StringLoader::LoadLC( R_MPX_SCANNING_COMPLETE_TXT,
|
|
206 |
iNumItemsAdded );
|
|
207 |
textRsc = R_MPX_SCANNING_COMPLETE_TXT;
|
|
208 |
}
|
|
209 |
else
|
|
210 |
{
|
|
211 |
text = StringLoader::LoadLC( R_MPX_UPTODATE_TXT );
|
|
212 |
textRsc = R_MPX_UPTODATE_TXT;
|
|
213 |
}
|
|
214 |
}
|
|
215 |
else // iWaitNoteType == EMPXRefreshNote
|
|
216 |
{
|
|
217 |
if ( isCollectionDBChanged )
|
|
218 |
{
|
|
219 |
text = StringLoader::LoadLC( R_MPX_REFRESHING_DB_COMPLETE_TXT,
|
|
220 |
iNumItemsAdded );
|
|
221 |
textRsc = R_MPX_REFRESHING_DB_COMPLETE_TXT;
|
|
222 |
}
|
|
223 |
else
|
|
224 |
{
|
|
225 |
text = StringLoader::LoadLC( R_MPX_UPTODATE_TXT );
|
|
226 |
textRsc = R_MPX_UPTODATE_TXT;
|
|
227 |
}
|
|
228 |
}
|
|
229 |
}
|
|
230 |
else if( iScanningError == KErrDiskFull )
|
|
231 |
{
|
|
232 |
// If the error was disk full
|
|
233 |
//
|
|
234 |
text = StringLoader::LoadLC( R_MPX_MEM_LO_NOT_ENOUGH_MEMORY,
|
|
235 |
iNumItemsAdded );
|
|
236 |
}
|
|
237 |
else
|
|
238 |
{
|
|
239 |
// Show stopped notes
|
|
240 |
//
|
|
241 |
if( iWaitNoteType == EMPXScanningNote ||
|
|
242 |
iWaitNoteType == EMPXCorruptScanningNote )
|
|
243 |
{
|
|
244 |
textRsc = R_MPX_SCANNING_STOPPED_TXT;
|
|
245 |
text = StringLoader::LoadLC( R_MPX_SCANNING_STOPPED_TXT,
|
|
246 |
iNumItemsAdded );
|
|
247 |
}
|
|
248 |
else // iWaitNoteType == EMPXRefreshNote
|
|
249 |
{
|
|
250 |
textRsc = R_MPX_REFRESHING_DB_STOPPED_TXT;
|
|
251 |
text = StringLoader::LoadLC( R_MPX_REFRESHING_DB_STOPPED_TXT,
|
|
252 |
iNumItemsAdded );
|
|
253 |
}
|
|
254 |
}
|
|
255 |
|
|
256 |
// Show the note
|
|
257 |
if( text )
|
|
258 |
{
|
|
259 |
if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
|
|
260 |
{
|
|
261 |
DisplayNoteDialogL( R_MPX_EMPTY_CLOSE_NOTE, textRsc, iNumItemsAdded,
|
|
262 |
*text, CAknNoteDialog::EConfirmationTone );
|
|
263 |
}
|
|
264 |
else
|
|
265 |
{
|
|
266 |
// When finish updating library, cancle the process waiting
|
|
267 |
// dialog and then prompt the refreshing completion dialog.
|
|
268 |
CancelProcessWaitDialogL();
|
|
269 |
DisplayNoteDialogL( R_MPX_EMPTY_CLOSE_NOTE, *text,
|
|
270 |
CAknNoteDialog::EConfirmationTone );
|
|
271 |
}
|
|
272 |
CleanupStack::PopAndDestroy( text );
|
|
273 |
}
|
|
274 |
|
|
275 |
MPX_DEBUG1("<--CMPXScanningWaitDialog::PostNoteHandleL");
|
|
276 |
}
|
|
277 |
|
|
278 |
// ---------------------------------------------------------------------------
|
|
279 |
// Handle the collection message
|
|
280 |
// ---------------------------------------------------------------------------
|
|
281 |
//
|
|
282 |
void CMPXScanningWaitDialog::HandleCollectionMessage(
|
|
283 |
CMPXMessage* aMessage, TInt aError )
|
|
284 |
{
|
|
285 |
if ( aError == KErrNone && aMessage )
|
|
286 |
{
|
|
287 |
TRAP_IGNORE( DoHandleCollectionMessageL( *aMessage ) );
|
|
288 |
}
|
|
289 |
}
|
|
290 |
|
|
291 |
// ---------------------------------------------------------------------------
|
|
292 |
// Cleanup both collection and harvester databases
|
|
293 |
// ---------------------------------------------------------------------------
|
|
294 |
//
|
|
295 |
void CMPXScanningWaitDialog::HandleDatabaseCorruptionL()
|
|
296 |
{
|
|
297 |
// Cleanup Harvester
|
|
298 |
if( iHarvesterUtil != NULL )
|
|
299 |
{
|
|
300 |
iHarvesterUtil->RecreateDatabasesL();
|
|
301 |
}
|
|
302 |
}
|
|
303 |
|
|
304 |
// ---------------------------------------------------------------------------
|
|
305 |
// MMPXCollectionObserver
|
|
306 |
// ---------------------------------------------------------------------------
|
|
307 |
//
|
|
308 |
void CMPXScanningWaitDialog::DoHandleCollectionMessageL(
|
|
309 |
const CMPXMessage& aMessage )
|
|
310 |
{
|
|
311 |
MPX_FUNC( "CMPXScanningWaitDialog::DoHandleCollectionMessageL" );
|
|
312 |
|
|
313 |
TMPXMessageId id( aMessage.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) );
|
|
314 |
if ( KMPXMessageGeneral == id )
|
|
315 |
{
|
|
316 |
TInt event( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) );
|
|
317 |
TInt op( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralType ) );
|
|
318 |
TInt data( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralData ) );
|
|
319 |
|
|
320 |
if(event == TMPXCollectionMessage::EBroadcastEvent &&
|
|
321 |
((op == EMcMsgRefreshStart) || (op == EMcMsgRefreshEnd)))
|
|
322 |
{
|
|
323 |
TInt songTotal = 0;
|
|
324 |
|
|
325 |
if ( iWaitNoteType == EMPXScanningNote )
|
|
326 |
{
|
|
327 |
RArray<TUid> ary;
|
|
328 |
CleanupClosePushL( ary );
|
|
329 |
ary.AppendL(TUid::Uid( EMPXCollectionPluginPodCast ) );
|
|
330 |
TUid podcastCollectionId = iCollection->CollectionIDL( ary.Array() );
|
|
331 |
ary.Reset();
|
|
332 |
ary.AppendL(TUid::Uid(EMPXCollectionPluginMusic));
|
|
333 |
TUid musicCollectionId = iCollection->CollectionIDL( ary.Array() );
|
|
334 |
CleanupStack::PopAndDestroy(&ary);
|
|
335 |
|
|
336 |
TInt removableDrive( EDriveF );
|
|
337 |
#ifdef RD_MULTIPLE_DRIVE
|
|
338 |
User::LeaveIfError( DriveInfo::GetDefaultDrive(
|
|
339 |
DriveInfo::EDefaultRemovableMassStorage,
|
|
340 |
removableDrive ) );
|
|
341 |
#endif // RD_MULTIPLE_DRIVE
|
|
342 |
|
|
343 |
TInt massStorageDrive( EDriveE );
|
|
344 |
User::LeaveIfError( DriveInfo::GetDefaultDrive(
|
|
345 |
DriveInfo::EDefaultMassStorage,
|
|
346 |
massStorageDrive ) );
|
|
347 |
|
|
348 |
songTotal = GetTrackCountL( removableDrive,
|
|
349 |
podcastCollectionId.iUid, EMPXCollectionCountTrack );
|
|
350 |
songTotal += GetTrackCountL( massStorageDrive,
|
|
351 |
podcastCollectionId.iUid, EMPXCollectionCountTrack );
|
|
352 |
|
|
353 |
songTotal += GetTrackCountL( removableDrive,
|
|
354 |
musicCollectionId.iUid, EMPXCollectionCountTotal );
|
|
355 |
songTotal += GetTrackCountL( massStorageDrive,
|
|
356 |
musicCollectionId.iUid, EMPXCollectionCountTotal );
|
|
357 |
|
|
358 |
}
|
|
359 |
if( op == EMcMsgRefreshStart )
|
|
360 |
{
|
|
361 |
iRefreshEnd = EFalse;
|
|
362 |
isCollectionDBChanged = EFalse;
|
|
363 |
MPX_DEBUG1("refreshStart store the initial count");
|
|
364 |
iInitialCount = songTotal;
|
|
365 |
}
|
|
366 |
|
|
367 |
if( op == EMcMsgRefreshEnd )
|
|
368 |
{
|
|
369 |
MPX_DEBUG1("CMPXScanningWaitDialog::HandleCollectionMessageL refresh end");
|
|
370 |
// Do not reset iNumItemsAdded while KErrLocked or KErrDiskFull.
|
|
371 |
if( data != KErrLocked && data != KErrDiskFull )
|
|
372 |
{
|
|
373 |
iNumItemsAdded = songTotal ;
|
|
374 |
}
|
|
375 |
switch ( iWaitNoteType )
|
|
376 |
{
|
|
377 |
case EMPXScanningNote:
|
|
378 |
case EMPXOpeningNote:
|
|
379 |
case EMPXRefreshingNote:
|
|
380 |
case EMPXCorruptScanningNote:
|
|
381 |
case EMPXUsbEventNote:
|
|
382 |
case EMPXMTPEventNote:
|
|
383 |
case EMPXFormatScanningNote:
|
|
384 |
case EMPXMediaNotAvailableNote:
|
|
385 |
case EMPXNoteNotDefined:
|
|
386 |
// fall through
|
|
387 |
default:
|
|
388 |
{
|
|
389 |
// Synchronize the number of items added if we had no errors
|
|
390 |
//
|
|
391 |
if( data > KErrNone || iTotalNewTracks )
|
|
392 |
{
|
|
393 |
isCollectionDBChanged = ETrue;
|
|
394 |
iNumItemsAdded = iTotalNewTracks;
|
|
395 |
}
|
|
396 |
else
|
|
397 |
{
|
|
398 |
isCollectionDBChanged = EFalse;
|
|
399 |
}
|
|
400 |
break;
|
|
401 |
}
|
|
402 |
};
|
|
403 |
|
|
404 |
iRefreshEnd = ETrue;
|
|
405 |
// If cancel was pressed, iWaitDialog is NULL
|
|
406 |
//
|
|
407 |
if( iWaitDialog )
|
|
408 |
{
|
|
409 |
MPX_DEBUG1("CMPXScanningWaitDialog::HandleCollectionMessageL killing dialog");
|
|
410 |
iScanningError = data;
|
|
411 |
iWaitDialog->ProcessFinishedL();
|
|
412 |
}
|
|
413 |
|
|
414 |
// Delay showing the number added dialog
|
|
415 |
if( iScanningError == KErrCancel )
|
|
416 |
{
|
|
417 |
PostNoteHandleL( EAknSoftkeyOk );
|
|
418 |
}
|
|
419 |
|
|
420 |
// Save the error code
|
|
421 |
iScanningError = data;
|
|
422 |
}
|
|
423 |
}
|
|
424 |
else if( event == TMPXCollectionMessage::EBroadcastEvent &&
|
|
425 |
op == EMcMsgDiskInserted )
|
|
426 |
{
|
|
427 |
// Dismiss this scanning note because scanning will be restarted
|
|
428 |
//
|
|
429 |
MPX_DEBUG1("CMPXScanningWaitDialog::HandleCollectionMessageL \
|
|
430 |
dismissing scan because of refresh msg ");
|
|
431 |
if( iWaitDialog )
|
|
432 |
{
|
|
433 |
MPX_DEBUG1("CMPXScanningWaitDialog::HandleCollectionMessageL killing dialog");
|
|
434 |
iWaitDialog->ProcessFinishedL();
|
|
435 |
}
|
|
436 |
|
|
437 |
iScanningError = KErrNone;
|
|
438 |
}
|
|
439 |
}
|
|
440 |
else if(id == KMPXMessageIdItemChanged)
|
|
441 |
{
|
|
442 |
// Loop through messages for arrays.
|
|
443 |
//
|
|
444 |
if (aMessage.IsSupported(KMPXMessageArrayContents))
|
|
445 |
{
|
|
446 |
const CMPXMessageArray* messageArray =
|
|
447 |
aMessage.Value<CMPXMessageArray>(KMPXMessageArrayContents);
|
|
448 |
User::LeaveIfNull(const_cast<CMPXMessageArray*>(messageArray));
|
|
449 |
|
|
450 |
for( TInt i=0; i<messageArray->Count(); ++i )
|
|
451 |
{
|
|
452 |
HandleCollectionMessage( messageArray->AtL( i ), KErrNone );
|
|
453 |
}
|
|
454 |
}
|
|
455 |
// Single item
|
|
456 |
else
|
|
457 |
{
|
|
458 |
MPX_DEBUG1("CMPXScanningWaitDialog::HandleCollectionMessageL KMPXMessageIdItemChanged");
|
|
459 |
TMPXChangeEventType changeType( aMessage.ValueTObjectL<TMPXChangeEventType>( KMPXMessageChangeEventType ) );
|
|
460 |
TMPXGeneralCategory cat(aMessage.ValueTObjectL<TMPXGeneralCategory>(KMPXMessageMediaGeneralCategory));
|
|
461 |
if( changeType == EMPXItemInserted &&
|
|
462 |
(cat == EMPXSong || cat == EMPXPlaylist || cat == EMPXPodcast) )
|
|
463 |
{
|
|
464 |
iNumItemsAdded++;
|
|
465 |
iTotalNewTracks++;
|
|
466 |
// Update wait note text if refreshing or scaning
|
|
467 |
if( iWaitNoteType == EMPXRefreshingNote || iWaitNoteType == EMPXScanningNote || iWaitNoteType == EMPXCorruptScanningNote &&
|
|
468 |
iScanningError == KErrNone )
|
|
469 |
{
|
|
470 |
HBufC* text = StringLoader::LoadLC( R_MPX_REFRESHING_DB_TXT,
|
|
471 |
iNumItemsAdded );
|
|
472 |
SetTextL( *text );
|
|
473 |
CleanupStack::PopAndDestroy( text );
|
|
474 |
}
|
|
475 |
}
|
|
476 |
}
|
|
477 |
}
|
|
478 |
}
|
|
479 |
// ---------------------------------------------------------------------------
|
|
480 |
// Get track count for given table in the db
|
|
481 |
// ---------------------------------------------------------------------------
|
|
482 |
//
|
|
483 |
TInt CMPXScanningWaitDialog::GetTrackCountL(TInt aDrive,TInt aColDbId, TInt aColTable)
|
|
484 |
{
|
|
485 |
MPX_DEBUG2("--->CMPXScanningWaitDialog::GetTrackCountL() aDrive = %d", aDrive );
|
|
486 |
TInt count(0);
|
|
487 |
|
|
488 |
//get count from db
|
|
489 |
CMPXCommand* cmdCountM = CMPXMedia::NewL();
|
|
490 |
CleanupStack::PushL(cmdCountM);
|
|
491 |
cmdCountM->SetTObjectValueL<TMPXCommandId>(
|
|
492 |
KMPXCommandGeneralId,
|
|
493 |
KMPXCommandCollectionGetCount );
|
|
494 |
cmdCountM->SetTObjectValueL<TBool>(
|
|
495 |
KMPXCommandGeneralDoSync,
|
|
496 |
ETrue );
|
|
497 |
cmdCountM->SetTObjectValueL<TInt>(
|
|
498 |
KMPXCommandGeneralCollectionId,
|
|
499 |
aColDbId );
|
|
500 |
cmdCountM->SetTObjectValueL<TInt>(
|
|
501 |
KMPXCommandCollectionCountDrive,
|
|
502 |
aDrive );
|
|
503 |
cmdCountM->SetTObjectValueL<TInt>(
|
|
504 |
KMPXCommandCollectionCountTable,
|
|
505 |
aColTable );
|
|
506 |
|
|
507 |
TRAPD( err, iCollection->Collection().CommandL( *cmdCountM ) );
|
|
508 |
|
|
509 |
// returned command should contain count
|
|
510 |
if ( err == KErrNone && cmdCountM->IsSupported(KMPXCommandCollectionCountValue ) )
|
|
511 |
{
|
|
512 |
count = cmdCountM->ValueTObjectL<TInt>(KMPXCommandCollectionCountValue);
|
|
513 |
}
|
|
514 |
|
|
515 |
CleanupStack::PopAndDestroy(cmdCountM);
|
|
516 |
MPX_DEBUG2("--->CMPXScanningWaitDialog::GetTrackCountL() count = %d", count );
|
|
517 |
|
|
518 |
return count;
|
|
519 |
}
|
|
520 |
// ---------------------------------------------------------------------------
|
|
521 |
// async callback
|
|
522 |
// ---------------------------------------------------------------------------
|
|
523 |
//
|
|
524 |
TInt CMPXScanningWaitDialog::AsyncCallHarvesterEventL( TAny* aSelf )
|
|
525 |
{
|
|
526 |
MPX_DEBUG1("CMPXScanningWaitDialog::CallHarvesterScanL <---");
|
|
527 |
CMPXScanningWaitDialog* self = static_cast<CMPXScanningWaitDialog*>( aSelf );
|
|
528 |
if( self->iHarvesterUtil == NULL )
|
|
529 |
{
|
|
530 |
self->iHarvesterUtil = CMPXHarvesterFactory::NewL();
|
|
531 |
}
|
|
532 |
if( self->iAsyncEvent == ECmdScan )
|
|
533 |
{
|
|
534 |
if( !self->iCancelScan )
|
|
535 |
{
|
|
536 |
self->iHarvesterUtil->ScanL();
|
|
537 |
self->iScanningError = KErrNone;
|
|
538 |
}
|
|
539 |
else
|
|
540 |
{
|
|
541 |
self->iCancelScan = EFalse;
|
|
542 |
}
|
|
543 |
}
|
|
544 |
|
|
545 |
if( self->iAsyncEvent == ECmdCancleScan || self->iCancelScan )
|
|
546 |
{
|
|
547 |
self->iScanningError = KErrCancel;
|
|
548 |
// If harvester crashed,..... restart it.
|
|
549 |
MPX_TRAPD( err, self->iHarvesterUtil->CancelScanL() );
|
|
550 |
if( err != KErrNone )
|
|
551 |
{
|
|
552 |
self->iHarvesterUtil->Close();
|
|
553 |
self->iHarvesterUtil = NULL;
|
|
554 |
self->iHarvesterUtil = CMPXHarvesterFactory::NewL();
|
|
555 |
}
|
|
556 |
}
|
|
557 |
self->iAsyncEvent = ECmdIdle;
|
|
558 |
MPX_DEBUG1("CMPXScanningWaitDialog::CallHarvesterScanL --->");
|
|
559 |
return KErrNone;
|
|
560 |
}
|
|
561 |
// END OF FILE
|
|
562 |
|