appinstaller/AppinstUi/sifuidevicedialogplugin/src/sifuidevicedialogplugin.cpp
changeset 25 98b66e4fb0be
child 37 6e7b00453237
equal deleted inserted replaced
24:84a16765cd86 25:98b66e4fb0be
       
     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: Software install framework (SIF) device dialog plugin.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "sifuidevicedialogplugin.h"
       
    19 #include "sifuidialogdefinitions.h"
       
    20 #include "sifuidialog.h"
       
    21 
       
    22 // This plugin implements one device dialog, SIF UI device dialog.
       
    23 static const char* KSifUiDeviceDialog = "com.nokia.sifui/1.0";
       
    24 static const struct {
       
    25     const char *mTypeString;
       
    26 } dialogInfos[] = {
       
    27     {KSifUiDeviceDialog}
       
    28 };
       
    29 
       
    30 
       
    31 // ----------------------------------------------------------------------------
       
    32 // SifUiDeviceDialogPlugin::SifUiDeviceDialogPlugin()
       
    33 // ----------------------------------------------------------------------------
       
    34 //
       
    35 SifUiDeviceDialogPlugin::SifUiDeviceDialogPlugin() : mError(KErrNone)
       
    36 {
       
    37 }
       
    38 
       
    39 // ----------------------------------------------------------------------------
       
    40 // SifUiDeviceDialogPlugin::~SifUiDeviceDialogPlugin()
       
    41 // ----------------------------------------------------------------------------
       
    42 //
       
    43 SifUiDeviceDialogPlugin::~SifUiDeviceDialogPlugin()
       
    44 {
       
    45 }
       
    46 
       
    47 // ----------------------------------------------------------------------------
       
    48 // SifUiDeviceDialogPlugin::accessAllowed()
       
    49 // ----------------------------------------------------------------------------
       
    50 //
       
    51 bool SifUiDeviceDialogPlugin::accessAllowed(const QString &deviceDialogType,
       
    52     const QVariantMap &parameters, const QVariantMap &securityInfo) const
       
    53 {
       
    54     Q_UNUSED(deviceDialogType)
       
    55     Q_UNUSED(parameters)
       
    56     Q_UNUSED(securityInfo)
       
    57 
       
    58     // All clients are allowed to use.
       
    59     // TODO: should access be limited to certain clients?
       
    60     return true;
       
    61 }
       
    62 
       
    63 // ----------------------------------------------------------------------------
       
    64 // SifUiDeviceDialogPlugin::createDeviceDialog()
       
    65 // ----------------------------------------------------------------------------
       
    66 //
       
    67 HbDeviceDialogInterface *SifUiDeviceDialogPlugin::createDeviceDialog(
       
    68     const QString &deviceDialogType, const QVariantMap &parameters)
       
    69 {
       
    70     //  Create device dialog widget
       
    71     Q_UNUSED(deviceDialogType)
       
    72 
       
    73     SifUiDialog *deviceDialog = new SifUiDialog(parameters);
       
    74     mError = deviceDialog->deviceDialogError();
       
    75     if (mError != KErrNone) {
       
    76         delete deviceDialog;
       
    77         deviceDialog = 0;
       
    78     }
       
    79 
       
    80     return deviceDialog;
       
    81 }
       
    82 
       
    83 // ----------------------------------------------------------------------------
       
    84 // SifUiDeviceDialogPlugin::deviceDialogInfo()
       
    85 // ----------------------------------------------------------------------------
       
    86 //
       
    87 bool SifUiDeviceDialogPlugin::deviceDialogInfo( const QString &deviceDialogType,
       
    88         const QVariantMap &parameters, DeviceDialogInfo *info) const
       
    89 {
       
    90     // Return device dialog flags
       
    91     Q_UNUSED(deviceDialogType);
       
    92     Q_UNUSED(parameters);
       
    93 
       
    94     info->group = DeviceNotificationDialogGroup;
       
    95     info->flags = NoDeviceDialogFlags;
       
    96     info->priority = DefaultPriority;
       
    97 
       
    98     return true;
       
    99 }
       
   100 
       
   101 // ----------------------------------------------------------------------------
       
   102 // SifUiDeviceDialogPlugin::deviceDialogTypes()
       
   103 // ----------------------------------------------------------------------------
       
   104 //
       
   105 QStringList SifUiDeviceDialogPlugin::deviceDialogTypes() const
       
   106 {
       
   107     // Return device dialog types this plugin implements
       
   108 
       
   109     QStringList types;
       
   110     const int numTypes = sizeof(dialogInfos) / sizeof(dialogInfos[0]);
       
   111     for(int i = 0; i < numTypes; ++i) {
       
   112         types.append(dialogInfos[i].mTypeString);
       
   113     }
       
   114 
       
   115     return types;
       
   116 }
       
   117 
       
   118 // ----------------------------------------------------------------------------
       
   119 // SifUiDeviceDialogPlugin::pluginFlags()
       
   120 // ----------------------------------------------------------------------------
       
   121 //
       
   122 HbDeviceDialogPlugin::PluginFlags SifUiDeviceDialogPlugin::pluginFlags() const
       
   123 {
       
   124     // Return plugin flags
       
   125     return NoPluginFlags;
       
   126 }
       
   127 
       
   128 // ----------------------------------------------------------------------------
       
   129 // SifUiDeviceDialogPlugin::error()
       
   130 // ----------------------------------------------------------------------------
       
   131 //
       
   132 int SifUiDeviceDialogPlugin::error() const
       
   133 {
       
   134     // Return last error
       
   135     return mError;
       
   136 }
       
   137 
       
   138 Q_EXPORT_PLUGIN2(SifUiDeviceDialogPlugin,SifUiDeviceDialogPlugin)
       
   139