author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 12:11:35 +0300 | |
branch | RCL_3 |
changeset 78 | 356f28cd5ca0 |
parent 66 | bd7edf625bdd |
child 86 | ed599363c2d7 |
permissions | -rw-r--r-- |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
66 | 14 |
* Description: Global Data for Calendar application |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
|
66 | 19 |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
//debug |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include "calendarui_debug.h" |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
// INCLUDE FILES |
66 | 24 |
#include "calenglobaldata.h" // CCalenGlobalData |
25 |
#include "RImplInfoPtrArrayOwn.inl" // Wrapper class with array deletion on close |
|
26 |
#include "calensend.h" // CCalenSend |
|
27 |
#include "CalenInterimUtils2.h" // CalenInterimUtils |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
#include "calencontextimpl.h" // Calendar context implementation |
66 | 29 |
#include "calenfilemapping.h" |
30 |
#include "missedalarmstore.h" |
|
31 |
#include "CleanupResetAndDestroy.h" |
|
32 |
#include "calendar.hrh" |
|
33 |
||
34 |
#include <Calendar.rsg> // Calendar resources |
|
35 |
#include <cmrmailboxutils.h> // CMRMailboxUtils |
|
36 |
#include <utf.h> // CnvUtfConverter |
|
37 |
#include <StringLoader.h> // Loads strings from resource files |
|
38 |
#include <featmgr.h> // Feature discovery API |
|
39 |
#include <calsession.h> // Calendar database session |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
#include <calinstanceview.h> // Calendar Instance view |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
#include <calentryview.h> // Calendar Entry view |
66 | 42 |
#include <cmrmailboxutils.h> // CMRMailboxUtils |
43 |
#include <calencommands.hrh> // Calendar commands |
|
44 |
#include <aknlists.h> |
|
45 |
#include <aknPopup.h> |
|
46 |
#include <AknUtils.h> |
|
47 |
#include <AknQueryDialog.h> |
|
48 |
#include <calencontext.h> |
|
49 |
#include <calcalendarinfo.h> |
|
50 |
#include <calcalendariterator.h> |
|
51 |
#include <CalendarInternalCRKeys.h> |
|
52 |
#include <calenmulticalutil.h> |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
|
66 | 54 |
#include <bautils.h> |
55 |
#include <calensvrmissedalarmmanagerresource.rsg> |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
// Default Calendar database path |
66 | 57 |
_LIT( KCalendarDatabaseFilePath, "c:calendar" ); |
58 |
_LIT( KPhoneCalendar,"Personal" ); |
|
59 |
_LIT( KExtCalendar,"Ext calendar" ); |
|
60 |
const TInt KBuffLength = 24; |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
|
21
9711e452b5e9
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
62 |
|
66 | 63 |
_LIT(KPersonal,"Personal"); |
64 |
||
65 |
_LIT( KMissedAlarmResourceFile, "z:\\resource\\CalenSvrMissedAlarmManagerResource.rsc"); // changes done |
|
66 |
||
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
67 |
// ============================ MEMBER FUNCTIONS =============================== |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
69 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
70 |
// CCalenGlobalData::CCalenGlobalData |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
71 |
// C++ default constructor can NOT contain any code, that might leave. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
72 |
// (other items were commented in a header). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
74 |
// |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
75 |
CCalenGlobalData::CCalenGlobalData( MCalProgressCallBack& aCalCallBack ) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
76 |
: iCalCallBack( aCalCallBack ) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
77 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
78 |
TRACE_ENTRY_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
79 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
iGlobalDataOwnsCalSession = EFalse; |
66 | 81 |
iGlobalDataOwnsEntryView = EFalse; |
82 |
||
83 |
iCalendarForcedExit = EFalse; |
|
84 |
||
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
85 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
86 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
87 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
88 |
// ---------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
89 |
// CCalenGlobalData::NewL |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
90 |
// Two phased construction. This will leave if an instance of global data |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
// already exists. All access to an instance of the global data should be |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
92 |
// through the InstanceL function, except for the initial construction |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
93 |
// which should be handled by the controller. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
94 |
// (other items were commented in a header). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
95 |
// ---------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
96 |
// |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
97 |
EXPORT_C CCalenGlobalData* CCalenGlobalData::NewL( MCalProgressCallBack& aCalCallBack, |
66 | 98 |
MCalenContextChangeObserver* aNotifier, |
99 |
MCalenDBChangeObserver* aDBNotifier) |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
100 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
101 |
TRACE_ENTRY_POINT; |
66 | 102 |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
103 |
CCalenGlobalData* self = NULL; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
104 |
TAny* tlsPtr = Dll::Tls(); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
105 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
106 |
// Check Thread local storage |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
107 |
if (!tlsPtr) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
108 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
109 |
// TLS is NULL, so no CCalenGlobalData has been created yet. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
110 |
self = new( ELeave ) CCalenGlobalData( aCalCallBack ); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
111 |
CleanupStack::PushL( self ); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
112 |
// Store a self pointer in TLS |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
113 |
User::LeaveIfError( Dll::SetTls( static_cast<TAny*>( self ) ) ); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
114 |
// Increment ref count right away. If we don't do it here, and someone |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
115 |
// calls CCalenGlobalData::InstanceL in ConstructL and then ConstructL |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
116 |
// leaves, we will double delete the global data. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
117 |
++self->iRefCount; |
66 | 118 |
self->ConstructL( aNotifier, aDBNotifier ); |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
119 |
CleanupStack::Pop( self ); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
120 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
121 |
else |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
122 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
123 |
// An instance of the global data exists already. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
124 |
// This function should only have been called once, by CCalenAppUi |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
125 |
User::Leave( KErrAlreadyExists ); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
126 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
127 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
128 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
129 |
return self; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
130 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
131 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
132 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
133 |
// CCalenGlobalData::InstanceL |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
134 |
// Two-phased constructor. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
135 |
// (other items were commented in a header). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
136 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
137 |
EXPORT_C CCalenGlobalData* CCalenGlobalData::InstanceL() |
66 | 138 |
{ |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
139 |
TRACE_ENTRY_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
140 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
141 |
CCalenGlobalData* self = NULL; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
142 |
TAny* tlsPtr = Dll::Tls(); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
143 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
144 |
// Check Thread local storage |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
145 |
if (!tlsPtr) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
146 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
147 |
// The global data has not yet been constructed. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
148 |
// FIXME - Revise comment |
66 | 149 |
//TLS is NULL, so no CCalenGlobalData has been created yet. |
150 |
/* self = new( ELeave ) CCalenGlobalData; |
|
151 |
CleanupStack::PushL( self ); |
|
152 |
self->ConstructL(); |
|
153 |
//Store a self pointer in TLS |
|
154 |
User::LeaveIfError( Dll::SetTls(static_cast<TAny*>(self))); |
|
155 |
CleanupStack::Pop(self);*/ |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
156 |
User::Leave( KErrNotReady ); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
157 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
158 |
else |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
159 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
160 |
self = static_cast<CCalenGlobalData*>( tlsPtr ); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
161 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
162 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
163 |
++self->iRefCount; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
164 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
165 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
166 |
return self; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
167 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
168 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
169 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
170 |
// CCalenGlobalData::InstanceL |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
171 |
// Two-phased constructor. Creates the CCalenGlobalData with an existing |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
172 |
// CCalSession. CCalenGlobalData does NOT take ownership of the passed session |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
173 |
// The caller is responsible for ensuring that the session exists until all |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
174 |
// open references to the CCalenGlobalData are released. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
175 |
// Calls User::Invariant() if CCalenGlobalData already has a valid session. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
176 |
// (other items were commented in a header). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
177 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
178 |
EXPORT_C CCalenGlobalData* CCalenGlobalData::InstanceL(CCalSession& aSession) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
179 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
180 |
TRACE_ENTRY_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
181 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
182 |
CCalenGlobalData* self = CCalenGlobalData::InstanceL(); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
183 |
CleanupStack::PushL(self); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
184 |
self->SetSessionL(&aSession); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
185 |
CleanupStack::Pop(self); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
186 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
187 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
188 |
return self; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
189 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
190 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
191 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
192 |
// CCalenGlobalData::InstanceL |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
193 |
// Non-leaving version of constructor. Returns an instance of |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
194 |
// CCalenGlobalData if one exists or NULL otherwise |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
195 |
// (other items were commented in a header). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
196 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
197 |
EXPORT_C CCalenGlobalData* CCalenGlobalData::Instance() |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
198 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
199 |
TRACE_ENTRY_POINT; |
66 | 200 |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
201 |
TAny* tlsPtr = Dll::Tls(); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
202 |
CCalenGlobalData* self = static_cast<CCalenGlobalData*>( tlsPtr ); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
203 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
204 |
if ( self ) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
205 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
206 |
++self->iRefCount; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
207 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
208 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
209 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
210 |
return self; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
211 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
212 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
213 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
214 |
// CCalenGlobalData::ConstructL |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
215 |
// Symbian 2nd phase constructor can leave. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
216 |
// (other items were commented in a header). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
217 |
// ----------------------------------------------------------------------------- |
66 | 218 |
void CCalenGlobalData::ConstructL( MCalenContextChangeObserver* aNotifier, |
219 |
MCalenDBChangeObserver* aDBNotifier) |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
220 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
221 |
TRACE_ENTRY_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
222 |
|
66 | 223 |
iContext = new (ELeave ) CCalenContextImpl( aNotifier ); |
224 |
||
225 |
iNewInstanceViewCreation = NULL; |
|
226 |
||
227 |
iDBChangeNotifier = aDBNotifier; |
|
228 |
||
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
229 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
230 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
231 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
232 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
233 |
// CCalenGlobalData::SetSessionL |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
234 |
// Sets the CCalenGlobalData to use an externally created CCalSession. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
235 |
// Leaves with KErrAlreadyExists if a session has already been created by the |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
236 |
// CCalenGlobalData |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
237 |
// (other items were commented in a header). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
238 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
239 |
void CCalenGlobalData::SetSessionL(CCalSession* aSession) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
240 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
241 |
TRACE_ENTRY_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
242 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
243 |
if (iCalSession) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
244 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
245 |
__ASSERT_ALWAYS(iCalSession == aSession, User::Leave(KErrAlreadyExists)); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
246 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
247 |
else |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
248 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
249 |
iGlobalDataOwnsCalSession = EFalse; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
250 |
iCalSession = aSession; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
251 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
252 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
253 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
254 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
255 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
256 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
257 |
// CCalenGlobalData::Release |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
258 |
// Release handle to CCalenGlobalData. If no other objects are referencing |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
259 |
// this class it will be deleted |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
260 |
// (other items were commented in a header). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
261 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
262 |
EXPORT_C void CCalenGlobalData::Release() |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
263 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
264 |
TRACE_ENTRY_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
265 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
266 |
--iRefCount; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
267 |
if (iRefCount == 0) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
268 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
269 |
delete this; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
270 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
271 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
272 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
273 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
274 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
275 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
276 |
// Destructor |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
277 |
// This is private and should only be called from the Release() function above |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
278 |
// (other items were commented in a header). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
279 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
280 |
CCalenGlobalData::~CCalenGlobalData() |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
281 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
282 |
TRACE_ENTRY_POINT; |
66 | 283 |
|
284 |
delete iSend; |
|
285 |
delete iInterimUtils; |
|
286 |
delete iUtilsAs; |
|
287 |
delete iMailboxUtils; |
|
288 |
delete iMRUtils; |
|
289 |
||
290 |
if (iInstanceView) |
|
291 |
{ |
|
292 |
delete iInstanceView; |
|
293 |
iInstanceView = NULL; |
|
294 |
} |
|
295 |
||
296 |
if (iInstanceViewCreation) |
|
297 |
{ |
|
298 |
delete iInstanceViewCreation; |
|
299 |
iInstanceViewCreation = NULL; |
|
300 |
} |
|
301 |
||
302 |
if (iEntryViewCreation) |
|
303 |
{ |
|
304 |
delete iEntryViewCreation; |
|
305 |
iEntryViewCreation = NULL; |
|
306 |
} |
|
65
12af337248b1
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
307 |
|
66 | 308 |
if (iNewInstanceView) |
309 |
{ |
|
310 |
delete iNewInstanceView; |
|
311 |
iNewInstanceView = NULL; |
|
312 |
iNewInstanceViewCreation = NULL; |
|
313 |
} |
|
314 |
||
315 |
if (iNewInstanceViewCreation) |
|
316 |
{ |
|
317 |
delete iNewInstanceViewCreation; |
|
318 |
iNewInstanceViewCreation = NULL; |
|
319 |
} |
|
320 |
||
65
12af337248b1
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
321 |
delete iContext; |
66 | 322 |
|
323 |
if(iGlobalDataOwnsEntryView) |
|
324 |
{ |
|
325 |
if(iEntryView) |
|
326 |
{ |
|
327 |
delete iEntryView; |
|
328 |
iEntryView = NULL; |
|
329 |
} |
|
330 |
} |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
331 |
|
66 | 332 |
if (iGlobalDataOwnsCalSession) |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
333 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
334 |
delete iCalSession; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
335 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
336 |
|
66 | 337 |
if (iCalendarInfoList.Count()) |
338 |
{ |
|
339 |
iCalendarInfoList.ResetAndDestroy(); |
|
340 |
} |
|
341 |
||
342 |
if( iFileMappingArray.Count() ) |
|
343 |
{ |
|
344 |
iFileMappingArray.ResetAndDestroy(); |
|
345 |
} |
|
65
12af337248b1
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
346 |
|
66 | 347 |
iKeyQueue.Reset(); |
348 |
||
349 |
iHashDbidIndexMap.Close(); |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
350 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
351 |
Dll::SetTls(NULL); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
352 |
|
66 | 353 |
if (iCalendarsSession) |
354 |
{ |
|
355 |
delete iCalendarsSession; |
|
356 |
iCalendarsSession = NULL; |
|
357 |
} |
|
358 |
||
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
359 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
360 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
361 |
|
66 | 362 |
// ----------------------------------------------------------------------------- |
363 |
// CCalenGlobalData::MailboxUtilsL |
|
364 |
// Create MailBoxUtils if necessary and returns a reference |
|
365 |
// (other items were commented in a header). |
|
366 |
// ----------------------------------------------------------------------------- |
|
367 |
EXPORT_C CMRMailboxUtils& CCalenGlobalData::MRMailboxUtilsL() |
|
368 |
{ |
|
369 |
TRACE_ENTRY_POINT; |
|
370 |
||
371 |
if (!iMailboxUtils) |
|
372 |
{ |
|
373 |
if (InterimUtilsL().MRViewersEnabledL()) |
|
374 |
{ |
|
375 |
iMailboxUtils = CMRMailboxUtils::NewL(); |
|
376 |
} |
|
377 |
else |
|
378 |
{ |
|
379 |
User::Leave(KErrNotSupported); |
|
380 |
} |
|
381 |
} |
|
382 |
||
383 |
TRACE_EXIT_POINT; |
|
384 |
return *iMailboxUtils; |
|
385 |
} |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
386 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
387 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
388 |
// CCalenGlobalData::CalSessionL |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
389 |
// Create a Calendar session if necessary and return a reference |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
390 |
// (other items were commented in a header). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
391 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
392 |
EXPORT_C CCalSession& CCalenGlobalData::CalSessionL() |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
393 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
394 |
TRACE_ENTRY_POINT; |
66 | 395 |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
396 |
if (!iCalSession) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
397 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
398 |
iGlobalDataOwnsCalSession = ETrue; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
399 |
iCalSession = CCalSession::NewL(); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
400 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
401 |
TRAPD( err, iCalSession->OpenL(KCalendarDatabaseFilePath)); |
66 | 402 |
if (err == KErrNotFound) |
403 |
{ |
|
404 |
CCalCalendarInfo* calendarInfo = GetDefaultCalendarInfoL(); |
|
405 |
CleanupStack::PushL(calendarInfo); |
|
406 |
iCalSession->CreateCalFileL( KCalendarDatabaseFilePath, |
|
407 |
*calendarInfo); |
|
408 |
iCalSession->OpenL(KCalendarDatabaseFilePath); |
|
409 |
CleanupStack::PopAndDestroy(calendarInfo); |
|
410 |
} |
|
411 |
else if(err == KErrNone) |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
412 |
{ |
66 | 413 |
// temp solution...need to handle this case |
414 |
CCalCalendarInfo* calendarInfo = iCalSession->CalendarInfoL(); |
|
415 |
CleanupStack::PushL(calendarInfo); |
|
416 |
if( !calendarInfo->NameL().Compare(KNullDesC) && |
|
417 |
!calendarInfo->Enabled() ) |
|
418 |
{ |
|
419 |
calendarInfo->SetNameL(KExtCalendar); |
|
420 |
calendarInfo->SetColor(KRgbBlack.Value()); |
|
421 |
iCalSession->SetCalendarInfoL(*calendarInfo); |
|
422 |
} |
|
423 |
CleanupStack::PopAndDestroy(calendarInfo); |
|
424 |
||
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
425 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
426 |
else |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
427 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
428 |
User::LeaveIfError( err ); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
429 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
430 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
431 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
432 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
433 |
return *iCalSession; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
434 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
435 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
436 |
// ----------------------------------------------------------------------------- |
66 | 437 |
// CCalenGlobalData::CalSessionL |
438 |
// Based on the calendar name return already cached session from iFileMappingArray |
|
439 |
// (other items were commented in a header). |
|
440 |
// ----------------------------------------------------------------------------- |
|
441 |
EXPORT_C CCalSession& CCalenGlobalData::CalSessionL(const TDesC& aCalendar) |
|
442 |
{ |
|
443 |
TRACE_ENTRY_POINT; |
|
444 |
CCalSession* session = NULL; |
|
445 |
HBufC* calendarFileName = aCalendar.AllocLC(); |
|
446 |
TInt index = iFileMappingArray.Find( |
|
447 |
*calendarFileName,CCalenGlobalData::CalenInfoIdentifierL); |
|
448 |
CleanupStack::PopAndDestroy(calendarFileName); |
|
449 |
if(KErrNotFound != index) |
|
450 |
{ |
|
451 |
session = iFileMappingArray[index]->GetSessionPtr(); |
|
452 |
} |
|
453 |
else |
|
454 |
{ |
|
455 |
User::LeaveIfError(KErrNotFound); |
|
456 |
} |
|
457 |
||
458 |
TRACE_EXIT_POINT; |
|
459 |
return *session; |
|
460 |
} |
|
461 |
||
462 |
// ----------------------------------------------------------------------------- |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
463 |
// CCalenGlobalData::InstanceViewL |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
464 |
// Create an instance view if necessary and returns a reference. Creating an |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
465 |
// instance view is an asynchronous operation, but this call returns |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
466 |
// synchronously. When the view is created, Completed() is called, which stops |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
467 |
// iAs allowing this function to complete. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
468 |
// Leaves with KErrInUse if this class is in the process of creating the |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
469 |
// instance view |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
470 |
// (other items were commented in a header). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
471 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
472 |
EXPORT_C CCalInstanceView* CCalenGlobalData::InstanceViewL() |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
473 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
474 |
TRACE_ENTRY_POINT; |
66 | 475 |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
476 |
if (!iInstanceView && !iInstanceViewCreation) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
477 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
478 |
if ( iEntryViewCreation ) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
479 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
480 |
iQueued = &CreateInstanceViewL; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
481 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
482 |
else |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
483 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
484 |
CreateInstanceViewL(); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
485 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
486 |
} |
66 | 487 |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
488 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
489 |
return iInstanceView; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
490 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
491 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
492 |
// ----------------------------------------------------------------------------- |
66 | 493 |
// CCalenGlobalData::InstanceViewL |
494 |
// Based on collection id array Create an instance view if necessary and returns a reference. |
|
495 |
// Creating an instance view is an asynchronous operation, but this call returns |
|
496 |
// synchronously. When the view is created, Completed() is called, which stops |
|
497 |
// iAs allowing this function to complete. |
|
498 |
// Leaves with KErrInUse if this class is in the process of creating the |
|
499 |
// instance view |
|
500 |
// (other items were commented in a header). |
|
501 |
// ----------------------------------------------------------------------------- |
|
502 |
EXPORT_C CCalInstanceView* CCalenGlobalData::InstanceViewL( |
|
503 |
const RArray<TInt>& aCollectionIds) |
|
504 |
{ |
|
505 |
TRACE_ENTRY_POINT; |
|
506 |
||
507 |
if(!iNewInstanceView && !iNewInstanceViewCreation) |
|
508 |
{ |
|
509 |
CreateInstanceViewL(aCollectionIds); |
|
510 |
} |
|
511 |
||
512 |
TRACE_EXIT_POINT; |
|
513 |
return iNewInstanceView; |
|
514 |
} |
|
515 |
||
516 |
// ----------------------------------------------------------------------------- |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
517 |
// CCalenGlobalData::EntryViewL |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
518 |
// Create an entry view if necessary and returns a reference. Creating an |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
519 |
// entry view is an asynchronous operation, but this call returns |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
520 |
// synchronously. When the view is created, Completed() is called, which stops |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
521 |
// iAs allowing this function to complete. |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
522 |
// Leaves with KErrInUse if this class is in the process of creating the |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
523 |
// entry view |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
524 |
// (other items were commented in a header). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
525 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
526 |
EXPORT_C CCalEntryView* CCalenGlobalData::EntryViewL() |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
527 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
528 |
TRACE_ENTRY_POINT; |
66 | 529 |
|
530 |
if (!iEntryView && !iEntryViewCreation) |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
531 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
532 |
if ( iInstanceViewCreation ) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
533 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
534 |
iQueued = &CreateEntryViewL; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
535 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
536 |
else |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
537 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
538 |
CreateEntryViewL(); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
539 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
540 |
} |
66 | 541 |
|
542 |
TRACE_EXIT_POINT; |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
543 |
return iEntryView; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
544 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
545 |
|
66 | 546 |
|
547 |
// ----------------------------------------------------------------------------- |
|
548 |
// CCalenGlobalData::EntryViewL |
|
549 |
// Based on collection id array Create an entry view if necessary and returns a reference. |
|
550 |
// Creating an entry view is an asynchronous operation, but this call returns |
|
551 |
// synchronously. When the view is created, Completed() is called, which stops |
|
552 |
// iAs allowing this function to complete. |
|
553 |
// Leaves with KErrInUse if this class is in the process of creating the |
|
554 |
// entry view |
|
555 |
// (other items were commented in a header). |
|
556 |
// ----------------------------------------------------------------------------- |
|
557 |
EXPORT_C CCalEntryView* CCalenGlobalData::EntryViewL( |
|
558 |
const TCalCollectionId aCollectionId) |
|
559 |
{ |
|
560 |
TRACE_ENTRY_POINT; |
|
561 |
__ASSERT_ALWAYS(aCollectionId > 0 ,User::Panic(_L("CCalenGlobalData"),-1)); |
|
562 |
||
563 |
CCalEntryView* entryView = NULL; |
|
564 |
||
565 |
TInt index = iHashDbidIndexMap.FindL(aCollectionId); |
|
566 |
if(index != KErrNotFound) |
|
567 |
{ |
|
568 |
entryView = iFileMappingArray[index]->GetEntryView(); |
|
569 |
} |
|
570 |
||
571 |
if(!entryView) |
|
572 |
{ |
|
573 |
User::LeaveIfNull(entryView); |
|
574 |
} |
|
575 |
||
576 |
TRACE_EXIT_POINT; |
|
577 |
return entryView; |
|
578 |
} |
|
579 |
||
580 |
// ----------------------------------------------------------------------------- |
|
581 |
// CCalenGlobalData::RegisterEntryViewObserver |
|
582 |
// Add observer into view observers entry observer list. |
|
583 |
// (other items were commented in a header). |
|
584 |
// ----------------------------------------------------------------------------- |
|
585 |
EXPORT_C TBool CCalenGlobalData::EntryViewExists() |
|
586 |
{ |
|
587 |
TRACE_ENTRY_POINT; |
|
588 |
TRACE_EXIT_POINT; |
|
589 |
return ( iEntryView != NULL ); |
|
590 |
} |
|
591 |
||
592 |
// ----------------------------------------------------------------------------- |
|
593 |
// CCalenGlobalData::MeetingRequestUtilsL |
|
594 |
// Create MR Utils if necessary and returns a reference |
|
595 |
// (other items were commented in a header). |
|
596 |
// ----------------------------------------------------------------------------- |
|
597 |
EXPORT_C CMRUtils& CCalenGlobalData::MeetingRequestUtilsL() |
|
598 |
{ |
|
599 |
TRACE_ENTRY_POINT; |
|
600 |
||
601 |
iCreateError = KErrNone; |
|
602 |
if (!iUtilsAs) |
|
603 |
{ |
|
604 |
iUtilsAs = new (ELeave) CActiveSchedulerWait; |
|
605 |
} |
|
606 |
if (!iMRUtils) |
|
607 |
{ |
|
608 |
if (InterimUtilsL().MRViewersEnabledL()) |
|
609 |
{ |
|
610 |
if (iUtilsAs->IsStarted()) |
|
611 |
{ |
|
612 |
User::Leave(KErrInUse); |
|
613 |
} |
|
614 |
else |
|
615 |
{ |
|
616 |
//Get the currently selected mailbox |
|
617 |
CMRMailboxUtils::TMailboxInfo defaultMailbox; |
|
618 |
MRMailboxUtilsL().GetDefaultMRMailBoxL(defaultMailbox); |
|
619 |
//CMRUtils resolves meeting request utilities based on mtm uid |
|
620 |
TBuf8<KMaxUidName> mrMtm; |
|
621 |
CnvUtfConverter::ConvertFromUnicodeToUtf8(mrMtm, defaultMailbox.iMtmUid.Name()); |
|
622 |
iMRUtils = CMRUtils::NewL(mrMtm, *this, CalSessionL(), NULL); |
|
623 |
iUtilsAs->Start(); |
|
624 |
User::LeaveIfError(iCreateError); |
|
625 |
} |
|
626 |
} |
|
627 |
else |
|
628 |
{ |
|
629 |
User::Leave(KErrNotSupported); |
|
630 |
} |
|
631 |
} |
|
632 |
||
633 |
TRACE_EXIT_POINT; |
|
634 |
return *iMRUtils; |
|
635 |
} |
|
636 |
||
637 |
// ----------------------------------------------------------------------------- |
|
638 |
// CCalenGlobalData::InterimUtilsL |
|
639 |
// Create a CCalenInterimUtils object if neccessary and return a reference |
|
640 |
// (other items were commented in a header). |
|
641 |
// ----------------------------------------------------------------------------- |
|
642 |
EXPORT_C CCalenInterimUtils2& CCalenGlobalData::InterimUtilsL() |
|
643 |
{ |
|
644 |
TRACE_ENTRY_POINT; |
|
645 |
||
646 |
if(!iInterimUtils) |
|
647 |
{ |
|
648 |
iInterimUtils = CCalenInterimUtils2::NewL(); |
|
649 |
} |
|
650 |
||
651 |
TRACE_EXIT_POINT; |
|
652 |
return *iInterimUtils; |
|
653 |
} |
|
654 |
||
655 |
// ----------------------------------------------------------------------------- |
|
656 |
// CCalenGlobalData::CalenSendL |
|
657 |
// Create a CCalenSend object if neccessary and return a reference |
|
658 |
// (other items were commented in a header). |
|
659 |
// ----------------------------------------------------------------------------- |
|
660 |
EXPORT_C CCalenSend& CCalenGlobalData::CalenSendL() |
|
661 |
{ |
|
662 |
TRACE_ENTRY_POINT; |
|
663 |
||
664 |
if( !iSend ) |
|
665 |
{ |
|
666 |
iSend = CCalenSend::NewL( ECalenSend, CalSessionL() ); |
|
667 |
} |
|
668 |
||
669 |
TRACE_EXIT_POINT; |
|
670 |
return *iSend; |
|
671 |
} |
|
672 |
||
673 |
// ----------------------------------------------------------------------------- |
|
674 |
// CCalenGlobalData::Context |
|
675 |
// Return a reference to the CCalenContext object |
|
676 |
// (other items were commented in a header). |
|
677 |
// ----------------------------------------------------------------------------- |
|
678 |
EXPORT_C MCalenContext& CCalenGlobalData::Context() |
|
679 |
{ |
|
680 |
TRACE_ENTRY_POINT; |
|
681 |
TRACE_EXIT_POINT; |
|
682 |
return *iContext; |
|
683 |
} |
|
684 |
||
685 |
// ----------------------------------------------------------------------------- |
|
686 |
// CCalenEditUi::AttemptToRetrieveDefaultMailboxL |
|
687 |
// Check to see if we have any mailboxes defined, and if we have a default |
|
688 |
// mailbox. If we don't, inform the user and return EFalse. This function |
|
689 |
// returns ETrue if aDefaultMailbox was initialised, and it is OK to create |
|
690 |
// a new MR. |
|
691 |
// (other items were commented in a header). |
|
692 |
// ----------------------------------------------------------------------------- |
|
693 |
EXPORT_C TBool CCalenGlobalData::AttemptToRetrieveDefaultMailboxL( CMRMailboxUtils::TMailboxInfo& aDefaultMailbox) |
|
694 |
{ |
|
695 |
TRACE_ENTRY_POINT; |
|
696 |
||
697 |
CMRMailboxUtils& mbUtils = MRMailboxUtilsL(); |
|
698 |
// Get the currently defined mailboxes. |
|
699 |
RArray<CMRMailboxUtils::TMailboxInfo> mailboxes; |
|
700 |
CleanupClosePushL(mailboxes); |
|
701 |
mbUtils.ListMailBoxesL(mailboxes); |
|
702 |
||
703 |
TBool canCreateMeetingRequest=EFalse; |
|
704 |
TInt mbCount = mailboxes.Count(); |
|
705 |
||
706 |
// The following 'if-else' block should always initialise |
|
707 |
// defaultMailBox if canCreateMeetingRequest comes out as ETrue. |
|
708 |
if(mbCount > 0) |
|
709 |
{ |
|
710 |
TInt res = KErrNone; |
|
711 |
TRAPD(err, res = mbUtils.GetDefaultMRMailBoxL(aDefaultMailbox)); |
|
712 |
if( res == KErrNone && err == KErrNone) |
|
713 |
{ |
|
714 |
canCreateMeetingRequest = ETrue; |
|
715 |
} |
|
716 |
else |
|
717 |
{ |
|
718 |
// We have one or more mailboxes defined, but failed to get a default. |
|
719 |
// Ask user to answer "Select default mailbox" query. The available mailboxes must |
|
720 |
// first be reduced to only show mailboxes with an associated meetnig request solution |
|
721 |
RImplInfoPtrArrayOwn implArray; |
|
722 |
CleanupClosePushL( implArray ); |
|
723 |
//Get all MRViewers Implementation |
|
724 |
const TUid mrViewersIface = {KMRViewersInterfaceUID}; |
|
725 |
REComSession::ListImplementationsL(mrViewersIface, implArray ); |
|
726 |
||
727 |
for (TInt i = mailboxes.Count() - 1; i >= 0; --i) |
|
728 |
{ |
|
729 |
//See if any meeting request implementation matches this mailbox |
|
730 |
for (TInt j=0; j<implArray.Count(); ++j) |
|
731 |
{ |
|
732 |
TBuf16<KMaxUidName> mbName; |
|
733 |
CnvUtfConverter::ConvertToUnicodeFromUtf8( mbName, implArray[j]->DataType() ); |
|
734 |
if(mailboxes[i].iMtmUid.Name().CompareF(mbName) == 0) |
|
735 |
{ |
|
736 |
//Found a match |
|
737 |
break; |
|
738 |
} |
|
739 |
//Mailbox has no matching meeting request solution |
|
740 |
//remove from list |
|
741 |
mailboxes.Remove(i); |
|
742 |
} |
|
743 |
} |
|
744 |
CleanupStack::PopAndDestroy(); //implArray |
|
745 |
||
746 |
TInt selected = PromptToSelectDefaultMailboxL(mailboxes); |
|
747 |
||
748 |
if(selected >= KErrNone) |
|
749 |
{ |
|
750 |
mbUtils.SetDefaultMRMailBoxL( mailboxes[selected].iEntryId ); |
|
751 |
canCreateMeetingRequest = ETrue; |
|
752 |
__ASSERT_ALWAYS((mbUtils.GetDefaultMRMailBoxL( aDefaultMailbox ) == KErrNone), User::Invariant()); // so we don't return ref to local variable. |
|
753 |
} |
|
754 |
} |
|
755 |
} |
|
756 |
else |
|
757 |
{ |
|
758 |
// Force the check of MR Impl existing |
|
759 |
InterimUtilsL().MRViewersEnabledL(ETrue); //ignore result |
|
760 |
} |
|
761 |
||
762 |
CleanupStack::PopAndDestroy(); // mailboxes |
|
763 |
||
764 |
TRACE_EXIT_POINT; |
|
765 |
return canCreateMeetingRequest; |
|
766 |
} |
|
767 |
||
768 |
// ----------------------------------------------------------------------------- |
|
769 |
// CCalenGlobalData::ResetKeyEventQueue |
|
770 |
// Reset Keyevents queue |
|
771 |
// (other items were commented in a header). |
|
772 |
// ----------------------------------------------------------------------------- |
|
773 |
EXPORT_C void CCalenGlobalData::ResetKeyEventQueue() |
|
774 |
{ |
|
775 |
TRACE_ENTRY_POINT; |
|
776 |
iKeyQueue.Reset(); |
|
777 |
TRACE_EXIT_POINT; |
|
778 |
} |
|
779 |
||
780 |
// ----------------------------------------------------------------------------- |
|
781 |
// CCalenGlobalData::QueueKeyEvent |
|
782 |
// Queue key press event in a queue |
|
783 |
// (other items were commented in a header). |
|
784 |
// ----------------------------------------------------------------------------- |
|
785 |
EXPORT_C TBool CCalenGlobalData::QueueKeyEvent(const TKeyEvent& aEvent, |
|
786 |
TEventCode aType) |
|
787 |
{ |
|
788 |
TRACE_ENTRY_POINT; |
|
789 |
TBool result(EFalse); |
|
790 |
TQueuedKeyEvent item; |
|
791 |
item.iType = aType; |
|
792 |
item.iEvent = aEvent; |
|
793 |
if( iKeyQueue.Insert(item, iKeyQueue.Count()) == KErrNone) // add to last |
|
794 |
{ |
|
795 |
result = ETrue; |
|
796 |
} |
|
797 |
TRACE_EXIT_POINT; |
|
798 |
return result; |
|
799 |
} |
|
800 |
||
801 |
// ----------------------------------------------------------------------------- |
|
802 |
// CCalenGlobalData::GetQueueKeyEvent |
|
803 |
// Get 1 queued event from the queue |
|
804 |
// (other items were commented in a header). |
|
805 |
// ----------------------------------------------------------------------------- |
|
806 |
EXPORT_C TBool CCalenGlobalData::GetQueuedKeyEvent(TKeyEvent& aEvent, TEventCode& aType) |
|
807 |
{ |
|
808 |
TRACE_ENTRY_POINT; |
|
809 |
TBool result(EFalse); |
|
810 |
if(iKeyQueue.Count() > 0) |
|
811 |
{ |
|
812 |
TQueuedKeyEvent item; |
|
813 |
item = iKeyQueue[0];// get first |
|
814 |
aEvent = item.iEvent; |
|
815 |
aType = item.iType; |
|
816 |
iKeyQueue.Remove(0); // remove first |
|
817 |
result = ETrue; |
|
818 |
iKeyQueue.Compress(); |
|
819 |
} |
|
820 |
TRACE_EXIT_POINT; |
|
821 |
return result; |
|
822 |
} |
|
823 |
||
824 |
// ----------------------------------------------------------------------------- |
|
825 |
// CCalenGlobalData::ConstructFileMappingL |
|
826 |
// Constructs mapping between symbian calendar file and metabd info |
|
827 |
// ----------------------------------------------------------------------------- |
|
828 |
EXPORT_C TBool CCalenGlobalData::ConstructFileMappingL() |
|
829 |
{ |
|
830 |
TRACE_ENTRY_POINT; |
|
831 |
iCalendarsSession = CCalSession::NewL(); |
|
832 |
||
833 |
ConstructCalendarsListL(); |
|
834 |
||
835 |
iFileMappingArray.Reset(); |
|
836 |
||
837 |
for(TInt index = 0; index < iCalendarInfoList.Count(); index++) |
|
838 |
{ |
|
839 |
TPtrC calendarFileName = iCalendarInfoList[index]->FileNameL(); |
|
840 |
CCalenFileMapping* filemap = CCalenFileMapping::NewL(); |
|
841 |
CleanupStack::PushL(filemap); |
|
842 |
filemap->SetCalendarFileNameL(calendarFileName); |
|
843 |
||
844 |
iNewEntryView = NULL; |
|
845 |
iNewEntryViewCreation = NULL; |
|
846 |
CCalenDbChangeNotifier* dbChangeNotifier = NULL; |
|
847 |
if(iCalSession) |
|
848 |
{ |
|
849 |
iNewCalSession = NULL; |
|
850 |
CCalCalendarInfo* calendarInfo = iCalendarInfoList[index]; |
|
851 |
||
852 |
CCalSession& tempSession = CreateNewSessionL( calendarFileName, |
|
853 |
*calendarInfo ); |
|
854 |
filemap->SetSessionPtr(&tempSession); |
|
855 |
filemap->SetCollectionId(tempSession.CollectionIdL()); |
|
856 |
CreateEntryViewL(tempSession); |
|
857 |
filemap->SetEntryView( iNewEntryView ); |
|
858 |
dbChangeNotifier = CCalenDbChangeNotifier::NewL( tempSession ); |
|
859 |
dbChangeNotifier->RegisterObserverL(*iDBChangeNotifier); |
|
860 |
filemap->SetDBChangeNotifier(dbChangeNotifier); |
|
861 |
} |
|
862 |
else |
|
863 |
{ |
|
864 |
CCalSession& tempSession = CalSessionL(); |
|
865 |
filemap->SetSessionPtr(&tempSession); |
|
866 |
filemap->SetCollectionId(tempSession.CollectionIdL()); |
|
867 |
CreateEntryViewL(tempSession); |
|
868 |
filemap->SetEntryView( iNewEntryView ); |
|
869 |
iGlobalDataOwnsEntryView = EFalse; |
|
870 |
iGlobalDataOwnsCalSession = EFalse; |
|
871 |
dbChangeNotifier = CCalenDbChangeNotifier::NewL( tempSession ); |
|
872 |
dbChangeNotifier->RegisterObserverL(*iDBChangeNotifier); |
|
873 |
filemap->SetDBChangeNotifier(dbChangeNotifier); |
|
874 |
} |
|
875 |
iFileMappingArray.Append(filemap); |
|
876 |
CleanupStack::Pop(filemap); |
|
877 |
} |
|
878 |
||
879 |
for(TInt index = 0; index < iFileMappingArray.Count(); index++) |
|
880 |
{ |
|
881 |
iHashDbidIndexMap.InsertL( iFileMappingArray[index]->GetCollectionId(), |
|
882 |
index); |
|
883 |
} |
|
884 |
||
885 |
TRACE_EXIT_POINT |
|
886 |
return ETrue; |
|
887 |
} |
|
888 |
||
889 |
// ----------------------------------------------------------------------------- |
|
890 |
// CCalenGlobalData::InitializeGlobalDataL |
|
891 |
// Initializes multiple db related objects |
|
892 |
// ----------------------------------------------------------------------------- |
|
893 |
EXPORT_C void CCalenGlobalData::InitializeGlobalDataL() |
|
894 |
{ |
|
895 |
TRACE_ENTRY_POINT |
|
896 |
||
897 |
ConstructFileMappingL(); |
|
898 |
||
899 |
TRACE_EXIT_POINT |
|
900 |
} |
|
901 |
||
902 |
// ----------------------------------------------------------------------------- |
|
903 |
// CCalenGlobalData::PromptToSelectDefaultMailboxL |
|
904 |
// Prompts the user to select the default mailbox. If the user cancels, the |
|
905 |
// function returns KErrCancel, otherwise it returns the index of the selected |
|
906 |
// mailbox. This function does not set the default mailbox, but rather returns |
|
907 |
// the index of the given array to which the default should be set. |
|
908 |
// (other items were commented in a header). |
|
909 |
// ----------------------------------------------------------------------------- |
|
910 |
TInt CCalenGlobalData::PromptToSelectDefaultMailboxL( RArray<CMRMailboxUtils::TMailboxInfo>& aMailboxes ) |
|
911 |
{ |
|
912 |
TRACE_ENTRY_POINT; |
|
913 |
||
914 |
TInt mbCount = aMailboxes.Count(); |
|
915 |
||
916 |
TInt selected; |
|
917 |
if (mbCount > 0) |
|
918 |
{ |
|
919 |
CAknSinglePopupMenuStyleListBox* list = |
|
920 |
new (ELeave) CAknSinglePopupMenuStyleListBox; |
|
921 |
CleanupStack::PushL(list); |
|
922 |
||
923 |
CAknPopupList* popupList = CAknPopupList::NewL(list, R_AVKON_SOFTKEYS_OK_CANCEL); |
|
924 |
CleanupStack::PushL(popupList); |
|
925 |
||
926 |
list->ConstructL(popupList, CEikListBox::ELeftDownInViewRect); |
|
927 |
list->CreateScrollBarFrameL(ETrue); |
|
928 |
list->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
929 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
930 |
||
931 |
CEikonEnv* eikEnv = CEikonEnv::Static(); |
|
932 |
||
933 |
CDesCArrayFlat* items = new (ELeave)CDesCArrayFlat(mbCount); |
|
934 |
CleanupStack::PushL(items); |
|
935 |
for(TInt i=0; i<mbCount; ++i) |
|
936 |
{ |
|
937 |
items->AppendL( aMailboxes[i].iName ); |
|
938 |
} |
|
939 |
CleanupStack::Pop(items); |
|
940 |
CTextListBoxModel* model = list->Model(); |
|
941 |
||
942 |
//Pass ownersip of items to model |
|
943 |
model->SetItemTextArray(items); |
|
944 |
||
945 |
HBufC* title = StringLoader::LoadLC(R_CALEN_SELECT_MAILBOX, eikEnv); |
|
946 |
popupList->SetTitleL(*title); |
|
947 |
CleanupStack::PopAndDestroy(title); |
|
948 |
||
949 |
TBool accepted = popupList->ExecuteLD(); |
|
950 |
CleanupStack::Pop(); // popupList |
|
951 |
||
952 |
if(accepted) |
|
953 |
{ |
|
954 |
selected = list->CurrentItemIndex(); |
|
955 |
} |
|
956 |
else |
|
957 |
{ |
|
958 |
selected = KErrCancel; |
|
959 |
} |
|
960 |
||
961 |
CleanupStack::PopAndDestroy(); // list |
|
962 |
} |
|
963 |
else |
|
964 |
{ |
|
965 |
//No mailboxes defined. Could prompt user to define one here? |
|
966 |
selected = KErrCancel; |
|
967 |
} |
|
968 |
||
969 |
TRACE_EXIT_POINT; |
|
970 |
return selected; |
|
971 |
} |
|
972 |
||
973 |
// ----------------------------------------------------------------------------- |
|
974 |
// CCalenGlobalData::HandleCalEngStatus |
|
975 |
// Called when Meeting Request utils are creation is complete. |
|
976 |
// Stops the CActiveSchedulerWait, allowing MeetingRequestUtilsL() to complete |
|
977 |
// (other items were commented in a header). |
|
978 |
// ----------------------------------------------------------------------------- |
|
979 |
void CCalenGlobalData::HandleCalEngStatus( TMRUtilsCalEngStatus aStatus ) |
|
980 |
{ |
|
981 |
TRACE_ENTRY_POINT; |
|
982 |
||
983 |
ASSERT(iUtilsAs); |
|
984 |
||
985 |
switch (aStatus) |
|
986 |
{ |
|
987 |
case ENotReady: |
|
988 |
{ |
|
989 |
//Keep waiting |
|
990 |
} |
|
991 |
break; |
|
992 |
case EAvailableWithoutTombs: |
|
993 |
case EAvailable: |
|
994 |
{ |
|
995 |
//Ready for use. Stop the CActiveSchedulerWait and return |
|
996 |
iUtilsAs->AsyncStop(); |
|
997 |
iCreateError = KErrNone; |
|
998 |
} |
|
999 |
break; |
|
1000 |
case ENotAvailable: |
|
1001 |
{ |
|
1002 |
//Somethings gone wrong. Stop the CActiveSchedulerWait but force |
|
1003 |
//MeetingRequestUtilsL to leave. |
|
1004 |
//We'll use KErrNotFound for now but we don't know what the problem is. |
|
1005 |
iUtilsAs->AsyncStop(); |
|
1006 |
iCreateError = KErrNotFound; |
|
1007 |
} |
|
1008 |
break; |
|
1009 |
default: |
|
1010 |
{ |
|
1011 |
//Shouldn't ever get called. |
|
1012 |
iUtilsAs->AsyncStop(); |
|
1013 |
iCreateError = KErrArgument; |
|
1014 |
} |
|
1015 |
break; |
|
1016 |
} |
|
1017 |
||
1018 |
TRACE_EXIT_POINT; |
|
1019 |
} |
|
1020 |
||
1021 |
// ----------------------------------------------------------------------------- |
|
1022 |
// CCalenGlobalData::HandleNotification |
|
1023 |
// Handle any notification if registered for |
|
1024 |
// ----------------------------------------------------------------------------- |
|
1025 |
void CCalenGlobalData::HandleNotification(const TCalenNotification aNotification ) |
|
1026 |
{ |
|
1027 |
TRACE_ENTRY_POINT; |
|
1028 |
||
1029 |
switch(aNotification) |
|
1030 |
{ |
|
1031 |
case ECalenNotifyEntryInstanceViewCreated: |
|
1032 |
{ |
|
1033 |
ViewCreationCompleted( ETrue ); |
|
1034 |
} |
|
1035 |
break; |
|
1036 |
case ECalenNotifyEntryInstanceViewCreationFailed: |
|
1037 |
{ |
|
1038 |
ViewCreationCompleted( EFalse ); |
|
1039 |
} |
|
1040 |
break; |
|
1041 |
case ECalenNotifyDeleteInstanceView: |
|
1042 |
{ |
|
1043 |
//InstanceView has to be deleted since deleting any session(Calendar) |
|
1044 |
//entryView and instanceView has to be deleted before deleting session. |
|
1045 |
if(iNewInstanceView) |
|
1046 |
{ |
|
1047 |
delete iNewInstanceView; |
|
1048 |
iNewInstanceViewCreation = iNewInstanceView = NULL; |
|
1049 |
} |
|
1050 |
||
1051 |
//If InstanceView is called by any component single instanceView |
|
1052 |
// without the knowledge of multi session (calendar). |
|
1053 |
//This instance also should be deleted for deleting the session. |
|
1054 |
if(iInstanceView) |
|
1055 |
{ |
|
1056 |
delete iInstanceView; |
|
1057 |
iInstanceView = iInstanceViewCreation = NULL; |
|
1058 |
} |
|
1059 |
} |
|
1060 |
break; |
|
1061 |
case ECalenNotifyRealExit: |
|
1062 |
{ |
|
1063 |
iCalendarForcedExit = ETrue; |
|
1064 |
} |
|
1065 |
break; |
|
1066 |
case ECalenNotifyCalendarInfoCreated: |
|
1067 |
{ |
|
1068 |
TRAP_IGNORE(HandleCalendarInfoCreatedL()); |
|
1069 |
} |
|
1070 |
break; |
|
1071 |
case ECalenNotifyCalendarInfoUpdated: |
|
1072 |
{ |
|
1073 |
TRAP_IGNORE(HandleCalendarInfoUpdatedL()); |
|
1074 |
} |
|
1075 |
break; |
|
1076 |
case ECalenNotifyCalendarFileDeleted: |
|
1077 |
{ |
|
1078 |
TRAP_IGNORE(HandleCalendarFileDeletedL()); |
|
1079 |
} |
|
1080 |
break; |
|
1081 |
default: |
|
1082 |
break; |
|
1083 |
} |
|
1084 |
||
1085 |
TRACE_EXIT_POINT; |
|
1086 |
} |
|
1087 |
||
1088 |
// ----------------------------------------------------------------------------- |
|
1089 |
// CCalenGlobalData::CreateEntryViewL |
|
1090 |
// ----------------------------------------------------------------------------- |
|
65
12af337248b1
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
1091 |
void CCalenGlobalData::CreateEntryViewL() |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1092 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1093 |
TRACE_ENTRY_POINT; |
66 | 1094 |
|
1095 |
HBufC* calendarFileName = KCalendarDatabaseFilePath().AllocLC(); |
|
1096 |
TInt index = iFileMappingArray.Find( |
|
1097 |
*calendarFileName, CCalenGlobalData::CalenInfoIdentifierL); |
|
1098 |
CleanupStack::PopAndDestroy(calendarFileName); |
|
1099 |
if(index != KErrNotFound) |
|
1100 |
{ |
|
1101 |
iEntryView = iFileMappingArray[index]->GetEntryView(); |
|
1102 |
} |
|
1103 |
||
1104 |
if(!iEntryView) |
|
1105 |
{ |
|
1106 |
User::LeaveIfNull(iEntryView); |
|
1107 |
} |
|
1108 |
||
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1109 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1110 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1111 |
|
66 | 1112 |
// ----------------------------------------------------------------------------- |
1113 |
// CCalenGlobalData::CreateEntryViewL |
|
1114 |
// ----------------------------------------------------------------------------- |
|
1115 |
void CCalenGlobalData::CreateEntryViewL(CCalSession& session) |
|
1116 |
{ |
|
1117 |
TRACE_ENTRY_POINT; |
|
1118 |
iNewEntryViewCreation = CCalEntryView::NewL( session, iCalCallBack ); |
|
1119 |
||
1120 |
if(iNewEntryViewCreation) |
|
1121 |
{ |
|
1122 |
iNewEntryView = iNewEntryViewCreation; |
|
1123 |
} |
|
1124 |
||
1125 |
TRACE_EXIT_POINT; |
|
1126 |
} |
|
1127 |
||
1128 |
// ----------------------------------------------------------------------------- |
|
1129 |
// CCalenGlobalData::CreateInstanceViewL |
|
1130 |
// ----------------------------------------------------------------------------- |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1131 |
void CCalenGlobalData::CreateInstanceViewL() |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1132 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1133 |
TRACE_ENTRY_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1134 |
iInstanceViewCreation = CCalInstanceView::NewL( CalSessionL(), iCalCallBack ); |
66 | 1135 |
if(iInstanceViewCreation) |
1136 |
{ |
|
1137 |
iInstanceView = iInstanceViewCreation; |
|
1138 |
} |
|
1139 |
TRACE_EXIT_POINT; |
|
1140 |
} |
|
1141 |
||
1142 |
// ----------------------------------------------------------------------------- |
|
1143 |
// CCalenGlobalData::CreateEntryViewL |
|
1144 |
// ----------------------------------------------------------------------------- |
|
1145 |
void CCalenGlobalData::CreateInstanceViewL(const RArray<TInt>& aCollectionIds) |
|
1146 |
{ |
|
1147 |
TRACE_ENTRY_POINT; |
|
1148 |
||
1149 |
RPointerArray<CCalSession> sessionArray; |
|
1150 |
||
1151 |
for(TInt i = 0; i < aCollectionIds.Count() ; i++) |
|
1152 |
{ |
|
1153 |
TInt index = iHashDbidIndexMap.FindL(aCollectionIds[i]); |
|
1154 |
if(index != KErrNotFound) |
|
1155 |
{ |
|
1156 |
CCalSession* sessionPtr = iFileMappingArray[index]->GetSessionPtr(); |
|
1157 |
sessionArray.AppendL(sessionPtr); |
|
1158 |
} |
|
1159 |
} |
|
1160 |
||
1161 |
if(sessionArray.Count()) |
|
1162 |
{ |
|
1163 |
iNewInstanceViewCreation = CCalInstanceView::NewL( sessionArray, iCalCallBack ); |
|
1164 |
if(iNewInstanceViewCreation) |
|
1165 |
{ |
|
1166 |
iNewInstanceView = iNewInstanceViewCreation; |
|
1167 |
} |
|
1168 |
} |
|
1169 |
||
1170 |
sessionArray.Reset(); |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1171 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1172 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1173 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1174 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1175 |
// CEntryViewObserver::ViewCreationCompleted |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1176 |
// FIXME -- Update description |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1177 |
// Get call after entryview / instance view being created |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1178 |
// (other items were commented in a header). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1179 |
// ----------------------------------------------------------------------------- |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1180 |
void CCalenGlobalData::ViewCreationCompleted( TBool aSuccess ) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1181 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1182 |
TRACE_ENTRY_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1183 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1184 |
if ( !aSuccess ) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1185 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1186 |
// Something has gone wrong |
66 | 1187 |
if (iEntryViewCreation) |
1188 |
{ |
|
1189 |
delete iEntryViewCreation; |
|
1190 |
iEntryViewCreation = NULL; |
|
1191 |
} |
|
1192 |
if (iInstanceViewCreation) |
|
1193 |
{ |
|
1194 |
delete iInstanceViewCreation; |
|
1195 |
iInstanceViewCreation = NULL; |
|
1196 |
} |
|
1197 |
||
1198 |
if (iNewEntryViewCreation) |
|
1199 |
{ |
|
1200 |
delete iNewEntryViewCreation; |
|
1201 |
iNewEntryViewCreation = NULL; |
|
1202 |
||
1203 |
HBufC* fileName = iContext->GetCalendarFileNameL().AllocLC(); |
|
1204 |
TInt index = iFileMappingArray.Find(*fileName, |
|
1205 |
CCalenGlobalData::CalenInfoIdentifierL); |
|
1206 |
CleanupStack::PopAndDestroy(fileName); |
|
1207 |
||
1208 |
if (index != KErrNotFound) |
|
1209 |
{ |
|
1210 |
iFileMappingArray[index]->SetEntryView(NULL); |
|
1211 |
} |
|
1212 |
} |
|
1213 |
||
1214 |
if (iNewInstanceViewCreation) |
|
1215 |
{ |
|
1216 |
delete iNewInstanceViewCreation; |
|
1217 |
iNewInstanceViewCreation = NULL; |
|
1218 |
} |
|
1219 |
||
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1220 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1221 |
else |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1222 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1223 |
if ( iEntryViewCreation ) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1224 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1225 |
iEntryView = iEntryViewCreation; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1226 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1227 |
else if ( iInstanceViewCreation ) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1228 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1229 |
iInstanceView = iInstanceViewCreation; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1230 |
} |
66 | 1231 |
|
1232 |
if ( iNewEntryViewCreation ) |
|
1233 |
{ |
|
1234 |
iNewEntryView = iNewEntryViewCreation; |
|
1235 |
} |
|
1236 |
else if ( iNewInstanceViewCreation ) |
|
1237 |
{ |
|
1238 |
iNewInstanceView = iNewInstanceViewCreation; |
|
1239 |
} |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1240 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1241 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1242 |
iEntryViewCreation = NULL; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1243 |
iInstanceViewCreation = NULL; |
66 | 1244 |
iNewEntryViewCreation = NULL; |
1245 |
iNewInstanceViewCreation = NULL; |
|
1246 |
||
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1247 |
if ( iQueued ) |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1248 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1249 |
(this->*iQueued)(); |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1250 |
iQueued = NULL; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1251 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1252 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1253 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1254 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1255 |
|
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1256 |
// ----------------------------------------------------------------------------- |
66 | 1257 |
// CCalenGlobalData::CreateNewSessionL |
1258 |
// Create a Calendar session if necessary and return a reference |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1259 |
// (other items were commented in a header). |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1260 |
// ----------------------------------------------------------------------------- |
66 | 1261 |
CCalSession& CCalenGlobalData::CreateNewSessionL( const TDesC& aCalendar ) |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1262 |
{ |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1263 |
TRACE_ENTRY_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1264 |
|
66 | 1265 |
if(!iNewCalSession) |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1266 |
{ |
66 | 1267 |
iNewCalSession = CCalSession::NewL(*iCalSession); |
1268 |
||
1269 |
TRAPD( err, iNewCalSession->OpenL(aCalendar)); |
|
1270 |
if ( err == KErrNotFound ) |
|
1271 |
{ |
|
1272 |
iNewCalSession->CreateCalFileL(aCalendar); |
|
1273 |
iNewCalSession->OpenL(aCalendar); // not trapped anymore |
|
1274 |
} |
|
1275 |
else |
|
1276 |
{ |
|
1277 |
User::LeaveIfError( err ); |
|
1278 |
} |
|
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1279 |
} |
66 | 1280 |
TRACE_EXIT_POINT; |
1281 |
return *iNewCalSession; |
|
1282 |
} |
|
1283 |
||
1284 |
// ----------------------------------------------------------------------------- |
|
1285 |
// CCalenGlobalData::CalenInfoIdentifierL |
|
1286 |
// ----------------------------------------------------------------------------- |
|
1287 |
// |
|
1288 |
TBool CCalenGlobalData::CalenInfoIdentifierL( const HBufC* aName, |
|
1289 |
const CCalenFileMapping& aFileMapping) |
|
1290 |
{ |
|
1291 |
TRACE_ENTRY_POINT; |
|
1292 |
TPtrC calendarFileName = aFileMapping.GetCalendarFileName(); |
|
1293 |
TRACE_EXIT_POINT; |
|
1294 |
return (!calendarFileName.CompareF(*aName)); |
|
1295 |
} |
|
1296 |
||
1297 |
// ----------------------------------------------------------------------------- |
|
1298 |
// CCalenGlobalData::AddCalendarL |
|
1299 |
// adds new calendar file and sets calendar info to it |
|
1300 |
// ----------------------------------------------------------------------------- |
|
1301 |
// |
|
1302 |
EXPORT_C void CCalenGlobalData::AddCalendarL(CCalCalendarInfo* aCalendarInfo) |
|
1303 |
{ |
|
1304 |
TRACE_ENTRY_POINT; |
|
1305 |
CleanupStack::PushL(aCalendarInfo); |
|
1306 |
||
1307 |
CCalenFileMapping* fileMapping = CCalenFileMapping::NewL(); |
|
1308 |
CleanupStack::PushL(fileMapping); |
|
1309 |
||
1310 |
HBufC* calendarFileName = CCalenMultiCalUtil::GetNextAvailableCalFileL(); |
|
1311 |
CleanupStack::PushL(calendarFileName); |
|
1312 |
fileMapping->SetCalendarFileNameL(calendarFileName->Des()); |
|
1313 |
CleanupStack::PopAndDestroy(calendarFileName); |
|
1314 |
if(iCalSession) |
|
1315 |
{ |
|
1316 |
iNewCalSession = NULL; |
|
1317 |
iNewEntryView = NULL; |
|
1318 |
iNewEntryViewCreation = NULL; |
|
1319 |
TPtrC calFileName = fileMapping->GetCalendarFileName(); |
|
1320 |
CCalSession& tempSession = CreateNewSessionL( calFileName, |
|
1321 |
*aCalendarInfo ); |
|
1322 |
fileMapping->SetSessionPtr(&tempSession); |
|
1323 |
fileMapping->SetCollectionId(tempSession.CollectionIdL()); |
|
1324 |
||
1325 |
if(!iCalendarForcedExit) |
|
1326 |
{ |
|
1327 |
CreateEntryViewL(tempSession); |
|
1328 |
} |
|
1329 |
fileMapping->SetEntryView( iNewEntryView ); |
|
1330 |
CCalenDbChangeNotifier* dbChangeNotifier = CCalenDbChangeNotifier::NewL( tempSession ); |
|
1331 |
dbChangeNotifier->RegisterObserverL(*iDBChangeNotifier); |
|
1332 |
fileMapping->SetDBChangeNotifier(dbChangeNotifier); |
|
1333 |
iCalendarInfoList.Append(tempSession.CalendarInfoL()); |
|
1334 |
} |
|
1335 |
||
1336 |
CleanupStack::Pop(fileMapping); |
|
1337 |
iFileMappingArray.Append(fileMapping); |
|
1338 |
||
1339 |
iHashDbidIndexMap.Close(); |
|
1340 |
for(TInt index = 0; index < iFileMappingArray.Count(); index++) |
|
1341 |
{ |
|
1342 |
iHashDbidIndexMap.InsertL( iFileMappingArray[index]->GetCollectionId(), |
|
1343 |
index); |
|
1344 |
} |
|
1345 |
||
1346 |
CleanupStack::PopAndDestroy(aCalendarInfo); |
|
1347 |
aCalendarInfo = NULL; |
|
1348 |
||
1349 |
TRACE_EXIT_POINT |
|
1350 |
} |
|
1351 |
||
1352 |
// ----------------------------------------------------------------------------- |
|
1353 |
// CCalenGlobalData::RemoveDeadCalendarsL |
|
1354 |
// removes dead calendar files from the file system |
|
1355 |
// ----------------------------------------------------------------------------- |
|
1356 |
// |
|
1357 |
EXPORT_C void CCalenGlobalData::RemoveDeadCalendarsL() |
|
1358 |
{ |
|
1359 |
TRACE_ENTRY_POINT; |
|
1360 |
CCalCalendarIterator* calendarIterator = |
|
1361 |
CCalCalendarIterator::NewL(*iCalendarsSession); |
|
1362 |
CleanupStack::PushL(calendarIterator); |
|
1363 |
||
1364 |
for( CCalCalendarInfo* calendarInfo = calendarIterator->FirstL(); |
|
1365 |
calendarInfo!=NULL;calendarInfo = calendarIterator->NextL()) |
|
65
12af337248b1
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
1366 |
{ |
66 | 1367 |
CleanupStack::PushL(calendarInfo); |
1368 |
HBufC* filename = calendarInfo->FileNameL().AllocLC(); |
|
1369 |
TInt index = iFileMappingArray.Find( *filename, |
|
1370 |
CCalenGlobalData::CalenInfoIdentifierL); |
|
1371 |
if(KErrNotFound == index) |
|
1372 |
{ |
|
1373 |
CCalSession* session = CCalSession::NewL(*iCalSession); |
|
1374 |
CleanupStack::PushL(session); |
|
1375 |
TRAP_IGNORE(session->DeleteCalFileL( *filename )); |
|
1376 |
CleanupStack::PopAndDestroy(session); |
|
1377 |
} |
|
1378 |
CleanupStack::PopAndDestroy(filename); |
|
1379 |
CleanupStack::PopAndDestroy(calendarInfo); |
|
65
12af337248b1
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
60
diff
changeset
|
1380 |
} |
66 | 1381 |
CleanupStack::PopAndDestroy(calendarIterator); |
0
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1382 |
TRACE_EXIT_POINT; |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1383 |
} |
f979ecb2b13e
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1384 |
|
66 | 1385 |
// ----------------------------------------------------------------------------- |
1386 |
// CCalenGlobalData::RemoveCalendarL |
|
1387 |
// removes calendar file from the file system |
|
1388 |
// ----------------------------------------------------------------------------- |
|
1389 |
// |
|
1390 |
EXPORT_C void CCalenGlobalData::RemoveCalendarL(const TDesC& aCalendarFileName) |
|
1391 |
{ |
|
1392 |
TRACE_ENTRY_POINT; |
|
1393 |
||
1394 |
HBufC* calendarFilename = aCalendarFileName.AllocLC(); |
|
1395 |
TInt index = iFileMappingArray.Find( *calendarFilename, |
|
1396 |
CCalenGlobalData::CalenInfoIdentifierL); |
|
1397 |
||
1398 |
if( KErrNotFound == index ) |
|
1399 |
{ |
|
1400 |
CleanupStack::PopAndDestroy(calendarFilename); |
|
1401 |
// reconstruct the calendar list using the iterator |
|
1402 |
ConstructCalendarsListL(); |
|
1403 |
||
1404 |
TRACE_EXIT_POINT; |
|
1405 |
return; |
|
1406 |
} |
|
1407 |
||
1408 |
if( index >= 0 ) |
|
1409 |
{ |
|
1410 |
CCalenFileMapping* filemap = iFileMappingArray.operator [](index); |
|
1411 |
CCalSession* session = filemap->GetSessionPtr(); |
|
1412 |
if(session) |
|
1413 |
{ |
|
1414 |
TRAPD(err, session->DeleteCalFileL(aCalendarFileName)); |
|
1415 |
if( err == KErrInUse ) |
|
1416 |
{ |
|
1417 |
//Calendar file is opened by other application. |
|
1418 |
//Mark the file as deleted. Try delete the file at later time. |
|
1419 |
// Get the CalFile |
|
1420 |
CCalCalendarInfo* caleninfo = session->CalendarInfoL(); |
|
1421 |
CleanupStack::PushL(caleninfo); |
|
1422 |
||
1423 |
// Mark the CalFile as Hidden |
|
1424 |
caleninfo->SetEnabled( EFalse ); |
|
1425 |
||
1426 |
||
1427 |
TBuf8<KBuffLength> keyBuff; |
|
1428 |
||
1429 |
// Set the modification time as home time. |
|
1430 |
keyBuff.Zero(); |
|
1431 |
keyBuff.AppendNum(EModificationTime); |
|
1432 |
TTime modificationTime; |
|
1433 |
modificationTime.HomeTime(); |
|
1434 |
TPckgC<TTime> pkgModificationTime(modificationTime); |
|
1435 |
caleninfo->SetPropertyL(keyBuff, pkgModificationTime); |
|
1436 |
||
1437 |
// Set the SyncStatus to False |
|
1438 |
keyBuff.Zero(); |
|
1439 |
keyBuff.AppendNum( ESyncStatus ); |
|
1440 |
TBool syncstatus( EFalse ); |
|
1441 |
TPckgC<TBool> pckgSyncStatusValue( syncstatus ); |
|
1442 |
caleninfo->SetPropertyL( keyBuff, pckgSyncStatusValue ); |
|
1443 |
||
1444 |
// Mark the meta property as SoftDeleted |
|
1445 |
keyBuff.Zero(); |
|
1446 |
keyBuff.AppendNum(EMarkAsDelete); |
|
1447 |
TPckgC<TBool> pkgSoftDelete( ETrue ); |
|
1448 |
caleninfo->SetPropertyL(keyBuff, pkgSoftDelete); |
|
1449 |
||
1450 |
session->SetCalendarInfoL( *caleninfo ); |
|
1451 |
CleanupStack::PopAndDestroy(caleninfo); |
|
1452 |
} |
|
1453 |
||
1454 |
TRAP_IGNORE(DeleteCalendarMissedAlarmsL(aCalendarFileName)); |
|
1455 |
||
1456 |
TInt infoListIndex = iCalendarInfoList.Find(*calendarFilename, |
|
1457 |
CCalenGlobalData::CalenCalendarInfoIdentiferL); |
|
1458 |
||
1459 |
CCalCalendarInfo* calendarInfo = iCalendarInfoList[infoListIndex]; |
|
1460 |
iCalendarInfoList.Remove(infoListIndex); |
|
1461 |
delete calendarInfo; |
|
1462 |
calendarInfo = NULL; |
|
1463 |
||
1464 |
iHashDbidIndexMap.Close(); |
|
1465 |
||
1466 |
iFileMappingArray.Remove(index); |
|
1467 |
delete filemap; |
|
1468 |
for(TInt index = 0; index < iFileMappingArray.Count(); index++) |
|
1469 |
{ |
|
1470 |
iHashDbidIndexMap.InsertL(iFileMappingArray[index]->GetCollectionId(), index); |
|
1471 |
} |
|
1472 |
} |
|
1473 |
} |
|
1474 |
||
1475 |
||
1476 |
CleanupStack::PopAndDestroy(calendarFilename); |
|
1477 |
TRACE_EXIT_POINT; |
|
1478 |
} |
|
1479 |
||
1480 |
// ----------------------------------------------------------------------------- |
|
1481 |
// CCalenGlobalData::UpdateCalendarL |
|
1482 |
// updates calendar info for the calendar file |
|
1483 |
// ----------------------------------------------------------------------------- |
|
1484 |
// |
|
1485 |
EXPORT_C void CCalenGlobalData::UpdateCalendarL(CCalCalendarInfo* aCalendarInfo) |
|
1486 |
{ |
|
1487 |
TRACE_ENTRY_POINT; |
|
1488 |
||
1489 |
HBufC* calendar = aCalendarInfo->FileNameL().AllocLC(); |
|
1490 |
TInt index = iFileMappingArray.Find( *calendar, |
|
1491 |
CCalenGlobalData::CalenInfoIdentifierL); |
|
1492 |
||
1493 |
if(index != KErrNotFound) |
|
1494 |
{ |
|
1495 |
CCalSession* session = iFileMappingArray[index]->GetSessionPtr(); |
|
1496 |
if(session) |
|
1497 |
{ |
|
1498 |
session->SetCalendarInfoL(*aCalendarInfo); |
|
1499 |
} |
|
1500 |
} |
|
1501 |
CleanupStack::PopAndDestroy(calendar); |
|
1502 |
||
1503 |
TRACE_EXIT_POINT; |
|
1504 |
} |
|
1505 |
||
1506 |
// ----------------------------------------------------------------------------- |
|
1507 |
// CCalenGlobalData::GetCalFileNameForCollectionId |
|
1508 |
// Get Calendar file name for the given collectionid |
|
1509 |
// ----------------------------------------------------------------------------- |
|
1510 |
// |
|
1511 |
EXPORT_C const TDesC& CCalenGlobalData::GetCalFileNameForCollectionId( |
|
1512 |
const TCalCollectionId aColId) |
|
1513 |
{ |
|
1514 |
TRACE_ENTRY_POINT; |
|
1515 |
||
1516 |
TInt index = iFileMappingArray.Find( aColId, |
|
1517 |
CCalenGlobalData::CalenFileMapIdentifierForColId ); |
|
1518 |
||
1519 |
if(index != KErrNotFound) |
|
1520 |
{ |
|
1521 |
TRACE_EXIT_POINT; |
|
1522 |
return iFileMappingArray[index]->GetCalendarFileName(); |
|
1523 |
} |
|
1524 |
else |
|
1525 |
{ |
|
1526 |
TRACE_EXIT_POINT; |
|
1527 |
return KNullDesC; |
|
1528 |
} |
|
1529 |
} |
|
1530 |
||
1531 |
// ----------------------------------------------------------------------------- |
|
1532 |
// CCalenGlobalData::GetAllCalendarInfoL |
|
1533 |
// Get all available calendar info |
|
1534 |
// ----------------------------------------------------------------------------- |
|
1535 |
// |
|
1536 |
EXPORT_C void CCalenGlobalData::GetAllCalendarInfoL( |
|
1537 |
RPointerArray<CCalCalendarInfo>& aCalendarInfoList ) |
|
1538 |
{ |
|
1539 |
TRACE_ENTRY_POINT; |
|
1540 |
CleanupClosePushL(aCalendarInfoList); |
|
1541 |
RFs fsSession; |
|
1542 |
CleanupClosePushL( fsSession ); |
|
1543 |
RResourceFile resourceFile; |
|
1544 |
CleanupClosePushL( resourceFile ); |
|
1545 |
User::LeaveIfError( fsSession.Connect() ); |
|
1546 |
TFileName resourceFileName( KMissedAlarmResourceFile ); |
|
1547 |
||
1548 |
BaflUtils::NearestLanguageFile( fsSession, resourceFileName ); |
|
1549 |
resourceFile.OpenL(fsSession, resourceFileName ); |
|
1550 |
resourceFile.ConfirmSignatureL( 0 ); |
|
1551 |
for(TInt index=0;index < iCalendarInfoList.Count();index++) |
|
1552 |
{ |
|
1553 |
||
1554 |
TPtrC calendarNamePtr = iCalendarInfoList[index]->NameL(); |
|
1555 |
if(calendarNamePtr.Compare(KPersonal) == 0) |
|
1556 |
{ |
|
1557 |
HBufC8* personalBuffer = resourceFile.AllocReadLC( R_CALE_DB_PERSONAL ); |
|
1558 |
const TPtrC16 ptrPBuffer(( TText16*) personalBuffer->Ptr(), |
|
1559 |
( personalBuffer->Length()+1 )>>1 ); |
|
1560 |
HBufC *personalCalendar = ptrPBuffer.AllocL(); |
|
1561 |
CleanupStack::PushL(personalCalendar); |
|
1562 |
iCalendarInfoList[index]->SetNameL(*personalCalendar); |
|
1563 |
CleanupStack::PopAndDestroy( 2,personalBuffer ); |
|
1564 |
} |
|
1565 |
||
1566 |
||
1567 |
aCalendarInfoList.AppendL(iCalendarInfoList[index]); |
|
1568 |
||
1569 |
} |
|
1570 |
CleanupStack::PopAndDestroy(2); |
|
1571 |
CleanupStack::Pop(&aCalendarInfoList); |
|
1572 |
TRACE_EXIT_POINT; |
|
1573 |
} |
|
1574 |
||
1575 |
// ----------------------------------------------------------------------------- |
|
1576 |
// CCalenGlobalData::CreateNewSessionL |
|
1577 |
// Create new session with metadata |
|
1578 |
// ----------------------------------------------------------------------------- |
|
1579 |
// |
|
1580 |
CCalSession& CCalenGlobalData::CreateNewSessionL( const TDesC& aCalendar, |
|
1581 |
const CCalCalendarInfo& aCalendarInfo ) |
|
1582 |
{ |
|
1583 |
TRACE_ENTRY_POINT; |
|
1584 |
||
1585 |
if(!iNewCalSession) |
|
1586 |
{ |
|
1587 |
iNewCalSession = CCalSession::NewL(*iCalSession); |
|
1588 |
||
1589 |
TRAPD( err, iNewCalSession->OpenL(aCalendar)); |
|
1590 |
if ( err == KErrNotFound ) |
|
1591 |
{ |
|
1592 |
iNewCalSession->CreateCalFileL( aCalendar, aCalendarInfo ); |
|
1593 |
iNewCalSession->OpenL(aCalendar); // not trapped anymore |
|
1594 |
} |
|
1595 |
else |
|
1596 |
{ |
|
1597 |
User::LeaveIfError( err ); |
|
1598 |
} |
|
1599 |
} |
|
1600 |
TRACE_EXIT_POINT; |
|
1601 |
return *iNewCalSession; |
|
1602 |
} |
|
1603 |
||
1604 |
// ----------------------------------------------------------------------------- |
|
1605 |
// CCalenGlobalData::CalenFileMapIdentifierForColId |
|
1606 |
// Search for filemap index based on collection id |
|
1607 |
// ----------------------------------------------------------------------------- |
|
1608 |
// |
|
1609 |
TBool CCalenGlobalData::CalenFileMapIdentifierForColId(const TCalCollectionId* aId, |
|
1610 |
const CCalenFileMapping& aFileMapping ) |
|
1611 |
{ |
|
1612 |
TRACE_ENTRY_POINT; |
|
1613 |
TRACE_EXIT_POINT; |
|
1614 |
return (*aId == (aFileMapping.GetCollectionId())); |
|
1615 |
} |
|
1616 |
||
1617 |
// ----------------------------------------------------------------------------- |
|
1618 |
// CCalenGlobalData::CalenCalendarInfoIdentiferL |
|
1619 |
// Construct calendar list from the calendar iterator |
|
1620 |
// ----------------------------------------------------------------------------- |
|
1621 |
// |
|
1622 |
TBool CCalenGlobalData::CalenCalendarInfoIdentiferL(const HBufC* aFileName, |
|
1623 |
const CCalCalendarInfo& aCalendarInfo) |
|
1624 |
{ |
|
1625 |
TRACE_ENTRY_POINT |
|
1626 |
TPtrC calendarFileName = aCalendarInfo.FileNameL(); |
|
1627 |
TRACE_EXIT_POINT |
|
1628 |
return (!calendarFileName.CompareF(*aFileName) ); |
|
1629 |
} |
|
1630 |
||
1631 |
// ----------------------------------------------------------------------------- |
|
1632 |
// CCalenGlobalData::ConstructCalendarsListL |
|
1633 |
// Construct calendar list from the calendar iterator |
|
1634 |
// ----------------------------------------------------------------------------- |
|
1635 |
// |
|
1636 |
void CCalenGlobalData::ConstructCalendarsListL() |
|
1637 |
{ |
|
1638 |
TRACE_ENTRY_POINT; |
|
1639 |
||
1640 |
iCalendarInfoList.ResetAndDestroy(); |
|
1641 |
CCalCalendarIterator* calendarIterator = |
|
1642 |
CCalCalendarIterator::NewL(*iCalendarsSession); |
|
1643 |
CleanupStack::PushL(calendarIterator); |
|
1644 |
||
1645 |
for( CCalCalendarInfo* calendarInfo = calendarIterator->FirstL(); |
|
1646 |
calendarInfo!=NULL;calendarInfo = calendarIterator->NextL()) |
|
1647 |
{ |
|
1648 |
TBuf8<KBuffLength> keyBuff; |
|
1649 |
// Mark the meta property as SoftDeleted |
|
1650 |
keyBuff.Zero(); |
|
1651 |
keyBuff.AppendNum(EMarkAsDelete); |
|
1652 |
TBool softDelete = EFalse; |
|
1653 |
TPckgC<TBool> pkgSoftDelete( softDelete ); |
|
1654 |
TRAPD(err,pkgSoftDelete.Set(calendarInfo->PropertyValueL(keyBuff))); |
|
1655 |
if( KErrNone == err ) |
|
1656 |
{ |
|
1657 |
softDelete = pkgSoftDelete(); |
|
1658 |
} |
|
1659 |
if( softDelete && |
|
78
356f28cd5ca0
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1660 |
calendarInfo->FileNameL().CompareF(KCalendarDatabaseFilePath) ) |
66 | 1661 |
{ |
1662 |
// delete caleninfo except for default calendar. |
|
1663 |
delete calendarInfo; |
|
1664 |
} |
|
1665 |
else |
|
1666 |
{ |
|
1667 |
iCalendarInfoList.Append(calendarInfo); |
|
1668 |
} |
|
1669 |
} |
|
1670 |
CleanupStack::PopAndDestroy(calendarIterator); |
|
1671 |
||
1672 |
TRACE_EXIT_POINT; |
|
1673 |
} |
|
1674 |
||
1675 |
// ----------------------------------------------------------------------------- |
|
1676 |
// CCalenGlobalData::UpdateCalendarListL |
|
1677 |
// Update calendar list whenever CalendarInfoUpdated notification is received. |
|
1678 |
// ----------------------------------------------------------------------------- |
|
1679 |
// |
|
1680 |
void CCalenGlobalData::UpdateCalendarListL() |
|
1681 |
{ |
|
1682 |
//Getting calendar name updated from calennotifier infochangednotification |
|
1683 |
HBufC* calendarNameUpdated = iContext->GetCalendarFileNameL().AllocLC(); |
|
1684 |
TInt index = iFileMappingArray.Find( *calendarNameUpdated, |
|
1685 |
CCalenGlobalData::CalenInfoIdentifierL); |
|
1686 |
||
1687 |
if(index != KErrNotFound) |
|
1688 |
{ |
|
1689 |
CCalSession* session = iFileMappingArray[index]->GetSessionPtr(); |
|
1690 |
for(TInt i=0; i<iCalendarInfoList.Count() ;i++) |
|
1691 |
{ |
|
1692 |
if( !iCalendarInfoList[i]->FileNameL().CompareF(calendarNameUpdated->Des())) |
|
1693 |
{ |
|
1694 |
iCalendarInfoList[i] = session->CalendarInfoL(); |
|
1695 |
} |
|
1696 |
} |
|
1697 |
} |
|
1698 |
CleanupStack::PopAndDestroy(calendarNameUpdated); |
|
1699 |
} |
|
1700 |
// ----------------------------------------------------------------------------- |
|
1701 |
// CCalenGlobalData::GetDefaultCalendarInfoL |
|
1702 |
// Get default calendar info |
|
1703 |
// ----------------------------------------------------------------------------- |
|
1704 |
// |
|
1705 |
CCalCalendarInfo* CCalenGlobalData::GetDefaultCalendarInfoL() |
|
1706 |
{ |
|
1707 |
TRACE_ENTRY_POINT; |
|
1708 |
||
1709 |
CCalCalendarInfo* defaultCalendarInfo = CCalCalendarInfo::NewL(); |
|
1710 |
CleanupStack::PushL(defaultCalendarInfo); |
|
1711 |
defaultCalendarInfo->SetColor(KCalenBlue.Value()); |
|
1712 |
defaultCalendarInfo->SetEnabled(ETrue); |
|
1713 |
defaultCalendarInfo->SetNameL(KPhoneCalendar); |
|
1714 |
CleanupStack::Pop(defaultCalendarInfo); |
|
1715 |
||
1716 |
TRACE_EXIT_POINT; |
|
1717 |
return defaultCalendarInfo; |
|
1718 |
} |
|
1719 |
||
1720 |
// ----------------------------------------------------------------------------- |
|
1721 |
// CCalenGlobalData::HandleCalendarInfoCreatedL |
|
1722 |
// Handles the notification ECalenNotifyCalendarInfoCreated |
|
1723 |
// ----------------------------------------------------------------------------- |
|
1724 |
// |
|
1725 |
void CCalenGlobalData::HandleCalendarInfoCreatedL() |
|
1726 |
{ |
|
1727 |
TRACE_ENTRY_POINT; |
|
1728 |
// get the filename from the context |
|
1729 |
TDesC& fileName = iContext->GetCalendarFileNameL(); |
|
1730 |
||
1731 |
// check for the calendar file already exists in filemap list |
|
1732 |
HBufC* calendar = fileName.AllocLC(); |
|
1733 |
TInt index = iFileMappingArray.Find(*calendar, |
|
1734 |
CCalenGlobalData::CalenInfoIdentifierL); |
|
1735 |
CleanupStack::PopAndDestroy(calendar); |
|
1736 |
||
1737 |
// if not exists,add to filemapper list |
|
1738 |
if (KErrNotFound == index) |
|
1739 |
{ |
|
1740 |
CCalenFileMapping* fileMapper = CCalenFileMapping::NewL(); |
|
1741 |
CleanupStack::PushL(fileMapper); |
|
1742 |
fileMapper->SetCalendarFileNameL(fileName); |
|
1743 |
||
1744 |
iNewEntryView = NULL; |
|
1745 |
iNewEntryViewCreation = NULL; |
|
1746 |
CCalSession* newSession = NULL; |
|
1747 |
if(iCalSession) |
|
1748 |
{ |
|
1749 |
// create the new session using default session |
|
1750 |
newSession = CCalSession::NewL(*iCalSession); |
|
1751 |
CleanupStack::PushL(newSession); |
|
1752 |
TRAPD(err,newSession->OpenL(fileName)); |
|
1753 |
User::LeaveIfError( err ); |
|
1754 |
CleanupStack::Pop(newSession); |
|
1755 |
// set filemapper data |
|
1756 |
fileMapper->SetSessionPtr(newSession); |
|
1757 |
fileMapper->SetCollectionId(newSession->CollectionIdL()); |
|
1758 |
||
1759 |
if(!iCalendarForcedExit) |
|
1760 |
{ |
|
1761 |
CreateEntryViewL(*newSession); |
|
1762 |
} |
|
1763 |
fileMapper->SetEntryView( iNewEntryView ); |
|
1764 |
||
1765 |
iCalendarInfoList.AppendL(newSession->CalendarInfoL()); |
|
1766 |
CCalenDbChangeNotifier* dbChangeNotifier = CCalenDbChangeNotifier::NewL( *newSession ); |
|
1767 |
dbChangeNotifier->RegisterObserverL(*iDBChangeNotifier); |
|
1768 |
fileMapper->SetDBChangeNotifier(dbChangeNotifier); |
|
1769 |
} |
|
1770 |
else |
|
1771 |
{ |
|
1772 |
// create the first session |
|
1773 |
iCalSession = CCalSession::NewL(); |
|
1774 |
TRAPD(err,iCalSession->OpenL(fileName)); |
|
1775 |
User::LeaveIfError(err); |
|
1776 |
||
1777 |
// set filemapper data |
|
1778 |
fileMapper->SetSessionPtr(iCalSession); |
|
1779 |
fileMapper->SetCollectionId(iCalSession->CollectionIdL()); |
|
1780 |
||
1781 |
if(!iCalendarForcedExit) |
|
1782 |
{ |
|
1783 |
CreateEntryViewL(*iCalSession); |
|
1784 |
} |
|
1785 |
||
1786 |
fileMapper->SetEntryView(iNewEntryView); |
|
1787 |
CCalenDbChangeNotifier* dbChangeNotifier = CCalenDbChangeNotifier::NewL( *iCalSession ); |
|
1788 |
fileMapper->SetDBChangeNotifier(dbChangeNotifier); |
|
1789 |
dbChangeNotifier->RegisterObserverL(*iDBChangeNotifier); |
|
1790 |
iGlobalDataOwnsEntryView = EFalse; |
|
1791 |
iGlobalDataOwnsCalSession = EFalse; |
|
1792 |
iCalendarInfoList.AppendL(iCalSession->CalendarInfoL()); |
|
1793 |
} |
|
1794 |
// append to filemapper list |
|
1795 |
iFileMappingArray.Append(fileMapper); |
|
1796 |
CleanupStack::Pop(fileMapper); |
|
1797 |
||
1798 |
iHashDbidIndexMap.Close(); |
|
1799 |
for(TInt index = 0; index < iFileMappingArray.Count(); index++) |
|
1800 |
{ |
|
1801 |
iHashDbidIndexMap.InsertL( |
|
1802 |
iFileMappingArray[index]->GetCollectionId(), index); |
|
1803 |
} |
|
1804 |
} |
|
1805 |
TRACE_EXIT_POINT; |
|
1806 |
} |
|
1807 |
||
1808 |
// ----------------------------------------------------------------------------- |
|
1809 |
// CCalenGlobalData::HandleCalendarInfoUpdatedL |
|
1810 |
// Handles the notification ECalenNotifyCalendarInfoUpdated |
|
1811 |
// ----------------------------------------------------------------------------- |
|
1812 |
// |
|
1813 |
void CCalenGlobalData::HandleCalendarInfoUpdatedL() |
|
1814 |
{ |
|
1815 |
TRACE_ENTRY_POINT; |
|
1816 |
||
1817 |
//Update Calendar list. |
|
1818 |
UpdateCalendarListL(); |
|
1819 |
||
1820 |
TRACE_EXIT_POINT; |
|
1821 |
} |
|
1822 |
||
1823 |
// ----------------------------------------------------------------------------- |
|
1824 |
// CCalenGlobalData::HandleCalendarFileDeletedL |
|
1825 |
// Handles the notification ECalenNotifyCalendarFileDeleted |
|
1826 |
// ----------------------------------------------------------------------------- |
|
1827 |
// |
|
1828 |
void CCalenGlobalData::HandleCalendarFileDeletedL() |
|
1829 |
{ |
|
1830 |
TRACE_ENTRY_POINT; |
|
1831 |
||
1832 |
// get the filename from the context |
|
1833 |
TDesC& fileName = iContext->GetCalendarFileNameL(); |
|
1834 |
||
1835 |
// delete the calendar file |
|
1836 |
RemoveCalendarL(fileName); |
|
1837 |
||
1838 |
TRACE_EXIT_POINT; |
|
1839 |
} |
|
1840 |
||
1841 |
// ----------------------------------------------------------------------------- |
|
1842 |
// CCalenGlobalData::DeleteCalendarMissedAlarmsL |
|
1843 |
// Delete all missed alarms for deleted calendar |
|
1844 |
// ----------------------------------------------------------------------------- |
|
1845 |
// |
|
1846 |
void CCalenGlobalData::DeleteCalendarMissedAlarmsL(const TDesC& aCalendarFilename) |
|
1847 |
{ |
|
1848 |
TRACE_ENTRY_POINT |
|
1849 |
//Clear all missed alarms related to this calendar |
|
1850 |
CMissedAlarmStore* missedAlarmStore = CMissedAlarmStore::NewLC(); |
|
1851 |
RPointerArray<CMissedAlarm> missedAlarms; |
|
1852 |
CleanupResetAndDestroyPushL(missedAlarms); |
|
1853 |
||
1854 |
missedAlarmStore->GetL(missedAlarms); |
|
1855 |
||
1856 |
for (TInt idx = 0; idx < missedAlarms.Count(); idx++) |
|
1857 |
{ |
|
1858 |
CMissedAlarm* missedAlarm = missedAlarms[idx]; |
|
1859 |
if (!missedAlarm->iCalFileName.CompareF(aCalendarFilename)) |
|
1860 |
{ |
|
1861 |
missedAlarmStore->RemoveL(*missedAlarm); |
|
1862 |
} |
|
1863 |
} |
|
1864 |
||
1865 |
CleanupStack::PopAndDestroy(&missedAlarms); |
|
1866 |
CleanupStack::PopAndDestroy(missedAlarmStore); |
|
1867 |
TRACE_EXIT_POINT |
|
1868 |
} |
|
1869 |
||
1870 |
// End of file |