|
1 /* |
|
2 * Copyright (c) 2002 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: Helper tool to get alarm and repeat data of Calendar note. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //debug |
|
20 #include "calendarui_debug.h" |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "CalenNoteDataUtil.h" |
|
24 #include "calendar.hrh" |
|
25 |
|
26 #include <calencommonui.rsg> |
|
27 |
|
28 #include <StringLoader.h> |
|
29 #include <aknPopup.h> |
|
30 #include <PathInfo.h> |
|
31 #include <aknlists.h> |
|
32 #include <BAUTILS.h> |
|
33 #include <CalRRule.h> |
|
34 #include <CalAlarm.h> |
|
35 #include <CalEntry.h> |
|
36 #include <data_caging_path_literals.hrh> |
|
37 |
|
38 // ================= MEMBER FUNCTIONS ======================= |
|
39 // --------------------------------------------------------- |
|
40 // CalenNoteDataUtil::RepeatIndexL |
|
41 // Return index of repeat type |
|
42 // (other items were commented in a header). |
|
43 // --------------------------------------------------------- |
|
44 // |
|
45 TCalenRepeatIndex CalenNoteDataUtil::RepeatIndexL(const CCalEntry& aEntry) |
|
46 { |
|
47 TRACE_ENTRY_POINT; |
|
48 |
|
49 TCalenRepeatIndex repeatIndex( ERepeatNotRepeated ); |
|
50 |
|
51 TCalRRule rrule; |
|
52 |
|
53 if( aEntry.GetRRuleL( rrule) ) |
|
54 { |
|
55 TCalRRule::TType type( rrule.Type() ); |
|
56 TInt repeatInterval( rrule.Interval() ); |
|
57 |
|
58 // If repeat type of current note is not supported in Calendar, |
|
59 // default repeat value is "Other". |
|
60 repeatIndex = ERepeatOther; |
|
61 |
|
62 switch( type ) |
|
63 { |
|
64 case TCalRRule::EDaily: |
|
65 { |
|
66 switch (repeatInterval) |
|
67 { |
|
68 case 1: repeatIndex = ERepeatDaily; break; |
|
69 case 7: repeatIndex = ERepeatWeekly; break; |
|
70 case 14: repeatIndex = ERepeatBiWeekly; break; |
|
71 default: break; |
|
72 } |
|
73 break; |
|
74 } |
|
75 |
|
76 case TCalRRule::EWeekly: |
|
77 { |
|
78 RArray<TDay> weekDays(7); |
|
79 rrule.GetByDayL( weekDays ); |
|
80 |
|
81 if( weekDays.Count() == 1 ) // FIXME: AL - is this necessary? |
|
82 { |
|
83 switch( repeatInterval ) |
|
84 { |
|
85 case 1: repeatIndex = ERepeatWeekly; break; |
|
86 case 2: repeatIndex = ERepeatBiWeekly; break; |
|
87 default: break; |
|
88 } |
|
89 } |
|
90 |
|
91 weekDays.Close(); |
|
92 |
|
93 break; |
|
94 } |
|
95 |
|
96 case TCalRRule::EMonthly: |
|
97 { |
|
98 RArray<TInt> monthDays(31); |
|
99 rrule.GetByMonthDayL ( monthDays ); |
|
100 |
|
101 if( monthDays.Count() == 1) // FIXME: AL - is this necessary? |
|
102 { |
|
103 switch( repeatInterval ) |
|
104 { |
|
105 case 1: repeatIndex = ERepeatMonthly; break; |
|
106 // If interval of repeat is 12 months, |
|
107 // every year is shown in Note Editor, |
|
108 // because it means yearly repeat. |
|
109 case 12: repeatIndex = ERepeatYearly; break; |
|
110 default: break; |
|
111 } |
|
112 } |
|
113 |
|
114 monthDays.Close(); |
|
115 |
|
116 break; |
|
117 } |
|
118 case TCalRRule::EYearly: |
|
119 { |
|
120 if( repeatInterval == 1 ) |
|
121 { |
|
122 repeatIndex = ERepeatYearly; |
|
123 } |
|
124 break; |
|
125 } |
|
126 |
|
127 default: |
|
128 { |
|
129 // If repeat type of current note is not supported in Calendar, |
|
130 // default repeat value is "Other". |
|
131 repeatIndex = ERepeatOther; |
|
132 break; |
|
133 } |
|
134 } |
|
135 } |
|
136 |
|
137 TRACE_EXIT_POINT; |
|
138 return repeatIndex; |
|
139 } |
|
140 // --------------------------------------------------------- |
|
141 // CalenNoteDataUtil::GetAlarmDateTimeL |
|
142 // If note has alarm, alarm time is set to aAlarmDateTime |
|
143 // and return ETrue. aAlarmDateTime has dd/mm/yy, hh:mm part, |
|
144 // E.g. 15/Sep/2002, 13:00. |
|
145 // If note has no alarm, aAlarmDateTime is not changed |
|
146 // and return EFalse. |
|
147 // (other items were commented in a header). |
|
148 // --------------------------------------------------------- |
|
149 // |
|
150 TBool CalenNoteDataUtil::GetAlarmDateTimeL(const CCalEntry& aEntry, TTime& aAlarmDateTime) |
|
151 { |
|
152 TRACE_ENTRY_POINT; |
|
153 |
|
154 TBool ret( EFalse ); |
|
155 // FIXME: leaving! |
|
156 CCalAlarm* alarm = aEntry.AlarmL(); |
|
157 |
|
158 if( alarm ) |
|
159 { |
|
160 CleanupStack::PushL( alarm ); |
|
161 ret = ETrue; |
|
162 |
|
163 switch( aEntry.EntryTypeL() ) |
|
164 { |
|
165 case CCalEntry::ETodo: |
|
166 aAlarmDateTime = aEntry.EndTimeL().TimeLocalL(); |
|
167 break; |
|
168 |
|
169 case CCalEntry::EAppt: |
|
170 case CCalEntry::EEvent: |
|
171 case CCalEntry::EAnniv: |
|
172 default: |
|
173 aAlarmDateTime = aEntry.StartTimeL().TimeLocalL(); |
|
174 break; |
|
175 } |
|
176 aAlarmDateTime -= alarm->TimeOffset(); |
|
177 |
|
178 CleanupStack::PopAndDestroy( alarm ); |
|
179 } |
|
180 |
|
181 TRACE_EXIT_POINT; |
|
182 return ret; |
|
183 } |
|
184 |
|
185 // ---------------------------------------------------------------------------- |
|
186 // CalenNoteDataUtil::ShowRepeatTypeQueryL |
|
187 // Shows a query asking the user to choose the repeat type. |
|
188 // (other items were commented in a header). |
|
189 // ---------------------------------------------------------------------------- |
|
190 // |
|
191 TBool CalenNoteDataUtil::ShowRepeatTypeQueryL( CalCommon::TRecurrenceRange& aAnswer, |
|
192 const TRepeatQueryType aType ) |
|
193 { |
|
194 TRACE_ENTRY_POINT; |
|
195 |
|
196 CAknSinglePopupMenuStyleListBox* list = new( ELeave )CAknSinglePopupMenuStyleListBox; |
|
197 CleanupStack::PushL( list ); |
|
198 CAknPopupList* popupList = CAknPopupList::NewL( list, R_AVKON_SOFTKEYS_OK_CANCEL ); |
|
199 CleanupStack::PushL( popupList ); |
|
200 |
|
201 list->ConstructL( popupList, CEikListBox::ELeftDownInViewRect ); |
|
202 list->CreateScrollBarFrameL(ETrue); |
|
203 list->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
204 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
205 |
|
206 CEikonEnv* eikEnv = CEikonEnv::Static(); |
|
207 CDesCArrayFlat* items = eikEnv->ReadDesCArrayResourceL( aType == EEdit ? |
|
208 R_CALEN_COMMONUI_REPEATNOTE_EDIT_CHOICELIST : |
|
209 R_CALEN_COMMONUI_REPEATNOTE_CHOICELIST ); |
|
210 CTextListBoxModel* model = list->Model(); |
|
211 model->SetItemTextArray( items ); |
|
212 |
|
213 TInt resID(0); |
|
214 |
|
215 switch( aType ) |
|
216 { |
|
217 case ESave: |
|
218 resID = R_CALEN_COMMONUI_QTN_CALE_LQ_SAVE_CHANG_REPEATED; |
|
219 break; |
|
220 case EEdit: |
|
221 resID = R_CALEN_COMMONUI_QTN_CALE_LQ_EDIT_RECURRING; |
|
222 break; |
|
223 default: |
|
224 User::Leave( KErrArgument ); |
|
225 break; |
|
226 } |
|
227 |
|
228 HBufC* title = StringLoader::LoadLC( resID, eikEnv ); |
|
229 popupList->SetTitleL( *title ); |
|
230 CleanupStack::PopAndDestroy( title ); |
|
231 |
|
232 TBool ret( ETrue ); |
|
233 |
|
234 if( popupList->ExecuteLD() ) |
|
235 { |
|
236 const TInt selected( list->CurrentItemIndex() ); |
|
237 |
|
238 switch( selected ) |
|
239 { |
|
240 case ECalenRepeatThis: |
|
241 aAnswer = CalCommon::EThisOnly; |
|
242 break; |
|
243 case ECalenRepeatThisFuture: |
|
244 aAnswer = CalCommon::EThisAndFuture; |
|
245 break; |
|
246 case ECalenRepeatThisPast: |
|
247 aAnswer = CalCommon::EThisAndPrior; |
|
248 break; |
|
249 case ECalenRepeatAll: |
|
250 aAnswer = CalCommon::EThisAndAll; |
|
251 break; |
|
252 default: |
|
253 ASSERT( EFalse ); |
|
254 break; |
|
255 } |
|
256 } |
|
257 else |
|
258 { |
|
259 ret = EFalse; |
|
260 } |
|
261 |
|
262 CleanupStack::Pop( popupList ); |
|
263 CleanupStack::PopAndDestroy( list ); |
|
264 |
|
265 TRACE_EXIT_POINT; |
|
266 return ret; |
|
267 } |
|
268 |
|
269 // End of file |