|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CalenDefaultEditors calss definition |
|
15 * |
|
16 */ |
|
17 |
|
18 // user includes |
|
19 #include "CalenDefaultEditors.h" |
|
20 #include "CalenDefaultEditors.hrh" |
|
21 #include "calennotedatautil.h" |
|
22 #include "calenentryutil.h" |
|
23 #include "calenunifiededitor.h" |
|
24 |
|
25 // system includes |
|
26 #include <CalenDefaultEditorsData.rsg> |
|
27 #include <avkon.hrh> |
|
28 #include <calentry.h> |
|
29 #include <data_caging_path_literals.hrh> |
|
30 #include <eikappui.h> |
|
31 #include <eikcmobs.h> |
|
32 #include <eikenv.h> |
|
33 #include <pathinfo.h> |
|
34 #include <akntitle.h> |
|
35 #include <eikspane.h> |
|
36 #include <bautils.h> |
|
37 #include <aknnavi.h> |
|
38 #include <calcommon.h> |
|
39 #include <calrrule.h> |
|
40 #include <calenservices.h> |
|
41 #include <calencontext.h> |
|
42 #include <caleninstanceid.h> |
|
43 #include "CleanupResetAndDestroy.h" |
|
44 |
|
45 // debug |
|
46 #include "calendarui_debug.h" |
|
47 |
|
48 |
|
49 // local constants |
|
50 #define KResourcePath KDC_RESOURCE_FILES_DIR |
|
51 _LIT( KResourceFile, "CalenDefaultEditorsData.rsc" ); |
|
52 |
|
53 enum TPanicCode |
|
54 { |
|
55 EPanicCalenDefaultEditorsResourceLoading = 1, |
|
56 }; |
|
57 |
|
58 static void Panic( TPanicCode aReason ) |
|
59 { |
|
60 TRACE_ENTRY_POINT; |
|
61 |
|
62 _LIT( KPanicText, "CalenDefaultEditors" ); |
|
63 User::Panic( KPanicText,aReason ); |
|
64 |
|
65 TRACE_EXIT_POINT; |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CCalenDefaultEditors::NewL |
|
70 // Two staged constructor. |
|
71 // (other items were commented in a header). |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CCalenDefaultEditors* CCalenDefaultEditors::NewL() |
|
75 { |
|
76 TRACE_ENTRY_POINT; |
|
77 |
|
78 CCalenDefaultEditors* self = new ( ELeave ) CCalenDefaultEditors; |
|
79 CleanupStack::PushL( self ); |
|
80 self->ConstructL(); |
|
81 CleanupStack::Pop( self ); |
|
82 |
|
83 TRACE_EXIT_POINT; |
|
84 return self; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CCalenDefaultEditors::~CCalenDefaultEditors |
|
89 // Destructor. |
|
90 // (other items were commented in a header). |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 CCalenDefaultEditors::~CCalenDefaultEditors() |
|
94 { |
|
95 TRACE_ENTRY_POINT; |
|
96 |
|
97 iResourceLoader.Close(); |
|
98 |
|
99 TRACE_EXIT_POINT; |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CCalenDefaultEditors::CCalenDefaultEditors |
|
104 // Constructor. |
|
105 // (other items were commented in a header). |
|
106 // ----------------------------------------------------------------------------- |
|
107 CCalenDefaultEditors::CCalenDefaultEditors() |
|
108 : iEikEnv( *( CEikonEnv::Static() ) ), iResourceLoader( iEikEnv ) |
|
109 { |
|
110 TRACE_ENTRY_POINT; |
|
111 TRACE_EXIT_POINT; |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CCalenDefaultEditors::ConstructL |
|
116 // Second phase construction. |
|
117 // (other items were commented in a header). |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 void CCalenDefaultEditors::ConstructL() |
|
121 { |
|
122 TRACE_ENTRY_POINT; |
|
123 |
|
124 TFileName resource( TParsePtrC( PathInfo::RomRootPath() ).Drive() ); |
|
125 resource.Append( KResourcePath ); |
|
126 resource.Append( KResourceFile ); |
|
127 BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), resource ); |
|
128 TInt err = iResourceLoader.Open( resource ); |
|
129 __ASSERT_ALWAYS( err == KErrNone, Panic( EPanicCalenDefaultEditorsResourceLoading ) ); |
|
130 |
|
131 TRACE_EXIT_POINT; |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CCalenDefaultEditors::ExecuteViewL |
|
136 // Launches the entry editor. |
|
137 // (other items were commented in a header). |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 TInt CCalenDefaultEditors::ExecuteViewL( RPointerArray<CCalEntry>& aEntries, |
|
141 const TAgnEntryUiInParams& aInParams, |
|
142 TAgnEntryUiOutParams& aOutParams, |
|
143 MAgnEntryUiCallback& aCallback ) |
|
144 { |
|
145 TRACE_ENTRY_POINT; |
|
146 |
|
147 CalCommon::TRecurrenceRange repeatType( CalCommon::EThisAndAll ); |
|
148 TBool iSEditable( ETrue ); |
|
149 |
|
150 if( ( aEntries[0]->EntryTypeL() == CCalEntry::EReminder ) |
|
151 || ( aEntries[0]->EntryTypeL() == CCalEntry::EAppt ) |
|
152 || ( aEntries[0]->EntryTypeL() == CCalEntry::EEvent ) ) |
|
153 { |
|
154 TCalRRule rrule; |
|
155 |
|
156 TBool repeating = aEntries[0]->GetRRuleL( rrule ); |
|
157 const TBool child = aEntries[0]->RecurrenceIdL().TimeUtcL() != Time::NullTTime(); |
|
158 |
|
159 if( child || repeating ) |
|
160 { |
|
161 // Aks the user for repeat type ( This/All occurrences ) |
|
162 iSEditable = CalenNoteDataUtil::ShowRepeatTypeQueryL( repeatType, CalenNoteDataUtil::EEdit); |
|
163 } |
|
164 // if editing exceptional entry and repeat type edit all occurences, |
|
165 // launch the parent entry |
|
166 if( child && repeatType == CalCommon::EThisAndAll) |
|
167 { |
|
168 TInt services( aInParams.iSpare ); |
|
169 iServices = reinterpret_cast< MCalenServices* >( services ); |
|
170 |
|
171 RPointerArray<CCalEntry> entries; |
|
172 CleanupResetAndDestroyPushL( entries ); |
|
173 iServices->EntryViewL(iServices->Context().InstanceId().iColId)->FetchL( aEntries[0]->UidL(), entries ); |
|
174 aEntries.Close(); |
|
175 aEntries.Append(entries[0]); |
|
176 entries.Remove(0); |
|
177 CleanupStack::PopAndDestroy( &entries ); |
|
178 } |
|
179 } |
|
180 |
|
181 TInt completion( 0 ); |
|
182 if( iSEditable ) |
|
183 { |
|
184 // Create settings own titlepane and navipane, and swap with existing ones |
|
185 CEikStatusPane* sp = CEikonEnv::Static()->AppUiFactory()->StatusPane(); |
|
186 |
|
187 // Titlepane |
|
188 CAknTitlePane* newtp = new( ELeave ) CAknTitlePane(); |
|
189 CleanupStack::PushL( newtp ); |
|
190 CCoeControl* oldtp = sp->SwapControlL( TUid::Uid(EEikStatusPaneUidTitle), newtp ); |
|
191 CleanupStack::Pop( newtp ); // ownership is passed to statuspane |
|
192 TRect oldRect( 0, 0, 0, 0 ); |
|
193 if( oldtp ) |
|
194 { |
|
195 CleanupStack::PushL( oldtp ); |
|
196 oldRect = oldtp->Rect(); |
|
197 CCoeControl* ctrl = sp->ContainerControlL( TUid::Uid( EEikStatusPaneUidTitle ) ); |
|
198 newtp->SetContainerWindowL( *ctrl ); |
|
199 newtp->ConstructL(); |
|
200 newtp->SetRect( oldRect ); |
|
201 newtp->ActivateL(); |
|
202 } |
|
203 |
|
204 // NaviPane |
|
205 CAknNavigationControlContainer* newnp = new( ELeave )CAknNavigationControlContainer(); |
|
206 CleanupStack::PushL( newnp ); |
|
207 CCoeControl* oldnp = sp->SwapControlL( TUid::Uid( EEikStatusPaneUidNavi ), newnp ); |
|
208 CleanupStack::Pop( newnp ); // ownership is passed to statuspane |
|
209 if( oldnp ) |
|
210 { |
|
211 CleanupStack::PushL( oldnp ); |
|
212 oldRect = oldnp->Rect(); |
|
213 CCoeControl* ctrl = sp->ContainerControlL( TUid::Uid( EEikStatusPaneUidNavi ) ); |
|
214 newnp->SetContainerWindowL( *ctrl ); |
|
215 newnp->ConstructL(); |
|
216 newnp->SetRect( oldRect ); |
|
217 newnp->PushDefaultL(); |
|
218 newnp->ActivateL(); |
|
219 } |
|
220 |
|
221 completion= LaunchEditorL( *(aEntries[0]), aInParams, aOutParams, aCallback, repeatType); |
|
222 |
|
223 if( oldnp && sp->SwapControlL( TUid::Uid(EEikStatusPaneUidNavi), oldnp ) ) |
|
224 { |
|
225 CleanupStack::Pop( oldnp ); |
|
226 delete newnp; |
|
227 oldnp->ActivateL(); |
|
228 } |
|
229 if( oldtp && sp->SwapControlL( TUid::Uid(EEikStatusPaneUidTitle), oldtp ) ) |
|
230 { |
|
231 CleanupStack::Pop( oldtp ); |
|
232 delete newtp; |
|
233 oldtp->ActivateL(); |
|
234 } |
|
235 if ( completion == EAknCmdExit || completion == 0) // 0 is mapped from EEikBidCancel. |
|
236 { |
|
237 // Exit application |
|
238 static_cast<MEikCommandObserver*>( iEikEnv.EikAppUi() )->ProcessCommandL( EAknCmdExit ); |
|
239 } |
|
240 } |
|
241 else |
|
242 { |
|
243 // if user cancels repeated entry confirmation query |
|
244 TInt services( aInParams.iSpare ); |
|
245 iServices = reinterpret_cast< MCalenServices* >( services ); |
|
246 iServices->IssueNotificationL( ECalenNotifyDialogClosed ); |
|
247 } |
|
248 |
|
249 TRACE_EXIT_POINT; |
|
250 return aOutParams.iAction; |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // CCalenDefaultEditors::SetHelpContext |
|
255 // Set the help context. |
|
256 // (other items were commented in a header). |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 void CCalenDefaultEditors::SetHelpContext( const TCoeHelpContext& /*aContext*/ ) |
|
260 { |
|
261 TRACE_ENTRY_POINT; |
|
262 |
|
263 // FIXME: implement |
|
264 TRACE_EXIT_POINT; |
|
265 } |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CCalenDefaultEditors::LaunchEditorL |
|
269 // Launches the calendar entry editor. |
|
270 // (other items were commented in a header). |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 TInt CCalenDefaultEditors::LaunchEditorL(CCalEntry& aEntry, const TAgnEntryUiInParams& aInParams, |
|
274 TAgnEntryUiOutParams& aOutParams, MAgnEntryUiCallback& aCallback, |
|
275 CalCommon::TRecurrenceRange aRepeatType ) |
|
276 { |
|
277 TRACE_ENTRY_POINT; |
|
278 |
|
279 TInt retValue = 0; |
|
280 CCalenUnifiedEditor* editor; |
|
281 |
|
282 // For repeat type, EThisAndAll start Date/Time is first instance Date/Time. |
|
283 TAgnEntryUiInParams inParamsCopy( aInParams ); |
|
284 if( aRepeatType == CalCommon::EThisAndAll ) |
|
285 { |
|
286 inParamsCopy.iInstanceDate.SetTimeLocalL( aEntry.StartTimeL().TimeLocalL() ); |
|
287 } |
|
288 |
|
289 switch ( aEntry.EntryTypeL() ) |
|
290 { |
|
291 case CCalEntry::EEvent: |
|
292 { |
|
293 editor = CCalenUnifiedEditor::NewL( aEntry, inParamsCopy, aCallback, aOutParams, aRepeatType ); |
|
294 retValue = editor->ExecuteLD(R_CALEN_UNIFIED_EDITOR); |
|
295 } |
|
296 break; |
|
297 |
|
298 // Launch the meeting editor |
|
299 case CCalEntry::EReminder: |
|
300 case CCalEntry::EAppt: |
|
301 { |
|
302 if( aInParams.iEditorMode == ECreateNewEntry ) |
|
303 { |
|
304 // Launch editor, for new entry |
|
305 editor = CCalenUnifiedEditor::NewL( aEntry, aInParams, aCallback, aOutParams, CalCommon::EThisAndAll ); |
|
306 } |
|
307 else |
|
308 { |
|
309 // Launch editor, to edit saved entry |
|
310 editor = CCalenUnifiedEditor::NewL( aEntry, inParamsCopy, aCallback, aOutParams, aRepeatType ); |
|
311 } |
|
312 retValue = editor->ExecuteLD( R_CALEN_UNIFIED_EDITOR ); |
|
313 break; |
|
314 } |
|
315 |
|
316 // Launch the anniversary editor |
|
317 case CCalEntry::EAnniv: |
|
318 { |
|
319 editor = CCalenUnifiedEditor::NewL( aEntry, inParamsCopy, aCallback, aOutParams ); |
|
320 retValue = editor->ExecuteLD( R_CALEN_UNIFIED_EDITOR ); |
|
321 break; |
|
322 } |
|
323 |
|
324 // Launch the todo editor |
|
325 case CCalEntry::ETodo: |
|
326 { |
|
327 editor = CCalenUnifiedEditor::NewL(aEntry, aInParams, aCallback, aOutParams ); |
|
328 retValue = editor->ExecuteLD( R_CALEN_UNIFIED_EDITOR ); |
|
329 break; |
|
330 } |
|
331 |
|
332 // Should never happen |
|
333 default: |
|
334 { |
|
335 __ASSERT_DEBUG( EFalse, User::Invariant() ); |
|
336 break; |
|
337 } |
|
338 } |
|
339 |
|
340 TRACE_EXIT_POINT; |
|
341 return retValue; |
|
342 } |
|
343 |
|
344 // End of file |