screensaver/devicedialogplugins/snsrdevicedialogplugin/src/snsrdevicedialogplugin.cpp
author hgs
Fri, 25 Jun 2010 19:19:22 +0300
changeset 62 341166945d65
child 69 87476091b3f5
permissions -rw-r--r--
201025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
62
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 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: Default Screensaver runtime.
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
#include <QDebug>
hgs
parents:
diff changeset
    20
#include <qservicemanager.h>
hgs
parents:
diff changeset
    21
#include <hbdevicedialog.h>
hgs
parents:
diff changeset
    22
hgs
parents:
diff changeset
    23
#include "snsrdevicedialogplugin.h"
hgs
parents:
diff changeset
    24
#include "snsrdevicedialog.h"
hgs
parents:
diff changeset
    25
hgs
parents:
diff changeset
    26
#ifdef COVERAGE_MEASUREMENT
hgs
parents:
diff changeset
    27
#pragma CTC SKIP
hgs
parents:
diff changeset
    28
#endif //COVERAGE_MEASUREMENT
hgs
parents:
diff changeset
    29
hgs
parents:
diff changeset
    30
/*!
hgs
parents:
diff changeset
    31
    \class SnsrDeviceDialogPlugin
hgs
parents:
diff changeset
    32
    \ingroup group_snsrdevicedialogplugin
hgs
parents:
diff changeset
    33
    \brief Screensaver Device Dialog Plug-in.
hgs
parents:
diff changeset
    34
 */
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
Q_EXPORT_PLUGIN2(snsrdevicedialogplugin, SnsrDeviceDialogPlugin)
hgs
parents:
diff changeset
    37
hgs
parents:
diff changeset
    38
// This plugin implements one device dialog type
hgs
parents:
diff changeset
    39
static const struct
hgs
parents:
diff changeset
    40
{
hgs
parents:
diff changeset
    41
    const char *mTypeString;
hgs
parents:
diff changeset
    42
} dialogInfos[] = { { "com.nokia.screensaver.snsrdevicedialogplugin/1.0" } };
hgs
parents:
diff changeset
    43
hgs
parents:
diff changeset
    44
const char *lBigClockSnsrPluginUri = 
hgs
parents:
diff changeset
    45
#ifdef Q_OS_SYMBIAN
hgs
parents:
diff changeset
    46
    "z:/snsrresources/plugins/screensaverplugins/snsrbigclockscreensaverplugin.xml";
hgs
parents:
diff changeset
    47
#else
hgs
parents:
diff changeset
    48
    "snsrresources/plugins/screensaverplugins/snsrbigclockscreensaverplugin.xml";
hgs
parents:
diff changeset
    49
#endif
hgs
parents:
diff changeset
    50
hgs
parents:
diff changeset
    51
const char *lViewType("view_type");
hgs
parents:
diff changeset
    52
hgs
parents:
diff changeset
    53
QTM_USE_NAMESPACE
hgs
parents:
diff changeset
    54
hgs
parents:
diff changeset
    55
/*!
hgs
parents:
diff changeset
    56
    Constructor.
hgs
parents:
diff changeset
    57
 */
hgs
parents:
diff changeset
    58
SnsrDeviceDialogPlugin::SnsrDeviceDialogPlugin() :
hgs
parents:
diff changeset
    59
    mError(0)
hgs
parents:
diff changeset
    60
{
hgs
parents:
diff changeset
    61
    qDebug("SnsrDeviceDialogPlugin::SnsrDeviceDialogPlugin()");
hgs
parents:
diff changeset
    62
hgs
parents:
diff changeset
    63
    QServiceManager manager;
hgs
parents:
diff changeset
    64
    manager.addService(lBigClockSnsrPluginUri);
hgs
parents:
diff changeset
    65
}
hgs
parents:
diff changeset
    66
hgs
parents:
diff changeset
    67
/*!
hgs
parents:
diff changeset
    68
    Destructor.
hgs
parents:
diff changeset
    69
 */
hgs
parents:
diff changeset
    70
SnsrDeviceDialogPlugin::~SnsrDeviceDialogPlugin()
hgs
parents:
diff changeset
    71
{
hgs
parents:
diff changeset
    72
    qDebug("SnsrDeviceDialogPlugin::~SnsrDeviceDialogPlugin()");
hgs
parents:
diff changeset
    73
}
hgs
parents:
diff changeset
    74
hgs
parents:
diff changeset
    75
/*!
hgs
parents:
diff changeset
    76
    \reimp
hgs
parents:
diff changeset
    77
 */
hgs
parents:
diff changeset
    78
bool SnsrDeviceDialogPlugin::accessAllowed(const QString &deviceDialogType,
hgs
parents:
diff changeset
    79
    const QVariantMap &parameters, const QVariantMap &securityInfo) const
hgs
parents:
diff changeset
    80
{
hgs
parents:
diff changeset
    81
    Q_UNUSED(deviceDialogType)
hgs
parents:
diff changeset
    82
    Q_UNUSED(parameters)
hgs
parents:
diff changeset
    83
    Q_UNUSED(securityInfo)
hgs
parents:
diff changeset
    84
hgs
parents:
diff changeset
    85
    // This plugin doesn't perform operations that may compromise security.
hgs
parents:
diff changeset
    86
    // All clients are allowed to use.
hgs
parents:
diff changeset
    87
    return true;
hgs
parents:
diff changeset
    88
}
hgs
parents:
diff changeset
    89
