src/hbcore/devicedialogbase/hbdevicedialog.cpp
changeset 2 06ff229162e9
parent 0 16d8024aca5e
child 5 627c4a0fd0e7
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
    26 /*!
    26 /*!
       
    27     @stable
       
    28     @hbcore
    27     \class HbDeviceDialog
    29     \class HbDeviceDialog
    28     \brief HbDeviceDialog displays dialogs on top of applications
    30     \brief HbDeviceDialog displays a dialog on top of all running applications
    29 
    31     
    30     HbDeviceDialog is a concrete class. It can be used directly or as a part of
    32     Device Dialogs are used to display information, queries and alerts for the device rather than
    31     specialization classes for different device dialog types. It's not a widget but interfaces
    33     for an application. Some example device dialogs are:
    32     to a device dialog service which is responsible for displaying device dialogs.
    34     - Low battery
    33     Device dialog widgets are implemented in plugins loaded by the service.
    35     - Low memory
    34 
    36     - Incoming bluetooth message
    35     Below is a runtime view of device dialog framework.
    37     - Text message received
       
    38     
       
    39     Due to the importance of these dialogs they are
       
    40     displayed on top of all applications. The HbDeviceDialog class provides the client
       
    41     interface for creating these dialogs. This differs from other dialog classes such as 
       
    42     HbMessageBox in that 
       
    43     HbDeviceDialog is not a widget but is the interface to a framework that handles the dialogs.
       
    44     
       
    45     \section _framework Device Dialog Framework
       
    46     
       
    47     Any application is able to generate device dialogs. However, in
       
    48     order to display the dialogs on top of all applications, the device dialog framework 
       
    49     uses a server. To display a dialog an application uses the HbDeviceDialog client interface to send requests for
       
    50     dialogs to the server. The HbDeviceDialog class can also be used or extended as part of a set of specialization classes
       
    51     to create different device dialog types. 
       
    52     
       
    53     Device dialog widgets are implemented in plugins loaded by the server.
       
    54 
       
    55     Shown below is a runtime view of the device dialog framework.
    36 
    56 
    37     \dot
    57     \dot
    38     digraph G {
    58     digraph G {
    39 
    59 
    40         rankdir=LR;
    60         rankdir=LR;
   103         deviceDialogManager -> deviceDialog1 [label = "data"];
   123         deviceDialogManager -> deviceDialog1 [label = "data"];
   104         deviceDialogManager -> deviceDialog2 [label = "data"];
   124         deviceDialogManager -> deviceDialog2 [label = "data"];
   105     }
   125     }
   106     \enddot
   126     \enddot
   107 
   127 
       
   128     <b>Platform dependent.</b> Currently server is implemented only for Symbian platform. On other platforms,
       
   129     device dialog are displayed on client's mainwindow.
       
   130 
   108     HbDeviceDialog has no dependencies to other parts of the framework. Only to Qt. Thus it can be used
   131     HbDeviceDialog has no dependencies to other parts of the framework. Only to Qt. Thus it can be used
   109     also from engine components that have no user interface.
   132     also from engine components that have no user interface.
   110 
   133 
   111     There are three classes of device dialogs. Generic device dialogs which are displayed on top
   134     \section _types Types of device dialogs
   112     of all applications (incoming call is an exception). Examples of these are "Low memory"
   135 
   113     message box and "Receive message via bluetooth" query. Device notification dialogs are
   136     There are three classes of device dialogs:
   114     notifications displayed in a top left corner of a display. Examples are "New message" and
   137      -# Generic device dialogs are displayed on top
   115     "Low battery" notifications. Universal indicator menu shows enhanced status indicator
   138     of all applications, except in the case of an incoming call. Examples of these are a "Low memory"
       
   139     message box and a "Receive message via bluetooth?" query. 
       
   140      -# Device notification dialogs are
       
   141     notifications displayed in the top left corner of the display. Examples are "New message" and
       
   142     "Low battery" notifications. 
       
   143      -# The Universal indicator menu shows enhanced status indicator
   116     information.
   144     information.
   117 
   145 
   118     Generic device dialogs and indicator menu interrupt current foreground application.
   146     Generic device dialogs and the indicator menu interrupt the current foreground application.
   119     User cannot interact with the application with a touch or keyboard until the dialog
   147     The user cannot interact with the application with a touch or keyboard until the dialog
   120     is dismissed. Device notification dialog behaves differently allowing interaction with the
   148     is dismissed. Device notification dialogs behave differently allowing interaction with the
   121     current foreground application.
   149     current foreground application.
   122 
   150 
   123     Device dialog widgets are constructed dynamically by the device dialog service. Construction
   151     Device dialog widgets are constructed dynamically by the device dialog service. Construction
   124     takes two parameters: a type and a set of parameters appropriate to the dialog type.
   152     takes two parameters: a type and a set of parameters appropriate to the dialog type.
   125     Widgets are implemented by plugins. Device dialog type is an unique string identifying the
   153     The device dialog type is a unique string identifying the
   126     dialog. A search is made to find a plugin that can instantiate the requested
   154     dialog. A search is made to find a plugin that can instantiate the requested
   127     dialog. The service loads the plugin and creates an instance of the widget.
   155     dialog. The service loads the plugin and creates an instance of the widget.
   128 
   156 
   129     Parameter set is encapsulated in QMap<QString, QVariant>. Each device dialog implementation has
   157     The parameter set is encapsulated in QMap<QString, QVariant>. Each device dialog implementation has
   130     a default value for all parameters. Only parameters that differ from the default needs to be
   158     a default value for all parameters. Only parameters that differ from the default need to be
   131     given. Parameters are <name, value> pairs. How the parameters are used depends on
   159     given. Parameters are <name, value> pairs. How the parameters are used depends on
   132     the plugin implementing the dialog. Suggested usage is <name, value> used as property
   160     the plugin implementing the dialog. Suggested usage is <name, value> used as property
   133     name and value pairs of the dialog implementation. This makes it easy to set properties using
   161     name and value pairs of the dialog implementation. This makes it easy to set properties using
   134     QObject::setProperty(const char*, const QVariant&). If data types supported by QVariant are
   162     QObject::setProperty(const char*, const QVariant&). If data types supported by QVariant are
   135     not suitable for a specific device dialog, Q_DECLARE_METATYPE can be used to add data types.
   163     not suitable for a specific device dialog, Q_DECLARE_METATYPE can be used to add data types.
   136 
   164 
   137     Data can be sent to a device dialog after it has been launched using update() function. Data
   165     %Data can be sent to a device dialog after it has been launched using the update() function. %Data
   138     sent by the dialog is received by dataReceived signal. A copy of the last data received
   166     sent by the dialog is received by the dataReceived signal. A copy of the last data received
   139     is held by the class and can be fetched by a receivedData() function. This allows to receive
   167     is held by the class and can be fetched by a call to the receivedData() function. This allows data to be received
   140     data without having to connect to a signal by waiting for a dialog to close and then
   168     without having to connect to a signal by waiting for a dialog to close and then
   141     getting the received data.
   169     getting the received data.
   142 
   170 
   143     It is possible to launch multiple device dialogs from a single HbDeviceDialog object.
   171     It is possible to launch multiple device dialogs from a single HbDeviceDialog object.
   144     However if there is a need to update a dialog or receive data from it, only the last one
   172     However if there is a need to update a dialog or receive data from it, only the last dialog
   145     launched is able to do it. In this case instantiate HbDeviceDialog class for each device dialog
   173     launched supports this. In this case instantiate the HbDeviceDialog class for each device dialog
   146     that needs communication (update or data receive) after a launch.
   174     that needs communication (update or data receive) after a launch.
   147 
   175 
   148     HbDeviceDialog::show() method returns after device dialog service has accepted the dialog.
   176     HbDeviceDialog::show() method returns after the device dialog service has accepted the dialog.
   149     The service decides when the dialog is actually displayed. If there is no need to receive
   177     The service decides when the dialog is actually displayed. If there is no need to receive
   150     data from the dialog widget, HbDeviceDialog object can be destroyed after show method returns
   178     data from the dialog widget, the HbDeviceDialog object can be destroyed after the show() method returns
   151     (can be allocated in a stack). A function is provided to wait for device dialog to be dismissed
   179     (can be allocated in a stack). A function is provided to wait for the device dialog to be dismissed,
   152     making the dialog display synchronous.
   180     making the dialog display synchronous.
   153 
   181 
   154     If any signals of HbDeviceDialog are connected, then the instance needs to exist until the
   182     If any signals of HbDeviceDialog are connected, then the instance needs to exist until the
   155     dialog is dismissed. In this case device dialog service will close all dialogs
   183     dialog is dismissed. In this case the device dialog service will close all dialogs
   156     launched by the instance when it is deleted making it inappropriate to allocate HbDeviceDialog
   184     launched by the instance when it is deleted making it inappropriate to allocate HbDeviceDialog
   157     into a stack.
   185     into a stack.
   158 
   186 
   159     Several clients can share the same device dialog widget by agreeing on an unique tag. See
   187     Several clients can share the same device dialog widget by agreeing on an unique tag. See
   160     HbDeviceDialogWidgetPlugin for more information.
   188     HbDeviceDialogWidgetPlugin for more information.
   161 
   189 
   162     When HbDeviceDialog object is created, it can reserve a communication channel to device dialog
   190     When the HbDeviceDialog object is created, it can reserve a communication channel to the device dialog
   163     service or the channel creation may be delayed until show(). This is controlled by a constructor
   191     service or the channel creation may be delayed until show(). This is controlled by a constructor
   164     flag. Default is the delayed resource reservation.
   192     flag. The default is the delayed resource reservation.
   165 
   193 
   166     HbDeviceDialog class is not thread safe. If cancel() needs to called across threads, a queued
   194     The HbDeviceDialog class is not thread safe. If cancel() needs to called across threads, a queued
   167     signal slot connection can be used.
   195     signal slot connection can be used.
   168 
   196     
   169     \sa HbDeviceDialogPlugin
   197     \section _usecases Using the HbDeviceDialog class
   170 
   198     
   171     \beta
   199     The code below launches a device dialog and continues execution
   172     \hbcore
       
   173 */
       
   174 
       
   175 /*!
       
   176     \enum HbDeviceDialog::DeviceDialogError
       
   177     Defines device dialog error codes and ranges.
       
   178 */
       
   179 /*!
       
   180     \var HbDeviceDialog::DeviceDialogError HbDeviceDialog::FrameworkErrors
       
   181     Start of an error range for errors originating from device dialog framework (client or server).
       
   182 */
       
   183 /*!
       
   184     \var HbDeviceDialog::DeviceDialogError HbDeviceDialog::PluginErrors
       
   185     Start of an error range for errors originating from device dialog plugins. The framework passes
       
   186     these from the plugin unmodified.
       
   187 */
       
   188 /*!
       
   189     \var HbDeviceDialog::DeviceDialogError HbDeviceDialog::ErrorTypeMask
       
   190     Mask for error type part of the error code.
       
   191 */
       
   192 /*!
       
   193     \var HbDeviceDialog::DeviceDialogError HbDeviceDialog::CancelledError
       
   194     Operation was cancelled by cancel().
       
   195 */
       
   196 /*!
       
   197     \var HbDeviceDialog::DeviceDialogError HbDeviceDialog::SystemCancelledError
       
   198     Operation was cancelled by device dialog framework.
       
   199 */
       
   200 
       
   201 /*!
       
   202     \enum HbDeviceDialog::DeviceDialogFlags
       
   203     Defines construct flags.
       
   204 */
       
   205 /*!
       
   206     \var HbDeviceDialog::DeviceDialogFlags HbDeviceDialog::NoDeviceDialogFlags
       
   207     No flags specified.
       
   208 */
       
   209 /*!
       
   210     \var HbDeviceDialog::DeviceDialogFlags HbDeviceDialog::NoFlags
       
   211     No flags specified.
       
   212 */
       
   213 /*!
       
   214     \var HbDeviceDialog::DeviceDialogFlags HbDeviceDialog::ImmediateResourceReservationFlag
       
   215     Reserves resources immediately instead of delaying until show() is called.
       
   216 */
       
   217 
       
   218 /*!
       
   219      \fn void HbDeviceDialog::dataReceived(QVariantMap data)
       
   220 
       
   221       This signal is emitted when data is received from a device dialog. \a data contains data from
       
   222       the dialog. The structure and meaning of the data is a contract between the dialog and
       
   223       a client. Suggested usage is a set of signal names and parameters.
       
   224 */
       
   225 
       
   226 /*!
       
   227     \fn void HbDeviceDialog::deviceDialogClosed()
       
   228 
       
   229     This signal is emitted when a device dialog is closed. Any data sent by the dialog is indicated by
       
   230     the dataReceived() signal. If the signal is not connected, latest data received is saved and
       
   231     can be retrieved by a receivedData() function.
       
   232 
       
   233     \sa dataReceived() receivedData()
       
   234 */
       
   235 
       
   236 /*!
       
   237     \fn void HbDeviceDialog::error(int error)
       
   238 
       
   239     This signal is emitted when an error has occurred. \a error contains an error code.
       
   240 */
       
   241 
       
   242 #include "hbdevicedialog.h"
       
   243 
       
   244 #include <QtGlobal>
       
   245 
       
   246 // Device dialogs are implemented only for Symbian/S60 OS. All others use a stub which shows
       
   247 // device dialogs in the calling process.
       
   248 #if defined(Q_OS_SYMBIAN)
       
   249 #include "hbdevicedialogsym_p.h"
       
   250 #else
       
   251 #include "hbdevicedialogwin32_p.h"
       
   252 #endif // defined(Q_OS_SYMBIAN)
       
   253 
       
   254 /*!
       
   255     Constructs an object. \a f contains construct flags. \a parent is a parent pointer.
       
   256     HbDeviceDialog can be allocated into a stack if no signals are to be connected. Device dialog
       
   257     service keeps dialogs launched when the object goes out of scope. If any signals
       
   258     are connected, device dialog service will clean all dialogs launched when the instance is
       
   259     deleted. In this case the object must remain in existence until the dialog widget is
       
   260     dismissed.
       
   261 */
       
   262 HbDeviceDialog::HbDeviceDialog(DeviceDialogFlags f, QObject *parent) :
       
   263     QObject(parent), d_ptr(new HbDeviceDialogPrivate)
       
   264 {
       
   265     Q_D(HbDeviceDialog);
       
   266     d->q_ptr = this;
       
   267     d->init(f);
       
   268 }
       
   269 
       
   270 HbDeviceDialog::HbDeviceDialog(HbDeviceDialogPrivate &dd, DeviceDialogFlags f, QObject *parent) :
       
   271     QObject(parent), d_ptr(&dd)
       
   272 {
       
   273     Q_D(HbDeviceDialog);
       
   274     d->q_ptr = this;
       
   275     d->init(f);
       
   276 }
       
   277 
       
   278 HbDeviceDialog::~HbDeviceDialog()
       
   279 {
       
   280     delete d_ptr;
       
   281 }
       
   282 
       
   283 /*!
       
   284     Shows a device dialog using a device dialog service. The function returns immediately after the
       
   285     service has accepted the dialog. Returns true if dialog was accepted, false if error occurred.
       
   286     The service decides when the dialog is actually displayed.
       
   287 
       
   288     \arg deviceDialogType identifies a device dialog to be displayed by a name.
       
   289     \arg parameters defines properties of the dialog.
       
   290 
       
   291     \sa update(), waitForClosed(), cancel()
       
   292 
       
   293     \code
   200     \code
   294     // Below code launches a device dialog and continues execution.
   201     // Launch a device dialog and continue execution.
   295 
   202 
   296     HbDeviceDialog deviceDialog;
   203     HbDeviceDialog deviceDialog;
   297     QVariantMap parameters;
   204     QVariantMap parameters;
   298     parameters.insertMulti(QString("text"), QVariant(QString("Warning text")));
   205     parameters.insertMulti(QString("text"), QVariant(QString("Warning text")));
   299     const char *deviceDialogType = "hb.devdlg.examplemessagebox/1.0";
   206     const char *deviceDialogType = "hb.devdlg.examplemessagebox/1.0";
   300     deviceDialog.show(QString(deviceDialogType), parameters);
   207     deviceDialog.show(QString(deviceDialogType), parameters);
   301     \endcode
   208     \endcode
   302 
   209 
       
   210     The code below demonstrates how to use HbDeviceDialog as a member variable and connect signals before launching the device dialog
   303     \code
   211     \code
   304     // Below code has HbDeviceDialog as a member variable. It connects signals and launches a device dialog.
   212     // Connect signals and launch a device dialog.
   305 
   213 
   306     connect(mDeviceDialog, SIGNAL(dataReceived(QVariantMap)),
   214     connect(mDeviceDialog, SIGNAL(dataReceived(QVariantMap)),
   307         this, SLOT(dataReceived(QVariantMap)));
   215         this, SLOT(dataReceived(QVariantMap)));
   308     connect(mDeviceDialog, SIGNAL(deviceDialogClosed()), this, SLOT(deviceDialogClosed()));
   216     connect(mDeviceDialog, SIGNAL(deviceDialogClosed()), this, SLOT(deviceDialogClosed()));
   309     connect(mDeviceDialog, SIGNAL(error(int)), this, SLOT(error(int)));
   217     connect(mDeviceDialog, SIGNAL(error(int)), this, SLOT(error(int)));
   310     QVariantMap parameters;
   218     QVariantMap parameters;
   311     mDeviceDialog.show(QString("hb.devdlg.examplequery/1.0"), parameters);
   219     mDeviceDialog.show(QString("hb.devdlg.examplequery/1.0"), parameters);
   312     \endcode
   220     \endcode    
   313 */
   221     
   314 bool HbDeviceDialog::show(const QString &deviceDialogType, const QVariantMap &parameters)
   222     The code below shows how to wait until a dialog has closed
   315 {
       
   316     return d_func()->show(deviceDialogType, parameters);
       
   317 }
       
   318 
       
   319 /*!
       
   320     Updates device dialog parameters by a set of new values. show() must be called before an
       
   321     update() can be called. If multiple dialogs have been launched by a single HbDeviceDialog
       
   322     instance, the last dialog launched receives the update. Returns true on success and false
       
   323     if error occurred.
       
   324 
       
   325     \sa show()
       
   326 */
       
   327 bool HbDeviceDialog::update(const QVariantMap &parameters)
       
   328 {
       
   329     return d_func()->update(parameters);
       
   330 }
       
   331 
       
   332 /*!
       
   333     Waits for a device dialog to be displayed and dismissed. \a flags specifies flags passed to
       
   334     QEventLoop::exec() function. Returns true on success and false if error occurred.
       
   335 
       
   336     The wait is implemented by starting a new event loop. Consider following caveats before using
       
   337     this function. Stack usage increases. Depending on application program flow, several event
       
   338     loops may get instantiated on top of each other. Application event processing continues while
       
   339     waitForClosed() executes. When it returns application state may have changed. For example some
       
   340     objects may have been deleted or application may have exited.
       
   341 
       
   342     <b>Note that starting an event loop isn't compatible with gestures.</b> Therefore if an application
       
   343     has an user interface, please don't use this function. Instead connect to signals.
       
   344 
       
   345     \sa cancel()
       
   346 
       
   347     \code
   223     \code
   348     // Below code launches a query and then waits for it to close.
   224     // Below code launches a query and then waits for it to close.
   349 
   225 
   350     // Launch query
   226     // Launch query
   351     HbDeviceDialog deviceDialog;
   227     HbDeviceDialog deviceDialog;
   354     // Wait for note to close
   230     // Wait for note to close
   355     deviceDialog.waitForClosed();
   231     deviceDialog.waitForClosed();
   356     // Get data the dialog sent
   232     // Get data the dialog sent
   357     QVariantMap data = deviceDialog.receivedData();
   233     QVariantMap data = deviceDialog.receivedData();
   358     \endcode
   234     \endcode
       
   235 
       
   236     \sa HbDeviceDialogPlugin
       
   237 */
       
   238 
       
   239 /*!
       
   240     \enum HbDeviceDialog::DeviceDialogError
       
   241     Defines device dialog error codes and ranges.
       
   242 */
       
   243 
       
   244 /*!
       
   245     \var HbDeviceDialog::DeviceDialogError HbDeviceDialog::FrameworkErrors
       
   246     Start of an error range for errors originating from the device dialog framework (client or server).
       
   247 */
       
   248 
       
   249 /*!
       
   250     \var HbDeviceDialog::DeviceDialogError HbDeviceDialog::PluginErrors
       
   251     Start of an error range for errors originating from the device dialog plugins. The framework passes
       
   252     these from the plugin unmodified.
       
   253 */
       
   254 
       
   255 /*!
       
   256     \var HbDeviceDialog::DeviceDialogError HbDeviceDialog::ErrorTypeMask
       
   257     Mask for the error type part of the error code.
       
   258 */
       
   259 
       
   260 /*!
       
   261     \var HbDeviceDialog::DeviceDialogError HbDeviceDialog::CancelledError
       
   262     Operation was cancelled by cancel().
       
   263 */
       
   264 
       
   265 /*!
       
   266     \var HbDeviceDialog::DeviceDialogError HbDeviceDialog::SystemCancelledError
       
   267     Operation was cancelled by the device dialog framework.
       
   268 */
       
   269 
       
   270 /*!
       
   271     \var HbDeviceDialog::DeviceDialogFlags HbDeviceDialog::NoFlags
       
   272     No flags specified.
       
   273 */
       
   274 
       
   275 /*!
       
   276     \enum HbDeviceDialog::DeviceDialogFlag
       
   277     Defines construct flags.
       
   278         
       
   279     The DeviceDialogFlags type is a typedef for QFlags<DeviceDialogFlag>. It stores an OR combination of the DeviceDialogFlag values.
       
   280 */
       
   281 
       
   282 /*!
       
   283     \var HbDeviceDialog::DeviceDialogFlags HbDeviceDialog::ImmediateResourceReservationFlag
       
   284     Reserves resources immediately instead of delaying until show() is called.
       
   285 */
       
   286 
       
   287 /*!
       
   288      \fn void HbDeviceDialog::dataReceived(QVariantMap data)
       
   289 
       
   290       This signal is emitted when data is received from a device dialog.
       
   291       
       
   292       \a data contains data from
       
   293       the dialog. The structure and meaning of the data is a contract between the dialog and
       
   294       a client. Suggested usage is a set of signal names and parameters.
       
   295 */
       
   296 
       
   297 /*!
       
   298     \fn void HbDeviceDialog::deviceDialogClosed()
       
   299 
       
   300     This signal is emitted when a device dialog is closed. Any data sent by the dialog is indicated by
       
   301     the dataReceived() signal. If the signal is not connected, the latest data received is saved and
       
   302     can be retrieved using the receivedData() function.
       
   303 
       
   304     \sa dataReceived() receivedData()
       
   305 */
       
   306 
       
   307 /*!
       
   308     \fn void HbDeviceDialog::error(int error)
       
   309 
       
   310     This signal is emitted when an error has occurred.
       
   311     
       
   312     \a error contains an error code.
       
   313 */
       
   314 
       
   315 #include "hbdevicedialog.h"
       
   316 
       
   317 #include <QtGlobal>
       
   318 
       
   319 // Device dialogs are implemented only for Symbian/S60 OS. All others use a stub which shows
       
   320 // device dialogs in the calling process.
       
   321 #if defined(Q_OS_SYMBIAN)
       
   322 #include "hbdevicedialogsym_p.h"
       
   323 #else
       
   324 #include "hbdevicedialogwin32_p.h"
       
   325 #endif // defined(Q_OS_SYMBIAN)
       
   326 
       
   327 /*!
       
   328     Constructor. 
       
   329     
       
   330     \param f Contains the construct flags. See DeviceDialogFlag
       
   331     \param parent The parent pointer.
       
   332     
       
   333     HbDeviceDialog can be allocated on the stack if no signals are to be connected. The Device dialog
       
   334     service keeps dialogs launched when the object goes out of scope. If any signals
       
   335     are connected, the device dialog service will clean all dialogs launched when the instance is
       
   336     deleted. In this case the object must remain in existence until the dialog widget is
       
   337     dismissed.
       
   338 */
       
   339 HbDeviceDialog::HbDeviceDialog(DeviceDialogFlags f, QObject *parent) :
       
   340     QObject(parent), d_ptr(new HbDeviceDialogPrivate)
       
   341 {
       
   342     Q_D(HbDeviceDialog);
       
   343     d->q_ptr = this;
       
   344     d->init(f);
       
   345 }
       
   346 
       
   347 /*!
       
   348  Constructor required by the shared d-pointer paradigm.
       
   349 */
       
   350 HbDeviceDialog::HbDeviceDialog(HbDeviceDialogPrivate &dd, DeviceDialogFlags f, QObject *parent) :
       
   351     QObject(parent), d_ptr(&dd)
       
   352 {
       
   353     Q_D(HbDeviceDialog);
       
   354     d->q_ptr = this;
       
   355     d->init(f);
       
   356 }
       
   357 
       
   358 /*!
       
   359     Destructor.
       
   360 */
       
   361 HbDeviceDialog::~HbDeviceDialog()
       
   362 {
       
   363     delete d_ptr;
       
   364 }
       
   365 
       
   366 /*!
       
   367     Shows a device dialog using the device dialog service.
       
   368     
       
   369     The function returns immediately after the
       
   370     service has accepted the dialog. Returns \c true if the dialog was accepted, \c false if an error occurred.
       
   371     The service decides when the dialog is actually displayed.
       
   372 
       
   373     \param deviceDialogType Identifies a device dialog to be displayed by a name.
       
   374     \param parameters Defines properties of the dialog.
       
   375 
       
   376     \sa update(), waitForClosed(), cancel()
       
   377 */
       
   378 bool HbDeviceDialog::show(const QString &deviceDialogType, const QVariantMap &parameters)
       
   379 {
       
   380     return d_func()->show(deviceDialogType, parameters);
       
   381 }
       
   382 
       
   383 /*!
       
   384     Updates device dialog parameters by a set of new values. You must call show() before calling
       
   385     update(). If multiple dialogs have been launched by a single HbDeviceDialog
       
   386     instance, the last dialog launched receives the update. 
       
   387     
       
   388     \return Returns \c true on success and \c false if an error occurred.
       
   389 
       
   390     \sa show()
       
   391 */
       
   392 bool HbDeviceDialog::update(const QVariantMap &parameters)
       
   393 {
       
   394     return d_func()->update(parameters);
       
   395 }
       
   396 
       
   397 /*!
       
   398     Waits for a device dialog to be displayed and subsequently dismissed.
       
   399     
       
   400     \a flags specifies the flags passed to the
       
   401     QEventLoop::exec() function. 
       
   402 
       
   403     The wait is implemented by starting a new event loop. The following potential problems should be considered before using
       
   404     this function: 
       
   405     - Stack usage increases.
       
   406     - Depending on the application program flow, several event
       
   407     loops may get instantiated on top of each other. 
       
   408     - Application event processing continues while
       
   409     waitForClosed() executes. 
       
   410     - When the function returns, the application state may have changed. For example some
       
   411     objects may have been deleted or the application may have exited.
       
   412 
       
   413     <b>Note that starting an event loop isn't compatible with gestures.</b> Therefore if an application
       
   414     has a user interface, please don't use this function. Instead connect to signals.
       
   415     \return Returns \c true on success and \c false if an error occurred.
       
   416     \sa cancel()
   359 */
   417 */
   360 bool HbDeviceDialog::waitForClosed(QEventLoop::ProcessEventsFlag flags)
   418 bool HbDeviceDialog::waitForClosed(QEventLoop::ProcessEventsFlag flags)
   361 {
   419 {
   362     return d_func()->waitForClosed(flags);
   420     return d_func()->waitForClosed(flags);
   363 }
   421 }
   364 
   422 
   365 /*!
   423 /*!
   366     Returns the latest data received from a device dialog. This function can be called instead of
   424     Returns the latest data received from a device dialog.
   367     connecting to dataReceived() signal. If dataReceived() signal has connections, latest data is
   425 
   368     not saved and this function returns empty data structure.
   426     This function can be called instead of
       
   427     connecting to the dataReceived() signal. If the dataReceived() signal has connections, the latest data is
       
   428     not saved and this function returns an empty data structure.
   369 
   429 
   370     \sa waitForClosed()
   430     \sa waitForClosed()
   371 */
   431 */
   372 QVariantMap HbDeviceDialog::receivedData() const
   432 QVariantMap HbDeviceDialog::receivedData() const
   373 {
   433 {
   374     return d_func()->receivedData();
   434     return d_func()->receivedData();
   375 }
   435 }
   376 
   436 
   377 /*!
   437 /*!
   378     Returns a last error. Last error is cleared when any other API function than error() is called.
   438     Returns the last error.
       
   439 
       
   440     The last error is cleared when any other API function except error() is called.
   379 */
   441 */
   380 int HbDeviceDialog::error() const
   442 int HbDeviceDialog::error() const
   381 {
   443 {
   382     return d_func()->error();
   444     return d_func()->error();
   383 }
   445 }
   384 
   446 
   385 /*!
   447 /*!
   386     Cancels a device dialog. The dialog is removed from the device dialog service. Does nothing if
   448     Cancels a device dialog and removes the dialog from the device dialog service.
   387     the dialog has already been dismissed. Removes dialog if it's waiting to be displayed or
   449 
   388     currently on display. If multiple dialogs have been launched by a single HbDeviceDialog
   450     Removes the dialog if the dialog is waiting to be displayed or
   389     instance, the last dialog launched is cancelled. deviceDialogClosed() signal is emitted if
   451     currently on display. Has no effect if
   390     a dialog was closed. Returns true on success and false if error occurred.
   452     the dialog has already been dismissed. If multiple dialogs have been launched by a single HbDeviceDialog
       
   453     instance, the last dialog launched is cancelled. The deviceDialogClosed() signal is emitted if
       
   454     a dialog was closed.
       
   455 
       
   456     \return Returns \c true on success and \c false if an error occurred.
   391 
   457 
   392     \sa show(), deviceDialogClosed()
   458     \sa show(), deviceDialogClosed()
   393 */
   459 */
   394 bool HbDeviceDialog::cancel()
   460 bool HbDeviceDialog::cancel()
   395 {
   461 {