perfapps/perfmon/ui/hb/datapopup/src/perfmondatapopupplugin.cpp
author hgs
Fri, 17 Sep 2010 14:22:55 +0300
changeset 52 36d60d12b4af
parent 51 b048e15729d6
permissions -rw-r--r--
201037
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description: 
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include <QtPlugin>
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include <hbdevicedialog.h>
hgs
parents:
diff changeset
    21
#include "perfmondatapopupplugin_p.h"
hgs
parents:
diff changeset
    22
#include "perfmondatapopupdialog_p.h"
hgs
parents:
diff changeset
    23
#include "perfmondatapopuppluginerrors_p.h"
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
Q_EXPORT_PLUGIN2(perfmondatapopupplugin, PerfMonDataPopupPlugin)
hgs
parents:
diff changeset
    26
hgs
parents:
diff changeset
    27
// This plugin implements one device dialog type
hgs
parents:
diff changeset
    28
static const struct {
hgs
parents:
diff changeset
    29
    const char *mTypeString;
hgs
parents:
diff changeset
    30
} dialogInfos[] = {
hgs
parents:
diff changeset
    31
    {"com.nokia.rnd.perfmondatapopup/1.0"}
hgs
parents:
diff changeset
    32
};
hgs
parents:
diff changeset
    33
hgs
parents:
diff changeset
    34
class PerfMonDataPopupPluginPrivate
hgs
parents:
diff changeset
    35
{
hgs
parents:
diff changeset
    36
public:
hgs
parents:
diff changeset
    37
    PerfMonDataPopupPluginPrivate() {mError = NoError;}
hgs
parents:
diff changeset
    38
hgs
parents:
diff changeset
    39
    int mError;
hgs
parents:
diff changeset
    40
};
hgs
parents:
diff changeset
    41
hgs
parents:
diff changeset
    42
// Constructor
hgs
parents:
diff changeset
    43
PerfMonDataPopupPlugin::PerfMonDataPopupPlugin()
hgs
parents:
diff changeset
    44
    : d(new PerfMonDataPopupPluginPrivate)
hgs
parents:
diff changeset
    45
{
hgs
parents:
diff changeset
    46
}
hgs
parents:
diff changeset
    47
hgs
parents:
diff changeset
    48
// Destructor
hgs
parents:
diff changeset
    49
PerfMonDataPopupPlugin::~PerfMonDataPopupPlugin()
hgs
parents:
diff changeset
    50
{
hgs
parents:
diff changeset
    51
    delete d;
hgs
parents:
diff changeset
    52
}
hgs
parents:
diff changeset
    53
hgs
parents:
diff changeset
    54
// Check if client is allowed to use device dialog widget
hgs
parents:
diff changeset
    55
bool PerfMonDataPopupPlugin::accessAllowed(const QString &deviceDialogType,
hgs
parents:
diff changeset
    56
    const QVariantMap &parameters, const QVariantMap &securityInfo) const
hgs
parents:
diff changeset
    57
{
hgs
parents:
diff changeset
    58
    Q_UNUSED(deviceDialogType)
hgs
parents:
diff changeset
    59
    Q_UNUSED(parameters)
hgs
parents:
diff changeset
    60
    Q_UNUSED(securityInfo)
hgs
parents:
diff changeset
    61
hgs
parents:
diff changeset
    62
    // This plugin doesn't perform operations that may compromise security. All clients
hgs
parents:
diff changeset
    63
    // are allowed to use.
hgs
parents:
diff changeset
    64
    return true;
hgs
parents:
diff changeset
    65
}
hgs
parents:
diff changeset
    66
hgs
parents:
diff changeset
    67
// Create device dialog widget
hgs
parents:
diff changeset
    68
HbDeviceDialogInterface *PerfMonDataPopupPlugin::createDeviceDialog(
hgs
parents:
diff changeset
    69
    const QString &deviceDialogType, const QVariantMap &parameters)
