25
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2009 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: Static helper methods
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "esmrhelper.h"
|
|
21 |
#include "esmrentryhelper.h"
|
|
22 |
#include "esmrconfig.hrh"
|
|
23 |
#include <f32file.h>
|
|
24 |
#include <caluser.h>
|
|
25 |
#include <miuthdr.h>
|
|
26 |
#include <msvapi.h>
|
|
27 |
#include <msvuids.h>
|
|
28 |
#include <miutpars.h>
|
|
29 |
#include <bautils.h>
|
|
30 |
#include <coemain.h>
|
|
31 |
#include <msvids.h>
|
|
32 |
#include <SendUiConsts.h>
|
|
33 |
#include <CalenInterimUtils2.h>
|
|
34 |
#include <calalarm.h>
|
|
35 |
#include <calrrule.h>
|
|
36 |
#include <calattachment.h>
|
|
37 |
#include <centralrepository.h>
|
|
38 |
#include <cmrmailboxutils.h>
|
|
39 |
#include <ct/rcpointerarray.h>
|
|
40 |
#include <utf.h>
|
|
41 |
#include <aknlists.h>
|
|
42 |
#include <aknPopup.h>
|
|
43 |
#include <CalendarInternalCRKeys.h>
|
|
44 |
#include <data_caging_path_literals.hrh>
|
|
45 |
//<cmail> hardcoded paths removal
|
|
46 |
#include <pathinfo.h>
|
|
47 |
//</cmail>
|
|
48 |
|
|
49 |
#include "emailtrace.h"
|
|
50 |
|
|
51 |
// CONSTANTS
|
|
52 |
|
|
53 |
/// Unnamed namespace for local definitions
|
|
54 |
namespace { // codescanner::namespace
|
|
55 |
|
|
56 |
_LIT( KMailtoMatchPattern, "mailto:*" ); // these are never localized
|
|
57 |
const TInt KMailtoLength = 7; // "mailto:" length
|
|
58 |
|
|
59 |
// Resource file format
|
|
60 |
_LIT( KResourceFileLocFormat1, "r%02d");
|
|
61 |
_LIT( KResourceFileLocFormat2, "r%d");
|
|
62 |
|
|
63 |
const TInt KMinTwoDigitLanguageCode = 10;
|
|
64 |
|
|
65 |
_LIT (KResourceFormat, "rsc" );
|
|
66 |
|
|
67 |
// Definition for max hours, minutes, seconds in day for Memo
|
|
68 |
const TInt KMaxHoursForMemo( 23 );
|
|
69 |
const TInt KMaxMinutesForMemo( 59 );
|
|
70 |
const TInt KMaxSecondsForMemo( 59 );
|
|
71 |
|
|
72 |
// Definition for max hours, minutes, seconds in day for To-Do
|
|
73 |
const TInt KMaxHoursForTodo( 23 );
|
|
74 |
const TInt KMaxMinutesForTodo( 59 );
|
|
75 |
const TInt KMaxSecondsForTodo( 00 );
|
|
76 |
|
|
77 |
const TInt KDefaultAnniversaryAlarmHours( 12 );
|
|
78 |
|
|
79 |
const TInt KDefaultTodoAlarmHours( 12 );
|
|
80 |
|
|
81 |
// Definition for default alarm time for meeting
|
|
82 |
const TInt KDefaultMeetingAlarmMinutes( 15 );
|
|
83 |
|
|
84 |
// Constant for default meeeting start hour
|
|
85 |
const TInt KDefaultMeetingStartHour( 8 );
|
|
86 |
|
|
87 |
// Constant for default meeeting end hour
|
|
88 |
const TInt KDefaultMeetingEndHour( 9 );
|
|
89 |
|
|
90 |
|
|
91 |
#ifdef _DEBUG
|
|
92 |
|
|
93 |
enum TPanicCode
|
|
94 |
{
|
|
95 |
EPanicNullMsvId = 1,
|
|
96 |
EIllegalMsvEntryType,
|
|
97 |
EPanicNoOrganizer,
|
|
98 |
EInvalidEntryType,
|
|
99 |
EInvalidSwitchType
|
|
100 |
};
|
|
101 |
|
|
102 |
// Panic message definition
|
|
103 |
_LIT( KPanicMsg, "ESMRHelper" );
|
|
104 |
|
|
105 |
void Panic( TPanicCode aReason )
|
|
106 |
{
|
|
107 |
User::Panic( KPanicMsg, aReason );
|
|
108 |
}
|
|
109 |
|
|
110 |
#endif // _DEBUG
|
|
111 |
|
|
112 |
CCalEntry::TType MapType( TESMRCalendarEventType aEntryType )
|
|
113 |
{
|
|
114 |
CCalEntry::TType type( CCalEntry::EAppt );
|
|
115 |
|
|
116 |
switch ( aEntryType )
|
|
117 |
{
|
|
118 |
case EESMREventTypeAppt:
|
|
119 |
case EESMREventTypeMeetingRequest:
|
|
120 |
{
|
|
121 |
type = CCalEntry::EAppt;
|
|
122 |
break;
|
|
123 |
}
|
|
124 |
case EESMREventTypeETodo:
|
|
125 |
{
|
|
126 |
type = CCalEntry::ETodo;
|
|
127 |
break;
|
|
128 |
}
|
|
129 |
case EESMREventTypeEEvent:
|
|
130 |
{
|
|
131 |
type = CCalEntry::EEvent;
|
|
132 |
break;
|
|
133 |
}
|
|
134 |
case EESMREventTypeEReminder:
|
|
135 |
{
|
|
136 |
type = CCalEntry::EReminder;
|
|
137 |
break;
|
|
138 |
}
|
|
139 |
case EESMREventTypeEAnniv:
|
|
140 |
{
|
|
141 |
type = CCalEntry::EAnniv;
|
|
142 |
break;
|
|
143 |
}
|
|
144 |
default:
|
|
145 |
{
|
|
146 |
__ASSERT_DEBUG( EFalse, Panic( EInvalidEntryType ) );
|
|
147 |
}
|
|
148 |
}
|
|
149 |
|
|
150 |
return type;
|
|
151 |
}
|
|
152 |
|
|
153 |
/**
|
|
154 |
* Fetches the supported mailboxes.
|
|
155 |
* @param aMBUtils utils class
|
|
156 |
* @param aMailBoxes to test
|
|
157 |
*/
|
|
158 |
void SupportedMailboxesL(
|
|
159 |
CMRMailboxUtils& aMBUtils,
|
|
160 |
RArray<CMRMailboxUtils::TMailboxInfo>& aMailBoxes )
|
|
161 |
{
|
|
162 |
FUNC_LOG;
|
|
163 |
aMBUtils.ListMailBoxesL( aMailBoxes );
|
|
164 |
|
|
165 |
RCPointerArray<CImplementationInformation> implArray;
|
|
166 |
CleanupClosePushL( implArray );
|
|
167 |
|
|
168 |
//Get all MRViewers Implementation
|
|
169 |
const TUid mrViewersIface = TUid::Uid(KMRViewersInterfaceUID);
|
|
170 |
REComSession::ListImplementationsL(mrViewersIface, implArray );
|
|
171 |
TInt mrviewerCount( implArray.Count() );
|
|
172 |
|
|
173 |
TInt index(0);
|
|
174 |
TInt mailboxCount( aMailBoxes.Count() );
|
|
175 |
while ( index < mailboxCount )
|
|
176 |
{
|
|
177 |
TBool supported( EFalse );
|
|
178 |
|
|
179 |
for ( TInt i(0); (i < mrviewerCount) && !supported; ++ i )
|
|
180 |
{
|
|
181 |
TBuf16<KMaxUidName> mbName;
|
|
182 |
CnvUtfConverter::ConvertToUnicodeFromUtf8(
|
|
183 |
mbName,
|
|
184 |
implArray[i]->DataType() );
|
|
185 |
|
|
186 |
if( aMailBoxes[index].iMtmUid.Name().CompareF(mbName) == 0)
|
|
187 |
{
|
|
188 |
supported = ETrue;
|
|
189 |
}
|
|
190 |
}
|
|
191 |
|
|
192 |
if ( supported )
|
|
193 |
{
|
|
194 |
index++;
|
|
195 |
}
|
|
196 |
else
|
|
197 |
{
|
|
198 |
aMailBoxes.Remove( index );
|
|
199 |
mailboxCount = aMailBoxes.Count();
|
|
200 |
}
|
|
201 |
}
|
|
202 |
CleanupStack::PopAndDestroy( &implArray );
|
|
203 |
}
|
|
204 |
|
|
205 |
/**
|
|
206 |
* Prompts user to select default mailbox.
|
|
207 |
* @param aMailBoxes Reference to mailbox list
|
|
208 |
*/
|
|
209 |
TInt PromptForDefaultMailboxL(
|
|
210 |
RArray<CMRMailboxUtils::TMailboxInfo>& aMailBoxes )
|
|
211 |
{
|
|
212 |
FUNC_LOG;
|
|
213 |
TInt selected( KErrCancel );
|
|
214 |
|
|
215 |
TInt mbCount = aMailBoxes.Count();
|
|
216 |
if( mbCount > 0)
|
|
217 |
{
|
|
218 |
CAknSinglePopupMenuStyleListBox* list =
|
|
219 |
new (ELeave) CAknSinglePopupMenuStyleListBox;
|
|
220 |
CleanupStack::PushL(list);
|
|
221 |
|
|
222 |
CAknPopupList* popupList = CAknPopupList::NewL(
|
|
223 |
list,
|
|
224 |
R_AVKON_SOFTKEYS_OK_CANCEL);
|
|
225 |
CleanupStack::PushL(popupList);
|
|
226 |
|
|
227 |
list->ConstructL(popupList, CEikListBox::ELeftDownInViewRect);
|
|
228 |
list->CreateScrollBarFrameL(ETrue);
|
|
229 |
list->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
230 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
|
|
231 |
|
|
232 |
CEikonEnv* eikEnv = CEikonEnv::Static();// codescanner::eikonenvstatic
|
|
233 |
|
|
234 |
CDesCArrayFlat* items = new (ELeave)CDesCArrayFlat(mbCount);
|
|
235 |
CleanupStack::PushL(items);
|
|
236 |
for(TInt i=0; i<mbCount; ++i)
|
|
237 |
{
|
|
238 |
items->AppendL( aMailBoxes[i].iName );
|
|
239 |
}
|
|
240 |
CleanupStack::Pop(items);
|
|
241 |
CTextListBoxModel* model = list->Model();
|
|
242 |
|
|
243 |
//Pass ownersip of items to model
|
|
244 |
model->SetItemTextArray(items);
|
|
245 |
|
|
246 |
HBufC* title = KNullDesC().AllocLC();
|
|
247 |
popupList->SetTitleL(*title);
|
|
248 |
CleanupStack::PopAndDestroy(title);
|
|
249 |
|
|
250 |
TBool accepted = popupList->ExecuteLD();
|
|
251 |
CleanupStack::Pop( popupList );
|
|
252 |
|
|
253 |
if(accepted)
|
|
254 |
{
|
|
255 |
selected = list->CurrentItemIndex();
|
|
256 |
}
|
|
257 |
else
|
|
258 |
{
|
|
259 |
selected = KErrCancel;
|
|
260 |
}
|
|
261 |
|
|
262 |
CleanupStack::PopAndDestroy( list );
|
|
263 |
}
|
|
264 |
else
|
|
265 |
{
|
|
266 |
//No mailboxes defined. Could prompt user to define one here.
|
|
267 |
selected = KErrCancel;
|
|
268 |
}
|
|
269 |
|
|
270 |
return selected;
|
|
271 |
}
|
|
272 |
|
|
273 |
/**
|
|
274 |
* Converts to-do specific priority to normal priority
|
|
275 |
* @param Calendar entry, which priority is converted
|
|
276 |
*/
|
|
277 |
void ConvertTodoPriorityToNormalL( CCalEntry& entry )
|
|
278 |
{
|
|
279 |
FUNC_LOG;
|
|
280 |
TInt priority( 0 );
|
|
281 |
if( entry.PriorityL() == EFSCalenTodoPriorityHigh )
|
|
282 |
{
|
|
283 |
priority = EFSCalenMRPriorityHigh;
|
|
284 |
}
|
|
285 |
|
|
286 |
else if( entry.PriorityL() == EFSCalenTodoPriorityNormal )
|
|
287 |
{
|
|
288 |
priority = EFSCalenMRPriorityNormal;
|
|
289 |
}
|
|
290 |
|
|
291 |
else if( entry.PriorityL() == EFSCalenTodoPriorityLow )
|
|
292 |
{
|
|
293 |
priority = EFSCalenMRPriorityLow;
|
|
294 |
}
|
|
295 |
|
|
296 |
else
|
|
297 |
{
|
|
298 |
// Priority unknown, let's set it to normal then
|
|
299 |
priority = EFSCalenMRPriorityNormal;
|
|
300 |
}
|
|
301 |
|
|
302 |
entry.SetPriorityL( priority );
|
|
303 |
}
|
|
304 |
|
|
305 |
} // namespace
|
|
306 |
|
|
307 |
// ======== MEMBER FUNCTIONS ========
|
|
308 |
|
|
309 |
// ----------------------------------------------------------------------------
|
|
310 |
// ESMRHelper::CopyAttendeeL
|
|
311 |
// ----------------------------------------------------------------------------
|
|
312 |
//
|
|
313 |
EXPORT_C CCalAttendee* ESMRHelper::CopyAttendeeL( CCalAttendee& aSource )
|
|
314 |
{
|
|
315 |
FUNC_LOG;
|
|
316 |
CCalAttendee* copy = CopyAttendeeLC( aSource );
|
|
317 |
CleanupStack::Pop( copy );
|
|
318 |
return copy;
|
|
319 |
}
|
|
320 |
|
|
321 |
// ----------------------------------------------------------------------------
|
|
322 |
// ESMRHelper::CopyAttendeeLC
|
|
323 |
// ----------------------------------------------------------------------------
|
|
324 |
//
|
|
325 |
EXPORT_C CCalAttendee* ESMRHelper::CopyAttendeeLC( CCalAttendee& aSource )
|
|
326 |
{
|
|
327 |
FUNC_LOG;
|
|
328 |
CCalAttendee* copy = CCalAttendee::NewL( aSource.Address(),
|
|
329 |
aSource.SentBy() );
|
|
330 |
CleanupStack::PushL( copy );
|
|
331 |
copy->SetCommonNameL( aSource.CommonName() );
|
|
332 |
copy->SetRoleL( aSource.RoleL() );
|
|
333 |
copy->SetStatusL( aSource.StatusL() );
|
|
334 |
copy->SetResponseRequested( aSource.ResponseRequested() );
|
|
335 |
return copy;
|
|
336 |
}
|
|
337 |
|
|
338 |
// ----------------------------------------------------------------------------
|
|
339 |
// ESMRHelper::CopyUserL
|
|
340 |
// ----------------------------------------------------------------------------
|
|
341 |
//
|
|
342 |
EXPORT_C CCalUser* ESMRHelper::CopyUserL( CCalUser& aSource )
|
|
343 |
{
|
|
344 |
FUNC_LOG;
|
|
345 |
CCalUser* copy = CopyUserLC( aSource );
|
|
346 |
CleanupStack::Pop( copy );
|
|
347 |
return copy;
|
|
348 |
}
|
|
349 |
|
|
350 |
// ----------------------------------------------------------------------------
|
|
351 |
// ESMRHelper::CopyUserLC
|
|
352 |
// ----------------------------------------------------------------------------
|
|
353 |
//
|
|
354 |
EXPORT_C CCalUser* ESMRHelper::CopyUserLC( CCalUser& aSource )
|
|
355 |
{
|
|
356 |
FUNC_LOG;
|
|
357 |
CCalUser* copy = CCalUser::NewL( aSource.Address(),
|
|
358 |
aSource.SentBy() );
|
|
359 |
CleanupStack::PushL( copy );
|
|
360 |
copy->SetCommonNameL( aSource.CommonName() );
|
|
361 |
return copy;
|
|
362 |
}
|
|
363 |
|
|
364 |
// ----------------------------------------------------------------------------
|
|
365 |
// ESMRHelper::CopyEntryL
|
|
366 |
// ----------------------------------------------------------------------------
|
|
367 |
//
|
|
368 |
EXPORT_C CCalEntry* ESMRHelper::CopyEntryL(
|
|
369 |
const CCalEntry& aEntry,
|
|
370 |
CCalEntry::TMethod aMethod,
|
|
371 |
TCopyFields aCopyType,
|
|
372 |
TESMRCalendarEventType aEntryType )
|
|
373 |
{
|
|
374 |
FUNC_LOG;
|
|
375 |
CCalEntry* copy = CopyEntryLC( aEntry, aMethod, aCopyType, aEntryType );
|
|
376 |
CleanupStack::Pop( copy );
|
|
377 |
return copy;
|
|
378 |
}
|
|
379 |
|
|
380 |
// ----------------------------------------------------------------------------
|
|
381 |
// ESMRHelper::CopyEntryLC
|
|
382 |
// ----------------------------------------------------------------------------
|
|
383 |
//
|
|
384 |
EXPORT_C CCalEntry* ESMRHelper::CopyEntryLC(
|
|
385 |
const CCalEntry& aEntry,
|
|
386 |
CCalEntry::TMethod aMethod,
|
|
387 |
TCopyFields aCopyType,
|
|
388 |
TESMRCalendarEventType aEntryType )
|
|
389 |
{
|
|
390 |
FUNC_LOG;
|
|
391 |
CCalEntry* copy = NULL;
|
|
392 |
|
|
393 |
TESMRCalendarEventType type = ESMREntryHelper::EventTypeL( aEntry );
|
|
394 |
|
|
395 |
if( aEntryType == EESMREventTypeNone ||
|
|
396 |
type == aEntryType )
|
|
397 |
{
|
|
398 |
HBufC8* uid = aEntry.UidL().AllocLC();
|
|
399 |
|
|
400 |
CCalEntry::TType entryType = aEntry.EntryTypeL();
|
|
401 |
|
|
402 |
if ( aEntryType != EESMREventTypeNone )
|
|
403 |
{
|
|
404 |
entryType = MapType( aEntryType );
|
|
405 |
}
|
|
406 |
|
|
407 |
if ( ESMREntryHelper::IsModifyingEntryL( aEntry ) )
|
|
408 |
{
|
|
409 |
copy = CCalEntry::NewL( entryType,
|
|
410 |
uid,
|
|
411 |
aMethod,
|
|
412 |
aEntry.SequenceNumberL(),
|
|
413 |
aEntry.RecurrenceIdL(),
|
|
414 |
aEntry.RecurrenceRangeL() );
|
|
415 |
}
|
|
416 |
else
|
|
417 |
{
|
|
418 |
copy = CCalEntry::NewL( entryType,
|
|
419 |
uid,
|
|
420 |
aMethod,
|
|
421 |
aEntry.SequenceNumberL() );
|
|
422 |
}
|
|
423 |
CleanupStack::Pop( uid ); // ownership transferred to the copy entry
|
|
424 |
CleanupStack::PushL( copy );
|
|
425 |
|
|
426 |
CopyFieldsL( aEntry, *copy, aCopyType );
|
|
427 |
copy->SetLastModifiedDateL();
|
|
428 |
|
|
429 |
}
|
|
430 |
else
|
|
431 |
{
|
|
432 |
copy = CopyEntryAndSwitchTypeL( aEntry, aEntryType );
|
|
433 |
CleanupStack::PushL( copy );
|
|
434 |
}
|
|
435 |
|
|
436 |
return copy;
|
|
437 |
}
|
|
438 |
|
|
439 |
// ----------------------------------------------------------------------------
|
|
440 |
// ESMRHelper::CopyFieldsL
|
|
441 |
// ----------------------------------------------------------------------------
|
|
442 |
//
|
|
443 |
EXPORT_C void ESMRHelper::CopyFieldsL(
|
|
444 |
const CCalEntry& aSource,
|
|
445 |
CCalEntry& aTarget,
|
|
446 |
TCopyFields aCopyType )
|
|
447 |
{
|
|
448 |
FUNC_LOG;
|
|
449 |
if ( aCopyType == ECopyFull )
|
|
450 |
{
|
|
451 |
CCalEntry::TMethod tmpMethod( aTarget.MethodL() );
|
|
452 |
aTarget.CopyFromL( aSource );
|
|
453 |
// We must re-set the method to the original value
|
|
454 |
aTarget.SetMethodL( tmpMethod );
|
|
455 |
|
|
456 |
if ( Time::NullTTime() == aTarget.DTStampL().TimeUtcL() )
|
|
457 |
{
|
|
458 |
TCalTime dtStamp( aSource.DTStampL() );
|
|
459 |
if ( Time::NullTTime() == dtStamp.TimeUtcL() )
|
|
460 |
{
|
|
461 |
TTime now; now.UniversalTime();
|
|
462 |
dtStamp.SetTimeUtcL( now );
|
|
463 |
}
|
|
464 |
aTarget.SetDTStampL( dtStamp );
|
|
465 |
}
|
|
466 |
}
|
|
467 |
else
|
|
468 |
{
|
|
469 |
if ( aCopyType == ECopyOrganizer )
|
|
470 |
{
|
|
471 |
__ASSERT_DEBUG( aSource.OrganizerL(), Panic( EPanicNoOrganizer ) );
|
|
472 |
CCalUser* organizer = CopyUserLC( *( aSource.OrganizerL() ) );
|
|
473 |
aTarget.SetOrganizerL( organizer );
|
|
474 |
CleanupStack::Pop( organizer ); // ownership transferred
|
|
475 |
}
|
|
476 |
|
|
477 |
// these are required for entries (start and end time actually not
|
|
478 |
// for cancels and responses, but won't do any harm either):
|
|
479 |
aTarget.SetStartAndEndTimeL( aSource.StartTimeL(), aSource.EndTimeL() );
|
|
480 |
aTarget.SetDTStampL( aSource.DTStampL() );
|
|
481 |
}
|
|
482 |
}
|
|
483 |
|
|
484 |
// ----------------------------------------------------------------------------
|
|
485 |
// ESMRHelper::AddressWithoutMailtoPrefix
|
|
486 |
// ----------------------------------------------------------------------------
|
|
487 |
//
|
|
488 |
EXPORT_C TPtrC ESMRHelper::AddressWithoutMailtoPrefix( const TDesC& aAddress )
|
|
489 |
{
|
|
490 |
FUNC_LOG;
|
|
491 |
TPtrC addrWithoutPrefix( aAddress );
|
|
492 |
TInt pos = KErrNotFound;
|
|
493 |
|
|
494 |
do
|
|
495 |
{
|
|
496 |
pos = addrWithoutPrefix.MatchF( KMailtoMatchPattern );
|
|
497 |
if ( pos != KErrNotFound )
|
|
498 |
{
|
|
499 |
addrWithoutPrefix.Set( addrWithoutPrefix.Mid( KMailtoLength ) );
|
|
500 |
}
|
|
501 |
}
|
|
502 |
while ( pos != KErrNotFound );
|
|
503 |
|
|
504 |
return addrWithoutPrefix;
|
|
505 |
}
|
|
506 |
|
|
507 |
// ----------------------------------------------------------------------------
|
|
508 |
// ESMRHelper::GetCorrectDllDriveL
|
|
509 |
// ----------------------------------------------------------------------------
|
|
510 |
//
|
|
511 |
EXPORT_C void ESMRHelper::GetCorrectDllDriveL( TFileName& aDriveName )
|
|
512 |
{
|
|
513 |
FUNC_LOG;
|
|
514 |
TParse parse;
|
|
515 |
Dll::FileName( aDriveName );
|
|
516 |
User::LeaveIfError( parse.Set( aDriveName, NULL, NULL ) );
|
|
517 |
aDriveName = parse.Drive(); // contains drive, e.g. "c:"
|
|
518 |
}
|
|
519 |
|
|
520 |
// ----------------------------------------------------------------------------
|
|
521 |
// ESMRHelper::LoadResourceL
|
|
522 |
// ----------------------------------------------------------------------------
|
|
523 |
//
|
|
524 |
EXPORT_C TInt ESMRHelper::LoadResourceL( // codescanner::intleaves
|
|
525 |
const TDesC& aResourceFile,
|
|
526 |
const TDesC& aResourcePath )
|
|
527 |
{
|
|
528 |
FUNC_LOG;
|
|
529 |
TFileName pathAndFile;
|
|
530 |
// contains drive, e.g. "c:"
|
|
531 |
ESMRHelper::GetCorrectDllDriveL( pathAndFile );
|
|
532 |
// e.g. "c:MyResource.rsc"
|
|
533 |
pathAndFile.Append( aResourceFile );
|
|
534 |
|
|
535 |
TParse parse;
|
|
536 |
parse.Set( pathAndFile, &aResourcePath, NULL );
|
|
537 |
pathAndFile = parse.FullName(); // now we have full (unlocalized) file name
|
|
538 |
|
|
539 |
// Find the resource file for the nearest language
|
|
540 |
BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(),
|
|
541 |
pathAndFile );
|
|
542 |
TInt offset = CCoeEnv::Static()->AddResourceFileL( pathAndFile );
|
|
543 |
return offset;
|
|
544 |
}
|
|
545 |
|
|
546 |
// ----------------------------------------------------------------------------
|
|
547 |
// ESMRHelper::CorrespondingSmtpServiceL
|
|
548 |
// ----------------------------------------------------------------------------
|
|
549 |
//
|
|
550 |
EXPORT_C TMsvId ESMRHelper::CorrespondingSmtpServiceL(
|
|
551 |
TMsvId aRelatedService,
|
|
552 |
CMsvSession& aMsvSession )
|
|
553 |
{
|
|
554 |
FUNC_LOG;
|
|
555 |
TMsvEntry entry;
|
|
556 |
TMsvId dummyService;
|
|
557 |
|
|
558 |
User::LeaveIfError( aMsvSession.GetEntry( aRelatedService,
|
|
559 |
dummyService,
|
|
560 |
entry ) );
|
|
561 |
TMsvId smtpId( KMsvNullIndexEntryId );
|
|
562 |
|
|
563 |
switch ( entry.iMtm.iUid )
|
|
564 |
{
|
|
565 |
case KSenduiMtmImap4UidValue: // flow through
|
|
566 |
case KSenduiMtmPop3UidValue:
|
|
567 |
{
|
|
568 |
// In these cases smtp entry is available in iRelatedId:
|
|
569 |
smtpId = entry.iRelatedId;
|
|
570 |
break;
|
|
571 |
}
|
|
572 |
case KSenduiMtmSmtpUidValue:
|
|
573 |
case KSenduiMtmSyncMLEmailUidValue:
|
|
574 |
{
|
|
575 |
// In these cases we already know the msvid for the smtp settings
|
|
576 |
// (for syncml there is also smtp settings):
|
|
577 |
smtpId = aRelatedService;
|
|
578 |
break;
|
|
579 |
}
|
|
580 |
default:
|
|
581 |
{
|
|
582 |
User::Leave( KErrNotSupported );
|
|
583 |
break;
|
|
584 |
}
|
|
585 |
}
|
|
586 |
|
|
587 |
return smtpId;
|
|
588 |
}
|
|
589 |
|
|
590 |
// ----------------------------------------------------------------------------
|
|
591 |
// ESMRHelper::PopulateChildFromParentL
|
|
592 |
// ----------------------------------------------------------------------------
|
|
593 |
//
|
|
594 |
EXPORT_C void ESMRHelper::PopulateChildFromParentL (
|
|
595 |
CCalEntry &aChild,
|
|
596 |
const CCalEntry &aParent)
|
|
597 |
{
|
|
598 |
FUNC_LOG;
|
|
599 |
if ( aChild.DescriptionL() == KNullDesC )
|
|
600 |
{
|
|
601 |
aChild.SetDescriptionL( aParent.DescriptionL() );
|
|
602 |
}
|
|
603 |
if ( aChild.LocationL() == KNullDesC )
|
|
604 |
{
|
|
605 |
aChild.SetLocationL( aParent.LocationL() );
|
|
606 |
}
|
|
607 |
if ( aChild.PriorityL() == 0 )
|
|
608 |
{
|
|
609 |
// zero is undefined priority according to iCal spec.
|
|
610 |
aChild.SetPriorityL( aParent.PriorityL() );
|
|
611 |
}
|
|
612 |
if ( aChild.SummaryL() == KNullDesC )
|
|
613 |
{
|
|
614 |
aChild.SetSummaryL( aParent.SummaryL() );
|
|
615 |
}
|
|
616 |
if ( aChild.StatusL() == CCalEntry::ENullStatus )
|
|
617 |
{
|
|
618 |
aChild.SetStatusL( aParent.StatusL() );
|
|
619 |
}
|
|
620 |
if (aChild.ReplicationStatusL() != aParent.ReplicationStatusL())
|
|
621 |
{
|
|
622 |
aChild.SetReplicationStatusL(aParent.ReplicationStatusL());
|
|
623 |
}
|
|
624 |
if (aChild.MethodL() == CCalEntry::EMethodNone)
|
|
625 |
{
|
|
626 |
aChild.SetMethodL(aParent.MethodL());
|
|
627 |
}
|
|
628 |
|
|
629 |
CCalAlarm* childAlarm = aChild.AlarmL();
|
|
630 |
CleanupStack::PushL( childAlarm );
|
|
631 |
CCalAlarm* parentAlarm = aChild.AlarmL();
|
|
632 |
CleanupStack::PushL( parentAlarm );
|
|
633 |
|
|
634 |
if( !childAlarm && parentAlarm )
|
|
635 |
{
|
|
636 |
aChild.SetAlarmL( parentAlarm );
|
|
637 |
}
|
|
638 |
CleanupStack::PopAndDestroy( parentAlarm );
|
|
639 |
CleanupStack::PopAndDestroy( childAlarm );
|
|
640 |
|
|
641 |
// Organizer
|
|
642 |
if ( !aChild.OrganizerL() && aParent.OrganizerL() )
|
|
643 |
{
|
|
644 |
CCalUser* owner =
|
|
645 |
ESMRHelper::CopyUserLC( *( aParent.OrganizerL() ) );
|
|
646 |
aChild.SetOrganizerL( owner );
|
|
647 |
CleanupStack::Pop(owner); // ownership transferred
|
|
648 |
}
|
|
649 |
|
|
650 |
// Attendees
|
|
651 |
RPointerArray<CCalAttendee>& childAtt = aChild.AttendeesL();
|
|
652 |
RPointerArray<CCalAttendee>& parentAtt = aParent.AttendeesL();
|
|
653 |
|
|
654 |
CCalUser *po = NULL;
|
|
655 |
if ( !aChild.PhoneOwnerL() )
|
|
656 |
{ // Phone owner is internal data, not part of ical protocol, it's
|
|
657 |
// benefit is to avoid heavy "who am I" resolving operation
|
|
658 |
po = aParent.PhoneOwnerL();
|
|
659 |
}
|
|
660 |
TInt parentAttCount( parentAtt.Count() );
|
|
661 |
if ( childAtt.Count() == 0 && parentAttCount > 0 )
|
|
662 |
{
|
|
663 |
for ( TInt i( 0 ); i < parentAttCount; ++i )
|
|
664 |
{
|
|
665 |
CCalAttendee* copy =
|
|
666 |
ESMRHelper::CopyAttendeeLC( *( parentAtt[i] ) );
|
|
667 |
aChild.AddAttendeeL( copy );
|
|
668 |
CleanupStack::Pop(copy); // ownership transferred
|
|
669 |
if(po == parentAtt[i])
|
|
670 |
{
|
|
671 |
aChild.SetPhoneOwnerL(copy);
|
|
672 |
}
|
|
673 |
}
|
|
674 |
}
|
|
675 |
}
|
|
676 |
|
|
677 |
// ----------------------------------------------------------------------------
|
|
678 |
// ESMRHelper::LocateResourceFile
|
|
679 |
// ----------------------------------------------------------------------------
|
|
680 |
//
|
|
681 |
EXPORT_C TInt ESMRHelper::LocateResourceFile(
|
|
682 |
const TDesC& aResource,
|
|
683 |
const TDesC& aPath,
|
|
684 |
TFileName &aResourceFile,
|
|
685 |
RFs* aFs )
|
|
686 |
{
|
|
687 |
FUNC_LOG;
|
|
688 |
RFs* fsSession;
|
|
689 |
if ( aFs )
|
|
690 |
{
|
|
691 |
fsSession = aFs;
|
|
692 |
}
|
|
693 |
else
|
|
694 |
{
|
|
695 |
fsSession=&CCoeEnv::Static()->FsSession();//codescanner::eikonenvstatic
|
|
696 |
}
|
|
697 |
|
|
698 |
TFindFile resourceFile( *fsSession );
|
|
699 |
TInt err = resourceFile.FindByDir(
|
|
700 |
aResource,
|
|
701 |
aPath );
|
|
702 |
|
|
703 |
if ( KErrNone == err )
|
|
704 |
{
|
|
705 |
aResourceFile.Copy( resourceFile.File() );
|
|
706 |
}
|
|
707 |
else
|
|
708 |
{
|
|
709 |
const TChar KFileFormatDelim( '.' );
|
|
710 |
TFileName locResourceFile;
|
|
711 |
|
|
712 |
|
|
713 |
TInt pos = aResource.LocateReverse( KFileFormatDelim );
|
|
714 |
if ( pos != KErrNotFound )
|
|
715 |
{
|
|
716 |
locResourceFile.Copy( aResource.Mid(0, pos + 1) );
|
|
717 |
|
|
718 |
TInt language( User::Language() );
|
|
719 |
if (language < KMinTwoDigitLanguageCode )
|
|
720 |
{
|
|
721 |
locResourceFile.AppendFormat( KResourceFileLocFormat1, language );
|
|
722 |
}
|
|
723 |
else
|
|
724 |
{
|
|
725 |
locResourceFile.AppendFormat( KResourceFileLocFormat2, language );
|
|
726 |
}
|
|
727 |
|
|
728 |
TFindFile resourceFile( *fsSession );
|
|
729 |
err = resourceFile.FindByDir(
|
|
730 |
locResourceFile,
|
|
731 |
aPath );
|
|
732 |
|
|
733 |
if ( KErrNone == err )
|
|
734 |
{
|
|
735 |
TFileName tempName;
|
|
736 |
tempName.Copy( resourceFile.File() );
|
|
737 |
TInt dotpos= tempName.LocateReverse(KFileFormatDelim);
|
|
738 |
aResourceFile.Copy(tempName.Mid(0,dotpos+1) );
|
|
739 |
aResourceFile.Append(KResourceFormat);
|
|
740 |
}
|
|
741 |
}
|
|
742 |
}
|
|
743 |
|
|
744 |
|
|
745 |
if ( KErrNone != err )
|
|
746 |
{
|
|
747 |
}
|
|
748 |
return err;
|
|
749 |
}
|
|
750 |
|
|
751 |
//<cmail>
|
|
752 |
// ----------------------------------------------------------------------------
|
|
753 |
// ESMRHelper::CreateAndAppendPrivateDirToFileName
|
|
754 |
// ----------------------------------------------------------------------------
|
|
755 |
//
|
|
756 |
EXPORT_C TInt ESMRHelper::CreateAndAppendPrivateDirToFileName(
|
|
757 |
TFileName& aFileName)
|
|
758 |
{
|
|
759 |
FUNC_LOG;
|
|
760 |
|
|
761 |
TFileName path;
|
|
762 |
RFs fsSession;
|
|
763 |
TInt result = fsSession.Connect();
|
|
764 |
if ( KErrNone == result )
|
|
765 |
{
|
|
766 |
TBool createPrivatePath( ETrue );
|
|
767 |
|
|
768 |
fsSession.PrivatePath(path);
|
|
769 |
|
|
770 |
TFindFile findFile(fsSession);
|
|
771 |
result = findFile.FindByDir(path, KNullDesC);
|
|
772 |
if (KErrNone == result )
|
|
773 |
{
|
|
774 |
// Check that we are able to drive into private path location
|
|
775 |
createPrivatePath = EFalse;
|
|
776 |
|
|
777 |
path = findFile.File();
|
|
778 |
TInt drive = TDriveUnit( path );
|
|
779 |
TInt KRomDrive = TDriveUnit( PathInfo::RomRootPath() );
|
|
780 |
|
|
781 |
if ( drive == KRomDrive )
|
|
782 |
{
|
|
783 |
// Private path locates in ROM
|
|
784 |
createPrivatePath = ETrue;
|
|
785 |
}
|
|
786 |
}
|
|
787 |
|
|
788 |
TPtrC phoneMemoryPath( PathInfo::PhoneMemoryRootPath() );
|
|
789 |
|
|
790 |
if ( createPrivatePath )
|
|
791 |
{
|
|
792 |
//create path if doesn't exists
|
|
793 |
TInt drive = TDriveUnit(phoneMemoryPath);
|
|
794 |
fsSession.CreatePrivatePath( drive );
|
|
795 |
}
|
|
796 |
|
|
797 |
result = findFile.FindByDir(path, KNullDesC);
|
|
798 |
path = findFile.File();
|
|
799 |
path[0] = phoneMemoryPath[0];
|
|
800 |
aFileName.Insert(0,path);
|
|
801 |
|
|
802 |
fsSession.MkDirAll(aFileName);
|
|
803 |
result = KErrNone;
|
|
804 |
}
|
|
805 |
|
|
806 |
// fsSession
|
|
807 |
fsSession.Close();
|
|
808 |
return result;
|
|
809 |
}
|
|
810 |
//</cmail>
|
|
811 |
|
|
812 |
// ----------------------------------------------------------------------------
|
|
813 |
// ESMRHelper::CreateAndAppendOthersDirToFileName
|
|
814 |
// ----------------------------------------------------------------------------
|
|
815 |
//
|
|
816 |
EXPORT_C TInt ESMRHelper::CreateAndAppendOthersDirToFileName(
|
|
817 |
TFileName& aFileName)
|
|
818 |
{
|
|
819 |
FUNC_LOG;
|
|
820 |
|
|
821 |
TFileName path;
|
|
822 |
RFs fsSession;
|
|
823 |
TInt result = fsSession.Connect();
|
|
824 |
if ( KErrNone == result )
|
|
825 |
{
|
|
826 |
aFileName.Insert(0, PathInfo::OthersPath() );
|
|
827 |
aFileName.Insert(0, PathInfo::PhoneMemoryRootPath() );
|
|
828 |
|
|
829 |
fsSession.MkDirAll(aFileName);
|
|
830 |
|
|
831 |
result = KErrNone;
|
|
832 |
}
|
|
833 |
|
|
834 |
// fsSession
|
|
835 |
fsSession.Close();
|
|
836 |
return result;
|
|
837 |
}
|
|
838 |
|
|
839 |
// ----------------------------------------------------------------------------
|
|
840 |
// ESMRHelper::CopyEntryAndSwitchTypeL
|
|
841 |
// ----------------------------------------------------------------------------
|
|
842 |
//
|
|
843 |
CCalEntry* ESMRHelper::CopyEntryAndSwitchTypeL(
|
|
844 |
const CCalEntry& aSourceEntry,
|
|
845 |
TESMRCalendarEventType aTargetType )
|
|
846 |
{
|
|
847 |
FUNC_LOG;
|
|
848 |
CCalEntry* entry = NULL;
|
|
849 |
|
|
850 |
TESMRSwitchEventType switchType;
|
|
851 |
|
|
852 |
switchType = ResolveSwitchType(
|
|
853 |
ESMREntryHelper::EventTypeL( aSourceEntry ), aTargetType );
|
|
854 |
|
|
855 |
switch ( switchType )
|
|
856 |
{
|
|
857 |
case EMRSwitchMRToMeeting:
|
|
858 |
{
|
|
859 |
entry = SwitchToMeetingL( aSourceEntry );
|
|
860 |
break;
|
|
861 |
}
|
|
862 |
case EMRSwitchMRToMemo:
|
|
863 |
{
|
|
864 |
entry = SwitchToMemoL( aSourceEntry );
|
|
865 |
break;
|
|
866 |
}
|
|
867 |
case EMRSwitchMRToAnniversary:
|
|
868 |
{
|
|
869 |
entry = SwitchToAnniversaryL( aSourceEntry );
|
|
870 |
break;
|
|
871 |
}
|
|
872 |
case EMRSwitchMRToTodo:
|
|
873 |
{
|
|
874 |
entry = SwitchToTodoL( aSourceEntry );
|
|
875 |
break;
|
|
876 |
}
|
|
877 |
case EMRSwitchMeetingToMR:
|
|
878 |
{
|
|
879 |
entry = SwitchToMRL( aSourceEntry );
|
|
880 |
break;
|
|
881 |
}
|
|
882 |
case EMRSwitchMeetingToMemo:
|
|
883 |
{
|
|
884 |
entry = SwitchToMemoL( aSourceEntry );
|
|
885 |
break;
|
|
886 |
}
|
|
887 |
case EMRSwitchMeetingToAnniversary:
|
|
888 |
{
|
|
889 |
entry = SwitchToAnniversaryL( aSourceEntry );
|
|
890 |
break;
|
|
891 |
}
|
|
892 |
case EMRSwitchMeetingToTodo:
|
|
893 |
{
|
|
894 |
entry = SwitchToTodoL( aSourceEntry );
|
|
895 |
break;
|
|
896 |
}
|
|
897 |
case EMRSwitchMemoToMR:
|
|
898 |
{
|
|
899 |
entry = SwitchToMRL( aSourceEntry );
|
|
900 |
break;
|
|
901 |
}
|
|
902 |
case EMRSwitchMemoToMeeting:
|
|
903 |
{
|
|
904 |
entry = SwitchToMeetingL( aSourceEntry );
|
|
905 |
break;
|
|
906 |
}
|
|
907 |
case EMRSwitchMemoToAnniversary:
|
|
908 |
{
|
|
909 |
entry = SwitchToAnniversaryL( aSourceEntry );
|
|
910 |
break;
|
|
911 |
}
|
|
912 |
case EMRSwitchMemoToTodo:
|
|
913 |
{
|
|
914 |
entry = SwitchToTodoL( aSourceEntry );
|
|
915 |
break;
|
|
916 |
}
|
|
917 |
case EMRSwitchAnniversaryToMR:
|
|
918 |
{
|
|
919 |
entry = SwitchToMRL( aSourceEntry );
|
|
920 |
break;
|
|
921 |
}
|
|
922 |
case EMRSwitchAnniversaryToMeeting:
|
|
923 |
{
|
|
924 |
entry = SwitchToMeetingL( aSourceEntry );
|
|
925 |
break;
|
|
926 |
}
|
|
927 |
case EMRSwitchAnniversaryToMemo:
|
|
928 |
{
|
|
929 |
entry = SwitchToMemoL( aSourceEntry );
|
|
930 |
break;
|
|
931 |
}
|
|
932 |
case EMRSwitchAnniversaryToTodo:
|
|
933 |
{
|
|
934 |
entry = SwitchToTodoL( aSourceEntry );
|
|
935 |
break;
|
|
936 |
}
|
|
937 |
case EMRSwitchTodoToMR:
|
|
938 |
{
|
|
939 |
entry = SwitchToMRL( aSourceEntry );
|
|
940 |
break;
|
|
941 |
}
|
|
942 |
case EMRSwitchTodoToMeeting:
|
|
943 |
{
|
|
944 |
entry = SwitchToMeetingL( aSourceEntry );
|
|
945 |
break;
|
|
946 |
}
|
|
947 |
case EMRSwitchTodoToMemo:
|
|
948 |
{
|
|
949 |
entry = SwitchToMemoL( aSourceEntry );
|
|
950 |
break;
|
|
951 |
}
|
|
952 |
case EMRSwitchTodoToAnniversary:
|
|
953 |
{
|
|
954 |
entry = SwitchToAnniversaryL( aSourceEntry );
|
|
955 |
break;
|
|
956 |
}
|
|
957 |
|
|
958 |
default:
|
|
959 |
{
|
|
960 |
__ASSERT_DEBUG( EFalse, Panic( EInvalidEntryType ) );
|
|
961 |
}
|
|
962 |
}
|
|
963 |
|
|
964 |
return entry;
|
|
965 |
}
|
|
966 |
|
|
967 |
// ----------------------------------------------------------------------------
|
|
968 |
// ESMRHelper::ResolveSwitchType
|
|
969 |
// ----------------------------------------------------------------------------
|
|
970 |
//
|
|
971 |
ESMRHelper::TESMRSwitchEventType ESMRHelper::ResolveSwitchType(
|
|
972 |
TESMRCalendarEventType aSourceType,
|
|
973 |
TESMRCalendarEventType aTargetType )
|
|
974 |
{
|
|
975 |
FUNC_LOG;
|
|
976 |
|
|
977 |
TESMRSwitchEventType type( EMRSwitchUnknown );
|
|
978 |
|
|
979 |
if( aSourceType == EESMREventTypeMeetingRequest ) // Meeting request
|
|
980 |
{
|
|
981 |
if( aTargetType == EESMREventTypeAppt )
|
|
982 |
{
|
|
983 |
type = EMRSwitchMRToMeeting;
|
|
984 |
}
|
|
985 |
|
|
986 |
if( aTargetType == EESMREventTypeEEvent )
|
|
987 |
{
|
|
988 |
type = EMRSwitchMRToMemo;
|
|
989 |
}
|
|
990 |
|
|
991 |
if( aTargetType == EESMREventTypeEAnniv )
|
|
992 |
{
|
|
993 |
type = EMRSwitchMRToAnniversary;
|
|
994 |
}
|
|
995 |
|
|
996 |
if( aTargetType == EESMREventTypeETodo )
|
|
997 |
{
|
|
998 |
type = EMRSwitchMRToTodo;
|
|
999 |
}
|
|
1000 |
}
|
|
1001 |
|
|
1002 |
if( aSourceType == EESMREventTypeAppt ) // Meeting
|
|
1003 |
{
|
|
1004 |
if( aTargetType == EESMREventTypeMeetingRequest )
|
|
1005 |
{
|
|
1006 |
type = EMRSwitchMeetingToMR;
|
|
1007 |
}
|
|
1008 |
|
|
1009 |
if( aTargetType == EESMREventTypeEEvent )
|
|
1010 |
{
|
|
1011 |
type = EMRSwitchMeetingToMemo;
|
|
1012 |
}
|
|
1013 |
|
|
1014 |
if( aTargetType == EESMREventTypeEAnniv )
|
|
1015 |
{
|
|
1016 |
type = EMRSwitchMeetingToAnniversary;
|
|
1017 |
}
|
|
1018 |
|
|
1019 |
if( aTargetType == EESMREventTypeETodo )
|
|
1020 |
{
|
|
1021 |
type = EMRSwitchMeetingToTodo;
|
|
1022 |
}
|
|
1023 |
}
|
|
1024 |
|
|
1025 |
if( aSourceType == EESMREventTypeEEvent ) // Memo
|
|
1026 |
{
|
|
1027 |
if( aTargetType == EESMREventTypeMeetingRequest )
|
|
1028 |
{
|
|
1029 |
type = EMRSwitchMemoToMR;
|
|
1030 |
}
|
|
1031 |
|
|
1032 |
if( aTargetType == EESMREventTypeAppt )
|
|
1033 |
{
|
|
1034 |
type = EMRSwitchMemoToMeeting;
|
|
1035 |
}
|
|
1036 |
|
|
1037 |
if( aTargetType == EESMREventTypeEAnniv )
|
|
1038 |
{
|
|
1039 |
type = EMRSwitchMemoToAnniversary;
|
|
1040 |
}
|
|
1041 |
|
|
1042 |
if( aTargetType == EESMREventTypeETodo )
|
|
1043 |
{
|
|
1044 |
type = EMRSwitchMemoToTodo;
|
|
1045 |
}
|
|
1046 |
}
|
|
1047 |
|
|
1048 |
if( aSourceType == EESMREventTypeEAnniv ) // Anniversary
|
|
1049 |
{
|
|
1050 |
if( aTargetType == EESMREventTypeMeetingRequest )
|
|
1051 |
{
|
|
1052 |
type = EMRSwitchAnniversaryToMR;
|
|
1053 |
}
|
|
1054 |
|
|
1055 |
if( aTargetType == EESMREventTypeAppt )
|
|
1056 |
{
|
|
1057 |
type = EMRSwitchAnniversaryToMeeting;
|
|
1058 |
}
|
|
1059 |
|
|
1060 |
if( aTargetType == EESMREventTypeEEvent )
|
|
1061 |
{
|
|
1062 |
type = EMRSwitchAnniversaryToMemo;
|
|
1063 |
}
|
|
1064 |
|
|
1065 |
if( aTargetType == EESMREventTypeETodo )
|
|
1066 |
{
|
|
1067 |
type = EMRSwitchAnniversaryToTodo;
|
|
1068 |
}
|
|
1069 |
}
|
|
1070 |
|
|
1071 |
if( aSourceType == EESMREventTypeETodo ) // To-do
|
|
1072 |
{
|
|
1073 |
if( aTargetType == EESMREventTypeMeetingRequest )
|
|
1074 |
{
|
|
1075 |
type = EMRSwitchTodoToMR;
|
|
1076 |
}
|
|
1077 |
|
|
1078 |
if( aTargetType == EESMREventTypeAppt )
|
|
1079 |
{
|
|
1080 |
type = EMRSwitchTodoToMeeting;
|
|
1081 |
}
|
|
1082 |
|
|
1083 |
if( aTargetType == EESMREventTypeEEvent )
|
|
1084 |
{
|
|
1085 |
type = EMRSwitchTodoToMemo;
|
|
1086 |
}
|
|
1087 |
|
|
1088 |
if( aTargetType == EESMREventTypeEAnniv )
|
|
1089 |
{
|
|
1090 |
type = EMRSwitchTodoToAnniversary;
|
|
1091 |
}
|
|
1092 |
}
|
|
1093 |
|
|
1094 |
__ASSERT_DEBUG( type != EMRSwitchUnknown, Panic( EInvalidSwitchType ) );
|
|
1095 |
|
|
1096 |
return type;
|
|
1097 |
}
|
|
1098 |
|
|
1099 |
// ----------------------------------------------------------------------------
|
|
1100 |
// ESMRHelper::SwitchToMemoL
|
|
1101 |
// ----------------------------------------------------------------------------
|
|
1102 |
//
|
|
1103 |
CCalEntry* ESMRHelper::SwitchToMemoL(
|
|
1104 |
const CCalEntry& aSourceEntry )
|
|
1105 |
{
|
|
1106 |
FUNC_LOG;
|
|
1107 |
CCalEntry* entry = CreateEntryL(
|
|
1108 |
CCalEntry::EEvent,
|
|
1109 |
aSourceEntry.UidL(),
|
|
1110 |
CCalEntry::EMethodNone,
|
|
1111 |
CalCommon::EThisOnly );
|
|
1112 |
|
|
1113 |
CleanupStack::PushL( entry );
|
|
1114 |
|
|
1115 |
// Copy all data from existing entry to new entry
|
|
1116 |
entry->CopyFromL( aSourceEntry );
|
|
1117 |
// We must re-set the method to the original value
|
|
1118 |
entry->SetMethodL( CCalEntry::EMethodNone );
|
|
1119 |
|
|
1120 |
#ifdef RD_USE_PS2_APIS
|
|
1121 |
// If source entry is a meeting request...
|
|
1122 |
if( CCalenInterimUtils2::IsMeetingRequestL( *entry ) )
|
|
1123 |
{
|
|
1124 |
// ... we need to clear all MR specific data
|
|
1125 |
entry->ClearMRSpecificDataL();
|
|
1126 |
}
|
|
1127 |
#endif // RD_USE_PS2_APIS
|
|
1128 |
|
|
1129 |
// Memo is never a repeating event
|
|
1130 |
entry->ClearRepeatingPropertiesL();
|
|
1131 |
|
|
1132 |
// Memo has start and stop date without time value.
|
|
1133 |
// Let's change the entry's start and stop times to memo specific
|
|
1134 |
// Setting start date and stop date
|
|
1135 |
TDateTime start = entry->StartTimeL().TimeLocalL().DateTime();
|
|
1136 |
start.SetHour( 0 );
|
|
1137 |
start.SetMinute( 0 );
|
|
1138 |
start.SetSecond( 0 );
|
|
1139 |
|
|
1140 |
TTime tempEnd = entry->EndTimeL().TimeLocalL();
|
|
1141 |
|
|
1142 |
if( ESMREntryHelper::IsAllDayEventL( aSourceEntry ) )
|
|
1143 |
{
|
|
1144 |
// If source is all day event, we need to reduce one from the day,
|
|
1145 |
// otherwise the new memo would be spanned over one day too long
|
|
1146 |
tempEnd -= TTimeIntervalDays( 1 );
|
|
1147 |
}
|
|
1148 |
|
|
1149 |
TDateTime end = tempEnd.DateTime();
|
|
1150 |
end.SetHour( KMaxHoursForMemo );
|
|
1151 |
end.SetMinute( KMaxMinutesForMemo );
|
|
1152 |
end.SetSecond( KMaxSecondsForMemo );
|
|
1153 |
|
|
1154 |
TCalTime startDate;
|
|
1155 |
startDate.SetTimeLocalFloatingL( start );
|
|
1156 |
TCalTime stopDate;
|
|
1157 |
stopDate.SetTimeLocalFloatingL( end );
|
|
1158 |
entry->SetStartAndEndTimeL( startDate, stopDate );
|
|
1159 |
|
|
1160 |
// Memo does not have any alarm value
|
|
1161 |
entry->SetAlarmL( NULL );
|
|
1162 |
|
|
1163 |
// If source entry is to-do, we need to convert the
|
|
1164 |
// priority from to-do priority to normal priority
|
|
1165 |
if( aSourceEntry.EntryTypeL() == CCalEntry::ETodo )
|
|
1166 |
{
|
|
1167 |
ConvertTodoPriorityToNormalL( *entry );
|
|
1168 |
}
|
|
1169 |
|
|
1170 |
CleanupStack::Pop( entry ); // ownership transferred to caller
|
|
1171 |
return entry;
|
|
1172 |
}
|
|
1173 |
|
|
1174 |
// ----------------------------------------------------------------------------
|
|
1175 |
// ESMRHelper::SwitchToAnniversaryL
|
|
1176 |
// ----------------------------------------------------------------------------
|
|
1177 |
//
|
|
1178 |
CCalEntry* ESMRHelper::SwitchToAnniversaryL(
|
|
1179 |
const CCalEntry& aSourceEntry )
|
|
1180 |
{
|
|
1181 |
FUNC_LOG;
|
|
1182 |
// Create an entry
|
|
1183 |
CCalEntry* entry = CreateEntryL(
|
|
1184 |
CCalEntry::EAnniv,
|
|
1185 |
aSourceEntry.UidL(),
|
|
1186 |
CCalEntry::EMethodNone,
|
|
1187 |
CalCommon::EThisOnly );
|
|
1188 |
|
|
1189 |
CleanupStack::PushL( entry );
|
|
1190 |
|
|
1191 |
// Copy all data from existing entry to new entry
|
|
1192 |
entry->CopyFromL( aSourceEntry );
|
|
1193 |
// We must re-set the method to the original value
|
|
1194 |
entry->SetMethodL( CCalEntry::EMethodNone );
|
|
1195 |
|
|
1196 |
#ifdef RD_USE_PS2_APIS
|
|
1197 |
// If source entry is a meeting request...
|
|
1198 |
if( CCalenInterimUtils2::IsMeetingRequestL( *entry ) )
|
|
1199 |
{
|
|
1200 |
// ... we need to clear all MR specific data
|
|
1201 |
entry->ClearMRSpecificDataL();
|
|
1202 |
}
|
|
1203 |
#endif // RD_USE_PS2_APIS
|
|
1204 |
|
|
1205 |
// Anniversary repeats once a year, so
|
|
1206 |
// we clear existing repeating rules...
|
|
1207 |
entry->ClearRepeatingPropertiesL();
|
|
1208 |
|
|
1209 |
// ... and create a new rule, to repeat once a year
|
|
1210 |
TCalRRule rrule( TCalRRule::EYearly );
|
|
1211 |
rrule.SetDtStart( entry->StartTimeL() );
|
|
1212 |
rrule.SetInterval( 1 );
|
|
1213 |
rrule.SetCount( 0 );
|
|
1214 |
entry->SetRRuleL( rrule );
|
|
1215 |
|
|
1216 |
// Anniversary default alarm is previous day at noon.
|
|
1217 |
// Let's set that also.
|
|
1218 |
TTime eventTime = entry->StartTimeL().TimeLocalL();
|
|
1219 |
TTime alarmTime = eventTime - TTimeIntervalDays( 1 );
|
|
1220 |
TDateTime alarmDateTime = alarmTime.DateTime();
|
|
1221 |
alarmDateTime.SetHour( KDefaultAnniversaryAlarmHours );
|
|
1222 |
alarmDateTime.SetMinute( 0 );
|
|
1223 |
alarmDateTime.SetSecond( 0 );
|
|
1224 |
alarmDateTime.SetMicroSecond( 0 );
|
|
1225 |
alarmTime = alarmDateTime;
|
|
1226 |
|
|
1227 |
// Calculating alarm offset
|
|
1228 |
TTimeIntervalMinutes alarmOffset( 0 );
|
|
1229 |
eventTime.MinutesFrom( alarmTime, alarmOffset );
|
|
1230 |
|
|
1231 |
// Creating alarm
|
|
1232 |
CCalAlarm* alarm = CCalAlarm::NewL();
|
|
1233 |
CleanupStack::PushL( alarm );
|
|
1234 |
alarm->SetTimeOffset( alarmOffset );
|
|
1235 |
|
|
1236 |
// Setting alarm
|
|
1237 |
entry->SetAlarmL( alarm );
|
|
1238 |
CleanupStack::PopAndDestroy( alarm );
|
|
1239 |
alarm = NULL;
|
|
1240 |
|
|
1241 |
// If source entry is to-do, we need to convert the
|
|
1242 |
// priority from to-do priority to normal priority
|
|
1243 |
if( aSourceEntry.EntryTypeL() == CCalEntry::ETodo )
|
|
1244 |
{
|
|
1245 |
ConvertTodoPriorityToNormalL( *entry );
|
|
1246 |
}
|
|
1247 |
|
|
1248 |
CleanupStack::Pop( entry ); // ownership transferred to caller
|
|
1249 |
return entry;
|
|
1250 |
}
|
|
1251 |
|
|
1252 |
// ----------------------------------------------------------------------------
|
|
1253 |
// ESMRHelper::SwitchToTodoL
|
|
1254 |
// ----------------------------------------------------------------------------
|
|
1255 |
//
|
|
1256 |
CCalEntry* ESMRHelper::SwitchToTodoL(
|
|
1257 |
const CCalEntry& aSourceEntry )
|
|
1258 |
{
|
|
1259 |
FUNC_LOG;
|
|
1260 |
CCalEntry* entry = CreateEntryL(
|
|
1261 |
CCalEntry::ETodo,
|
|
1262 |
aSourceEntry.UidL(),
|
|
1263 |
CCalEntry::EMethodNone,
|
|
1264 |
CalCommon::EThisOnly );
|
|
1265 |
|
|
1266 |
CleanupStack::PushL( entry );
|
|
1267 |
|
|
1268 |
// Copy all data from existing entry to new entry
|
|
1269 |
entry->CopyFromL( aSourceEntry );
|
|
1270 |
// We must re-set the method to the original value
|
|
1271 |
entry->SetMethodL( CCalEntry::EMethodNone );
|
|
1272 |
|
|
1273 |
#ifdef RD_USE_PS2_APIS
|
|
1274 |
// If source entry is a meeting request...
|
|
1275 |
if( CCalenInterimUtils2::IsMeetingRequestL( *entry ) )
|
|
1276 |
{
|
|
1277 |
// ... we need to clear all MR specific data
|
|
1278 |
entry->ClearMRSpecificDataL();
|
|
1279 |
}
|
|
1280 |
#endif // RD_USE_PS2_APIS
|
|
1281 |
|
|
1282 |
// To-do is never a repeating event
|
|
1283 |
entry->ClearRepeatingPropertiesL();
|
|
1284 |
|
|
1285 |
// To-do has a due date only. Let's change the entry's start and stop
|
|
1286 |
// times to To-do specific ones
|
|
1287 |
TTime tempEnd = entry->EndTimeL().TimeLocalL();
|
|
1288 |
|
|
1289 |
if( ESMREntryHelper::IsAllDayEventL( aSourceEntry ) )
|
|
1290 |
{
|
|
1291 |
// If source is all day event, we need to reduce one from the day,
|
|
1292 |
// otherwise the new todos due date would be one day late
|
|
1293 |
tempEnd -= TTimeIntervalDays( 1 );
|
|
1294 |
}
|
|
1295 |
|
|
1296 |
TDateTime tempDue = tempEnd.DateTime();
|
|
1297 |
|
|
1298 |
tempDue.SetHour( KMaxHoursForTodo );
|
|
1299 |
tempDue.SetMinute( KMaxMinutesForTodo );
|
|
1300 |
tempDue.SetSecond( KMaxSecondsForTodo );
|
|
1301 |
|
|
1302 |
TCalTime dueDate;
|
|
1303 |
dueDate.SetTimeLocalFloatingL( tempDue );
|
|
1304 |
|
|
1305 |
entry->SetStartAndEndTimeL( dueDate, dueDate );
|
|
1306 |
|
|
1307 |
// Setting to-do specific alarm
|
|
1308 |
if( entry->AlarmL() )
|
|
1309 |
{
|
|
1310 |
// Setting default To-do alarm for entry
|
|
1311 |
TTime eventTime = entry->EndTimeL().TimeLocalL();
|
|
1312 |
|
|
1313 |
// Calculate alarm time (due date at 12:00am)
|
|
1314 |
TTime alarmTime = eventTime;
|
|
1315 |
TDateTime alarmDateTime = alarmTime.DateTime();
|
|
1316 |
alarmDateTime.SetHour( KDefaultTodoAlarmHours );
|
|
1317 |
alarmDateTime.SetMinute( 0 );
|
|
1318 |
alarmDateTime.SetSecond( 0 );
|
|
1319 |
alarmDateTime.SetMicroSecond( 0 );
|
|
1320 |
alarmTime = alarmDateTime;
|
|
1321 |
|
|
1322 |
TTime currentTime;
|
|
1323 |
currentTime.HomeTime();
|
|
1324 |
|
|
1325 |
// If alarm is in the future
|
|
1326 |
if ( alarmTime > currentTime )
|
|
1327 |
{
|
|
1328 |
CCalAlarm* alarm = CCalAlarm::NewL();
|
|
1329 |
CleanupStack::PushL( alarm );
|
|
1330 |
TTimeIntervalMinutes alarmOffset( 0 );
|
|
1331 |
eventTime.MinutesFrom( alarmTime, alarmOffset );
|
|
1332 |
alarm->SetTimeOffset( alarmOffset );
|
|
1333 |
entry->SetAlarmL( alarm );
|
|
1334 |
CleanupStack::PopAndDestroy( alarm );
|
|
1335 |
}
|
|
1336 |
// Alarm is in the past, let's set it to NULL
|
|
1337 |
else
|
|
1338 |
{
|
|
1339 |
entry->SetAlarmL( NULL );
|
|
1340 |
}
|
|
1341 |
}
|
|
1342 |
|
|
1343 |
// Setting to-do specific priority
|
|
1344 |
TInt priority( 0 );
|
|
1345 |
if( entry->PriorityL() == EFSCalenMRPriorityHigh )
|
|
1346 |
{
|
|
1347 |
priority = EFSCalenTodoPriorityHigh;
|
|
1348 |
}
|
|
1349 |
|
|
1350 |
else if( entry->PriorityL() == EFSCalenMRPriorityNormal )
|
|
1351 |
{
|
|
1352 |
priority = EFSCalenTodoPriorityNormal;
|
|
1353 |
}
|
|
1354 |
|
|
1355 |
else if( entry->PriorityL() == EFSCalenMRPriorityLow )
|
|
1356 |
{
|
|
1357 |
priority = EFSCalenTodoPriorityLow;
|
|
1358 |
}
|
|
1359 |
|
|
1360 |
else
|
|
1361 |
{
|
|
1362 |
// Priority unknown, let's set it to normal then
|
|
1363 |
priority = EFSCalenTodoPriorityNormal;
|
|
1364 |
}
|
|
1365 |
|
|
1366 |
entry->SetPriorityL( priority );
|
|
1367 |
|
|
1368 |
CleanupStack::Pop( entry ); // ownership transferred to caller
|
|
1369 |
return entry;
|
|
1370 |
}
|
|
1371 |
|
|
1372 |
// ----------------------------------------------------------------------------
|
|
1373 |
// ESMRHelper::SwitchToMeetingL
|
|
1374 |
// ----------------------------------------------------------------------------
|
|
1375 |
//
|
|
1376 |
CCalEntry* ESMRHelper::SwitchToMeetingL(
|
|
1377 |
const CCalEntry& aSourceEntry )
|
|
1378 |
{
|
|
1379 |
FUNC_LOG;
|
|
1380 |
|
|
1381 |
CCalEntry* entry = CreateEntryL(
|
|
1382 |
CCalEntry::EAppt,
|
|
1383 |
aSourceEntry.UidL(),
|
|
1384 |
CCalEntry::EMethodNone,
|
|
1385 |
CalCommon::EThisOnly );
|
|
1386 |
|
|
1387 |
CleanupStack::PushL( entry );
|
|
1388 |
|
|
1389 |
// Copy all data from existing entry to new entry
|
|
1390 |
entry->CopyFromL( aSourceEntry );
|
|
1391 |
|
|
1392 |
// If source was to-do, priority needs converting
|
|
1393 |
if( aSourceEntry.EntryTypeL() == CCalEntry::ETodo )
|
|
1394 |
{
|
|
1395 |
ConvertTodoPriorityToNormalL( *entry );
|
|
1396 |
}
|
|
1397 |
|
|
1398 |
// We must re-set the method to the original value
|
|
1399 |
entry->SetMethodL( CCalEntry::EMethodNone );
|
|
1400 |
|
|
1401 |
#ifdef RD_USE_PS2_APIS
|
|
1402 |
// If source entry is a meeting request...
|
|
1403 |
if( CCalenInterimUtils2::IsMeetingRequestL( *entry ) )
|
|
1404 |
{
|
|
1405 |
// ... we need to clear all MR specific data,
|
|
1406 |
// but otherwise the enrty is now converted
|
|
1407 |
// correctly from MR to meeting
|
|
1408 |
entry->ClearMRSpecificDataL();
|
|
1409 |
}
|
|
1410 |
else
|
|
1411 |
#endif // RD_USE_PS2_APIS
|
|
1412 |
{
|
|
1413 |
// Repeating rules from memo, to-do and anniversary
|
|
1414 |
// are not compatible with a meeting
|
|
1415 |
entry->ClearRepeatingPropertiesL();
|
|
1416 |
|
|
1417 |
// Setting meeting time, since memo, to-do and anniversary
|
|
1418 |
// start / end times are not compatible with meeting's corresponding
|
|
1419 |
// values
|
|
1420 |
SetMeetingTimeL( *entry, aSourceEntry );
|
|
1421 |
|
|
1422 |
// If source is not an appointment, we'll set default
|
|
1423 |
// alarm for meeting, since memo, to-do and anniversary
|
|
1424 |
// alarms are not compatible with meeting alarm
|
|
1425 |
if( entry->AlarmL() &&
|
|
1426 |
aSourceEntry.EntryTypeL() != CCalEntry::EAppt )
|
|
1427 |
{
|
|
1428 |
SetDefaultAlarmForMeetingL( *entry );
|
|
1429 |
}
|
|
1430 |
|
|
1431 |
// If source entry is to-do, we need to convert the
|
|
1432 |
// priority from to-do priority to normal priority
|
|
1433 |
if( aSourceEntry.EntryTypeL() == CCalEntry::ETodo )
|
|
1434 |
{
|
|
1435 |
ConvertTodoPriorityToNormalL( *entry );
|
|
1436 |
}
|
|
1437 |
}
|
|
1438 |
|
|
1439 |
CleanupStack::Pop( entry ); // ownership transferred to caller
|
|
1440 |
return entry;
|
|
1441 |
}
|
|
1442 |
|
|
1443 |
// ----------------------------------------------------------------------------
|
|
1444 |
// ESMRHelper::SwitchToMRL
|
|
1445 |
// ----------------------------------------------------------------------------
|
|
1446 |
//
|
|
1447 |
CCalEntry* ESMRHelper::SwitchToMRL(
|
|
1448 |
const CCalEntry& aSourceEntry )
|
|
1449 |
{
|
|
1450 |
FUNC_LOG;
|
|
1451 |
CCalEntry* entry = CreateEntryL(
|
|
1452 |
CCalEntry::EAppt,
|
|
1453 |
aSourceEntry.UidL(),
|
|
1454 |
CCalEntry::EMethodRequest,
|
|
1455 |
CalCommon::EThisOnly );
|
|
1456 |
|
|
1457 |
CleanupStack::PushL( entry );
|
|
1458 |
|
|
1459 |
// Copy all data from existing entry to new entry
|
|
1460 |
entry->CopyFromL( aSourceEntry );
|
|
1461 |
|
|
1462 |
// If source was to-do, priority needs converting
|
|
1463 |
if( aSourceEntry.EntryTypeL() == CCalEntry::ETodo )
|
|
1464 |
{
|
|
1465 |
ConvertTodoPriorityToNormalL( *entry );
|
|
1466 |
}
|
|
1467 |
|
|
1468 |
// We must re-set the method to the original value
|
|
1469 |
entry->SetMethodL( CCalEntry::EMethodRequest );
|
|
1470 |
|
|
1471 |
// If source is a meeting...
|
|
1472 |
if( aSourceEntry.EntryTypeL() != CCalEntry::EAppt )
|
|
1473 |
{
|
|
1474 |
// Repeating rules from memo, to-do and anniversary
|
|
1475 |
// are not compatible with MR
|
|
1476 |
entry->ClearRepeatingPropertiesL();
|
|
1477 |
|
|
1478 |
// Setting meeting time, since memo, to-do and anniversary
|
|
1479 |
// start / end times are not compatible with MR's corresponding
|
|
1480 |
// values
|
|
1481 |
SetMeetingTimeL( *entry, aSourceEntry );
|
|
1482 |
|
|
1483 |
// If source is not an appointment, we'll set default
|
|
1484 |
// alarm for MR, since memo, to-do and anniversary
|
|
1485 |
// alarms are not compatible with MR alarm
|
|
1486 |
if( entry->AlarmL() &&
|
|
1487 |
aSourceEntry.EntryTypeL() != CCalEntry::EAppt )
|
|
1488 |
{
|
|
1489 |
SetDefaultAlarmForMeetingL( *entry );
|
|
1490 |
}
|
|
1491 |
|
|
1492 |
// If source entry is to-do, we need to convert the
|
|
1493 |
// priority from to-do priority to normal priority
|
|
1494 |
if( aSourceEntry.EntryTypeL() == CCalEntry::ETodo )
|
|
1495 |
{
|
|
1496 |
ConvertTodoPriorityToNormalL( *entry );
|
|
1497 |
}
|
|
1498 |
}
|
|
1499 |
|
|
1500 |
// Add organizer
|
|
1501 |
AddOrganizerL( *entry );
|
|
1502 |
|
|
1503 |
// Set organizer as phone owner
|
|
1504 |
entry->SetPhoneOwnerL( entry->OrganizerL() );
|
|
1505 |
|
|
1506 |
CleanupStack::Pop( entry ); // ownership transferred to caller
|
|
1507 |
return entry;
|
|
1508 |
}
|
|
1509 |
|
|
1510 |
// ----------------------------------------------------------------------------
|
|
1511 |
// ESMRHelper::CreateEntryL
|
|
1512 |
// ----------------------------------------------------------------------------
|
|
1513 |
//
|
|
1514 |
CCalEntry* ESMRHelper::CreateEntryL(
|
|
1515 |
CCalEntry::TType aType,
|
|
1516 |
const TDesC8& aUid,
|
|
1517 |
CCalEntry::TMethod aMethod,
|
|
1518 |
CalCommon::TRecurrenceRange aRange )
|
|
1519 |
{
|
|
1520 |
FUNC_LOG;
|
|
1521 |
|
|
1522 |
HBufC8* guid = aUid.AllocLC();
|
|
1523 |
CCalEntry* entry = CCalEntry::NewL( aType, guid, aMethod, aRange );
|
|
1524 |
CleanupStack::Pop( guid );
|
|
1525 |
|
|
1526 |
return entry;
|
|
1527 |
}
|
|
1528 |
|
|
1529 |
// ----------------------------------------------------------------------------
|
|
1530 |
// ESMRHelper::SetMeetingTimeL
|
|
1531 |
// ----------------------------------------------------------------------------
|
|
1532 |
//
|
|
1533 |
void ESMRHelper::SetMeetingTimeL(
|
|
1534 |
CCalEntry& aTargetEntry,
|
|
1535 |
const CCalEntry& aSourceEntry )
|
|
1536 |
{
|
|
1537 |
FUNC_LOG;
|
|
1538 |
TCalTime start;
|
|
1539 |
TCalTime end;
|
|
1540 |
|
|
1541 |
TDateTime tempStart;
|
|
1542 |
TDateTime tempEnd;
|
|
1543 |
|
|
1544 |
CCalEntry::TType type = aSourceEntry.EntryTypeL();
|
|
1545 |
|
|
1546 |
switch ( type )
|
|
1547 |
{
|
|
1548 |
case CCalEntry::EAppt:
|
|
1549 |
{
|
|
1550 |
start.SetTimeLocalL( aSourceEntry.StartTimeL().TimeLocalL() );
|
|
1551 |
end.SetTimeLocalL( aSourceEntry.EndTimeL().TimeLocalL() );
|
|
1552 |
break;
|
|
1553 |
}
|
|
1554 |
case CCalEntry::ETodo:
|
|
1555 |
{
|
|
1556 |
tempStart = aSourceEntry.StartTimeL().TimeLocalL().DateTime();
|
|
1557 |
tempStart.SetHour( KDefaultMeetingStartHour );
|
|
1558 |
tempStart.SetMinute( 0 );
|
|
1559 |
tempStart.SetSecond( 0 );
|
|
1560 |
|
|
1561 |
tempEnd = aSourceEntry.StartTimeL().TimeLocalL().DateTime();
|
|
1562 |
tempEnd.SetHour( KDefaultMeetingEndHour );
|
|
1563 |
tempEnd.SetMinute( 0 );
|
|
1564 |
tempEnd.SetSecond( 0 );
|
|
1565 |
|
|
1566 |
start.SetTimeLocalL( tempStart );
|
|
1567 |
end.SetTimeLocalL( tempEnd );
|
|
1568 |
break;
|
|
1569 |
}
|
|
1570 |
case CCalEntry::EEvent: //Memo
|
|
1571 |
{
|
|
1572 |
// Memo is one day event with start time as 00:00 and end as 23:59
|
|
1573 |
// Let's add start date from that, and set hour, minute and second
|
|
1574 |
// as default values
|
|
1575 |
tempStart = aSourceEntry.StartTimeL().TimeLocalL().DateTime();
|
|
1576 |
tempStart.SetHour( KDefaultMeetingStartHour );
|
|
1577 |
tempStart.SetMinute( 0 );
|
|
1578 |
tempStart.SetSecond( 0 );
|
|
1579 |
|
|
1580 |
tempEnd = aSourceEntry.StartTimeL().TimeLocalL().DateTime();
|
|
1581 |
tempEnd.SetHour( KDefaultMeetingEndHour );
|
|
1582 |
tempEnd.SetMinute( 0 );
|
|
1583 |
tempEnd.SetSecond( 0 );
|
|
1584 |
|
|
1585 |
start.SetTimeLocalL( tempStart );
|
|
1586 |
end.SetTimeLocalL( tempEnd );
|
|
1587 |
|
|
1588 |
break;
|
|
1589 |
}
|
|
1590 |
case CCalEntry::EAnniv:
|
|
1591 |
{
|
|
1592 |
// Anniversary has start date, which is taken as date of the meeting.
|
|
1593 |
// Hour, minute and second are set as teh default values.
|
|
1594 |
tempStart = aSourceEntry.StartTimeL().TimeLocalL().DateTime();
|
|
1595 |
tempStart.SetHour( KDefaultMeetingStartHour );
|
|
1596 |
tempStart.SetMinute( 0 );
|
|
1597 |
tempStart.SetSecond( 0 );
|
|
1598 |
|
|
1599 |
tempEnd = aSourceEntry.StartTimeL().TimeLocalL().DateTime();
|
|
1600 |
tempEnd.SetHour( KDefaultMeetingEndHour );
|
|
1601 |
tempEnd.SetMinute( 0 );
|
|
1602 |
tempEnd.SetSecond( 0 );
|
|
1603 |
|
|
1604 |
start.SetTimeLocalL( tempStart );
|
|
1605 |
end.SetTimeLocalL( tempEnd );
|
|
1606 |
break;
|
|
1607 |
}
|
|
1608 |
|
|
1609 |
default:
|
|
1610 |
{
|
|
1611 |
__ASSERT_DEBUG( EFalse, Panic( EInvalidEntryType ) );
|
|
1612 |
}
|
|
1613 |
}
|
|
1614 |
|
|
1615 |
aTargetEntry.SetStartAndEndTimeL( start, end );
|
|
1616 |
}
|
|
1617 |
|
|
1618 |
// ----------------------------------------------------------------------------
|
|
1619 |
// ESMRHelper::SetDefaultAlarmForMetingL
|
|
1620 |
// ----------------------------------------------------------------------------
|
|
1621 |
//
|
|
1622 |
void ESMRHelper::SetDefaultAlarmForMeetingL(
|
|
1623 |
CCalEntry& aTargetEntry )
|
|
1624 |
{
|
|
1625 |
FUNC_LOG;
|
|
1626 |
|
|
1627 |
// Get default alarm time from central repository
|
|
1628 |
TInt defaultAlarmTime;
|
|
1629 |
CRepository* repository = CRepository::NewLC( KCRUidCalendar );
|
|
1630 |
TInt err = repository->Get( KCalendarDefaultAlarmTime, defaultAlarmTime );
|
|
1631 |
CleanupStack::PopAndDestroy( repository );
|
|
1632 |
|
|
1633 |
if ( err != KErrNone )
|
|
1634 |
{
|
|
1635 |
defaultAlarmTime = KDefaultMeetingAlarmMinutes;
|
|
1636 |
}
|
|
1637 |
|
|
1638 |
// Getting current time
|
|
1639 |
TTime currentTime;
|
|
1640 |
currentTime.HomeTime();
|
|
1641 |
|
|
1642 |
// Getting meeting start time
|
|
1643 |
TTime start = aTargetEntry.StartTimeL().TimeLocalL();
|
|
1644 |
|
|
1645 |
// Create default alarm
|
|
1646 |
CCalAlarm* alarm = CCalAlarm::NewL();
|
|
1647 |
CleanupStack::PushL( alarm );
|
|
1648 |
|
|
1649 |
TTimeIntervalMinutes alarmOffset( defaultAlarmTime );
|
|
1650 |
|
|
1651 |
// If alarm time is in past
|
|
1652 |
if ( ( start - alarmOffset ) < currentTime )
|
|
1653 |
{
|
|
1654 |
// Setting alarm off
|
|
1655 |
aTargetEntry.SetAlarmL( NULL );
|
|
1656 |
}
|
|
1657 |
else
|
|
1658 |
{
|
|
1659 |
// Set default alarm time
|
|
1660 |
alarm->SetTimeOffset( alarmOffset );
|
|
1661 |
aTargetEntry.SetAlarmL( alarm );
|
|
1662 |
}
|
|
1663 |
CleanupStack::PopAndDestroy( alarm );
|
|
1664 |
|
|
1665 |
}
|
|
1666 |
|
|
1667 |
// ---------------------------------------------------------------------------
|
|
1668 |
// ESMRHelper::AddOrganizerL
|
|
1669 |
// ---------------------------------------------------------------------------
|
|
1670 |
//
|
|
1671 |
void ESMRHelper::AddOrganizerL( CCalEntry& aTargetEntry )
|
|
1672 |
{
|
|
1673 |
FUNC_LOG;
|
|
1674 |
CMRMailboxUtils* mbUtils = CMRMailboxUtils::NewL( NULL );
|
|
1675 |
CleanupStack::PushL( mbUtils );
|
|
1676 |
|
|
1677 |
CMRMailboxUtils::TMailboxInfo defaultMailBox;
|
|
1678 |
TInt err = mbUtils->GetDefaultMRMailBoxL( defaultMailBox );
|
|
1679 |
|
|
1680 |
if ( KErrNone != err )
|
|
1681 |
{
|
|
1682 |
RArray<CMRMailboxUtils::TMailboxInfo> mailBoxes;
|
|
1683 |
CleanupClosePushL( mailBoxes );
|
|
1684 |
|
|
1685 |
SupportedMailboxesL( *mbUtils, mailBoxes );
|
|
1686 |
|
|
1687 |
TInt selectedMailbox( PromptForDefaultMailboxL(mailBoxes) );
|
|
1688 |
|
|
1689 |
if ( KErrCancel != selectedMailbox )
|
|
1690 |
{
|
|
1691 |
mbUtils->SetDefaultMRMailBoxL(
|
|
1692 |
mailBoxes[selectedMailbox].iEntryId ); // codescanner::accessArrayElementWithoutCheck2
|
|
1693 |
mbUtils->GetDefaultMRMailBoxL(defaultMailBox);
|
|
1694 |
}
|
|
1695 |
CleanupStack::PopAndDestroy( &mailBoxes );
|
|
1696 |
|
|
1697 |
// This will leave if user cancelled the mailbox selection
|
|
1698 |
User::LeaveIfError( selectedMailbox );
|
|
1699 |
}
|
|
1700 |
|
|
1701 |
//Set the organizer from the selected mailbox
|
|
1702 |
CCalUser* organizer = CCalUser::NewL( defaultMailBox.iEmailAddress );
|
|
1703 |
CleanupStack::PushL( organizer );
|
|
1704 |
aTargetEntry.SetOrganizerL( organizer );
|
|
1705 |
CleanupStack::Pop( organizer ); // Ownership trasferred
|
|
1706 |
|
|
1707 |
CleanupStack::PopAndDestroy( mbUtils );
|
|
1708 |
}
|
|
1709 |
|
|
1710 |
// EOF
|
|
1711 |
|