src/hbplugins/devicedialogs/devicemessageboxplugin/hbdevicemessageboxplugin.cpp
changeset 34 ed14f46c0e55
parent 0 16d8024aca5e
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
    26 #include <QtPlugin>
    26 #include <QtPlugin>
       
    27 #ifdef Q_OS_SYMBIAN
       
    28 #include <e32capability.h>
       
    29 #endif // Q_OS_SYMBIAN
    27 
    30 
    28 #include <hbdevicedialog.h>
    31 #include <hbdevicedialog.h>
    29 #include <hbdevicedialogtrace_p.h>
    32 #include <hbdevicedialogtrace_p.h>
    30 #include "hbdevicemessageboxplugin_p.h"
    33 #include "hbdevicemessageboxplugin_p.h"
    31 #include "hbdevicemessageboxwidget_p.h"
    34 #include "hbdevicemessageboxwidget_p.h"
    38     const char *mTypeString;
    41     const char *mTypeString;
    39 } dialogInfos[] = {
    42 } dialogInfos[] = {
    40     {"com.nokia.hb.devicemessagebox/1.0"}
    43     {"com.nokia.hb.devicemessagebox/1.0"}
    41 };
    44 };
    42 
    45 
       
    46 /// \cond
    43 class HbDeviceMessageBoxPluginPrivate
    47 class HbDeviceMessageBoxPluginPrivate
    44 {
    48 {
    45 public:
    49 public:
    46     HbDeviceMessageBoxPluginPrivate() {mError = NoError;}
    50     HbDeviceMessageBoxPluginPrivate() {mError = NoError;}
    47 
    51 
    48     int mError;
    52     int mError;
    49 };
    53 };
       
    54 /// \endcond
    50 
    55 
    51 // Constructor
    56 // Constructor
    52 HbDeviceMessageBoxPlugin::HbDeviceMessageBoxPlugin()
    57 HbDeviceMessageBoxPlugin::HbDeviceMessageBoxPlugin()
    53 {
    58 {
    54     TRACE_ENTRY
    59     TRACE_ENTRY
    68 bool HbDeviceMessageBoxPlugin::accessAllowed(const QString &deviceDialogType,
    73 bool HbDeviceMessageBoxPlugin::accessAllowed(const QString &deviceDialogType,
    69     const QVariantMap &parameters, const QVariantMap &securityInfo) const
    74     const QVariantMap &parameters, const QVariantMap &securityInfo) const
    70 {
    75 {
    71     TRACE_ENTRY
    76     TRACE_ENTRY
    72     Q_UNUSED(deviceDialogType)
    77     Q_UNUSED(deviceDialogType)
       
    78 
       
    79 #ifdef Q_OS_SYMBIAN
       
    80     // If show group is higher than normal, a swEvent capability is required
       
    81     if (showLevel(parameters) != NormalLevel) {
       
    82         return (securityInfo["sym-caps"].toInt() >> ECapabilitySwEvent) & 1;
       
    83     } else {
       
    84         return true; // all clients are allowed to use.
       
    85     }
       
    86 #else
    73     Q_UNUSED(parameters)
    87     Q_UNUSED(parameters)
    74     Q_UNUSED(securityInfo)
    88     Q_UNUSED(securityInfo)
    75 
       
    76     // This plugin doesn't perform operations that may compromise security.
       
    77     // All clients are allowed to use.
    89     // All clients are allowed to use.
    78     return true;
    90     return true;
    79     TRACE_EXIT
    91 #endif // Q_OS_SYMBIAN
    80 }
    92 }
    81 
    93 
    82 // Create device dialog widget
    94 // Create device dialog widget
    83 HbDeviceDialogInterface *HbDeviceMessageBoxPlugin::createDeviceDialog(
    95 HbDeviceDialogInterface *HbDeviceMessageBoxPlugin::createDeviceDialog(
    84     const QString &deviceDialogType, const QVariantMap &parameters)
    96     const QString &deviceDialogType, const QVariantMap &parameters)
   126 // Return information of device dialog the plugin creates
   138 // Return information of device dialog the plugin creates
   127 bool HbDeviceMessageBoxPlugin::deviceDialogInfo(const QString &deviceDialogType,
   139 bool HbDeviceMessageBoxPlugin::deviceDialogInfo(const QString &deviceDialogType,
   128     const QVariantMap &parameters, DeviceDialogInfo *info) const
   140     const QVariantMap &parameters, DeviceDialogInfo *info) const
   129 {
   141 {
   130     TRACE_ENTRY
   142     TRACE_ENTRY
   131     Q_UNUSED(parameters)
       
   132     Q_UNUSED(deviceDialogType)
   143     Q_UNUSED(deviceDialogType)
   133 
   144 
       
   145     unsigned int level = static_cast<unsigned int>(showLevel(parameters));
       
   146     if (level > CriticalLevel) {
       
   147         return false;
       
   148     }
       
   149 
   134     info->group = GenericDeviceDialogGroup;
   150     info->group = GenericDeviceDialogGroup;
   135     info->flags = NoDeviceDialogFlags;
   151     info->flags = level == NormalLevel ? NoDeviceDialogFlags : SecurityCheck;
   136     info->priority = DefaultPriority;
   152     info->showLevel = static_cast<ShowLevel>(level);
   137     TRACE_EXIT
       
   138     return true;
   153     return true;
   139 }
   154 }
   140 
   155 
   141 // Return device dialog types this plugin implements
   156 // Return device dialog types this plugin implements
   142 QStringList HbDeviceMessageBoxPlugin::deviceDialogTypes() const
   157 QStringList HbDeviceMessageBoxPlugin::deviceDialogTypes() const
   164 {
   179 {
   165     TRACE_ENTRY
   180     TRACE_ENTRY
   166     TRACE_EXIT
   181     TRACE_EXIT
   167     return d->mError;
   182     return d->mError;
   168 }
   183 }
       
   184 
       
   185 // Search parameters for show group
       
   186 int HbDeviceMessageBoxPlugin::showLevel(const QVariantMap &parameters)
       
   187 {
       
   188     int level = NormalLevel;
       
   189     const QString propertyName("showLevel"); 
       
   190     if (parameters.contains(propertyName)) {
       
   191         level = parameters[propertyName].toInt(); 
       
   192     }
       
   193     return level;
       
   194 }