hgs
parents:
diff changeset
    70
{
hgs
parents:
diff changeset
    71
    Q_UNUSED(deviceDialogType)
hgs
parents:
diff changeset
    72
    d->mError = NoError;
hgs
parents:
diff changeset
    73
hgs
parents:
diff changeset
    74
    HbDeviceDialogInterface *ret(0);
hgs
parents:
diff changeset
    75
    QVariantMap params = parameters;
hgs
parents:
diff changeset
    76
hgs
parents:
diff changeset
    77
    PerfMonDataPopupDialog *deviceDialog =
hgs
parents:
diff changeset
    78
        new PerfMonDataPopupDialog(params);
hgs
parents:
diff changeset
    79
    d->mError = deviceDialog->deviceDialogError();
hgs
parents:
diff changeset
    80
    if (d->mError != NoError) {
hgs
parents:
diff changeset
    81
        delete deviceDialog;
hgs
parents:
diff changeset
    82
        deviceDialog = 0;
hgs
parents:
diff changeset
    83
    }
hgs
parents:
diff changeset
    84
    ret = deviceDialog;
hgs
parents:
diff changeset
    85
hgs
parents:
diff changeset
    86
    return ret;
hgs
parents:
diff changeset
    87
}
hgs
parents:
diff changeset
    88
hgs
parents:
diff changeset
    89
// Return device dialog flags
hgs
parents:
diff changeset
    90
bool PerfMonDataPopupPlugin::deviceDialogInfo(const QString &deviceDialogType,
hgs
parents:
diff changeset
    91
        const QVariantMap &parameters, DeviceDialogInfo *info) const
hgs
parents:
diff changeset
    92
{
hgs
parents:
diff changeset
    93
    Q_UNUSED(deviceDialogType);
hgs
parents:
diff changeset
    94
    Q_UNUSED(parameters);
hgs
parents:
diff changeset
    95
hgs
parents:
diff changeset
    96
    info->group = DeviceNotificationDialogGroup;
hgs
parents:
diff changeset
    97
    //info->group = GenericDeviceDialogGroup;
52
hgs
parents: 51
diff changeset
    98
    //info->group = IndicatorGroup;
51
hgs
parents:
diff changeset
    99
    info->flags = NoDeviceDialogFlags;
hgs
parents:
diff changeset
   100
    info->priority = DefaultPriority;
hgs
parents:
diff changeset
   101
hgs
parents:
diff changeset
   102
    return true;
hgs
parents:
diff changeset
   103
}
hgs
parents:
diff changeset
   104
hgs
parents:
diff changeset
   105
// Return device dialog types this plugin implements
hgs
parents:
diff changeset
   106
QStringList PerfMonDataPopupPlugin::deviceDialogTypes() const
hgs
parents:
diff changeset
   107
{
hgs
parents:
diff changeset
   108
    QStringList types;
hgs
parents:
diff changeset
   109
    const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]);
hgs
parents:
diff changeset
   110
    for(int i = 0; i < numTypes; i++) {
hgs
parents:
diff changeset
   111
        types.append(dialogInfos[i].mTypeString);
hgs
parents:
diff changeset
   112
    }
hgs
parents:
diff changeset
   113
    return types;
hgs
parents:
diff changeset
   114
}
hgs
parents:
diff changeset
   115
hgs
parents:
diff changeset
   116
// Return plugin flags
hgs
parents:
diff changeset
   117
HbDeviceDialogPlugin::PluginFlags PerfMonDataPopupPlugin::pluginFlags() const
hgs
parents:
diff changeset
   118
{
hgs
parents:
diff changeset
   119
    return NoPluginFlags;
hgs
parents:
diff changeset
   120
}
hgs
parents:
diff changeset
   121
hgs
parents:
diff changeset
   122
// Return last error
hgs
parents:
diff changeset
   123
int PerfMonDataPopupPlugin::error() const
hgs
parents:
diff changeset
   124
{
hgs
parents:
diff changeset
   125
    return d->mError;
hgs
parents:
diff changeset
   126
}