VirtualBox

Changeset 86845 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Nov 10, 2020 11:11:14 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9722: VirtualBox Manager: A bit of validation for public key loading stuff.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r86817 r86845  
    10351035}
    10361036
    1037 void UIMessageCenter::cannotOpenPublicKeyFile(const QString &strPath, QWidget *pParent /* = 0 */) const
     1037void UIMessageCenter::cannotCreateConsoleConnection(const CCloudMachine &comMachine, QWidget *pParent /* = 0 */)
     1038{
     1039    error(pParent, MessageType_Error,
     1040          tr("Failed to create console connection for cloud machine <b>%1</b>.")
     1041             .arg(CCloudMachine(comMachine).GetName()),
     1042          UIErrorString::formatErrorInfo(comMachine));
     1043}
     1044
     1045void UIMessageCenter::cannotCreateConsoleConnection(const CProgress &comProgress, const QString &strMachineName, QWidget *pParent /* = 0 */)
     1046{
     1047    error(pParent, MessageType_Error,
     1048          tr("Failed to create console connection for cloud machine <b>%1</b>.")
     1049             .arg(strMachineName),
     1050          UIErrorString::formatErrorInfo(comProgress));
     1051}
     1052
     1053void UIMessageCenter::cannotDeleteConsoleConnection(const CCloudMachine &comMachine, QWidget *pParent /* = 0 */)
     1054{
     1055    error(pParent, MessageType_Error,
     1056          tr("Failed to delete console connection for cloud machine <b>%1</b>.")
     1057             .arg(CCloudMachine(comMachine).GetName()),
     1058          UIErrorString::formatErrorInfo(comMachine));
     1059}
     1060
     1061void UIMessageCenter::cannotDeleteConsoleConnection(const CProgress &comProgress, const QString &strMachineName, QWidget *pParent /* = 0 */)
     1062{
     1063    error(pParent, MessageType_Error,
     1064          tr("Failed to delete console connection for cloud machine <b>%1</b>.")
     1065             .arg(strMachineName),
     1066          UIErrorString::formatErrorInfo(comProgress));
     1067}
     1068
     1069void UIMessageCenter::publicKeyFilePathIsEmpty(QWidget *pParent /* = 0 */) const
     1070{
     1071    alert(pParent, MessageType_Error,
     1072          tr("Public key file path is empty."));
     1073}
     1074
     1075void UIMessageCenter::publicKeyFileIsntReadable(const QString &strPath, QWidget *pParent /* = 0 */) const
    10381076{
    10391077    alert(pParent, MessageType_Error,
    10401078          tr("Failed to open the public key file <nobr><b>%1</b></nobr>. Check file permissions.")
    10411079             .arg(strPath));
    1042 }
    1043 
    1044 void UIMessageCenter::cannotCreateConsoleConnection(const CCloudMachine &comMachine, QWidget *pParent /* = 0 */)
    1045 {
    1046     error(pParent, MessageType_Error,
    1047           tr("Failed to create console connection for cloud machine <b>%1</b>.")
    1048              .arg(CCloudMachine(comMachine).GetName()),
    1049           UIErrorString::formatErrorInfo(comMachine));
    1050 }
    1051 
    1052 void UIMessageCenter::cannotCreateConsoleConnection(const CProgress &comProgress, const QString &strMachineName, QWidget *pParent /* = 0 */)
    1053 {
    1054     error(pParent, MessageType_Error,
    1055           tr("Failed to create console connection for cloud machine <b>%1</b>.")
    1056              .arg(strMachineName),
    1057           UIErrorString::formatErrorInfo(comProgress));
    1058 }
    1059 
    1060 void UIMessageCenter::cannotDeleteConsoleConnection(const CCloudMachine &comMachine, QWidget *pParent /* = 0 */)
    1061 {
    1062     error(pParent, MessageType_Error,
    1063           tr("Failed to delete console connection for cloud machine <b>%1</b>.")
    1064              .arg(CCloudMachine(comMachine).GetName()),
    1065           UIErrorString::formatErrorInfo(comMachine));
    1066 }
    1067 
    1068 void UIMessageCenter::cannotDeleteConsoleConnection(const CProgress &comProgress, const QString &strMachineName, QWidget *pParent /* = 0 */)
    1069 {
    1070     error(pParent, MessageType_Error,
    1071           tr("Failed to delete console connection for cloud machine <b>%1</b>.")
    1072              .arg(strMachineName),
    1073           UIErrorString::formatErrorInfo(comProgress));
    10741080}
    10751081
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r86776 r86845  
    305305    void cannotMoveMachine(const CMachine &machine, QWidget *pParent = 0) const;
    306306    void cannotMoveMachine(const CProgress &progress, const QString &strMachineName, QWidget *pParent = 0) const;
    307     void cannotOpenPublicKeyFile(const QString &strPath, QWidget *pParent = 0) const;
    308307    void cannotCreateConsoleConnection(const CCloudMachine &comMachine, QWidget *pParent = 0);
    309308    void cannotCreateConsoleConnection(const CProgress &comProgress, const QString &strMachineName, QWidget *pParent = 0);
    310309    void cannotDeleteConsoleConnection(const CCloudMachine &comMachine, QWidget *pParent = 0);
    311310    void cannotDeleteConsoleConnection(const CProgress &comProgress, const QString &strMachineName, QWidget *pParent = 0);
     311    void publicKeyFilePathIsEmpty(QWidget *pParent = 0) const;
     312    void publicKeyFileIsntReadable(const QString &strPath, QWidget *pParent = 0) const;
    312313
    313314    /* API: Snapshot warnings: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r86734 r86845  
    136136    void prepare();
    137137
    138     /** Loads file contents. */
    139     void loadFileContents(const QString &strPath, bool fIgnoreErrors = false);
     138    /** Loads file contents.
     139      * @returns Whether file was really loaded. */
     140    bool loadFileContents(const QString &strPath, bool fIgnoreErrors = false);
    140141
    141142    /** Holds the text-editor instance. */
     
    235236}
    236237
    237 void UIAcquirePublicKeyDialog::loadFileContents(const QString &strPath, bool fIgnoreErrors /* = false */)
    238 {
     238bool UIAcquirePublicKeyDialog::loadFileContents(const QString &strPath, bool fIgnoreErrors /* = false */)
     239{
     240    /* Make sure file path isn't empty: */
    239241    if (strPath.isEmpty())
    240         return;
     242    {
     243        if (!fIgnoreErrors)
     244            msgCenter().publicKeyFilePathIsEmpty();
     245        return false;
     246    }
     247
     248    /* Make sure file can be opened: */
    241249    QFile file(strPath);
    242     if (file.open(QIODevice::ReadOnly))
    243         m_pTextEditor->setPlainText(file.readAll());
    244     else if (!fIgnoreErrors)
    245         msgCenter().cannotOpenPublicKeyFile(strPath);
     250    if (!file.open(QIODevice::ReadOnly))
     251    {
     252        if (!fIgnoreErrors)
     253            msgCenter().publicKeyFileIsntReadable(strPath);
     254        return false;
     255    }
     256
     257    /* File opened and read, filling editor: */
     258    m_pTextEditor->setPlainText(file.readAll());
     259    return true;
    246260}
    247261
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