Add missing files to securitydialogs/Autolock/indicatorplugin directory (Bug 3653)
authorFrancisco Cotrina <francisco.cotrina@nokia.com>
Fri, 03 Sep 2010 13:36:43 +0100
changeset 52 a08e464d25ca
parent 51 f479c7dc25d6
Add missing files to securitydialogs/Autolock/indicatorplugin directory (Bug 3653)
securitydialogs/Autolock/indicatorplugin/autolockindicators.h
securitydialogs/Autolock/indicatorplugin/hbindicatorautolockplugin.cpp
securitydialogs/Autolock/indicatorplugin/hbindicatorautolockplugin.h
securitydialogs/Autolock/indicatorplugin/indicatorautolockplugin.pro
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/securitydialogs/Autolock/indicatorplugin/autolockindicators.h	Fri Sep 03 13:36:43 2010 +0100
@@ -0,0 +1,67 @@
+/*
+* ============================================================================
+*  Name        : autolockindicators.h
+*  Part of     : hb /
+*  Description :
+*  Version     : %version: 1 %
+*
+*  Copyright (c) 2009 Nokia.  All rights reserved.
+*  This material, including documentation and any related computer
+*  programs, is protected by copyright controlled by Nokia.  All
+*  rights are reserved.  Copying, including reproducing, storing,
+*  adapting or translating, any or all of this material requires the
+*  prior written consent of Nokia.  This material also contains
+*  confidential information which may not be disclosed to others
+*  without the prior written consent of Nokia.
+* ============================================================================
+*/
+
+#ifndef AUTOLOCKINDICATORS_H
+#define AUTOLOCKINDICATORS_H
+
+#include <hbindicatorinterface.h>
+#include <QMetaType>
+#include <QString>
+
+static const char *IndicatorNameTemplate = "com.nokia.hb.indicator.autolock.autolock_%1/1.0";
+
+enum Interaction
+{
+    InteractionNone,
+    ChangeContent,
+    Deactivate,
+    ChangeOrientation
+};
+
+inline QString indicatorName(int indicatorType) {
+    return QString(IndicatorNameTemplate).arg(indicatorType);
+}
+
+struct IndicatorInfo
+{
+    const char *icon;
+    const char *iconMono;
+    const char *primaryText;
+    const char *secondaryText;
+    HbIndicatorInterface::Category category;
+    Interaction interaction;
+};
+
+Q_DECLARE_METATYPE(IndicatorInfo)
+
+static const int IndicatorCount = 10;
+static const IndicatorInfo IndicatorInfos[IndicatorCount] = {
+    {"navi_left.svg", "qtg_mono_settings.svg", "Notification indicator 1", "no interaction", HbIndicatorInterface::NotificationCategory, InteractionNone},
+    {"qt_prog_bar_play.svg","qtg_status_new_email.svg", "Notification indicator 2", "deactivates, when clicked (additional to test the text truncation.)", HbIndicatorInterface::NotificationCategory, Deactivate},
+    {"hb_vol_slider_increment_pressed.svg", "qtg_status_new_email.svg", "Notification indicator 3", "changes content", HbIndicatorInterface::NotificationCategory, ChangeContent},
+    {"hb_vol_slider_muted.svg", "qtg_status_new_email.svg", "Notification indicator 4", "changes content, when clicked", HbIndicatorInterface::NotificationCategory, ChangeContent},
+    {"qgn_menu_pinb.svg", "qgn_menu_pinb.svg", "Progress indicator 1", "no interaction", HbIndicatorInterface::ProgressCategory, InteractionNone},
+    {"qgn_menu_note.svg", "qgn_menu_note.svg", "Progress indicator 2", "changes content, when clicked", HbIndicatorInterface::ProgressCategory, ChangeContent},
+    {"note_error.svg", "note_error.svg", "Progress indicator 3", "changes orientation, when clicked", HbIndicatorInterface::ProgressCategory, ChangeOrientation},
+    {"note_info.svg", "note_info.svg", "Progress indicator 4", "changes content, when clicked", HbIndicatorInterface::ProgressCategory, ChangeContent},
+    {"qtg_large_device_lock.svg", "qtg_large_device_lock.svg", "Keyguard Enabled", "Keyguard Enabled", HbIndicatorInterface::SettingCategory, InteractionNone},
+    {"qgn_menu_phob.svg", "qgn_menu_phob.svg", "Devicelock Enabled", "Devicelock Enabled", HbIndicatorInterface::SettingCategory, InteractionNone}
+};
+
+
+#endif // AUTOLOCKINDICATORS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/securitydialogs/Autolock/indicatorplugin/hbindicatorautolockplugin.cpp	Fri Sep 03 13:36:43 2010 +0100
@@ -0,0 +1,220 @@
+/*
+* ============================================================================
+*  Name        : hbindicatorautolockplugin.cpp
+*  Part of     : hb / hbcore
+*  Description : indicator autolock plugin implementation
+*  Version     : %version: 1 %
+*
+*  Copyright (c) 2009 Nokia.  All rights reserved.
+*  This material, including documentation and any related computer
+*  programs, is protected by copyright controlled by Nokia.  All
+*  rights are reserved.  Copying, including reproducing, storing,
+*  adapting or translating, any or all of this material requires the
+*  prior written consent of Nokia.  This material also contains
+*  confidential information which may not be disclosed to others
+*  without the prior written consent of Nokia.
+* ============================================================================
+*/
+
+#include <QtPlugin>
+#include <QVariant>
+#include <HbInstance>
+#include <HbMainWindow>
+#include <QDebug>
+
+#include "hbindicatorautolockplugin.h"
+
+Q_EXPORT_PLUGIN(HbIndicatorAutolockPlugin)
+
+// Constructor
+HbIndicatorAutolockPlugin::HbIndicatorAutolockPlugin() : mError(0)
+{
+    for (int i = 0; i < IndicatorCount; ++i) {
+        mIndicatorTypes.append(indicatorName(i));
+    }
+}
+
+// Destructor
+HbIndicatorAutolockPlugin::~HbIndicatorAutolockPlugin()
+{
+}
+
+// Return notification types this plugin implements
+QStringList HbIndicatorAutolockPlugin::indicatorTypes() const
+{
+    return mIndicatorTypes;
+}
+
+// Check if client is allowed to use notification widget
+bool HbIndicatorAutolockPlugin::accessAllowed(const QString &indicatorType,
+    const QVariantMap &securityInfo) const
+{
+    Q_UNUSED(indicatorType)
+    Q_UNUSED(securityInfo)
+
+    // This plugin doesn't perform operations that may compromise security.
+    // All clients are allowed to use.
+    return true;
+}
+
+HbIndicatorInterface* HbIndicatorAutolockPlugin::createIndicator(
+        const QString &indicatorType)
+{
+    HbIndicatorInterface *indicator = 0;
+    int index(typeIndex(indicatorType));
+    if (index >= 0) {
+        indicator = new HbAutolockIndicator(
+                indicatorType, index, IndicatorInfos[index].interaction);
+    }
+    return indicator;
+}
+
+int HbIndicatorAutolockPlugin::error() const
+{
+    return mError;
+}
+
+int HbIndicatorAutolockPlugin::typeIndex(const QString &indicatorType) const
+{
+    for (int i = 0; i < mIndicatorTypes.count(); ++i) {
+        if (mIndicatorTypes.at(i) == indicatorType) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+HbAutolockIndicator::HbAutolockIndicator(const QString &indicatorType,
+                                 int typeIndex,
+                                 Interaction interaction) :
+    HbIndicatorInterface(indicatorType, IndicatorInfos[typeIndex].category,
+    (interaction == InteractionNone) ? NoInteraction : InteractionActivated),
+    mPrimaryText(IndicatorInfos[typeIndex].primaryText),
+    mSecondaryText(IndicatorInfos[typeIndex].secondaryText),
+    mIcon(IndicatorInfos[typeIndex].icon),
+    mIconMono(IndicatorInfos[typeIndex].iconMono),
+    mTypeIndex(typeIndex), mInteraction(interaction)
+{
+}
+
+HbAutolockIndicator::~HbAutolockIndicator()
+{
+}
+
+bool HbAutolockIndicator::handleInteraction(InteractionType type)
+{
+    if (type == InteractionActivated) {
+        switch(mInteraction) {
+        case ChangeContent:
+            mPrimaryText = "Clicked";
+            mSecondaryText = "content changed!";
+            mIcon = "qtg_mono_ok.svg";
+            break;
+        case Deactivate:
+            emit deactivate();
+            break;
+        case ChangeOrientation:
+        		qDebug() << "============= HbAutolockIndicator::handleInteraction doesn't react to ChangeOrientation";
+            /*
+            if (hbInstance->orientation() == Qt::Horizontal) {
+                hbInstance->setOrientation(Qt::Vertical);
+            } else {
+                hbInstance->setOrientation(Qt::Horizontal);
+            }
+            */
+            if (hbInstance->allMainWindows().at(0)->orientation() == Qt::Horizontal) {
+                hbInstance->allMainWindows().at(0)->setOrientation(Qt::Vertical);
+            } else {
+                hbInstance->allMainWindows().at(0)->setOrientation(Qt::Horizontal);
+            }
+            break;
+        default:
+            return false;
+        }
+        emit dataChanged();
+    }
+    return false;
+}
+
+QVariant HbAutolockIndicator::indicatorData(int role) const
+{
+    if (role == PrimaryTextRole) {
+        if (mParameter.isValid()) {
+        		qDebug() << "============= HbAutolockIndicator::indicatorData 11=";
+						qDebug() << QString("data:").append(mParameter.toString())
+                                   .append(" ")
+                                   .append(mPrimaryText);
+            return QString("data:").append(mParameter.toString())
+                                   .append(" ")
+                                   .append(mPrimaryText);
+        } else {
+        		qDebug() << "============= HbAutolockIndicator::indicatorData 12=";
+        		qDebug() << mPrimaryText ;
+            return mPrimaryText;
+        }
+    } else if (role == SecondaryTextRole && mTypeIndex != 7) {
+        if (mParameter.isValid()) {
+        		qDebug() << "============= HbAutolockIndicator::indicatorData 21=";
+						qDebug() << QString("data:").append(mParameter.toString())
+                                   .append(" ")
+                                   .append(mPrimaryText);
+            return QString("data:").append(mParameter.toString())
+                                   .append(" ")
+                                   .append(mSecondaryText);
+        } else {
+        		qDebug() << "============= HbAutolockIndicator::indicatorData 22=";
+        		qDebug() << mSecondaryText ;
+            return mSecondaryText;
+        }
+    } else if (role == MonoDecorationNameRole) {
+        if (mParameter.isValid()) {
+        		qDebug() << "============= HbAutolockIndicator::indicatorData 31=";
+        		qDebug() << "qtg_mono_ok.svg" ;
+            return "qtg_mono_ok.svg";
+        } else {
+        		qDebug() << "============= HbAutolockIndicator::indicatorData 32=";
+        		qDebug() << mIcon ;
+            return mIcon;
+        }
+    } else if (role == DecorationNameRole) {
+        if (mParameter.isValid()) {
+        		qDebug() << "============= HbAutolockIndicator::indicatorData 41=";
+        		qDebug() << "qtg_mono_ok.svg" ;
+            return "qtg_mono_ok.svg";
+        } else {
+        		qDebug() << "============= HbAutolockIndicator::indicatorData 42=";
+        		qDebug() << mIcon ;
+            return mIcon;
+        }
+    } else if (role == MonoDecorationNameRole) {
+        if (mParameter.isValid()) {
+        		qDebug() << "============= HbAutolockIndicator::indicatorData 51=";
+        		qDebug() << "qtg_mono_ok.svg" ;
+            return "qtg_mono_ok.svg";
+        } else {
+        		qDebug() << "============= HbAutolockIndicator::indicatorData 52=";
+        		qDebug() << mIconMono ;
+            return mIconMono;
+        }
+    }
+    return QVariant();
+}
+
+bool HbAutolockIndicator::handleClientRequest(RequestType type, const QVariant &parameter)
+{
+    bool handled(false);
+    switch (type) {
+    case RequestActivate:
+        if (mParameter != parameter) {
+            mParameter = parameter;
+            emit dataChanged();
+        }
+        handled =  true;
+        break;
+    default:
+        mParameter.clear();
+    }
+
+    return handled;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/securitydialogs/Autolock/indicatorplugin/hbindicatorautolockplugin.h	Fri Sep 03 13:36:43 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* ============================================================================
+*  Name        : hbindicatorautolockplugin.h
+*  Part of     : hb / hbcore
+*  Description : indicator autolock plugin header
+*  Version     : %version: 1 %
+*
+*  Copyright (c) 2009 Nokia.  All rights reserved.
+*  This material, including documentation and any related computer
+*  programs, is protected by copyright controlled by Nokia.  All
+*  rights are reserved.  Copying, including reproducing, storing,
+*  adapting or translating, any or all of this material requires the
+*  prior written consent of Nokia.  This material also contains
+*  confidential information which may not be disclosed to others
+*  without the prior written consent of Nokia.
+* ============================================================================
+*/
+
+#ifndef HBINDICATORAUTOLOCKPLUGIN_H
+#define HBINDICATORAUTOLOCKPLUGIN_H
+
+#include <QObject>
+#include <QStringList>
+#include <QVariant>
+
+#include <hbindicatorplugininterface.h>
+#include <hbindicatorinterface.h>
+#include "autolockindicators.h"
+
+class HbIndicatorAutolockPlugin : public QObject, public HbIndicatorPluginInterface
+{
+    Q_OBJECT
+    Q_INTERFACES(HbIndicatorPluginInterface)
+
+public:
+    HbIndicatorAutolockPlugin();
+    ~HbIndicatorAutolockPlugin();
+
+    QStringList indicatorTypes() const;
+    bool accessAllowed(const QString &indicatorType,
+        const QVariantMap &securityInfo) const;
+    HbIndicatorInterface* createIndicator(const QString &indicatorType);
+    int error() const;
+private:
+    int typeIndex(const QString &indicatorType) const;
+private:
+    Q_DISABLE_COPY(HbIndicatorAutolockPlugin)
+    int mError;
+    QStringList mIndicatorTypes;
+};
+
+class HbAutolockIndicator : public HbIndicatorInterface
+{
+public:
+    HbAutolockIndicator(const QString &indicatorType,
+                    int typeIndex,
+                    Interaction interaction);
+    ~HbAutolockIndicator();
+    bool handleInteraction(InteractionType type);
+    QVariant indicatorData(int role) const;
+protected:
+    bool handleClientRequest(RequestType type, const QVariant &parameter);
+private:
+    QString mPrimaryText;
+    QString mSecondaryText;
+    QString mIcon;
+    QString mIconMono;
+    int mTypeIndex;
+    Interaction mInteraction;
+    QVariant mParameter;
+};
+
+#endif // HBINDICATORAUTOLOCKPLUGIN_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/securitydialogs/Autolock/indicatorplugin/indicatorautolockplugin.pro	Fri Sep 03 13:36:43 2010 +0100
@@ -0,0 +1,61 @@
+#
+# ============================================================================
+#  Name        : indicatorautolockplugin.pro
+#  Part of     : hb / 
+#  Description : indicator autolock plugin
+#  Version     : %version: 1 %
+#
+#  Copyright © 2009 Nokia.  All rights reserved.
+#  This material, including documentation and any related computer
+#  programs, is protected by copyright controlled by Nokia.  All
+#  rights are reserved.  Copying, including reproducing, storing,
+#  adapting or translating, any or all of this material requires the
+#  prior written consent of Nokia.  This material also contains
+#  confidential information which may not be disclosed to others
+#  without the prior written consent of Nokia.
+# ============================================================================
+#
+
+TEMPLATE = lib
+
+CONFIG += Hb
+
+TARGET = IndicatorAutolockPlugin
+CONFIG += plugin
+win32 {
+    debug {
+        DESTDIR = ../indicatorplugin/debug
+    }
+    else {
+        DESTDIR = ../indicatorplugin/release
+    }
+}
+else {
+    DESTDIR = ../indicatorplugin
+}
+
+HEADERS += hbindicatorautolockplugin.h autolockindicators.h
+SOURCES += hbindicatorautolockplugin.cpp
+
+symbian {
+    TARGET.EPOCALLOWDLLDATA=1
+    TARGET.CAPABILITY = CAP_GENERAL_DLL
+
+    hblib.sources = Hb.dll
+    hblib.path = \sys\bin
+    hblib.depends = "(0xEEF9EA38), 1, 0, 0, {\"Hb\"}"
+
+    pluginstub.sources = indicatorautolockplugin.dll
+    pluginstub.path = /resource/plugins/indicators
+    DEPLOYMENT += pluginstub
+}
+
+!local {
+    target.path = $${HB_PLUGINS_DIR}/indicators
+    INSTALLS += target
+}
+
+BLD_INF_RULES.prj_exports += \
+    "$${LITERAL_HASH}include <platform_paths.hrh>" \
+    "rom/indicatorautolockplugin.iby CORE_APP_LAYER_IBY_EXPORT_PATH(indicatorautolockplugin.iby)"
+