|
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 |
|
23 #include "charvesterpluginvalidator.h" |
|
24 #include "cblacklisthandler.h" |
|
25 |
|
26 const TUint32 KInProgressPropertyKey = { 0x1028000E }; |
|
27 const TUint32 KHarvesterUid = { 0x10282E5A }; |
|
28 |
|
29 // ======== MEMBER FUNCTIONS ======== |
|
30 |
|
31 // ---------------------------------------------------------------------------- |
|
32 // |
|
33 // ---------------------------------------------------------------------------- |
|
34 // |
|
35 EXPORT_C CHarvesterPluginValidator* CHarvesterPluginValidator::NewL( TUid aUid, |
|
36 TAny *aParameter ) |
|
37 { |
|
38 CHarvesterPluginValidator* self = |
|
39 CHarvesterPluginValidator::NewLC( aUid , aParameter ); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // ---------------------------------------------------------------------------- |
|
45 // |
|
46 // ---------------------------------------------------------------------------- |
|
47 // |
|
48 EXPORT_C CHarvesterPluginValidator* CHarvesterPluginValidator::NewLC( TUid aUid, |
|
49 TAny *aParameter ) |
|
50 { |
|
51 CHarvesterPluginValidator* self = new( ELeave ) |
|
52 CHarvesterPluginValidator( aUid, aParameter ); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // destructor |
|
62 // --------------------------------------------------------------------------- |
|
63 CHarvesterPluginValidator::~CHarvesterPluginValidator() |
|
64 { |
|
65 iInProgressProperty.Close( ); |
|
66 delete iBlacklist; |
|
67 } |
|
68 |
|
69 // ---------------------------------------------------------------------------- |
|
70 // |
|
71 // ---------------------------------------------------------------------------- |
|
72 // |
|
73 CHarvesterPluginValidator::CHarvesterPluginValidator( TUid aUid, TAny* aParameter ): |
|
74 CPluginValidator(aUid, aParameter), |
|
75 iStartup( ETrue ) |
|
76 { |
|
77 |
|
78 } |
|
79 |
|
80 // ---------------------------------------------------------------------------- |
|
81 // |
|
82 // ---------------------------------------------------------------------------- |
|
83 // |
|
84 void CHarvesterPluginValidator::ConstructL() |
|
85 { |
|
86 iBlacklist = CBlacklistHandler::NewL( ); |
|
87 CPluginValidator::ConstructL(); |
|
88 } |
|
89 |
|
90 |
|
91 // ---------------------------------------------------------------------------- |
|
92 // |
|
93 // ---------------------------------------------------------------------------- |
|
94 // |
|
95 void CHarvesterPluginValidator::ManagePluginsL() |
|
96 { |
|
97 TInt errorCode = iInProgressProperty.Define( TUid::Uid( KHarvesterUid ), |
|
98 KInProgressPropertyKey, RProperty::EInt ); |
|
99 |
|
100 if ( KErrAlreadyExists == errorCode ) |
|
101 { |
|
102 TInt value(-1); |
|
103 iInProgressProperty.Get( TUid::Uid( KHarvesterUid ), |
|
104 KInProgressPropertyKey, value); |
|
105 if ( value == 1 ) |
|
106 { |
|
107 // property value == inprogress |
|
108 // there was a panic in the previous startup |
|
109 // so we make unofficial blacklist official |
|
110 iBlacklist->CopyBlacklistL( EFalse ); |
|
111 } |
|
112 } |
|
113 else |
|
114 { |
|
115 User::LeaveIfError( errorCode ); |
|
116 } |
|
117 // copy blacklisted plugins to unoffical blacklist at startup |
|
118 iBlacklist->CopyBlacklistL( ETrue ); |
|
119 |
|
120 // set property value to 1 (which means "in progress") |
|
121 iInProgressProperty.Set( TUid::Uid( KHarvesterUid ), |
|
122 KInProgressPropertyKey, 1 ); |
|
123 |
|
124 CPluginValidator::ManagePluginsL(); |
|
125 |
|
126 if ( iStartup ) |
|
127 { |
|
128 RProperty::Set( KPSUidActiveIdle2, |
|
129 KActiveIdleCpsPluginsUpdated , EPSAiPluginsUpdated ); |
|
130 iStartup = EFalse; |
|
131 } |
|
132 // set property value to 0 (which means "finished") |
|
133 iInProgressProperty.Set( TUid::Uid( KHarvesterUid ), |
|
134 KInProgressPropertyKey, 0 ); |
|
135 } |
|
136 |
|
137 // ---------------------------------------------------------------------------- |
|
138 // |
|
139 // ---------------------------------------------------------------------------- |
|
140 // |
|
141 void CHarvesterPluginValidator::LoadPluginL( TPluginInfo& aPluginInfo ) |
|
142 { |
|
143 if ( !iBlacklist->IsPresentL( aPluginInfo.iImplementationUid ) ) |
|
144 { |
|
145 //first we append UID to the blacklist |
|
146 iBlacklist->AppendL( aPluginInfo.iImplementationUid ); |
|
147 TAny* plug ( NULL ); |
|
148 TInt err( KErrNone ); |
|
149 TRAP( err, plug = REComSession::CreateImplementationL( |
|
150 aPluginInfo.iImplementationUid, |
|
151 aPluginInfo.iDtor_ID_Key, iParameter ) ); |
|
152 if( err==KErrNone && plug ) |
|
153 { |
|
154 TRAP_IGNORE( |
|
155 CleanupStack::PushL( plug ); |
|
156 aPluginInfo.iPlugin = plug; |
|
157 iPluginArray.AppendL( aPluginInfo ); |
|
158 CleanupStack::Pop( plug ); |
|
159 static_cast<CContentHarvesterPlugin*>( plug )->UpdateL() |
|
160 ); |
|
161 } |
|
162 //no panic during load so we can remove UID from blacklist |
|
163 iBlacklist->RemoveL( aPluginInfo.iImplementationUid ); |
|
164 } |
|
165 } |
|
166 |
|
167 |
|
168 |
|
169 |