|
1 /* |
|
2 * Copyright (c) 2002 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: Implementation of CPushMessageInfoOp. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "PushMessageInfoOp.h" |
|
23 #include "PushMessageInfoDialog.h" |
|
24 #include "PushMtmUtil.h" |
|
25 #include "PushMtmUiDef.h" |
|
26 #include "PushMtmUiPanic.h" |
|
27 #include "PushMtmLog.h" |
|
28 #include <AknNoteWrappers.h> |
|
29 #include <PushMtmUi.rsg> |
|
30 #include <data_caging_path_literals.hrh> |
|
31 #include <f32file.h> |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 |
|
35 // --------------------------------------------------------- |
|
36 // CPushMessageInfoOp::CPushMessageInfoOp |
|
37 // --------------------------------------------------------- |
|
38 // |
|
39 CPushMessageInfoOp::CPushMessageInfoOp( CMsvSession& aSession, |
|
40 TMsvId aEntryId, |
|
41 TBool aDontShowNotification, |
|
42 TRequestStatus& aObserverStatus ) |
|
43 : CPushMtmUiOperation( aSession, aEntryId, aObserverStatus ), |
|
44 iDontShowNotification( aDontShowNotification ), |
|
45 iObserverCompleted( EFalse ) |
|
46 { |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------- |
|
50 // CPushMessageInfoOp::~CPushMessageInfoOp |
|
51 // --------------------------------------------------------- |
|
52 // |
|
53 CPushMessageInfoOp::~CPushMessageInfoOp() |
|
54 { |
|
55 Cancel(); |
|
56 delete iDialog; |
|
57 if ( iDeletedFlag ) |
|
58 { |
|
59 *iDeletedFlag = ETrue; |
|
60 } |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // CPushMessageInfoOp::StartL |
|
65 // --------------------------------------------------------- |
|
66 // |
|
67 void CPushMessageInfoOp::StartL() |
|
68 { |
|
69 Cancel(); |
|
70 iObserverCompleted = EFalse; |
|
71 CPushMtmOperation::StartL(); |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------- |
|
75 // CPushMessageInfoOp::RunL |
|
76 // --------------------------------------------------------- |
|
77 // |
|
78 void CPushMessageInfoOp::RunL() |
|
79 { |
|
80 __ASSERT_DEBUG( !iDialog, UiPanic( EPushMtmUiPanAlreadyInitialized ) ); |
|
81 |
|
82 if ( iObserverCompleted ) |
|
83 { |
|
84 return; |
|
85 } |
|
86 |
|
87 TBool deleted( EFalse ); |
|
88 iDeletedFlag = &deleted; |
|
89 |
|
90 // Time to set up entry observation (delete & replacement case). |
|
91 ObserveEntryEventL(); |
|
92 |
|
93 iDialog = new (ELeave) CPushMessageInfoDialog; |
|
94 // Workaround for Cancel(): SetActive() is called. |
|
95 // CMsvSingleOpWatcher::DoCancel() will wait for this observed object to |
|
96 // complete that. iDialog->ExecuteLD() allows other RunL's to run, so |
|
97 // that it may happen that CMsvSingleOpWatcher::DoCancel() is called |
|
98 // when iDialog->ExecuteLD() is running. It means that this object must |
|
99 // be active in that time in order DoCancel() will be called. |
|
100 iStatus = KRequestPending; |
|
101 SetActive(); |
|
102 iDialog->ExecuteLD( iMsvSession, iEntryId ); |
|
103 |
|
104 // Ready. |
|
105 if ( !deleted ) |
|
106 { |
|
107 iDialog = NULL; |
|
108 iDeletedFlag = NULL; |
|
109 // Consider what happens if this object is cancelled in ExecuteLD! |
|
110 // In this case the observer is already completed (DoCancel), so |
|
111 // avoid completeing it twice. iObserverCompleted indicates it. |
|
112 if ( !iObserverCompleted ) |
|
113 { |
|
114 SignalObserver( KErrNone ); |
|
115 iObserverCompleted = ETrue; |
|
116 // Due to SetActive() call RunL again, but it will do nothing |
|
117 // (see above). |
|
118 InvokeRun(); |
|
119 } |
|
120 } |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------- |
|
124 // CPushMessageInfoOp::DoCancel |
|
125 // --------------------------------------------------------- |
|
126 // |
|
127 void CPushMessageInfoOp::DoCancel() |
|
128 { |
|
129 PUSHLOG_WRITE("CPushMessageInfoOp::DoCancel"); |
|
130 CancelObserveEntryEvent(); |
|
131 |
|
132 if ( iDialog ) |
|
133 { |
|
134 delete iDialog; |
|
135 iDialog = NULL; |
|
136 // Due to SetActive() in RunL we must call InvokeRun(): the dialog |
|
137 // does not completes this operation. |
|
138 InvokeRun(); |
|
139 } |
|
140 if ( !iObserverCompleted ) |
|
141 { |
|
142 SignalObserver( KErrCancel ); |
|
143 iObserverCompleted = ETrue; |
|
144 } |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------- |
|
148 // CPushMessageInfoOp::RunError |
|
149 // --------------------------------------------------------- |
|
150 // |
|
151 TInt CPushMessageInfoOp::RunError( TInt aError ) |
|
152 { |
|
153 PUSHLOG_WRITE_FORMAT("CPushMessageInfoOp::RunError: %d",aError); |
|
154 CancelObserveEntryEvent(); |
|
155 |
|
156 if ( !iObserverCompleted ) |
|
157 { |
|
158 SignalObserver( aError ); |
|
159 iObserverCompleted = ETrue; |
|
160 } |
|
161 return aError; |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------- |
|
165 // CPushMessageInfoOp::HandleEntryEventL |
|
166 // --------------------------------------------------------- |
|
167 // |
|
168 void CPushMessageInfoOp::HandleEntryEventL( TMsvEntryEvent aEvent, |
|
169 TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/ ) |
|
170 { |
|
171 PUSHLOG_ENTERFN("CPushMessageInfoOp::HandleEntryEventL"); |
|
172 |
|
173 if ( aEvent == EMsvEntryChanged ) |
|
174 { |
|
175 PUSHLOG_WRITE(" Changed"); |
|
176 HandleEntryChangeL(); |
|
177 } |
|
178 else if ( aEvent == EMsvEntryDeleted ) |
|
179 { |
|
180 PUSHLOG_WRITE(" Deleted"); |
|
181 NotifyAndCancelL( R_PUSHLS_EXPIRED_NOTE ); |
|
182 } |
|
183 else |
|
184 { |
|
185 // Nothing to do. |
|
186 } |
|
187 |
|
188 PUSHLOG_LEAVEFN("CPushMessageInfoOp::HandleEntryEventL"); |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------- |
|
192 // CPushMessageInfoOp::HandleEntryChangeL |
|
193 // --------------------------------------------------------- |
|
194 // |
|
195 void CPushMessageInfoOp::HandleEntryChangeL() |
|
196 { |
|
197 PUSHLOG_ENTERFN("CPushMessageInfoOp::HandleEntryChangeL"); |
|
198 |
|
199 // We have to act only in case of such changes where the content |
|
200 // of the message changes, not only the unread/read flag. |
|
201 // The content handlers and the Push subsystem behave so that |
|
202 // the content is changed only when the entry becomes 'unread', |
|
203 // except one case where the CH changes the content, but the |
|
204 // message becomes 'read' (SL-execute-high). In this case |
|
205 // a flag indicates that the content was changed. |
|
206 |
|
207 // Get an up-to-date entry and check the necessary flags: |
|
208 TMsvEntry tEntry; |
|
209 TMsvId service; |
|
210 User::LeaveIfError( iMsvSession.GetEntry( iEntryId, service, tEntry ) ); |
|
211 TBool isChangeToUnread = tEntry.Unread(); |
|
212 TBool contentChangedFlagSet = |
|
213 CPushMtmUtil::Attrs( tEntry ) & EPushMtmReadButContentChanged; |
|
214 |
|
215 if ( !isChangeToUnread && !contentChangedFlagSet ) |
|
216 { |
|
217 // Nothing to do. Somebody has just marked it 'read'. |
|
218 PUSHLOG_WRITE(" Content not changed"); |
|
219 } |
|
220 else |
|
221 { |
|
222 NotifyAndCancelL( R_PUSHMISC_INFO_REPLACED ); |
|
223 } |
|
224 |
|
225 PUSHLOG_LEAVEFN("CPushMessageInfoOp::HandleEntryChangeL") |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------- |
|
229 // CPushMessageInfoOp::NotifyAndCancelL |
|
230 // --------------------------------------------------------- |
|
231 // |
|
232 void CPushMessageInfoOp::NotifyAndCancelL( TInt aResId ) |
|
233 { |
|
234 PUSHLOG_ENTERFN("CPushMessageInfoOp::NotifyAndCancelL"); |
|
235 |
|
236 if ( iDontShowNotification ) |
|
237 { |
|
238 // Don't show. |
|
239 } |
|
240 else |
|
241 { |
|
242 // Add resource file. |
|
243 TParse* fileParser = new (ELeave) TParse; |
|
244 CleanupStack::PushL( fileParser ); |
|
245 fileParser->Set( KPushMtmUiResourceFileAndDrive, &KDC_MTM_RESOURCE_DIR, NULL ); |
|
246 AssureResourceL( fileParser->FullName() ); |
|
247 CleanupStack::PopAndDestroy( fileParser ); // fileParser |
|
248 fileParser = NULL; |
|
249 |
|
250 // Show note about the message deletion. |
|
251 HBufC* noteText = iCoeEnv.AllocReadResourceLC( aResId ); |
|
252 CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue ); |
|
253 note->ExecuteLD( *noteText ); |
|
254 CleanupStack::PopAndDestroy( noteText ); // noteText |
|
255 } |
|
256 |
|
257 // Close the dialog anyway. |
|
258 Cancel(); |
|
259 |
|
260 PUSHLOG_LEAVEFN("CPushMessageInfoOp::NotifyAndCancelL"); |
|
261 } |
|
262 |
|
263 // End of file. |
|
264 |