VirtualBox

Changeset 78110 in vbox


Ignore:
Timestamp:
Apr 11, 2019 1:32:48 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9434: Import Appliance wizard: Move UIApplianceImportEditorWidget class out of 2nd wizard page to separate files.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
3 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r77901 r78110  
    684684        src/wizards/exportappliance/UIWizardExportAppPageBasic3.h \
    685685        src/wizards/exportappliance/UIWizardExportAppPageExpert.h \
     686        src/wizards/importappliance/UIApplianceUnverifiedCertificateViewer.h \
    686687        src/wizards/importappliance/UIWizardImportApp.h \
    687688        src/wizards/importappliance/UIWizardImportAppPageBasic1.h \
     
    11111112        src/wizards/exportappliance/UIWizardExportAppPageBasic3.cpp \
    11121113        src/wizards/exportappliance/UIWizardExportAppPageExpert.cpp \
     1114        src/wizards/importappliance/UIApplianceUnverifiedCertificateViewer.cpp \
    11131115        src/wizards/importappliance/UIWizardImportApp.cpp \
    11141116        src/wizards/importappliance/UIWizardImportAppPageBasic1.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIApplianceUnverifiedCertificateViewer.cpp

    r78109 r78110  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardImportAppPageBasic2 class implementation.
     3 * VBox Qt GUI - UIApplianceUnverifiedCertificateViewer class implementation.
    44 */
    55
     
    1818/* Qt includes: */
    1919#include <QLabel>
    20 #include <QPointer>
    2120#include <QPushButton>
    2221#include <QTextBrowser>
     
    2524/* GUI includes: */
    2625#include "QIDialogButtonBox.h"
    27 #include "QIRichTextLabel.h"
    28 #include "UIWizardImportApp.h"
    29 #include "UIWizardImportAppPageBasic2.h"
     26#include "UIApplianceUnverifiedCertificateViewer.h"
    3027
    3128/* COM includes: */
    32 #include "CAppliance.h"
     29#include "COMEnums.h"
    3330#include "CCertificate.h"
    3431
    3532
    36 /*********************************************************************************************************************************
    37 *   Class UIWizardImportAppPage2 implementation.                                                                                 *
    38 *********************************************************************************************************************************/
    39 
    40 UIWizardImportAppPage2::UIWizardImportAppPage2()
    41 {
    42 }
    43 
    44 
    45 /*********************************************************************************************************************************
    46 *   Class UIWizardImportAppPageBasic2 implementation.                                                                            *
    47 *********************************************************************************************************************************/
    48 
    49 UIWizardImportAppPageBasic2::UIWizardImportAppPageBasic2(const QString &strFileName)
    50     : m_enmCertText(kCertText_Uninitialized)
    51 {
    52     /* Create main layout: */
    53     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    54     if (pMainLayout)
    55     {
    56         /* Create label: */
    57         m_pLabel = new QIRichTextLabel(this);
    58         if (m_pLabel)
    59         {
    60             /* Add into layout: */
    61             pMainLayout->addWidget(m_pLabel);
    62         }
    63 
    64         /* Create appliance widget: */
    65         m_pApplianceWidget = new UIApplianceImportEditorWidget(this);
    66         {
    67             m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
    68             m_pApplianceWidget->setFile(strFileName);
    69 
    70             /* Add into layout: */
    71             pMainLayout->addWidget(m_pApplianceWidget);
    72         }
    73 
    74         /* Create certificate label: */
    75         m_pCertLabel = new QLabel("<cert label>", this);
    76         if (m_pCertLabel)
    77         {
    78             /* Add into layout: */
    79             pMainLayout->addWidget(m_pCertLabel);
    80         }
    81     }
    82 
    83     /* Register classes: */
    84     qRegisterMetaType<ImportAppliancePointer>();
    85     /* Register fields: */
    86     registerField("applianceWidget", this, "applianceWidget");
    87 }
    88 
    89 void UIWizardImportAppPageBasic2::retranslateUi()
    90 {
    91     /* Translate page: */
    92     setTitle(UIWizardImportApp::tr("Appliance settings"));
    93 
    94     /* Translate widgets: */
    95     m_pLabel->setText(UIWizardImportApp::tr("These are the virtual machines contained in the appliance "
    96                                             "and the suggested settings of the imported VirtualBox machines. "
    97                                             "You can change many of the properties shown by double-clicking "
    98                                             "on the items and disable others using the check boxes below."));
    99     switch (m_enmCertText)
    100     {
    101         case kCertText_Unsigned:
    102             m_pCertLabel->setText(UIWizardImportApp::tr("Appliance is not signed"));
    103             break;
    104         case kCertText_IssuedTrusted:
    105             m_pCertLabel->setText(UIWizardImportApp::tr("Appliance signed by %1 (trusted)").arg(m_strSignedBy));
    106             break;
    107         case kCertText_IssuedExpired:
    108             m_pCertLabel->setText(UIWizardImportApp::tr("Appliance signed by %1 (expired!)").arg(m_strSignedBy));
    109             break;
    110         case kCertText_IssuedUnverified:
    111             m_pCertLabel->setText(UIWizardImportApp::tr("Unverified signature by %1!").arg(m_strSignedBy));
    112             break;
    113         case kCertText_SelfSignedTrusted:
    114             m_pCertLabel->setText(UIWizardImportApp::tr("Self signed by %1 (trusted)").arg(m_strSignedBy));
    115             break;
    116         case kCertText_SelfSignedExpired:
    117             m_pCertLabel->setText(UIWizardImportApp::tr("Self signed by %1 (expired!)").arg(m_strSignedBy));
    118             break;
    119         case kCertText_SelfSignedUnverified:
    120             m_pCertLabel->setText(UIWizardImportApp::tr("Unverified self signed signature by %1!").arg(m_strSignedBy));
    121             break;
    122         default:
    123             AssertFailed();
    124             RT_FALL_THRU();
    125         case kCertText_Uninitialized:
    126             m_pCertLabel->setText("<uninitialized page>");
    127             break;
    128     }
    129 }
    130 
    131 void UIWizardImportAppPageBasic2::initializePage()
    132 {
    133     /* Acquire appliance: */
    134     CAppliance *pAppliance = m_pApplianceWidget->appliance();
    135 
    136     /* Check if pAppliance is alive. If not just return here.
    137      * This prevents crashes when an invalid ova file is supllied: */
    138     if (!pAppliance)
    139     {
    140         if (wizard())
    141             wizard()->reject();
    142         return;
    143     }
    144 
    145     /* Acquire certificate: */
    146     CCertificate comCertificate = pAppliance->GetCertificate();
    147     if (comCertificate.isNull())
    148         m_enmCertText = kCertText_Unsigned;
    149     else
    150     {
    151         /* Pick a 'signed-by' name: */
    152         m_strSignedBy = comCertificate.GetFriendlyName();
    153 
    154         /* If trusted, just select the right message: */
    155         if (comCertificate.GetTrusted())
    156         {
    157             if (comCertificate.GetSelfSigned())
    158                 m_enmCertText = !comCertificate.GetExpired() ? kCertText_SelfSignedTrusted : kCertText_SelfSignedExpired;
    159             else
    160                 m_enmCertText = !comCertificate.GetExpired() ? kCertText_IssuedTrusted     : kCertText_IssuedExpired;
    161         }
    162         else
    163         {
    164             /* Not trusted!  Must ask the user whether to continue in this case: */
    165             m_enmCertText = comCertificate.GetSelfSigned() ? kCertText_SelfSignedUnverified : kCertText_IssuedUnverified;
    166 
    167             /* Translate page early: */
    168             retranslateUi();
    169 
    170             /* Instantiate the dialog: */
    171             QPointer<UIApplianceUnverifiedCertificateViewer> pDialog = new UIApplianceUnverifiedCertificateViewer(this, comCertificate);
    172             AssertPtrReturnVoid(pDialog.data());
    173 
    174             /* Show viewer in modal mode: */
    175             const int iResultCode = pDialog->exec();
    176 
    177             /* Leave if viewer destroyed prematurely: */
    178             if (!pDialog)
    179                 return;
    180             /* Delete viewer finally: */
    181             delete pDialog;
    182 
    183             /* Dismiss the entire import-appliance wizard if user rejects certificate: */
    184             if (iResultCode == QDialog::Rejected)
    185                 wizard()->reject();
    186         }
    187     }
    188 
    189     /* Translate page: */
    190     retranslateUi();
    191 }
    192 
    193 void UIWizardImportAppPageBasic2::cleanupPage()
    194 {
    195     /* Rollback settings: */
    196     m_pApplianceWidget->restoreDefaults();
    197     /* Call to base-class: */
    198     UIWizardPage::cleanupPage();
    199 }
    200 
    201 bool UIWizardImportAppPageBasic2::validatePage()
    202 {
    203     /* Initial result: */
    204     bool fResult = true;
    205 
    206     /* Lock finish button: */
    207     startProcessing();
    208 
    209     /* Try to import appliance: */
    210     if (fResult)
    211         fResult = qobject_cast<UIWizardImportApp*>(wizard())->importAppliance();
    212 
    213     /* Unlock finish button: */
    214     endProcessing();
    215 
    216     /* Return result: */
    217     return fResult;
    218 }
    219 
    220 
    221 /*********************************************************************************************************************************
    222 *   Class UIApplianceUnverifiedCertificateViewer implementation.                                                                 *
    223 *********************************************************************************************************************************/
    224 
    225 UIApplianceUnverifiedCertificateViewer::UIApplianceUnverifiedCertificateViewer(QWidget *pParent, const CCertificate &comCertificate)
     33UIApplianceUnverifiedCertificateViewer::UIApplianceUnverifiedCertificateViewer(QWidget *pParent,
     34                                                                               const CCertificate &comCertificate)
    22635    : QIWithRetranslateUI<QIDialog>(pParent)
    22736    , m_comCertificate(comCertificate)
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIApplianceUnverifiedCertificateViewer.h

    r78109 r78110  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardImportAppPageBasic2 class declaration.
     3 * VBox Qt GUI - UIApplianceUnverifiedCertificateViewer class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_wizards_importappliance_UIWizardImportAppPageBasic2_h
    19 #define FEQT_INCLUDED_SRC_wizards_importappliance_UIWizardImportAppPageBasic2_h
     18#ifndef FEQT_INCLUDED_SRC_wizards_importappliance_UIApplianceUnverifiedCertificateViewer_h
     19#define FEQT_INCLUDED_SRC_wizards_importappliance_UIApplianceUnverifiedCertificateViewer_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2525#include "QIDialog.h"
    2626#include "QIWithRetranslateUI.h"
    27 #include "UIWizardImportAppDefs.h"
    28 #include "UIWizardPage.h"
    2927
    3028/* Forward declarations: */
    3129class QLabel;
    3230class QTextBrowser;
    33 class QDialogButtonBox;
    34 class QIRichTextLabel;
    3531class CCertificate;
    36 
    37 /** UIWizardPageBase extension for 2nd page of the Import Appliance wizard. */
    38 class UIWizardImportAppPage2 : public UIWizardPageBase
    39 {
    40 protected:
    41 
    42     /** Constructs 2nd page base. */
    43     UIWizardImportAppPage2();
    44 
    45     /** Returns appliance widget instance. */
    46     ImportAppliancePointer applianceWidget() const { return m_pApplianceWidget; }
    47 
    48     /** Holds the appliance widget instance. */
    49     ImportAppliancePointer m_pApplianceWidget;
    50 };
    51 
    52 /** UIWizardPage extension for 2nd page of the Import Appliance wizard, extends UIWizardImportAppPage2 as well. */
    53 class UIWizardImportAppPageBasic2 : public UIWizardPage, public UIWizardImportAppPage2
    54 {
    55     Q_OBJECT;
    56     Q_PROPERTY(ImportAppliancePointer applianceWidget READ applianceWidget);
    57 
    58 public:
    59 
    60     /** Constructs 2nd basic page.
    61       * @param  strFileName  Brings appliance file name. */
    62     UIWizardImportAppPageBasic2(const QString &strFileName);
    63 
    64 private:
    65 
    66     /** Handles translation event. */
    67     virtual void retranslateUi() /* override */;
    68 
    69     /** Performs page initialization. */
    70     virtual void initializePage() /* override */;
    71     /** Performs page cleanup. */
    72     virtual void cleanupPage() /* override */;
    73 
    74     /** Performs page validation. */
    75     virtual bool validatePage() /* override */;
    76 
    77     /** Holds the label instance. */
    78     QIRichTextLabel *m_pLabel;
    79 
    80     /** Holds the signature/certificate info label instance. */
    81     QLabel *m_pCertLabel;
    82 
    83     /** Holds the certificate text template type. */
    84     enum {
    85         kCertText_Uninitialized = 0, kCertText_Unsigned,
    86         kCertText_IssuedTrusted,     kCertText_IssuedExpired,     kCertText_IssuedUnverified,
    87         kCertText_SelfSignedTrusted, kCertText_SelfSignedExpired, kCertText_SelfSignedUnverified
    88     } m_enmCertText;
    89 
    90     /** Holds the "signed by" information. */
    91     QString m_strSignedBy;
    92 };
    9332
    9433/** QIDialog extension
     
    10039public:
    10140
    102     /** Constructs appliance @a certificate viewer for passed @a pParent. */
     41    /** Constructs appliance @a comCertificate viewer for passed @a pParent. */
    10342    UIApplianceUnverifiedCertificateViewer(QWidget *pParent, const CCertificate &comCertificate);
    10443
     
    12261};
    12362
    124 #endif /* !FEQT_INCLUDED_SRC_wizards_importappliance_UIWizardImportAppPageBasic2_h */
     63#endif /* !FEQT_INCLUDED_SRC_wizards_importappliance_UIApplianceUnverifiedCertificateViewer_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic2.cpp

    r78037 r78110  
    1919#include <QLabel>
    2020#include <QPointer>
    21 #include <QPushButton>
    22 #include <QTextBrowser>
    2321#include <QVBoxLayout>
    2422
    2523/* GUI includes: */
    26 #include "QIDialogButtonBox.h"
    2724#include "QIRichTextLabel.h"
     25#include "UIApplianceUnverifiedCertificateViewer.h"
    2826#include "UIWizardImportApp.h"
    2927#include "UIWizardImportAppPageBasic2.h"
     
    217215    return fResult;
    218216}
    219 
    220 
    221 /*********************************************************************************************************************************
    222 *   Class UIApplianceUnverifiedCertificateViewer implementation.                                                                 *
    223 *********************************************************************************************************************************/
    224 
    225 UIApplianceUnverifiedCertificateViewer::UIApplianceUnverifiedCertificateViewer(QWidget *pParent, const CCertificate &comCertificate)
    226     : QIWithRetranslateUI<QIDialog>(pParent)
    227     , m_comCertificate(comCertificate)
    228     , m_pTextLabel(0)
    229     , m_pTextBrowser(0)
    230 {
    231     prepare();
    232 }
    233 
    234 void UIApplianceUnverifiedCertificateViewer::prepare()
    235 {
    236     /* Create layout: */
    237     QVBoxLayout *pLayout = new QVBoxLayout(this);
    238     if (pLayout)
    239     {
    240         /* Create text-label: */
    241         m_pTextLabel = new QLabel;
    242         if (m_pTextLabel)
    243         {
    244             m_pTextLabel->setWordWrap(true);
    245 
    246             /* Add into layout: */
    247             pLayout->addWidget(m_pTextLabel);
    248         }
    249 
    250         /* Create text-browser: */
    251         m_pTextBrowser = new QTextBrowser;
    252         if (m_pTextBrowser)
    253         {
    254             m_pTextBrowser->setMinimumSize(500, 300);
    255 
    256             /* Add into layout: */
    257             pLayout->addWidget(m_pTextBrowser);
    258         }
    259 
    260         /* Create button-box: */
    261         QIDialogButtonBox *pButtonBox = new QIDialogButtonBox;
    262         if (pButtonBox)
    263         {
    264             pButtonBox->setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No);
    265             pButtonBox->button(QDialogButtonBox::Yes)->setShortcut(Qt::Key_Enter);
    266             //pButtonBox->button(QDialogButtonBox::No)->setShortcut(Qt::Key_Esc);
    267             connect(pButtonBox, &QIDialogButtonBox::accepted, this, &UIApplianceUnverifiedCertificateViewer::accept);
    268             connect(pButtonBox, &QIDialogButtonBox::rejected, this, &UIApplianceUnverifiedCertificateViewer::reject);
    269 
    270             /* Add into layout: */
    271             pLayout->addWidget(pButtonBox);
    272         }
    273     }
    274 
    275     /* Translate UI: */
    276     retranslateUi();
    277 }
    278 
    279 void UIApplianceUnverifiedCertificateViewer::retranslateUi()
    280 {
    281     /* Translate dialog title: */
    282     setWindowTitle(tr("Unverifiable Certificate! Continue?"));
    283 
    284     /* Translate text-label caption: */
    285     if (m_comCertificate.GetSelfSigned())
    286         m_pTextLabel->setText(tr("<b>The appliance is signed by an unverified self signed certificate issued by '%1'. "
    287                                  "We recommend to only proceed with the importing if you are sure you should trust this entity.</b>"
    288                                  ).arg(m_comCertificate.GetFriendlyName()));
    289     else
    290         m_pTextLabel->setText(tr("<b>The appliance is signed by an unverified certificate issued to '%1'. "
    291                                  "We recommend to only proceed with the importing if you are sure you should trust this entity.</b>"
    292                                  ).arg(m_comCertificate.GetFriendlyName()));
    293 
    294     /* Translate text-browser contents: */
    295     const QString strTemplateRow = tr("<tr><td>%1:</td><td>%2</td></tr>", "key: value");
    296     QString strTableContent;
    297     strTableContent += strTemplateRow.arg(tr("Issuer"),               QStringList(m_comCertificate.GetIssuerName().toList()).join(", "));
    298     strTableContent += strTemplateRow.arg(tr("Subject"),              QStringList(m_comCertificate.GetSubjectName().toList()).join(", "));
    299     strTableContent += strTemplateRow.arg(tr("Not Valid Before"),     m_comCertificate.GetValidityPeriodNotBefore());
    300     strTableContent += strTemplateRow.arg(tr("Not Valid After"),      m_comCertificate.GetValidityPeriodNotAfter());
    301     strTableContent += strTemplateRow.arg(tr("Serial Number"),        m_comCertificate.GetSerialNumber());
    302     strTableContent += strTemplateRow.arg(tr("Self-Signed"),          m_comCertificate.GetSelfSigned() ? tr("True") : tr("False"));
    303     strTableContent += strTemplateRow.arg(tr("Authority (CA)"),       m_comCertificate.GetCertificateAuthority() ? tr("True") : tr("False"));
    304 //    strTableContent += strTemplateRow.arg(tr("Trusted"),              m_comCertificate.GetTrusted() ? tr("True") : tr("False"));
    305     strTableContent += strTemplateRow.arg(tr("Public Algorithm"),     tr("%1 (%2)", "value (clarification)").arg(m_comCertificate.GetPublicKeyAlgorithm()).arg(m_comCertificate.GetPublicKeyAlgorithmOID()));
    306     strTableContent += strTemplateRow.arg(tr("Signature Algorithm"),  tr("%1 (%2)", "value (clarification)").arg(m_comCertificate.GetSignatureAlgorithmName()).arg(m_comCertificate.GetSignatureAlgorithmOID()));
    307     strTableContent += strTemplateRow.arg(tr("X.509 Version Number"), QString::number(m_comCertificate.GetVersionNumber()));
    308     m_pTextBrowser->setText(QString("<table>%1</table>").arg(strTableContent));
    309 }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic2.h

    r78037 r78110  
    2323
    2424/* GUI includes: */
    25 #include "QIDialog.h"
    26 #include "QIWithRetranslateUI.h"
    2725#include "UIWizardImportAppDefs.h"
    2826#include "UIWizardPage.h"
     
    3028/* Forward declarations: */
    3129class QLabel;
    32 class QTextBrowser;
    33 class QDialogButtonBox;
    3430class QIRichTextLabel;
    35 class CCertificate;
    3631
    3732/** UIWizardPageBase extension for 2nd page of the Import Appliance wizard. */
     
    9287};
    9388
    94 /** QIDialog extension
    95   * asking for consent to continue with unverifiable certificate. */
    96 class UIApplianceUnverifiedCertificateViewer : public QIWithRetranslateUI<QIDialog>
    97 {
    98     Q_OBJECT;
    99 
    100 public:
    101 
    102     /** Constructs appliance @a certificate viewer for passed @a pParent. */
    103     UIApplianceUnverifiedCertificateViewer(QWidget *pParent, const CCertificate &comCertificate);
    104 
    105 protected:
    106 
    107     /** Prepares all. */
    108     void prepare();
    109 
    110     /** Handles translation event. */
    111     virtual void retranslateUi() /* override */;
    112 
    113 private:
    114 
    115     /** Holds the certificate reference. */
    116     const CCertificate &m_comCertificate;
    117 
    118     /** Holds the text-label instance. */
    119     QLabel       *m_pTextLabel;
    120     /** Holds the text-browser instance. */
    121     QTextBrowser *m_pTextBrowser;
    122 };
    123 
    12489#endif /* !FEQT_INCLUDED_SRC_wizards_importappliance_UIWizardImportAppPageBasic2_h */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette