16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 |
19 |
20 // INCLUDE FILES |
20 // INCLUDE FILES |
21 #include <AknDynamicSoftNotifier.h> |
21 #include <hbindicatorsymbian.h> |
22 #include <AknDynamicSoftNotificationParams.h> |
22 #include <hbsymbianvariant.h> |
23 |
23 |
24 #include "iaupdatebgsoftnotification.h" |
24 #include "iaupdatebgsoftnotification.h" |
25 #include "iaupdatebginternalfilehandler.h" |
25 #include "iaupdatebginternalfilehandler.h" |
26 #include "iaupdatebgconst.h" |
26 #include "iaupdatebgconst.h" |
27 #include "iaupdatebglogger.h" |
27 #include "iaupdatebglogger.h" |
28 |
28 |
|
29 // Indicator type |
|
30 _LIT(KIndicatorTypeBgc, "com.nokia.iaupdate.indicatorplugin/1.0"); |
29 |
31 |
30 // ============================ MEMBER FUNCTIONS =============================== |
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 void CIAUpdateBGSoftNotification::NotificationDialogActivated( |
|
34 const CHbDeviceNotificationDialogSymbian* /* aDialog */) |
|
35 { |
|
36 |
|
37 FLOG("[bgchecker] softnotification callback function ACCEPTED"); |
|
38 |
|
39 // indicator shall not be shown |
|
40 SetIndicatorEnabled( EFalse ); |
|
41 |
|
42 // Remove (possibly) existing indicator |
|
43 RemoveIndicatorL(); |
|
44 |
|
45 iCallback->SoftNotificationCallBack( ETrue ); |
|
46 |
|
47 // remove dialog |
|
48 //delete iNotificationDialog; |
|
49 //iNotificationDialog = 0; |
|
50 |
|
51 return; |
|
52 } |
|
53 |
|
54 void CIAUpdateBGSoftNotification::NotificationDialogClosed |
|
55 ( const CHbDeviceNotificationDialogSymbian* /* aDialog */, |
|
56 TInt /* aCompletionCode*/ ) |
|
57 { |
|
58 |
|
59 |
|
60 FLOG("[bgchecker] softnotification callback function Closed"); |
|
61 |
|
62 // Set indicator, if needed |
|
63 if (IsIndicatorEnabled()) |
|
64 { |
|
65 ShowIndicatorL(); |
|
66 } |
|
67 |
|
68 |
|
69 iCallback->SoftNotificationCallBack( EFalse ); |
|
70 |
|
71 // remove dialog |
|
72 //delete iNotificationDialog; |
|
73 //iNotificationDialog = 0; |
|
74 |
|
75 return; |
|
76 } |
|
77 |
|
78 |
31 // ----------------------------------------------------------------------------- |
79 // ----------------------------------------------------------------------------- |
32 // CIAUpdateBGSoftNotification::NewLC |
80 // CIAUpdateBGSoftNotification::NewLC |
33 // Static constructor |
81 // Static constructor |
34 // ----------------------------------------------------------------------------- |
82 // ----------------------------------------------------------------------------- |
35 // |
83 // |
36 CIAUpdateBGSoftNotification* CIAUpdateBGSoftNotification::NewL( MIAUpdateBGSoftNotificationCallBack* aCallback, |
84 CIAUpdateBGSoftNotification* CIAUpdateBGSoftNotification::NewL( |
37 CIAUpdateBGInternalFileHandler* aInternalFile ) |
85 MIAUpdateBGSoftNotificationCallBack* aCallback ) |
38 { |
86 { |
39 CIAUpdateBGSoftNotification* self = |
87 CIAUpdateBGSoftNotification* self = |
40 new ( ELeave ) CIAUpdateBGSoftNotification( aCallback, aInternalFile ); |
88 new ( ELeave ) CIAUpdateBGSoftNotification( aCallback ); |
41 CleanupStack::PushL( self ); |
89 CleanupStack::PushL( self ); |
42 |
90 |
43 self->ConstructL(); |
91 self->ConstructL(); |
44 CleanupStack::Pop( self ); |
92 CleanupStack::Pop( self ); |
45 |
93 |
50 // Destructor |
98 // Destructor |
51 // ----------------------------------------------------------------------------- |
99 // ----------------------------------------------------------------------------- |
52 // |
100 // |
53 CIAUpdateBGSoftNotification::~CIAUpdateBGSoftNotification() |
101 CIAUpdateBGSoftNotification::~CIAUpdateBGSoftNotification() |
54 { |
102 { |
55 delete iSoftkey1; |
103 |
56 delete iSoftkey2; |
104 delete iTitle; |
57 |
105 delete iText; |
58 delete iLabel; |
106 |
59 delete iGroupLabel; |
107 delete iImagePath; |
60 |
108 |
61 delete iImageData; |
109 delete iNotificationDialog; |
62 |
110 |
63 delete iNotifier; |
111 } |
64 } |
112 |
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CIAUpdateBGSoftNotification::NotificationAccepted |
|
68 // Dynamic soft notification was accepted by user. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CIAUpdateBGSoftNotification::NotificationAccepted( TInt /*aIdentifier*/ ) |
|
72 { |
|
73 FLOG("[bgchecker] softnotification callback function ACCEPTED"); |
|
74 //remove the soft notifiation id |
|
75 iInternalFile->SetSoftNotificationID( 0 ); |
|
76 TRAP_IGNORE( iInternalFile->WriteControllerDataL() ); |
|
77 |
|
78 iCallback->SoftNotificationCallBack( ETrue ); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CIAUpdateBGSoftNotification::NotificationCanceled |
|
83 // Dynamic soft notification was canceled by user. |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CIAUpdateBGSoftNotification::NotificationCanceled( TInt /*aIdentifier*/ ) |
|
87 { |
|
88 FLOG("[bgchecker] softnotification callback function Canceled"); |
|
89 //remove the soft notifiation id |
|
90 iInternalFile->SetSoftNotificationID( 0 ); |
|
91 TRAP_IGNORE( iInternalFile->WriteControllerDataL() ); |
|
92 |
|
93 iCallback->SoftNotificationCallBack( EFalse ); |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
113 // ----------------------------------------------------------------------------- |
97 // CIAUpdateBGSoftNotification::ShowSoftNotificationL |
114 // CIAUpdateBGSoftNotification::ShowSoftNotificationL |
98 // Displays a soft notification |
115 // Displays notification |
99 // ----------------------------------------------------------------------------- |
116 // ----------------------------------------------------------------------------- |
100 // |
117 // |
101 void CIAUpdateBGSoftNotification::ShowSoftNotificationL() |
118 void CIAUpdateBGSoftNotification::ShowNotificationL() |
102 { |
119 { |
103 TAknDynamicSoftNotificationParams param( KSoftNotificationPriority ); |
120 _LIT( KIcon, "C:\\qgn_note_swupdate_notification.svg" ); |
104 FillNotificationParams( param ); |
121 _LIT( KFirstTimeText, "Check for updates ?" ); |
105 |
122 _LIT( KNormalText, "Check for updates ?" ); |
106 TInt oldId = iNotificationId; |
123 _LIT( KTextRow2, "Tap to view" ); |
107 iNotificationId = |
124 |
108 iNotifier->SetDynamicNotificationCountL( param, iNotificationId, 1 ); |
125 FLOG("[bgchecker] ShowNotificationL"); |
109 |
126 |
110 if( oldId != iNotificationId ) |
127 // crete dialog, id does not exist already |
111 { |
128 if (!iNotificationDialog) |
112 FLOG("[bgchecker] softnotification save notification Id"); |
129 { |
113 iInternalFile->SetSoftNotificationID( iNotificationId ); |
130 iNotificationDialog = CHbDeviceNotificationDialogSymbian::NewL( this ); |
114 TRAP_IGNORE( iInternalFile->WriteControllerDataL() ); |
131 } |
115 |
132 |
116 iNotifier->StopObserving( oldId ); |
133 //CleanupStack::PushL( notificationDialog ); // --> memberiin - delete closessa/activaatiossa/destructorissa |
117 iNotifier->StartObservingL( iNotificationId, this ); |
134 // + leave kiinni + tuhoaminen |
118 } |
135 // save number of updates |
119 } |
136 //SetNrOfUpdates ( aNrOfUpdates ); |
120 |
137 |
121 // ----------------------------------------------------------------------------- |
138 // enable indicator showing |
122 // CIAUpdateBGSoftNotification::RemoveSoftNotificationL |
139 SetIndicatorEnabled( ETrue ); |
123 // Cancels and removes the soft notification |
140 |
124 // ----------------------------------------------------------------------------- |
141 // fill texts, icon & behaviour parameters |
125 // |
142 FillNotificationParams(); |
126 void CIAUpdateBGSoftNotification::RemoveSoftNotificationL( TInt aNotifierId ) |
143 |
127 { |
144 iNotificationDialog->ShowL(); |
128 if ( aNotifierId != 0 ) |
145 |
129 { |
146 return; |
130 iNotifier->CancelDynamicNotificationL( aNotifierId ); |
147 |
131 } |
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CIAUpdateBGSoftNotification::ShowIndicatorL |
|
152 // Displays indicator |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void CIAUpdateBGSoftNotification::ShowIndicatorL() |
|
156 { |
|
157 |
|
158 FLOG("[bgchecker] ShowIndicatorL"); |
|
159 |
|
160 CHbIndicatorSymbian *ind = CHbIndicatorSymbian::NewL(); |
|
161 CleanupStack::PushL( ind ); |
|
162 |
|
163 TInt value = GetNrOfUpdates(); |
|
164 |
|
165 // Set indicator |
|
166 CHbSymbianVariant* varValue = CHbSymbianVariant::NewL( &value, |
|
167 CHbSymbianVariant::EInt ); |
|
168 CleanupStack::PushL( varValue ); |
|
169 // Temporary removal |
|
170 // ind->Activate( KIndicatorTypeBgc, varValue ); |
|
171 CleanupStack::PopAndDestroy( varValue ); |
|
172 CleanupStack::PopAndDestroy( ind ); |
|
173 |
|
174 return; |
|
175 |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CIAUpdateBGSoftNotification::Remove indicator |
|
180 // Removes indicator |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 void CIAUpdateBGSoftNotification::RemoveIndicatorL() |
|
184 { |
|
185 |
|
186 FLOG("[bgchecker] RemoveIndicatorL"); |
|
187 |
|
188 CHbIndicatorSymbian *ind = CHbIndicatorSymbian::NewL(); |
|
189 CleanupStack::PushL( ind ); |
|
190 // Temporary removal |
|
191 // ind->Deactivate( KIndicatorTypeBgc ); |
|
192 CleanupStack::PopAndDestroy(ind); |
|
193 |
|
194 return; |
|
195 |
132 } |
196 } |
133 |
197 |
134 // ----------------------------------------------------------------------------- |
198 // ----------------------------------------------------------------------------- |
135 // CIAUpdateBGSoftNotification::SetTextL |
199 // CIAUpdateBGSoftNotification::SetTextL |
136 // Sets a text for a soft notification |
200 // Sets a text for a soft notification |
137 // ----------------------------------------------------------------------------- |
201 // ----------------------------------------------------------------------------- |
138 // |
202 // |
139 void CIAUpdateBGSoftNotification::SetTextL( const TDesC& aText, const TDesC& aGroupText ) |
203 void CIAUpdateBGSoftNotification::SetTextL( |
140 { |
204 const TDesC& aTitle, const TDesC& aText ) |
141 HBufC* txt = aText.AllocL(); |
205 { |
142 delete iLabel; |
206 HBufC* txt = aTitle.AllocL(); |
143 iLabel = txt; |
207 delete iTitle; |
144 |
208 iTitle = txt; |
145 txt = aGroupText.AllocL(); |
209 |
146 delete iGroupLabel; |
210 txt = aText.AllocL(); |
147 iGroupLabel = txt; |
211 delete iText; |
148 } |
212 iText = txt; |
149 |
213 } |
150 // ----------------------------------------------------------------------------- |
214 |
151 // CIAUpdateBGSoftNotification::SetSoftkeyLabelsL |
215 // ----------------------------------------------------------------------------- |
152 // Sets new labels for softkeys |
216 // CIAUpdateBGSoftNotification::SetImagePathL |
153 // ----------------------------------------------------------------------------- |
217 // Sets an image path for a soft notification |
154 // |
218 // ----------------------------------------------------------------------------- |
155 void CIAUpdateBGSoftNotification::SetSoftkeyLabelsL( |
219 // |
156 const TDesC& aSoftkey1Label, |
220 void CIAUpdateBGSoftNotification::SetImagePathL( const TDesC& aImage ) |
157 const TDesC& aSoftkey2Label ) |
221 { |
158 { |
222 HBufC* txt = aImage.AllocL(); |
159 HBufC* txt = aSoftkey1Label.AllocL(); |
223 delete iImagePath; |
160 delete iSoftkey1; |
224 iImagePath = txt; |
161 iSoftkey1 = txt; |
225 return; |
162 |
226 } |
163 txt = aSoftkey2Label.AllocL(); |
227 |
164 delete iSoftkey2; |
228 // ----------------------------------------------------------------------------- |
165 iSoftkey2 = txt; |
229 // CIAUpdateBGSoftNotification::SetNrOfUpdates |
166 } |
230 // Sets an image path for a soft notification |
167 |
231 // ----------------------------------------------------------------------------- |
168 // ----------------------------------------------------------------------------- |
232 // |
169 // CIAUpdateBGSoftNotification::SetImageL |
233 void CIAUpdateBGSoftNotification::SetNrOfUpdates( const TInt& aNrOfUpdates) |
170 // Sets an image for a soft notification |
234 { |
171 // ----------------------------------------------------------------------------- |
235 // save number of updates |
172 // |
236 iNrOfUpdates = aNrOfUpdates; |
173 void CIAUpdateBGSoftNotification::SetImageL( |
237 return; |
174 const TDesC8& aImage ) |
238 } |
175 { |
|
176 HBufC8* image = aImage.AllocL(); |
|
177 delete iImageData; |
|
178 iImageData = image; |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CIAUpdateBGSoftNotification::Id |
|
183 // Notification Id |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 TInt CIAUpdateBGSoftNotification::Id() |
|
187 { |
|
188 return iNotificationId; |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
239 // ----------------------------------------------------------------------------- |
192 // CIAUpdateBGSoftNotification::ConstructL |
240 // CIAUpdateBGSoftNotification::ConstructL |
193 // Symbian 2nd phase constructor can leave. |
241 // Symbian 2nd phase constructor can leave. |
194 // ----------------------------------------------------------------------------- |
242 // ----------------------------------------------------------------------------- |
195 // |
243 // |
196 void CIAUpdateBGSoftNotification::ConstructL() |
244 void CIAUpdateBGSoftNotification::ConstructL() |
197 { |
245 { |
198 FLOG("[bgchecker] softnotification ConstructL"); |
246 FLOG("[bgchecker] softnotification ConstructL"); |
199 iNotifier = CAknDynamicSoftNotifier::NewL(); |
|
200 |
|
201 iInternalFile->ReadControllerDataL(); |
|
202 iNotificationId = iInternalFile->SoftNotificationID(); |
|
203 |
|
204 } |
247 } |
205 |
248 |
206 // ----------------------------------------------------------------------------- |
249 // ----------------------------------------------------------------------------- |
207 // CIAUpdateBGSoftNotification::CIAUpdateBGSoftNotification |
250 // CIAUpdateBGSoftNotification::CIAUpdateBGSoftNotification |
208 // C++ default constructor can NOT contain any code, that |
251 // C++ default constructor can NOT contain any code, that |
209 // might leave. |
252 // might leave. |
210 // ----------------------------------------------------------------------------- |
253 // ----------------------------------------------------------------------------- |
211 // |
254 // |
212 CIAUpdateBGSoftNotification::CIAUpdateBGSoftNotification( MIAUpdateBGSoftNotificationCallBack* aCallback, |
255 CIAUpdateBGSoftNotification::CIAUpdateBGSoftNotification( |
213 CIAUpdateBGInternalFileHandler* aInternalFile ) |
256 MIAUpdateBGSoftNotificationCallBack* aCallback ) |
214 : iCallback ( aCallback ), iInternalFile ( aInternalFile ) |
257 : iCallback ( aCallback ) |
215 { |
258 { |
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // CIAUpdateBGSoftNotification::StartObservingIfNeededL |
|
220 // ----------------------------------------------------------------------------- |
|
221 // |
|
222 void CIAUpdateBGSoftNotification::StartObservingIfNeededL() |
|
223 { |
|
224 if ( iNotificationId ) |
|
225 { |
|
226 FLOG("[bgchecker] softnotification There is a buffered softnotification"); |
|
227 //a buffering soft notification |
|
228 iNotifier->StartObservingL( iNotificationId, this ); |
|
229 } |
|
230 } |
259 } |
231 |
260 |
232 // ----------------------------------------------------------------------------- |
261 // ----------------------------------------------------------------------------- |
233 // CIAUpdateBGSoftNotification::FillNotificationParams |
262 // CIAUpdateBGSoftNotification::FillNotificationParams |
234 // ----------------------------------------------------------------------------- |
263 // ----------------------------------------------------------------------------- |
235 // |
264 // |
236 void CIAUpdateBGSoftNotification::FillNotificationParams( |
265 |
237 TAknDynamicSoftNotificationParams& aParam ) |
266 void CIAUpdateBGSoftNotification::FillNotificationParams() |
238 { |
267 { |
239 if( iSoftkey1 && iSoftkey2 ) |
268 |
240 { |
269 // set title, text and icon |
241 aParam.SetSoftkeys( *iSoftkey1, *iSoftkey2 ); |
270 if ( iTitle ) |
242 } |
271 { |
243 |
272 iNotificationDialog->SetTitleL(iTitle->Des()); |
244 if( iLabel ) |
273 } |
245 { |
274 |
246 aParam.SetNoteLabels( *iLabel, *iLabel ); |
275 if ( iText ) |
247 } |
276 { |
248 |
277 iNotificationDialog->SetTextL(iText->Des()); |
249 if( iGroupLabel ) |
278 } |
250 { |
279 |
251 //aParam.SetGroupLabels( *iGroupLabel, *iGroupLabel ); |
280 if ( iImagePath ) |
252 } |
281 { |
253 |
282 iNotificationDialog->SetIconNameL(iImagePath->Des()); |
254 if( iImageData ) |
283 } |
255 { |
284 |
256 aParam.SetImageData( *iImageData ); |
285 // set wrapping, timeout and touch |
257 } |
286 iNotificationDialog->SetTitleTextWrappingL( |
258 |
287 CHbDeviceNotificationDialogSymbian::TextWordWrap); |
259 aParam.EnableObserver(); |
288 iNotificationDialog->SetTimeoutL(4000); //default 3000 |
|
289 iNotificationDialog->EnableTouchActivationL(ETrue); // default FALSE |
|
290 |
|
291 } |
|
292 // ---------------------------------------------------------- |
|
293 // CIAUpdateBGSoftNotification::EnableIndicator(TBool aEnabled) |
|
294 // ---------------------------------------------------------- |
|
295 void CIAUpdateBGSoftNotification::SetIndicatorEnabled( TBool aEnabled ) |
|
296 { |
|
297 |
|
298 iActivateIndicator = aEnabled; |
|
299 |
|
300 } |
|
301 |
|
302 // ---------------------------------------------------------- |
|
303 // CIAUpdateBGSoftNotification::IndicatorEnabled() |
|
304 // ---------------------------------------------------------- |
|
305 TBool CIAUpdateBGSoftNotification::IsIndicatorEnabled() |
|
306 { |
|
307 |
|
308 return iActivateIndicator; |
|
309 |
|
310 } |
|
311 // ---------------------------------------------------------- |
|
312 // CIAUpdateBGSoftNotification::SetNrOfUpdates( TIAUpdateBGMode aNrOfUpdates ) |
|
313 // ---------------------------------------------------------- |
|
314 /* |
|
315 void CIAUpdateBGSoftNotification::SetNrOfUpdates( const int aNrOfUpdates ) |
|
316 { |
|
317 |
|
318 iNrOfUpdates = aNrOfUpdates; |
|
319 |
|
320 }*/ |
|
321 |
|
322 // ---------------------------------------------------------- |
|
323 // CIAUpdateBGSoftNotification::GetNrOfUpdates() |
|
324 // ---------------------------------------------------------- |
|
325 int CIAUpdateBGSoftNotification::GetNrOfUpdates() |
|
326 { |
|
327 |
|
328 return iNrOfUpdates; |
|
329 |
260 } |
330 } |
261 |
331 |
262 // End of File |
332 // End of File |