|
1 /* |
|
2 * Copyright (c) 2006 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: Email interface implementation, translator utilities. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "BasePlugin.h" |
|
21 #include "baseplugincommonutils.h" |
|
22 #include "CFSMailCommon.h" |
|
23 |
|
24 |
|
25 static void TranslateMsgStoreAttendeeL( |
|
26 CMsgStorePropertyContainer& aSrc, |
|
27 TUint aIdx, |
|
28 MMROrganizer& aAttendee ); |
|
29 |
|
30 static void TranslateMsgStoreAttendeesL( |
|
31 CMsgStorePropertyContainer& aMessage, |
|
32 CBaseMrInfoObject& aMrInfo, |
|
33 const TDesC8& aProperty, |
|
34 MMRAttendee::TAttendeeRole aRole ); |
|
35 |
|
36 |
|
37 /**@ the info object's description field is mapped to the message body which can be |
|
38 of arbitrary size; at the moment cap the max description size to avoid memory problems.*/ |
|
39 const TInt KMaxDescription = 512*1024; |
|
40 |
|
41 /** |
|
42 * |
|
43 */ |
|
44 class TDayOfWeekFtor |
|
45 { |
|
46 public: |
|
47 virtual void operator () ( MRRecurrenceRule::TMRRecurrentDay aDay ) = 0; |
|
48 }; |
|
49 |
|
50 /** |
|
51 * |
|
52 */ |
|
53 class TWeekDayTranslator : public TDayOfWeekFtor |
|
54 { |
|
55 public: |
|
56 TWeekDayTranslator( RArray<MRRecurrenceRule::TMRRecurrentDay>& aDays ) |
|
57 : iDays( aDays ) |
|
58 { |
|
59 }; |
|
60 |
|
61 virtual void operator () ( MRRecurrenceRule::TMRRecurrentDay aDay ) |
|
62 { |
|
63 iDays.AppendL( aDay ); |
|
64 }; |
|
65 |
|
66 private: |
|
67 RArray<MRRecurrenceRule::TMRRecurrentDay>& iDays; |
|
68 }; |
|
69 |
|
70 /** |
|
71 * |
|
72 */ |
|
73 class TMonthDayTranslator : public TDayOfWeekFtor |
|
74 { |
|
75 public: |
|
76 TMonthDayTranslator( MRRecurrenceRule::TMRRecurrentDay& aDayOfWeek ) |
|
77 : iDayOfWeek( aDayOfWeek ) |
|
78 { |
|
79 }; |
|
80 |
|
81 virtual void operator () ( MRRecurrenceRule::TMRRecurrentDay aDay ) |
|
82 { |
|
83 /**@ the contract with IMS/Outlook is that there is a single day |
|
84 set in a monthly by day of week rule; asserts ?*/ |
|
85 iDayOfWeek = aDay; |
|
86 }; |
|
87 |
|
88 private: |
|
89 MRRecurrenceRule::TMRRecurrentDay& iDayOfWeek; |
|
90 }; |
|
91 |
|
92 |
|
93 /** |
|
94 * |
|
95 */ |
|
96 EXPORT_C void CBasePlugin::TranslateMsgStorePropsL( |
|
97 const TFSMailMsgId& aMailBoxId, |
|
98 CMsgStorePropertyContainer& aMessage, |
|
99 CFSMailMessagePart& aFsMsg, |
|
100 const TFSMailDetails aDetails ) |
|
101 |
|
102 { |
|
103 __LOG_ENTER( "TranslateMsgStorePropsL" ) |
|
104 |
|
105 __LOG_WRITE_FORMAT1_INFO( "aDetails = 0x%X.", aDetails ) |
|
106 |
|
107 TFSMailMsgId fsId( GetPluginId(), aMessage.ParentId() ); |
|
108 aFsMsg.SetFolderId( fsId ); |
|
109 |
|
110 TUint idx = 0; |
|
111 //subject. |
|
112 if ( ( EFSMsgDataEnvelope & aDetails || EFSMsgDataStructure & aDetails |
|
113 || EFSMsgDataSubject & aDetails ) |
|
114 && aMessage.FindProperty( KMsgStorePropertySubject, idx ) ) |
|
115 { |
|
116 const TDesC& subject = aMessage.PropertyValueDesL( idx ); |
|
117 aFsMsg.SetSubject( subject ); |
|
118 idx = 0; |
|
119 |
|
120 __LOG_WRITE_FORMAT1_INFO( "Subject: %S.", &subject ); |
|
121 } |
|
122 |
|
123 //from. |
|
124 if ( ( EFSMsgDataEnvelope & aDetails|| EFSMsgDataStructure & aDetails |
|
125 || EFSMsgDataSender & aDetails ) |
|
126 && aMessage.FindProperty( KMsgStorePropertyFrom, idx ) ) |
|
127 { |
|
128 CFSMailAddress* address = FetchEmailAddressL( aMessage, idx ); |
|
129 aFsMsg.SetSender( address ); |
|
130 idx = 0; |
|
131 } |
|
132 |
|
133 //received. |
|
134 if ( ( EFSMsgDataEnvelope & aDetails || EFSMsgDataStructure & aDetails |
|
135 || EFSMsgDataDate & aDetails ) |
|
136 && aMessage.FindProperty( KMsgStorePropertyReceivedAt, idx ) ) |
|
137 { |
|
138 TTime time; |
|
139 aMessage.PropertyValueTimeL( idx, time ); |
|
140 aFsMsg.SetDate( time ); |
|
141 idx = 0; |
|
142 |
|
143 __LOG_WRITE8_FORMAT1_INFO( "Received: %ld.", time.Int64() ); |
|
144 } |
|
145 |
|
146 //sent. |
|
147 if ( ( EFSMsgDataEnvelope & aDetails || EFSMsgDataStructure & aDetails |
|
148 || EFSMsgDataDate & aDetails ) |
|
149 && aMessage.FindProperty( KMsgStorePropertySent, idx ) ) |
|
150 { |
|
151 TTime time; |
|
152 aMessage.PropertyValueTimeL( idx, time ); |
|
153 aFsMsg.SetDate( time ); |
|
154 idx = 0; |
|
155 |
|
156 __LOG_WRITE8_FORMAT1_INFO( "Sent: %ld.", time.Int64() ); |
|
157 } |
|
158 |
|
159 if ( EFSMsgDataEnvelope & aDetails || EFSMsgDataStructure & aDetails ) |
|
160 { |
|
161 //to recipients. |
|
162 while ( aMessage.FindProperty( KMsgStorePropertyTo, idx, idx ) ) |
|
163 { |
|
164 CFSMailAddress* address = FetchEmailAddressL( aMessage, idx ); |
|
165 aFsMsg.AppendToRecipient( address ); |
|
166 ++idx; |
|
167 } |
|
168 idx = 0; |
|
169 |
|
170 //cc recipients. |
|
171 while ( aMessage.FindProperty( KMsgStorePropertyCc, idx, idx ) ) |
|
172 { |
|
173 CFSMailAddress* address = FetchEmailAddressL( aMessage, idx ); |
|
174 aFsMsg.AppendCCRecipient( address ); |
|
175 ++idx; |
|
176 } |
|
177 idx = 0; |
|
178 |
|
179 //bcc recipients. |
|
180 while ( aMessage.FindProperty( KMsgStorePropertyBcc, idx, idx ) ) |
|
181 { |
|
182 CFSMailAddress* address = FetchEmailAddressL( aMessage, idx ); |
|
183 aFsMsg.AppendBCCRecipient( address ); |
|
184 ++idx; |
|
185 } |
|
186 idx = 0; |
|
187 |
|
188 //flags. |
|
189 if ( aMessage.FindProperty( KMsgStorePropertyFlags, idx ) ) |
|
190 { |
|
191 TUint32 i = aMessage.PropertyValueUint32L( idx ); |
|
192 aFsMsg.SetFlag( i ); |
|
193 idx = 0; |
|
194 |
|
195 __LOG_WRITE_FORMAT1_INFO( "Flags: 0x%X.", i ) |
|
196 } |
|
197 |
|
198 //content-size. |
|
199 if ( aMessage.FindProperty( KMsgStorePropertySize, idx ) ) |
|
200 { |
|
201 TUint32 i = aMessage.PropertyValueUint32L( idx ); |
|
202 aFsMsg.SetContentSize( i ); |
|
203 idx = 0; |
|
204 |
|
205 __LOG_WRITE_FORMAT1_INFO( "Content-size: %d.", i ) |
|
206 } |
|
207 |
|
208 //content-type. |
|
209 if ( aMessage.FindProperty( KMsgStorePropertyContentType, idx ) ) |
|
210 { |
|
211 |
|
212 const TDesC& contentType = aMessage.PropertyValueDesL( idx ); |
|
213 |
|
214 idx = 0; |
|
215 if ( aMessage.FindProperty( KMsgStorePropertyCharset, idx ) ) |
|
216 { |
|
217 _LIT( KCharSemicolon, ";" ); |
|
218 const TDesC& charSet = aMessage.PropertyValueDesL( idx ); |
|
219 |
|
220 TInt maxLength = contentType.Length() + KFSMailContentTypeParamCharset().Length() + |
|
221 KCharSemicolon().Length() + charSet.Length(); |
|
222 |
|
223 HBufC* buf = HBufC::NewLC( maxLength ); |
|
224 TPtr bufPtr( buf->Des() ); |
|
225 |
|
226 bufPtr.Append( contentType ); |
|
227 bufPtr.Append( KCharSemicolon ); |
|
228 bufPtr.Append( KFSMailContentTypeParamCharset ); |
|
229 bufPtr.Append( charSet ); |
|
230 aFsMsg.SetContentType( bufPtr ); |
|
231 __LOG_WRITE_FORMAT1_INFO( "Content-type: %S.", &bufPtr ); |
|
232 CleanupStack::PopAndDestroy( buf ); |
|
233 } |
|
234 else |
|
235 { |
|
236 aFsMsg.SetContentType( contentType ); |
|
237 __LOG_WRITE_FORMAT1_INFO( "Content-type: %S.", &contentType ); |
|
238 } |
|
239 |
|
240 idx = 0; |
|
241 } |
|
242 |
|
243 //content-id. |
|
244 if ( aMessage.FindProperty( KMsgStorePropertyContentId, idx ) ) |
|
245 { |
|
246 const TDesC& contentId = aMessage.PropertyValueDesL( idx ); |
|
247 aFsMsg.SetContentIDL( contentId ); |
|
248 idx = 0; |
|
249 |
|
250 __LOG_WRITE_FORMAT1_INFO( "Content-id: %S.", &contentId ); |
|
251 } |
|
252 |
|
253 //content-description. |
|
254 if ( aMessage.FindProperty( KMsgStorePropertyContentDescription, idx ) ) |
|
255 { |
|
256 const TDesC& contentDescription = aMessage.PropertyValueDesL( idx ); |
|
257 aFsMsg.SetContentDescription( contentDescription ); |
|
258 idx = 0; |
|
259 |
|
260 __LOG_WRITE_FORMAT1_INFO( |
|
261 "Content-description: %S.", &contentDescription ); |
|
262 } |
|
263 |
|
264 //content-class. |
|
265 if ( aMessage.FindProperty( KMsgStorePropertyContentClass, idx ) ) |
|
266 { |
|
267 const TDesC& contentClass = aMessage.PropertyValueDesL( idx ); |
|
268 aFsMsg.SetContentClass( contentClass ); |
|
269 idx = 0; |
|
270 } |
|
271 |
|
272 //fetched content size. |
|
273 if ( aMessage.FindProperty( KMsgStorePropertyRetrievedSize, idx ) ) |
|
274 { |
|
275 TUint32 retrievedSize = aMessage.PropertyValueUint32L( idx ); |
|
276 aFsMsg.SetFetchedContentSize( retrievedSize ); |
|
277 idx = 0; |
|
278 } |
|
279 |
|
280 //content-disposition. |
|
281 if ( aMessage.FindProperty( KMsgStorePropertyContentDisposition, idx ) ) |
|
282 { |
|
283 const TDesC& contentDisposition = aMessage.PropertyValueDesL( idx ); |
|
284 aFsMsg.SetContentDisposition( contentDisposition ); |
|
285 idx = 0; |
|
286 |
|
287 __LOG_WRITE_FORMAT1_INFO( |
|
288 "Content-desposition: %S.", &contentDisposition ); |
|
289 } |
|
290 |
|
291 //meeting request info. |
|
292 if ( aMessage.FindProperty( KMsgStorePropertyMeetingRequest, idx ) ) |
|
293 { |
|
294 CMsgStorePropertyContainer* mrInfo |
|
295 = aMessage.PropertyValueContainerL( idx ); |
|
296 CleanupStack::PushL( mrInfo ); |
|
297 TranslateMsgStoreMrL( aMailBoxId, aMessage, *mrInfo, aFsMsg ); |
|
298 CleanupStack::PopAndDestroy( mrInfo ); |
|
299 idx = 0; |
|
300 } |
|
301 |
|
302 //read-only size |
|
303 if ( aMessage.FindProperty( KMsgStorePropertyReadOnlySize, idx ) ) |
|
304 { |
|
305 TUint readOnlySize = aMessage.PropertyValueUint32L(idx); |
|
306 aFsMsg.SetReadOnlyPartSize(readOnlySize); |
|
307 idx = 0; |
|
308 } |
|
309 } |
|
310 |
|
311 __LOG_EXIT |
|
312 } //TranslateMsgStorePropsL. |
|
313 |
|
314 |
|
315 /** |
|
316 * Common msgstore meeting request fields translation to Freestyle. |
|
317 * |
|
318 * @param aMessage |
|
319 * @param aFsMsg |
|
320 */ |
|
321 EXPORT_C void CBasePlugin::TranslateMsgStoreMrL( |
|
322 const TFSMailMsgId& aMailBoxId, |
|
323 CMsgStorePropertyContainer& aMessage, |
|
324 CMsgStorePropertyContainer& aCalendar, |
|
325 CFSMailMessagePart& aFsMsg ) |
|
326 |
|
327 { |
|
328 __LOG_ENTER( "TranslateMsgStoreMrL" ) |
|
329 |
|
330 CBaseMrInfoObject* mmrInfo = CBaseMrInfoObject::NewL(); |
|
331 CleanupStack::PushL( mmrInfo ); |
|
332 |
|
333 TUint idx; |
|
334 |
|
335 //uid. |
|
336 idx = 0; |
|
337 if ( aCalendar.FindProperty( KMsgStorePropertyMrGuid, idx ) ) |
|
338 { |
|
339 const TDesC8& uid8 = aCalendar.PropertyValueDes8L( idx ); |
|
340 |
|
341 HBufC* uid = HBufC::NewLC( uid8.Length() ); |
|
342 //uid not utf8-encoded. |
|
343 uid->Des().Copy( uid8 ); |
|
344 mmrInfo->SetUidL( uid ); |
|
345 |
|
346 CleanupStack::Pop( uid ); |
|
347 } |
|
348 |
|
349 //subject. |
|
350 idx = 0; |
|
351 if ( aMessage.FindProperty( KMsgStorePropertySubject, idx ) ) |
|
352 { |
|
353 const TDesC& subject = aMessage.PropertyValueDesL( idx ); |
|
354 mmrInfo->SetSubjectL( subject ); |
|
355 |
|
356 __LOG_WRITE_FORMAT1_INFO( "MR Subject: %S.", &subject ); |
|
357 } |
|
358 |
|
359 //description - the plain/text email body. |
|
360 __LOG_WRITE_INFO( "About to translate the description field." ); |
|
361 idx = 0; |
|
362 TMsgStoreId msgId = aMessage.Id(); |
|
363 |
|
364 CMailboxInfo& mailBox = GetMailboxInfoL( aMailBoxId.Id() ); |
|
365 CMsgStoreMessage* theMessage = mailBox().FetchMessageL( msgId, KMsgStoreInvalidId ); |
|
366 CleanupStack::PushL( theMessage ); |
|
367 |
|
368 CMsgStoreMessagePart* plainText = GetBodyPartL( *theMessage ); |
|
369 if ( NULL != plainText ) |
|
370 { |
|
371 CleanupStack::PushL( plainText ); |
|
372 |
|
373 TUint length = plainText->ContentLengthL(); |
|
374 //the body can be of arbitrary size - taking precautions until resolved. |
|
375 length = length < KMaxDescription ? length : KMaxDescription; |
|
376 HBufC* description = HBufC::NewLC( length ); |
|
377 |
|
378 RBuf8 buf8; |
|
379 CleanupClosePushL( buf8 ); |
|
380 buf8.CreateL( length ); |
|
381 |
|
382 plainText->FetchContentToBufferL( buf8 ); |
|
383 |
|
384 //replace the cr with the lf per iCal spec otherwise the Symbian iCal importer would leave with -20; |
|
385 //see ANN0001 for more info. |
|
386 |
|
387 _LIT8( KCrLf, "\r\x00\n\x00" ); |
|
388 _LIT8( KLf, "\n\x00" ); |
|
389 const TUint crLfSize = KCrLf().Size(); |
|
390 |
|
391 TInt idx = KErrNotFound; |
|
392 while ( KErrNotFound != ( idx = buf8.Find( KCrLf ) ) ) |
|
393 { |
|
394 buf8.Replace( idx, crLfSize, KLf ); |
|
395 } |
|
396 |
|
397 TPtrC ptr( KNullDesC ); |
|
398 ptr.Set( reinterpret_cast<const TUint16*>( buf8.Ptr() ), buf8.Length() / 2 ); |
|
399 |
|
400 mmrInfo->SetDescriptionL( ptr ); |
|
401 |
|
402 //CleanupStack::PopAndDestroy( body ); |
|
403 CleanupStack::PopAndDestroy( &buf8 ); |
|
404 CleanupStack::PopAndDestroy( description ); |
|
405 CleanupStack::PopAndDestroy( plainText ); |
|
406 } |
|
407 CleanupStack::PopAndDestroy( theMessage ); |
|
408 |
|
409 //creation date. |
|
410 idx = 0; |
|
411 if ( aCalendar.FindProperty( KMsgStorePropertyMrCreationDate, idx ) ) |
|
412 { |
|
413 TTime time; |
|
414 aCalendar.PropertyValueTimeL( idx, time ); |
|
415 mmrInfo->SetCreationTimeInUtcL( time ); |
|
416 } |
|
417 |
|
418 //start date. |
|
419 idx = 0; |
|
420 if ( aCalendar.FindProperty( KMsgStorePropertyMrStartDate, idx ) ) |
|
421 { |
|
422 TTime time; |
|
423 aCalendar.PropertyValueTimeL( idx, time ); |
|
424 mmrInfo->SetStartTimeInUtcL( time ); |
|
425 } |
|
426 |
|
427 //end date. |
|
428 idx = 0; |
|
429 if ( aCalendar.FindProperty( KMsgStorePropertyMrEndDate, idx ) ) |
|
430 { |
|
431 TTime time; |
|
432 aCalendar.PropertyValueTimeL( idx, time ); |
|
433 mmrInfo->SetEndTimeInUtcL( time ); |
|
434 } |
|
435 |
|
436 //location. |
|
437 idx = 0; |
|
438 if ( aCalendar.FindProperty( KMsgStorePropertyMrLocation, idx ) ) |
|
439 { |
|
440 const TDesC& location = aCalendar.PropertyValueDesL( idx ); |
|
441 mmrInfo->SetLocationL( location ); |
|
442 } |
|
443 |
|
444 //organizer / from. |
|
445 idx = 0; |
|
446 if ( aMessage.FindProperty( KMsgStorePropertyFrom, idx ) ) |
|
447 { |
|
448 TranslateMsgStoreAttendeeL( aMessage, idx, mmrInfo->MROrganizerL() ); |
|
449 } |
|
450 |
|
451 //attendees / to. |
|
452 TranslateMsgStoreAttendeesL( |
|
453 aMessage, *mmrInfo, KMsgStorePropertyTo, MMRAttendee::EMRAttendeeParticipant ); |
|
454 |
|
455 //attendees / cc. |
|
456 TranslateMsgStoreAttendeesL( |
|
457 aMessage, *mmrInfo, KMsgStorePropertyCc, MMRAttendee::EMRAttendeeOptionalParticipant ); |
|
458 |
|
459 //recurrence info. |
|
460 __LOG_WRITE_INFO( "About to start translating the recurrence rule." ) |
|
461 |
|
462 CBaseMrRecurrenceRule* recurrenceRule = CBaseMrRecurrenceRule::NewL(); |
|
463 CleanupStack::PushL( recurrenceRule ); |
|
464 |
|
465 //start date. |
|
466 /**@ dupes the infoobject one ?*/ |
|
467 idx = 0; |
|
468 if ( aCalendar.FindProperty( KMsgStorePropertyMrStartDate, idx ) ) |
|
469 { |
|
470 TTime time; |
|
471 aCalendar.PropertyValueTimeL( idx, time ); |
|
472 recurrenceRule->SetRecurrenceStartTimeL( time ); |
|
473 } |
|
474 |
|
475 //end date. |
|
476 idx = 0; |
|
477 if ( aCalendar.FindProperty( KMsgStorePropertyMrRecurEndDate, idx ) ) |
|
478 { |
|
479 TTime time; |
|
480 aCalendar.PropertyValueTimeL( idx, time ); |
|
481 recurrenceRule->SetRecurrenceUntilL( time ); |
|
482 } |
|
483 |
|
484 //frequency. |
|
485 idx = 0; |
|
486 if ( aCalendar.FindProperty( KMsgStorePropertyMrFrequency, idx ) ) |
|
487 { |
|
488 TUint32 imsFreq = aCalendar.PropertyValueUint32L( idx ); |
|
489 recurrenceRule->SetRecurrentInterval( imsFreq ); |
|
490 } |
|
491 |
|
492 //priority. |
|
493 idx = 0; |
|
494 if ( aCalendar.FindProperty( KMsgStorePropertyMrPriority, idx ) ) |
|
495 { |
|
496 TUint32 priority = aCalendar.PropertyValueUint32L( idx ); |
|
497 mmrInfo->SetPriorityL( priority ); |
|
498 } |
|
499 |
|
500 /**@ privacy/sensitivity missing ? */ |
|
501 /*idx = 0; |
|
502 if ( aCalendar.FindProperty( KMsgStorePropertyMrPrivate, idx ) ) |
|
503 { |
|
504 TBool private = aCalendar.PropertyValueBoolL( idx ); |
|
505 }*/ |
|
506 |
|
507 //method. |
|
508 idx = 0; |
|
509 if ( aCalendar.FindProperty( KMsgStorePropertyMrMethod, idx ) ) |
|
510 { |
|
511 TUint32 method = aCalendar.PropertyValueUint32L( idx ); |
|
512 mmrInfo->SetMethod( static_cast<MMRInfoObject::TMRMethod>( method ) ); |
|
513 } |
|
514 |
|
515 //status. |
|
516 idx = 0; |
|
517 if ( aCalendar.FindProperty( KMsgStorePropertyMrStatus, idx ) ) |
|
518 { |
|
519 TUint32 status = aCalendar.PropertyValueUint32L( idx ); |
|
520 mmrInfo->SetMRResponseL( static_cast<MMRInfoObject::TResponse>( status ) ); |
|
521 } |
|
522 |
|
523 //alarm/reminder time. |
|
524 idx = 0; |
|
525 if ( aCalendar.FindProperty( KMsgStorePropertyMrReminder, idx ) ) |
|
526 { |
|
527 TBool hasReminder = aCalendar.PropertyValueBoolL( idx ); |
|
528 if ( hasReminder ) |
|
529 { |
|
530 idx = 0; |
|
531 if ( aCalendar.FindProperty( KMsgStorePropertyMrReminderTime, idx ) ) |
|
532 { |
|
533 if ( Time::NullTTime() != mmrInfo->StartTimeInUtcL() ) |
|
534 { |
|
535 TUint32 offsetMinutes; |
|
536 offsetMinutes = aCalendar.PropertyValueUint32L( idx ); |
|
537 |
|
538 TTime time = mmrInfo->StartTimeInUtcL(); |
|
539 time -= TTimeIntervalMinutes( offsetMinutes ); |
|
540 mmrInfo->SetAlarmInUtcL( time ); |
|
541 } |
|
542 else |
|
543 { |
|
544 __LOG_WRITE_INFO( |
|
545 "Could not find a start date/time so can't set the reminder time." ) |
|
546 } |
|
547 } |
|
548 } |
|
549 } |
|
550 |
|
551 //recurrent count. |
|
552 idx = 0; |
|
553 if ( aCalendar.FindProperty( KMsgStorePropertyMrRecurCount, idx ) ) |
|
554 { |
|
555 TUint32 count = aCalendar.PropertyValueUint32L( idx ); |
|
556 recurrenceRule->SetRecurrentCountL( count ); |
|
557 } |
|
558 |
|
559 //recurrence rule type. |
|
560 idx = 0; |
|
561 MRRecurrenceRule::TMRRecurrenceType recurrenceType |
|
562 = MRRecurrenceRule::EMRRecurrenceInvalid; |
|
563 if ( aCalendar.FindProperty( KMsgStorePropertyMrRecurType, idx ) ) |
|
564 { |
|
565 TUint32 fsType = aCalendar.PropertyValueUint32L( idx ); |
|
566 recurrenceType = static_cast<MRRecurrenceRule::TMRRecurrenceType>( fsType ); |
|
567 recurrenceRule->SetRecurrenceTypeL( recurrenceType ); |
|
568 } |
|
569 |
|
570 //monthly-by-day-of-week. |
|
571 if ( MRRecurrenceRule::EMRRecurrenceMonthly == recurrenceType ) |
|
572 { |
|
573 MRRecurrenceRule::TRecurrentDaysofMonth dayOfMonth; |
|
574 |
|
575 //week number. |
|
576 idx = 0; |
|
577 if ( aCalendar.FindProperty( KMsgStorePropertyMrWeekNo, idx ) ) |
|
578 { |
|
579 TUint32 weekNo = aCalendar.PropertyValueUint32L( idx ); |
|
580 /**@ double check that when testing starts.*/ |
|
581 dayOfMonth.iWeekOfMonth = |
|
582 static_cast<MRRecurrenceRule::TMRRecurrenceWeek>( weekNo ); |
|
583 } |
|
584 |
|
585 //day of week mask. |
|
586 idx = 0 ; |
|
587 if ( aCalendar.FindProperty( KMsgStorePropertyMrDayOfWeekMask, idx ) ) |
|
588 { |
|
589 TUint32 dowMask = aCalendar.PropertyValueUint32L( idx ); |
|
590 |
|
591 TMonthDayTranslator mdt( dayOfMonth.iDayOfWeek ); |
|
592 TranslateMsgStoreDayOfWeek( dowMask, mdt ); |
|
593 } |
|
594 |
|
595 /** IMS, Outlook support a single day, intellisync-specific.*/ |
|
596 RArray<MRRecurrenceRule::TRecurrentDaysofMonth> days; |
|
597 CleanupClosePushL( days ); |
|
598 |
|
599 days.AppendL( dayOfMonth ); |
|
600 recurrenceRule->SetRecurrentDaysofMonthL( days ); |
|
601 |
|
602 CleanupStack::PopAndDestroy( &days ); |
|
603 |
|
604 } |
|
605 //monthly-by-monthday. |
|
606 if ( MRRecurrenceRule::EMRRecurrenceMonthlyByDay == recurrenceType ) |
|
607 { |
|
608 //Day number. |
|
609 idx = 0; |
|
610 RArray<TInt> days; |
|
611 CleanupClosePushL( days ); |
|
612 |
|
613 if ( aCalendar.FindProperty( KMsgStorePropertyMrMonthDay, idx ) ) |
|
614 { |
|
615 TUint32 monthDayNo = aCalendar.PropertyValueUint32L( idx ); |
|
616 days.Append(monthDayNo); |
|
617 /**@ double check that when testing starts.*/ |
|
618 } |
|
619 |
|
620 recurrenceRule->SetRecurrentMonthDaysL( days ); |
|
621 |
|
622 CleanupStack::PopAndDestroy( &days ); |
|
623 |
|
624 } |
|
625 //weekly. |
|
626 else if ( MRRecurrenceRule::EMRRecurrenceWeekly == recurrenceType ) |
|
627 { |
|
628 //day of week mask. |
|
629 idx = 0 ; |
|
630 if ( aCalendar.FindProperty( KMsgStorePropertyMrDayOfWeekMask, idx ) ) |
|
631 { |
|
632 TUint32 dowMask = aCalendar.PropertyValueUint32L( idx ); |
|
633 |
|
634 RArray<MRRecurrenceRule::TMRRecurrentDay> days; |
|
635 CleanupClosePushL( days ); |
|
636 |
|
637 TWeekDayTranslator wdt( days ); |
|
638 TranslateMsgStoreDayOfWeek( dowMask, wdt ); |
|
639 recurrenceRule->SetRecurrentWeekDaysL( days ); |
|
640 |
|
641 CleanupStack::PopAndDestroy( &days ); |
|
642 } |
|
643 } |
|
644 //yearly. |
|
645 else if ( MRRecurrenceRule::EMRRecurrenceYearly == recurrenceType ) |
|
646 { |
|
647 //week number. |
|
648 idx = 0; |
|
649 if ( aCalendar.FindProperty( KMsgStorePropertyMrWeekNo, idx ) ) |
|
650 { |
|
651 /**@ needs redoing after the latest changes to the MMR ifaces |
|
652 by activesync.*/ |
|
653 /*TUint32 weekNo = aCalendar.PropertyValueUint32L( idx ); |
|
654 |
|
655 MRRecurrenceRule::TRecurrentDaysofMonth dayOfMonth;*/ |
|
656 /**@ double check that when testing starts.*/ |
|
657 /*dayOfMonth.iWeekOfMonth = |
|
658 static_cast<MRRecurrenceRule::TMRRecurrenceWeek>( weekNo ); |
|
659 |
|
660 //add to mmr info object. |
|
661 RArray<TInt> days; |
|
662 CleanupClosePushL( days ); |
|
663 |
|
664 days.AppendL( dayOfMonth ); |
|
665 recurrenceRule->SetRecurrentMonthDaysL( days ); |
|
666 |
|
667 CleanupStack::PopAndDestroy( &days );*/ |
|
668 } |
|
669 |
|
670 //day of week mask. |
|
671 idx = 0; |
|
672 if ( aCalendar.FindProperty( KMsgStorePropertyMrDayOfWeekMask, idx ) ) |
|
673 { |
|
674 TUint32 dowMask = aCalendar.PropertyValueUint32L( idx ); |
|
675 |
|
676 RArray<MRRecurrenceRule::TMRRecurrentDay> days; |
|
677 CleanupClosePushL( days ); |
|
678 |
|
679 TWeekDayTranslator wdt( days ); |
|
680 TranslateMsgStoreDayOfWeek( dowMask, wdt ); |
|
681 recurrenceRule->SetRecurrentWeekDaysL( days ); |
|
682 |
|
683 CleanupStack::PopAndDestroy( &days ); |
|
684 } |
|
685 } |
|
686 |
|
687 mmrInfo->SetRecurrenceRuleL( *recurrenceRule ); |
|
688 CleanupStack::Pop( recurrenceRule ); |
|
689 |
|
690 //recurrence id. |
|
691 idx = 0; |
|
692 if ( aCalendar.FindProperty( KMsgStorePropertyMrRRID, idx ) ) |
|
693 { |
|
694 TTime time; |
|
695 aCalendar.PropertyValueTimeL( idx, time ); |
|
696 mmrInfo->SetMRRecurrenceIdL( time ); |
|
697 } |
|
698 |
|
699 //sequence number. |
|
700 idx = 0; |
|
701 if ( aCalendar.FindProperty( KMsgStorePropertyMrSeqNo, idx ) ) |
|
702 { |
|
703 TUint32 seqNo = aCalendar.PropertyValueUint32L( idx ); |
|
704 mmrInfo->SetMRSequenceNumber( static_cast<TInt>( seqNo ) ); |
|
705 } |
|
706 |
|
707 aFsMsg.SetMRInfo( mmrInfo ); |
|
708 CleanupStack::Pop( mmrInfo ); |
|
709 |
|
710 __LOG_EXIT |
|
711 } //TranslateMsgStoreMrL. |
|
712 |
|
713 |
|
714 /** |
|
715 * |
|
716 */ |
|
717 EXPORT_C void CBasePlugin::TranslateEmailFwMessageL( |
|
718 CFSMailMessagePart& aSrc, |
|
719 CMsgStoreMessagePart& aDst, |
|
720 TBool aInInbox ) |
|
721 |
|
722 { |
|
723 __LOG_ENTER( "TranslateEmailFwMessageL" ) |
|
724 |
|
725 //subject. |
|
726 TDesC& value = aSrc.GetSubject(); |
|
727 if ( NULL != &value && KNullDesC() != value ) |
|
728 { |
|
729 aDst.AddOrUpdatePropertyL( KMsgStorePropertySubject, value ); |
|
730 } |
|
731 |
|
732 RMsgStoreAddress msgStoreAddress; |
|
733 CleanupClosePushL( msgStoreAddress ); //+msgStoreAddress |
|
734 |
|
735 //from. |
|
736 CFSMailAddress* address = aSrc.GetSender(); |
|
737 if ( NULL != address ) |
|
738 { |
|
739 CBasePlugin::RemoveAllPropertiesL( aDst, KMsgStorePropertyFrom ); |
|
740 |
|
741 if ( address->GetEmailAddress().Length() ) |
|
742 { |
|
743 msgStoreAddress.iEmailAddress.Create( address->GetEmailAddress() ); |
|
744 } |
|
745 |
|
746 if ( address->GetDisplayName().Length() ) |
|
747 { |
|
748 msgStoreAddress.iDisplayName.Create( address->GetDisplayName() ); |
|
749 } |
|
750 |
|
751 aDst.AddOrUpdatePropertyL( KMsgStorePropertyFrom, msgStoreAddress ); |
|
752 msgStoreAddress.Close(); |
|
753 } |
|
754 |
|
755 CleanupStack::PopAndDestroy( &msgStoreAddress ); //-msgStoreAddress |
|
756 |
|
757 //received or sent, depending on the folder. |
|
758 if ( aInInbox ) |
|
759 { |
|
760 if ( aSrc.GetDate() != 0 ) |
|
761 { |
|
762 aDst.AddOrUpdatePropertyL( KMsgStorePropertyReceivedAt, aSrc.GetDate() ); |
|
763 } |
|
764 } |
|
765 else |
|
766 { |
|
767 //set the sent stamp. |
|
768 TTime sentTime; |
|
769 sentTime.UniversalTime(); |
|
770 aDst.AddOrUpdatePropertyL( KMsgStorePropertySent, sentTime ); |
|
771 aSrc.SetDate( sentTime ); |
|
772 } |
|
773 |
|
774 //to recipients. |
|
775 RPointerArray<CFSMailAddress>& toRecipients = aSrc.GetToRecipients(); |
|
776 TranslateEmailFwRecipientsL( aDst, KMsgStorePropertyTo, toRecipients ); |
|
777 |
|
778 //cc recipients. |
|
779 RPointerArray<CFSMailAddress>& ccRecipients = aSrc.GetCCRecipients(); |
|
780 TranslateEmailFwRecipientsL( aDst, KMsgStorePropertyCc, ccRecipients ); |
|
781 |
|
782 //bcc recipients. |
|
783 RPointerArray<CFSMailAddress>& bccRecipients = aSrc.GetBCCRecipients(); |
|
784 TranslateEmailFwRecipientsL( aDst, KMsgStorePropertyBcc, bccRecipients ); |
|
785 |
|
786 //flags. |
|
787 //the cast is important otherwise the TBool overload gets called. |
|
788 TUint32 flag = static_cast<TUint32>( aSrc.GetFlags() ); |
|
789 aDst.AddOrUpdatePropertyL( |
|
790 KMsgStorePropertyFlags, flag ); |
|
791 |
|
792 //content type. |
|
793 const TPtrC& contentType = aSrc.GetContentType(); |
|
794 if ( 0 < contentType.Length() ) |
|
795 { |
|
796 aDst.AddOrUpdatePropertyL( KMsgStorePropertyContentType, contentType ); |
|
797 } |
|
798 |
|
799 //content id. |
|
800 const TPtrC& contentId = aSrc.ContentID(); |
|
801 if ( 0 < contentId.Length() ) |
|
802 { |
|
803 aDst.AddOrUpdatePropertyL( KMsgStorePropertyContentId, contentId ); |
|
804 } |
|
805 |
|
806 //content description. |
|
807 const TPtrC& contentDescription = aSrc.ContentDescription(); |
|
808 if ( 0 < contentDescription.Length() ) |
|
809 { |
|
810 aDst.AddOrUpdatePropertyL( |
|
811 KMsgStorePropertyContentDescription, contentDescription ); |
|
812 } |
|
813 |
|
814 //content disposition. |
|
815 const TPtrC& contentDisposition = aSrc.ContentDisposition(); |
|
816 if ( 0 < contentDisposition.Length() ) |
|
817 { |
|
818 aDst.AddOrUpdatePropertyL( |
|
819 KMsgStorePropertyContentDisposition, contentDisposition ); |
|
820 } |
|
821 |
|
822 //content class. |
|
823 const TDesC& contentClass = aSrc.GetContentClass(); |
|
824 if ( 0 < contentClass.Length() ) |
|
825 { |
|
826 aDst.AddOrUpdatePropertyL( |
|
827 KMsgStorePropertyContentClass, contentClass ); |
|
828 } |
|
829 |
|
830 //attachment name. |
|
831 const TDesC& attachmentName = aSrc.AttachmentNameL(); |
|
832 if ( 0 < attachmentName.Length() ) |
|
833 { |
|
834 aDst.AddOrUpdatePropertyL( KMsgStorePropertyName, attachmentName ); |
|
835 } |
|
836 |
|
837 //meeting request info. |
|
838 if ( aSrc.IsMRInfoSet() ) |
|
839 { |
|
840 MMRInfoObject& mmrInfo = aSrc.GetMRInfo(); //no ownership transfer. |
|
841 TranslateEmailFwMrL( mmrInfo, aDst ); |
|
842 } |
|
843 else |
|
844 { |
|
845 //in the case of a MR origination the MRInfo object is not used thus is never set but still |
|
846 //the calendar property container is present and necessary. |
|
847 TUint index = 0; |
|
848 if ( !( flag & EFSMsgFlag_CalendarMsg ) |
|
849 && aDst.FindProperty( KMsgStorePropertyMeetingRequest, index ) ) |
|
850 { |
|
851 aDst.RemovePropertyL( index ); |
|
852 } |
|
853 } |
|
854 |
|
855 //read-only size |
|
856 if (aSrc.ReadOnlyPartSize() > 0) |
|
857 { |
|
858 aDst.AddOrUpdatePropertyL(KMsgStorePropertyReadOnlySize, (TUint32)aSrc.ReadOnlyPartSize()); |
|
859 } |
|
860 |
|
861 __LOG_EXIT |
|
862 } //TranslateEmailFwMessageL. |
|
863 |
|
864 |
|
865 /** |
|
866 * |
|
867 */ |
|
868 EXPORT_C void CBasePlugin::TranslateEmailFwMrL( |
|
869 MMRInfoObject& aSrc, |
|
870 CMsgStorePropertyContainer& aDst ) |
|
871 |
|
872 { |
|
873 __LOG_ENTER( "TranslateEmailFwMrL" ) |
|
874 |
|
875 TUint index; |
|
876 CMsgStorePropertyContainer* calendar = aDst.FindProperty( |
|
877 KMsgStorePropertyMeetingRequest, index ) ? |
|
878 aDst.PropertyValueContainerL( index ) |
|
879 : CMsgStorePropertyContainer::NewL(); |
|
880 CleanupStack::PushL( calendar ); |
|
881 |
|
882 //response code. |
|
883 calendar->AddOrUpdatePropertyL( |
|
884 KMsgStorePropertyMrMethod, static_cast<TUint32>( aSrc.MRMethodL() ) ); |
|
885 |
|
886 calendar->AddOrUpdatePropertyL( |
|
887 KMsgStorePropertyMrStatus, static_cast<TUint32>( aSrc.MRResponse() ) ); |
|
888 |
|
889 //uid. |
|
890 const TDesC& uid = aSrc.UidL(); |
|
891 if ( uid != KNullDesC ) |
|
892 { |
|
893 HBufC8* uid8 = HBufC8::NewLC( uid.Length() ); |
|
894 //uid not utf8-encoded. |
|
895 uid8->Des().Copy( uid ); |
|
896 calendar->AddOrUpdatePropertyL( KMsgStorePropertyMrGuid, *uid8 ); |
|
897 CleanupStack::PopAndDestroy( uid8 ); |
|
898 } |
|
899 |
|
900 //description. |
|
901 const TDesC& description = aSrc.DescriptionL(); |
|
902 if ( description != KNullDesC ) |
|
903 { |
|
904 /**@ set the body of the plain text part instead ?*/ |
|
905 calendar->AddOrUpdatePropertyL( KMsgStorePropertyMrCalBody, description ); |
|
906 } |
|
907 |
|
908 //creation date. |
|
909 TTime time = aSrc.CreationTimeInUtcL(); |
|
910 if ( Time::NullTTime() != time ) |
|
911 { |
|
912 calendar->AddOrUpdatePropertyL( KMsgStorePropertyMrCreationDate, time ); |
|
913 } |
|
914 |
|
915 //start date. |
|
916 time = aSrc.StartTimeInUtcL(); |
|
917 if ( Time::NullTTime() != time ) |
|
918 { |
|
919 calendar->AddOrUpdatePropertyL( KMsgStorePropertyMrStartDate, time ); |
|
920 } |
|
921 |
|
922 //end date. |
|
923 time = aSrc.EndTimeInUtcL(); |
|
924 if ( Time::NullTTime() != time ) |
|
925 { |
|
926 calendar->AddOrUpdatePropertyL( KMsgStorePropertyMrEndDate, time ); |
|
927 } |
|
928 |
|
929 //alarm/reminder time. |
|
930 time = aSrc.AlarmInUtcL(); |
|
931 if ( Time::NullTTime() != time ) |
|
932 { |
|
933 if ( Time::NullTTime() != aSrc.StartTimeInUtcL() ) |
|
934 { |
|
935 TTimeIntervalMinutes offsetMinutes; |
|
936 TInt error = aSrc.StartTimeInUtcL().MinutesFrom( time, offsetMinutes ); |
|
937 |
|
938 if ( KErrNone != error ) |
|
939 { |
|
940 calendar->AddOrUpdatePropertyL( KMsgStorePropertyMrReminderTime, |
|
941 static_cast<TUint32>( offsetMinutes.Int() ) ); |
|
942 calendar->AddOrUpdatePropertyL( KMsgStorePropertyMrReminder, ETrue ); |
|
943 } |
|
944 else |
|
945 { |
|
946 __LOG_WRITE_FORMAT1_INFO( |
|
947 "Failed to compute the reminder time, error %d.", error ) |
|
948 } |
|
949 } |
|
950 } |
|
951 |
|
952 //location. |
|
953 const TDesC& location = aSrc.LocationL(); |
|
954 if ( location != KNullDesC ) |
|
955 { |
|
956 calendar->AddOrUpdatePropertyL( KMsgStorePropertyMrLocation, location ); |
|
957 } |
|
958 |
|
959 const TDesC& summary = aSrc.SubjectL(); |
|
960 if ( summary != KNullDesC ) |
|
961 { |
|
962 calendar->AddOrUpdatePropertyL( KMsgStorePropertyMrSubject, summary ); |
|
963 } |
|
964 |
|
965 //organizer / from. |
|
966 RMsgStoreAddress msgStoreAddress; |
|
967 CleanupClosePushL( msgStoreAddress ); |
|
968 |
|
969 /*TranslateEmailFwAttendeeL( aSrc.MROrganizerL(), msgStoreAddress ); |
|
970 aDst.AddOrUpdatePropertyL( KMsgStorePropertyFrom, msgStoreAddress );*/ |
|
971 |
|
972 //attendees / to. |
|
973 /*RPointerArray<MMRAttendee>& attendees = aSrc.AttendeesL(); |
|
974 TInt count = attendees.Count(); |
|
975 |
|
976 for ( TInt i = 0; i < count; i++ ) |
|
977 { |
|
978 msgStoreAddress.Close(); |
|
979 |
|
980 TranslateEmailFwAttendeeL( *(attendees[i]), msgStoreAddress ); |
|
981 aDst.AddPropertyL( KMsgStorePropertyTo, msgStoreAddress ); |
|
982 }*/ |
|
983 |
|
984 CleanupStack::PopAndDestroy( &msgStoreAddress ); |
|
985 |
|
986 //recurrence info. |
|
987 __LOG_WRITE_INFO( "Translating MMR info object recurrence rule to MsgStore." ) |
|
988 const MRRecurrenceRule& rRule = aSrc.RecurrenceRuleL(); |
|
989 |
|
990 //start date. |
|
991 time = rRule.RecurrenceStartTime(); |
|
992 if ( Time::NullTTime() != time ) |
|
993 { |
|
994 calendar->AddOrUpdatePropertyL( KMsgStorePropertyMrStartDate, time ); |
|
995 } |
|
996 |
|
997 //end date. |
|
998 time = rRule.RecurrentUntil(); |
|
999 if ( Time::NullTTime() != time ) |
|
1000 { |
|
1001 calendar->AddOrUpdatePropertyL( KMsgStorePropertyMrRecurEndDate, time ); |
|
1002 } |
|
1003 |
|
1004 //frequency. |
|
1005 TInt frequency = rRule.RecurrentInterval(); |
|
1006 if ( 0 != frequency ) |
|
1007 { |
|
1008 calendar->AddOrUpdatePropertyL( |
|
1009 KMsgStorePropertyMrFrequency, static_cast<TUint32>( rRule.RecurrentInterval() ) ); |
|
1010 } |
|
1011 else |
|
1012 { |
|
1013 TUint index = 0; |
|
1014 if ( calendar->FindProperty( KMsgStorePropertyMrFrequency, index ) ) |
|
1015 { |
|
1016 calendar->RemovePropertyL( index ); |
|
1017 } |
|
1018 } |
|
1019 |
|
1020 //priority. |
|
1021 calendar->AddOrUpdatePropertyL( |
|
1022 KMsgStorePropertyMrPriority, static_cast<TUint32>( aSrc.PriorityL() ) ); |
|
1023 |
|
1024 /**@ privacy/sensitivity missing ? */ |
|
1025 /*idx = 0; |
|
1026 if ( aCalendar.FindProperty( KMsgStorePropertyMrPrivate, idx ) ) |
|
1027 { |
|
1028 TBool private = aCalendar.PropertyValueBoolL( idx ); |
|
1029 }*/ |
|
1030 |
|
1031 //recurrent count. |
|
1032 calendar->AddOrUpdatePropertyL( |
|
1033 KMsgStorePropertyMrRecurCount, static_cast<TUint32>( rRule.RecurrentCount() ) ); |
|
1034 |
|
1035 //recurrence rule type. |
|
1036 MRRecurrenceRule::TMRRecurrenceType rType = rRule.Type(); |
|
1037 calendar->AddOrUpdatePropertyL( |
|
1038 KMsgStorePropertyMrRecurType, static_cast<TUint32>( rType ) ); |
|
1039 |
|
1040 //monthly-by-day-of-week. |
|
1041 if ( MRRecurrenceRule::EMRRecurrenceMonthly == rType ) |
|
1042 { |
|
1043 /**@ needs redoing after the latest MMR iface changes by activesync.*/ |
|
1044 /*const RArray<TInt>& monthDays = rRule.RecurrentMonthDays(); |
|
1045 if ( monthDays.Count() ) |
|
1046 { |
|
1047 //week number. |
|
1048 calendar->AddOrUpdatePropertyL( |
|
1049 KMsgStorePropertyMrWeekNo, static_cast<TUint32>( monthDays[0].iWeekOfMonth ) ); |
|
1050 |
|
1051 //day of week mask. |
|
1052 TUint32 dowMask = 0; |
|
1053 TranslateEmailFwDayOfWeek( monthDays[0].iDayOfWeek, dowMask ); |
|
1054 calendar->AddOrUpdatePropertyL( |
|
1055 KMsgStorePropertyMrDayOfWeekMask, static_cast<TUint32>( dowMask ) ); |
|
1056 }*/ |
|
1057 } |
|
1058 //weekly. |
|
1059 else if ( MRRecurrenceRule::EMRRecurrenceWeekly == rType ) |
|
1060 { |
|
1061 const RArray<MRRecurrenceRule::TMRRecurrentDay>& days = rRule.RecurrentWeekDays(); |
|
1062 |
|
1063 //day of week mask. |
|
1064 if ( days.Count() ) |
|
1065 { |
|
1066 TUint32 dowMask = 0; |
|
1067 |
|
1068 for ( TInt i = 0; i < days.Count(); i++ ) |
|
1069 { |
|
1070 TranslateEmailFwDayOfWeek( days[i], dowMask ); |
|
1071 } |
|
1072 |
|
1073 calendar->AddOrUpdatePropertyL( |
|
1074 KMsgStorePropertyMrDayOfWeekMask, static_cast<TUint32>( dowMask ) ); |
|
1075 } |
|
1076 } |
|
1077 //yearly. |
|
1078 else if ( MRRecurrenceRule::EMRRecurrenceYearly == rType ) |
|
1079 { |
|
1080 /**@ needs redoing after the latest MMR iface changes by activesync.*/ |
|
1081 /*const RArray<MRRecurrenceRule::TRecurrentDaysofMonth>& monthDays = rRule.RecurrentMonthDays(); |
|
1082 if ( monthDays.Count() ) |
|
1083 { |
|
1084 //week number. |
|
1085 calendar->AddOrUpdatePropertyL( |
|
1086 KMsgStorePropertyMrWeekNo, static_cast<TUint32>( monthDays[0].iWeekOfMonth ) ); |
|
1087 |
|
1088 //day of week mask. |
|
1089 TUint32 dowMask = 0; |
|
1090 TranslateEmailFwDayOfWeek( monthDays[0].iDayOfWeek, dowMask ); |
|
1091 calendar->AddOrUpdatePropertyL( |
|
1092 KMsgStorePropertyMrDayOfWeekMask, static_cast<TUint32>( dowMask ) ); |
|
1093 }*/ |
|
1094 } |
|
1095 |
|
1096 //recurrence id. |
|
1097 calendar->AddOrUpdatePropertyL( KMsgStorePropertyMrRRID, aSrc.MRRecurrenceId() ); |
|
1098 |
|
1099 //sequence number. |
|
1100 calendar->AddOrUpdatePropertyL( KMsgStorePropertyMrSeqNo, static_cast<TUint32>( aSrc.MRSequenceNumberL() ) ); |
|
1101 |
|
1102 aDst.AddOrUpdatePropertyL( KMsgStorePropertyMeetingRequest, *calendar ); |
|
1103 CleanupStack::PopAndDestroy( calendar ); |
|
1104 __LOG_EXIT |
|
1105 } //TranslateEmailFwMrL. |
|
1106 |
|
1107 |
|
1108 /** |
|
1109 * Day of week translator from the MsgStore to the FS format. The actual translation |
|
1110 * step is supplied via the day of week ftor. See CDayOfWeekFtor for further |
|
1111 * information. Although not strictly necessary this avoids duplicating all the if's |
|
1112 * when dealing with rule translation. |
|
1113 * |
|
1114 * @param aDayOfWeekMask day of week mask in the MsgStore format, see |
|
1115 * MsgStorePropertyKeys.h for information. |
|
1116 * @param aFtor translation ftor. |
|
1117 */ |
|
1118 void CBasePlugin::TranslateMsgStoreDayOfWeek( |
|
1119 TUint32 aDayOfWeekMask, |
|
1120 TDayOfWeekFtor& aFtor ) |
|
1121 |
|
1122 { |
|
1123 if ( KMsgStoreDaySunday & aDayOfWeekMask ) |
|
1124 { |
|
1125 aFtor( MRRecurrenceRule::EMRRecurrenceSunday ); |
|
1126 } |
|
1127 if ( KMsgStoreDayMonday & aDayOfWeekMask ) |
|
1128 { |
|
1129 aFtor( MRRecurrenceRule::EMRRecurrenceMonday ); |
|
1130 } |
|
1131 if ( KMsgStoreDayTuesday & aDayOfWeekMask ) |
|
1132 { |
|
1133 aFtor( MRRecurrenceRule::EMRRecurrenceTuesday ); |
|
1134 } |
|
1135 if ( KMsgStoreDayWednesday & aDayOfWeekMask ) |
|
1136 { |
|
1137 aFtor( MRRecurrenceRule::EMRRecurrenceWednesday ); |
|
1138 } |
|
1139 if ( KMsgStoreDayThursday & aDayOfWeekMask ) |
|
1140 { |
|
1141 aFtor( MRRecurrenceRule::EMRRecurrenceThursday ); |
|
1142 } |
|
1143 if ( KMsgStoreDayFriday & aDayOfWeekMask ) |
|
1144 { |
|
1145 aFtor( MRRecurrenceRule::EMRRecurrenceFriday ); |
|
1146 } |
|
1147 if ( KMsgStoreDaySaturday & aDayOfWeekMask ) |
|
1148 { |
|
1149 aFtor( MRRecurrenceRule::EMRRecurrenceSaturday ); |
|
1150 } |
|
1151 } |
|
1152 |
|
1153 |
|
1154 /** |
|
1155 * |
|
1156 */ |
|
1157 void CBasePlugin::TranslateEmailFwDayOfWeek( |
|
1158 MRRecurrenceRule::TMRRecurrentDay aSrc, |
|
1159 TUint32& aDst ) |
|
1160 |
|
1161 { |
|
1162 if ( MRRecurrenceRule::EMRRecurrenceSunday == aSrc ) |
|
1163 { |
|
1164 aDst |= KMsgStoreDaySunday; |
|
1165 } |
|
1166 if ( MRRecurrenceRule::EMRRecurrenceMonday == aSrc ) |
|
1167 { |
|
1168 aDst |= KMsgStoreDayMonday; |
|
1169 } |
|
1170 if ( MRRecurrenceRule::EMRRecurrenceTuesday == aSrc ) |
|
1171 { |
|
1172 aDst |= KMsgStoreDayTuesday; |
|
1173 } |
|
1174 if ( MRRecurrenceRule::EMRRecurrenceWednesday == aSrc ) |
|
1175 { |
|
1176 aDst |= KMsgStoreDayWednesday; |
|
1177 } |
|
1178 if ( MRRecurrenceRule::EMRRecurrenceThursday == aSrc ) |
|
1179 { |
|
1180 aDst |= KMsgStoreDayThursday; |
|
1181 } |
|
1182 if ( MRRecurrenceRule::EMRRecurrenceFriday == aSrc ) |
|
1183 { |
|
1184 aDst |= KMsgStoreDayFriday; |
|
1185 } |
|
1186 if ( MRRecurrenceRule::EMRRecurrenceSaturday == aSrc ) |
|
1187 { |
|
1188 aDst |= KMsgStoreDaySaturday; |
|
1189 } |
|
1190 } |
|
1191 |
|
1192 |
|
1193 /** |
|
1194 * |
|
1195 */ |
|
1196 /*static*/ void TranslateMsgStoreAttendeeL( |
|
1197 CMsgStorePropertyContainer& aSrc, |
|
1198 TUint aIdx, |
|
1199 MMROrganizer& aAttendee ) |
|
1200 |
|
1201 { |
|
1202 RMsgStoreAddress address; |
|
1203 CleanupClosePushL( address ); |
|
1204 |
|
1205 aSrc.PropertyValueAddressL( aIdx, address ); |
|
1206 |
|
1207 if ( address.iEmailAddress.Length() ) |
|
1208 { |
|
1209 aAttendee.SetAddressL( address.iEmailAddress ); |
|
1210 } |
|
1211 |
|
1212 if ( address.iDisplayName.Length() ) |
|
1213 { |
|
1214 aAttendee.SetCommonNameL( address.iDisplayName ); |
|
1215 } |
|
1216 |
|
1217 CleanupStack::PopAndDestroy( &address ); |
|
1218 } |
|
1219 |
|
1220 |
|
1221 /** |
|
1222 * |
|
1223 */ |
|
1224 EXPORT_C void CBasePlugin::TranslateEmailFwAttendeeL( |
|
1225 MMROrganizer& aSrc, |
|
1226 RMsgStoreAddress& aDst ) |
|
1227 |
|
1228 { |
|
1229 const TDesC& address = aSrc.Address(); |
|
1230 if ( address != KNullDesC ) |
|
1231 { |
|
1232 aDst.iEmailAddress.Create( address ); |
|
1233 } |
|
1234 |
|
1235 const TDesC& commonName = aSrc.CommonName(); |
|
1236 if ( commonName != KNullDesC ) |
|
1237 { |
|
1238 aDst.iDisplayName.Create( commonName ); |
|
1239 } |
|
1240 } |
|
1241 |
|
1242 |
|
1243 /** |
|
1244 * |
|
1245 */ |
|
1246 EXPORT_C inline void CBasePlugin::RemoveAllPropertiesL( |
|
1247 CMsgStorePropertyContainer& aContainer, |
|
1248 const TDesC8& aName ) |
|
1249 |
|
1250 { |
|
1251 TUint index = 0; |
|
1252 while ( aContainer.FindProperty( aName, index ) ) |
|
1253 { |
|
1254 aContainer.RemovePropertyL( index ); |
|
1255 } |
|
1256 } |
|
1257 |
|
1258 |
|
1259 /** |
|
1260 * |
|
1261 */ |
|
1262 void CBasePlugin::TranslateEmailFwRecipientsL( |
|
1263 CMsgStoreMessagePart& aDst, |
|
1264 const TDesC8& aDstProperty, |
|
1265 RPointerArray<CFSMailAddress>& aRecipients ) |
|
1266 |
|
1267 { |
|
1268 CBasePlugin::RemoveAllPropertiesL( aDst, aDstProperty ); |
|
1269 |
|
1270 TInt count = aRecipients.Count(); |
|
1271 if ( 0 < count ) |
|
1272 { |
|
1273 RMsgStoreAddress msgStoreAddress; |
|
1274 CleanupClosePushL( msgStoreAddress ); |
|
1275 |
|
1276 for ( TUint i = 0; i < count; i++ ) |
|
1277 { |
|
1278 if ( aRecipients[i]->GetEmailAddress().Length() ) |
|
1279 { |
|
1280 msgStoreAddress.iEmailAddress.Create( aRecipients[i]->GetEmailAddress() ); |
|
1281 } |
|
1282 if ( aRecipients[i]->GetDisplayName().Length() ) |
|
1283 { |
|
1284 msgStoreAddress.iDisplayName.Create( aRecipients[i]->GetDisplayName() ); |
|
1285 } |
|
1286 |
|
1287 aDst.AddPropertyL( aDstProperty, msgStoreAddress ); |
|
1288 msgStoreAddress.Close(); |
|
1289 } |
|
1290 |
|
1291 CleanupStack::PopAndDestroy( &msgStoreAddress ); |
|
1292 } |
|
1293 } |
|
1294 |
|
1295 |
|
1296 /** |
|
1297 * |
|
1298 */ |
|
1299 /*static*/ void TranslateMsgStoreAttendeesL( |
|
1300 CMsgStorePropertyContainer& aMessage, |
|
1301 CBaseMrInfoObject& aMrInfo, |
|
1302 const TDesC8& aProperty, |
|
1303 MMRAttendee::TAttendeeRole aRole ) |
|
1304 { |
|
1305 |
|
1306 TUint idx = 0; |
|
1307 while ( aMessage.FindProperty( aProperty, idx, idx ) ) |
|
1308 { |
|
1309 MMRAttendee* attendee = CBaseMrAttendee::NewL(); |
|
1310 CleanupStack::PushL( attendee ); |
|
1311 |
|
1312 TranslateMsgStoreAttendeeL( aMessage, idx, *attendee ); |
|
1313 attendee->SetAttendeeRoleL( aRole ); |
|
1314 |
|
1315 aMrInfo.AddAttendeeL( attendee ); |
|
1316 CleanupStack::Pop( attendee ); |
|
1317 |
|
1318 ++idx; |
|
1319 } |
|
1320 } |
|
1321 |
|
1322 |
|
1323 /* ANN0001 |
|
1324 An intentional formatted text line break MUST only be included in a |
|
1325 "TEXT" property value by representing the line break with the |
|
1326 character sequence of BACKSLASH (US-ASCII decimal 92), followed by a |
|
1327 LATIN SMALL LETTER N (US-ASCII decimal 110) or a LATIN CAPITAL LETTER |
|
1328 N (US-ASCII decimal 78), that is "\n" or "\N". |
|
1329 |
|
1330 http://www.kanzaki.com/docs/ical/text.html |
|
1331 */ |