Changeset 71138 in vbox
- Timestamp:
- Feb 27, 2018 2:58:24 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 121025
- 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 70 70 commandData.m_strPassword = ValueUnion.psz; \ 71 71 break; 72 73 QString 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 }; 72 116 73 117 QString generateErrorString(int getOptErrorCode, const RTGETOPTUNION &/*valueUnion*/) … … 143 187 " [-P|--parents] [<guest directory>\n" 144 188 " [--sessionid <id> | [sessionname <name>]]\n" 145 " stat[common-options]\n"189 "[stat|ls [common-options]\n" 146 190 " [--sessionid <id> | [sessionname <name>]]\n" 147 191 ) … … 274 318 if (!findOrCreateSession(commandData, guestSession) || !guestSession.isOk()) 275 319 return false; 320 if (guestSession.GetStatus() != KGuestSessionStatus_Started) 321 RETURN_ERROR("The guest session is not valid"); 276 322 277 323 bool isADirectory = … … 385 431 } 386 432 } 433 /* search within the existing CGuestSessions and return a valid one if found: */ 434 if (findAValidGuestSession(outGuestSession)) 435 return true; 387 436 /* if neither sessionname and session id is given then create a new session */ 388 437 else … … 392 441 } 393 442 return true; 443 } 444 445 bool 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; 394 460 } 395 461 … … 462 528 m_subCommandHandlers.insert("mkdir" , &UIGuestControlInterface::handleMkdir); 463 529 m_subCommandHandlers.insert("stat" , &UIGuestControlInterface::handleStat); 530 m_subCommandHandlers.insert("ls" , &UIGuestControlInterface::handleStat); 464 531 } 465 532 … … 552 619 bool UIGuestControlInterface::createSession(const CommandData &commandData, CGuestSession& outSession) 553 620 { 621 if (!m_comGuest.isOk()) 622 return false; 623 if(commandData.m_strUserName.isEmpty()) 624 RETURN_ERROR("No user name has been given"); 554 625 CGuestSession guestSession = m_comGuest.CreateSession(commandData.m_strUserName, 555 626 commandData.m_strPassword, … … 575 646 if (!fsObjectInfo.isOk()) 576 647 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())); 582 653 583 654 return strInfo; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlInterface.h
r71135 r71138 58 58 /** findOrCreateSession parses command options and determines if an existing session 59 59 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); 61 63 bool findSession(const QString& strSessionName, CGuestSession& outSession); 62 64 bool findSession(ULONG strSessionId, CGuestSession& outSession);
Note:
See TracChangeset
for help on using the changeset viewer.