13 * |
13 * |
14 * Description: Base class for online operations |
14 * Description: Base class for online operations |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
|
19 |
|
20 #include "emailtrace.h" |
18 #include "emailtrace.h" |
21 #include "ipsplgheaders.h" |
19 #include "ipsplgheaders.h" |
22 |
20 |
23 |
|
24 // ---------------------------------------------------------------------------- |
21 // ---------------------------------------------------------------------------- |
25 // CIpsPlgOnlineOperation::~CIpsPlgOnlineOperation() |
22 // CIpsPlgOnlineOperation::~CIpsPlgOnlineOperation() |
26 // ---------------------------------------------------------------------------- |
23 // ---------------------------------------------------------------------------- |
27 // |
24 // |
28 CIpsPlgOnlineOperation::~CIpsPlgOnlineOperation() |
25 CIpsPlgOnlineOperation::~CIpsPlgOnlineOperation() |
29 { |
26 { |
30 FUNC_LOG; |
27 FUNC_LOG; |
31 Cancel(); |
28 Cancel(); |
32 delete iOperation; |
29 delete iSubOperation; |
33 delete iBaseMtm; |
30 delete iBaseMtm; |
34 delete iMtmReg; |
31 delete iMtmReg; |
35 } |
32 } |
36 |
33 |
37 // ---------------------------------------------------------------------------- |
34 // ---------------------------------------------------------------------------- |
38 // CIpsPlgOnlineOperation::CIpsPlgOnlineOperation() |
35 // CIpsPlgOnlineOperation::CIpsPlgOnlineOperation() |
39 // ---------------------------------------------------------------------------- |
36 // ---------------------------------------------------------------------------- |
40 // |
37 // <qmail> priority parameter has been removed |
|
38 // <qmail> MFSMailRequestObserver& changed to pointer |
|
39 // <qmail> aSignallingAllowed parameter has been returned |
41 CIpsPlgOnlineOperation::CIpsPlgOnlineOperation( |
40 CIpsPlgOnlineOperation::CIpsPlgOnlineOperation( |
42 CMsvSession& aMsvSession, |
41 CMsvSession& aMsvSession, |
43 TInt aPriority, |
|
44 TRequestStatus& aObserverRequestStatus, |
42 TRequestStatus& aObserverRequestStatus, |
45 CIpsPlgTimerOperation& aActivityTimer, |
43 CIpsPlgTimerOperation& aActivityTimer, |
46 TFSMailMsgId aFSMailBoxId, |
44 TFSMailMsgId aFSMailBoxId, |
47 MFSMailRequestObserver& aFSOperationObserver, |
45 MFSMailRequestObserver* aFSOperationObserver, |
48 TInt aFSRequestId, |
46 TInt aFSRequestId, |
49 TBool aSignallingAllowed ) |
47 TBool aSignallingAllowed ) |
50 : |
48 : |
51 CIpsPlgBaseOperation( aMsvSession, aPriority, aObserverRequestStatus, |
49 CIpsPlgBaseOperation( |
52 aFSRequestId, aFSMailBoxId ), |
50 aMsvSession, |
53 iActivityTimer( &aActivityTimer ), |
51 aObserverRequestStatus, |
54 iBaseMtm( NULL ), |
52 aFSRequestId, |
55 iMtmReg( NULL ), |
53 aFSMailBoxId ), |
56 iOperation( NULL ), |
54 iActivityTimer( &aActivityTimer ), |
57 iError( KErrNone ), |
55 iBaseMtm( NULL ), |
58 iSignallingAllowed( aSignallingAllowed ), |
56 iMtmReg( NULL ), |
59 iFSOperationObserver( aFSOperationObserver ) |
57 iSubOperation( NULL ), |
|
58 iError( KErrNone ), |
|
59 iSignallingAllowed( aSignallingAllowed ), |
|
60 iFSOperationObserver( aFSOperationObserver ) |
60 { |
61 { |
61 FUNC_LOG; |
62 FUNC_LOG; |
62 } |
63 } |
63 |
64 |
64 // ---------------------------------------------------------------------------- |
65 // ---------------------------------------------------------------------------- |
65 // CIpsPlgOnlineOperation::BaseConstructL() |
66 // CIpsPlgOnlineOperation::BaseConstructL() |
66 // ---------------------------------------------------------------------------- |
67 // ---------------------------------------------------------------------------- |
67 // |
68 // |
68 void CIpsPlgOnlineOperation::BaseConstructL(TUid aMtmType) |
69 void CIpsPlgOnlineOperation::BaseConstructL( TUid aMtmType ) |
69 { |
70 { |
70 FUNC_LOG; |
71 FUNC_LOG; |
71 // reset timer, if operation not completed after timer fires causes |
72 // reset timer, if operation not completed after timer fires causes |
72 // disconnection |
73 // disconnection |
73 if( iActivityTimer ) |
74 // <qmail> remove cheking of existence of this reference member |
|
75 if (iActivityTimer) |
74 { |
76 { |
75 iActivityTimer->ResetTimerOperation(); |
77 iActivityTimer->ResetTimerOperation(); |
76 } |
78 } |
77 |
79 |
78 iMtmReg = CClientMtmRegistry::NewL( iMsvSession ); |
80 iMtmReg = CClientMtmRegistry::NewL( iMsvSession ); |
79 |
|
80 iBaseMtm = iMtmReg->NewMtmL( aMtmType ); |
81 iBaseMtm = iMtmReg->NewMtmL( aMtmType ); |
81 |
|
82 iObserverRequestStatus = KRequestPending; |
82 iObserverRequestStatus = KRequestPending; |
83 CActiveScheduler::Add(this); |
83 CActiveScheduler::Add(this); |
84 } |
84 } |
85 |
85 |
86 // ---------------------------------------------------------------------------- |
86 // ---------------------------------------------------------------------------- |
102 // ---------------------------------------------------------------------------- |
102 // ---------------------------------------------------------------------------- |
103 // |
103 // |
104 void CIpsPlgOnlineOperation::RunL() |
104 void CIpsPlgOnlineOperation::RunL() |
105 { |
105 { |
106 FUNC_LOG; |
106 FUNC_LOG; |
107 |
107 TInt err( KErrNone ); |
108 TInt err = KErrNone; |
|
109 TRAP( err, DoRunL() ); |
108 TRAP( err, DoRunL() ); |
110 |
109 |
111 // Just end the operation, if something has gone wrong |
110 // Just end the operation, if something has gone wrong |
112 if ( err != KErrNone ) |
111 if ( err ) |
113 { |
112 { |
114 CompleteObserver( err ); |
113 CompleteObserver( err ); |
115 } |
114 } |
116 else if ( iError != KErrNone ) |
115 else if ( iError ) |
117 { |
116 { |
118 CompleteObserver( iError ); |
117 CompleteObserver( iError ); |
119 } |
118 } |
120 } |
119 } |
121 |
120 |
122 // ---------------------------------------------------------------------------- |
121 // <qmail> removing TInt CIpsPlgOnlineOperation::RunError( TInt aError ) |
123 // CIpsPlgOnlineOperation::RunError() |
|
124 // ---------------------------------------------------------------------------- |
|
125 // |
|
126 TInt CIpsPlgOnlineOperation::RunError( TInt aError ) |
|
127 { |
|
128 FUNC_LOG; |
|
129 CompleteObserver( aError ); |
|
130 return KErrNone; // RunError must return KErrNone to active sheduler. |
|
131 } |
|
132 |
122 |
133 // ---------------------------------------------------------------------------- |
123 // ---------------------------------------------------------------------------- |
134 // CIpsPlgOnlineOperation::CompleteObserver() |
124 // CIpsPlgOnlineOperation::CompleteObserver() |
135 // ---------------------------------------------------------------------------- |
125 // ---------------------------------------------------------------------------- |
136 // |
126 // |
137 void CIpsPlgOnlineOperation::CompleteObserver( TInt aStatus ) |
127 void CIpsPlgOnlineOperation::CompleteObserver( TInt aStatus ) |
138 { |
128 { |
139 FUNC_LOG; |
129 FUNC_LOG; |
|
130 NM_COMMENT("CIpsPlgOnlineOperation::CompleteObserver"); |
140 TRequestStatus* status = &iObserverRequestStatus; |
131 TRequestStatus* status = &iObserverRequestStatus; |
141 if (status && status->Int() == KRequestPending) |
132 if (status && status->Int() == KRequestPending) |
142 { |
133 { |
143 |
|
144 SignalFSObserver( aStatus ); |
134 SignalFSObserver( aStatus ); |
|
135 // <qmail> |
145 // removed checks to prevent unwanted disconnections |
136 // removed checks to prevent unwanted disconnections |
146 //if we're connected, reset activitytimer. if not, there is no reason to. |
137 //if connected, reset activitytimer. if not, there is no reason to. |
147 if( iActivityTimer ) |
138 if ( Connected() ) |
148 { |
139 { |
|
140 NM_COMMENT("CIpsPlgOnlineOperation::reseting activitytimer"); |
149 iActivityTimer->ResetTimerOperation(); |
141 iActivityTimer->ResetTimerOperation(); |
150 } |
142 } |
|
143 else |
|
144 { |
|
145 iActivityTimer->Cancel(); |
|
146 } |
|
147 // </qmail> |
151 User::RequestComplete(status, aStatus); |
148 User::RequestComplete(status, aStatus); |
152 } |
149 } |
153 } |
150 } |
154 |
151 |
155 // ---------------------------------------------------------------------------- |
152 // ---------------------------------------------------------------------------- |
157 // ---------------------------------------------------------------------------- |
154 // ---------------------------------------------------------------------------- |
158 // |
155 // |
159 void CIpsPlgOnlineOperation::CompleteThis() |
156 void CIpsPlgOnlineOperation::CompleteThis() |
160 { |
157 { |
161 FUNC_LOG; |
158 FUNC_LOG; |
162 |
159 SetActive(); |
163 TRequestStatus* status = &iStatus; |
160 TRequestStatus* status = &iStatus; |
164 User::RequestComplete(status, KErrNone); |
161 User::RequestComplete(status, KErrNone); |
165 } |
162 } |
166 |
163 |
167 // ---------------------------------------------------------------------------- |
164 // ---------------------------------------------------------------------------- |
168 // CIpsPlgOnlineOperation::InvokeClientMtmAsyncFunctionL() |
165 // CIpsPlgOnlineOperation::InvokeClientMtmAsyncFunctionL() |
169 // ---------------------------------------------------------------------------- |
166 // ---------------------------------------------------------------------------- |
170 // |
167 // <qmail> remove contextId as not needed |
171 void CIpsPlgOnlineOperation::InvokeClientMtmAsyncFunctionL( |
168 void CIpsPlgOnlineOperation::InvokeClientMtmAsyncFunctionL( |
172 TInt aFunctionId, |
169 TInt aFunctionId, |
173 TMsvId aEntryId, |
170 TMsvId aEntryId, |
174 TMsvId aContextId, |
|
175 const TDesC8& aParams) |
171 const TDesC8& aParams) |
176 { |
172 { |
177 FUNC_LOG; |
173 FUNC_LOG; |
178 |
174 |
179 CMsvEntrySelection* sel = new(ELeave) CMsvEntrySelection; |
175 CMsvEntrySelection* sel = new(ELeave) CMsvEntrySelection; |
180 CleanupStack::PushL( sel ); |
176 CleanupStack::PushL( sel ); |
181 sel->AppendL( aEntryId ); |
177 sel->AppendL( aEntryId ); |
182 InvokeClientMtmAsyncFunctionL(aFunctionId, *sel, aContextId, aParams); |
178 InvokeClientMtmAsyncFunctionL(aFunctionId, *sel, aParams); |
183 CleanupStack::PopAndDestroy( sel ); |
179 CleanupStack::PopAndDestroy( sel ); |
184 } |
180 } |
185 |
181 |
186 // ---------------------------------------------------------------------------- |
182 // ---------------------------------------------------------------------------- |
187 // CIpsPlgOnlineOperation::InvokeClientMtmAsyncFunctionL() |
183 // CIpsPlgOnlineOperation::InvokeClientMtmAsyncFunctionL() |
188 // ---------------------------------------------------------------------------- |
184 // ---------------------------------------------------------------------------- |
189 // |
185 // <qmail> remove contextId as not needed |
190 void CIpsPlgOnlineOperation::InvokeClientMtmAsyncFunctionL( |
186 void CIpsPlgOnlineOperation::InvokeClientMtmAsyncFunctionL( |
191 TInt aFunctionId, |
187 TInt aFunctionId, |
192 const CMsvEntrySelection& aSel, |
188 const CMsvEntrySelection& aSel, |
193 TMsvId aContextId, |
189 const TDesC8& aParams ) |
194 const TDesC8& aParams) |
|
195 { |
190 { |
196 FUNC_LOG; |
191 FUNC_LOG; |
197 |
192 |
198 TMsvEntry tEntry; |
193 TMsvEntry tEntry; |
199 TMsvId service; |
194 TMsvId service; |
200 if ( aSel.Count() ) |
195 if ( aSel.Count() ) |
201 { |
196 { |
202 iMsvSession.GetEntry( aSel.At(0), service, tEntry ); |
197 iMsvSession.GetEntry( aSel.At(0), service, tEntry ); |
203 } |
198 } |
204 |
199 |
205 if( aContextId != tEntry.iServiceId ) |
200 // setting our context to serviceId |
206 { |
201 iBaseMtm->SwitchCurrentEntryL( tEntry.iServiceId ); |
207 // Client context must be service for FetchL(). |
202 |
208 iBaseMtm->SwitchCurrentEntryL( tEntry.iServiceId ); |
203 HBufC8* params = aParams.AllocLC(); // can not pass const parameter to InvokeAsyncFunctionL |
209 } |
|
210 else |
|
211 { |
|
212 iBaseMtm->SwitchCurrentEntryL( aContextId ); |
|
213 } |
|
214 HBufC8* params = aParams.AllocLC(); |
|
215 TPtr8 ptr(params->Des()); |
204 TPtr8 ptr(params->Des()); |
216 // Delete previous operation if it exist |
205 // Delete previous operation if it exist |
217 if ( iOperation ) |
206 if ( iSubOperation ) |
218 { |
207 { |
219 delete iOperation; |
208 delete iSubOperation; |
220 iOperation = NULL; |
209 iSubOperation = NULL; |
221 } |
210 } |
222 iOperation = iBaseMtm->InvokeAsyncFunctionL(aFunctionId, aSel, ptr, iStatus); |
211 iSubOperation = iBaseMtm->InvokeAsyncFunctionL( aFunctionId, aSel, ptr, iStatus ); |
223 CleanupStack::PopAndDestroy( params ); |
212 CleanupStack::PopAndDestroy( params ); |
224 } |
213 } |
225 |
214 |
226 // ---------------------------------------------------------------------------- |
215 // ---------------------------------------------------------------------------- |
227 // CIpsPlgOnlineOperation::SignalFSObserver() |
216 // CIpsPlgOnlineOperation::SignalFSObserver() |
228 // ---------------------------------------------------------------------------- |
217 // ---------------------------------------------------------------------------- |
229 // |
218 // |
230 void CIpsPlgOnlineOperation::SignalFSObserver( TInt aStatus ) |
219 void CIpsPlgOnlineOperation::SignalFSObserver( TInt aStatus ) |
231 { |
220 { |
232 FUNC_LOG; |
221 FUNC_LOG; |
233 if ( iSignallingAllowed ) |
222 // <qmail> clean up this function |
234 { |
223 // <qmail> |
235 TFSProgress prog; |
224 if( iSignallingAllowed ) |
|
225 // </qmail> |
|
226 { |
236 // Initialize the progress data |
227 // Initialize the progress data |
|
228 TFSProgress prog = { TFSProgress::EFSStatus_RequestComplete, 1, 1, aStatus, NULL }; |
237 // it would be better to get fs progress from inherited class |
229 // it would be better to get fs progress from inherited class |
238 // by calling FSProgressL method?? |
230 // by calling FSProgressL method?? |
239 if ( aStatus == KErrCancel ) |
231 if ( aStatus == KErrCancel ) |
240 { |
232 { |
241 prog.iError = KErrNone; |
|
242 prog.iProgressStatus = TFSProgress::EFSStatus_RequestCancelled; |
233 prog.iProgressStatus = TFSProgress::EFSStatus_RequestCancelled; |
243 } |
234 } |
244 else if ( aStatus == KErrImapBadLogon ) |
235 // <qmail> |
245 { |
236 if( iFSOperationObserver ) |
246 prog.iError = aStatus; |
237 { |
247 prog.iProgressStatus = TFSProgress::EFSStatus_RequestCancelled; |
238 // do the actual signalling |
248 } |
239 TRAP_IGNORE( iFSOperationObserver->RequestResponseL( prog, iFSRequestId ) ); |
249 else |
240 } |
250 { |
241 // </qmail> |
251 prog.iError = aStatus; |
242 } |
252 prog.iProgressStatus = TFSProgress::EFSStatus_RequestComplete; |
243 } |
253 } |
244 |
254 // At least in the attachment download, FS UI assumes that |
245 // <qmail> removed IpsOpType() |
255 // the counter fields are greater than 0 |
246 |
256 prog.iMaxCount = 1; |
247 // <qmail> makes more sence to have this method here in "base" online op than in every derived class |
257 prog.iCounter = 1; |
248 // ---------------------------------------------------------------------------- |
258 |
249 // ---------------------------------------------------------------------------- |
259 //in case of autoconnect, we don't have valid observer |
250 TBool CIpsPlgOnlineOperation::Connected() const |
260 if ( &iFSOperationObserver ) |
251 { |
261 { |
252 FUNC_LOG; |
262 TRAP_IGNORE( iFSOperationObserver.RequestResponseL( prog, iFSRequestId ) ); |
253 TMsvEntry tentry; |
263 } |
254 TMsvId service; |
264 } |
255 iMsvSession.GetEntry(iService, service, tentry ); |
265 } |
256 return tentry.Connected(); |
266 |
257 } |
267 // ---------------------------------------------------------------------------- |
258 // </qmail> |
268 // ---------------------------------------------------------------------------- |
|
269 TInt CIpsPlgOnlineOperation::IpsOpType() const |
|
270 { |
|
271 FUNC_LOG; |
|
272 return EIpsOpTypeOnlineOp; |
|
273 } |
|
274 |
|