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: Installer Queue implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "sconinstqueue.h" |
|
21 #include "sconbrqueue.h" |
|
22 #include "sconinstaller.h" |
|
23 #include "sconpcdconsts.h" |
|
24 #include "debug.h" |
|
25 |
|
26 // ============================= MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CCSConInstallerQueue* CSConInstallerQueue::NewL() |
|
30 // Two-phase constructor |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CSConInstallerQueue* CSConInstallerQueue::NewL( RFs& aFs ) |
|
34 { |
|
35 TRACE_FUNC_ENTRY; |
|
36 CSConInstallerQueue* self = new (ELeave) CSConInstallerQueue( aFs ); |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop( self ); |
|
40 TRACE_FUNC_EXIT; |
|
41 return self; |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CSConInstallerQueue::CSConInstallerQueue() |
|
46 // Constructor |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CSConInstallerQueue::CSConInstallerQueue( RFs& aFs ) : CActive( EPriorityStandard ), iFs( aFs ) |
|
50 { |
|
51 CActiveScheduler::Add( this ); |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CSConInstallerQueue::ConstructL() |
|
56 // Initializes member data |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 void CSConInstallerQueue::ConstructL() |
|
60 { |
|
61 TRACE_FUNC_ENTRY; |
|
62 iInstaller = CSConAppInstaller::NewL( this, iFs ); |
|
63 User::LeaveIfError( iTimer.CreateLocal() ); |
|
64 TRACE_FUNC_EXIT; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CSConInstallerQueue::~CSConInstallerQueue() |
|
69 // Destructor |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CSConInstallerQueue::~CSConInstallerQueue() |
|
73 { |
|
74 TRACE_FUNC_ENTRY; |
|
75 Cancel(); |
|
76 if( iInstaller ) |
|
77 { |
|
78 iInstaller->Cancel(); |
|
79 delete iInstaller; |
|
80 iInstaller = NULL; |
|
81 } |
|
82 TRACE_FUNC_EXIT; |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CSConInstallerQueue::StartQueue() |
|
87 // Starts queue polling |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CSConInstallerQueue::StartQueue() |
|
91 { |
|
92 TRACE_FUNC; |
|
93 if( IsActive() ) |
|
94 { |
|
95 Cancel(); |
|
96 } |
|
97 |
|
98 iTimer.After( iStatus, KSConTimerValue ); |
|
99 SetActive(); |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CSConInstallerQueue::StartQueue() |
|
104 // Stops queue polling |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void CSConInstallerQueue::StopQueue() |
|
108 { |
|
109 TRACE_FUNC_ENTRY; |
|
110 iTimer.Cancel(); |
|
111 TRACE_FUNC_EXIT; |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CSConInstallerQueue::CancelTask( TInt aTask, TBool aAllTasks ) |
|
116 // Cancels a task |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 void CSConInstallerQueue::CancelTask( TInt aTask, TBool aAllTasks ) |
|
120 { |
|
121 TRACE_FUNC_ENTRY; |
|
122 //Stop the installer |
|
123 if( aTask && !aAllTasks ) |
|
124 { |
|
125 iInstaller->StopInstaller( aTask ); |
|
126 } |
|
127 |
|
128 if( aAllTasks ) |
|
129 { |
|
130 iInstaller->Cancel(); |
|
131 } |
|
132 CSConTaskQueue::CancelTask( aTask, aAllTasks ); |
|
133 TRACE_FUNC_EXIT; |
|
134 } |
|
135 |
|
136 // ----------------------------------------------------------------------------- |
|
137 // CSConInstallerQueue::QueueAddress( CSConBackupRestoreQueue*& aTaskQueue ) |
|
138 // An address pointer to another queue |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 void CSConInstallerQueue::QueueAddress( CSConBackupRestoreQueue*& aTaskQueue ) |
|
142 { |
|
143 TRACE_FUNC; |
|
144 iBRQueueAddress = aTaskQueue; |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CSConInstallerQueue::PollQueue() |
|
149 // Polls queue |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CSConInstallerQueue::PollQueue() |
|
153 { |
|
154 TRACE_FUNC; |
|
155 // find and start next task if installer and BR is inactive |
|
156 if( !iInstaller->InstallerActive() |
|
157 && !iBRQueueAddress->QueueProcessActive() ) |
|
158 { |
|
159 //find next task |
|
160 for( TInt i = 0; i < iQueue.Count(); i++ ) |
|
161 { |
|
162 TBool complete = iQueue[i]->GetCompleteValue(); |
|
163 |
|
164 if( complete == EFalse ) |
|
165 { |
|
166 iInstaller->StartInstaller( iQueue[i]->iTaskId ); |
|
167 i = iQueue.Count() + 1; // jump out from loop |
|
168 } |
|
169 } |
|
170 } |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CSConInstallerQueue::DoCancel() |
|
175 // Implementation of CActive::DoCancel() |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 void CSConInstallerQueue::DoCancel() |
|
179 { |
|
180 TRACE_FUNC; |
|
181 iTimer.Cancel(); |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CSConInstallerQueue::RunL() |
|
186 // Implementation of CActive::RunL() |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 void CSConInstallerQueue::RunL() |
|
190 { |
|
191 TRACE_FUNC_ENTRY; |
|
192 LOGGER_WRITE_1( "There are still %d tasks in this queue", iQueue.Count() ); |
|
193 if( iQueue.Count() > 0 ) |
|
194 { |
|
195 PollQueue(); |
|
196 StartQueue(); |
|
197 } |
|
198 TRACE_FUNC_EXIT; |
|
199 } |
|
200 |
|
201 // End of file |
|