102
|
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: ?Description
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <s32mem.h>
|
|
19 |
|
|
20 |
#include <usif/scr/scr.h>
|
|
21 |
#include <usif/scr/screntries.h>
|
|
22 |
|
|
23 |
#include "caprogresscanner.h"
|
|
24 |
#include "castorageproxy.h"
|
|
25 |
#include "cainnerquery.h"
|
|
26 |
#include "cainnerentry.h"
|
|
27 |
#include "caarraycleanup.inl"
|
|
28 |
#include "casrvplugin.h"
|
|
29 |
|
|
30 |
using namespace Usif;
|
|
31 |
|
|
32 |
// ---------------------------------------------------------------------------
|
|
33 |
//
|
|
34 |
// ---------------------------------------------------------------------------
|
|
35 |
//
|
|
36 |
EXPORT_C CCaProgresScanner* CCaProgresScanner::NewL(
|
|
37 |
TPluginParams* aPluginParam )
|
|
38 |
{
|
|
39 |
CCaProgresScanner* self = new ( ELeave ) CCaProgresScanner(
|
|
40 |
aPluginParam );
|
|
41 |
CleanupStack::PushL( self );
|
|
42 |
self->ConstructL();
|
|
43 |
CleanupStack::Pop( self );
|
|
44 |
return self;
|
|
45 |
}
|
|
46 |
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
CCaProgresScanner::~CCaProgresScanner()
|
|
52 |
{
|
|
53 |
delete iNotifier;
|
|
54 |
iResultArrayItems.ResetAndDestroy();
|
|
55 |
}
|
|
56 |
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CCaProgresScanner::CCaProgresScanner( TPluginParams* aPluginParam ) :
|
|
62 |
iStorageProxy( *aPluginParam->storageProxy ),
|
|
63 |
iSoftwareRegistry( *aPluginParam->softwareRegistry )
|
|
64 |
{
|
|
65 |
}
|
|
66 |
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
//
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
void CCaProgresScanner::ConstructL()
|
|
72 |
{
|
|
73 |
iNotifier = CSifOperationsNotifier::NewL( *this );
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
void CCaProgresScanner::StartOperationHandler( TUint aKey,
|
|
81 |
const CSifOperationStartData& aStartData )
|
|
82 |
{
|
|
83 |
TInt err( KErrNone );
|
|
84 |
TComponentId componentId( 0 );
|
|
85 |
iResultArrayItems.ResetAndDestroy();
|
|
86 |
|
|
87 |
TRAP(err, componentId = iSoftwareRegistry.GetComponentIdL(
|
|
88 |
aStartData.GlobalComponentId(), aStartData.SoftwareType() ));
|
|
89 |
if ( !err )
|
|
90 |
TRAP(err, MarkEntrysForUnistallL(aKey, componentId));
|
|
91 |
|
|
92 |
}
|
|
93 |
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
// ---------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
void CCaProgresScanner::EndOperationHandler(
|
|
99 |
const CSifOperationEndData& aEndData )
|
|
100 |
{
|
|
101 |
TInt err = KErrNone;
|
|
102 |
TRAP( err, EndOperationL( aEndData.ErrorCode() ) );
|
|
103 |
iResultArrayItems.ResetAndDestroy();
|
|
104 |
}
|
|
105 |
|
|
106 |
// ---------------------------------------------------------------------------
|
|
107 |
//
|
|
108 |
// ---------------------------------------------------------------------------
|
|
109 |
//
|
|
110 |
void CCaProgresScanner::ProgressOperationHandler(
|
|
111 |
const CSifOperationProgressData& aProgressData )
|
|
112 |
{
|
|
113 |
TInt err = KErrNone;
|
|
114 |
TRAP( err, UpdateProgressL( aProgressData ) );
|
|
115 |
}
|
|
116 |
|
|
117 |
// ---------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
// ---------------------------------------------------------------------------
|
|
120 |
//
|
|
121 |
void CCaProgresScanner::UpdateProgressL(
|
|
122 |
const CSifOperationProgressData& aProgressData )
|
|
123 |
{
|
|
124 |
RBuf totalProgressBuf;
|
|
125 |
totalProgressBuf.CleanupClosePushL();
|
|
126 |
totalProgressBuf.CreateL( sizeof(TComponentId) + 1 );
|
|
127 |
totalProgressBuf.AppendNum( aProgressData.CurrentProgess() );
|
|
128 |
|
|
129 |
if ( iResultArrayItems.Count() && aProgressData.Phase() == EUninstalling )
|
|
130 |
{
|
|
131 |
for ( int i = 0; i < iResultArrayItems.Count(); i++ )
|
|
132 |
{
|
|
133 |
iResultArrayItems[i]->AddAttributeL( KCaAppUninstallProgress,
|
|
134 |
totalProgressBuf );
|
|
135 |
iStorageProxy.AddL( iResultArrayItems[i], ETrue,
|
|
136 |
EItemUninstallProgressChanged );
|
|
137 |
}
|
|
138 |
}
|
|
139 |
|
|
140 |
CleanupStack::PopAndDestroy( &totalProgressBuf );
|
|
141 |
}
|
|
142 |
|
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
//
|
|
145 |
// ---------------------------------------------------------------------------
|
|
146 |
//
|
|
147 |
void CCaProgresScanner::EndOperationL( TInt aError )
|
|
148 |
{
|
|
149 |
if ( aError )
|
|
150 |
{
|
|
151 |
for ( int i = 0; i < iResultArrayItems.Count(); i++ )
|
|
152 |
{
|
|
153 |
iResultArrayItems[i]->SetFlags( iResultArrayItems[i]->GetFlags()
|
|
154 |
& ~EUninstall );
|
|
155 |
iStorageProxy.AddL( iResultArrayItems[i] );
|
|
156 |
}
|
|
157 |
}
|
|
158 |
iNotifier->CancelSubscribeL( iKey );
|
|
159 |
}
|
|
160 |
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
// ---------------------------------------------------------------------------
|
|
164 |
//
|
|
165 |
void CCaProgresScanner::MarkEntrysForUnistallL( TUint aKey,
|
|
166 |
TComponentId aComponentId )
|
|
167 |
{
|
|
168 |
RBuf componentIdBuf;
|
|
169 |
componentIdBuf.CleanupClosePushL();
|
|
170 |
componentIdBuf.CreateL( sizeof(TComponentId) + 1 );
|
|
171 |
componentIdBuf.AppendNum( aComponentId );
|
|
172 |
|
|
173 |
// find entry by componentID
|
|
174 |
CCaInnerQuery *innerQuery = CCaInnerQuery::NewLC();
|
|
175 |
innerQuery->SetRole( CCaInnerQuery::Item );
|
|
176 |
innerQuery->AddAttributeL( KCaAttrComponentId, componentIdBuf );
|
|
177 |
|
|
178 |
iStorageProxy.GetEntriesL( innerQuery, iResultArrayItems );
|
|
179 |
|
|
180 |
if ( iResultArrayItems.Count() )
|
|
181 |
{
|
|
182 |
for ( int i = 0; i < iResultArrayItems.Count(); i++ )
|
|
183 |
{
|
|
184 |
iResultArrayItems[i]->SetFlags( iResultArrayItems[i]->GetFlags()
|
|
185 |
| EUninstall );
|
|
186 |
iStorageProxy.AddL( iResultArrayItems[i] );
|
|
187 |
}
|
|
188 |
// subscribe for progress notifier
|
|
189 |
iKey = aKey;
|
|
190 |
iNotifier->SubscribeL( aKey, ETrue );
|
|
191 |
}
|
|
192 |
CleanupStack::PopAndDestroy( innerQuery );
|
|
193 |
CleanupStack::PopAndDestroy( &componentIdBuf );
|
|
194 |
}
|