deviceupdatesui/devicemanagementnotifiersplugin/devicemanagementnotifierplugin.cpp
changeset 44 137912d1a556
parent 43 88e14c3d4c4f
child 45 0f9fc722d255
equal deleted inserted replaced
43:88e14c3d4c4f 44:137912d1a556
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QtPlugin>
       
    19 
       
    20 #include <hbdevicedialog.h>
       
    21 #include "devicemanagementnotifierplugin_p.h"
       
    22 #include "devicemanagementnotifierwidget_p.h"
       
    23 
       
    24 
       
    25 Q_EXPORT_PLUGIN2(devicemanagementnotifiersplugin, devicemanagementnotifierplugin)
       
    26 
       
    27 // This plugin implements one device dialog type
       
    28 static const struct {
       
    29     const char *mTypeString;
       
    30 } dialogInfos[] = {
       
    31     {"com.nokia.hb.devicemanagementdialog/1.0"}
       
    32 };
       
    33 
       
    34 class devicemanagementnotifierpluginprivate
       
    35 {
       
    36 public:
       
    37     devicemanagementnotifierpluginprivate() {mError = 0;}
       
    38 
       
    39     int mError;
       
    40 };
       
    41 
       
    42 // Constructor
       
    43 devicemanagementnotifierplugin::devicemanagementnotifierplugin()
       
    44 {
       
    45     
       
    46     d = new devicemanagementnotifierpluginprivate;
       
    47     
       
    48 }
       
    49 
       
    50 // Destructor
       
    51 devicemanagementnotifierplugin::~devicemanagementnotifierplugin()
       
    52 {
       
    53     
       
    54     delete d;
       
    55     
       
    56 }
       
    57 
       
    58 // Check if client is allowed to use device dialog widget
       
    59 bool devicemanagementnotifierplugin::accessAllowed(const QString &deviceDialogType,
       
    60     const QVariantMap &parameters, const QVariantMap &securityInfo) const
       
    61 {
       
    62     
       
    63     
       
    64     // This plugin doesn't perform operations that may compromise security.
       
    65     // All clients are allowed to use.
       
    66     return true;
       
    67     
       
    68 }
       
    69 
       
    70 // Create device dialog widget
       
    71 HbDeviceDialogInterface *devicemanagementnotifierplugin::createDeviceDialog(
       
    72     const QString &deviceDialogType, const QVariantMap &parameters)
       
    73 {
       
    74     return new devicemanagementnotifierwidget(parameters);
       
    75 }
       
    76 
       
    77 // Return information of device dialog the plugin creates
       
    78 bool devicemanagementnotifierplugin::deviceDialogInfo(const QString &deviceDialogType,
       
    79     const QVariantMap &parameters, DeviceDialogInfo *info) const
       
    80 {
       
    81     
       
    82    info->group = GenericDeviceDialogGroup;
       
    83 
       
    84 info->flags = NoDeviceDialogFlags;
       
    85 
       
    86 info->priority = DefaultPriority;
       
    87     return true;
       
    88 }
       
    89 
       
    90 // Return device dialog types this plugin implements
       
    91 QStringList devicemanagementnotifierplugin::deviceDialogTypes() const
       
    92 {
       
    93     
       
    94     QStringList types;
       
    95     const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]);
       
    96     for(int i = 0; i < numTypes; i++) {
       
    97         types.append(dialogInfos[i].mTypeString);
       
    98     }
       
    99     
       
   100     return types;
       
   101 }
       
   102 
       
   103 // Return plugin flags
       
   104 HbDeviceDialogPlugin::PluginFlags devicemanagementnotifierplugin::pluginFlags() const
       
   105 {
       
   106     
       
   107     return NoPluginFlags;
       
   108 }
       
   109 
       
   110 // Return last error
       
   111 int devicemanagementnotifierplugin::error() const
       
   112 {
       
   113     return d->mError;
       
   114 }