hgs
parents:
diff changeset
    90
/*!
hgs
parents:
diff changeset
    91
    \reimp
hgs
parents:
diff changeset
    92
 */
hgs
parents:
diff changeset
    93
HbDeviceDialogInterface *SnsrDeviceDialogPlugin::createDeviceDialog(
hgs
parents:
diff changeset
    94
    const QString &deviceDialogType, const QVariantMap &parameters)
hgs
parents:
diff changeset
    95
{
hgs
parents:
diff changeset
    96
    qDebug("SnsrDeviceDialogPlugin::createDeviceDialog()");
hgs
parents:
diff changeset
    97
    mError = 0;
hgs
parents:
diff changeset
    98
hgs
parents:
diff changeset
    99
    HbDeviceDialogInterface *ret(0);
hgs
parents:
diff changeset
   100
    const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]);
hgs
parents:
diff changeset
   101
    for (int i = 0; i < numTypes && !ret; i++) {
hgs
parents:
diff changeset
   102
        if (dialogInfos[i].mTypeString == deviceDialogType) {
hgs
parents:
diff changeset
   103
            //create the dialog
hgs
parents:
diff changeset
   104
            ret = new SnsrDeviceDialog(parameters);
hgs
parents:
diff changeset
   105
        }
hgs
parents:
diff changeset
   106
    }
hgs
parents:
diff changeset
   107
hgs
parents:
diff changeset
   108
    if (!ret) {
hgs
parents:
diff changeset
   109
        mError = -1;
hgs
parents:
diff changeset
   110
    }
hgs
parents:
diff changeset
   111
    return ret;
hgs
parents:
diff changeset
   112
}
hgs
parents:
diff changeset
   113
hgs
parents:
diff changeset
   114
/*!
hgs
parents:
diff changeset
   115
    \reimp
hgs
parents:
diff changeset
   116
 */
hgs
parents:
diff changeset
   117
bool SnsrDeviceDialogPlugin::deviceDialogInfo(
hgs
parents:
diff changeset
   118
    const QString &deviceDialogType, const QVariantMap &parameters,
hgs
parents:
diff changeset
   119
    DeviceDialogInfo *info) const
hgs
parents:
diff changeset
   120
{
hgs
parents:
diff changeset
   121
    Q_UNUSED(parameters)
hgs
parents:
diff changeset
   122
    Q_UNUSED(deviceDialogType)
hgs
parents:
diff changeset
   123
hgs
parents:
diff changeset
   124
    info->group = SecurityGroup;
hgs
parents:
diff changeset
   125
    info->flags = NoDeviceDialogFlags;
hgs
parents:
diff changeset
   126
    info->priority = DefaultPriority;
hgs
parents:
diff changeset
   127
hgs
parents:
diff changeset
   128
    return true;
hgs
parents:
diff changeset
   129
}
hgs
parents:
diff changeset
   130
hgs
parents:
diff changeset
   131
/*!
hgs
parents:
diff changeset
   132
    \reimp
hgs
parents:
diff changeset
   133
 */
hgs
parents:
diff changeset
   134
QStringList SnsrDeviceDialogPlugin::deviceDialogTypes() const
hgs
parents:
diff changeset
   135
{
hgs
parents:
diff changeset
   136
    QStringList types;
hgs
parents:
diff changeset
   137
    const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]);
hgs
parents:
diff changeset
   138
    for (int i = 0; i < numTypes; i++) {
hgs
parents:
diff changeset
   139
        types.append(dialogInfos[i].mTypeString);
hgs
parents:
diff changeset
   140
    }
hgs
parents:
diff changeset
   141
hgs
parents:
diff changeset
   142
    return types;
hgs
parents:
diff changeset
   143
}
hgs
parents:
diff changeset
   144
hgs
parents:
diff changeset
   145
/*!
hgs
parents:
diff changeset
   146
    \reimp
hgs
parents:
diff changeset
   147
 */
hgs
parents:
diff changeset
   148
HbDeviceDialogPlugin::PluginFlags SnsrDeviceDialogPlugin::pluginFlags() const
hgs
parents:
diff changeset
   149
{
hgs
parents:
diff changeset
   150
    return NoPluginFlags;
hgs
parents:
diff changeset
   151
}
hgs
parents:
diff changeset
   152
hgs
parents:
diff changeset
   153
/*!
hgs
parents:
diff changeset
   154
    \reimp
hgs
parents:
diff changeset
   155
 */
hgs
parents:
diff changeset
   156
int SnsrDeviceDialogPlugin::error() const
hgs
parents:
diff changeset
   157
{
hgs
parents:
diff changeset
   158
    return mError;
hgs
parents:
diff changeset
   159
}
hgs
parents:
diff changeset
   160
hgs
parents:
diff changeset
   161
#ifdef COVERAGE_MEASUREMENT
hgs
parents:
diff changeset
   162
#pragma CTC ENDSKIP
hgs
parents:
diff changeset
   163
#endif //COVERAGE_MEASUREMENT