|
1 /* |
|
2 * Copyright (c) 2002-2009 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 #include <f32file.h> |
|
18 #include "movetimer.h" |
|
19 #include "mdsutils.h" |
|
20 #include "harvestercommon.h" |
|
21 |
|
22 #include <harvesterdata.h> |
|
23 |
|
24 const TInt KTimeout = 1000000; |
|
25 |
|
26 CMoveTimer::CMoveTimer( MMoveTimerObserver* aObserver ) : |
|
27 CActive( KHarvesterPriorityMonitorPlugin ) |
|
28 { |
|
29 iObserver = aObserver; |
|
30 } |
|
31 |
|
32 CMoveTimer* CMoveTimer::NewLC( MMoveTimerObserver* aObserver ) |
|
33 { |
|
34 CMoveTimer* self = new ( ELeave ) CMoveTimer( aObserver ); |
|
35 CleanupStack::PushL( self ); |
|
36 self->ConstructL(); |
|
37 return self; |
|
38 } |
|
39 |
|
40 CMoveTimer* CMoveTimer::NewL( MMoveTimerObserver* aObserver ) |
|
41 { |
|
42 CMoveTimer* self = CMoveTimer::NewLC( aObserver ); |
|
43 CleanupStack::Pop( self ); |
|
44 return self; |
|
45 } |
|
46 |
|
47 void CMoveTimer::AddHarvesterDataL( CHarvesterData* aHD ) |
|
48 { |
|
49 iHDArray.AppendL( aHD ); |
|
50 StartL(); |
|
51 } |
|
52 |
|
53 CHarvesterData* CMoveTimer::CheckUriL( const TDesC& aUri ) |
|
54 { |
|
55 TPtrC nameExt; |
|
56 |
|
57 if( MdsUtils::GetNameExt( aUri, nameExt ) ) |
|
58 { |
|
59 |
|
60 // check if harvester queue contains harvesting request |
|
61 // with same file name and extension |
|
62 for (int i = iHDArray.Count(); --i >= 0; ) |
|
63 { |
|
64 CHarvesterData* hd = iHDArray[i]; |
|
65 |
|
66 TPtrC tempNameExt; |
|
67 |
|
68 if ( MdsUtils::GetNameExt( hd->Uri(), tempNameExt ) && |
|
69 MdsUtils::Compare( nameExt, tempNameExt ) == 0 ) |
|
70 { |
|
71 iHDArray.Remove( i ); |
|
72 |
|
73 if( iHDArray.Count() == 0 ) |
|
74 { |
|
75 iHDArray.Compress(); |
|
76 } |
|
77 |
|
78 return hd; |
|
79 } |
|
80 } |
|
81 } |
|
82 |
|
83 return NULL; |
|
84 } |
|
85 |
|
86 void CMoveTimer::ConstructL() |
|
87 { |
|
88 User::LeaveIfError( iTimer.CreateLocal() ); // Initialize timer |
|
89 CActiveScheduler::Add( this ); // Add to scheduler |
|
90 } |
|
91 |
|
92 CMoveTimer::~CMoveTimer() |
|
93 { |
|
94 Cancel(); // Cancel any request, if outstanding |
|
95 iTimer.Close(); // Destroy the RTimer object |
|
96 // Delete instance variables if any |
|
97 iHDArray.ResetAndDestroy(); |
|
98 iHDArray.Close(); |
|
99 } |
|
100 |
|
101 void CMoveTimer::DoCancel() |
|
102 { |
|
103 iTimer.Cancel(); |
|
104 } |
|
105 |
|
106 void CMoveTimer::StartL() |
|
107 { |
|
108 Cancel(); // Cancel any request, just to be sure |
|
109 iTimer.After( iStatus, KTimeout ); // Set for later |
|
110 SetActive(); // Tell scheduler a request is active |
|
111 } |
|
112 |
|
113 void CMoveTimer::RunL() |
|
114 { |
|
115 User::LeaveIfError( iStatus.Int() ); |
|
116 if( iObserver && iHDArray.Count() > 0) |
|
117 { |
|
118 iObserver->NotMoveEvent( iHDArray ); |
|
119 } |
|
120 iHDArray.Reset(); |
|
121 iHDArray.Compress(); |
|
122 } |
|
123 |
|
124 TInt CMoveTimer::RunError( TInt /*aError*/ ) |
|
125 { |
|
126 if( iObserver && iHDArray.Count() > 0) |
|
127 { |
|
128 iObserver->NotMoveEvent( iHDArray ); |
|
129 } |
|
130 iHDArray.Reset(); |
|
131 return KErrNone; |
|
132 } |