VirtualBox

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


Ignore:
Timestamp:
Nov 16, 2020 3:15:56 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
141365
Message:

FE/Qt: bugref:9722: VirtualBox Manager: Move a list of default public key folders to a separate function; Also, more readable file loading call, a check which will be reused.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r86860 r86894  
    140140    void prepareEditorContents();
    141141
     142    /** Returns a list of default key folders. */
     143    QStringList defaultKeyFolders() const;
     144
    142145    /** Loads file contents.
    143146      * @returns Whether file was really loaded. */
     
    246249void UIAcquirePublicKeyDialog::prepareEditorContents()
    247250{
     251    /* Check whether we were able to load key file: */
     252    bool fFileLoaded = false;
     253
    248254    /* Try to load last remembered file contents: */
    249     if (!loadFileContents(gEDataManager->cloudConsolePublicKeyPath(), true /* ignore errors */))
     255    fFileLoaded = loadFileContents(gEDataManager->cloudConsolePublicKeyPath(), true /* ignore errors */);
     256    if (!fFileLoaded)
    250257    {
    251258        /* We have failed to load file mentioned in extra-data, now we have
    252259         * to check whether file present in one of default paths: */
    253         QStringList paths;
    254 #ifdef VBOX_WS_WIN
    255         // WORKAROUND:
    256         // There is additional default path on Windows:
    257         paths << QDir(QDir::homePath()).absoluteFilePath("oci");
    258 #endif
    259         paths << QDir(QDir::homePath()).absoluteFilePath(".ssh");
    260 
    261         /* Look for required file in one of those paths: */
    262260        QString strAbsoluteFilePathWeNeed;
    263         foreach (const QString &strPath, paths)
     261        foreach (const QString &strPath, defaultKeyFolders())
    264262        {
    265263            /* Gather possible file names, there can be few of them: */
     
    284282        /* Try to open file if it was really found: */
    285283        if (!strAbsoluteFilePathWeNeed.isEmpty())
    286             loadFileContents(strAbsoluteFilePathWeNeed, true /* ignore errors */);
    287     }
     284            fFileLoaded = loadFileContents(strAbsoluteFilePathWeNeed, true /* ignore errors */);
     285    }
     286}
     287
     288QStringList UIAcquirePublicKeyDialog::defaultKeyFolders() const
     289{
     290    QStringList folders;
     291#ifdef VBOX_WS_WIN
     292    // WORKAROUND:
     293    // There is additional default folder on Windows:
     294    folders << QDir::toNativeSeparators(QDir(QDir::homePath()).absoluteFilePath("oci"));
     295#endif
     296    folders << QDir::toNativeSeparators(QDir(QDir::homePath()).absoluteFilePath(".ssh"));
     297    return folders;
    288298}
    289299
Note: See TracChangeset for help on using the changeset viewer.

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