96 iVariantMap = CHbSymbianVariantMap::NewL(); |
103 iVariantMap = CHbSymbianVariantMap::NewL(); |
97 } |
104 } |
98 |
105 |
99 void CHbDeviceNotificationDialogSymbianPrivate::ShowL() |
106 void CHbDeviceNotificationDialogSymbianPrivate::ShowL() |
100 { |
107 { |
101 AddVariantL(KKeyTouchActivation, &iEnable, CHbSymbianVariant::EBool); |
108 if (iEnable.iChanged) { |
102 AddVariantL(KKeyTimeOut, &iTimeout, CHbSymbianVariant::EInt); |
109 AddVariantL(KKeyTouchActivation, &iEnable.iValue, CHbSymbianVariant::EBool); |
103 AddVariantL(KKeyTitleTextWrapping, &iWrap, CHbSymbianVariant::EInt); |
110 } |
104 if (iShowLevel) { // send only if non-default |
111 if (iTimeout.iChanged) { |
105 AddVariantL(KKeyShowLevel, &iShowLevel, CHbSymbianVariant::EInt); |
112 AddVariantL(KKeyTimeOut, &iTimeout.iValue, CHbSymbianVariant::EInt); |
|
113 } |
|
114 if (iWrap.iChanged) { |
|
115 AddVariantL(KKeyTitleTextWrapping, &iWrap.iValue, CHbSymbianVariant::EInt); |
|
116 } |
|
117 if (iShowLevel.iChanged) { |
|
118 AddVariantL(KKeyShowLevel, &iShowLevel.iValue, CHbSymbianVariant::EInt); |
106 } |
119 } |
107 |
120 |
108 TInt error = iDeviceDialog->Show(KPluginIdentifier, *iVariantMap, this); |
121 TInt error = iDeviceDialog->Show(KPluginIdentifier, *iVariantMap, this); |
109 if (error != KErrNone) { |
122 if (error != KErrNone) { |
110 User::Leave(error); // error can be positive or negative |
123 User::Leave(error); // error can be positive or negative |
111 } |
124 } |
112 } |
125 } |
113 |
126 |
114 void CHbDeviceNotificationDialogSymbianPrivate::UpdateL() |
127 void CHbDeviceNotificationDialogSymbianPrivate::UpdateL() |
115 { |
128 { |
116 AddVariantL(KKeyTouchActivation, &iEnable, CHbSymbianVariant::EBool); |
129 if (iEnable.iChanged) { |
117 AddVariantL(KKeyTimeOut, &iTimeout, CHbSymbianVariant::EInt); |
130 AddVariantL(KKeyTouchActivation, &iEnable, CHbSymbianVariant::EBool); |
118 AddVariantL(KKeyTitleTextWrapping, &iWrap, CHbSymbianVariant::EInt); |
131 } |
|
132 if (iTimeout.iChanged) { |
|
133 AddVariantL(KKeyTimeOut, &iTimeout, CHbSymbianVariant::EInt); |
|
134 } |
|
135 if (iWrap.iChanged) { |
|
136 AddVariantL(KKeyTitleTextWrapping, &iWrap, CHbSymbianVariant::EInt); |
|
137 } |
119 TInt error = iDeviceDialog->Update(*iVariantMap); |
138 TInt error = iDeviceDialog->Update(*iVariantMap); |
120 if (error != KErrNone) { |
139 if (error != KErrNone) { |
121 User::Leave(error); // error can be positive or negative |
140 User::Leave(error); // error can be positive or negative |
122 } |
141 } |
123 } |
142 } |
169 } |
188 } |
170 |
189 |
171 // Set dialog show level |
190 // Set dialog show level |
172 void SetShowLevel(CHbDeviceNotificationDialogSymbianPrivate *aDialog, TInt aLevel) |
191 void SetShowLevel(CHbDeviceNotificationDialogSymbianPrivate *aDialog, TInt aLevel) |
173 { |
192 { |
174 aDialog->iShowLevel = aLevel; |
193 aDialog->iShowLevel.iValue = aLevel; |
|
194 aDialog->iShowLevel.iChanged = ETrue; |
175 } |
195 } |
176 |
196 |
177 /*! |
197 /*! |
178 \class MHbDeviceNotificationDialogObserver |
198 \class MHbDeviceNotificationDialogObserver |
179 \brief MHbDeviceNotificationDialogObserver is an observer interface for observing CHbDeviceNotificationDialogSymbian. |
199 \brief MHbDeviceNotificationDialogObserver is an observer interface for observing CHbDeviceNotificationDialogSymbian. |
180 */ |
200 */ |
181 |
|
182 /*! |
201 /*! |
183 \fn void MHbDeviceNotificationDialogObserver::NotificationDialogActivated(const CHbDeviceNotificationDialogSymbian* aDialog) = 0; |
202 \fn void MHbDeviceNotificationDialogObserver::NotificationDialogActivated(const CHbDeviceNotificationDialogSymbian* aDialog) = 0; |
184 |
203 |
185 This callback is called when notification dialog is activated. |
204 This callback is called when notification dialog is activated. |
186 \a aDialog - Pointer to dialog instance which received activation event. |
205 \a aDialog is a pointer to a dialog instance which received activation event. |
187 */ |
206 |
188 |
207 \sa CHbDeviceNotificationDialogSymbian::EnableTouchActivation() |
|
208 */ |
189 /*! |
209 /*! |
190 \fn void MHbDeviceNotificationDialogObserver::NotificationDialogClosed(const CHbDeviceNotificationDialogSymbian* aDialog, TInt aCompletionCode) = 0; |
210 \fn void MHbDeviceNotificationDialogObserver::NotificationDialogClosed(const CHbDeviceNotificationDialogSymbian* aDialog, TInt aCompletionCode) = 0; |
191 |
211 |
192 This callback is called when notification dialog is closed. |
212 This callback is called when notification dialog has closed. |
193 \a aDialog - Pointer to dialog instance which received closed event. |
213 \a aDialog is a pointer to a dialog instance which received closed event. |
194 \a aCompletionCode - Result of the dialog completion. |
214 \a aCompletionCode can be either Symbian error code or device dialog error code. |
195 */ |
215 */ |
196 |
216 |
197 /*! |
217 /*! |
198 \fn void MHbDeviceNotificationDialogObserver::NotificationDialogError(const CHbDeviceNotificationDialogSymbian* aDialog, TInt aError) = 0; |
218 \stable |
199 |
219 \hbwidgets |
200 This callback is called when an error has occurred. |
220 |
201 \a aDialog - Pointer to dialog instance which received closed event. |
|
202 \a aError - Error code. |
|
203 */ |
|
204 |
|
205 /*! |
|
206 \class CHbDeviceNotificationDialogSymbian |
221 \class CHbDeviceNotificationDialogSymbian |
207 \brief CHbDeviceNotificationDialogSymbian is a Symbian implementation of HbDeviceNotificationDialog. |
222 \brief CHbDeviceNotificationDialogSymbian is a Symbian implementation of HbDeviceNotificationDialog. |
208 |
223 |
209 It is a client interface for s60 native application to show a non-modal dialog on top of applications when |
224 <b>This class is Symbian only. Not available on other platforms.</b> |
210 HbDeviceNotificationDialog can not be used. |
225 |
211 |
226 CHbDeviceNotificationDialogSymbian is intended for use by servers that don't run Qt event loop |
212 CHbDeviceNotificationDialogSymbian provides similar interface and functionality as HbDeviceNotificationDialog. |
227 and cannot use HbDeviceNotificationDialog. |
213 Main difference is that signals are replaced by an observer interface CHbDeviceNotificationDialogSymbianObserver. |
228 |
214 |
229 See HbDeviceNotificationDialog documentation to find out more about device notification |
215 For the content CHbDeviceNotificationDialogSymbian provides two rows of text, an image or an animation and for the usage |
230 dialogs. |
216 same rules as for the HbDeviceNotificationDialog apply. Dialog is shown when show() is called. It is recommended that |
231 |
217 the dialog data is initialized before calling ShowL() or UpdateL() methods, because those methods use interprocess communication. |
232 CHbDeviceNotificationDialogSymbian provides similar interface and functionality as |
218 |
233 HbDeviceNotificationDialog. Main difference is that signals are replaced by an observer |
219 Two timeout constants are provided for setting the dialog timeout: KHbShortNotificationDialogTimeout and |
234 interface CHbDeviceNotificationDialogSymbianObserver. |
220 KHbLongNotificationDialogTimeout. The first is equivalent to HbPopup::ConfirmationNoteTimeout and the latter |
235 |
221 is equivalent to HbPopup::StandardTimeout. |
236 An asynchronous ShowL() method launches a dialog. Device dialog framework decides when the |
222 |
237 dialog is actually shown. There may be a delay untill dialog appears on display. Close() |
|
238 closes a dialog. |
|
239 |
|
240 After dialog has been lauched, properties may be updated by setters and calling UpdateL(). |
|
241 It is recommended that dialog properties are set before calling ShowL() as updating them after |
|
242 causes interprocess communication. |
|
243 |
|
244 If there is no need to update or receive activation from a launched dialog, |
|
245 CHbDeviceNotificationDialogSymbian object can be deleted after ShowL() returns. Device |
|
246 dialog framework takes care of displaying the dialog. |
|
247 |
|
248 For maintaining consistent look and feel, two timeout constants are provided for setting |
|
249 dialog timeout: KHbShortNotificationDialogTimeout and KHbLongNotificationDialogTimeout. |
|
250 The first one is equivalent to HbPopup::ConfirmationNoteTimeout and the latter |
|
251 to HbPopup::StandardTimeout. |
|
252 |
223 \code |
253 \code |
224 Following code snippet creates a device notification dialog containing title, text and icon. |
254 Following code snippet creates a device notification dialog containing title, text and icon. |
225 |
255 |
226 _LIT(KDialogText, "Dialog text"); |
256 _LIT(KDialogText, "Dialog text"); |
227 _LIT(KDialogTitle, "Dialog title"); |
257 _LIT(KDialogTitle, "Dialog title"); |
228 _LIT(KDialogIcon, "note_info.svg"); |
258 _LIT(KDialogIcon, "qtg_large_info"); |
229 |
259 |
230 CHbDeviceNotificationDialogSymbian* dialog = CHbDeviceNotificationDialogSymbian::NewL(); |
260 CHbDeviceNotificationDialogSymbian* dialog = CHbDeviceNotificationDialogSymbian::NewL(); |
231 CleanupStack::PushL(dialog); |
261 CleanupStack::PushL(dialog); |
232 dialog->SetTextL(KDialogText); |
262 dialog->SetTextL(KDialogText); |
233 dialog->SetTitleL(KDialogTitle); |
263 dialog->SetTitleL(KDialogTitle); |
234 dialog->SetIconNameL(KDialogIcon); |
264 dialog->SetIconNameL(KDialogIcon); |
235 dialog->Show(); |
265 dialog->ShowL(); |
236 CleanupStack::PopAndDestroy(dialog); |
266 CleanupStack::PopAndDestroy(dialog); |
237 \endcode |
267 \endcode |
238 |
268 |
239 or equivalent dialog can be created using one of the provided convenience methods: |
269 or equivalent dialog can be created using one of the provided convenience methods: |
240 |
270 |
241 \code |
271 \code |
242 _LIT(KDialogText, "Dialog text"); |
272 _LIT(KDialogText, "Dialog text"); |
243 _LIT(KDialogTitle, "Dialog title"); |
273 _LIT(KDialogTitle, "Dialog title"); |
244 _LIT(KDialogIcon, "note_info.svg"); |
274 _LIT(KDialogIcon, "qtg_large_info"); |
245 |
275 |
246 CHbDeviceNotificationDialogSymbian::Notification(KDialogIcon, KDialogText, KDialogTitle); |
276 CHbDeviceNotificationDialogSymbian::Notification(KDialogIcon, KDialogText, KDialogTitle); |
247 \endcode |
277 \endcode |
248 |
278 |
249 When using convenience methods, it is not possible to receive user interaction events, because the |
279 When using convenience methods, it is not possible to receive user interaction events, |
250 HbDeviceNotificationDialog instance is destroyed when the call returns. Ownership and handling of the |
280 because the HbDeviceNotificationDialog instance is destroyed when the call returns. |
251 dialog is transferred to HbDeviceDialog framework. Also dialog can not be closed nor updated. |
281 |
252 |
282 Below is an example of receiving user interaction events from device notification dialog. |
253 Below is an example of receiving user interaction events from device notification dialog. With following example |
283 With following example user is able to receive activated and close events. |
254 user is able to receive activated and close events. Note that dialog is cancelled, if it goes out of scope. |
284 Note that in this case the dialog is closed by device dialog framework if |
|
285 CHbDeviceNotificationDialogSymbian object is deleted. |
255 |
286 |
256 \code |
287 \code |
257 _LIT(KDialogText, "Dialog text"); |
288 _LIT(KDialogText, "Dialog text"); |
258 _LIT(KDialogTitle, "Dialog title"); |
289 _LIT(KDialogTitle, "Dialog title"); |
259 _LIT(KDialogIcon, "note_info.svg"); |
290 _LIT(KDialogIcon, "qtg_large_info"); |
260 |
291 |
261 class DialogObserver : public MHbDeviceNotificationDialogObserver |
292 class DialogObserver : public MHbDeviceNotificationDialogObserver |
262 { |
293 { |
263 public: |
294 public: |
264 DialogObserver() {} |
295 DialogObserver() {} |
502 } |
547 } |
503 return TPtrC(KNullDesC()); |
548 return TPtrC(KNullDesC()); |
504 } |
549 } |
505 |
550 |
506 /*! |
551 /*! |
507 Enable user interaction on dialog. Setting is not set, if Show() or Update() |
552 Enables user interaction on dialog. |
508 is not called. |
553 |
509 \param aEnable - When enabled, activation event is notified via observer interface. |
554 \param aEnable True enables activation event notification via observer interface. |
510 |
555 |
511 Default value is false. |
556 \sa IsTouchActivating(), ShowL(), UpdateL(), MCHbDeviceNotificationDialogSymbianObserver |
512 \sa ShowL(), UpdateL(), MCHbDeviceNotificationDialogSymbianObserver. |
|
513 */ |
557 */ |
514 EXPORT_C void CHbDeviceNotificationDialogSymbian::EnableTouchActivation(TBool aEnable) |
558 EXPORT_C void CHbDeviceNotificationDialogSymbian::EnableTouchActivation(TBool aEnable) |
515 { |
559 { |
516 d->iEnable = aEnable; |
560 d->iEnable.iValue = aEnable; |
517 } |
561 d->iEnable.iChanged = ETrue; |
518 |
562 } |
519 /*! |
563 |
520 Get touch activation setting. |
564 /*! |
|
565 Returns touch activation setting. Default value is false. |
521 |
566 |
522 \sa EnableTouchActivation() |
567 \sa EnableTouchActivation() |
523 */ |
568 */ |
524 EXPORT_C TBool CHbDeviceNotificationDialogSymbian::IsTouchActivating() const |
569 EXPORT_C TBool CHbDeviceNotificationDialogSymbian::IsTouchActivating() const |
525 { |
570 { |
526 return d->iEnable; |
571 return d->iEnable.iValue; |
527 } |
572 } |
528 |
573 |
529 /*! |
574 /*! |
530 Set dialog timeout. Timeout is not set, if Show() or Update() |
575 Set dialog timeout. |
531 is not called. |
576 |
532 \param aTimeout - Set timeout for dialog. |
577 \param aTimeout Dialog timeout in milliseconds. |
533 |
578 |
534 Default value is KHbLongNotificationDialogTimeout (3000 ms). |
579 \sa Timeout(), ShowL(), UpdateL() |
535 \sa ShowL(), UpdateL() |
|
536 */ |
580 */ |
537 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetTimeout(TInt aTimeout) |
581 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetTimeout(TInt aTimeout) |
538 { |
582 { |
539 d->iTimeout = aTimeout; |
583 d->iTimeout.iValue = aTimeout; |
540 } |
584 d->iTimeout.iChanged = ETrue; |
541 |
585 } |
542 /*! |
586 |
543 Get timeout setting. |
587 /*! |
|
588 Returns timeout. Default value is KHbLongNotificationDialogTimeout (3000 ms). |
544 |
589 |
545 \sa SetTimeout() |
590 \sa SetTimeout() |
546 */ |
591 */ |
547 EXPORT_C TInt CHbDeviceNotificationDialogSymbian::Timeout() const |
592 EXPORT_C TInt CHbDeviceNotificationDialogSymbian::Timeout() const |
548 { |
593 { |
549 return d->iTimeout; |
594 return d->iTimeout.iValue; |
550 } |
595 } |
551 |
596 |
552 /*! |
597 /*! |
553 Set dialog title text wrapping. Text wrapping is not set, if Show() or Update() |
598 Sets title text wrapping. The title can wrap only if there is no text for the dialog. |
554 is not called. |
599 The title can wrap to a maximum of two lines. SetTextL() also changes title text wrapping. |
555 \param aWrapping - Defines title text wrapping. |
600 |
556 |
601 |
557 Default value is CHbDeviceNotificationDialogSymbian::TextNoWrap. |
602 \param aWrapping Title text wrapping. |
558 \sa ShowL(), UpdateL() |
603 |
|
604 \sa TitleTextWrapping(), SetTextL(), ShowL(), UpdateL() |
559 */ |
605 */ |
560 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetTitleTextWrapping( |
606 EXPORT_C void CHbDeviceNotificationDialogSymbian::SetTitleTextWrapping( |
561 TextWrapping aWrapping) |
607 TextWrapping aWrapping) |
562 { |
608 { |
563 d->iWrap = aWrapping; |
609 d->iWrap.iValue = aWrapping; |
564 } |
610 d->iWrap.iChanged = ETrue; |
565 |
611 } |
566 /*! |
612 |
567 Get title text wrapping setting. |
613 /*! |
|
614 Returns title text wrapping. |
|
615 |
|
616 The title can wrap only if dialog text is empty. The title can wrap to a maximum of two lines. |
|
617 The default is CHbDeviceNotificationDialogSymbian::TextWordWrap. |
568 |
618 |
569 \sa SetTitleTextWrapping() |
619 \sa SetTitleTextWrapping() |
570 */ |
620 */ |
571 EXPORT_C CHbDeviceNotificationDialogSymbian::TextWrapping CHbDeviceNotificationDialogSymbian::TitleTextWrapping() const |
621 EXPORT_C CHbDeviceNotificationDialogSymbian::TextWrapping CHbDeviceNotificationDialogSymbian::TitleTextWrapping() const |
572 { |
622 { |
573 return d->iWrap; |
623 if (d->iWrap.iChanged) { |
574 } |
624 return static_cast<TextWrapping>(d->iWrap.iValue); |
575 |
625 } else { |
576 /*! |
626 return Text().Length() == 0 ? TextWordWrap : TextNoWrap; |
577 Show the dialog. |
627 } |
578 \code |
628 } |
579 // example to show dialog. |
629 |
580 iNotificationDialog->SetTitleL("Dialog title text"); |
630 /*! |
581 iNotificationDialog->ShowL(); |
631 Shows a notification dialog and returns immediately without waiting for it to close. |
582 \endcode |
632 Closing of the dialog and tapping of dialog is indicated by MHbDeviceNotificationDialogObserver |
|
633 callback interface. Dialog can be updated while showing by property setters and then calling |
|
634 UpdateL(). |
|
635 |
|
636 \sa UpdateL(), Close(), MHbDeviceNotificationDialogObserver |
583 */ |
637 */ |
584 EXPORT_C void CHbDeviceNotificationDialogSymbian::ShowL() |
638 EXPORT_C void CHbDeviceNotificationDialogSymbian::ShowL() |
585 { |
639 { |
586 d->ShowL(); |
640 d->ShowL(); |
587 } |
641 } |
588 |
642 |
589 /*! |
643 /*! |
590 Update the dialog. Show must be called before update can be used. |
644 Updates changed properties to a showing notification dialog via interprocess |
591 \code |
645 communication. Has no effect if ShowL() has not been called or the dialog has |
592 // example to update already showing dialog. |
646 closed already. |
593 iNotificationDialog->SetTitleL("Update title"); |
647 |
594 iNotificationDialog->UpdateL(); |
648 \sa ShowL() |
595 \endcode |
|
596 */ |
649 */ |
597 |
650 |
598 EXPORT_C void CHbDeviceNotificationDialogSymbian::UpdateL() |
651 EXPORT_C void CHbDeviceNotificationDialogSymbian::UpdateL() |
599 { |
652 { |
600 d->UpdateL(); |
653 d->UpdateL(); |
601 } |
654 } |
602 |
655 |
603 /*! |
656 /*! |
604 Close the dialog. Method has no effect if convenience methods |
657 Closes a device notification dialog. |
605 are used to show device notification dialog. |
|
606 */ |
658 */ |
607 EXPORT_C void CHbDeviceNotificationDialogSymbian::Close() |
659 EXPORT_C void CHbDeviceNotificationDialogSymbian::Close() |
608 { |
660 { |
609 d->Close(); |
661 d->Close(); |
610 } |
662 } |