36 #include "CalenLunarLocalizer.h" |
36 #include "CalenLunarLocalizer.h" |
37 #include "CalenLunarInfoProvider.h" |
37 #include "CalenLunarInfoProvider.h" |
38 #include "CalendarPrivateCRKeys.h" |
38 #include "CalendarPrivateCRKeys.h" |
39 #include "calenRegionalInfoData.h" |
39 #include "calenRegionalInfoData.h" |
40 #include "hb_calencommands.hrh" |
40 #include "hb_calencommands.hrh" |
|
41 #include "OstTraceDefinitions.h" |
|
42 #ifdef OST_TRACE_COMPILER_IN_USE |
|
43 #include "CalenLunarChinesePluginTraces.h" |
|
44 #endif |
|
45 |
41 |
46 |
42 //CONSTANTS |
47 //CONSTANTS |
43 static const QString fieldSeparator("\n"); |
48 static const QString fieldSeparator("\n"); |
44 static const QString headerSeparator("\n "); |
49 static const QString headerSeparator("\n "); |
45 |
50 |
56 :iLocalizer(NULL), |
61 :iLocalizer(NULL), |
57 iLocInfo(NULL), |
62 iLocInfo(NULL), |
58 iServices(aServices), |
63 iServices(aServices), |
59 iInfoBarText(NULL) |
64 iInfoBarText(NULL) |
60 { |
65 { |
61 TRACE_ENTRY_POINT; |
66 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_CCALENLUNARCHINESEPLUGIN_ENTRY ); |
62 |
67 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_CCALENLUNARCHINESEPLUGIN_EXIT ); |
63 TRACE_EXIT_POINT; |
|
64 } |
68 } |
65 |
69 |
66 // ----------------------------------------------------------------------------- |
70 // ----------------------------------------------------------------------------- |
67 // CCalenLunarChinesePlugin::CreateChinesePluginL |
71 // CCalenLunarChinesePlugin::CreateChinesePluginL |
68 // ----------------------------------------------------------------------------- |
72 // ----------------------------------------------------------------------------- |
69 // |
73 // |
70 CCalenLunarChinesePlugin* CCalenLunarChinesePlugin::NewL( |
74 CCalenLunarChinesePlugin* CCalenLunarChinesePlugin::NewL( |
71 MCalenServices* aServices ) |
75 MCalenServices* aServices ) |
72 { |
76 { |
73 TRACE_ENTRY_POINT; |
77 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_NEWL_ENTRY ); |
74 CCalenLunarChinesePlugin* self = new( ELeave ) |
78 CCalenLunarChinesePlugin* self = new( ELeave ) |
75 CCalenLunarChinesePlugin( aServices); |
79 CCalenLunarChinesePlugin( aServices); |
76 CleanupStack::PushL( self ); |
80 CleanupStack::PushL( self ); |
77 self->ConstructL(); |
81 self->ConstructL(); |
78 CleanupStack::Pop(self); |
82 CleanupStack::Pop(self); |
79 TRACE_EXIT_POINT; |
83 TRACE_EXIT_POINT; |
|
84 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_NEWL_EXIT ); |
80 return self; |
85 return self; |
81 } |
86 } |
82 |
87 |
83 // ----------------------------------------------------------------------------- |
88 // ----------------------------------------------------------------------------- |
84 // CCalenLunarChinesePlugin::~CCalenLunarChinesePlugin |
89 // CCalenLunarChinesePlugin::~CCalenLunarChinesePlugin |
85 // ----------------------------------------------------------------------------- |
90 // ----------------------------------------------------------------------------- |
86 // |
91 // |
87 CCalenLunarChinesePlugin::~CCalenLunarChinesePlugin() |
92 CCalenLunarChinesePlugin::~CCalenLunarChinesePlugin() |
88 { |
93 { |
89 TRACE_ENTRY_POINT; |
94 OstTraceFunctionEntry0( DUP1_CCALENLUNARCHINESEPLUGIN_CCALENLUNARCHINESEPLUGIN_ENTRY ); |
90 |
|
91 |
|
92 //Deregister services |
95 //Deregister services |
93 if ( iServices ) |
96 if ( iServices ) |
94 { |
97 { |
95 iServices->CancelNotifications(this); |
98 iServices->CancelNotifications(this); |
96 iServices->Release(); |
99 iServices->Release(); |
115 // Remove the translator for plugin |
118 // Remove the translator for plugin |
116 if (iTranslator) { |
119 if (iTranslator) { |
117 delete iTranslator; |
120 delete iTranslator; |
118 iTranslator = 0; |
121 iTranslator = 0; |
119 } |
122 } |
120 TRACE_EXIT_POINT; |
123 OstTraceFunctionExit0( DUP1_CCALENLUNARCHINESEPLUGIN_CCALENLUNARCHINESEPLUGIN_EXIT ); |
121 } |
124 } |
122 |
125 |
123 // ----------------------------------------------------------------------------- |
126 // ----------------------------------------------------------------------------- |
124 // CCalenLunarChinesePlugin::ContructL |
127 // CCalenLunarChinesePlugin::ContructL |
125 // ----------------------------------------------------------------------------- |
128 // ----------------------------------------------------------------------------- |
126 // |
129 // |
127 void CCalenLunarChinesePlugin::ConstructL() |
130 void CCalenLunarChinesePlugin::ConstructL() |
128 { |
131 { |
129 TRACE_ENTRY_POINT; |
132 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_CONSTRUCTL_ENTRY ); |
130 iServices->RegisterForNotificationsL( this, ECalenNotifyContextChanged ); |
133 iServices->RegisterForNotificationsL( this, ECalenNotifyContextChanged ); |
131 iServices->GetCommandRange( iStart, iEnd ); |
134 iServices->GetCommandRange( iStart, iEnd ); |
132 |
135 |
133 // Install the translator before the CCalenLunarLocalizer is constructed |
136 // Install the translator before the CCalenLunarLocalizer is constructed |
134 iTranslator = new HbTranslator("calenregional"); |
137 iTranslator = new HbTranslator("calenregional"); |
138 iInfoProvider = CCalenLunarInfoProvider::NewL( |
141 iInfoProvider = CCalenLunarInfoProvider::NewL( |
139 CEikonEnv::Static()->FsSession() ); |
142 CEikonEnv::Static()->FsSession() ); |
140 //Qt class having a slot ,calls when user clicked show lunar data option |
143 //Qt class having a slot ,calls when user clicked show lunar data option |
141 iRegionalInfo = new CalenRegionalInfo(*this); |
144 iRegionalInfo = new CalenRegionalInfo(*this); |
142 |
145 |
143 TRACE_EXIT_POINT; |
146 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_CONSTRUCTL_EXIT ); |
144 } |
147 } |
145 |
148 |
146 // ----------------------------------------------------------------------------- |
149 // ----------------------------------------------------------------------------- |
147 // CCalenLunarChinesePlugin::FormatExtraRowStringL |
150 // CCalenLunarChinesePlugin::FormatExtraRowStringL |
148 // ----------------------------------------------------------------------------- |
151 // ----------------------------------------------------------------------------- |
149 // |
152 // |
150 void CCalenLunarChinesePlugin::FormatExtraRowStringL() |
153 void CCalenLunarChinesePlugin::FormatExtraRowStringL() |
151 |
154 |
152 { |
155 { |
153 TRACE_ENTRY_POINT; |
156 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_FORMATEXTRAROWSTRINGL_ENTRY ); |
154 |
|
155 if ( iLocInfo ) |
157 if ( iLocInfo ) |
156 { |
158 { |
157 iExtraRowText.Set( iLocalizer->GetExtraRowTextL( *iLocInfo) ); |
159 iExtraRowText.Set( iLocalizer->GetExtraRowTextL( *iLocInfo) ); |
158 } |
160 } |
159 else |
161 else |
160 { |
162 { |
161 iExtraRowText.Set( KNullDesC ); |
163 iExtraRowText.Set( KNullDesC ); |
162 } |
164 } |
163 |
165 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_FORMATEXTRAROWSTRINGL_EXIT ); |
164 TRACE_EXIT_POINT; |
|
165 } |
166 } |
166 |
167 |
167 // ----------------------------------------------------------------------------- |
168 // ----------------------------------------------------------------------------- |
168 // CCalenLunarChinesePlugin::InfobarL |
169 // CCalenLunarChinesePlugin::InfobarL |
169 // ----------------------------------------------------------------------------- |
170 // ----------------------------------------------------------------------------- |
170 // |
171 // |
171 HbWidget* CCalenLunarChinesePlugin::InfobarL( ) |
172 HbWidget* CCalenLunarChinesePlugin::InfobarL( ) |
172 { |
173 { |
173 TRACE_ENTRY_POINT; |
174 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_INFOBARL_ENTRY ); |
174 TRACE_EXIT_POINT; |
175 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_INFOBARL_EXIT ); |
175 return NULL; |
176 return NULL; |
176 } |
177 } |
177 |
178 |
178 // ---------------------------------------------------------------------------- |
179 // ---------------------------------------------------------------------------- |
179 // CCalenThaiPlugin::InfobarL |
180 // CCalenThaiPlugin::InfobarL |
180 // This function is called in case of Hitchcock views |
181 // This function is called in case of Hitchcock views |
181 // ---------------------------------------------------------------------------- |
182 // ---------------------------------------------------------------------------- |
182 // |
183 // |
183 QString* CCalenLunarChinesePlugin::InfobarTextL( ) |
184 QString* CCalenLunarChinesePlugin::InfobarTextL( ) |
184 { |
185 { |
185 TRACE_ENTRY_POINT; |
186 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_INFOBARTEXTL_ENTRY ); |
186 if(iInfoBarText) |
187 if(iInfoBarText) |
187 { |
188 { |
188 delete iInfoBarText; |
189 delete iInfoBarText; |
189 iInfoBarText = NULL; |
190 iInfoBarText = NULL; |
190 } |
191 } |
193 UpdateLocalizerInfoL(); |
194 UpdateLocalizerInfoL(); |
194 FormatExtraRowStringL(); |
195 FormatExtraRowStringL(); |
195 iInfoBarText = iExtraRowText.AllocLC(); |
196 iInfoBarText = iExtraRowText.AllocLC(); |
196 CleanupStack::Pop(); |
197 CleanupStack::Pop(); |
197 |
198 |
198 TRACE_EXIT_POINT; |
|
199 return (new QString((QChar*)iInfoBarText->Des().Ptr(),iInfoBarText->Length())); |
199 return (new QString((QChar*)iInfoBarText->Des().Ptr(),iInfoBarText->Length())); |
200 } |
200 } |
201 |
201 |
202 // ---------------------------------------------------------------------------- |
202 // ---------------------------------------------------------------------------- |
203 // CCalenThaiPlugin::InfobarL |
203 // CCalenThaiPlugin::InfobarL |
205 // ---------------------------------------------------------------------------- |
205 // ---------------------------------------------------------------------------- |
206 // |
206 // |
207 |
207 |
208 void CCalenLunarChinesePlugin::CustomiseMenu(HbMenu* aHbMenu) |
208 void CCalenLunarChinesePlugin::CustomiseMenu(HbMenu* aHbMenu) |
209 { |
209 { |
|
210 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_CUSTOMISEMENU_ENTRY ); |
210 HbAction* lunarAction = new HbAction("Show Lunar Data"); |
211 HbAction* lunarAction = new HbAction("Show Lunar Data"); |
211 QList<QAction*> actionList = aHbMenu->actions(); |
212 QList<QAction*> actionList = aHbMenu->actions(); |
212 TInt count = actionList.count() - 1; //To show the option "show lunar data" |
213 TInt count = actionList.count() - 1; //To show the option "show lunar data" |
213 //as a second last action item for all |
214 //as a second last action item for all |
214 //Menu |
215 //Menu |
215 if(count >= 0) |
216 if(count >= 0) |
216 aHbMenu->insertAction(actionList[count], lunarAction); |
217 aHbMenu->insertAction(actionList[count], lunarAction); |
217 //calls a slot whenever user clicked "show lunar data" option |
218 //calls a slot whenever user clicked "show lunar data" option |
218 QObject::connect(lunarAction,SIGNAL(triggered()), iRegionalInfo,SLOT(showRegionalDetails())); |
219 QObject::connect(lunarAction,SIGNAL(triggered()), iRegionalInfo,SLOT(showRegionalDetails())); |
|
220 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_CUSTOMISEMENU_EXIT ); |
219 } |
221 } |
220 |
222 |
221 // ----------------------------------------------------------------------------- |
223 // ----------------------------------------------------------------------------- |
222 // CCalenLunarChinesePlugin::HandleCommandL |
224 // CCalenLunarChinesePlugin::HandleCommandL |
223 // ----------------------------------------------------------------------------- |
225 // ----------------------------------------------------------------------------- |
224 // |
226 // |
225 TBool CCalenLunarChinesePlugin::HandleCommandL( const TCalenCommand& aCommand ) |
227 TBool CCalenLunarChinesePlugin::HandleCommandL( const TCalenCommand& aCommand ) |
226 { |
228 { |
227 TRACE_ENTRY_POINT; |
229 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_HANDLECOMMANDL_ENTRY ); |
228 |
|
229 const TInt commandId = aCommand.Command(); |
230 const TInt commandId = aCommand.Command(); |
230 if(ECalenRegionalPluginTapEvent == commandId) |
231 if(ECalenRegionalPluginTapEvent == commandId) |
231 { |
232 { |
232 ShowDetailsL(); |
233 ShowDetailsL(); |
233 } |
234 } |
234 TRACE_EXIT_POINT; |
235 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_HANDLECOMMANDL_EXIT ); |
235 return EFalse; |
236 return EFalse; |
236 } |
237 } |
237 |
238 |
238 // ---------------------------------------------------------------------------- |
239 // ---------------------------------------------------------------------------- |
239 // CCalenLunarChinesePlugin::CalenCommandHandlerExtensionL |
240 // CCalenLunarChinesePlugin::CalenCommandHandlerExtensionL |
241 // ---------------------------------------------------------------------------- |
242 // ---------------------------------------------------------------------------- |
242 // |
243 // |
243 TAny* CCalenLunarChinesePlugin::CalenCommandHandlerExtensionL( |
244 TAny* CCalenLunarChinesePlugin::CalenCommandHandlerExtensionL( |
244 TUid /*aExtensionUid*/ ) |
245 TUid /*aExtensionUid*/ ) |
245 { |
246 { |
246 TRACE_ENTRY_POINT; |
247 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_CALENCOMMANDHANDLEREXTENSIONL_ENTRY ); |
247 TRACE_EXIT_POINT; |
248 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_CALENCOMMANDHANDLEREXTENSIONL_EXIT ); |
248 return NULL; |
249 return NULL; |
249 } |
250 } |
250 |
251 |
251 // ----------------------------------------------------------------------------- |
252 // ----------------------------------------------------------------------------- |
252 // CCalenLunarChinesePlugin::CommandHandlerL |
253 // CCalenLunarChinesePlugin::CommandHandlerL |
253 // ----------------------------------------------------------------------------- |
254 // ----------------------------------------------------------------------------- |
254 // |
255 // |
255 MCalenCommandHandler* CCalenLunarChinesePlugin::CommandHandlerL( TInt aCommand ) |
256 MCalenCommandHandler* CCalenLunarChinesePlugin::CommandHandlerL( TInt aCommand ) |
256 { |
257 { |
257 TRACE_ENTRY_POINT; |
258 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_COMMANDHANDLERL_ENTRY ); |
258 |
|
259 MCalenCommandHandler* commandHandler = NULL; |
259 MCalenCommandHandler* commandHandler = NULL; |
260 |
260 |
261 if(ECalenRegionalPluginTapEvent == aCommand) |
261 if(ECalenRegionalPluginTapEvent == aCommand) |
262 { |
262 { |
263 commandHandler = this; |
263 commandHandler = this; |
264 } |
264 } |
265 |
265 |
|
266 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_COMMANDHANDLERL_EXIT ); |
266 return commandHandler; |
267 return commandHandler; |
267 TRACE_EXIT_POINT; |
|
268 } |
268 } |
269 |
269 |
270 // ----------------------------------------------------------------------------- |
270 // ----------------------------------------------------------------------------- |
271 // CCalenLunarChinesePlugin::UpdateInfoLabelL |
271 // CCalenLunarChinesePlugin::UpdateInfoLabelL |
272 // ----------------------------------------------------------------------------- |
272 // ----------------------------------------------------------------------------- |
273 // |
273 // |
274 void CCalenLunarChinesePlugin::UpdateLocalizerInfoL() |
274 void CCalenLunarChinesePlugin::UpdateLocalizerInfoL() |
275 { |
275 { |
276 TRACE_ENTRY_POINT; |
276 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_UPDATELOCALIZERINFOL_ENTRY ); |
277 QDateTime focusDateTime= iServices->Context().focusDateAndTime(); |
277 QDateTime focusDateTime= iServices->Context().focusDateAndTime(); |
278 TDateTime tempDateTime( |
278 TDateTime tempDateTime( |
279 focusDateTime.date().year(), |
279 focusDateTime.date().year(), |
280 static_cast<TMonth>(focusDateTime.date().month() - 1), |
280 static_cast<TMonth>(focusDateTime.date().month() - 1), |
281 focusDateTime.date().day() - 1, focusDateTime.time().hour(), |
281 focusDateTime.date().day() - 1, focusDateTime.time().hour(), |
286 iLocInfo = NULL; |
286 iLocInfo = NULL; |
287 if(iLocalizer) |
287 if(iLocalizer) |
288 { |
288 { |
289 iLocInfo = iLocalizer->LocalizeL( lunarInfo ); |
289 iLocInfo = iLocalizer->LocalizeL( lunarInfo ); |
290 } |
290 } |
291 TRACE_EXIT_POINT; |
291 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_UPDATELOCALIZERINFOL_EXIT ); |
292 } |
292 } |
293 |
293 |
294 // ----------------------------------------------------------------------------- |
294 // ----------------------------------------------------------------------------- |
295 // CCalenLunarChinesePlugin::HandleNotification |
295 // CCalenLunarChinesePlugin::HandleNotification |
296 // ----------------------------------------------------------------------------- |
296 // ----------------------------------------------------------------------------- |
297 // |
297 // |
298 void CCalenLunarChinesePlugin::HandleNotification( |
298 void CCalenLunarChinesePlugin::HandleNotification( |
299 const TCalenNotification aNotification ) |
299 const TCalenNotification aNotification ) |
300 { |
300 { |
301 TRACE_ENTRY_POINT; |
301 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_HANDLENOTIFICATION_ENTRY ); |
302 if (aNotification == ECalenNotifyContextChanged) |
302 if (aNotification == ECalenNotifyContextChanged) |
303 { |
303 { |
304 TRAP_IGNORE(UpdateLocalizerInfoL()); |
304 TRAP_IGNORE(UpdateLocalizerInfoL()); |
305 } |
305 } |
306 TRACE_EXIT_POINT; |
306 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_HANDLENOTIFICATION_EXIT ); |
307 } |
307 } |
308 |
308 |
309 // ----------------------------------------------------------------------------- |
309 // ----------------------------------------------------------------------------- |
310 // CCalenLunarChinesePlugin::ShowDetailsL |
310 // CCalenLunarChinesePlugin::ShowDetailsL |
311 // Message popup from menu |
311 // Message popup from menu |
312 // ----------------------------------------------------------------------------- |
312 // ----------------------------------------------------------------------------- |
313 // |
313 // |
314 void CCalenLunarChinesePlugin::ShowDetailsL( ) |
314 void CCalenLunarChinesePlugin::ShowDetailsL( ) |
315 { |
315 { |
|
316 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_SHOWDETAILSL_ENTRY ); |
316 QString msgText; |
317 QString msgText; |
317 if(iLocInfo) { |
318 if(iLocInfo) { |
318 QStringList headerIds; |
319 QStringList headerIds; |
319 headerIds.append(hbTrId("txt_calendar_info_festival")); |
320 headerIds.append(hbTrId("txt_calendar_info_festival")); |
320 headerIds.append(hbTrId("txt_calendar_solar_term")); |
321 headerIds.append(hbTrId("txt_calendar_solar_term")); |
347 } |
348 } |
348 } |
349 } |
349 } |
350 } |
350 } |
351 } |
351 ExecuteMessageDialogL(msgText); |
352 ExecuteMessageDialogL(msgText); |
|
353 OstTraceFunctionExit0( CCALENLUNARCHINESEPLUGIN_SHOWDETAILSL_EXIT ); |
352 } |
354 } |
353 |
355 |
354 // ----------------------------------------------------------------------------- |
356 // ----------------------------------------------------------------------------- |
355 // CCalenLunarChinesePlugin::ExecuteMessageDialogL |
357 // CCalenLunarChinesePlugin::ExecuteMessageDialogL |
356 // ----------------------------------------------------------------------------- |
358 // ----------------------------------------------------------------------------- |
357 // |
359 // |
358 void CCalenLunarChinesePlugin::ExecuteMessageDialogL(QString aMsgText) |
360 void CCalenLunarChinesePlugin::ExecuteMessageDialogL(QString aMsgText) |
359 { |
361 { |
360 TRACE_ENTRY_POINT; |
362 OstTraceFunctionEntry0( CCALENLUNARCHINESEPLUGIN_EXECUTEMESSAGEDIALOGL_ENTRY ); |
361 // Instantiate a popup |
363 // Instantiate a popup |
362 HbMessageBox *popup = new HbMessageBox(); |
364 HbMessageBox *popup = new HbMessageBox(); |
363 popup->setDismissPolicy(HbDialog::NoDismiss); |
365 popup->setDismissPolicy(HbDialog::NoDismiss); |
364 popup->setTimeout(HbDialog::NoTimeout); |
366 popup->setTimeout(HbDialog::NoTimeout); |
365 popup->setIconVisible(false); |
367 popup->setIconVisible(false); |