devicemgmtdialogsplugin/src/devicemanagementnotifierplugin.cpp
branchRCL_3
changeset 57 6757f1e2efd2
equal deleted inserted replaced
55:c4687ff85147 57:6757f1e2efd2
       
     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 <devicedialogconsts.h>
       
    22 #include "devicemanagementnotifierplugin_p.h"
       
    23 #include "devicemanagementnotifierwidget_p.h"
       
    24 #include "omacppinquerydialog.h"
       
    25 #include "fotadevicedialogs.h"
       
    26 
       
    27 
       
    28 Q_EXPORT_PLUGIN2(devicemanagementnotifiersplugin, devicemanagementnotifierplugin)
       
    29 
       
    30 // This plugin implements one device dialog type
       
    31 static const struct
       
    32     {
       
    33     const char *mTypeString;
       
    34     } dialogInfos[] =
       
    35     {
       
    36         {
       
    37         devicedialogtype
       
    38         }
       
    39 
       
    40     };
       
    41 
       
    42 class devicemanagementnotifierpluginprivate
       
    43 {
       
    44 public:
       
    45     devicemanagementnotifierpluginprivate() {mError = 0;}
       
    46 
       
    47     int mError;
       
    48 };
       
    49 
       
    50 // Constructor
       
    51 devicemanagementnotifierplugin::devicemanagementnotifierplugin()
       
    52 {
       
    53     
       
    54     d = new devicemanagementnotifierpluginprivate;
       
    55     
       
    56 }
       
    57 
       
    58 // Destructor
       
    59 devicemanagementnotifierplugin::~devicemanagementnotifierplugin()
       
    60 {
       
    61     
       
    62     delete d;
       
    63     
       
    64 }
       
    65 
       
    66 // Check if client is allowed to use device dialog widget
       
    67 bool devicemanagementnotifierplugin::accessAllowed(const QString &deviceDialogType,
       
    68     const QVariantMap &parameters, const QVariantMap &securityInfo) const
       
    69 {
       
    70        
       
    71     // This plugin doesn't perform operations that may compromise security.
       
    72     // All clients are allowed to use.
       
    73     return true;
       
    74     
       
    75 }
       
    76 
       
    77 // Create device dialog widget
       
    78 HbDeviceDialogInterface *devicemanagementnotifierplugin::createDeviceDialog(
       
    79         const QString &deviceDialogType, const QVariantMap &parameters)
       
    80     {
       
    81     // Find the dialog key
       
    82     QVariantMap::const_iterator i = parameters.find(keydialog);
       
    83     if (i != parameters.end())
       
    84         {
       
    85         int dialogtype = i.value().toInt();
       
    86         //Compare the dialog with the constant declared
       
    87         if (dialogtype == EOmaCPPinDialog)
       
    88             {
       
    89             // Return specific object for showing appropriate dialog
       
    90             return new omacppinquerydialog(parameters);
       
    91             }
       
    92            
       
    93         if (dialogtype >= EFwDLNeedMoreMemory && dialogtype <= EFwUpdResumeUpdate)
       
    94             {
       
    95             // Return specific object for showing appropriate dialog
       
    96             return new fotadevicedialogs(parameters);
       
    97             }
       
    98 
       
    99         }
       
   100     return new devicemanagementnotifierwidget(parameters);
       
   101         
       
   102 }
       
   103 
       
   104 // Return information of device dialog the plugin creates
       
   105 bool devicemanagementnotifierplugin::deviceDialogInfo(const QString &deviceDialogType,
       
   106     const QVariantMap &parameters, DeviceDialogInfo *info) const
       
   107 {
       
   108     info->group = GenericDeviceDialogGroup;
       
   109     info->flags = NoDeviceDialogFlags;
       
   110     info->priority = DefaultPriority;
       
   111     return true;
       
   112 }
       
   113 
       
   114 // Return device dialog types this plugin implements
       
   115 QStringList devicemanagementnotifierplugin::deviceDialogTypes() const
       
   116 {
       
   117     
       
   118     QStringList types;
       
   119     const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]);
       
   120     for(int i = 0; i < numTypes; i++) {
       
   121         types.append(dialogInfos[i].mTypeString);
       
   122     }
       
   123     
       
   124     return types;
       
   125 }
       
   126 
       
   127 // Return plugin flags
       
   128 HbDeviceDialogPlugin::PluginFlags devicemanagementnotifierplugin::pluginFlags() const
       
   129 {
       
   130     
       
   131     return NoPluginFlags;
       
   132 }
       
   133 
       
   134 // Return last error
       
   135 int devicemanagementnotifierplugin::error() const
       
   136 {
       
   137     return d->mError;
       
   138 }