|
1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This file implements class CESMRCalDbNormal. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //INCLUDE FILES |
|
20 #include "emailtrace.h" |
|
21 #include "cesmrcaldbnormal.h" |
|
22 |
|
23 // From System |
|
24 #include <calentryview.h> |
|
25 #include <calinstanceview.h> |
|
26 #include <calentry.h> |
|
27 #include <calsession.h> |
|
28 #include <calcommon.h> |
|
29 #include <caluser.h> |
|
30 |
|
31 // CONSTANTS |
|
32 /// Unnamed namespace for local definitions |
|
33 namespace { |
|
34 |
|
35 #ifdef _DEBUG |
|
36 |
|
37 // Cal db normal panic text |
|
38 _LIT( KESMRCalDbNormalTxt, "CESMRCalDbNormal" ); |
|
39 |
|
40 // Cal db normal panic codes |
|
41 enum TESMRCalDbNormalPanicCode |
|
42 { |
|
43 EESMRCalDbNormalUnexpectedCalEngStatus = 1 |
|
44 }; |
|
45 |
|
46 void Panic( TESMRCalDbNormalPanicCode aReason ) |
|
47 { |
|
48 User::Panic( KESMRCalDbNormalTxt, aReason ); |
|
49 } |
|
50 |
|
51 #endif |
|
52 |
|
53 } // namespace |
|
54 |
|
55 |
|
56 // ======== MEMBER FUNCTIONS ======== |
|
57 |
|
58 // ---------------------------------------------------------------------------- |
|
59 // CESMRCalDbNormal::CESMRCalDbNormal |
|
60 // ---------------------------------------------------------------------------- |
|
61 // |
|
62 CESMRCalDbNormal::CESMRCalDbNormal( |
|
63 CCalSession& aCalSession, |
|
64 MESMRCalDbObserver& aDbObserver, |
|
65 MCalProgressCallBack& aCmdObserver ) |
|
66 : CESMRCalDbBase( aDbObserver, aCmdObserver ) |
|
67 { |
|
68 FUNC_LOG; |
|
69 // This subclass of CMRUtilsCalDbBase doesn't own the session |
|
70 iCalSession = &aCalSession; |
|
71 } |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // CESMRCalDbNormal::~CESMRCalDbNormal |
|
75 // |
|
76 // Destructor. |
|
77 // ---------------------------------------------------------------------------- |
|
78 // |
|
79 CESMRCalDbNormal::~CESMRCalDbNormal() |
|
80 { |
|
81 FUNC_LOG; |
|
82 delete iCalEntryView; |
|
83 delete iCalInstanceView; |
|
84 } |
|
85 |
|
86 // ---------------------------------------------------------------------------- |
|
87 // CESMRCalDbNormal::NewL |
|
88 // ---------------------------------------------------------------------------- |
|
89 // |
|
90 CESMRCalDbNormal* CESMRCalDbNormal::NewL( |
|
91 CCalSession& aCalSession, |
|
92 MESMRCalDbObserver& aDbObserver, |
|
93 MCalProgressCallBack& aCmdObserver ) |
|
94 { |
|
95 FUNC_LOG; |
|
96 |
|
97 CESMRCalDbNormal* self = |
|
98 new( ELeave ) CESMRCalDbNormal( aCalSession, |
|
99 aDbObserver, |
|
100 aCmdObserver ); |
|
101 CleanupStack::PushL( self ); |
|
102 self->ConstructL(); |
|
103 CleanupStack::Pop(); |
|
104 |
|
105 |
|
106 return self; |
|
107 } |
|
108 |
|
109 // ---------------------------------------------------------------------------- |
|
110 // CESMRCalDbNormal::ConstructL |
|
111 // ---------------------------------------------------------------------------- |
|
112 // |
|
113 void CESMRCalDbNormal::ConstructL() |
|
114 { |
|
115 FUNC_LOG; |
|
116 |
|
117 iCalEntryView = CCalEntryView::NewL( *iCalSession, *this ); |
|
118 iDbStatus = MESMRCalDbObserver::EInitEntryView; |
|
119 // See Completed() for continuation... |
|
120 |
|
121 } |
|
122 |
|
123 // ---------------------------------------------------------------------------- |
|
124 // CESMRCalDbNormal::Completed |
|
125 // ---------------------------------------------------------------------------- |
|
126 // |
|
127 void CESMRCalDbNormal::Completed( TInt aError ) |
|
128 { |
|
129 FUNC_LOG; |
|
130 |
|
131 if ( aError == KErrNone ) |
|
132 { |
|
133 if ( iDbStatus == MESMRCalDbObserver::EInitEntryView ) |
|
134 { // Entry view successfully initialized, create instance view next |
|
135 |
|
136 TRAPD( err, iCalInstanceView = |
|
137 CCalInstanceView::NewL( *iCalSession, *this ) ); |
|
138 if ( err == KErrNone ) |
|
139 { // Instance view initialization started: |
|
140 iDbStatus = MESMRCalDbObserver::EInitInstanceView; |
|
141 } |
|
142 else |
|
143 { // Instance view creation failed, cal engine not usable: |
|
144 iDbStatus = MESMRCalDbObserver::EFinishedError; |
|
145 } |
|
146 } |
|
147 else |
|
148 { // Instance view successfully initialized |
|
149 __ASSERT_DEBUG( iDbStatus == MESMRCalDbObserver::EInitInstanceView, |
|
150 Panic( EESMRCalDbNormalUnexpectedCalEngStatus ) ); |
|
151 iDbStatus = MESMRCalDbObserver::EFinishedOk; |
|
152 } |
|
153 } |
|
154 else |
|
155 { // Initialization error has occurred, cal engine not usable: |
|
156 iDbStatus = MESMRCalDbObserver::EFinishedError; |
|
157 } |
|
158 |
|
159 // If either of the final states has been reached, then notify observer: |
|
160 if ( iDbStatus == MESMRCalDbObserver::EFinishedOk || |
|
161 iDbStatus == MESMRCalDbObserver::EFinishedError ) |
|
162 { |
|
163 iDbObserver.HandleCalDbStatus( this, iDbStatus ); |
|
164 } |
|
165 |
|
166 } |
|
167 |
|
168 // End of file |
|
169 |