|
1 /* |
|
2 * Copyright (c) 2007 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 the License "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 |
|
19 #include "wrtharvesterpsnotifier.h" |
|
20 #include "wrtharvester.h" |
|
21 #include <UikonInternalPSKeys.h>//For MMC Observing |
|
22 |
|
23 // ============================ MEMBER FUNCTIONS ============================= |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // Creates an instance of CCHPluginNotifier implementation |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 CWrtHarvesterPSNotifier* CWrtHarvesterPSNotifier::NewL( |
|
30 CWrtHarvester* aHarvester, TPropertyKeys aKey ) |
|
31 { |
|
32 CWrtHarvesterPSNotifier* self = new (ELeave) CWrtHarvesterPSNotifier( |
|
33 aHarvester, aKey ); |
|
34 CleanupStack::PushL( self ); |
|
35 self->ConstructL(); |
|
36 CleanupStack::Pop( self ); |
|
37 |
|
38 return self; |
|
39 } |
|
40 |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // Destructor |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CWrtHarvesterPSNotifier::~CWrtHarvesterPSNotifier() |
|
47 { |
|
48 Cancel(); |
|
49 iProperty.Close(); |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CWrtHarvesterPSNotifier::CCHPluginNotifier |
|
54 // C++ default constructor |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CWrtHarvesterPSNotifier::CWrtHarvesterPSNotifier( |
|
58 CWrtHarvester* aHarvester, TPropertyKeys aKey ) : CActive( EPriorityNormal ) |
|
59 { |
|
60 iHarvester = aHarvester; |
|
61 iKey = aKey; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CWrtHarvesterPSNotifier::ConstructL |
|
66 // S2nd phase constructor. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CWrtHarvesterPSNotifier::ConstructL() |
|
70 { |
|
71 CActiveScheduler::Add( this ); |
|
72 TInt r(KErrNone); |
|
73 if( iKey != EWidgetMMCAltered ) |
|
74 { |
|
75 // define property to be integer type |
|
76 r = RProperty::Define( KPropertyCat, iKey, RProperty::EInt ); |
|
77 } |
|
78 |
|
79 if ( r != KErrAlreadyExists || r != KErrNone ) |
|
80 { |
|
81 User::LeaveIfError( r ); |
|
82 } |
|
83 // Attach the key |
|
84 if( iKey == EWidgetMMCAltered ) |
|
85 { |
|
86 User::LeaveIfError( iProperty.Attach( KPSUidUikon,KUikMMCInserted )); |
|
87 } |
|
88 else |
|
89 { |
|
90 User::LeaveIfError( iProperty.Attach( KPropertyCat, iKey)); |
|
91 } |
|
92 |
|
93 |
|
94 // Set the initial value to indicate that first widget can be launched |
|
95 if( iKey == EWidgetUIState ) |
|
96 { |
|
97 User::LeaveIfError( iProperty.Set( 1 )); |
|
98 } |
|
99 |
|
100 // initial subscription |
|
101 iProperty.Subscribe( iStatus ); |
|
102 SetActive(); |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // CWrtHarvesterPSNotifier::DoCancel |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 void CWrtHarvesterPSNotifier::DoCancel() |
|
110 { |
|
111 iProperty.Cancel(); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // CWrtHarvesterPSNotifier::RunL |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 void CWrtHarvesterPSNotifier::RunL() |
|
119 { |
|
120 // resubscribe before processing new value to prevent missing updates |
|
121 iProperty.Subscribe( iStatus ); |
|
122 SetActive(); |
|
123 |
|
124 TInt value( 0 ); |
|
125 TInt r (KErrNone); |
|
126 if( iKey != EWidgetMMCAltered ) |
|
127 { |
|
128 iProperty.Get( KPropertyCat, iKey, value ); |
|
129 } |
|
130 else |
|
131 { |
|
132 iProperty.Get( KPSUidUikon, KUikMMCInserted , value ); |
|
133 } |
|
134 |
|
135 if( r == KErrNone ) |
|
136 { |
|
137 if( iKey == EWidgetUIState && value == 1 ) |
|
138 { |
|
139 iHarvester->TryLaunchNextWidgetL(); |
|
140 } |
|
141 else if( iKey == EWidgetRegAltered && value == 1 ) |
|
142 { |
|
143 iHarvester->UpdateL(); |
|
144 } |
|
145 else if( iKey ==EWidgetMMCAltered ) |
|
146 { |
|
147 iHarvester->UpdateL(); |
|
148 } |
|
149 } |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // CCHPluginNotifier::RunError |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 TInt CWrtHarvesterPSNotifier::RunError(TInt /*aError*/) |
|
157 { |
|
158 if ( !IsActive()) |
|
159 { |
|
160 iProperty.Subscribe( iStatus ); |
|
161 SetActive(); |
|
162 } |
|
163 return KErrNone; |
|
164 } |
|
165 |
|
166 // --------------------------------------------------------------------------- |
|
167 // CCHPluginNotifier::Value |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 TInt CWrtHarvesterPSNotifier::GetValue( TInt& aValue) |
|
171 { |
|
172 return iProperty.Get( aValue ); |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // CWrtHarvesterPSNotifier::Value |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 TInt CWrtHarvesterPSNotifier::SetValue( TInt aValue ) |
|
180 { |
|
181 return iProperty.Set( aValue ); |
|
182 } |
|
183 |
|
184 // End of File |