20
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-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: Backup-Restore Queue implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "sconbrqueue.h"
|
|
21 |
#include "sconbackuprestore.h"
|
|
22 |
#include "sconpcdconsts.h"
|
|
23 |
#include "sconinstqueue.h"
|
|
24 |
#include "debug.h"
|
|
25 |
|
|
26 |
// -----------------------------------------------------------------------------
|
|
27 |
// CSConBackupRestoreQueue::NewL( const TInt aMaxObjectSize )
|
|
28 |
// Two-phase constructor
|
|
29 |
// -----------------------------------------------------------------------------
|
|
30 |
//
|
|
31 |
CSConBackupRestoreQueue* CSConBackupRestoreQueue::NewL( const TInt aMaxObjectSize, RFs& aFs )
|
|
32 |
{
|
|
33 |
CSConBackupRestoreQueue* self = new (ELeave) CSConBackupRestoreQueue();
|
|
34 |
CleanupStack::PushL( self );
|
|
35 |
self->ConstructL( aMaxObjectSize, aFs );
|
|
36 |
CleanupStack::Pop( self );
|
|
37 |
return self;
|
|
38 |
}
|
|
39 |
|
|
40 |
// -----------------------------------------------------------------------------
|
|
41 |
// CSConBackupRestoreQueue::CSConBackupRestoreQueue()
|
|
42 |
// Destructor
|
|
43 |
// -----------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
CSConBackupRestoreQueue::CSConBackupRestoreQueue() :
|
|
46 |
CActive( EPriorityStandard )
|
|
47 |
{
|
|
48 |
}
|
|
49 |
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
// CSConBackupRestoreQueue::ConstructL( const TInt aMaxObjectSize )
|
|
52 |
// Initializes member data
|
|
53 |
// -----------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
void CSConBackupRestoreQueue::ConstructL( const TInt aMaxObjectSize, RFs& aFs )
|
|
56 |
{
|
|
57 |
iBackupRestore = CSConBackupRestore::NewL( this, aMaxObjectSize, aFs );
|
|
58 |
CActiveScheduler::Add( iBackupRestore );
|
|
59 |
User::LeaveIfError( iTimer.CreateLocal() );
|
|
60 |
}
|
|
61 |
|
|
62 |
// -----------------------------------------------------------------------------
|
|
63 |
// CSConBackupRestoreQueue::~CSConBackupRestoreQueue()
|
|
64 |
// Destructor
|
|
65 |
// -----------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
CSConBackupRestoreQueue::~CSConBackupRestoreQueue()
|
|
68 |
{
|
|
69 |
TRACE_FUNC_ENTRY;
|
|
70 |
Cancel();
|
|
71 |
if( iBackupRestore )
|
|
72 |
{
|
|
73 |
delete iBackupRestore;
|
|
74 |
iBackupRestore = NULL;
|
|
75 |
}
|
|
76 |
|
|
77 |
TRACE_FUNC_EXIT;
|
|
78 |
}
|
|
79 |
|
|
80 |
// -----------------------------------------------------------------------------
|
|
81 |
// CSConBackupRestoreQueue::StartQueue()
|
|
82 |
// Starts queue polling
|
|
83 |
// -----------------------------------------------------------------------------
|
|
84 |
//
|
|
85 |
void CSConBackupRestoreQueue::StartQueue()
|
|
86 |
{
|
|
87 |
if( IsActive() )
|
|
88 |
{
|
|
89 |
Cancel();
|
|
90 |
}
|
|
91 |
|
|
92 |
iTimer.After( iStatus, KSConTimerValue );
|
|
93 |
SetActive();
|
|
94 |
}
|
|
95 |
|
|
96 |
// -----------------------------------------------------------------------------
|
|
97 |
// CSConBackupRestoreQueue::StopQueue()
|
|
98 |
// Stops queue polling
|
|
99 |
// -----------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
void CSConBackupRestoreQueue::StopQueue()
|
|
102 |
{
|
|
103 |
iTimer.Cancel();
|
|
104 |
}
|
|
105 |
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
// CSConBackupRestoreQueue::AddNewTask( CSConTask*& aNewTask, TInt aTaskId )
|
|
108 |
// Adds a new task to queue
|
|
109 |
// -----------------------------------------------------------------------------
|
|
110 |
//
|
|
111 |
TInt CSConBackupRestoreQueue::AddNewTask( CSConTask*& aNewTask, TInt aTaskId )
|
|
112 |
{
|
|
113 |
LOGGER_WRITE_1( "CSConBackupRestoreQueue::AddNewTask aTaskId: %d", aTaskId );
|
|
114 |
TInt ret( KErrNone );
|
|
115 |
|
|
116 |
aNewTask->iTaskId = aTaskId;
|
|
117 |
|
|
118 |
//Set progress value "task accepted for execution"
|
|
119 |
aNewTask->SetProgressValue( KSConCodeTaskCreated );
|
|
120 |
aNewTask->SetCompleteValue( EFalse );
|
|
121 |
|
|
122 |
//For RequestData and SupplyData
|
|
123 |
if( iQueue.Find( aNewTask, CSConTaskQueue::Match ) != KErrNotFound )
|
|
124 |
{
|
|
125 |
RemoveTask( aTaskId );
|
|
126 |
}
|
|
127 |
|
|
128 |
if( iQueue.Count() == 0 )
|
|
129 |
{
|
|
130 |
StartQueue();
|
|
131 |
}
|
|
132 |
|
|
133 |
ret = iQueue.InsertInOrder( aNewTask, CSConTaskQueue::Compare );
|
|
134 |
return ret;
|
|
135 |
}
|
|
136 |
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
// CSConBackupRestoreQueue::CancelTask( TInt aTask, TBool aAllTasks )
|
|
139 |
// Cancels a task
|
|
140 |
// -----------------------------------------------------------------------------
|
|
141 |
//
|
|
142 |
void CSConBackupRestoreQueue::CancelTask( TInt aTask, TBool aAllTasks )
|
|
143 |
{
|
|
144 |
TRACE_FUNC_ENTRY;
|
|
145 |
//Stop backup/restore
|
|
146 |
if( aTask && !aAllTasks )
|
|
147 |
{
|
|
148 |
LOGGER_WRITE_1("CSConBackupRestoreQueue::CancelTask - Cancel task: %d", aTask);
|
|
149 |
iBackupRestore->StopBackupRestore( aTask );
|
|
150 |
}
|
|
151 |
|
|
152 |
if( aAllTasks )
|
|
153 |
{
|
|
154 |
LOGGER_WRITE("CSConBackupRestoreQueue::CancelTask - Cancel All");
|
|
155 |
iBackupRestore->Cancel();
|
|
156 |
iBackupRestore->Reset();
|
|
157 |
}
|
|
158 |
|
|
159 |
CSConTaskQueue::CancelTask( aTask, aAllTasks );
|
|
160 |
TRACE_FUNC_EXIT;
|
|
161 |
}
|
|
162 |
|
|
163 |
// -----------------------------------------------------------------------------
|
|
164 |
// CSConBackupRestoreQueue::Reset()
|
|
165 |
// Resets the queue
|
|
166 |
// -----------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
void CSConBackupRestoreQueue::Reset()
|
|
169 |
{
|
|
170 |
TRACE_FUNC_ENTRY;
|
|
171 |
CSConTaskQueue::Reset();
|
|
172 |
iBackupRestore->Reset();
|
|
173 |
TRACE_FUNC_EXIT;
|
|
174 |
}
|
|
175 |
|
|
176 |
// -----------------------------------------------------------------------------
|
|
177 |
// CSConBackupRestoreQueue::QueueAddress( CSConInstallerQueue*& aTaskQueue )
|
|
178 |
// An address pointer to another queue
|
|
179 |
// -----------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
void CSConBackupRestoreQueue::QueueAddress( CSConInstallerQueue*& aTaskQueue )
|
|
182 |
{
|
|
183 |
iInstQueueAddress = aTaskQueue;
|
|
184 |
}
|
|
185 |
|
|
186 |
// -----------------------------------------------------------------------------
|
|
187 |
// CSConBackupRestoreQueue::GetTaskMethod( TInt& aTaskId )
|
|
188 |
// Returns the task type
|
|
189 |
// -----------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
TSConMethodName CSConBackupRestoreQueue::GetTaskMethodL( TInt aTaskId )
|
|
192 |
{
|
|
193 |
TRACE_FUNC_ENTRY;
|
|
194 |
CSConTask* task = NULL;
|
|
195 |
CSConTaskQueue::GetTask( aTaskId, task );
|
|
196 |
LOGGER_WRITE_1( "CSConBackupRestoreQueue::GetTaskMethodL( TInt aTaskId ) : returned %d",
|
|
197 |
task->GetServiceId() );
|
|
198 |
return task->GetServiceId();
|
|
199 |
}
|
|
200 |
|
|
201 |
// -----------------------------------------------------------------------------
|
|
202 |
// CSConBackupRestoreQueue::PollQueue()
|
|
203 |
// Polls queue
|
|
204 |
// -----------------------------------------------------------------------------
|
|
205 |
//
|
|
206 |
void CSConBackupRestoreQueue::PollQueue()
|
|
207 |
{
|
|
208 |
// find and start next task if BR and installer is inactive
|
|
209 |
if( !iBackupRestore->BackupRestoreActive()
|
|
210 |
&& !iInstQueueAddress->QueueProcessActive() )
|
|
211 |
{
|
|
212 |
//find next task
|
|
213 |
for( TInt i = 0; i < iQueue.Count(); i++ )
|
|
214 |
{
|
|
215 |
TBool complete = iQueue[i]->GetCompleteValue();
|
|
216 |
|
|
217 |
if( complete == EFalse )
|
|
218 |
{
|
|
219 |
iBackupRestore->StartBackupRestore(
|
|
220 |
iQueue[i]->iTaskId );
|
|
221 |
i = iQueue.Count() + 1; // jump out from loop
|
|
222 |
}
|
|
223 |
}
|
|
224 |
}
|
|
225 |
}
|
|
226 |
|
|
227 |
// -----------------------------------------------------------------------------
|
|
228 |
// Implementation of CActive::DoCancel()
|
|
229 |
// Entry to CSConPCD
|
|
230 |
// -----------------------------------------------------------------------------
|
|
231 |
//
|
|
232 |
void CSConBackupRestoreQueue::DoCancel()
|
|
233 |
{
|
|
234 |
TRACE_FUNC_ENTRY;
|
|
235 |
iTimer.Cancel();
|
|
236 |
TRACE_FUNC_EXIT;
|
|
237 |
}
|
|
238 |
|
|
239 |
// -----------------------------------------------------------------------------
|
|
240 |
// Implementation of CActive::RunL()
|
|
241 |
// Entry to CSConPCD
|
|
242 |
// -----------------------------------------------------------------------------
|
|
243 |
//
|
|
244 |
void CSConBackupRestoreQueue::RunL()
|
|
245 |
{
|
|
246 |
if( iQueue.Count() > 0 )
|
|
247 |
{
|
|
248 |
PollQueue();
|
|
249 |
StartQueue();
|
|
250 |
}
|
|
251 |
}
|
|
252 |
|
|
253 |
// End of file
|