VirtualBox

Changeset 60420 in vbox


Ignore:
Timestamp:
Apr 11, 2016 11:00:18 AM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8249: Moving some code to appropriate place according to r106412, s.a. r106505.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic2.cpp

    r60419 r60420  
    3737
    3838#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     39
     40
     41/*********************************************************************************************************************************
     42*   Class UIWizardImportAppPage2 implementation.                                                                                 *
     43*********************************************************************************************************************************/
     44
     45UIWizardImportAppPage2::UIWizardImportAppPage2()
     46{
     47}
     48
     49
     50/*********************************************************************************************************************************
     51*   Class UIWizardImportAppPageBasic2 implementation.                                                                            *
     52*********************************************************************************************************************************/
     53
     54UIWizardImportAppPageBasic2::UIWizardImportAppPageBasic2(const QString &strFileName)
     55    : m_enmCertText(kCertText_Uninitialized)
     56{
     57    /* Create widgets: */
     58    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     59    {
     60        m_pLabel = new QIRichTextLabel(this);
     61        m_pApplianceWidget = new UIApplianceImportEditorWidget(this);
     62        {
     63            m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
     64            m_pApplianceWidget->setFile(strFileName);
     65        }
     66        m_pCertLabel = new QLabel("<cert label>", this);
     67        pMainLayout->addWidget(m_pLabel);
     68        pMainLayout->addWidget(m_pApplianceWidget);
     69        pMainLayout->addWidget(m_pCertLabel);
     70    }
     71
     72    /* Register classes: */
     73    qRegisterMetaType<ImportAppliancePointer>();
     74    /* Register fields: */
     75    registerField("applianceWidget", this, "applianceWidget");
     76}
     77
     78void UIWizardImportAppPageBasic2::retranslateUi()
     79{
     80    /* Translate page: */
     81    setTitle(UIWizardImportApp::tr("Appliance settings"));
     82
     83    /* Translate widgets: */
     84    m_pLabel->setText(UIWizardImportApp::tr("These are the virtual machines contained in the appliance "
     85                                            "and the suggested settings of the imported VirtualBox machines. "
     86                                            "You can change many of the properties shown by double-clicking "
     87                                            "on the items and disable others using the check boxes below."));
     88    switch (m_enmCertText)
     89    {
     90        case kCertText_Unsigned:
     91            m_pCertLabel->setText(UIWizardImportApp::tr("Appliance is not signed"));
     92            break;
     93        case kCertText_IssuedTrusted:
     94            m_pCertLabel->setText(UIWizardImportApp::tr("Appliance signed by %1 (trusted)").arg(m_strSignedBy));
     95            break;
     96        case kCertText_IssuedExpired:
     97            m_pCertLabel->setText(UIWizardImportApp::tr("Appliance signed by %1 (expired!)").arg(m_strSignedBy));
     98            break;
     99        case kCertText_IssuedUnverified:
     100            m_pCertLabel->setText(UIWizardImportApp::tr("Unverified signature by %1!").arg(m_strSignedBy));
     101            break;
     102        case kCertText_SelfSignedTrusted:
     103            m_pCertLabel->setText(UIWizardImportApp::tr("Self signed by %1 (trusted)").arg(m_strSignedBy));
     104            break;
     105        case kCertText_SelfSignedExpired:
     106            m_pCertLabel->setText(UIWizardImportApp::tr("Self signed by %1 (expired!)").arg(m_strSignedBy));
     107            break;
     108        case kCertText_SelfSignedUnverified:
     109            m_pCertLabel->setText(UIWizardImportApp::tr("Unverified self signed signature by %1!").arg(m_strSignedBy));
     110            break;
     111        default:
     112            AssertFailed();
     113        case kCertText_Uninitialized:
     114            m_pCertLabel->setText("<uninitialized page>");
     115            break;
     116    }
     117}
     118
     119void UIWizardImportAppPageBasic2::initializePage()
     120{
     121    /* Acquire appliance and certificate: */
     122    CAppliance *pAppliance = m_pApplianceWidget->appliance();
     123    CCertificate certificate = pAppliance->GetCertificate();
     124    if (certificate.isNull())
     125        m_enmCertText = kCertText_Unsigned;
     126    else
     127    {
     128        /* Pick a 'signed-by' name. */
     129        m_strSignedBy = certificate.GetFriendlyName();
     130
     131        /* If trusted, just select the right message: */
     132        if (certificate.GetTrusted())
     133        {
     134            if (certificate.GetSelfSigned())
     135                m_enmCertText = !certificate.GetExpired() ? kCertText_SelfSignedTrusted : kCertText_SelfSignedExpired;
     136            else
     137                m_enmCertText = !certificate.GetExpired() ? kCertText_IssuedTrusted     : kCertText_IssuedExpired;
     138        }
     139        else
     140        {
     141            /* Not trusted!  Must ask the user whether to continue in this case: */
     142            m_enmCertText = !certificate.GetExpired() ? kCertText_SelfSignedUnverified : kCertText_SelfSignedUnverified;
     143
     144            /* Translate page early: */
     145            retranslateUi();
     146
     147            /* Instantiate the dialog: */
     148            QPointer<UIApplianceUnverifiedCertificateViewer> pDialog = new UIApplianceUnverifiedCertificateViewer(this, certificate);
     149            AssertPtrReturnVoid(pDialog.data());
     150
     151            /* Show viewer in modal mode: */
     152            int iResultCode = pDialog->exec();
     153
     154            /* Leave if destroyed prematurely: */
     155            if (!pDialog)
     156                return;
     157            /* Delete viewer: */
     158            if (pDialog)
     159            {
     160                delete pDialog;
     161                pDialog = 0;
     162            }
     163
     164            /* Dismiss the entire import-appliance wizard if user rejects certificate: */
     165            if (iResultCode == QDialog::Rejected)
     166                wizard()->reject();
     167        }
     168    }
     169
     170    /* Translate page: */
     171    retranslateUi();
     172}
     173
     174void UIWizardImportAppPageBasic2::cleanupPage()
     175{
     176    /* Rollback settings: */
     177    m_pApplianceWidget->restoreDefaults();
     178    /* Call to base-class: */
     179    UIWizardPage::cleanupPage();
     180}
     181
     182bool UIWizardImportAppPageBasic2::validatePage()
     183{
     184    /* Initial result: */
     185    bool fResult = true;
     186
     187    /* Lock finish button: */
     188    startProcessing();
     189
     190    /* Try to import appliance: */
     191    if (fResult)
     192        fResult = qobject_cast<UIWizardImportApp*>(wizard())->importAppliance();
     193
     194    /* Unlock finish button: */
     195    endProcessing();
     196
     197    /* Return result: */
     198    return fResult;
     199}
    39200
    40201
     
    129290}
    130291
    131 
    132 /*********************************************************************************************************************************
    133 *   Class UIWizardImportAppPage2 implementation.                                                                                 *
    134 *********************************************************************************************************************************/
    135 
    136 UIWizardImportAppPage2::UIWizardImportAppPage2()
    137 {
    138 }
    139 
    140 
    141 /*********************************************************************************************************************************
    142 *   Class UIWizardImportAppPageBasic2 implementation.                                                                            *
    143 *********************************************************************************************************************************/
    144 
    145 UIWizardImportAppPageBasic2::UIWizardImportAppPageBasic2(const QString &strFileName)
    146     : m_enmCertText(kCertText_Uninitialized)
    147 {
    148     /* Create widgets: */
    149     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    150     {
    151         m_pLabel = new QIRichTextLabel(this);
    152         m_pApplianceWidget = new UIApplianceImportEditorWidget(this);
    153         {
    154             m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
    155             m_pApplianceWidget->setFile(strFileName);
    156         }
    157         m_pCertLabel = new QLabel("<cert label>", this);
    158         pMainLayout->addWidget(m_pLabel);
    159         pMainLayout->addWidget(m_pApplianceWidget);
    160         pMainLayout->addWidget(m_pCertLabel);
    161     }
    162 
    163     /* Register classes: */
    164     qRegisterMetaType<ImportAppliancePointer>();
    165     /* Register fields: */
    166     registerField("applianceWidget", this, "applianceWidget");
    167 }
    168 
    169 void UIWizardImportAppPageBasic2::retranslateUi()
    170 {
    171     /* Translate page: */
    172     setTitle(UIWizardImportApp::tr("Appliance settings"));
    173 
    174     /* Translate widgets: */
    175     m_pLabel->setText(UIWizardImportApp::tr("These are the virtual machines contained in the appliance "
    176                                             "and the suggested settings of the imported VirtualBox machines. "
    177                                             "You can change many of the properties shown by double-clicking "
    178                                             "on the items and disable others using the check boxes below."));
    179     switch (m_enmCertText)
    180     {
    181         case kCertText_Unsigned:
    182             m_pCertLabel->setText(UIWizardImportApp::tr("Appliance is not signed"));
    183             break;
    184         case kCertText_IssuedTrusted:
    185             m_pCertLabel->setText(UIWizardImportApp::tr("Appliance signed by %1 (trusted)").arg(m_strSignedBy));
    186             break;
    187         case kCertText_IssuedExpired:
    188             m_pCertLabel->setText(UIWizardImportApp::tr("Appliance signed by %1 (expired!)").arg(m_strSignedBy));
    189             break;
    190         case kCertText_IssuedUnverified:
    191             m_pCertLabel->setText(UIWizardImportApp::tr("Unverified signature by %1!").arg(m_strSignedBy));
    192             break;
    193         case kCertText_SelfSignedTrusted:
    194             m_pCertLabel->setText(UIWizardImportApp::tr("Self signed by %1 (trusted)").arg(m_strSignedBy));
    195             break;
    196         case kCertText_SelfSignedExpired:
    197             m_pCertLabel->setText(UIWizardImportApp::tr("Self signed by %1 (expired!)").arg(m_strSignedBy));
    198             break;
    199         case kCertText_SelfSignedUnverified:
    200             m_pCertLabel->setText(UIWizardImportApp::tr("Unverified self signed signature by %1!").arg(m_strSignedBy));
    201             break;
    202         default:
    203             AssertFailed();
    204         case kCertText_Uninitialized:
    205             m_pCertLabel->setText("<uninitialized page>");
    206             break;
    207     }
    208 }
    209 
    210 void UIWizardImportAppPageBasic2::initializePage()
    211 {
    212     /* Acquire appliance and certificate: */
    213     CAppliance *pAppliance = m_pApplianceWidget->appliance();
    214     CCertificate certificate = pAppliance->GetCertificate();
    215     if (certificate.isNull())
    216         m_enmCertText = kCertText_Unsigned;
    217     else
    218     {
    219         /* Pick a 'signed-by' name. */
    220         m_strSignedBy = certificate.GetFriendlyName();
    221 
    222         /* If trusted, just select the right message: */
    223         if (certificate.GetTrusted())
    224         {
    225             if (certificate.GetSelfSigned())
    226                 m_enmCertText = !certificate.GetExpired() ? kCertText_SelfSignedTrusted : kCertText_SelfSignedExpired;
    227             else
    228                 m_enmCertText = !certificate.GetExpired() ? kCertText_IssuedTrusted     : kCertText_IssuedExpired;
    229         }
    230         else
    231         {
    232             /* Not trusted!  Must ask the user whether to continue in this case: */
    233             m_enmCertText = !certificate.GetExpired() ? kCertText_SelfSignedUnverified : kCertText_SelfSignedUnverified;
    234 
    235             /* Translate page early: */
    236             retranslateUi();
    237 
    238             /* Instantiate the dialog: */
    239             QPointer<UIApplianceUnverifiedCertificateViewer> pDialog = new UIApplianceUnverifiedCertificateViewer(this, certificate);
    240             AssertPtrReturnVoid(pDialog.data());
    241 
    242             /* Show viewer in modal mode: */
    243             int iResultCode = pDialog->exec();
    244 
    245             /* Leave if destroyed prematurely: */
    246             if (!pDialog)
    247                 return;
    248             /* Delete viewer: */
    249             if (pDialog)
    250             {
    251                 delete pDialog;
    252                 pDialog = 0;
    253             }
    254 
    255             /* Dismiss the entire import-appliance wizard if user rejects certificate: */
    256             if (iResultCode == QDialog::Rejected)
    257                 wizard()->reject();
    258         }
    259     }
    260 
    261     /* Translate page: */
    262     retranslateUi();
    263 }
    264 
    265 void UIWizardImportAppPageBasic2::cleanupPage()
    266 {
    267     /* Rollback settings: */
    268     m_pApplianceWidget->restoreDefaults();
    269     /* Call to base-class: */
    270     UIWizardPage::cleanupPage();
    271 }
    272 
    273 bool UIWizardImportAppPageBasic2::validatePage()
    274 {
    275     /* Initial result: */
    276     bool fResult = true;
    277 
    278     /* Lock finish button: */
    279     startProcessing();
    280 
    281     /* Try to import appliance: */
    282     if (fResult)
    283         fResult = qobject_cast<UIWizardImportApp*>(wizard())->importAppliance();
    284 
    285     /* Unlock finish button: */
    286     endProcessing();
    287 
    288     /* Return result: */
    289     return fResult;
    290 }
    291 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic2.h

    r60419 r60420  
    112112};
    113113
    114 
    115114#endif /* !___UIWizardImportAppPageBasic2_h___ */
    116115
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