src/hbplugins/devicedialogs/deviceprogressdialogplugin/hbdeviceprogressdialogplugin.cpp
changeset 0 16d8024aca5e
child 23 e6ad4ef83b23
child 34 ed14f46c0e55
equal deleted inserted replaced
-1:000000000000 0:16d8024aca5e
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbPlugins module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 
       
    26 #include <QtPlugin>
       
    27 
       
    28 #include <hbdevicedialog.h>
       
    29 #include <hbdevicedialogtrace_p.h>
       
    30 #include "hbdeviceprogressdialogplugin_p.h"
       
    31 #include "hbdeviceprogressdialogwidget_p.h"
       
    32 #include "hbdeviceprogressdialogpluginerrors_p.h"
       
    33 
       
    34 Q_EXPORT_PLUGIN2(deviceprogressdialogplugin, HbDeviceProgressDialogPlugin)
       
    35 
       
    36 // This plugin implements one device dialog type
       
    37 static const struct {
       
    38     const char *mTypeString;
       
    39 } dialogInfos[] = {
       
    40     {"com.nokia.hb.deviceprogressdialog/1.0"}
       
    41 };
       
    42 
       
    43 class HbDeviceProgressDialogPluginPrivate
       
    44 {
       
    45 public:
       
    46     HbDeviceProgressDialogPluginPrivate() {mError = NoError;}
       
    47 
       
    48     int mError;
       
    49 };
       
    50 
       
    51 // Constructor
       
    52 HbDeviceProgressDialogPlugin::HbDeviceProgressDialogPlugin()
       
    53 {
       
    54     TRACE_ENTRY
       
    55     d = new HbDeviceProgressDialogPluginPrivate;
       
    56     TRACE_EXIT
       
    57 }
       
    58 
       
    59 // Destructor
       
    60 HbDeviceProgressDialogPlugin::~HbDeviceProgressDialogPlugin()
       
    61 {
       
    62     TRACE_ENTRY
       
    63     delete d;
       
    64     TRACE_EXIT
       
    65 }
       
    66 
       
    67 // Check if client is allowed to use device dialog widget
       
    68 bool HbDeviceProgressDialogPlugin::accessAllowed(const QString &deviceDialogType,
       
    69     const QVariantMap &parameters, const QVariantMap &securityInfo) const
       
    70 {
       
    71     TRACE_ENTRY
       
    72     Q_UNUSED(deviceDialogType)
       
    73     Q_UNUSED(parameters)
       
    74     Q_UNUSED(securityInfo)
       
    75 
       
    76     // This plugin doesn't perform operations that may compromise security. All clients
       
    77     // are allowed to use.
       
    78     return true;
       
    79     TRACE_EXIT
       
    80 }
       
    81 
       
    82 // Create device dialog widget
       
    83 HbDeviceDialogInterface *HbDeviceProgressDialogPlugin::createDeviceDialog(
       
    84     const QString &deviceDialogType,
       
    85     const QVariantMap &parameters)
       
    86 {
       
    87     TRACE_ENTRY
       
    88     d->mError = NoError;
       
    89 
       
    90     HbDeviceDialogInterface *ret(0);
       
    91     int i(0);
       
    92     const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]);
       
    93     for(i = 0; i < numTypes; i++) {
       
    94         if (dialogInfos[i].mTypeString == deviceDialogType) {
       
    95             break;
       
    96         }
       
    97     }
       
    98     if (i < numTypes) {
       
    99         HbProgressDialog::ProgressDialogType dialogType;
       
   100         QVariantMap params = parameters;
       
   101         if (HbDeviceProgressDialogWidget::getDialogType(dialogType, params)) {
       
   102             HbDeviceProgressDialogWidget *deviceDialog =
       
   103                 new HbDeviceProgressDialogWidget(dialogType, params);
       
   104             d->mError = deviceDialog->deviceDialogError();
       
   105             if (d->mError != NoError) {
       
   106                 delete deviceDialog;
       
   107                 deviceDialog = 0;
       
   108             }
       
   109             ret = deviceDialog;
       
   110         } else {
       
   111             d->mError = ParameterError;
       
   112             ret = 0;
       
   113         }
       
   114     } else {
       
   115         d->mError = UnknownDeviceDialogError;
       
   116         ret = 0;
       
   117     }
       
   118 
       
   119     TRACE_EXIT
       
   120     return ret;
       
   121 }
       
   122 
       
   123 // Return information of device dialog the plugin creates
       
   124 bool HbDeviceProgressDialogPlugin::deviceDialogInfo(const QString &deviceDialogType,
       
   125     const QVariantMap &parameters, DeviceDialogInfo *info) const
       
   126 {
       
   127     TRACE_ENTRY
       
   128     Q_UNUSED(parameters)
       
   129     Q_UNUSED(deviceDialogType)
       
   130 
       
   131     info->group = GenericDeviceDialogGroup;
       
   132     info->flags = NoDeviceDialogFlags;
       
   133     info->priority = DefaultPriority;
       
   134     TRACE_EXIT
       
   135     return true;
       
   136 }
       
   137 
       
   138 // Return device dialog types this plugin implements
       
   139 QStringList HbDeviceProgressDialogPlugin::deviceDialogTypes() const
       
   140 {
       
   141     TRACE_ENTRY
       
   142     QStringList types;
       
   143     const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]);
       
   144     for(int i = 0; i < numTypes; i++) {
       
   145         types.append(dialogInfos[i].mTypeString);
       
   146     }
       
   147     TRACE_EXIT
       
   148     return types;
       
   149 }
       
   150 
       
   151 // Return plugin flags
       
   152 HbDeviceDialogPlugin::PluginFlags HbDeviceProgressDialogPlugin::pluginFlags() const
       
   153 {
       
   154     TRACE_ENTRY
       
   155     TRACE_EXIT
       
   156     return NoPluginFlags;
       
   157 }
       
   158 
       
   159 // Return last error
       
   160 int HbDeviceProgressDialogPlugin::error() const
       
   161 {
       
   162     TRACE_ENTRY
       
   163     TRACE_EXIT
       
   164     return d->mError;
       
   165 }