25
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Calendar Entry wrapper implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
|
|
21 |
#include "cmrcalentry.h"
|
|
22 |
#include "esmrhelper.h"
|
|
23 |
|
|
24 |
#include "cesmrrecurrenceinfohandler.h"
|
|
25 |
#include "cesmralarminfohandler.h"
|
|
26 |
#include "tesmralarminfo.h"
|
|
27 |
#include "cesmrcaluserutil.h"
|
|
28 |
#include "cesmrcaldbmgr.h"
|
|
29 |
#include "esmrentryhelper.h"
|
|
30 |
#include "cesmrconflictchecker.h"
|
|
31 |
|
|
32 |
#include <mrcaleventdata.rsg>
|
|
33 |
#include <coemain.h>
|
|
34 |
#include <e32std.h>
|
|
35 |
#include <AknUtils.h>
|
|
36 |
#include <data_caging_path_literals.hrh>
|
|
37 |
#include <centralrepository.h>
|
|
38 |
#include <calentry.h>
|
|
39 |
#include <calattachment.h>
|
|
40 |
#include <calalarm.h>
|
|
41 |
#include <calrrule.h>
|
|
42 |
#include <calinstance.h>
|
|
43 |
#include <calinstanceview.h>
|
|
44 |
#include <CalenInterimUtils2.h>
|
|
45 |
|
|
46 |
#include <CalendarInternalCRKeys.h>
|
|
47 |
#include <ct/rcpointerarray.h>
|
|
48 |
|
|
49 |
#include <calenservices.h>
|
|
50 |
|
|
51 |
#include "emailtrace.h"
|
|
52 |
|
|
53 |
namespace { // codescanner::namespace
|
|
54 |
|
|
55 |
const TInt KHoursInDay( 24 );
|
|
56 |
const TInt KDefaultTodoAlarmHours( 12 );
|
|
57 |
const TInt KDefaultAnniversaryAlarmHours( 12 );
|
|
58 |
|
|
59 |
// Definition for max hours, minutes, seconds in day for To-Do
|
|
60 |
const TInt KMaxHoursForTodo( 23 );
|
|
61 |
const TInt KMaxMinutesForTodo( 59 );
|
|
62 |
const TInt KMaxSecondsForTodo( 00 );
|
|
63 |
|
|
64 |
// Definition for max hours, minutes, seconds in day for Memo
|
|
65 |
const TInt KMaxHoursForMemo( 23 );
|
|
66 |
const TInt KMaxMinutesForMemo( 59 );
|
|
67 |
const TInt KMaxSecondsForMemo( 59 );
|
|
68 |
|
|
69 |
// Definition for default alarm time for meeting
|
|
70 |
const TInt KDefaultMeetingAlarmMinutes( 15 );
|
|
71 |
|
|
72 |
// Definitions for alarm information resource file
|
|
73 |
_LIT( KAlarmInfoResource, "mrcaleventdata.rsc" );
|
|
74 |
|
|
75 |
#ifdef _DEBUG
|
|
76 |
|
|
77 |
// Definition for panic text
|
|
78 |
_LIT( KBCCalEntryPanicTxt, "MRCalEntry" );
|
|
79 |
|
|
80 |
enum TBCCalEntryPanic
|
|
81 |
{
|
|
82 |
EBCCalEntryNotExist = 1, // Entry does not exist
|
|
83 |
};
|
|
84 |
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
// Raises panic.
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
void Panic(TBCCalEntryPanic aPanic)
|
|
90 |
{
|
|
91 |
User::Panic( KBCCalEntryPanicTxt, aPanic);
|
|
92 |
}
|
|
93 |
|
|
94 |
#endif // _DEBUG
|
|
95 |
|
|
96 |
} // namespace
|
|
97 |
|
|
98 |
|
|
99 |
// ======== MEMBER FUNCTIONS ========
|
|
100 |
|
|
101 |
// ---------------------------------------------------------------------------
|
|
102 |
// CMRCalEntry::CMRCalEntry
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
//
|
|
105 |
CMRCalEntry::CMRCalEntry(
|
|
106 |
MESMRCalDbMgr& aCalDb )
|
|
107 |
: iCalDb( aCalDb )
|
|
108 |
{
|
|
109 |
FUNC_LOG;
|
|
110 |
}
|
|
111 |
|
|
112 |
// ---------------------------------------------------------------------------
|
|
113 |
// CMRCalEntry::~CMRCalEntry
|
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
//
|
|
116 |
CMRCalEntry::~CMRCalEntry()
|
|
117 |
{
|
|
118 |
FUNC_LOG;
|
|
119 |
delete iEntry;
|
|
120 |
delete iOriginalEntry;
|
|
121 |
delete iComparativeEntry;
|
|
122 |
}
|
|
123 |
|
|
124 |
// ---------------------------------------------------------------------------
|
|
125 |
// CMRCalEntry::NewL
|
|
126 |
// ---------------------------------------------------------------------------
|
|
127 |
//
|
|
128 |
CMRCalEntry* CMRCalEntry::NewL(
|
|
129 |
CCalEntry& aEntry,
|
|
130 |
MESMRCalDbMgr& aCalDb )
|
|
131 |
{
|
|
132 |
FUNC_LOG;
|
|
133 |
|
|
134 |
CMRCalEntry* self = new (ELeave) CMRCalEntry( aCalDb );
|
|
135 |
CleanupStack::PushL( self );
|
|
136 |
self->ConstructL( aEntry );
|
|
137 |
CleanupStack::Pop( self );
|
|
138 |
|
|
139 |
return self;
|
|
140 |
}
|
|
141 |
|
|
142 |
// ---------------------------------------------------------------------------
|
|
143 |
// CMRCalEntry::ConstructL
|
|
144 |
// ---------------------------------------------------------------------------
|
|
145 |
//
|
|
146 |
void CMRCalEntry::ConstructL(
|
|
147 |
CCalEntry& aEntry )
|
|
148 |
{
|
|
149 |
FUNC_LOG;
|
|
150 |
iOriginalEntry = CreateCopyL( aEntry );
|
|
151 |
|
|
152 |
// Create the entry for editing:
|
|
153 |
iEntry = CreateCopyL( *iOriginalEntry );
|
|
154 |
|
|
155 |
// Create copy of initialized entry for
|
|
156 |
// comparing purposes e.g. IsEntryEdited.
|
|
157 |
iComparativeEntry = CreateCopyL( *iEntry );
|
|
158 |
}
|
|
159 |
|
|
160 |
// ---------------------------------------------------------------------------
|
|
161 |
// CMRCalEntry::CreateCopyL
|
|
162 |
//
|
|
163 |
CCalEntry* CMRCalEntry::CreateCopyL( CCalEntry& aSourceEntry )
|
|
164 |
{
|
|
165 |
FUNC_LOG;
|
|
166 |
CCalEntry* entry =
|
|
167 |
ESMRHelper::CopyEntryL(
|
|
168 |
aSourceEntry,
|
|
169 |
aSourceEntry.MethodL(),
|
|
170 |
ESMRHelper::ECopyFull );
|
|
171 |
|
|
172 |
return entry;
|
|
173 |
}
|
|
174 |
|
|
175 |
// ---------------------------------------------------------------------------
|
|
176 |
// CMRCalEntry::Type
|
|
177 |
// ---------------------------------------------------------------------------
|
|
178 |
//
|
|
179 |
MESMRCalEntry::TESMRCalEntryType CMRCalEntry::Type() const
|
|
180 |
{
|
|
181 |
FUNC_LOG;
|
|
182 |
|
|
183 |
MESMRCalEntry::TESMRCalEntryType type( EESMRCalEntryNotSupported );
|
|
184 |
|
|
185 |
CCalEntry::TType entryType( CCalEntry::EAppt );
|
|
186 |
|
|
187 |
TRAP_IGNORE( {
|
|
188 |
entryType = DoGetEntry()->EntryTypeL();
|
|
189 |
} );
|
|
190 |
|
|
191 |
switch ( entryType )
|
|
192 |
{
|
|
193 |
case CCalEntry::EAppt:
|
|
194 |
{
|
|
195 |
type = EESMRCalEntryMeeting;
|
|
196 |
break;
|
|
197 |
}
|
|
198 |
case CCalEntry::ETodo:
|
|
199 |
{
|
|
200 |
type = EESMRCalEntryTodo;
|
|
201 |
break;
|
|
202 |
}
|
|
203 |
case CCalEntry::EEvent:
|
|
204 |
{
|
|
205 |
type = EESMRCalEntryMemo;
|
|
206 |
break;
|
|
207 |
}
|
|
208 |
case CCalEntry::EReminder:
|
|
209 |
{
|
|
210 |
type = EESMRCalEntryReminder;
|
|
211 |
break;
|
|
212 |
}
|
|
213 |
case CCalEntry::EAnniv:
|
|
214 |
{
|
|
215 |
type = EESMRCalEntryAnniversary;
|
|
216 |
break;
|
|
217 |
}
|
|
218 |
default:
|
|
219 |
break;
|
|
220 |
}
|
|
221 |
|
|
222 |
return type;
|
|
223 |
}
|
|
224 |
|
|
225 |
// ---------------------------------------------------------------------------
|
|
226 |
// CMRCalEntry::MESMRCalEntryRef
|
|
227 |
// ---------------------------------------------------------------------------
|
|
228 |
//
|
|
229 |
MESMRCalEntry& CMRCalEntry::MESMRCalEntryRef()
|
|
230 |
{
|
|
231 |
FUNC_LOG;
|
|
232 |
return *this;
|
|
233 |
}
|
|
234 |
|
|
235 |
// ---------------------------------------------------------------------------
|
|
236 |
// CMRCalEntry::MESMRCalEntryRef
|
|
237 |
// ---------------------------------------------------------------------------
|
|
238 |
//
|
|
239 |
const MESMRCalEntry& CMRCalEntry::MESMRCalEntryRef() const
|
|
240 |
{
|
|
241 |
FUNC_LOG;
|
|
242 |
return *this;
|
|
243 |
}
|
|
244 |
|
|
245 |
// ---------------------------------------------------------------------------
|
|
246 |
// CMRCalEntry::Entry
|
|
247 |
// ---------------------------------------------------------------------------
|
|
248 |
//
|
|
249 |
const CCalEntry& CMRCalEntry::Entry() const
|
|
250 |
{
|
|
251 |
FUNC_LOG;
|
|
252 |
return *DoGetEntry();
|
|
253 |
}
|
|
254 |
|
|
255 |
// ---------------------------------------------------------------------------
|
|
256 |
// CMRCalEntry::Entry
|
|
257 |
// ---------------------------------------------------------------------------
|
|
258 |
//
|
|
259 |
CCalEntry& CMRCalEntry::Entry()
|
|
260 |
{
|
|
261 |
FUNC_LOG;
|
|
262 |
return *DoGetEntry();
|
|
263 |
}
|
|
264 |
|
|
265 |
// ---------------------------------------------------------------------------
|
|
266 |
// CMRCalEntry::InstanceL
|
|
267 |
// ---------------------------------------------------------------------------
|
|
268 |
//
|
|
269 |
CCalInstance* CMRCalEntry::InstanceL() const
|
|
270 |
{
|
|
271 |
FUNC_LOG;
|
|
272 |
|
|
273 |
CCalInstance* instance = NULL;
|
|
274 |
|
|
275 |
instance = iCalDb.FindInstanceL( *DoGetEntry() );
|
|
276 |
if ( !instance )
|
|
277 |
{
|
|
278 |
// Instance not found by using the edited entry
|
|
279 |
// Trying with orginal.
|
|
280 |
instance = iCalDb.FindInstanceL( *iComparativeEntry );
|
|
281 |
}
|
|
282 |
|
|
283 |
if ( !instance )
|
|
284 |
{
|
|
285 |
// Instance not found by using edited or orginal entry.
|
|
286 |
// --> Leave
|
|
287 |
User::Leave( KErrNotFound );
|
|
288 |
}
|
|
289 |
|
|
290 |
return instance;
|
|
291 |
}
|
|
292 |
|
|
293 |
// ---------------------------------------------------------------------------
|
|
294 |
// CMRCalEntry::CanSetRecurrenceL
|
|
295 |
// ---------------------------------------------------------------------------
|
|
296 |
//
|
|
297 |
TBool CMRCalEntry::CanSetRecurrenceL() const
|
|
298 |
{
|
|
299 |
FUNC_LOG;
|
|
300 |
|
|
301 |
TBool canSetRecurrence( ETrue );
|
|
302 |
|
|
303 |
if ( DoGetEntry()->EntryTypeL() == CCalEntry::EAppt &&
|
|
304 |
IsRepeatingMeetingL(*iEntry) &&
|
|
305 |
(!ESMREntryHelper::IsModifyingEntryL(*iEntry) &&
|
|
306 |
MESMRCalEntry::EESMRThisOnly == iRecurrenceModRule ))
|
|
307 |
{
|
|
308 |
canSetRecurrence = EFalse;
|
|
309 |
}
|
|
310 |
|
|
311 |
return canSetRecurrence;
|
|
312 |
}
|
|
313 |
|
|
314 |
|
|
315 |
// ---------------------------------------------------------------------------
|
|
316 |
// CMRCalEntry::GetRecurrenceL
|
|
317 |
// ---------------------------------------------------------------------------
|
|
318 |
//
|
|
319 |
void CMRCalEntry::GetRecurrenceL(
|
|
320 |
TESMRRecurrenceValue& aRecurrence,
|
|
321 |
TTime& aUntil ) const
|
|
322 |
{
|
|
323 |
FUNC_LOG;
|
|
324 |
|
|
325 |
CESMRRecurrenceInfoHandler* recurrenceHandler =
|
|
326 |
CESMRRecurrenceInfoHandler::NewLC( *DoGetEntry() );
|
|
327 |
|
|
328 |
recurrenceHandler->GetRecurrenceL( aRecurrence, aUntil );
|
|
329 |
CleanupStack::PopAndDestroy( recurrenceHandler );
|
|
330 |
}
|
|
331 |
|
|
332 |
// ---------------------------------------------------------------------------
|
|
333 |
// CMRCalEntry::IsAllDayEventL
|
|
334 |
// ---------------------------------------------------------------------------
|
|
335 |
//
|
|
336 |
TBool CMRCalEntry::IsAllDayEventL() const
|
|
337 |
{
|
|
338 |
FUNC_LOG;
|
|
339 |
|
|
340 |
TBool allDayEvent(EFalse);
|
|
341 |
|
|
342 |
CCalEntry::TType entryType = DoGetEntry()->EntryTypeL();
|
|
343 |
|
|
344 |
if ( (CCalEntry::EAppt == entryType) ||
|
|
345 |
(CCalEntry::EEvent == entryType) )
|
|
346 |
{
|
|
347 |
TCalTime startTime = iEntry->StartTimeL();
|
|
348 |
TCalTime stopTime = iEntry->EndTimeL();
|
|
349 |
|
|
350 |
TTimeIntervalHours hoursBetweenStartAndEnd;
|
|
351 |
stopTime.TimeLocalL().HoursFrom(
|
|
352 |
startTime.TimeLocalL(),
|
|
353 |
hoursBetweenStartAndEnd );
|
|
354 |
|
|
355 |
TCalTime::TTimeMode mode = startTime.TimeMode();
|
|
356 |
|
|
357 |
TInt hoursBetweenStartAndEndAsInt( hoursBetweenStartAndEnd.Int() );
|
|
358 |
TInt alldayDivident( hoursBetweenStartAndEndAsInt % KHoursInDay );
|
|
359 |
|
|
360 |
if ( hoursBetweenStartAndEndAsInt && 0 == alldayDivident )
|
|
361 |
{
|
|
362 |
TDateTime startTimeLocal = startTime.TimeLocalL().DateTime();
|
|
363 |
TDateTime stopTimeLocal = stopTime.TimeLocalL().DateTime();
|
|
364 |
|
|
365 |
if ( startTimeLocal.Hour() == 0 &&
|
|
366 |
startTimeLocal.Minute() == 0 &&
|
|
367 |
startTimeLocal.Minute() == stopTimeLocal.Minute() &&
|
|
368 |
startTimeLocal.Second() == 0 &&
|
|
369 |
startTimeLocal.Second() == stopTimeLocal.Second() )
|
|
370 |
{
|
|
371 |
allDayEvent = ETrue;
|
|
372 |
}
|
|
373 |
}
|
|
374 |
}
|
|
375 |
|
|
376 |
return allDayEvent;
|
|
377 |
}
|
|
378 |
|
|
379 |
// ---------------------------------------------------------------------------
|
|
380 |
// CMRCalEntry::SetRecurrenceL
|
|
381 |
// ---------------------------------------------------------------------------
|
|
382 |
//
|
|
383 |
void CMRCalEntry::SetRecurrenceL(
|
|
384 |
TESMRRecurrenceValue aRecurrence,
|
|
385 |
TTime aUntil )
|
|
386 |
{
|
|
387 |
FUNC_LOG;
|
|
388 |
// Check if this entry's recurrence can be edited
|
|
389 |
|
|
390 |
if ( !CanSetRecurrenceL() )
|
|
391 |
{
|
|
392 |
User::Leave( KErrNotSupported );
|
|
393 |
}
|
|
394 |
|
|
395 |
CESMRRecurrenceInfoHandler* recurrenceHandler =
|
|
396 |
CESMRRecurrenceInfoHandler::NewLC( *DoGetEntry() );
|
|
397 |
|
|
398 |
recurrenceHandler->SetRecurrenceL( aRecurrence, aUntil );
|
|
399 |
CleanupStack::PopAndDestroy( recurrenceHandler );
|
|
400 |
|
|
401 |
iRecurrenceModRule = MESMRCalEntry::EESMRAllInSeries;
|
|
402 |
}
|
|
403 |
|
|
404 |
// ---------------------------------------------------------------------------
|
|
405 |
// CMRCalEntry::SetAllDayEventL
|
|
406 |
// ---------------------------------------------------------------------------
|
|
407 |
//
|
|
408 |
void CMRCalEntry::SetAllDayEventL( TTime aStartDate, TTime aEndDate)
|
|
409 |
{
|
|
410 |
FUNC_LOG;
|
|
411 |
TCalTime startTime;
|
|
412 |
TCalTime stopTime;
|
|
413 |
|
|
414 |
TDateTime start;
|
|
415 |
TDateTime end;
|
|
416 |
|
|
417 |
// set the start time to 0:00
|
|
418 |
start.Set( aStartDate.DateTime().Year(),
|
|
419 |
aStartDate.DateTime().Month(),
|
|
420 |
aStartDate.DateTime().Day(),
|
|
421 |
0,
|
|
422 |
0,
|
|
423 |
0,
|
|
424 |
0);
|
|
425 |
|
|
426 |
// set the end date to next day from given end date since
|
|
427 |
// all day event should last 24 hours.
|
|
428 |
aEndDate += TTimeIntervalDays( 1 );
|
|
429 |
|
|
430 |
end.Set( aEndDate.DateTime().Year(),
|
|
431 |
aEndDate.DateTime().Month(),
|
|
432 |
aEndDate.DateTime().Day(),
|
|
433 |
0,
|
|
434 |
0,
|
|
435 |
0,
|
|
436 |
0);
|
|
437 |
|
|
438 |
startTime.SetTimeLocalL( start );
|
|
439 |
stopTime.SetTimeLocalL( end );
|
|
440 |
|
|
441 |
DoGetEntry()->SetStartAndEndTimeL( startTime, stopTime );
|
|
442 |
}
|
|
443 |
|
|
444 |
// ---------------------------------------------------------------------------
|
|
445 |
// CMRCalEntry::IsStoredL
|
|
446 |
// ---------------------------------------------------------------------------
|
|
447 |
//
|
|
448 |
TBool CMRCalEntry::IsStoredL() const
|
|
449 |
{
|
|
450 |
FUNC_LOG;
|
|
451 |
|
|
452 |
__ASSERT_DEBUG( iEntry, Panic(EBCCalEntryNotExist ) );
|
|
453 |
|
|
454 |
TBool ret(EFalse);
|
|
455 |
CCalEntry* dbEntry = NULL;
|
|
456 |
|
|
457 |
TRAPD( err, dbEntry = iCalDb.FetchEntryL(
|
|
458 |
iEntry->UidL(),
|
|
459 |
iEntry->RecurrenceIdL() ) );
|
|
460 |
|
|
461 |
if ( KErrNotFound == err )
|
|
462 |
{
|
|
463 |
// Error has occured while retrieving an entry
|
|
464 |
ret = EFalse;
|
|
465 |
}
|
|
466 |
else if ( dbEntry)
|
|
467 |
{
|
|
468 |
// Entry was found from the calendar db --> it is stored for sure.
|
|
469 |
ret = ETrue;
|
|
470 |
}
|
|
471 |
|
|
472 |
delete dbEntry;
|
|
473 |
|
|
474 |
return ret;
|
|
475 |
}
|
|
476 |
|
|
477 |
// ---------------------------------------------------------------------------
|
|
478 |
// CMRCalEntry::IsEntryEditedL
|
|
479 |
// ---------------------------------------------------------------------------
|
|
480 |
//
|
|
481 |
TBool CMRCalEntry::IsEntryEditedL() const
|
|
482 |
{
|
|
483 |
FUNC_LOG;
|
|
484 |
|
|
485 |
TBool isSame(ETrue);
|
|
486 |
|
|
487 |
// The compare entry has not been created yet; so
|
|
488 |
// entry has not changed.
|
|
489 |
if ( iComparativeEntry )
|
|
490 |
{
|
|
491 |
isSame = iComparativeEntry->CompareL( *DoGetEntry() );
|
|
492 |
|
|
493 |
// CCalEntry's CompareL doesn't check the priority value:
|
|
494 |
if ( isSame && iEntry->PriorityL() != iComparativeEntry->PriorityL() )
|
|
495 |
{
|
|
496 |
isSame = EFalse;
|
|
497 |
}
|
|
498 |
else if ( iEntry->DescriptionL() != iComparativeEntry->DescriptionL() )
|
|
499 |
{
|
|
500 |
isSame = EFalse;
|
|
501 |
}
|
|
502 |
else if ( iEntry->LocationL() != iComparativeEntry->LocationL() )
|
|
503 |
{
|
|
504 |
isSame = EFalse;
|
|
505 |
}
|
|
506 |
else if ( iEntry->ReplicationStatusL() != iComparativeEntry->ReplicationStatusL() )
|
|
507 |
{
|
|
508 |
isSame = EFalse;
|
|
509 |
}
|
|
510 |
|
|
511 |
if ( IsStoredL() )
|
|
512 |
if ( iCalDb.EntryViewL( *iEntry ) != iCalDb.EntryView() )
|
|
513 |
{
|
|
514 |
isSame = EFalse;
|
|
515 |
}
|
|
516 |
}
|
|
517 |
|
|
518 |
|
|
519 |
|
|
520 |
return !isSame;
|
|
521 |
}
|
|
522 |
|
|
523 |
// ---------------------------------------------------------------------------
|
|
524 |
// CMRCalEntry::IsRecurrentEventL
|
|
525 |
// ---------------------------------------------------------------------------
|
|
526 |
//
|
|
527 |
TBool CMRCalEntry::IsRecurrentEventL() const
|
|
528 |
{
|
|
529 |
FUNC_LOG;
|
|
530 |
if ( DoGetEntry()->EntryTypeL() != CCalEntry::EAppt )
|
|
531 |
{
|
|
532 |
return EFalse;
|
|
533 |
}
|
|
534 |
|
|
535 |
TBool recurrenceEvent( EFalse );
|
|
536 |
if ( IsStoredL() )
|
|
537 |
{
|
|
538 |
// Entry is stored in calendar db
|
|
539 |
// Lets look recurrence using instance
|
|
540 |
|
|
541 |
// Ownership is transferred
|
|
542 |
CCalInstance* instance = NULL;
|
|
543 |
TRAPD(err, instance = InstanceL() );
|
|
544 |
if ( KErrNotFound != err )
|
|
545 |
{
|
|
546 |
User::LeaveIfError( err );
|
|
547 |
}
|
|
548 |
|
|
549 |
if ( instance )
|
|
550 |
{
|
|
551 |
CleanupStack::PushL( instance );
|
|
552 |
|
|
553 |
CCalEntry& instanceParentEntry = instance->Entry();
|
|
554 |
|
|
555 |
if ( IsRepeatingMeetingL( instanceParentEntry ) )
|
|
556 |
{
|
|
557 |
recurrenceEvent = ETrue;
|
|
558 |
}
|
|
559 |
CleanupStack::PopAndDestroy( instance );
|
|
560 |
}
|
|
561 |
else
|
|
562 |
{
|
|
563 |
if ( IsRepeatingMeetingL( *iEntry ) )
|
|
564 |
{
|
|
565 |
recurrenceEvent = ETrue;
|
|
566 |
}
|
|
567 |
}
|
|
568 |
}
|
|
569 |
else
|
|
570 |
{
|
|
571 |
// Entry is not stored in calendar db
|
|
572 |
if ( IsRepeatingMeetingL( *iEntry ) )
|
|
573 |
{
|
|
574 |
// This is repeating meeting
|
|
575 |
recurrenceEvent = ETrue;
|
|
576 |
}
|
|
577 |
}
|
|
578 |
|
|
579 |
return recurrenceEvent;
|
|
580 |
}
|
|
581 |
|
|
582 |
// ---------------------------------------------------------------------------
|
|
583 |
// CMRCalEntry::IsEntryTypeChangedL
|
|
584 |
// ---------------------------------------------------------------------------
|
|
585 |
//
|
|
586 |
TBool CMRCalEntry::IsEntryTypeChangedL() const
|
|
587 |
{
|
|
588 |
FUNC_LOG;
|
|
589 |
|
|
590 |
return iTypeChanged;
|
|
591 |
}
|
|
592 |
|
|
593 |
// ---------------------------------------------------------------------------
|
|
594 |
// CMRCalEntry::SetModifyingRuleL
|
|
595 |
// ---------------------------------------------------------------------------
|
|
596 |
//
|
|
597 |
void CMRCalEntry::SetModifyingRuleL( TESMRRecurrenceModifyingRule aRule,
|
|
598 |
const TBool aTypeChanging )
|
|
599 |
{
|
|
600 |
FUNC_LOG;
|
|
601 |
|
|
602 |
CESMRRecurrenceInfoHandler* recHandler =
|
|
603 |
CESMRRecurrenceInfoHandler::NewL( *iComparativeEntry );
|
|
604 |
CleanupStack::PushL( recHandler );
|
|
605 |
|
|
606 |
TESMRRecurrenceValue orginalRecurrence;
|
|
607 |
TTime orginalUntil;
|
|
608 |
|
|
609 |
recHandler->GetRecurrenceL(
|
|
610 |
orginalRecurrence,
|
|
611 |
orginalUntil);
|
|
612 |
CleanupStack::PopAndDestroy( recHandler );
|
|
613 |
recHandler = NULL;
|
|
614 |
|
|
615 |
TBool modifyingEntry( ESMREntryHelper::IsModifyingEntryL( *DoGetEntry() ) );
|
|
616 |
|
|
617 |
if ( MESMRCalEntry::EESMRAllInSeries == aRule && IsStoredL() && !aTypeChanging)
|
|
618 |
{
|
|
619 |
// When we want to modify series of recurrence entries -->
|
|
620 |
// Parent entry is modified
|
|
621 |
if ( ERecurrenceNot == orginalRecurrence && !modifyingEntry )
|
|
622 |
{
|
|
623 |
// Orginal entry was not recurrent event
|
|
624 |
// No need to fect instance at all
|
|
625 |
// For modifying entries we need to fetch the original parent entry
|
|
626 |
iRecurrenceModRule = aRule;
|
|
627 |
return;
|
|
628 |
}
|
|
629 |
|
|
630 |
CCalInstance* instance = NULL;
|
|
631 |
TRAPD(err, instance = InstanceL() );
|
|
632 |
if( KErrNotFound != err )
|
|
633 |
{
|
|
634 |
User::LeaveIfError( err );
|
|
635 |
}
|
|
636 |
|
|
637 |
if ( instance )
|
|
638 |
{
|
|
639 |
CleanupStack::PushL( instance );
|
|
640 |
|
|
641 |
CCalEntry::TMethod entryMethod( iEntry->MethodL() );
|
|
642 |
|
|
643 |
delete iEntry;
|
|
644 |
iEntry = NULL;
|
|
645 |
|
|
646 |
delete iComparativeEntry;
|
|
647 |
iComparativeEntry = NULL;
|
|
648 |
|
|
649 |
RCPointerArray<CCalEntry> entries;
|
|
650 |
CleanupClosePushL( entries );
|
|
651 |
|
|
652 |
iCalDb.EntryViewL( instance->Entry() )->FetchL(
|
|
653 |
instance->Entry().UidL(), entries );
|
|
654 |
|
|
655 |
TInt parentIndex( KErrNotFound );
|
|
656 |
TInt entryCount( entries.Count() );
|
|
657 |
for ( TInt i(0); i < entryCount && KErrNotFound == parentIndex; ++i )
|
|
658 |
{
|
|
659 |
TBool modifyingEntry( ESMREntryHelper::IsModifyingEntryL( *entries[i]) );
|
|
660 |
if ( !modifyingEntry )
|
|
661 |
{
|
|
662 |
parentIndex = i;
|
|
663 |
}
|
|
664 |
}
|
|
665 |
|
|
666 |
CCalEntry& parent = *entries[parentIndex];
|
|
667 |
|
|
668 |
TPtrC description( parent.DescriptionL() );
|
|
669 |
|
|
670 |
iEntry = CreateCopyL( parent );
|
|
671 |
|
|
672 |
// Adjust parent entry's start and end time to entry
|
|
673 |
TCalTime start;
|
|
674 |
TCalTime end;
|
|
675 |
|
|
676 |
CESMRRecurrenceInfoHandler* recurrenceHandler =
|
|
677 |
CESMRRecurrenceInfoHandler::NewLC( parent );
|
|
678 |
|
|
679 |
recurrenceHandler->GetFirstInstanceTimeL( start, end );
|
|
680 |
CleanupStack::PopAndDestroy( recurrenceHandler );
|
|
681 |
recurrenceHandler = NULL;
|
|
682 |
|
|
683 |
iEntry->SetStartAndEndTimeL( start, end );
|
|
684 |
|
|
685 |
iComparativeEntry = CreateCopyL( *iEntry );
|
|
686 |
|
|
687 |
iEntry->SetDescriptionL( description );
|
|
688 |
iComparativeEntry->SetDescriptionL( description );
|
|
689 |
|
|
690 |
CleanupStack::PopAndDestroy(); // entries
|
|
691 |
CleanupStack::PopAndDestroy( instance );
|
|
692 |
}
|
|
693 |
}
|
|
694 |
else if ( ERecurrenceNot != orginalRecurrence &&
|
|
695 |
aTypeChanging && !modifyingEntry )
|
|
696 |
{
|
|
697 |
// if entry( in the memory) is a recurrent event
|
|
698 |
// ,and if entry type is changing, and not in modifying status then EESMRAllInSeries
|
|
699 |
iRecurrenceModRule = EESMRAllInSeries ;
|
|
700 |
return;
|
|
701 |
}
|
|
702 |
|
|
703 |
|
|
704 |
iRecurrenceModRule = aRule;
|
|
705 |
}
|
|
706 |
|
|
707 |
// ---------------------------------------------------------------------------
|
|
708 |
// CMRCalEntry::RecurrenceModRule
|
|
709 |
// ---------------------------------------------------------------------------
|
|
710 |
//
|
|
711 |
MESMRCalEntry::TESMRRecurrenceModifyingRule
|
|
712 |
CMRCalEntry::RecurrenceModRule() const
|
|
713 |
{
|
|
714 |
FUNC_LOG;
|
|
715 |
return iRecurrenceModRule;
|
|
716 |
}
|
|
717 |
|
|
718 |
// ---------------------------------------------------------------------------
|
|
719 |
// CMRCalEntry::GetAlarmL
|
|
720 |
// ---------------------------------------------------------------------------
|
|
721 |
//
|
|
722 |
void CMRCalEntry::GetAlarmL(TESMRAlarmType& aAlarmType, TTime &aAlarmTime )
|
|
723 |
{
|
|
724 |
FUNC_LOG;
|
|
725 |
|
|
726 |
aAlarmType = MESMRCalEntry::EESMRAlarmNotFound;
|
|
727 |
aAlarmTime = Time::NullTTime();
|
|
728 |
|
|
729 |
TFileName alarmInfoResource;
|
|
730 |
ESMRHelper::LocateResourceFile(
|
|
731 |
KAlarmInfoResource,
|
|
732 |
KDC_RESOURCE_FILES_DIR,
|
|
733 |
alarmInfoResource);
|
|
734 |
|
|
735 |
CESMRAlarmInfoHandler* alarmInfoHandler =
|
|
736 |
CESMRAlarmInfoHandler::NewLC();
|
|
737 |
|
|
738 |
alarmInfoHandler->ReadFromResourceL(
|
|
739 |
alarmInfoResource,
|
|
740 |
MRCALEVENT_ALARM_INFO_TABLE );
|
|
741 |
|
|
742 |
TRAPD( err,
|
|
743 |
alarmInfoHandler->GetAbsoluteAlarmTimeL(*DoGetEntry(), aAlarmTime) );
|
|
744 |
|
|
745 |
if ( KErrNone == err )
|
|
746 |
{
|
|
747 |
aAlarmType = MESMRCalEntry::EESMRAlarmAbsolute;
|
|
748 |
|
|
749 |
// only meeting that is not allday event can have relative alarm:
|
|
750 |
if ( Type() == EESMRCalEntryMeeting && !IsAllDayEventL() )
|
|
751 |
{
|
|
752 |
TESMRAlarmInfo alarmInfo;
|
|
753 |
TRAP( err,
|
|
754 |
alarmInfoHandler->GetAlarmInfoObjectL(*iEntry, alarmInfo) );
|
|
755 |
|
|
756 |
if ( KErrNone == err )
|
|
757 |
{
|
|
758 |
aAlarmType = MESMRCalEntry::EESMRAlarmRelative;
|
|
759 |
if( alarmInfo.iRelativeAlarmInSeconds < 0 )
|
|
760 |
{
|
|
761 |
aAlarmType = MESMRCalEntry::EESMRAlarmNotFound;
|
|
762 |
}
|
|
763 |
}
|
|
764 |
}
|
|
765 |
}
|
|
766 |
|
|
767 |
CleanupStack::PopAndDestroy( alarmInfoHandler );
|
|
768 |
alarmInfoHandler = NULL;
|
|
769 |
}
|
|
770 |
|
|
771 |
// ---------------------------------------------------------------------------
|
|
772 |
// CMRCalEntry::OriginalEntry
|
|
773 |
// ---------------------------------------------------------------------------
|
|
774 |
//
|
|
775 |
const CCalEntry& CMRCalEntry::OriginalEntry()
|
|
776 |
{
|
|
777 |
FUNC_LOG;
|
|
778 |
return *iComparativeEntry;
|
|
779 |
}
|
|
780 |
|
|
781 |
|
|
782 |
|
|
783 |
// ----------------------------------------------------------------------------
|
|
784 |
// CMRCalEntry::IsRepeatingMeetingL
|
|
785 |
// ----------------------------------------------------------------------------
|
|
786 |
//
|
|
787 |
TBool CMRCalEntry::IsRepeatingMeetingL(const CCalEntry& aEntry) const
|
|
788 |
{
|
|
789 |
FUNC_LOG;
|
|
790 |
TBool retVal( EFalse );
|
|
791 |
|
|
792 |
if ( ESMREntryHelper::IsModifyingEntryL(aEntry) )
|
|
793 |
{
|
|
794 |
retVal = ETrue;
|
|
795 |
}
|
|
796 |
else
|
|
797 |
{
|
|
798 |
TCalRRule dummyRule;
|
|
799 |
if ( aEntry.GetRRuleL( dummyRule ) )
|
|
800 |
{
|
|
801 |
retVal = ETrue;
|
|
802 |
}
|
|
803 |
else
|
|
804 |
{
|
|
805 |
RArray<TCalTime> dummyRDateList;
|
|
806 |
CleanupClosePushL( dummyRDateList );
|
|
807 |
aEntry.GetRDatesL( dummyRDateList );
|
|
808 |
if ( dummyRDateList.Count() > 0 )
|
|
809 |
{
|
|
810 |
retVal = ETrue;
|
|
811 |
}
|
|
812 |
CleanupStack::PopAndDestroy(); // dummyRDateList
|
|
813 |
}
|
|
814 |
}
|
|
815 |
|
|
816 |
return retVal;
|
|
817 |
}
|
|
818 |
|
|
819 |
// ---------------------------------------------------------------------------
|
|
820 |
// CMRCalEntry::SetPriorityL
|
|
821 |
// ---------------------------------------------------------------------------
|
|
822 |
//
|
|
823 |
void CMRCalEntry::SetPriorityL ( TUint aPriority )
|
|
824 |
{
|
|
825 |
FUNC_LOG;
|
|
826 |
DoGetEntry()->SetPriorityL( aPriority );
|
|
827 |
}
|
|
828 |
|
|
829 |
// ---------------------------------------------------------------------------
|
|
830 |
// CESMRMeetingRequestEntry::GetPriorityL
|
|
831 |
// ---------------------------------------------------------------------------
|
|
832 |
//
|
|
833 |
TUint CMRCalEntry::GetPriorityL() const
|
|
834 |
{
|
|
835 |
FUNC_LOG;
|
|
836 |
TUint entryPriority = DoGetEntry()->PriorityL();
|
|
837 |
|
|
838 |
if ( iEntry->EntryTypeL() == CCalEntry::ETodo )
|
|
839 |
{
|
|
840 |
if ( entryPriority != EFSCalenTodoPriorityLow &&
|
|
841 |
entryPriority != EFSCalenTodoPriorityNormal &&
|
|
842 |
entryPriority != EFSCalenTodoPriorityHigh )
|
|
843 |
{
|
|
844 |
entryPriority = EFSCalenTodoPriorityNormal;
|
|
845 |
}
|
|
846 |
}
|
|
847 |
else
|
|
848 |
{
|
|
849 |
if ( entryPriority != EFSCalenMRPriorityLow &&
|
|
850 |
entryPriority != EFSCalenMRPriorityNormal &&
|
|
851 |
entryPriority != EFSCalenMRPriorityHigh )
|
|
852 |
{
|
|
853 |
entryPriority = EFSCalenMRPriorityNormal;
|
|
854 |
}
|
|
855 |
}
|
|
856 |
|
|
857 |
return entryPriority;
|
|
858 |
}
|
|
859 |
|
|
860 |
// ----------------------------------------------------------------------------
|
|
861 |
// CMRCalEntry::UpdateEntryAfterStoringL
|
|
862 |
// ----------------------------------------------------------------------------
|
|
863 |
//
|
|
864 |
void CMRCalEntry::UpdateEntryAfterStoringL()
|
|
865 |
{
|
|
866 |
FUNC_LOG;
|
|
867 |
|
|
868 |
__ASSERT_DEBUG( iEntry, Panic( EBCCalEntryNotExist ) );
|
|
869 |
|
|
870 |
CCalEntry* storedEntry = NULL;
|
|
871 |
|
|
872 |
if ( IsRecurrentEventL() &&
|
|
873 |
EESMRThisOnly == iRecurrenceModRule &&
|
|
874 |
IsStoredL() && !ESMREntryHelper::IsModifyingEntryL(*iEntry) )
|
|
875 |
{
|
|
876 |
// We have stored one instance of series.
|
|
877 |
storedEntry = iCalDb.FetchEntryL(
|
|
878 |
iEntry->UidL(),
|
|
879 |
iComparativeEntry->StartTimeL() );
|
|
880 |
}
|
|
881 |
else
|
|
882 |
{
|
|
883 |
// We are dealing with single instance or with the series
|
|
884 |
storedEntry = iCalDb.FetchEntryL(
|
|
885 |
iEntry->UidL(),
|
|
886 |
iEntry->RecurrenceIdL() );
|
|
887 |
}
|
|
888 |
|
|
889 |
__ASSERT_DEBUG( storedEntry, Panic( EBCCalEntryNotExist ) );
|
|
890 |
CleanupStack::PushL( storedEntry );
|
|
891 |
|
|
892 |
// Description needs to be fecthed explicitly into memory
|
|
893 |
TPtrC description( storedEntry->DescriptionL() );
|
|
894 |
|
|
895 |
delete iEntry;
|
|
896 |
iEntry = NULL;
|
|
897 |
iEntry = CreateCopyL(*storedEntry);
|
|
898 |
|
|
899 |
if ( MESMRCalEntry::EESMRAllInSeries == iRecurrenceModRule &&
|
|
900 |
IsRecurrentEventL() )
|
|
901 |
{
|
|
902 |
// Adjust parent entry's start and end time to entry
|
|
903 |
TCalTime start;
|
|
904 |
TCalTime end;
|
|
905 |
|
|
906 |
CESMRRecurrenceInfoHandler* recurrenceHandler =
|
|
907 |
CESMRRecurrenceInfoHandler::NewLC( *iEntry );
|
|
908 |
|
|
909 |
recurrenceHandler->GetFirstInstanceTimeL( start, end );
|
|
910 |
CleanupStack::PopAndDestroy( recurrenceHandler );
|
|
911 |
recurrenceHandler = NULL;
|
|
912 |
|
|
913 |
iEntry->SetStartAndEndTimeL( start, end );
|
|
914 |
iEntry->SetDescriptionL( description );
|
|
915 |
}
|
|
916 |
|
|
917 |
CCalEntry* temp = CreateCopyL( *iEntry );
|
|
918 |
|
|
919 |
delete iComparativeEntry;
|
|
920 |
iComparativeEntry = temp;
|
|
921 |
|
|
922 |
CleanupStack::PopAndDestroy( storedEntry );
|
|
923 |
}
|
|
924 |
|
|
925 |
// ---------------------------------------------------------------------------
|
|
926 |
// CMRCalEntry::SetDefaultValuesToEntryL
|
|
927 |
// ---------------------------------------------------------------------------
|
|
928 |
//
|
|
929 |
void CMRCalEntry::SetDefaultValuesToEntryL()
|
|
930 |
{
|
|
931 |
FUNC_LOG;
|
|
932 |
|
|
933 |
if ( !IsStoredL() )
|
|
934 |
{
|
|
935 |
// by default when creating a meeting the priority
|
|
936 |
// value is normal
|
|
937 |
switch ( DoGetEntry()->EntryTypeL() )
|
|
938 |
{
|
|
939 |
case CCalEntry::ETodo:
|
|
940 |
{
|
|
941 |
SetDefaultValuesForTodoL();
|
|
942 |
}
|
|
943 |
break;
|
|
944 |
case CCalEntry::EEvent: // Memo
|
|
945 |
{
|
|
946 |
SetDefaultValuesForMemoL();
|
|
947 |
}
|
|
948 |
break;
|
|
949 |
case CCalEntry::EAppt:
|
|
950 |
{
|
|
951 |
SetDefaultValuesForMeetingL();
|
|
952 |
}
|
|
953 |
break;
|
|
954 |
case CCalEntry::EAnniv:
|
|
955 |
default:
|
|
956 |
{
|
|
957 |
SetDefaultValuesForAnniversaryL();
|
|
958 |
}
|
|
959 |
break;
|
|
960 |
}
|
|
961 |
iEntry->SetReplicationStatusL( CCalEntry::EOpen );
|
|
962 |
|
|
963 |
// Entry has now been set up with default values;
|
|
964 |
// Let's update comparative entry
|
|
965 |
delete iComparativeEntry;
|
|
966 |
iComparativeEntry = NULL;
|
|
967 |
|
|
968 |
iComparativeEntry = CreateCopyL( *iEntry );
|
|
969 |
}
|
|
970 |
}
|
|
971 |
|
|
972 |
// ---------------------------------------------------------------------------
|
|
973 |
// CMRCalEntry::UpdateTimeStampL
|
|
974 |
// ---------------------------------------------------------------------------
|
|
975 |
//
|
|
976 |
void CMRCalEntry::UpdateTimeStampL()
|
|
977 |
{
|
|
978 |
FUNC_LOG;
|
|
979 |
|
|
980 |
ASSERT( iEntry );
|
|
981 |
|
|
982 |
TTime currentUTCTime;
|
|
983 |
currentUTCTime.UniversalTime();
|
|
984 |
|
|
985 |
TCalTime currentTime;
|
|
986 |
currentTime.SetTimeUtcL( currentUTCTime );
|
|
987 |
|
|
988 |
iEntry->SetDTStampL( currentTime );
|
|
989 |
}
|
|
990 |
|
|
991 |
// ----------------------------------------------------------------------------
|
|
992 |
// CMRCalEntry::CloneEntryLC
|
|
993 |
// ----------------------------------------------------------------------------
|
|
994 |
//
|
|
995 |
CCalEntry* CMRCalEntry::CloneEntryLC( TESMRCalEntryType aType ) const
|
|
996 |
{
|
|
997 |
CCalEntry* entry = ESMRHelper::CopyEntryLC(
|
|
998 |
*DoGetEntry(),
|
|
999 |
iEntry->MethodL(),
|
|
1000 |
ESMRHelper::ECopyFull,
|
|
1001 |
TESMRCalendarEventType( aType ) );
|
|
1002 |
|
|
1003 |
return entry;
|
|
1004 |
}
|
|
1005 |
|
|
1006 |
// ----------------------------------------------------------------------------
|
|
1007 |
// CMRCalEntry::UpdateComparativeEntry
|
|
1008 |
// ----------------------------------------------------------------------------
|
|
1009 |
//
|
|
1010 |
void CMRCalEntry::UpdateComparativeEntry( CCalEntry* aNewComparativeEntry )
|
|
1011 |
{
|
|
1012 |
FUNC_LOG;
|
|
1013 |
if( iComparativeEntry )
|
|
1014 |
{
|
|
1015 |
delete iComparativeEntry;
|
|
1016 |
iComparativeEntry = NULL;
|
|
1017 |
|
|
1018 |
iComparativeEntry = aNewComparativeEntry;
|
|
1019 |
}
|
|
1020 |
|
|
1021 |
}
|
|
1022 |
|
|
1023 |
// ----------------------------------------------------------------------------
|
|
1024 |
// CMRCalEntry::SetDefaultValuesForTodoL
|
|
1025 |
// ----------------------------------------------------------------------------
|
|
1026 |
//
|
|
1027 |
void CMRCalEntry::SetDefaultValuesForTodoL()
|
|
1028 |
{
|
|
1029 |
FUNC_LOG;
|
|
1030 |
|
|
1031 |
SetPriorityL( EFSCalenTodoPriorityNormal );
|
|
1032 |
|
|
1033 |
// Update event time
|
|
1034 |
TDateTime start = iEntry->StartTimeL().TimeLocalL().DateTime();
|
|
1035 |
start.SetHour( KMaxHoursForTodo );
|
|
1036 |
start.SetMinute( KMaxMinutesForTodo );
|
|
1037 |
start.SetSecond( KMaxSecondsForTodo );
|
|
1038 |
|
|
1039 |
TCalTime dueTime;
|
|
1040 |
dueTime.SetTimeLocalL( start );
|
|
1041 |
iEntry->SetStartAndEndTimeL( dueTime, dueTime );
|
|
1042 |
|
|
1043 |
// Create default alarm
|
|
1044 |
TTime eventTime = iEntry->EndTimeL().TimeLocalL();
|
|
1045 |
|
|
1046 |
// Calculate alarm time (due date at 12:00am)
|
|
1047 |
TTime alarmTime = eventTime;
|
|
1048 |
TDateTime alarmDateTime = alarmTime.DateTime();
|
|
1049 |
alarmDateTime.SetHour( KDefaultTodoAlarmHours );
|
|
1050 |
alarmDateTime.SetMinute( 0 );
|
|
1051 |
alarmDateTime.SetSecond( 0 );
|
|
1052 |
alarmDateTime.SetMicroSecond( 0 );
|
|
1053 |
alarmTime = alarmDateTime;
|
|
1054 |
|
|
1055 |
TTime currentTime;
|
|
1056 |
currentTime.HomeTime();
|
|
1057 |
|
|
1058 |
if ( alarmTime > currentTime )
|
|
1059 |
{
|
|
1060 |
CCalAlarm* alarm = CCalAlarm::NewL();
|
|
1061 |
CleanupStack::PushL( alarm );
|
|
1062 |
TTimeIntervalMinutes alarmOffset( 0 );
|
|
1063 |
eventTime.MinutesFrom( alarmTime, alarmOffset );
|
|
1064 |
alarm->SetTimeOffset( alarmOffset );
|
|
1065 |
iEntry->SetAlarmL( alarm );
|
|
1066 |
CleanupStack::PopAndDestroy( alarm );
|
|
1067 |
}
|
|
1068 |
}
|
|
1069 |
|
|
1070 |
// ----------------------------------------------------------------------------
|
|
1071 |
// CMRCalEntry::SetDefaultValuesForMemoL
|
|
1072 |
// ----------------------------------------------------------------------------
|
|
1073 |
//
|
|
1074 |
void CMRCalEntry::SetDefaultValuesForMemoL()
|
|
1075 |
{
|
|
1076 |
FUNC_LOG;
|
|
1077 |
|
|
1078 |
SetPriorityL( EFSCalenMRPriorityNormal );
|
|
1079 |
|
|
1080 |
// Update event time
|
|
1081 |
TDateTime start = iEntry->StartTimeL().TimeLocalL().DateTime();
|
|
1082 |
start.SetHour( 0 );
|
|
1083 |
start.SetMinute( 0 );
|
|
1084 |
start.SetSecond( 0 );
|
|
1085 |
|
|
1086 |
TDateTime end = iEntry->EndTimeL().TimeLocalL().DateTime();
|
|
1087 |
end.SetHour( KMaxHoursForMemo );
|
|
1088 |
end.SetMinute( KMaxMinutesForMemo );
|
|
1089 |
end.SetSecond( KMaxSecondsForMemo );
|
|
1090 |
|
|
1091 |
TCalTime startTime;
|
|
1092 |
startTime.SetTimeLocalL( start );
|
|
1093 |
TCalTime endTime;
|
|
1094 |
endTime.SetTimeLocalL( end );
|
|
1095 |
|
|
1096 |
iEntry->SetStartAndEndTimeL( startTime, endTime );
|
|
1097 |
}
|
|
1098 |
|
|
1099 |
// ----------------------------------------------------------------------------
|
|
1100 |
// CMRCalEntry::SetDefaultValuesForMeetingL
|
|
1101 |
// ----------------------------------------------------------------------------
|
|
1102 |
//
|
|
1103 |
void CMRCalEntry::SetDefaultValuesForMeetingL()
|
|
1104 |
{
|
|
1105 |
FUNC_LOG;
|
|
1106 |
|
|
1107 |
SetPriorityL( EFSCalenMRPriorityNormal );
|
|
1108 |
|
|
1109 |
// Get default alarm time from central repository
|
|
1110 |
TInt defaultAlarmTime;
|
|
1111 |
CRepository* repository = CRepository::NewLC( TUid::Uid(0x101F874B) /*KCRUidCalendar*/ );
|
|
1112 |
TInt err = repository->Get( KCalendarDefaultAlarmTime, defaultAlarmTime );
|
|
1113 |
CleanupStack::PopAndDestroy( repository );
|
|
1114 |
|
|
1115 |
if ( err != KErrNone )
|
|
1116 |
{
|
|
1117 |
defaultAlarmTime = KDefaultMeetingAlarmMinutes;
|
|
1118 |
}
|
|
1119 |
|
|
1120 |
// Getting current time
|
|
1121 |
TTime currentTime;
|
|
1122 |
currentTime.HomeTime();
|
|
1123 |
|
|
1124 |
// Getting meeting start time
|
|
1125 |
TTime start = iEntry->StartTimeL().TimeLocalL();
|
|
1126 |
|
|
1127 |
// Create default alarm
|
|
1128 |
CCalAlarm* alarm = CCalAlarm::NewL();
|
|
1129 |
CleanupStack::PushL( alarm );
|
|
1130 |
|
|
1131 |
TTimeIntervalMinutes alarmOffset( defaultAlarmTime );
|
|
1132 |
|
|
1133 |
// If alarm time is in past
|
|
1134 |
if ( ( start - alarmOffset ) < currentTime )
|
|
1135 |
{
|
|
1136 |
// Setting alarm off
|
|
1137 |
iEntry->SetAlarmL( NULL );
|
|
1138 |
}
|
|
1139 |
else
|
|
1140 |
{
|
|
1141 |
// Set default alarm time
|
|
1142 |
alarm->SetTimeOffset( alarmOffset );
|
|
1143 |
iEntry->SetAlarmL( alarm );
|
|
1144 |
}
|
|
1145 |
CleanupStack::PopAndDestroy( alarm );
|
|
1146 |
|
|
1147 |
if ( iEntry->StartTimeL().TimeUtcL() == iEntry->EndTimeL().TimeUtcL() )
|
|
1148 |
{
|
|
1149 |
// Should this value be read from cenrep?
|
|
1150 |
TTimeIntervalHours KDefaultMeetingDuration(1);
|
|
1151 |
|
|
1152 |
TCalTime newEndTime;
|
|
1153 |
newEndTime.SetTimeUtcL(
|
|
1154 |
iEntry->StartTimeL().TimeUtcL() + KDefaultMeetingDuration );
|
|
1155 |
iEntry->SetStartAndEndTimeL(iEntry->StartTimeL(), newEndTime);
|
|
1156 |
}
|
|
1157 |
}
|
|
1158 |
|
|
1159 |
// ----------------------------------------------------------------------------
|
|
1160 |
// CMRCalEntry::SetDefaultValuesForAnniversaryL
|
|
1161 |
// ----------------------------------------------------------------------------
|
|
1162 |
//
|
|
1163 |
void CMRCalEntry::SetDefaultValuesForAnniversaryL()
|
|
1164 |
{
|
|
1165 |
FUNC_LOG;
|
|
1166 |
|
|
1167 |
SetPriorityL( EFSCalenMRPriorityNormal );
|
|
1168 |
|
|
1169 |
// Getting event time
|
|
1170 |
TTime eventTime = iEntry->StartTimeL().TimeLocalL();
|
|
1171 |
|
|
1172 |
// Setting default alarm parameters to previous day at noon
|
|
1173 |
TTime alarmTime = eventTime - TTimeIntervalDays( 1 );
|
|
1174 |
TDateTime alarmDateTime = alarmTime.DateTime();
|
|
1175 |
alarmDateTime.SetHour( KDefaultAnniversaryAlarmHours );
|
|
1176 |
alarmDateTime.SetMinute( 0 );
|
|
1177 |
alarmDateTime.SetSecond( 0 );
|
|
1178 |
alarmDateTime.SetMicroSecond( 0 );
|
|
1179 |
alarmTime = alarmDateTime;
|
|
1180 |
|
|
1181 |
// Calculating alarm offset
|
|
1182 |
TTimeIntervalMinutes alarmOffset( 0 );
|
|
1183 |
eventTime.MinutesFrom( alarmTime, alarmOffset );
|
|
1184 |
|
|
1185 |
// Creating alarm
|
|
1186 |
CCalAlarm* alarm = CCalAlarm::NewL();
|
|
1187 |
CleanupStack::PushL( alarm );
|
|
1188 |
alarm->SetTimeOffset( alarmOffset );
|
|
1189 |
|
|
1190 |
// Setting alarm
|
|
1191 |
iEntry->SetAlarmL( alarm );
|
|
1192 |
CleanupStack::PopAndDestroy( alarm );
|
|
1193 |
alarm = NULL;
|
|
1194 |
}
|
|
1195 |
|
|
1196 |
// ----------------------------------------------------------------------------
|
|
1197 |
// CMRCalEntry::DoGetEntry
|
|
1198 |
// ----------------------------------------------------------------------------
|
|
1199 |
//
|
|
1200 |
CCalEntry* CMRCalEntry::DoGetEntry() const
|
|
1201 |
{
|
|
1202 |
__ASSERT_DEBUG( iEntry, Panic( EBCCalEntryNotExist ) );
|
|
1203 |
|
|
1204 |
return iEntry;
|
|
1205 |
}
|
|
1206 |
|
|
1207 |
// ----------------------------------------------------------------------------
|
|
1208 |
// CMRCalEntry::ValidateEntryL
|
|
1209 |
// ----------------------------------------------------------------------------
|
|
1210 |
//
|
|
1211 |
CCalEntry* CMRCalEntry::ValidateEntryL()
|
|
1212 |
{
|
|
1213 |
FUNC_LOG;
|
|
1214 |
|
|
1215 |
CCalEntry* entry = NULL;
|
|
1216 |
|
|
1217 |
MESMRCalEntry::TESMRCalEntryType entryType = Type();
|
|
1218 |
switch ( entryType )
|
|
1219 |
{
|
|
1220 |
case EESMRCalEntryMeeting:
|
|
1221 |
{
|
|
1222 |
entry = ValidateMeetingL();
|
|
1223 |
}
|
|
1224 |
break;
|
|
1225 |
|
|
1226 |
case EESMRCalEntryAnniversary:
|
|
1227 |
{
|
|
1228 |
entry = CreateCopyL( *iEntry );
|
|
1229 |
CleanupStack::PushL( entry );
|
|
1230 |
|
|
1231 |
// Special check for anniversary: Occurancy must be set to yearly
|
|
1232 |
// for new entries
|
|
1233 |
if ( ( entry->EntryTypeL() == CCalEntry::EAnniv ) &&
|
|
1234 |
!IsStoredL() &&
|
|
1235 |
!IsRecurrentEventL() )
|
|
1236 |
{
|
|
1237 |
TCalRRule rrule( TCalRRule::EYearly );
|
|
1238 |
rrule.SetDtStart( Entry().StartTimeL() );
|
|
1239 |
rrule.SetInterval( 1 );
|
|
1240 |
rrule.SetCount( 0 );
|
|
1241 |
entry->SetRRuleL( rrule );
|
|
1242 |
}
|
|
1243 |
|
|
1244 |
CleanupStack::Pop( entry ); //Ownership given to caller
|
|
1245 |
}
|
|
1246 |
break;
|
|
1247 |
|
|
1248 |
case EESMRCalEntryTodo: // flow through
|
|
1249 |
case EESMRCalEntryMemo: // flow through
|
|
1250 |
case EESMRCalEntryReminder:
|
|
1251 |
{
|
|
1252 |
entry = CreateCopyL( *iEntry );
|
|
1253 |
}
|
|
1254 |
break;
|
|
1255 |
default:
|
|
1256 |
// This should not occur
|
|
1257 |
User::Leave( KErrArgument );
|
|
1258 |
break;
|
|
1259 |
}
|
|
1260 |
|
|
1261 |
return entry;
|
|
1262 |
}
|
|
1263 |
|
|
1264 |
// ---------------------------------------------------------------------------
|
|
1265 |
// CMRCalEntry::RemoveInstanceFromSeriesL
|
|
1266 |
// ---------------------------------------------------------------------------
|
|
1267 |
//
|
|
1268 |
CCalEntry* CMRCalEntry::RemoveInstanceFromSeriesL()
|
|
1269 |
{
|
|
1270 |
FUNC_LOG;
|
|
1271 |
|
|
1272 |
CCalEntry* retEntry = NULL;
|
|
1273 |
|
|
1274 |
if ( IsRecurrentEventL() &&
|
|
1275 |
EESMRThisOnly == iRecurrenceModRule )
|
|
1276 |
{
|
|
1277 |
CCalInstance* instance = NULL;
|
|
1278 |
TRAPD( err, instance = InstanceL() );
|
|
1279 |
if( KErrNotFound != err )
|
|
1280 |
{
|
|
1281 |
User::LeaveIfError( err );
|
|
1282 |
}
|
|
1283 |
|
|
1284 |
if ( instance )
|
|
1285 |
{
|
|
1286 |
CleanupStack::PushL( instance );
|
|
1287 |
|
|
1288 |
CCalEntry& parentEntry = instance->Entry();
|
|
1289 |
retEntry = ESMRHelper::CopyEntryL(
|
|
1290 |
parentEntry,
|
|
1291 |
parentEntry.MethodL(),
|
|
1292 |
ESMRHelper::ECopyFull );
|
|
1293 |
|
|
1294 |
CleanupStack::PopAndDestroy( instance );
|
|
1295 |
instance = NULL;
|
|
1296 |
|
|
1297 |
CleanupStack::PushL( retEntry );
|
|
1298 |
|
|
1299 |
CESMRRecurrenceInfoHandler* recurrenceHandler =
|
|
1300 |
CESMRRecurrenceInfoHandler::NewLC( *retEntry );
|
|
1301 |
|
|
1302 |
TCalTime orginalInstanceTime;
|
|
1303 |
orginalInstanceTime.SetTimeUtcL(
|
|
1304 |
iEntry->StartTimeL().TimeUtcL() );
|
|
1305 |
|
|
1306 |
recurrenceHandler->RemoveInstanceL( orginalInstanceTime );
|
|
1307 |
|
|
1308 |
CleanupStack::PopAndDestroy( recurrenceHandler );
|
|
1309 |
CleanupStack::Pop( retEntry );
|
|
1310 |
}
|
|
1311 |
}
|
|
1312 |
else
|
|
1313 |
{
|
|
1314 |
User::Leave( KErrNotSupported );
|
|
1315 |
}
|
|
1316 |
|
|
1317 |
return retEntry;
|
|
1318 |
}
|
|
1319 |
|
|
1320 |
// ---------------------------------------------------------------------------
|
|
1321 |
// CMRCalEntry::GetDBMgr
|
|
1322 |
// ---------------------------------------------------------------------------
|
|
1323 |
//
|
|
1324 |
MESMRCalDbMgr& CMRCalEntry::GetDBMgr()
|
|
1325 |
{
|
|
1326 |
return iCalDb;
|
|
1327 |
}
|
|
1328 |
|
|
1329 |
|
|
1330 |
// ---------------------------------------------------------------------------
|
|
1331 |
// CMRCalEntry::SupportsCapabilityL
|
|
1332 |
// ---------------------------------------------------------------------------
|
|
1333 |
//
|
|
1334 |
TBool CMRCalEntry::SupportsCapabilityL(
|
|
1335 |
MESMRCalEntry::TMREntryCapability aCapability ) const
|
|
1336 |
{
|
|
1337 |
FUNC_LOG;
|
|
1338 |
|
|
1339 |
TBool retValue( EFalse );
|
|
1340 |
|
|
1341 |
if ( aCapability == MESMRCalEntry::EMRCapabilityAttachments )
|
|
1342 |
{
|
|
1343 |
retValue = ETrue;
|
|
1344 |
}
|
|
1345 |
|
|
1346 |
return retValue;
|
|
1347 |
}
|
|
1348 |
|
|
1349 |
// ---------------------------------------------------------------------------
|
|
1350 |
// CMRCalEntry::ContainsRemoteAttachmentsL
|
|
1351 |
// ---------------------------------------------------------------------------
|
|
1352 |
//
|
|
1353 |
TBool CMRCalEntry::ContainsRemoteAttachmentsL()
|
|
1354 |
{
|
|
1355 |
FUNC_LOG;
|
|
1356 |
|
|
1357 |
TBool retValue( EFalse );
|
|
1358 |
|
|
1359 |
TInt attachmentCount( iEntry->AttachmentCountL() );
|
|
1360 |
|
|
1361 |
for ( TInt i(0); i < attachmentCount && !retValue; ++i )
|
|
1362 |
{
|
|
1363 |
CCalAttachment* attachment = iEntry->AttachmentL(i);
|
|
1364 |
CCalAttachment::TType type( attachment->Type() );
|
|
1365 |
|
|
1366 |
if ( CCalAttachment::EFile != type )
|
|
1367 |
{
|
|
1368 |
retValue = ETrue;
|
|
1369 |
}
|
|
1370 |
}
|
|
1371 |
|
|
1372 |
return retValue;
|
|
1373 |
}
|
|
1374 |
|
|
1375 |
// ---------------------------------------------------------------------------
|
|
1376 |
// CMRCalEntry::ValidateMeetingL
|
|
1377 |
// ---------------------------------------------------------------------------
|
|
1378 |
//
|
|
1379 |
CCalEntry* CMRCalEntry::ValidateMeetingL()
|
|
1380 |
{
|
|
1381 |
FUNC_LOG;
|
|
1382 |
|
|
1383 |
CCalEntry* entry = NULL;
|
|
1384 |
|
|
1385 |
if ( IsRecurrentEventL() &&
|
|
1386 |
EESMRThisOnly == iRecurrenceModRule &&
|
|
1387 |
IsStoredL() &&
|
|
1388 |
!ESMREntryHelper::IsModifyingEntryL( *iEntry ) )
|
|
1389 |
{
|
|
1390 |
CCalInstance* instance = NULL;
|
|
1391 |
TRAPD( err, instance = InstanceL() );
|
|
1392 |
if( KErrNotFound != err )
|
|
1393 |
{
|
|
1394 |
User::LeaveIfError( err );
|
|
1395 |
}
|
|
1396 |
|
|
1397 |
if ( instance )
|
|
1398 |
{
|
|
1399 |
|
|
1400 |
CleanupStack::PushL( instance );
|
|
1401 |
CCalEntry& parent = instance->Entry();
|
|
1402 |
|
|
1403 |
entry = iCalDb.FetchEntryL(
|
|
1404 |
parent.UidL(),
|
|
1405 |
iComparativeEntry->StartTimeL() );
|
|
1406 |
|
|
1407 |
if ( !entry )
|
|
1408 |
{
|
|
1409 |
|
|
1410 |
// copy global UID from the original entry
|
|
1411 |
HBufC8* guid = parent.UidL().AllocLC();
|
|
1412 |
|
|
1413 |
// create new (child) entry
|
|
1414 |
entry = CCalEntry::NewL(
|
|
1415 |
parent.EntryTypeL(),
|
|
1416 |
guid,
|
|
1417 |
parent.MethodL(),
|
|
1418 |
0,
|
|
1419 |
iComparativeEntry->StartTimeL(),
|
|
1420 |
CalCommon::EThisOnly );
|
|
1421 |
|
|
1422 |
CleanupStack::Pop( guid );
|
|
1423 |
guid = NULL; // ownership transferred
|
|
1424 |
}
|
|
1425 |
|
|
1426 |
CleanupStack::PopAndDestroy( instance );
|
|
1427 |
instance = NULL; // instance
|
|
1428 |
CleanupStack::PushL( entry );
|
|
1429 |
|
|
1430 |
|
|
1431 |
CCalEntry::TMethod method( iEntry->MethodL() );
|
|
1432 |
|
|
1433 |
entry->CopyFromL( *iEntry, CCalEntry::EDontCopyId );
|
|
1434 |
entry->SetSequenceNumberL( 0 );
|
|
1435 |
entry->SetMethodL( method );
|
|
1436 |
entry->SetSummaryL( iEntry->SummaryL() );
|
|
1437 |
entry->SetLocalUidL( TCalLocalUid( 0 ) );
|
|
1438 |
entry->ClearRepeatingPropertiesL();
|
|
1439 |
|
|
1440 |
CleanupStack::Pop( entry );
|
|
1441 |
}
|
|
1442 |
}
|
|
1443 |
|
|
1444 |
if ( !entry )
|
|
1445 |
{
|
|
1446 |
entry = CreateCopyL( *iEntry );
|
|
1447 |
}
|
|
1448 |
|
|
1449 |
return entry;
|
|
1450 |
}
|
|
1451 |
|
|
1452 |
// ---------------------------------------------------------------------------
|
|
1453 |
// CMRCalEntry::SetTypeChanged
|
|
1454 |
// ---------------------------------------------------------------------------
|
|
1455 |
//
|
|
1456 |
void CMRCalEntry::SetTypeChanged( TBool aTypeChanged )
|
|
1457 |
{
|
|
1458 |
FUNC_LOG;
|
|
1459 |
|
|
1460 |
iTypeChanged = aTypeChanged;
|
|
1461 |
}
|
|
1462 |
|
|
1463 |
// ---------------------------------------------------------------------------
|
|
1464 |
// CMRCalEntry::AnyInstancesBetweenTimePeriodL
|
|
1465 |
// ---------------------------------------------------------------------------
|
|
1466 |
//
|
|
1467 |
TBool CMRCalEntry::AnyInstancesBetweenTimePeriodL(
|
|
1468 |
TTime& aStart,
|
|
1469 |
TTime& aEnd )
|
|
1470 |
{
|
|
1471 |
FUNC_LOG;
|
|
1472 |
|
|
1473 |
__ASSERT_DEBUG( iEntry, Panic( EBCCalEntryNotExist ) );
|
|
1474 |
|
|
1475 |
TBool retValue( EFalse );
|
|
1476 |
|
|
1477 |
RCPointerArray<CCalEntry> entries;
|
|
1478 |
CleanupClosePushL( entries );
|
|
1479 |
|
|
1480 |
CESMRConflictChecker* conflictCheckker =
|
|
1481 |
CESMRConflictChecker::NewL( iCalDb );
|
|
1482 |
CleanupStack::PushL( conflictCheckker );
|
|
1483 |
|
|
1484 |
CCalInstance* instance = InstanceL();
|
|
1485 |
CleanupStack::PushL( instance );
|
|
1486 |
|
|
1487 |
TCalCollectionId colId = instance->InstanceIdL().iCollectionId;
|
|
1488 |
CleanupStack::PopAndDestroy( instance );
|
|
1489 |
|
|
1490 |
conflictCheckker->FindInstancesForEntryL( aStart,
|
|
1491 |
aEnd,
|
|
1492 |
*iEntry,
|
|
1493 |
colId,
|
|
1494 |
entries );
|
|
1495 |
|
|
1496 |
if ( entries.Count() )
|
|
1497 |
{
|
|
1498 |
retValue = ETrue;
|
|
1499 |
}
|
|
1500 |
|
|
1501 |
CleanupStack::PopAndDestroy( conflictCheckker );
|
|
1502 |
CleanupStack::PopAndDestroy(); // entries
|
|
1503 |
|
|
1504 |
return retValue;
|
|
1505 |
}
|
|
1506 |
|
|
1507 |
// ---------------------------------------------------------------------------
|
|
1508 |
// CMRCalEntry::GetFirstInstanceStartAndEndTimeL
|
|
1509 |
// ---------------------------------------------------------------------------
|
|
1510 |
//
|
|
1511 |
void CMRCalEntry::GetFirstInstanceStartAndEndTimeL(
|
|
1512 |
TTime& aStart,
|
|
1513 |
TTime& aEnd )
|
|
1514 |
{
|
|
1515 |
FUNC_LOG;
|
|
1516 |
|
|
1517 |
__ASSERT_DEBUG( iEntry, Panic( EBCCalEntryNotExist ) );
|
|
1518 |
|
|
1519 |
// This fetches the parent entry
|
|
1520 |
TCalTime recurrenceId;
|
|
1521 |
recurrenceId.SetTimeLocalL( Time::NullTTime() );
|
|
1522 |
CCalEntry* parent = iCalDb.FetchEntryL(
|
|
1523 |
iEntry->UidL(),
|
|
1524 |
recurrenceId );
|
|
1525 |
|
|
1526 |
CleanupStack::PushL( parent );
|
|
1527 |
|
|
1528 |
aStart = parent->StartTimeL().TimeLocalL();
|
|
1529 |
aEnd = parent->EndTimeL().TimeLocalL();
|
|
1530 |
|
|
1531 |
CleanupStack::PopAndDestroy( parent );
|
|
1532 |
}
|
|
1533 |
|
|
1534 |
// EOF
|