|
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: Implementation for meeting request viewers |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // ---------------------------------------------------------------------------- |
|
21 // INCLUDE FILES |
|
22 // ---------------------------------------------------------------------------- |
|
23 // |
|
24 #include "CMRViewersImpl.h" |
|
25 #include "ICalUILog.h" |
|
26 #include "MRHelpers.h" |
|
27 #include "CMRHandler.h" |
|
28 #include "MRViewersPanic.h" //panic enums |
|
29 #include <coemain.h> //coe env |
|
30 #include <bautils.h> //bafl utils |
|
31 #include <data_caging_path_literals.hrh> //data caging constants |
|
32 #include <f32file.h> //file server session |
|
33 #include <CMRMailboxUtils.h> |
|
34 |
|
35 // CONSTANTS |
|
36 /// Unnamed namespace for local definitions |
|
37 namespace { |
|
38 |
|
39 _LIT( KPanicMsg, "CMRViewersImpl" ); |
|
40 |
|
41 void Panic( TPanicCode aReason ) |
|
42 { |
|
43 User::Panic( KPanicMsg, aReason ); |
|
44 } |
|
45 |
|
46 _LIT( KResourceFileName,"meetingrequestviewersuires.rsc" ); |
|
47 |
|
48 } // namespace |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // MEMBER FUNCTIONS |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 |
|
55 // ---------------------------------------------------------------------------- |
|
56 // CMRViewersImpl::NewL |
|
57 // ---------------------------------------------------------------------------- |
|
58 // |
|
59 CMRViewersImpl* CMRViewersImpl::NewL( TAny* aMtmUid ) |
|
60 { |
|
61 CMRViewersImpl* self = new( ELeave ) CMRViewersImpl( aMtmUid ); |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL(); |
|
64 CleanupStack::Pop(); |
|
65 return self; |
|
66 } |
|
67 |
|
68 // ---------------------------------------------------------------------------- |
|
69 // CMRViewersImpl::CMRViewersImpl |
|
70 // |
|
71 // Constructor. |
|
72 // ---------------------------------------------------------------------------- |
|
73 // |
|
74 CMRViewersImpl::CMRViewersImpl( TAny* aMtmUid ) |
|
75 : iEngStatus( ENotReady ) |
|
76 { |
|
77 iMtmUid = reinterpret_cast<HBufC8*>( aMtmUid ); // ownership transferred |
|
78 } |
|
79 |
|
80 // ---------------------------------------------------------------------------- |
|
81 // CMRViewersImpl::~CMRViewersImpl |
|
82 // |
|
83 // Destructor. |
|
84 // ---------------------------------------------------------------------------- |
|
85 // |
|
86 CMRViewersImpl::~CMRViewersImpl() |
|
87 { |
|
88 LOG("CMRViewersImpl::~CMRViewersImpl"); |
|
89 delete iIdleTimer; |
|
90 delete iMtmUid; |
|
91 delete iMRHandler; |
|
92 delete iMRUtils; |
|
93 delete iMRMailboxUtils; |
|
94 |
|
95 if ( iResourceFileOffset ) |
|
96 { |
|
97 CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset ); |
|
98 } |
|
99 |
|
100 LOG("CMRViewersImpl::~CMRViewersImpl -> End"); |
|
101 } |
|
102 |
|
103 // ---------------------------------------------------------------------------- |
|
104 // CMRViewersImpl::ConstructL |
|
105 // ---------------------------------------------------------------------------- |
|
106 // |
|
107 void CMRViewersImpl::ConstructL() |
|
108 { |
|
109 LOG("CMRViewersImpl::ConstructL, loading resource"); |
|
110 iResourceFileOffset = MRHelpers::LoadResourceL( KResourceFileName, |
|
111 KDC_RESOURCE_FILES_DIR ); |
|
112 LOG("CMRViewersImpl::ConstructL -> End"); |
|
113 } |
|
114 |
|
115 // ---------------------------------------------------------------------------- |
|
116 // CMRViewersImpl::ExecuteViewL |
|
117 // ---------------------------------------------------------------------------- |
|
118 // |
|
119 TInt CMRViewersImpl::ExecuteViewL( |
|
120 RPointerArray<CCalEntry>& aEntries, |
|
121 const TAgnEntryUiInParams& aInParams, |
|
122 TAgnEntryUiOutParams& aOutParams, |
|
123 MAgnEntryUiCallback& aCallback) |
|
124 { |
|
125 LOG("CMRViewersImpl::ExecuteViewL"); |
|
126 TInt returnCode( KErrNone ); |
|
127 |
|
128 // check that utils objects (configured to use given sessions) exist: |
|
129 EnsureUtilsExistL( &( aInParams.iCalSession ), aInParams.iMsgSession ); |
|
130 |
|
131 // CMRHandler is not reusable, must be re-created each time |
|
132 LOG("CMRViewersImpl::ExecuteViewL, creating iMRHandler"); |
|
133 delete iMRHandler; |
|
134 iMRHandler = NULL; |
|
135 iMRHandler = CMRHandler::NewL( aEntries, |
|
136 aInParams, |
|
137 aOutParams, |
|
138 aCallback ); |
|
139 iMRHandler->SetHelpContext( *iContext ); |
|
140 |
|
141 LOG("CMRViewersImpl::ExecuteViewL, executing view"); |
|
142 returnCode = iMRHandler->ExecuteViewL(); |
|
143 |
|
144 LOG("CMRViewersImpl::ExecuteViewL -> End"); |
|
145 return returnCode; |
|
146 } |
|
147 |
|
148 // ---------------------------------------------------------------------------- |
|
149 // CMRViewersImpl::SetHelpContext |
|
150 // ---------------------------------------------------------------------------- |
|
151 // |
|
152 void CMRViewersImpl::SetHelpContext( |
|
153 const TCoeHelpContext& aContext ) |
|
154 { |
|
155 iContext = &aContext; |
|
156 } |
|
157 |
|
158 // ---------------------------------------------------------------------------- |
|
159 // CMRViewersImpl::EnsureUtilsExistL |
|
160 // Will cause HandleCalEngStatus() callback regardless MR Utils is created |
|
161 // or not. It is done that way to ensure that program flow is similar in |
|
162 // both cases. |
|
163 // ---------------------------------------------------------------------------- |
|
164 // |
|
165 void CMRViewersImpl::EnsureUtilsExistL( |
|
166 CCalSession* aCalSession, |
|
167 CMsvSession* aMsgSession ) |
|
168 { |
|
169 // no iMRUtils exist or session has changed so that must re-instantiate |
|
170 if ( !iMRUtils || |
|
171 aCalSession != iCalSession || |
|
172 aMsgSession != iMsgSession ) |
|
173 { |
|
174 delete iMRUtils; |
|
175 iMRUtils = NULL; |
|
176 LOG("CMRViewersImpl::EnsureUtilsExistL, creating iMRUtils"); |
|
177 iMRUtils = CMRUtilsInternal::NewL( *this, |
|
178 *aCalSession, |
|
179 aMsgSession ); |
|
180 } |
|
181 else |
|
182 { |
|
183 delete iIdleTimer; |
|
184 iIdleTimer = NULL; |
|
185 iIdleTimer = CIdle::NewL( CActive::EPriorityIdle ); |
|
186 iIdleTimer->Start( TCallBack( HandleEngStatusCheck, this ) ); |
|
187 } |
|
188 |
|
189 // no iMRMailboxUtils exists or session has changed |
|
190 if ( !iMRMailboxUtils || aMsgSession != iMsgSession ) |
|
191 { |
|
192 delete iMRMailboxUtils; |
|
193 iMRMailboxUtils = NULL; |
|
194 LOG("CMRViewersImpl::EnsureUtilsExistL, creating iMRMailboxUtils"); |
|
195 iMRMailboxUtils = CMRMailboxUtils::NewL( aMsgSession ); |
|
196 } |
|
197 |
|
198 // now set session pointer members to contain current values: |
|
199 iCalSession = aCalSession; |
|
200 iMsgSession = aMsgSession; |
|
201 } |
|
202 |
|
203 // ---------------------------------------------------------------------------- |
|
204 // CMRViewersImpl::HandleEngStatusCheck |
|
205 // ---------------------------------------------------------------------------- |
|
206 // |
|
207 TInt CMRViewersImpl::HandleEngStatusCheck( TAny* aThis ) |
|
208 { |
|
209 CMRViewersImpl* self = static_cast<CMRViewersImpl*>( aThis ); |
|
210 self->HandleCalEngStatus( self->iEngStatus ); |
|
211 delete self->iIdleTimer; |
|
212 self->iIdleTimer = NULL; |
|
213 return 0; |
|
214 } |
|
215 |
|
216 // ---------------------------------------------------------------------------- |
|
217 // CMRViewersImpl::HandleCalEngStatus |
|
218 // ---------------------------------------------------------------------------- |
|
219 // |
|
220 void CMRViewersImpl::HandleCalEngStatus( TMRUtilsCalEngStatus aStatus ) |
|
221 { |
|
222 iEngStatus = aStatus; |
|
223 TRAPD( err, DoHandleCalEngStatusL( iEngStatus) ); |
|
224 if ( err ) |
|
225 { |
|
226 // TODO: handle severe error, no meeting request can be shown, |
|
227 // either show error note and empty viewer or exit viewer. |
|
228 // Notice that in theory status events can be received at any time, |
|
229 // viewer might be already happily running. |
|
230 } |
|
231 } |
|
232 |
|
233 // ---------------------------------------------------------------------------- |
|
234 // CMRViewersImpl::DoHandleCalEngStatusL |
|
235 // ---------------------------------------------------------------------------- |
|
236 // |
|
237 void CMRViewersImpl::DoHandleCalEngStatusL( TMRUtilsCalEngStatus aStatus ) |
|
238 { |
|
239 LOG("CMRViewersImpl::DoHandleCalEngStatusL"); |
|
240 if ( aStatus == MMRUtilsObserver::EAvailable ) |
|
241 { |
|
242 iMRHandler->HandleEngReadyL( *iMtmUid, *iMRUtils, *iMRMailboxUtils ); |
|
243 } |
|
244 else |
|
245 { // Problem in the cal eng status, handle error |
|
246 LOG("CMRViewersImpl::DoHandleCalEngStatusL, bad cal eng status"); |
|
247 User::Leave( KErrGeneral ); |
|
248 } |
|
249 LOG("CMRViewersImpl::DoHandleCalEngStatusL -> End"); |
|
250 } |
|
251 |
|
252 // End of file |