34 #include "hbsymbianvariant.h" |
34 #include "hbsymbianvariant.h" |
35 #include "hbsymbianvariantconverter_p.h" |
35 #include "hbsymbianvariantconverter_p.h" |
36 #include "hbdeleteguardsymbian_p.h" |
36 #include "hbdeleteguardsymbian_p.h" |
37 |
37 |
38 /*! |
38 /*! |
39 \class CHbDeviceDialogSymbian |
39 \stable |
40 \brief CHbDeviceDialog displays dialogs on top of applications. It is a client interface for Symbian applications to Hb |
40 \hbcore |
41 device dialogs. |
41 |
42 \sa HbDeviceDialog |
42 \class CHbDeviceDialogSymbian |
43 |
43 \brief CHbDeviceDialogSymbian is a Symbian implementation of HbDeviceDialog. |
44 Data given to this API in symbian format is packed to QVariantMap. See |
44 |
45 CHbSymbianVariant to see which Qt datatypes are supported. |
45 <b>This class is Symbian only. Not available on other platforms.</b> |
46 \sa CHbSymbianVariant |
46 |
47 \sa CHbSymbianVariantMap |
47 See HbDeviceDialog documentation to find out more about device dialogs. |
48 |
48 |
49 When plugin returns data in Qt format, the data is converted, if possible, |
49 CHbDeviceDialogSymbian is intended for use by Symbian servers that don't run Qt event loop |
50 to CHbSymbianVariantMap. |
50 and cannot use HbDeviceDialog. |
51 |
51 |
52 \stable |
52 The class is accompanied by classes CHbSymbianVariant and CHbSymbianVariantMap which |
53 |
53 are used to encapsulate device dialog parameters. Device dialog framework takes care of |
54 \hbcore |
54 translating Symbian data types to/from format understood by device dialog plugins. |
|
55 |
|
56 CHbDeviceDialogSymbian provides an asynchronous interface to show dialogs. Dialog closing |
|
57 and data events are indicated by MHbDeviceDialogObserver callback interface. |
|
58 |
|
59 The code below launches a device dialog. Observer is not set and the dialog |
|
60 closes itself by timeout. |
|
61 \code |
|
62 |
|
63 CHbDeviceDialogSymbian* dialog = CHbDeviceDialogSymbian::NewL(); |
|
64 CleanupStack::PushL(dialog); |
|
65 CHbSymbianVariantMap* map = CHbSymbianVariantMap::NewL(); |
|
66 CleanupStack::PushL(map); |
|
67 |
|
68 _LIT(KTimeoutKey, "timeout"); |
|
69 const TInt timeoutValue = 10000; |
|
70 CHbSymbianVariant* timeout = CHbSymbianVariant::NewL(&timeoutValue, CHbSymbianVariant::EInt); |
|
71 CleanupStack::PushL(timeout); |
|
72 User::LeaveIfError(map->Add(KTimeoutKey, timeout)); |
|
73 CleanupStack::Pop(); // timeout |
|
74 |
|
75 _LIT(KTitleValue, "Sample title"); |
|
76 _LIT(KTitleKey, "title"); |
|
77 CHbSymbianVariant* title = CHbSymbianVariant::NewL(&KTitleValue(), CHbSymbianVariant::EDes); |
|
78 CleanupStack::PushL(title); |
|
79 User::LeaveIfError(map->Add(KTitleKey, title)); |
|
80 CleanupStack::Pop(); // title |
|
81 |
|
82 _LIT(KTextValue, "Sample text"); |
|
83 _LIT(KTextKey, "text"); |
|
84 CHbSymbianVariant* text = CHbSymbianVariant::NewL(&KTextValue(), CHbSymbianVariant::EDes); |
|
85 CleanupStack::PushL(text); |
|
86 User::LeaveIfError(map->Add(KTextKey, text)); |
|
87 CleanupStack::Pop(); // text |
|
88 |
|
89 _LIT(KDeviceDialogType, "com.nokia.hb.devicenotificationdialog/1.0"); |
|
90 dialog->Show(KDeviceDialogType, *map); |
|
91 CleanupStack::PopAndDestroy(2); // dialog, map |
|
92 \endcode |
|
93 |
|
94 \sa HbDeviceDialog, CHbSymbianVariant, CHbSymbianVariantMap, MHbDeviceDialogObserver |
55 */ |
95 */ |
56 |
96 |
57 /*! |
97 /*! |
58 \enum CHbDeviceDialogSymbian::TDeviceDialogError |
98 \enum CHbDeviceDialogSymbian::TDeviceDialogError |
59 Defines device dialog error codes and ranges. |
99 Defines device dialog error codes and ranges. |
60 */ |
100 */ |
61 /*! |
101 /*! |
62 \var TDeviceDialogError::DeviceDialogError HbDeviceDialog::EFrameworkErrors |
102 \var CHbDeviceDialogSymbian::TDeviceDialogError CHbDeviceDialogSymbian::EFrameworkErrors |
63 Start of an error range for errors originating from device dialog framework (client or server). |
103 Start of an error range for errors originating from device dialog framework (client or server). |
64 */ |
104 */ |
65 /*! |
105 /*! |
66 \var TDeviceDialogError::DeviceDialogError HbDeviceDialog::EPluginErrors |
106 \var CHbDeviceDialogSymbian::TDeviceDialogError CHbDeviceDialogSymbian::EPluginErrors |
67 Start of an error range for errors originating from device dialog plugins. The framework passes |
107 Start of an error range for errors originating from device dialog plugins. The framework passes |
68 these from the plugin unmodified. |
108 these from the plugin unmodified. |
69 */ |
109 */ |
70 /*! |
110 /*! |
71 \var TDeviceDialogError::DeviceDialogError HbDeviceDialog::EErrorTypeMask |
111 \var CHbDeviceDialogSymbian::TDeviceDialogError CHbDeviceDialogSymbian::EErrorTypeMask |
72 Mask for error type part of the error code. |
112 Mask for error type part of the error code. |
73 */ |
113 */ |
74 /*! |
114 /*! |
75 \var TDeviceDialogError::DeviceDialogError HbDeviceDialog::ECancelledError |
115 \var CHbDeviceDialogSymbian::TDeviceDialogError CHbDeviceDialogSymbian::ECancelledError |
76 Operation was cancelled by Cancel(). |
116 Operation was cancelled by Cancel(). |
77 */ |
117 */ |
78 /*! |
118 /*! |
79 \var TDeviceDialogError::DeviceDialogError HbDeviceDialog::ESystemCancelledError |
119 \var CHbDeviceDialogSymbian::TDeviceDialogError CHbDeviceDialogSymbian::ESystemCancelledError |
80 Operation was cancelled by device dialog framework. |
120 Operation was cancelled by device dialog framework. |
81 */ |
121 */ |
82 /*! |
122 /*! |
83 \var TDeviceDialogError::DeviceDialogError HbDeviceDialog::EInstanceExistsError |
123 \var CHbDeviceDialogSymbian::TDeviceDialogError CHbDeviceDialogSymbian::EInstanceExistsError |
84 A single instance device dialog widget exists already (has been launched). |
124 A single instance device dialog widget exists already (has been launched). |
85 See HbDeviceDialogPlugin::SingleInstance. |
125 See HbDeviceDialogPlugin::SingleInstance. |
86 */ |
126 */ |
87 |
127 |
88 /*! |
128 /*! |
|
129 \enum CHbDeviceDialogSymbian::TDeviceDialogFlag |
|
130 Defines construct flags. |
|
131 */ |
|
132 /*! |
|
133 \var CHbDeviceDialogSymbian::TDeviceDialogFlag CHbDeviceDialogSymbian::ENoDeviceDialogFlags |
|
134 No flags specified. |
|
135 */ |
|
136 /*! |
|
137 \var CHbDeviceDialogSymbian::TDeviceDialogFlag CHbDeviceDialogSymbian::EImmediateResourceReservation |
|
138 Reserves resources immediately instead of delaying until Show() is called. |
|
139 */ |
|
140 /*! |
|
141 \var CHbDeviceDialogSymbian::TDeviceDialogFlag CHbDeviceDialogSymbian::EASyncServerStartup |
|
142 Starts device dialog service asynchronously. |
|
143 */ |
|
144 |
|
145 /*! |
89 \fn void MHbDeviceDialogObserver::DataReceived(CHbSymbianVariantMap& aData) |
146 \fn void MHbDeviceDialogObserver::DataReceived(CHbSymbianVariantMap& aData) |
90 |
147 |
91 This callback is called when data is received from a device dialog. |
148 This callback is called when data is received from a device dialog. |
92 \a aData contains data from the dialog plugin. |
149 \a aData contains data from the dialog plugin. The structure and meaning |
93 The structure and meaning of the data is a contract between the dialog and |
150 of the data is a contract between the dialog and a client. |
94 a client. Structure should be aligned with the data types supported by |
151 |
95 CHbSymbianVariantMap. |
152 If no observer is set in CHbDeviceDialogSymbian::Show() the latest data |
96 |
153 can be retrieved with CHbDeviceDialogSymbian::receivedData(). |
97 \sa CHbSymbianVariantMap. |
154 |
|
155 \sa CHbSymbianVariantMap |
98 */ |
156 */ |
99 |
157 |
100 /*! |
158 /*! |
101 \fn void MHbDeviceDialogObserver::DeviceDialogClosed(TInt aCompletionCode) |
159 \fn void MHbDeviceDialogObserver::DeviceDialogClosed(TInt aCompletionCode) |
102 |
160 |
103 This callback is called when a device dialog is closed. Any data sent by |
161 This callback is called when a device dialog is closed. Any data sent by |
104 the dialog is indicated by the dataReceived() callback. If no observer is |
162 the dialog is indicated by the dataReceived() callback. |
105 set in CHbDeviceDialogSymbian::Show the latest data can be retrieved with |
|
106 CHbDeviceDialogSymbian::receivedData() |
|
107 |
163 |
108 \a aCompletionCode gives the result of the dialog completion. Code can be |
164 \a aCompletionCode gives the result of the dialog completion. Code can be |
109 either Symbian error code or device dialog error code. |
165 either Symbian error code or device dialog error code. |
110 |
166 |
111 \sa DataReceived() ReceivedData() |
167 \sa DataReceived(), ReceivedData() |
112 */ |
168 */ |
113 |
169 |
114 // Device dialogs are implemented only for Symbian/S60 OS. |
170 NONSHARABLE_CLASS(CHbDeviceDialogSymbianPrivate) : public CActive |
115 |
|
116 class CHbDeviceDialogSymbianPrivate : public CActive |
|
117 { |
171 { |
118 public: |
172 public: |
119 CHbDeviceDialogSymbianPrivate(TInt aFlags); |
173 CHbDeviceDialogSymbianPrivate(TInt aFlags); |
120 ~CHbDeviceDialogSymbianPrivate(); |
174 ~CHbDeviceDialogSymbianPrivate(); |
121 TInt Initialize(); |
175 TInt Initialize(); |
493 { |
523 { |
494 delete d; |
524 delete d; |
495 } |
525 } |
496 |
526 |
497 /*! |
527 /*! |
498 Show of device dialog. Each time a Show() is called a new dialog is launched. |
528 Shows a device dialog. Each time a Show() is called, a new dialog is launched. |
499 aParameter data is sent to device dialog in Qt's QVariantMap object. |
529 The function is asynchronous and returns after the service has accepted the dialog. |
500 The function is asynchronous and returns immediately. Closing and data events from the |
530 Closing and data events from the dialog are indicated by observer interface. |
501 dialog can be received by observer interface. Deleting CHbDeviceDialogSymbian object |
531 Deleting CHbDeviceDialogSymbian object closes and deletes the device dialog at server |
502 closes and deletes the device dialog at server if observer is set. If observer is null |
532 if observer is set. If no observer is set, the dialog is left executing at the server |
503 the dialog is left executing at the server and it's assumed it closes itself by a timeout. |
533 and it's assumed it closes itself by a timeout. Cancel() closes the device dialog. |
504 Cancel() to closes the device dialog. |
534 |
505 |
535 \param aDeviceDialogType Identifies a device dialog. |
506 \a aDeviceDialogType is name of the device dialog. Identifies the device |
536 \param aParameters Contains parameters for the device dialog. |
507 dialog plugin. \a aParameters is a buffer containing data for the device dialog. |
537 \param aObserver Contains observer for the dialog or 0 for no observer. |
508 |
538 |
509 \a aObserver is used to observe the session. |
539 \return returns 0 on success or error code. |
510 |
540 |
511 Return value informs if the call was successful. |
541 \sa Update(), Cancel() |
512 |
|
513 \sa Update() Cancel() |
|
514 */ |
542 */ |
515 EXPORT_C TInt CHbDeviceDialogSymbian::Show(const TDesC& aDeviceDialogType, const CHbSymbianVariantMap& aParameters, MHbDeviceDialogObserver* aObserver) |
543 EXPORT_C TInt CHbDeviceDialogSymbian::Show(const TDesC& aDeviceDialogType, const CHbSymbianVariantMap& aParameters, MHbDeviceDialogObserver* aObserver) |
516 { |
544 { |
517 d->SetObserver(aObserver); |
545 d->SetObserver(aObserver); |
518 |
546 |