src/hbcore/indicatorplugins/hbindicatorplugininterface.cpp
author hgs
Mon, 18 Oct 2010 18:23:13 +0300
changeset 34 ed14f46c0e55
parent 2 06ff229162e9
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/****************************************************************************
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
** All rights reserved.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
** Contact: Nokia Corporation (developer.feedback@nokia.com)
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
** This file is part of the HbCore module of the UI Extensions for Mobile.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
** GNU Lesser General Public License Usage
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
** This file may be used under the terms of the GNU Lesser General Public
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
** License version 2.1 as published by the Free Software Foundation and
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
** appearing in the file LICENSE.LGPL included in the packaging of this file.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
** Please review the following information to ensure the GNU Lesser General
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
** Public License version 2.1 requirements will be met:
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
** In addition, as a special exception, Nokia gives you certain additional
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
** rights.  These rights are described in the Nokia Qt LGPL Exception
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
** If you have questions regarding the use of this file, please contact
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
** Nokia at developer.feedback@nokia.com.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
**
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
****************************************************************************/
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include <hbindicatorplugininterface.h>
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
/*!
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
    \class HbIndicatorPluginInterface
34
hgs
parents: 2
diff changeset
    30
    \brief HbIndicatorPluginInterface is an abstract interface class for indicator plugins.
hgs
parents: 2
diff changeset
    31
hgs
parents: 2
diff changeset
    32
    Indicators are activated, deactivated and updated using HbIndicator class. Indicator
hgs
parents: 2
diff changeset
    33
    framework takes care of displaying indicators in satus bar and/or indicator menu.
hgs
parents: 2
diff changeset
    34
hgs
parents: 2
diff changeset
    35
    Indicator plugins contain implentation of indicators. Single pluging can implement
hgs
parents: 2
diff changeset
    36
    one or several indicators. HbIndicatorInterface defines functionality required from an
hgs
parents: 2
diff changeset
    37
    indicator implementation.
hgs
parents: 2
diff changeset
    38
hgs
parents: 2
diff changeset
    39
    Indicators are identified by a string. By convention the string should follow
hgs
parents: 2
diff changeset
    40
    inverted domain name format. For example com.nokia.hb.indicator.xxx/1.0.
hgs
parents: 2
diff changeset
    41
    Function indicatorTypes() returns a list of indicators the plugin implements.
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
34
hgs
parents: 2
diff changeset
    43
    Appending version number into indicator type string enables versioning.
hgs
parents: 2
diff changeset
    44
    A plugin should handle versioning by returning indicator type string for all versions it
hgs
parents: 2
diff changeset
    45
    implements in indicatorTypes() and then in createIndicator() create an indicator
hgs
parents: 2
diff changeset
    46
    instance compatible with the version requested. This could always be the latest version if it
hgs
parents: 2
diff changeset
    47
    is backwards compatible with older versions. Indicator framework is unaware of version
hgs
parents: 2
diff changeset
    48
    numbers in type strings. It performs string comparison of the whole string when searching
hgs
parents: 2
diff changeset
    49
    for a plugin.
hgs
parents: 2
diff changeset
    50
hgs
parents: 2
diff changeset
    51
    Plugins are responsible for maintaining system security for their own part. If plugin
hgs
parents: 2
diff changeset
    52
    performs operations that may compromise security or want's to limit access to specific
hgs
parents: 2
diff changeset
    53
    clients, it should check client security credentials in accessAllowed() function.
hgs
parents: 2
diff changeset
    54
    Indicator framework calls this function before activating/deactivating indicators.
hgs
parents: 2
diff changeset
    55
hgs
parents: 2
diff changeset
    56
    \section _exceptions Exception handling
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
34
hgs
parents: 2
diff changeset
    58
    Indicator service uses two strategies in exception handling: Avoidance and trapping.
hgs
parents: 2
diff changeset
    59
    Memory allocation exceptions while an indicator is running are avoided by ensuring there is
hgs
parents: 2
diff changeset
    60
    sufficient heap space available before allowing new indicators to be activated.
hgs
parents: 2
diff changeset
    61
    Trapping is used while an indicator is created. A call to createIndicator() is enclosed
hgs
parents: 2
diff changeset
    62
    in try/catch block. Memory allocation exception causes indicator activation to fail
hgs
parents: 2
diff changeset
    63
    and an error is returned to a client. Plugin should take care there are no memory leaks
hgs
parents: 2
diff changeset
    64
    if exception is thrown inside createIndicator(). Calls to HbIndicatorInterface
hgs
parents: 2
diff changeset
    65
    functions are trapped and thrown allocation exceptions are ignored. Plugins can
hgs
parents: 2
diff changeset
    66
    provide more fine grained exception handling by trapping exceptions themselves.
hgs
parents: 2
diff changeset
    67
hgs
parents: 2
diff changeset
    68
    \section _platform_hbindicatorplugin Platform-specific implementation notes for HbIndicatorPluginInterface
hgs
parents: 2
diff changeset
    69
hgs
parents: 2
diff changeset
    70
    \subsection _nonsymbian Non-Symbian
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
34
hgs
parents: 2
diff changeset
    72
    Indicator plugins are loaded into client process. Plugin executables are searched from
hgs
parents: 2
diff changeset
    73
    application's current directory and HB_PLUGINS_DIR/indicators directory.
hgs
parents: 2
diff changeset
    74
hgs
parents: 2
diff changeset
    75
    \subsection _symbian Symbian
hgs
parents: 2
diff changeset
    76
hgs
parents: 2
diff changeset
    77
    Plugins are run by a server with platform security capabilities ProtServ, SwEvent,
hgs
parents: 2
diff changeset
    78
    TrustedUI and ReadDeviceData. If a plugin doesn't have required platform security
hgs
parents: 2
diff changeset
    79
    capabilities it will not load.
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
34
hgs
parents: 2
diff changeset
    81
    Device dialog plugin stubs (.qtplugin) are searched from /resource/plugins/indicators directory
hgs
parents: 2
diff changeset
    82
    and executables in /sys/bin directory in each drive.
2
06ff229162e9 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
    83
34
hgs
parents: 2
diff changeset
    84
    \section _example_code Example code
hgs
parents: 2
diff changeset
    85
hgs
parents: 2
diff changeset
    86
    Below is an example of how to create a simple indicator plugin.
hgs
parents: 2
diff changeset
    87
hgs
parents: 2
diff changeset
    88
    If plugin implements only one indicator, plugin can also inherit from
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
    HbIndicatorInterface. Example header-file:
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
34
hgs
parents: 2
diff changeset
    91
    \snippet{tsrc\unit\unittest_hbindicator\codesnippetplugin\hbcodesnippetplugin.h,1}
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
    Example source-file:
34
hgs
parents: 2
diff changeset
    94
    \snippet{tsrc\unit\unittest_hbindicator\codesnippetplugin\hbcodesnippetplugin.cpp,1}
hgs
parents: 2
diff changeset
    95
hgs
parents: 2
diff changeset
    96
    If more than one indicators are implemented inside a plugin, plugin inherits from HbIndicatorPluginInterface.
hgs
parents: 2
diff changeset
    97
hgs
parents: 2
diff changeset
    98
    \snippet{tsrc\unit\unittest_hbindicator\codesnippetplugin\hbcodesnippetplugin.h,2}
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
34
hgs
parents: 2
diff changeset
   100
    And createIndicator should create new object based on indicator type.
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
34
hgs
parents: 2
diff changeset
   102
    \snippet{tsrc\unit\unittest_hbindicator\codesnippetplugin\hbcodesnippetplugin.cpp,2}
hgs
parents: 2
diff changeset
   103
hgs
parents: 2
diff changeset
   104
    \sa HbIndicator, HbIndicatorInterface
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
2
06ff229162e9 Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 1
diff changeset
   106
    \stable
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
    \hbcore
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
*/
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
/*!
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    \fn virtual QStringList HbIndicatorPluginInterface::indicatorTypes() const = 0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
34
hgs
parents: 2
diff changeset
   113
    Should return the indicator types the plugin implements.
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
*/
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
/*!
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
    \fn virtual bool HbIndicatorPluginInterface::accessAllowed(
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
        const QString &indicatorType, const QVariantMap &securityInfo) const
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
    Checks if client is allowed to activate or deactivate the indicator.  The
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
    implementation is operating system dependent. On Symbian this may involve checking client's
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
    platform security capabilities or secure ID for example.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
    \a indicatorType contains indicator type.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
    \a securityInfo contains information for security check. See HbDeviceDialogPlugin::accessAllowed() for format.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
    Should return true if client is allowed to activate and deactivate the indicator.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
    \sa HbDeviceDialogPlugin::accessAllowed()
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
*/
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
/*!
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
    \fn virtual  HbIndicatorInterface *HbIndicatorPluginInterface::createIndicator(const QString &indicatorType) = 0
34
hgs
parents: 2
diff changeset
   134
hgs
parents: 2
diff changeset
   135
    Creates an indicator of type \a indicatorType. Ownership is passed to the caller.
hgs
parents: 2
diff changeset
   136
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
    \sa HbIndicatorPluginInterface::indicatorTypes()
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
*/
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
/*!
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
    \fn virtual int HbIndicatorPluginInterface::error() const = 0
34
hgs
parents: 2
diff changeset
   142
0
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
    Returns the last error code. The code is cleared when any other API function than error() is
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
    called.
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
*/
16d8024aca5e Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146