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 iNotificationDialog; |
60 |
108 |
61 delete iImageData; |
109 } |
62 |
110 |
63 delete iNotifier; |
111 // ----------------------------------------------------------------------------- |
64 } |
112 // CIAUpdateBGSoftNotification::ShowNotificationL |
65 |
113 // Displays notification |
66 // ----------------------------------------------------------------------------- |
114 // ----------------------------------------------------------------------------- |
67 // CIAUpdateBGSoftNotification::NotificationAccepted |
115 // |
68 // Dynamic soft notification was accepted by user. |
116 void CIAUpdateBGSoftNotification::ShowNotificationL() |
69 // ----------------------------------------------------------------------------- |
117 { |
70 // |
118 |
71 void CIAUpdateBGSoftNotification::NotificationAccepted( TInt /*aIdentifier*/ ) |
119 FLOG("[bgchecker] ShowNotificationL"); |
72 { |
120 |
73 FLOG("[bgchecker] softnotification callback function ACCEPTED"); |
121 // crete dialog, id does not exist already |
74 //remove the soft notifiation id |
122 if (!iNotificationDialog) |
75 iInternalFile->SetSoftNotificationID( 0 ); |
123 { |
76 TRAP_IGNORE( iInternalFile->WriteControllerDataL() ); |
124 iNotificationDialog = CHbDeviceNotificationDialogSymbian::NewL( this ); |
77 |
125 } |
78 iCallback->SoftNotificationCallBack( ETrue ); |
126 |
79 } |
127 // enable indicator showing |
80 |
128 SetIndicatorEnabled( ETrue ); |
81 // ----------------------------------------------------------------------------- |
129 |
82 // CIAUpdateBGSoftNotification::NotificationCanceled |
130 // fill texts, icon & behaviour parameters |
83 // Dynamic soft notification was canceled by user. |
131 FillNotificationParams(); |
84 // ----------------------------------------------------------------------------- |
132 |
85 // |
133 iNotificationDialog->ShowL(); |
86 void CIAUpdateBGSoftNotification::NotificationCanceled( TInt /*aIdentifier*/ ) |
134 |
87 { |
135 return; |
88 FLOG("[bgchecker] softnotification callback function Canceled"); |
136 |
89 //remove the soft notifiation id |
137 } |
90 iInternalFile->SetSoftNotificationID( 0 ); |
138 |
91 TRAP_IGNORE( iInternalFile->WriteControllerDataL() ); |
139 // ----------------------------------------------------------------------------- |
92 |
140 // CIAUpdateBGSoftNotification::ShowIndicatorL |
93 iCallback->SoftNotificationCallBack( EFalse ); |
141 // Displays indicator |
94 } |
142 // ----------------------------------------------------------------------------- |
95 |
143 // |
96 // ----------------------------------------------------------------------------- |
144 void CIAUpdateBGSoftNotification::ShowIndicatorL() |
97 // CIAUpdateBGSoftNotification::ShowSoftNotificationL |
145 { |
98 // Displays a soft notification |
146 |
99 // ----------------------------------------------------------------------------- |
147 FLOG("[bgchecker] ShowIndicatorL"); |
100 // |
148 |
101 void CIAUpdateBGSoftNotification::ShowSoftNotificationL() |
149 CHbIndicatorSymbian *ind = CHbIndicatorSymbian::NewL(); |
102 { |
150 CleanupStack::PushL( ind ); |
103 TAknDynamicSoftNotificationParams param( KSoftNotificationPriority ); |
151 |
104 FillNotificationParams( param ); |
152 TInt value = GetNrOfUpdates(); |
105 |
153 |
106 TInt oldId = iNotificationId; |
154 // Set indicator |
107 iNotificationId = |
155 CHbSymbianVariant* varValue = CHbSymbianVariant::NewL( &value, |
108 iNotifier->SetDynamicNotificationCountL( param, iNotificationId, 1 ); |
156 CHbSymbianVariant::EInt ); |
109 |
157 CleanupStack::PushL( varValue ); |
110 if( oldId != iNotificationId ) |
158 // Temporary removal |
111 { |
159 ind->Activate( KIndicatorTypeBgc, varValue ); |
112 FLOG("[bgchecker] softnotification save notification Id"); |
160 CleanupStack::PopAndDestroy( varValue ); |
113 iInternalFile->SetSoftNotificationID( iNotificationId ); |
161 CleanupStack::PopAndDestroy( ind ); |
114 TRAP_IGNORE( iInternalFile->WriteControllerDataL() ); |
162 |
115 |
163 return; |
116 iNotifier->StopObserving( oldId ); |
164 |
117 iNotifier->StartObservingL( iNotificationId, this ); |
165 } |
118 } |
166 |
119 } |
167 // ----------------------------------------------------------------------------- |
120 |
168 // CIAUpdateBGSoftNotification::Remove indicator |
121 // ----------------------------------------------------------------------------- |
169 // Removes indicator |
122 // CIAUpdateBGSoftNotification::RemoveSoftNotificationL |
170 // ----------------------------------------------------------------------------- |
123 // Cancels and removes the soft notification |
171 // |
124 // ----------------------------------------------------------------------------- |
172 void CIAUpdateBGSoftNotification::RemoveIndicatorL() |
125 // |
173 { |
126 void CIAUpdateBGSoftNotification::RemoveSoftNotificationL( TInt aNotifierId ) |
174 |
127 { |
175 FLOG("[bgchecker] RemoveIndicatorL"); |
128 if ( aNotifierId != 0 ) |
176 |
129 { |
177 CHbIndicatorSymbian *ind = CHbIndicatorSymbian::NewL(); |
130 iNotifier->CancelDynamicNotificationL( aNotifierId ); |
178 CleanupStack::PushL( ind ); |
131 } |
179 // Temporary removal |
|
180 ind->Deactivate( KIndicatorTypeBgc ); |
|
181 CleanupStack::PopAndDestroy(ind); |
|
182 |
|
183 return; |
|
184 |
132 } |
185 } |
133 |
186 |
134 // ----------------------------------------------------------------------------- |
187 // ----------------------------------------------------------------------------- |
135 // CIAUpdateBGSoftNotification::SetTextL |
188 // CIAUpdateBGSoftNotification::SetTextL |
136 // Sets a text for a soft notification |
189 // Sets a text for a soft notification |
137 // ----------------------------------------------------------------------------- |
190 // ----------------------------------------------------------------------------- |
138 // |
191 // |
139 void CIAUpdateBGSoftNotification::SetTextL( const TDesC& aText, const TDesC& aGroupText ) |
192 void CIAUpdateBGSoftNotification::SetTextL( |
140 { |
193 const TDesC& aTitle, const TDesC& aText ) |
141 HBufC* txt = aText.AllocL(); |
194 { |
142 delete iLabel; |
195 HBufC* txt = aTitle.AllocL(); |
143 iLabel = txt; |
196 delete iTitle; |
144 |
197 iTitle = txt; |
145 txt = aGroupText.AllocL(); |
198 |
146 delete iGroupLabel; |
199 txt = aText.AllocL(); |
147 iGroupLabel = txt; |
200 delete iText; |
148 } |
201 iText = txt; |
149 |
202 } |
150 // ----------------------------------------------------------------------------- |
203 |
151 // CIAUpdateBGSoftNotification::SetSoftkeyLabelsL |
204 // ----------------------------------------------------------------------------- |
152 // Sets new labels for softkeys |
205 // CIAUpdateBGSoftNotification::SetNrOfUpdates |
153 // ----------------------------------------------------------------------------- |
206 // Sets an image path for a soft notification |
154 // |
207 // ----------------------------------------------------------------------------- |
155 void CIAUpdateBGSoftNotification::SetSoftkeyLabelsL( |
208 // |
156 const TDesC& aSoftkey1Label, |
209 void CIAUpdateBGSoftNotification::SetNrOfUpdates( const TInt& aNrOfUpdates) |
157 const TDesC& aSoftkey2Label ) |
210 { |
158 { |
211 // save number of updates |
159 HBufC* txt = aSoftkey1Label.AllocL(); |
212 iNrOfUpdates = aNrOfUpdates; |
160 delete iSoftkey1; |
213 return; |
161 iSoftkey1 = txt; |
214 } |
162 |
|
163 txt = aSoftkey2Label.AllocL(); |
|
164 delete iSoftkey2; |
|
165 iSoftkey2 = txt; |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CIAUpdateBGSoftNotification::SetImageL |
|
170 // Sets an image for a soft notification |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 void CIAUpdateBGSoftNotification::SetImageL( |
|
174 const TDesC8& aImage ) |
|
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 // ----------------------------------------------------------------------------- |
215 // ----------------------------------------------------------------------------- |
192 // CIAUpdateBGSoftNotification::ConstructL |
216 // CIAUpdateBGSoftNotification::ConstructL |
193 // Symbian 2nd phase constructor can leave. |
217 // Symbian 2nd phase constructor can leave. |
194 // ----------------------------------------------------------------------------- |
218 // ----------------------------------------------------------------------------- |
195 // |
219 // |
196 void CIAUpdateBGSoftNotification::ConstructL() |
220 void CIAUpdateBGSoftNotification::ConstructL() |
197 { |
221 { |
198 FLOG("[bgchecker] softnotification ConstructL"); |
222 FLOG("[bgchecker] softnotification ConstructL"); |
199 iNotifier = CAknDynamicSoftNotifier::NewL(); |
|
200 |
|
201 iInternalFile->ReadControllerDataL(); |
|
202 iNotificationId = iInternalFile->SoftNotificationID(); |
|
203 |
|
204 } |
223 } |
205 |
224 |
206 // ----------------------------------------------------------------------------- |
225 // ----------------------------------------------------------------------------- |
207 // CIAUpdateBGSoftNotification::CIAUpdateBGSoftNotification |
226 // CIAUpdateBGSoftNotification::CIAUpdateBGSoftNotification |
208 // C++ default constructor can NOT contain any code, that |
227 // C++ default constructor can NOT contain any code, that |
209 // might leave. |
228 // might leave. |
210 // ----------------------------------------------------------------------------- |
229 // ----------------------------------------------------------------------------- |
211 // |
230 // |
212 CIAUpdateBGSoftNotification::CIAUpdateBGSoftNotification( MIAUpdateBGSoftNotificationCallBack* aCallback, |
231 CIAUpdateBGSoftNotification::CIAUpdateBGSoftNotification( |
213 CIAUpdateBGInternalFileHandler* aInternalFile ) |
232 MIAUpdateBGSoftNotificationCallBack* aCallback ) |
214 : iCallback ( aCallback ), iInternalFile ( aInternalFile ) |
233 : iCallback ( aCallback ) |
215 { |
234 { |
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 } |
235 } |
231 |
236 |
232 // ----------------------------------------------------------------------------- |
237 // ----------------------------------------------------------------------------- |
233 // CIAUpdateBGSoftNotification::FillNotificationParams |
238 // CIAUpdateBGSoftNotification::FillNotificationParams |
234 // ----------------------------------------------------------------------------- |
239 // ----------------------------------------------------------------------------- |
235 // |
240 // |
236 void CIAUpdateBGSoftNotification::FillNotificationParams( |
241 |
237 TAknDynamicSoftNotificationParams& aParam ) |
242 void CIAUpdateBGSoftNotification::FillNotificationParams() |
238 { |
243 { |
239 if( iSoftkey1 && iSoftkey2 ) |
244 |
240 { |
245 // set title, text and icon |
241 aParam.SetSoftkeys( *iSoftkey1, *iSoftkey2 ); |
246 if ( iTitle ) |
242 } |
247 { |
243 |
248 iNotificationDialog->SetTitleL(iTitle->Des()); |
244 if( iLabel ) |
249 } |
245 { |
250 |
246 aParam.SetNoteLabels( *iLabel, *iLabel ); |
251 if ( iText ) |
247 } |
252 { |
248 |
253 iNotificationDialog->SetTextL(iText->Des()); |
249 if( iGroupLabel ) |
254 } |
250 { |
255 |
251 //aParam.SetGroupLabels( *iGroupLabel, *iGroupLabel ); |
256 // set wrapping, timeout and touch |
252 } |
257 iNotificationDialog->SetTitleTextWrapping( |
253 |
258 CHbDeviceNotificationDialogSymbian::TextWordWrap); |
254 if( iImageData ) |
259 iNotificationDialog->SetTimeout(4000); //default 3000 |
255 { |
260 iNotificationDialog->EnableTouchActivation(ETrue); // default FALSE |
256 aParam.SetImageData( *iImageData ); |
261 |
257 } |
262 } |
258 |
263 // ---------------------------------------------------------- |
259 aParam.EnableObserver(); |
264 // CIAUpdateBGSoftNotification::EnableIndicator(TBool aEnabled) |
|
265 // ---------------------------------------------------------- |
|
266 void CIAUpdateBGSoftNotification::SetIndicatorEnabled( TBool aEnabled ) |
|
267 { |
|
268 |
|
269 iActivateIndicator = aEnabled; |
|
270 |
|
271 } |
|
272 |
|
273 // ---------------------------------------------------------- |
|
274 // CIAUpdateBGSoftNotification::IndicatorEnabled() |
|
275 // ---------------------------------------------------------- |
|
276 TBool CIAUpdateBGSoftNotification::IsIndicatorEnabled() |
|
277 { |
|
278 |
|
279 return iActivateIndicator; |
|
280 |
|
281 } |
|
282 |
|
283 // ---------------------------------------------------------- |
|
284 // CIAUpdateBGSoftNotification::GetNrOfUpdates() |
|
285 // ---------------------------------------------------------- |
|
286 int CIAUpdateBGSoftNotification::GetNrOfUpdates() |
|
287 { |
|
288 |
|
289 return iNrOfUpdates; |
|
290 |
260 } |
291 } |
261 |
292 |
262 // End of File |
293 // End of File |