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