30
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 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 |
|
|
18 |
#include <e32property.h>
|
|
19 |
#include <ecom/ecom.h>
|
|
20 |
#include <mmf/common/mmfcontrollerpluginresolver.h>
|
|
21 |
#include <contentharvesterplugin.h> // harvesting plugin
|
|
22 |
#include "charvesterpluginvalidator.h"
|
|
23 |
#include "cblacklisthandler.h"
|
|
24 |
|
|
25 |
const TUint32 KInProgressPropertyKey =
|
|
26 |
{
|
|
27 |
0x1028000E
|
|
28 |
};
|
|
29 |
const TUint32 KHarvesterUid =
|
|
30 |
{
|
|
31 |
0x10282E5A
|
|
32 |
};
|
|
33 |
|
|
34 |
const TInt KADatFactorySettingsServerPluginUid(0x102830EF);
|
|
35 |
|
|
36 |
// ======== MEMBER FUNCTIONS ========
|
|
37 |
|
|
38 |
// ----------------------------------------------------------------------------
|
|
39 |
//
|
|
40 |
// ----------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
EXPORT_C CHarvesterPluginValidator* CHarvesterPluginValidator::NewL(
|
|
43 |
TUid aUid, TAny *aParameter)
|
|
44 |
{
|
|
45 |
CHarvesterPluginValidator* self = CHarvesterPluginValidator::NewLC(aUid,
|
|
46 |
aParameter);
|
|
47 |
CleanupStack::Pop(self);
|
|
48 |
return self;
|
|
49 |
}
|
|
50 |
|
|
51 |
// ----------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
// ----------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
EXPORT_C CHarvesterPluginValidator* CHarvesterPluginValidator::NewLC(
|
|
56 |
TUid aUid, TAny *aParameter)
|
|
57 |
{
|
|
58 |
CHarvesterPluginValidator* self = new (ELeave) CHarvesterPluginValidator(
|
|
59 |
aUid, aParameter);
|
|
60 |
CleanupStack::PushL(self);
|
|
61 |
self->ConstructL();
|
|
62 |
return self;
|
|
63 |
}
|
|
64 |
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
// destructor
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
CHarvesterPluginValidator::~CHarvesterPluginValidator()
|
|
69 |
{
|
|
70 |
iInProgressProperty.Close();
|
|
71 |
delete iBlacklist;
|
|
72 |
delete iUpdateIdle;
|
|
73 |
}
|
|
74 |
|
|
75 |
// ----------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
// ----------------------------------------------------------------------------
|
|
78 |
//
|
|
79 |
CHarvesterPluginValidator::CHarvesterPluginValidator(TUid aUid,
|
|
80 |
TAny* aParameter) :
|
|
81 |
CPluginValidator(aUid, aParameter)
|
|
82 |
{
|
|
83 |
|
|
84 |
}
|
|
85 |
|
|
86 |
// ----------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
// ----------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
void CHarvesterPluginValidator::ConstructL()
|
|
91 |
{
|
|
92 |
iBlacklist = CBlacklistHandler::NewL();
|
|
93 |
iUpdateIdle = CIdle::NewL( CActive::EPriorityIdle );
|
|
94 |
iUpdateIdle->Start( TCallBack( UpdateCallback, this ) );
|
|
95 |
CPluginValidator::ConstructL();
|
|
96 |
}
|
|
97 |
|
|
98 |
// ----------------------------------------------------------------------------
|
|
99 |
//
|
|
100 |
// ----------------------------------------------------------------------------
|
|
101 |
//
|
|
102 |
void CHarvesterPluginValidator::ManagePluginsL()
|
|
103 |
{
|
|
104 |
TInt errorCode = iInProgressProperty.Define(TUid::Uid(KHarvesterUid),
|
|
105 |
KInProgressPropertyKey, RProperty::EInt);
|
|
106 |
|
|
107 |
if (KErrAlreadyExists == errorCode)
|
|
108 |
{
|
|
109 |
TInt value(-1);
|
|
110 |
iInProgressProperty.Get(TUid::Uid(KHarvesterUid),
|
|
111 |
KInProgressPropertyKey, value);
|
|
112 |
if (value == 1)
|
|
113 |
{
|
|
114 |
// property value == inprogress
|
|
115 |
// there was a panic in the previous startup
|
|
116 |
// so we make unofficial blacklist official
|
|
117 |
iBlacklist->CopyBlacklistL(EFalse);
|
|
118 |
}
|
|
119 |
}
|
|
120 |
else
|
|
121 |
{
|
|
122 |
User::LeaveIfError(errorCode);
|
|
123 |
}
|
|
124 |
// copy blacklisted plugins to unoffical blacklist at startup
|
|
125 |
iBlacklist->CopyBlacklistL(ETrue);
|
|
126 |
|
|
127 |
// set property value to 1 (which means "in progress")
|
|
128 |
iInProgressProperty.Set(TUid::Uid(KHarvesterUid), KInProgressPropertyKey,
|
|
129 |
1);
|
|
130 |
CPluginValidator::ManagePluginsL();
|
|
131 |
// set property value to 0 (which means "finished")
|
|
132 |
iInProgressProperty.Set( TUid::Uid( KHarvesterUid ),
|
|
133 |
KInProgressPropertyKey, 0 );
|
|
134 |
}
|
|
135 |
|
|
136 |
// ----------------------------------------------------------------------------
|
|
137 |
//
|
|
138 |
// ----------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
void CHarvesterPluginValidator::LoadPluginL(TPluginInfo& aPluginInfo)
|
|
141 |
{
|
|
142 |
if (!iBlacklist->IsPresentL(aPluginInfo.iImplementationUid))
|
|
143 |
{
|
|
144 |
//first we append UID to the blacklist
|
|
145 |
iBlacklist->AppendL(aPluginInfo.iImplementationUid);
|
|
146 |
TAny* plug(NULL);
|
|
147 |
TInt err(KErrNone);
|
|
148 |
TRAP( err, plug = REComSession::CreateImplementationL(
|
|
149 |
aPluginInfo.iImplementationUid,
|
|
150 |
aPluginInfo.iDtor_ID_Key, iParameter ) );
|
|
151 |
if (err == KErrNone && plug)
|
|
152 |
{
|
|
153 |
TRAP_IGNORE(
|
|
154 |
CleanupStack::PushL( plug );
|
|
155 |
aPluginInfo.iPlugin = plug;
|
|
156 |
iPluginArray.AppendL( aPluginInfo );
|
|
157 |
CleanupStack::Pop( plug );
|
|
158 |
);
|
|
159 |
}
|
|
160 |
//no panic during load so we can remove UID from blacklist
|
|
161 |
iBlacklist->RemoveL(aPluginInfo.iImplementationUid);
|
|
162 |
}
|
|
163 |
}
|
|
164 |
|
|
165 |
// ----------------------------------------------------------------------------
|
|
166 |
//
|
|
167 |
// ----------------------------------------------------------------------------
|
|
168 |
//
|
|
169 |
void CHarvesterPluginValidator::UpdatePluginsL()
|
|
170 |
{
|
|
171 |
// set property value to 1 (which means "in progress")
|
|
172 |
iInProgressProperty.Set(TUid::Uid(KHarvesterUid), KInProgressPropertyKey, 1);
|
|
173 |
CContentHarvesterPlugin* plugin = NULL;
|
|
174 |
CContentHarvesterPlugin* fsplugin =
|
|
175 |
static_cast<CContentHarvesterPlugin*> (GetImplementation(
|
|
176 |
TUid::Uid(KADatFactorySettingsServerPluginUid)));
|
|
177 |
|
|
178 |
if (fsplugin)
|
|
179 |
{
|
|
180 |
iBlacklist->AppendL(TUid::Uid(KADatFactorySettingsServerPluginUid));
|
|
181 |
TRAP_IGNORE( fsplugin->UpdateL() );
|
|
182 |
iBlacklist->RemoveL(TUid::Uid(KADatFactorySettingsServerPluginUid));
|
|
183 |
}
|
|
184 |
for (TInt i = 0; i < iPluginArray.Count(); i++)
|
|
185 |
{
|
|
186 |
plugin
|
|
187 |
= static_cast<CContentHarvesterPlugin*> (iPluginArray[i].iPlugin);
|
|
188 |
if (plugin != fsplugin)
|
|
189 |
{
|
|
190 |
//first we append UID to the blacklist
|
|
191 |
iBlacklist->AppendL(iPluginArray[i].iImplementationUid);
|
|
192 |
TRAP_IGNORE( plugin->UpdateL() );
|
|
193 |
//no panic during update so we can remove UID from blacklist
|
|
194 |
iBlacklist->RemoveL(iPluginArray[i].iImplementationUid);
|
|
195 |
}
|
|
196 |
}
|
|
197 |
// set property value to 0 (which means "finished")
|
|
198 |
iInProgressProperty.Set(TUid::Uid(KHarvesterUid), KInProgressPropertyKey,
|
|
199 |
0);
|
|
200 |
}
|
|
201 |
|
|
202 |
// -----------------------------------------------------------------------------
|
|
203 |
//
|
|
204 |
// -----------------------------------------------------------------------------
|
|
205 |
//
|
|
206 |
TInt CHarvesterPluginValidator::UpdateCallback( TAny* aValidator )
|
|
207 |
{
|
|
208 |
if ( aValidator )
|
|
209 |
{
|
|
210 |
TRAP_IGNORE( static_cast<CHarvesterPluginValidator*>(aValidator)->
|
|
211 |
UpdatePluginsL( ));
|
|
212 |
}
|
|
213 |
return KErrNone;
|
|
214 |
}
|