|
1 /* |
|
2 * Copyright (c) 2007-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: common base mailbox object |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <AknUtils.h> // AknTextUtils |
|
19 |
|
20 #include "emailtrace.h" |
|
21 #include "CFSMailBoxBase.h" |
|
22 |
|
23 _LIT( KCharsToReplace, "\r\n\t\x2028\x2029" ); |
|
24 |
|
25 // ================= MEMBER FUNCTIONS ========================================== |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CFSMailBoxBase::NewLC |
|
28 // ----------------------------------------------------------------------------- |
|
29 EXPORT_C CFSMailBoxBase* CFSMailBoxBase::NewLC(TFSMailMsgId aMailBoxId) |
|
30 { |
|
31 FUNC_LOG; |
|
32 CFSMailBoxBase* api = new (ELeave) CFSMailBoxBase(); |
|
33 CleanupStack:: PushL(api); |
|
34 api->ConstructL(aMailBoxId); |
|
35 return api; |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CFSMailBoxBase::NewL |
|
40 // ----------------------------------------------------------------------------- |
|
41 EXPORT_C CFSMailBoxBase* CFSMailBoxBase::NewL(TFSMailMsgId aMailBoxId) |
|
42 { |
|
43 FUNC_LOG; |
|
44 CFSMailBoxBase* api = CFSMailBoxBase::NewLC(aMailBoxId); |
|
45 CleanupStack:: Pop(api); |
|
46 return api; |
|
47 } |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CFSMailBoxBase::CFSMailBoxBase |
|
50 // ----------------------------------------------------------------------------- |
|
51 CFSMailBoxBase::CFSMailBoxBase() : CExtendableEmail() |
|
52 { |
|
53 FUNC_LOG; |
|
54 |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CFSMailBoxBase::~CFSMailBoxBase |
|
59 // ----------------------------------------------------------------------------- |
|
60 EXPORT_C CFSMailBoxBase::~CFSMailBoxBase() |
|
61 { |
|
62 FUNC_LOG; |
|
63 if( iMailBoxName ) |
|
64 { |
|
65 delete iMailBoxName; |
|
66 } |
|
67 iMailBoxName = NULL; |
|
68 |
|
69 if( iBrId ) |
|
70 { |
|
71 delete iBrId; |
|
72 } |
|
73 iBrId = NULL; |
|
74 |
|
75 if( iOwnMailAddress ) |
|
76 { |
|
77 delete iOwnMailAddress; |
|
78 } |
|
79 iOwnMailAddress = NULL; |
|
80 |
|
81 if( iMRInfoProcessor ) |
|
82 { |
|
83 delete iMRInfoProcessor; |
|
84 } |
|
85 iMRInfoProcessor = NULL; |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CFSMailBoxBase::ConstructL |
|
90 // ----------------------------------------------------------------------------- |
|
91 void CFSMailBoxBase::ConstructL(const TFSMailMsgId aMailBoxId) |
|
92 { |
|
93 FUNC_LOG; |
|
94 iMailBoxId = aMailBoxId; |
|
95 |
|
96 // <cmail> code moved here and modified to fix OOM test |
|
97 // prepare null empty descriptor |
|
98 iMailBoxName = HBufC::NewL(1); |
|
99 iMailBoxName->Des().Copy(KNullDesC()); |
|
100 |
|
101 iBrId = HBufC::NewL(1); |
|
102 iBrId->Des().Copy(KNullDesC()); |
|
103 // </cmail> |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CFSMailBoxBase::GetId |
|
108 // ----------------------------------------------------------------------------- |
|
109 EXPORT_C TFSMailMsgId CFSMailBoxBase::GetId() const |
|
110 { |
|
111 FUNC_LOG; |
|
112 return iMailBoxId; |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CFSMailBoxBase::GetName |
|
117 // ----------------------------------------------------------------------------- |
|
118 EXPORT_C TDesC& CFSMailBoxBase::GetName() const |
|
119 { |
|
120 FUNC_LOG; |
|
121 return *iMailBoxName; |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CFSMailBoxBase::SetName |
|
126 // ----------------------------------------------------------------------------- |
|
127 EXPORT_C void CFSMailBoxBase::SetName( const TDesC& aMailBoxName ) |
|
128 { |
|
129 FUNC_LOG; |
|
130 // init mailbox name |
|
131 HBufC* name = HBufC::New(aMailBoxName.Length()); |
|
132 |
|
133 // store new mailbox name |
|
134 if(name) |
|
135 { |
|
136 name->Des().Copy(aMailBoxName); |
|
137 TPtr textPtr = name->Des(); |
|
138 AknTextUtils::ReplaceCharacters( textPtr, KCharsToReplace, ' ' ); |
|
139 |
|
140 delete iMailBoxName; |
|
141 iMailBoxName = name; |
|
142 } |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CFSMailBoxBase::GetStatus |
|
147 // ----------------------------------------------------------------------------- |
|
148 EXPORT_C TFSMailBoxStatus CFSMailBoxBase::GetStatus( ) const |
|
149 { |
|
150 FUNC_LOG; |
|
151 return EFSMailBoxOffline; |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CFSMailBoxBase::SetStatus |
|
156 // ----------------------------------------------------------------------------- |
|
157 EXPORT_C void CFSMailBoxBase::SetStatus( const TFSMailBoxStatus /*aStatus*/ ) |
|
158 { |
|
159 FUNC_LOG; |
|
160 |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CFSMailBoxBase::GetRCLInfo |
|
165 // ----------------------------------------------------------------------------- |
|
166 EXPORT_C void CFSMailBoxBase::GetRCLInfo(TUid& aProtocolUid, TUint& aAccountUid) |
|
167 { |
|
168 FUNC_LOG; |
|
169 aProtocolUid = iProtocolUid; |
|
170 aAccountUid = iAccountUid; |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CFSMailBoxBase::SetRCLInfo |
|
175 // ----------------------------------------------------------------------------- |
|
176 EXPORT_C void CFSMailBoxBase::SetRCLInfo(const TUid aProtocolUid, const TUint aAccountUid) |
|
177 { |
|
178 FUNC_LOG; |
|
179 iProtocolUid = aProtocolUid; |
|
180 iAccountUid = aAccountUid; |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CFSMailBoxBase::GetSettingsUid |
|
185 // ----------------------------------------------------------------------------- |
|
186 EXPORT_C const TUid CFSMailBoxBase::GetSettingsUid() |
|
187 { |
|
188 FUNC_LOG; |
|
189 return iSettingsUid; |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CFSMailBoxBase::SetSettingsUid |
|
194 // ----------------------------------------------------------------------------- |
|
195 EXPORT_C void CFSMailBoxBase::SetSettingsUid(const TUid aUid) |
|
196 { |
|
197 FUNC_LOG; |
|
198 iSettingsUid = aUid; |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CFSMailBoxBase::MRInfoProcessorL |
|
203 // ----------------------------------------------------------------------------- |
|
204 EXPORT_C MMRInfoProcessor& CFSMailBoxBase::MRInfoProcessorL() |
|
205 { |
|
206 FUNC_LOG; |
|
207 return *iMRInfoProcessor; |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CFSMailBoxBase::IsMRInfoProcessorSet |
|
212 // ----------------------------------------------------------------------------- |
|
213 EXPORT_C TBool CFSMailBoxBase::IsMRInfoProcessorSet() |
|
214 { |
|
215 FUNC_LOG; |
|
216 if(iMRInfoProcessor) |
|
217 { |
|
218 return ETrue; |
|
219 } |
|
220 else |
|
221 { |
|
222 return EFalse; |
|
223 } |
|
224 } |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CFSMailBoxBase::SetMRInfoProcessorL |
|
228 // ----------------------------------------------------------------------------- |
|
229 EXPORT_C void CFSMailBoxBase::SetMRInfoProcessorL(MMRInfoProcessor* aMRInfoProcessor) |
|
230 { |
|
231 FUNC_LOG; |
|
232 |
|
233 if(iMRInfoProcessor) |
|
234 { |
|
235 delete iMRInfoProcessor; |
|
236 } |
|
237 iMRInfoProcessor = aMRInfoProcessor; |
|
238 } |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // CFSMailBoxBase::OwnMailAddress |
|
242 // ----------------------------------------------------------------------------- |
|
243 EXPORT_C CFSMailAddress& CFSMailBoxBase::OwnMailAddress( ) |
|
244 { |
|
245 FUNC_LOG; |
|
246 return *iOwnMailAddress; |
|
247 } |
|
248 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // CFSMailBoxBase::SetOwnMailAddress |
|
251 // ----------------------------------------------------------------------------- |
|
252 EXPORT_C void CFSMailBoxBase::SetOwnMailAddressL( CFSMailAddress* aOwnMailAddress) |
|
253 { |
|
254 FUNC_LOG; |
|
255 if(iOwnMailAddress) |
|
256 { |
|
257 delete iOwnMailAddress; |
|
258 } |
|
259 iOwnMailAddress = aOwnMailAddress; |
|
260 |
|
261 // set also branding id based on domain name |
|
262 TPtrC ptr = OwnMailAddress().GetEmailAddress(); |
|
263 TInt index = ptr.Locate('@') + 1; |
|
264 if(index > 0 && ptr.Length() > 0) |
|
265 { |
|
266 if(iBrId) |
|
267 { |
|
268 delete iBrId; |
|
269 iBrId = NULL; |
|
270 } |
|
271 ptr.Set( ptr.Right( ptr.Length() - index ) ); |
|
272 iBrId = HBufC::New(ptr.Length()); |
|
273 iBrId->Des().Copy(ptr); |
|
274 } |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // CFSMailBoxBase::BrandingId |
|
279 // ----------------------------------------------------------------------------- |
|
280 TDesC& CFSMailBoxBase::BrandingId( ) |
|
281 { |
|
282 FUNC_LOG; |
|
283 return *iBrId; |
|
284 } |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CFSMailBoxBase::MailBoxId |
|
288 // ----------------------------------------------------------------------------- |
|
289 void CFSMailBoxBase::SetMailBoxId( TFSMailMsgId aMailBoxId ) |
|
290 { |
|
291 FUNC_LOG; |
|
292 iMailBoxId = aMailBoxId; |
|
293 } |
|
294 |
|
295 |