src/hbplugins/devicedialogs/devicenotificationdialogplugin/hbdevicenotificationdialogplugin.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 "hbdevicenotificationdialogplugin_p.h"
       
    31 #include "hbdevicenotificationdialogwidget_p.h"
       
    32 #include "hbdevicenotificationdialogpluginerrors_p.h"
       
    33 
       
    34 Q_EXPORT_PLUGIN2(devicenotificationdialogplugin, HbDeviceNotificationDialogPlugin)
       
    35 
       
    36 // This plugin implements one device dialog type
       
    37 static const struct {
       
    38     const char *mTypeString;
       
    39 } dialogInfos[] = {
       
    40     {"com.nokia.hb.devicenotificationdialog/1.0"}
       
    41 };
       
    42 
       
    43 class HbDeviceNotificationDialogPluginPrivate
       
    44 {
       
    45 public:
       
    46     HbDeviceNotificationDialogPluginPrivate() {mError = NoError;}
       
    47 
       
    48     int mError;
       
    49 };
       
    50 
       
    51 // Constructor
       
    52 HbDeviceNotificationDialogPlugin::HbDeviceNotificationDialogPlugin()
       
    53 {
       
    54     TRACE_ENTRY
       
    55     d = new HbDeviceNotificationDialogPluginPrivate;
       
    56     TRACE_EXIT
       
    57 }
       
    58 
       
    59 // Destructor
       
    60 HbDeviceNotificationDialogPlugin::~HbDeviceNotificationDialogPlugin()
       
    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 HbDeviceNotificationDialogPlugin::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 *HbDeviceNotificationDialogPlugin::createDeviceDialog(
       
    84     const QString &deviceDialogType, const QVariantMap &parameters)
       
    85 {
       
    86     TRACE_ENTRY
       
    87     Q_UNUSED(deviceDialogType)
       
    88     d->mError = NoError;
       
    89 
       
    90     HbDeviceDialogInterface *ret(0);
       
    91     QVariantMap params = parameters;
       
    92 
       
    93     HbDeviceNotificationDialogWidget *deviceDialog =
       
    94         new HbDeviceNotificationDialogWidget(params);
       
    95     d->mError = deviceDialog->deviceDialogError();
       
    96     if (d->mError != NoError) {
       
    97         delete deviceDialog;
       
    98         deviceDialog = 0;
       
    99     }
       
   100     ret = deviceDialog;
       
   101 
       
   102     TRACE_EXIT
       
   103     return ret;
       
   104 }
       
   105 
       
   106 // Return device dialog flags
       
   107 bool HbDeviceNotificationDialogPlugin::deviceDialogInfo(const QString &deviceDialogType,
       
   108         const QVariantMap &parameters, DeviceDialogInfo *info) const
       
   109 {
       
   110     TRACE_ENTRY
       
   111     Q_UNUSED(deviceDialogType);
       
   112     Q_UNUSED(parameters);
       
   113 
       
   114     info->group = DeviceNotificationDialogGroup;
       
   115     info->flags = NoDeviceDialogFlags;
       
   116     info->priority = DefaultPriority;
       
   117 
       
   118     TRACE_EXIT
       
   119     return true;
       
   120 }
       
   121 
       
   122 // Return device dialog types this plugin implements
       
   123 QStringList HbDeviceNotificationDialogPlugin::deviceDialogTypes() const
       
   124 {
       
   125     TRACE_ENTRY
       
   126     QStringList types;
       
   127     const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]);
       
   128     for(int i = 0; i < numTypes; i++) {
       
   129         types.append(dialogInfos[i].mTypeString);
       
   130     }
       
   131     TRACE_EXIT
       
   132     return types;
       
   133 }
       
   134 
       
   135 // Return plugin flags
       
   136 HbDeviceDialogPlugin::PluginFlags HbDeviceNotificationDialogPlugin::pluginFlags() const
       
   137 {
       
   138     TRACE_ENTRY
       
   139     TRACE_EXIT
       
   140     return NoPluginFlags;
       
   141 }
       
   142 
       
   143 // Return last error
       
   144 int HbDeviceNotificationDialogPlugin::error() const
       
   145 {
       
   146     TRACE_ENTRY
       
   147     TRACE_EXIT
       
   148     return d->mError;
       
   149 }