|
1 /* |
|
2 * Copyright (c) 2008 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 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <AknDynamicSoftNotifier.h> |
|
22 #include <AknDynamicSoftNotificationParams.h> |
|
23 |
|
24 #include "iaupdatebgsoftnotification.h" |
|
25 #include "iaupdatebginternalfilehandler.h" |
|
26 #include "iaupdatebgconst.h" |
|
27 #include "iaupdatebglogger.h" |
|
28 |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CIAUpdateBGSoftNotification::NewLC |
|
33 // Static constructor |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CIAUpdateBGSoftNotification* CIAUpdateBGSoftNotification::NewL( MIAUpdateBGSoftNotificationCallBack* aCallback, |
|
37 CIAUpdateBGInternalFileHandler* aInternalFile ) |
|
38 { |
|
39 CIAUpdateBGSoftNotification* self = |
|
40 new ( ELeave ) CIAUpdateBGSoftNotification( aCallback, aInternalFile ); |
|
41 CleanupStack::PushL( self ); |
|
42 |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop( self ); |
|
45 |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // Destructor |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CIAUpdateBGSoftNotification::~CIAUpdateBGSoftNotification() |
|
54 { |
|
55 delete iSoftkey1; |
|
56 delete iSoftkey2; |
|
57 |
|
58 delete iLabel; |
|
59 delete iGroupLabel; |
|
60 |
|
61 delete iImageData; |
|
62 |
|
63 delete iNotifier; |
|
64 } |
|
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 // ----------------------------------------------------------------------------- |
|
97 // CIAUpdateBGSoftNotification::ShowSoftNotificationL |
|
98 // Displays a soft notification |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CIAUpdateBGSoftNotification::ShowSoftNotificationL() |
|
102 { |
|
103 TAknDynamicSoftNotificationParams param( KSoftNotificationPriority ); |
|
104 FillNotificationParams( param ); |
|
105 |
|
106 TInt oldId = iNotificationId; |
|
107 iNotificationId = |
|
108 iNotifier->SetDynamicNotificationCountL( param, iNotificationId, 1 ); |
|
109 |
|
110 if( oldId != iNotificationId ) |
|
111 { |
|
112 FLOG("[bgchecker] softnotification save notification Id"); |
|
113 iInternalFile->SetSoftNotificationID( iNotificationId ); |
|
114 TRAP_IGNORE( iInternalFile->WriteControllerDataL() ); |
|
115 |
|
116 iNotifier->StopObserving( oldId ); |
|
117 iNotifier->StartObservingL( iNotificationId, this ); |
|
118 } |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CIAUpdateBGSoftNotification::RemoveSoftNotificationL |
|
123 // Cancels and removes the soft notification |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 void CIAUpdateBGSoftNotification::RemoveSoftNotificationL( TInt aNotifierId ) |
|
127 { |
|
128 if ( aNotifierId != 0 ) |
|
129 { |
|
130 iNotifier->CancelDynamicNotificationL( aNotifierId ); |
|
131 } |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CIAUpdateBGSoftNotification::SetTextL |
|
136 // Sets a text for a soft notification |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CIAUpdateBGSoftNotification::SetTextL( const TDesC& aText, const TDesC& aGroupText ) |
|
140 { |
|
141 HBufC* txt = aText.AllocL(); |
|
142 delete iLabel; |
|
143 iLabel = txt; |
|
144 |
|
145 txt = aGroupText.AllocL(); |
|
146 delete iGroupLabel; |
|
147 iGroupLabel = txt; |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CIAUpdateBGSoftNotification::SetSoftkeyLabelsL |
|
152 // Sets new labels for softkeys |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void CIAUpdateBGSoftNotification::SetSoftkeyLabelsL( |
|
156 const TDesC& aSoftkey1Label, |
|
157 const TDesC& aSoftkey2Label ) |
|
158 { |
|
159 HBufC* txt = aSoftkey1Label.AllocL(); |
|
160 delete iSoftkey1; |
|
161 iSoftkey1 = txt; |
|
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 // ----------------------------------------------------------------------------- |
|
192 // CIAUpdateBGSoftNotification::ConstructL |
|
193 // Symbian 2nd phase constructor can leave. |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 void CIAUpdateBGSoftNotification::ConstructL() |
|
197 { |
|
198 FLOG("[bgchecker] softnotification ConstructL"); |
|
199 iNotifier = CAknDynamicSoftNotifier::NewL(); |
|
200 |
|
201 iInternalFile->ReadControllerDataL(); |
|
202 iNotificationId = iInternalFile->SoftNotificationID(); |
|
203 |
|
204 } |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CIAUpdateBGSoftNotification::CIAUpdateBGSoftNotification |
|
208 // C++ default constructor can NOT contain any code, that |
|
209 // might leave. |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 CIAUpdateBGSoftNotification::CIAUpdateBGSoftNotification( MIAUpdateBGSoftNotificationCallBack* aCallback, |
|
213 CIAUpdateBGInternalFileHandler* aInternalFile ) |
|
214 : iCallback ( aCallback ), iInternalFile ( aInternalFile ) |
|
215 { |
|
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 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // CIAUpdateBGSoftNotification::FillNotificationParams |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 void CIAUpdateBGSoftNotification::FillNotificationParams( |
|
237 TAknDynamicSoftNotificationParams& aParam ) |
|
238 { |
|
239 if( iSoftkey1 && iSoftkey2 ) |
|
240 { |
|
241 aParam.SetSoftkeys( *iSoftkey1, *iSoftkey2 ); |
|
242 } |
|
243 |
|
244 if( iLabel ) |
|
245 { |
|
246 aParam.SetNoteLabels( *iLabel, *iLabel ); |
|
247 } |
|
248 |
|
249 if( iGroupLabel ) |
|
250 { |
|
251 //aParam.SetGroupLabels( *iGroupLabel, *iGroupLabel ); |
|
252 } |
|
253 |
|
254 if( iImageData ) |
|
255 { |
|
256 aParam.SetImageData( *iImageData ); |
|
257 } |
|
258 |
|
259 aParam.EnableObserver(); |
|
260 } |
|
261 |
|
262 // End of File |