|
1 /* |
|
2 * Copyright (c) 2006-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: IMAP4 connect operation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "emailtrace.h" |
|
21 #include "ipsplgheaders.h" |
|
22 |
|
23 // Constants and defines |
|
24 const TInt KConnectOpPriority = CActive::EPriorityStandard; |
|
25 |
|
26 // ---------------------------------------------------------------------------- |
|
27 // CIpsPlgDisconnectOp::NewL() |
|
28 // ---------------------------------------------------------------------------- |
|
29 // |
|
30 CIpsPlgDisconnectOp* CIpsPlgDisconnectOp::NewL( |
|
31 CMsvSession& aMsvSession, |
|
32 TRequestStatus& aObserverRequestStatus, |
|
33 TMsvId aService, |
|
34 CIpsPlgTimerOperation& aActivityTimer, |
|
35 TFSMailMsgId aFSMailBoxId, |
|
36 MFSMailRequestObserver& aFSOperationObserver, |
|
37 TInt aFSRequestId, |
|
38 TBool aDoRemoveAfterDisconnect ) |
|
39 { |
|
40 FUNC_LOG; |
|
41 CIpsPlgDisconnectOp* op = new(ELeave) CIpsPlgDisconnectOp(aMsvSession, |
|
42 aObserverRequestStatus, |
|
43 aService, |
|
44 aActivityTimer, |
|
45 aFSMailBoxId, |
|
46 aFSOperationObserver, |
|
47 aFSRequestId, |
|
48 aDoRemoveAfterDisconnect ); |
|
49 |
|
50 CleanupStack::PushL(op); |
|
51 op->ConstructL(); |
|
52 CleanupStack::Pop( op ); |
|
53 return op; |
|
54 } |
|
55 |
|
56 // ---------------------------------------------------------------------------- |
|
57 // CIpsPlgDisconnectOp::~CIpsPlgDisconnectOp() |
|
58 // ---------------------------------------------------------------------------- |
|
59 // |
|
60 CIpsPlgDisconnectOp::~CIpsPlgDisconnectOp() |
|
61 { |
|
62 FUNC_LOG; |
|
63 } |
|
64 |
|
65 // ---------------------------------------------------------------------------- |
|
66 // CIpsPlgDisconnectOp::ProgressL() |
|
67 // ---------------------------------------------------------------------------- |
|
68 // |
|
69 const TDesC8& CIpsPlgDisconnectOp::ProgressL() |
|
70 { |
|
71 FUNC_LOG; |
|
72 if ( iTEntry.iMtm == KUidMsgTypePOP3 ) |
|
73 { |
|
74 return iPopProgress; |
|
75 } |
|
76 else |
|
77 { |
|
78 return iImapProgress; |
|
79 } |
|
80 } |
|
81 |
|
82 // ---------------------------------------------------------------------------- |
|
83 // CIpsPlgDisconnectOp::GetErrorProgressL() |
|
84 // ---------------------------------------------------------------------------- |
|
85 // |
|
86 const TDesC8& CIpsPlgDisconnectOp::GetErrorProgressL(TInt aError) |
|
87 { |
|
88 FUNC_LOG; |
|
89 iError = aError; |
|
90 if ( iOperation && iError == KErrNone ) |
|
91 { |
|
92 return iOperation->ProgressL(); |
|
93 } |
|
94 |
|
95 if ( iTEntry.iMtm == KUidMsgTypePOP3 ) |
|
96 { |
|
97 return iPopProgress; |
|
98 } |
|
99 else |
|
100 { |
|
101 return iImapProgress; |
|
102 } |
|
103 } |
|
104 |
|
105 // ---------------------------------------------------------------------------- |
|
106 // CIpsPlgDisconnectOp::GetFSProgressL() |
|
107 // ---------------------------------------------------------------------------- |
|
108 // |
|
109 TFSProgress CIpsPlgDisconnectOp::GetFSProgressL() const |
|
110 { |
|
111 FUNC_LOG; |
|
112 TFSProgress result = { TFSProgress::EFSStatus_Waiting, 0, 0, KErrNone }; |
|
113 if ( Connected() ) |
|
114 { |
|
115 result.iProgressStatus = TFSProgress::EFSStatus_Connected; |
|
116 result.iError = KErrNone; |
|
117 } |
|
118 else |
|
119 { |
|
120 result.iProgressStatus = TFSProgress::EFSStatus_RequestComplete; |
|
121 result.iError = iStatus.Int(); |
|
122 } |
|
123 return result; |
|
124 } |
|
125 |
|
126 // ---------------------------------------------------------------------------- |
|
127 // CIpsPlgDisconnectOp::Connected() |
|
128 // ---------------------------------------------------------------------------- |
|
129 // |
|
130 TBool CIpsPlgDisconnectOp::Connected() const |
|
131 { |
|
132 FUNC_LOG; |
|
133 return iTEntry.Connected(); |
|
134 } |
|
135 |
|
136 // ---------------------------------------------------------------------------- |
|
137 // CIpsPlgDisconnectOp::DoRunL() |
|
138 // ---------------------------------------------------------------------------- |
|
139 // |
|
140 void CIpsPlgDisconnectOp::DoRunL() |
|
141 { |
|
142 FUNC_LOG; |
|
143 if( !iDisconnected ) |
|
144 { |
|
145 DoDisconnectL(); |
|
146 iDisconnected = ETrue; |
|
147 } |
|
148 else |
|
149 { |
|
150 if ( iDoRemoveAfterDisconnect ) |
|
151 { |
|
152 CIpsSetDataApi* settings = CIpsSetDataApi::NewL( iMsvSession ); |
|
153 CleanupStack::PushL( settings ); |
|
154 settings->RemoveAccountL( iTEntry, iMsvSession ); |
|
155 CleanupStack::PopAndDestroy( settings ); |
|
156 |
|
157 // delete the activitytimer here and set it to null so we don't try |
|
158 // to use it in CompleteObserver. This is a special case that |
|
159 // relates to deleting a connected mailbox. |
|
160 delete iActivityTimer; |
|
161 iActivityTimer = NULL; |
|
162 } |
|
163 |
|
164 CompleteObserver( KErrNone ); |
|
165 } |
|
166 } |
|
167 |
|
168 // ---------------------------------------------------------------------------- |
|
169 // CIpsPlgDisconnectOp::CIpsPlgDisconnectOp() |
|
170 // ---------------------------------------------------------------------------- |
|
171 // |
|
172 CIpsPlgDisconnectOp::CIpsPlgDisconnectOp( |
|
173 CMsvSession& aMsvSession, |
|
174 TRequestStatus& aObserverRequestStatus, |
|
175 TMsvId aServiceId, |
|
176 CIpsPlgTimerOperation& aActivityTimer, |
|
177 TFSMailMsgId aFSMailBoxId, |
|
178 MFSMailRequestObserver& aFSOperationObserver, |
|
179 TInt aFSRequestId, |
|
180 TBool aDoRemoveAfterDisconnect ) |
|
181 : |
|
182 CIpsPlgOnlineOperation( |
|
183 aMsvSession, |
|
184 KConnectOpPriority, |
|
185 aObserverRequestStatus, |
|
186 aActivityTimer, |
|
187 aFSMailBoxId, |
|
188 aFSOperationObserver, |
|
189 aFSRequestId), |
|
190 iDoRemoveAfterDisconnect( aDoRemoveAfterDisconnect ) |
|
191 { |
|
192 iService = aServiceId; |
|
193 } |
|
194 |
|
195 // ---------------------------------------------------------------------------- |
|
196 // CIpsPlgDisconnectOp::ConstructL() |
|
197 // ---------------------------------------------------------------------------- |
|
198 // |
|
199 void CIpsPlgDisconnectOp::ConstructL() |
|
200 { |
|
201 FUNC_LOG; |
|
202 iDisconnected = EFalse; |
|
203 TMsvId service; |
|
204 |
|
205 iMsvSession.GetEntry( iService, service, iTEntry ); |
|
206 |
|
207 if ( iTEntry.iType.iUid == KUidMsvServiceEntryValue ) |
|
208 { |
|
209 BaseConstructL( iTEntry.iMtm ); |
|
210 } |
|
211 else |
|
212 { |
|
213 //should we panic with own codes? |
|
214 User::Leave( KErrNotSupported ); |
|
215 } |
|
216 |
|
217 SetActive(); |
|
218 CompleteThis(); |
|
219 } |
|
220 |
|
221 // ---------------------------------------------------------------------------- |
|
222 // CIpsPlgDisconnectOp::DoDisconnectL() |
|
223 // ---------------------------------------------------------------------------- |
|
224 // |
|
225 void CIpsPlgDisconnectOp::DoDisconnectL() |
|
226 { |
|
227 FUNC_LOG; |
|
228 iStatus = KRequestPending; |
|
229 |
|
230 TInt cmd = (iTEntry.iMtm == KUidMsgTypePOP3) ? KPOP3MTMDisconnect : KIMAP4MTMDisconnect; |
|
231 |
|
232 InvokeClientMtmAsyncFunctionL(cmd, iService, iService); |
|
233 SetActive(); |
|
234 } |
|
235 |