VirtualBox

Changeset 71138 in vbox


Ignore:
Timestamp:
Feb 27, 2018 2:58:24 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
121025
Message:

FE/Qt bugref:66099 Improvements on guest control 'stat' handling

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlInterface.cpp

    r71135 r71138  
    7070        commandData.m_strPassword = ValueUnion.psz;   \
    7171        break;
     72
     73QString getFsObjTypeString(KFsObjType type)
     74{
     75    QString strType;
     76    switch(type)
     77    {
     78        case (KFsObjType_Unknown):
     79            strType = "Unknown";
     80            break;
     81    case (KFsObjType_Fifo):
     82        strType = "Fifo";
     83        break;
     84
     85    case (KFsObjType_DevChar):
     86        strType = "DevChar";
     87        break;
     88
     89    case (KFsObjType_Directory):
     90        strType = "Directory";
     91        break;
     92
     93    case (KFsObjType_DevBlock):
     94        strType = "DevBlock";
     95        break;
     96
     97    case (KFsObjType_File):
     98        strType = "File";
     99        break;
     100    case (KFsObjType_Symlink):
     101        strType = "Symlink";
     102        break;
     103    case (KFsObjType_Socket):
     104        strType = "Socket";
     105        break;
     106
     107    case (KFsObjType_WhiteOut):
     108        strType = "WhiteOut";
     109        break;
     110    default:
     111        strType = "Unknown";
     112        break;
     113    }
     114    return strType;
     115};
    72116
    73117QString generateErrorString(int getOptErrorCode, const RTGETOPTUNION &/*valueUnion*/)
     
    143187                "                                   [-P|--parents] [<guest directory>\n"
    144188                "                                   [--sessionid <id> |  [sessionname <name>]]\n"
    145                 "stat                            [common-options]\n"
     189                "[stat|ls                          [common-options]\n"
    146190                "                                   [--sessionid <id> |  [sessionname <name>]]\n"
    147191                )
     
    274318    if (!findOrCreateSession(commandData, guestSession) || !guestSession.isOk())
    275319        return false;
     320    if (guestSession.GetStatus() != KGuestSessionStatus_Started)
     321        RETURN_ERROR("The guest session is not valid");
    276322
    277323    bool isADirectory =
     
    385431        }
    386432    }
     433    /* search within the existing CGuestSessions and return a valid one if found: */
     434    if (findAValidGuestSession(outGuestSession))
     435        return true;
    387436    /* if neither sessionname and session id is given then create a new session */
    388437    else
     
    392441    }
    393442    return true;
     443}
     444
     445bool UIGuestControlInterface::findAValidGuestSession(CGuestSession &outGuestSession)
     446{
     447    if (!m_comGuest.isOk())
     448        return false;
     449
     450    QVector<CGuestSession> sessions = m_comGuest.GetSessions();
     451    for(int i = 0; i < sessions.size(); ++i)
     452    {
     453        if (sessions[i].isOk() && sessions[i].GetStatus() == KGuestSessionStatus_Started)
     454        {
     455            outGuestSession = sessions[i];
     456            return true;
     457        }
     458    }
     459    return false;
    394460}
    395461
     
    462528    m_subCommandHandlers.insert("mkdir" , &UIGuestControlInterface::handleMkdir);
    463529    m_subCommandHandlers.insert("stat" , &UIGuestControlInterface::handleStat);
     530    m_subCommandHandlers.insert("ls" , &UIGuestControlInterface::handleStat);
    464531}
    465532
     
    552619bool UIGuestControlInterface::createSession(const CommandData &commandData, CGuestSession& outSession)
    553620{
     621    if (!m_comGuest.isOk())
     622        return false;
     623    if(commandData.m_strUserName.isEmpty())
     624        RETURN_ERROR("No user name has been given");
    554625    CGuestSession guestSession = m_comGuest.CreateSession(commandData.m_strUserName,
    555626                                                          commandData.m_strPassword,
     
    575646    if (!fsObjectInfo.isOk())
    576647        return strInfo;
    577     strInfo.append(QString("Name %1 \n").arg(fsObjectInfo.GetName()));
    578     strInfo.append(QString("Size %1 \n").arg(fsObjectInfo.GetObjectSize()));
    579     strInfo.append(QString("User %1 \n").arg(fsObjectInfo.GetUserName()));
    580     strInfo.append(QString("BirthTime %1 \n").arg(fsObjectInfo.GetBirthTime()));
    581     strInfo.append(QString("ChangeTime %1 ").arg(fsObjectInfo.GetChangeTime()));
     648    strInfo.append(QString("%1 \t").arg(fsObjectInfo.GetName()));
     649    strInfo.append(QString("%1 \t").arg(getFsObjTypeString(fsObjectInfo.GetType())));
     650    strInfo.append(QString("%1 \t").arg(fsObjectInfo.GetObjectSize()));
     651    strInfo.append(QString("%1 \t").arg(fsObjectInfo.GetBirthTime()));
     652    strInfo.append(QString("%1 ").arg(fsObjectInfo.GetChangeTime()));
    582653
    583654    return strInfo;
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlInterface.h

    r71135 r71138  
    5858    /** findOrCreateSession parses command options and determines if an existing session
    5959        to be returned or a new one to be created */
    60     bool findOrCreateSession(const CommandData &commandData, CGuestSession &guestSession);
     60    bool findOrCreateSession(const CommandData &commandData, CGuestSession &outGuestSession);
     61    /* Search a valid gurst session among existing ones, assign @p outGuestSession if found and return true */
     62    bool findAValidGuestSession(CGuestSession &outGuestSession);
    6163    bool findSession(const QString& strSessionName, CGuestSession& outSession);
    6264    bool findSession(ULONG strSessionId, CGuestSession& outSession);
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