src/hbplugins/devicedialogs/devicenotificationdialogplugin/hbdevicenotificationdialogplugin.cpp
changeset 34 ed14f46c0e55
parent 0 16d8024aca5e
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    38     const char *mTypeString;
    38     const char *mTypeString;
    39 } dialogInfos[] = {
    39 } dialogInfos[] = {
    40     {"com.nokia.hb.devicenotificationdialog/1.0"}
    40     {"com.nokia.hb.devicenotificationdialog/1.0"}
    41 };
    41 };
    42 
    42 
       
    43 /// \cond
    43 class HbDeviceNotificationDialogPluginPrivate
    44 class HbDeviceNotificationDialogPluginPrivate
    44 {
    45 {
    45 public:
    46 public:
    46     HbDeviceNotificationDialogPluginPrivate() {mError = NoError;}
    47     HbDeviceNotificationDialogPluginPrivate() {mError = NoError;}
    47 
    48 
    48     int mError;
    49     int mError;
    49 };
    50 };
       
    51 /// \endcond
    50 
    52 
    51 // Constructor
    53 // Constructor
    52 HbDeviceNotificationDialogPlugin::HbDeviceNotificationDialogPlugin()
    54 HbDeviceNotificationDialogPlugin::HbDeviceNotificationDialogPlugin()
    53 {
    55 {
    54     TRACE_ENTRY
    56     TRACE_ENTRY
    68 bool HbDeviceNotificationDialogPlugin::accessAllowed(const QString &deviceDialogType,
    70 bool HbDeviceNotificationDialogPlugin::accessAllowed(const QString &deviceDialogType,
    69     const QVariantMap &parameters, const QVariantMap &securityInfo) const
    71     const QVariantMap &parameters, const QVariantMap &securityInfo) const
    70 {
    72 {
    71     TRACE_ENTRY
    73     TRACE_ENTRY
    72     Q_UNUSED(deviceDialogType)
    74     Q_UNUSED(deviceDialogType)
       
    75 
       
    76 #ifdef Q_OS_SYMBIAN
       
    77     // If show group is higher than normal, a swEvent capability is required
       
    78     if (showLevel(parameters) != NormalLevel) {
       
    79         return (securityInfo["sym-caps"].toInt() >> ECapabilitySwEvent) & 1;
       
    80     } else {
       
    81         return true; // all clients are allowed to use.
       
    82     }
       
    83 #else
    73     Q_UNUSED(parameters)
    84     Q_UNUSED(parameters)
    74     Q_UNUSED(securityInfo)
    85     Q_UNUSED(securityInfo)
    75 
    86     // All clients are allowed to use.
    76     // This plugin doesn't perform operations that may compromise security. All clients
       
    77     // are allowed to use.
       
    78     return true;
    87     return true;
    79     TRACE_EXIT
    88 #endif // Q_OS_SYMBIAN
    80 }
    89 }
    81 
    90 
    82 // Create device dialog widget
    91 // Create device dialog widget
    83 HbDeviceDialogInterface *HbDeviceNotificationDialogPlugin::createDeviceDialog(
    92 HbDeviceDialogInterface *HbDeviceNotificationDialogPlugin::createDeviceDialog(
    84     const QString &deviceDialogType, const QVariantMap &parameters)
    93     const QString &deviceDialogType, const QVariantMap &parameters)
   107 bool HbDeviceNotificationDialogPlugin::deviceDialogInfo(const QString &deviceDialogType,
   116 bool HbDeviceNotificationDialogPlugin::deviceDialogInfo(const QString &deviceDialogType,
   108         const QVariantMap &parameters, DeviceDialogInfo *info) const
   117         const QVariantMap &parameters, DeviceDialogInfo *info) const
   109 {
   118 {
   110     TRACE_ENTRY
   119     TRACE_ENTRY
   111     Q_UNUSED(deviceDialogType);
   120     Q_UNUSED(deviceDialogType);
   112     Q_UNUSED(parameters);
       
   113 
   121 
       
   122     unsigned int level = static_cast<unsigned int>(showLevel(parameters));
       
   123     if (level > CriticalLevel) {
       
   124         return false;
       
   125     }
   114     info->group = DeviceNotificationDialogGroup;
   126     info->group = DeviceNotificationDialogGroup;
   115     info->flags = NoDeviceDialogFlags;
   127     info->flags = level == NormalLevel ? NoDeviceDialogFlags : SecurityCheck;
   116     info->priority = DefaultPriority;
   128     info->showLevel = static_cast<ShowLevel>(level);
   117 
       
   118     TRACE_EXIT
       
   119     return true;
   129     return true;
   120 }
   130 }
   121 
   131 
   122 // Return device dialog types this plugin implements
   132 // Return device dialog types this plugin implements
   123 QStringList HbDeviceNotificationDialogPlugin::deviceDialogTypes() const
   133 QStringList HbDeviceNotificationDialogPlugin::deviceDialogTypes() const
   145 {
   155 {
   146     TRACE_ENTRY
   156     TRACE_ENTRY
   147     TRACE_EXIT
   157     TRACE_EXIT
   148     return d->mError;
   158     return d->mError;
   149 }
   159 }
       
   160 
       
   161 // Search parameters for show group
       
   162 int HbDeviceNotificationDialogPlugin::showLevel(const QVariantMap &parameters)
       
   163 {
       
   164     int level = NormalLevel;
       
   165     const QString propertyName("showLevel");
       
   166     if (parameters.contains(propertyName)) {
       
   167         level = parameters[propertyName].toInt(); 
       
   168     }
       
   169     return level;
       
   170 }