perfmon/ui/hb/datapopup/src/perfmondatapopupplugin.cpp
branchRCL_3
changeset 22 fad26422216a
parent 21 b3cee849fa46
child 23 f8280f3bfeb7
equal deleted inserted replaced
21:b3cee849fa46 22:fad26422216a
     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 "perfmondatapopupplugin_p.h"
       
    22 #include "perfmondatapopupdialog_p.h"
       
    23 #include "perfmondatapopuppluginerrors_p.h"
       
    24 
       
    25 Q_EXPORT_PLUGIN2(perfmondatapopupplugin, PerfMonDataPopupPlugin)
       
    26 
       
    27 // This plugin implements one device dialog type
       
    28 static const struct {
       
    29     const char *mTypeString;
       
    30 } dialogInfos[] = {
       
    31     {"com.nokia.rnd.perfmondatapopup/1.0"}
       
    32 };
       
    33 
       
    34 class PerfMonDataPopupPluginPrivate
       
    35 {
       
    36 public:
       
    37     PerfMonDataPopupPluginPrivate() {mError = NoError;}
       
    38 
       
    39     int mError;
       
    40 };
       
    41 
       
    42 // Constructor
       
    43 PerfMonDataPopupPlugin::PerfMonDataPopupPlugin()
       
    44     : d(new PerfMonDataPopupPluginPrivate)
       
    45 {
       
    46 }
       
    47 
       
    48 // Destructor
       
    49 PerfMonDataPopupPlugin::~PerfMonDataPopupPlugin()
       
    50 {
       
    51     delete d;
       
    52 }
       
    53 
       
    54 // Check if client is allowed to use device dialog widget
       
    55 bool PerfMonDataPopupPlugin::accessAllowed(const QString &deviceDialogType,
       
    56     const QVariantMap &parameters, const QVariantMap &securityInfo) const
       
    57 {
       
    58     Q_UNUSED(deviceDialogType)
       
    59     Q_UNUSED(parameters)
       
    60     Q_UNUSED(securityInfo)
       
    61 
       
    62     // This plugin doesn't perform operations that may compromise security. All clients
       
    63     // are allowed to use.
       
    64     return true;
       
    65 }
       
    66 
       
    67 // Create device dialog widget
       
    68 HbDeviceDialogInterface *PerfMonDataPopupPlugin::createDeviceDialog(
       
    69     const QString &deviceDialogType, const QVariantMap &parameters)
       
    70 {
       
    71     Q_UNUSED(deviceDialogType)
       
    72     d->mError = NoError;
       
    73 
       
    74     HbDeviceDialogInterface *ret(0);
       
    75     QVariantMap params = parameters;
       
    76 
       
    77     PerfMonDataPopupDialog *deviceDialog =
       
    78         new PerfMonDataPopupDialog(params);
       
    79     d->mError = deviceDialog->deviceDialogError();
       
    80     if (d->mError != NoError) {
       
    81         delete deviceDialog;
       
    82         deviceDialog = 0;
       
    83     }
       
    84     ret = deviceDialog;
       
    85 
       
    86     return ret;
       
    87 }
       
    88 
       
    89 // Return device dialog flags
       
    90 bool PerfMonDataPopupPlugin::deviceDialogInfo(const QString &deviceDialogType,
       
    91         const QVariantMap &parameters, DeviceDialogInfo *info) const
       
    92 {
       
    93     Q_UNUSED(deviceDialogType);
       
    94     Q_UNUSED(parameters);
       
    95 
       
    96     info->group = DeviceNotificationDialogGroup;
       
    97     info->flags = NoDeviceDialogFlags;
       
    98     info->priority = DefaultPriority;
       
    99 
       
   100     return true;
       
   101 }
       
   102 
       
   103 // Return device dialog types this plugin implements
       
   104 QStringList PerfMonDataPopupPlugin::deviceDialogTypes() const
       
   105 {
       
   106     QStringList types;
       
   107     const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]);
       
   108     for(int i = 0; i < numTypes; i++) {
       
   109         types.append(dialogInfos[i].mTypeString);
       
   110     }
       
   111     return types;
       
   112 }
       
   113 
       
   114 // Return plugin flags
       
   115 HbDeviceDialogPlugin::PluginFlags PerfMonDataPopupPlugin::pluginFlags() const
       
   116 {
       
   117     return NoPluginFlags;
       
   118 }
       
   119 
       
   120 // Return last error
       
   121 int PerfMonDataPopupPlugin::error() const
       
   122 {
       
   123     return d->mError;
       
   124 }