- Timestamp:
- Feb 15, 2018 1:50:20 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlInterface.cpp
r71019 r71021 32 32 33 33 34 #define SUCCESS_RETURN(strMessage){ \35 emit sigOutputString(strMessage); \36 return true; \37 }38 39 #define ERROR_RETURN(strMessage){ \40 emit sigOutputString(strMessage); \41 return false; \42 }43 44 34 #define GCTLCMD_COMMON_OPT_USER 999 /**< The --username option number. */ 45 35 #define GCTLCMD_COMMON_OPT_PASSWORD 998 /**< The --password option number. */ … … 57 47 { "--verbose", 'v', RTGETOPT_REQ_NOTHING }, 58 48 59 60 /** Common option definitions. */ 49 #define HANDLE_COMMON_OPTION_DEFS() \ 50 case GCTLCMD_COMMON_OPT_USER: \ 51 commandData.m_strUserName = ValueUnion.psz; \ 52 break; \ 53 case GCTLCMD_COMMON_OPT_PASSWORD: \ 54 commandData.m_strPassword = ValueUnion.psz; \ 55 break; 56 57 QString generateErrorString(int getOptErrorCode, const RTGETOPTUNION &valueUnion) 58 { 59 QString errorString; 60 if(valueUnion.pDef) 61 { 62 if(valueUnion.pDef->pszLong) 63 { 64 errorString = QString(valueUnion.pDef->pszLong); 65 } 66 } 67 68 switch (getOptErrorCode) 69 { 70 case (VERR_GETOPT_UNKNOWN_OPTION): 71 errorString = errorString.append("RTGetOpt: Command line option not recognized."); 72 break; 73 case (VERR_GETOPT_REQUIRED_ARGUMENT_MISSING): 74 errorString = errorString.append("RTGetOpt: Command line option needs argument."); 75 break; 76 case (VERR_GETOPT_INVALID_ARGUMENT_FORMAT): 77 errorString = errorString.append("RTGetOpt: Command line option has argument with bad format."); 78 break; 79 case (VINF_GETOPT_NOT_OPTION): 80 errorString = errorString.append("RTGetOpt: Not an option."); 81 break; 82 case (VERR_GETOPT_INDEX_MISSING): 83 errorString = errorString.append("RTGetOpt: Command line option needs an index."); 84 break; 85 default: 86 break; 87 } 88 return errorString; 89 } 90 91 /** Common option definitions: */ 61 92 class CommandData 62 93 { … … 106 137 107 138 CommandData commandData; 108 parseCommonOptions(argc, argv, commandData);139 //parseCommonOptions(argc, argv, commandData); 109 140 110 141 static const RTGETOPTDEF s_aOptions[] = 111 142 { 143 GCTLCMD_COMMON_OPTION_DEFS() 112 144 { "--sessionname", GCTLCMD_COMMON_OPT_SESSION_NAME, RTGETOPT_REQ_STRING }, 113 145 { "--sessionid", GCTLCMD_COMMON_OPT_SESSION_ID, RTGETOPT_REQ_UINT32 }, … … 127 159 RTGETOPTUNION ValueUnion; 128 160 RTGETOPTSTATE GetState; 129 RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 0, 0);161 RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1 /* ignore 0th element (command) */, 0); 130 162 while ((ch = RTGetOpt(&GetState, &ValueUnion))) 131 163 { 132 164 switch (ch) 133 165 { 166 HANDLE_COMMON_OPTION_DEFS() 134 167 case GCTLCMD_COMMON_OPT_SESSION_NAME: 135 168 sessionNameGiven = true; … … 144 177 break; 145 178 default: 146 break; 179 { 180 emit sigOutputString(generateErrorString(ch, ValueUnion)); 181 return false; 182 printf("hoppala %d\n", ch); 183 break; 184 } 147 185 } 148 186 } … … 150 188 if (sessionNameGiven && commandData.m_strSessionName.isEmpty()) 151 189 { 152 emit sigOutputString(QString( "'Session Name' is not name valid\n").append(m_strHelp));190 emit sigOutputString(QString(m_strHelp).append("'Session Name' is not name valid\n")); 153 191 return false; 154 192 } … … 158 196 if (sessionIdGiven && sessionNameGiven) 159 197 { 160 emit sigOutputString(QString( "Both 'Session Name' and 'Session Id' are supplied\n").append(m_strHelp));198 emit sigOutputString(QString(m_strHelp).append("Both 'Session Name' and 'Session Id' are supplied\n")); 161 199 return false; 162 200 } … … 166 204 if (!findSession(commandData.m_uSessionId, guestSession)) 167 205 { 168 emit sigOutputString(QString( "No session with id %1 found.\n").arg(commandData.m_uSessionId).append(m_strHelp));206 emit sigOutputString(QString(m_strHelp).append("No session with id %1 found.\n").arg(commandData.m_uSessionId)); 169 207 return false; 170 208 } … … 207 245 { 208 246 CommandData commandData; 209 if (!parseCommonOptions(argc, argv, commandData))210 return false;211 247 212 248 static const RTGETOPTDEF s_aOptions[] = … … 223 259 switch (ch) 224 260 { 261 HANDLE_COMMON_OPTION_DEFS() 225 262 case GCTLCMD_COMMON_OPT_SESSION_NAME: 226 263 commandData.m_strSessionName = ValueUnion.psz; … … 238 275 if (!createSession(commandData, guestSession)) 239 276 return false; 240 return true;241 }242 243 bool UIGuestControlInterface::parseCommonOptions(int argc, char** argv, CommandData& commandData)244 {245 static const RTGETOPTDEF s_aOptions[] =246 {247 { "--username", GCTLCMD_COMMON_OPT_USER, RTGETOPT_REQ_STRING },248 { "--passwordfile", GCTLCMD_COMMON_OPT_PASSWORD_FILE, RTGETOPT_REQ_STRING },249 { "--password", GCTLCMD_COMMON_OPT_PASSWORD, RTGETOPT_REQ_STRING },250 { "--domain", GCTLCMD_COMMON_OPT_DOMAIN, RTGETOPT_REQ_STRING },251 { "--quiet", 'q', RTGETOPT_REQ_NOTHING },252 { "--verbose", 'v', RTGETOPT_REQ_NOTHING },253 };254 255 256 int ch;257 RTGETOPTUNION ValueUnion;258 RTGETOPTSTATE GetState;259 RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 0, 0);260 while ((ch = RTGetOpt(&GetState, &ValueUnion)))261 {262 switch (ch)263 {264 /* Username: */265 case GCTLCMD_COMMON_OPT_USER:266 commandData.m_strUserName = ValueUnion.psz;267 break;268 /* Paaword: */269 case GCTLCMD_COMMON_OPT_PASSWORD:270 commandData.m_strPassword = ValueUnion.psz;271 break;272 default:273 break;274 }275 }276 277 277 return true; 278 278 } … … 341 341 else 342 342 { 343 emit sigOutputString(QString( "Unknown Command '%1'\n").arg(ValueUnion.psz).append(m_strHelp));343 emit sigOutputString(QString(m_strHelp).append("\nSyntax Error. Unknown Command '%1'").arg(ValueUnion.psz)); 344 344 RTGetOptArgvFree(argv); 345 345 return; … … 398 398 } 399 399 /* Wait session to start: */ 400 const ULONG waitTimeout = 1;//2000;400 const ULONG waitTimeout = 2000; 401 401 KGuestSessionWaitResult waitResult = guestSession.WaitFor(KGuestSessionWaitForFlag_Start, waitTimeout); 402 402 if (waitResult != KGuestSessionWaitResult_Start) -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIGuestControlInterface.h
r71016 r71021 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI InformationConfigurationclass declaration.3 * VBox Qt GUI - UIGuestControlInterface class declaration. 4 4 */ 5 5 … … 66 66 /* Handles the 'create' session command */ 67 67 bool handleCreate(int, char**); 68 bool parseCommonOptions(int argc, char** argv, CommandData& commandData); 68 69 69 70 70 CGuest m_comGuest; -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/information/guestctrl/UIInformationGuestSession.h
r70998 r71021 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIInformation Configuration class declaration.3 * VBox Qt GUI - UIInformationGuestSession class declaration. 4 4 */ 5 5
Note:
See TracChangeset
for help on using the changeset viewer.