securitydialogs/secuinotifications/secuinotificationdialogplugin/src/secuinotificationdialogplugin.cpp
branchRCL_3
changeset 21 09b1ac925e3f
equal deleted inserted replaced
20:63339781d179 21:09b1ac925e3f
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: SecUi notification plugin.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "secuinotificationdebug.h"
       
    19 #include "secuinotificationdialogplugin.h"
       
    20 #include "secuinotificationdialog.h"
       
    21 #include "secuinotificationdialogpluginkeys.h"
       
    22 
       
    23 #include <etelmm.h>
       
    24 
       
    25 // This plugin implements one device dialog type
       
    26 static const struct {
       
    27     const char *mTypeString;
       
    28 } dialogInfos[] = {
       
    29     {SECUINOTIFICATIONDIALOG}
       
    30 };
       
    31 
       
    32 
       
    33 // ----------------------------------------------------------------------------
       
    34 // SecUiNotificationDialogPlugin::SecUiNotificationDialogPlugin()
       
    35 // ----------------------------------------------------------------------------
       
    36 //
       
    37 SecUiNotificationDialogPlugin::SecUiNotificationDialogPlugin() : mError(KNoError)
       
    38 {
       
    39 }
       
    40 
       
    41 // ----------------------------------------------------------------------------
       
    42 // SecUiNotificationDialogPlugin::~SecUiNotificationDialogPlugin()
       
    43 // ----------------------------------------------------------------------------
       
    44 //
       
    45 SecUiNotificationDialogPlugin::~SecUiNotificationDialogPlugin()
       
    46 {
       
    47 }
       
    48 
       
    49 // ----------------------------------------------------------------------------
       
    50 // SecUiNotificationDialogPlugin::accessAllowed()
       
    51 // ----------------------------------------------------------------------------
       
    52 //
       
    53 bool SecUiNotificationDialogPlugin::accessAllowed(const QString &deviceDialogType,
       
    54     const QVariantMap &parameters, const QVariantMap &securityInfo) const
       
    55 {
       
    56 		RDEBUG("0", 0);
       
    57     Q_UNUSED(deviceDialogType)
       
    58     Q_UNUSED(parameters)
       
    59     Q_UNUSED(securityInfo)
       
    60 
       
    61     // All clients are allowed to use.
       
    62     // should access be limited to certain clients or capabilities ? Not for now.
       
    63     return true;
       
    64 }
       
    65 
       
    66 // ----------------------------------------------------------------------------
       
    67 // SecUiNotificationDialogPlugin::createDeviceDialog()
       
    68 // ----------------------------------------------------------------------------
       
    69 //
       
    70 HbDeviceDialogInterface *SecUiNotificationDialogPlugin::createDeviceDialog(
       
    71     const QString &deviceDialogType, const QVariantMap &parameters)
       
    72 {
       
    73     //  Create device dialog widget
       
    74     RDEBUG("0", 0);
       
    75     Q_UNUSED(deviceDialogType)
       
    76 
       
    77     SecUiNotificationDialog *deviceDialog = new SecUiNotificationDialog(parameters);
       
    78     mError = deviceDialog->deviceDialogError();
       
    79     if (mError != KNoError) {
       
    80         delete deviceDialog;
       
    81         deviceDialog = 0;
       
    82     }
       
    83 
       
    84     RDEBUG("1", 1);
       
    85     return deviceDialog;
       
    86 }
       
    87 
       
    88 // ----------------------------------------------------------------------------
       
    89 // SecUiNotificationDialogPlugin::deviceDialogInfo()
       
    90 // ----------------------------------------------------------------------------
       
    91 //
       
    92 bool SecUiNotificationDialogPlugin::deviceDialogInfo( const QString &deviceDialogType,
       
    93         const QVariantMap &parameters, DeviceDialogInfo *info) const
       
    94 {
       
    95 		// For some unknown reason, this function doesn't print the signature 
       
    96 		RDEBUG("0", 0);
       
    97 		#ifdef _DEBUG
       
    98 		RDebug::Printf( "SecUiNotificationDialogPlugin::deviceDialogInfo=%x", 0 );
       
    99 		#endif
       
   100 
       
   101     Q_UNUSED(deviceDialogType);
       
   102 
       
   103 		info->group = SecurityGroup;
       
   104     info->flags = NoDeviceDialogFlags;
       
   105     info->priority = DefaultPriority;
       
   106 
       
   107 		// The unlock-query must have higher priority, to get over Telephony.
       
   108 		if (parameters.contains(KQueryType)) {
       
   109 				#ifdef _DEBUG
       
   110 				RDebug::Printf( "SecUiNotificationDialogPlugin::deviceDialogInfo KQueryType=%x", 1 );
       
   111 				#endif
       
   112         int iqueryType = parameters.value(KQueryType).toUInt();
       
   113         RDEBUG("iqueryType", iqueryType);
       
   114 				#ifdef _DEBUG
       
   115 				RDebug::Printf( "SecUiNotificationDialogPlugin::deviceDialogInfo iqueryType=%x", iqueryType );
       
   116 				#endif
       
   117 				if( (iqueryType & 0xFFFF) == RMobilePhone::ESecurityCodePhonePassword )
       
   118 					{
       
   119 					RDEBUG("CriticalGroup", CriticalGroup);
       
   120 					#ifdef _DEBUG
       
   121 					RDebug::Printf( "SecUiNotificationDialogPlugin::deviceDialogInfo CriticalGroup=%x", CriticalGroup );
       
   122 					#endif
       
   123 					info->group = CriticalGroup;
       
   124 					}
       
   125 				// The unlock-query must have lower priority, to get over change PIN code request.					
       
   126 				else if( iqueryType == 0xB000000 )
       
   127 					{
       
   128 					#ifdef _DEBUG
       
   129 					RDebug::Printf( "SecUiNotificationDialogPlugin::deviceDialogInfo GenericDeviceDialogGroup=%x", GenericDeviceDialogGroup );
       
   130 					#endif						
       
   131 				  info->group = GenericDeviceDialogGroup;
       
   132 					}					
       
   133 				}
       
   134     // Return device dialog flags
       
   135 
       
   136     RDEBUG("1", 1);
       
   137     return true;
       
   138 }
       
   139 
       
   140 // ----------------------------------------------------------------------------
       
   141 // SecUiNotificationDialogPlugin::deviceDialogTypes()
       
   142 // ----------------------------------------------------------------------------
       
   143 //
       
   144 QStringList SecUiNotificationDialogPlugin::deviceDialogTypes() const
       
   145 {
       
   146 		RDEBUG("0", 0);
       
   147     // Return device dialog types this plugin implements
       
   148 
       
   149     QStringList types;
       
   150     const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]);
       
   151     for(int i = 0; i < numTypes; ++i) {
       
   152         types.append(dialogInfos[i].mTypeString);
       
   153     }
       
   154 
       
   155     return types;
       
   156 }
       
   157 
       
   158 // ----------------------------------------------------------------------------
       
   159 // SecUiNotificationDialogPlugin::pluginFlags()
       
   160 // ----------------------------------------------------------------------------
       
   161 //
       
   162 HbDeviceDialogPlugin::PluginFlags SecUiNotificationDialogPlugin::pluginFlags() const
       
   163 {
       
   164 		RDEBUG("0", 0);
       
   165     // Return plugin flags
       
   166     return NoPluginFlags;
       
   167 }
       
   168 
       
   169 // ----------------------------------------------------------------------------
       
   170 // SecUiNotificationDialogPlugin::error()
       
   171 // ----------------------------------------------------------------------------
       
   172 //
       
   173 int SecUiNotificationDialogPlugin::error() const
       
   174 {
       
   175 		RDEBUG("mError", mError);
       
   176     // Return last error
       
   177     return mError;
       
   178 }
       
   179 
       
   180 Q_EXPORT_PLUGIN2(secuinotificationdialogplugin,SecUiNotificationDialogPlugin)