securitysettings/eapqtdialogs/src/eapdialogplugin.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
child 55 9c2aa05919d9
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
     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: Eap Dialog Plugin implementation
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 10 %
       
    20 */
       
    21 
       
    22 // System includes
       
    23 #include <hbdevicedialoginterface.h>
       
    24 #include <QVariantMap>
       
    25 
       
    26 // User includes
       
    27 #include "eapdialogplugin.h"
       
    28 #include "eapusernamepwddialog.h"
       
    29 #include "eapquerydialog.h"
       
    30 #include "eappasswordquerydialog.h"
       
    31 #include "eapfastinstallpacquerydialog.h"
       
    32 #include "eapfastpacstorepwquerydialog.h"
       
    33 #include "eapfastpacfilepwquerydialog.h"
       
    34 #include "eapfastcreatemasterkeyquerydialog.h"
       
    35 #include "eapfastprovwaitnotedialog.h"
       
    36 #include "eapmschapv2pwdexpirednotedialog.h"
       
    37 #include "eapmschapv2oldpwddialog.h"
       
    38 #include "eapmschapv2newpwddialog.h"
       
    39 #include "eapfastprovnotsuccessnotedialog.h"
       
    40 #include "OstTraceDefinitions.h"
       
    41 #ifdef OST_TRACE_COMPILER_IN_USE
       
    42 #include "eapdialogpluginTraces.h"
       
    43 #endif
       
    44 
       
    45 /*!
       
    46  * \class EapDialogPlugin
       
    47  * \brief Implements Eap Dialog Plugin. 
       
    48  */
       
    49 
       
    50 // External function prototypes
       
    51 
       
    52 Q_EXPORT_PLUGIN2(eapdialogplugin, EapDialogPlugin)
       
    53 
       
    54 // Local constants
       
    55 
       
    56 //! This plugin implements several device dialog types
       
    57 static const struct {
       
    58     const char *mTypeString;
       
    59 } dialogInfos[] = {
       
    60     {"com.nokia.eap.usernamepassworddialog/1.0"},
       
    61     {"com.nokia.eap.querydialog/1.0"},
       
    62     {"com.nokia.eap.passwordquerydialog/1.0"},
       
    63     {"com.nokia.eap.fastinstallpacquerydialog/1.0"},
       
    64     {"com.nokia.eap.fastpacstorepwquerydialog/1.0"},
       
    65     {"com.nokia.eap.fastcreatemasterkeyquerydialog/1.0"},
       
    66     {"com.nokia.eap.fastpacfilepwquerydialog/1.0"},
       
    67     {"com.nokia.eap.fastprovwaitnotedialog/1.0"},
       
    68     {"com.nokia.eap.mschapv2passwordexpirednotedialog/1.0"},
       
    69     {"com.nokia.eap.mschapv2oldpassworddialog/1.0"},
       
    70     {"com.nokia.eap.mschapv2newpassworddialog/1.0"},
       
    71     {"com.nokia.eap.fastshowprovnotsuccessnotedialog/1.0"}
       
    72 };
       
    73 
       
    74 // ======== LOCAL FUNCTIONS ========
       
    75 
       
    76 // ======== MEMBER FUNCTIONS ========
       
    77 
       
    78 /*!
       
    79  * Constructor.
       
    80  */
       
    81 EapDialogPlugin::EapDialogPlugin()
       
    82 {
       
    83     OstTraceFunctionEntry0( EAPDIALOGPLUGIN_EAPDIALOGPLUGIN_ENTRY );
       
    84     qDebug("EapDialogPlugin::EapDialogPlugin");
       
    85         
       
    86     OstTraceFunctionExit0( EAPDIALOGPLUGIN_EAPDIALOGPLUGIN_EXIT );
       
    87 }
       
    88 
       
    89 /*!
       
    90  * Destructor
       
    91  */ 
       
    92 EapDialogPlugin::~EapDialogPlugin()
       
    93 {
       
    94     OstTraceFunctionEntry0( DUP1_EAPDIALOGPLUGIN_DEAPDIALOGPLUGIN_ENTRY );
       
    95       
       
    96     OstTraceFunctionExit0( EAPDIALOGPLUGIN_DEAPDIALOGPLUGIN_EXIT );
       
    97 }
       
    98 
       
    99 /*!
       
   100  * Create device dialog widget
       
   101  *
       
   102  * @param [in]  deviceDialogType Tells which Dialog to create
       
   103  * @param [in]  parameters Parameters for the Construction of the dialog.
       
   104  * @return  created dialog widget
       
   105  */ 
       
   106 HbDeviceDialogInterface *EapDialogPlugin::createDeviceDialog(
       
   107     const QString &deviceDialogType,
       
   108     const QVariantMap &parameters)
       
   109 {  
       
   110     OstTraceFunctionEntry0( EAPDIALOGPLUGIN_CREATEDEVICEDIALOG_ENTRY );
       
   111     qDebug("EapDialogPlugin::createDeviceDialog ENTER");
       
   112     
       
   113     HbDeviceDialogInterface* dialog = NULL; 
       
   114         
       
   115     if ( deviceDialogType.compare(dialogInfos[0].mTypeString) == 0 ) 
       
   116         {
       
   117         qDebug("EapDialogPlugin::createDeviceDialog: new EapUsernamePwdDialog");
       
   118         dialog = new EapUsernamePwdDialog(parameters);
       
   119         }
       
   120     else if ( deviceDialogType.compare(dialogInfos[1].mTypeString) == 0 ) 
       
   121         { 
       
   122         qDebug("EapDialogPlugin::createDeviceDialog: new EapQueryDialog");
       
   123         dialog = new EapQueryDialog(parameters);   
       
   124         }
       
   125     else if ( deviceDialogType.compare(dialogInfos[2].mTypeString) == 0 ) 
       
   126         { 
       
   127         qDebug("EapDialogPlugin::createDeviceDialog: new EapPasswordQueryDialog");
       
   128         dialog = new EapPasswordQueryDialog(parameters);
       
   129         }
       
   130     else if ( deviceDialogType.compare(dialogInfos[3].mTypeString) == 0 )
       
   131         {
       
   132         qDebug("EapDialogPlugin::createDeviceDialog: new EapFastInstallPacQueryDialog");
       
   133         dialog = new EapFastInstallPacQueryDialog(parameters);
       
   134         }
       
   135     else if ( deviceDialogType.compare(dialogInfos[4].mTypeString) == 0 )
       
   136         {
       
   137         qDebug("EapDialogPlugin::createDeviceDialog: new EapFastPacStorePwQueryDialog");
       
   138         dialog = new EapFastPacStorePwQueryDialog(parameters);
       
   139         }   
       
   140     else if ( deviceDialogType.compare(dialogInfos[5].mTypeString) == 0 )
       
   141         {
       
   142         qDebug("EapDialogPlugin::createDeviceDialog: new EapFastCreateMasterKeyQueryDialog");
       
   143         dialog = new EapFastCreateMasterKeyQueryDialog(parameters);
       
   144         }  
       
   145     else if ( deviceDialogType.compare(dialogInfos[6].mTypeString) == 0 )
       
   146         {
       
   147         qDebug("EapDialogPlugin::createDeviceDialog: new EapFastPacFilePwQueryDialog");
       
   148         dialog = new EapFastPacFilePwQueryDialog(parameters);
       
   149         }
       
   150     else if ( deviceDialogType.compare(dialogInfos[7].mTypeString) == 0 )
       
   151         {
       
   152         qDebug("EapDialogPlugin::createDeviceDialog: new EapFastProvWaitNoteDialog");
       
   153         dialog = new EapFastProvWaitNoteDialog(parameters);
       
   154         }  
       
   155     else if ( deviceDialogType.compare(dialogInfos[8].mTypeString) == 0 )
       
   156         {
       
   157         qDebug("EapDialogPlugin::createDeviceDialog: new EapMschapv2PwdExpNoteDialog");
       
   158         dialog = new EapMschapv2PwdExpNoteDialog(parameters);
       
   159         }  
       
   160     else if ( deviceDialogType.compare(dialogInfos[9].mTypeString) == 0 )
       
   161         {
       
   162         qDebug("EapDialogPlugin::createDeviceDialog: new EapMschapv2OldPwdDialog");
       
   163         dialog = new EapMschapv2OldPwdDialog(parameters);
       
   164         }  
       
   165     else if ( deviceDialogType.compare(dialogInfos[10].mTypeString) == 0 )
       
   166         {
       
   167         qDebug("EapDialogPlugin::createDeviceDialog: new EapMschapv2NewPwdDialog");
       
   168         dialog = new EapMschapv2NewPwdDialog(parameters);
       
   169         }  
       
   170     else if ( deviceDialogType.compare(dialogInfos[11].mTypeString) == 0 )
       
   171         {
       
   172         qDebug("EapDialogPlugin::createDeviceDialog: new EapFastProvNotSuccessNoteDialog");
       
   173         dialog = new EapFastProvNotSuccessNoteDialog(parameters);
       
   174         }   
       
   175     OstTraceFunctionExit0( EAPDIALOGPLUGIN_CREATEDEVICEDIALOG_EXIT );
       
   176     qDebug("EapDialogPlugin::createDeviceDialog EXIT");
       
   177     
       
   178     return dialog;
       
   179 }
       
   180 
       
   181 /*!
       
   182  * Check if client is allowed to use device dialog widget. For the meantime
       
   183  * this plugin doesn't perform operations that may compromise security.
       
   184  * All clients are allowed to use.
       
   185  *
       
   186  * @param [in]  deviceDialogType Tells which Dialog type
       
   187  * @param [in]  parameters Device dialog parameters
       
   188  * @param [in]  securityInfo Information for Security check
       
   189  * @return  returns always true
       
   190  */ 
       
   191 bool EapDialogPlugin::accessAllowed(const QString &deviceDialogType,
       
   192     const QVariantMap &parameters, const QVariantMap &securityInfo) const
       
   193 {
       
   194     OstTraceFunctionEntry0( EAPDIALOGPLUGIN_ACCESSALLOWED_ENTRY );
       
   195     
       
   196     Q_UNUSED(deviceDialogType)
       
   197     Q_UNUSED(parameters)
       
   198     Q_UNUSED(securityInfo)
       
   199 
       
   200     return true;
       
   201 }
       
   202 
       
   203 /*!
       
   204  * Return information of device dialog the plugin creates
       
   205  *
       
   206  * @param [in]  deviceDialogType Tells which Dialog type
       
   207  * @param [in]  parameters Device dialog parameters
       
   208  * @param [in,out]  info Structure the plugin fills with an information 
       
   209  * @return  returns always true
       
   210  */ 
       
   211 bool EapDialogPlugin::deviceDialogInfo(const QString &deviceDialogType,
       
   212     const QVariantMap &parameters, DeviceDialogInfo *info) const
       
   213 {
       
   214     OstTraceFunctionEntry0( EAPDIALOGPLUGIN_DEVICEDIALOGINFO_ENTRY );
       
   215     qDebug("EapDialogPlugin::deviceDialogInfo");
       
   216     
       
   217     Q_UNUSED(parameters)
       
   218     Q_UNUSED(deviceDialogType)
       
   219     
       
   220     info->group = GenericDeviceDialogGroup;
       
   221     info->flags = NoDeviceDialogFlags;
       
   222     info->priority = DefaultPriority;
       
   223     
       
   224     OstTraceFunctionExit0( EAPDIALOGPLUGIN_DEVICEDIALOGINFO_EXIT );
       
   225     qDebug("EapDialogPlugin::deviceDialogInfo EXIT");
       
   226     return true;
       
   227 }
       
   228 
       
   229 /*!
       
   230  * Returns a list of device dialog types the plugin implements. 
       
   231  *
       
   232  * @return returns device dialog types this plugin implements
       
   233  */ 
       
   234 QStringList EapDialogPlugin::deviceDialogTypes() const
       
   235 {
       
   236     OstTraceFunctionEntry0( EAPDIALOGPLUGIN_DEVICEDIALOGTYPES_ENTRY );
       
   237     qDebug("EapDialogPlugin::deviceDialogTypes");
       
   238     
       
   239     QStringList types;
       
   240     const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]);
       
   241     for(int i = 0; i < numTypes; i++) {
       
   242         types.append(dialogInfos[i].mTypeString);
       
   243     }
       
   244     
       
   245     OstTraceFunctionExit0( EAPDIALOGPLUGIN_DEVICEDIALOGTYPES_EXIT );
       
   246     return types;
       
   247 }
       
   248 
       
   249 /*!
       
   250  * Return plugin flags
       
   251  *
       
   252  * @return returns plugin flags
       
   253  */ 
       
   254 EapDialogPlugin::PluginFlags EapDialogPlugin::pluginFlags() const
       
   255 {
       
   256     OstTraceFunctionEntry0( EAPDIALOGPLUGIN_PLUGINFLAGS_ENTRY );   
       
   257     OstTraceFunctionExit0( EAPDIALOGPLUGIN_PLUGINFLAGS_EXIT );
       
   258     return NoPluginFlags;
       
   259 }
       
   260 
       
   261 /*!
       
   262  * The last error is not stored, not supported
       
   263  *
       
   264  * @return returns always 0
       
   265  */ 
       
   266 int EapDialogPlugin::error() const
       
   267 {
       
   268     OstTraceFunctionEntry0( EAPDIALOGPLUGIN_ERROR_ENTRY );
       
   269     OstTraceFunctionExit0( EAPDIALOGPLUGIN_ERROR_EXIT );
       
   270     return 0;
       
   271 }
       
   272