Changeset 85425 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jul 23, 2020 10:31:35 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 139468
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r85412 r85425 26 26 #include <QStatusBar> 27 27 #include <QTextEdit> 28 #ifndef VBOX_WS_WIN 29 # include <QRegExp> 30 #endif 28 31 29 32 /* GUI includes: */ … … 1237 1240 void UIVirtualBoxManager::sltExecuteExternalApplication() 1238 1241 { 1239 /* Acquire passed path and argument : */1242 /* Acquire passed path and argument strings: */ 1240 1243 QAction *pAction = qobject_cast<QAction*>(sender()); 1241 1244 AssertMsgReturnVoid(pAction, ("This slot should be called by action only!\n")); 1242 1245 const QString strPath = pAction->property("path").toString(); 1243 QStringList arguments = pAction->property("arguments").toString().split(' ');1246 const QString strArguments = pAction->property("arguments").toString(); 1244 1247 1245 1248 /* Get current-item: */ … … 1249 1252 AssertPtrReturnVoid(pCloudItem); 1250 1253 1251 /* Add serial command to arguments: */1254 /* Get cloud machine to acquire serial command: */ 1252 1255 const CCloudMachine comMachine = pCloudItem->machine(); 1256 1253 1257 #ifdef VBOX_WS_WIN 1258 /* Gather arguments: */ 1259 QStringList arguments; 1260 arguments << strArguments; 1254 1261 arguments << comMachine.GetSerialConsoleCommandWindows(); 1255 #else 1262 1263 /* Execute console application finally: */ 1264 QProcess::startDetached(QString("%1 %2").arg(strPath, arguments.join(' '))); 1265 #else /* !VBOX_WS_WIN */ 1266 /* Gather arguments: */ 1267 QStringList arguments; 1268 arguments << parseShellArguments(strArguments); 1256 1269 arguments << comMachine.GetSerialConsoleCommand(); 1257 #endif1258 1270 1259 1271 /* Execute console application finally: */ 1260 1272 QProcess::startDetached(strPath, arguments); 1273 #endif /* !VBOX_WS_WIN */ 1261 1274 } 1262 1275 … … 2440 2453 } 2441 2454 2455 #ifndef VBOX_WS_WIN 2456 QStringList UIVirtualBoxManager::parseShellArguments(const QString &strArguments) 2457 { 2458 //printf("start processing arguments\n"); 2459 2460 /* Parse argument string: */ 2461 QStringList arguments; 2462 QRegExp re("(\"[^\"]+\")|('[^']+')|([^\\s\"']+)"); 2463 int iPosition = 0; 2464 int iIndex = re.indexIn(strArguments, iPosition); 2465 while (iIndex != -1) 2466 { 2467 /* Get what's the sequence we have: */ 2468 const QString strCap0 = re.cap(0); 2469 /* Get what's the double-quoted sequence we have: */ 2470 const QString strCap1 = re.cap(1); 2471 /* Get what's the single-quoted sequence we have: */ 2472 const QString strCap2 = re.cap(2); 2473 /* Get what's the unquoted sequence we have: */ 2474 const QString strCap3 = re.cap(3); 2475 2476 /* If new sequence starts where previous ended 2477 * we are appending new value to previous one, otherwise 2478 * we are appending new value to argument list itself.. */ 2479 2480 /* Do we have double-quoted sequence? */ 2481 if (!strCap1.isEmpty()) 2482 { 2483 //printf(" [D] double-quoted sequence starting at: %d\n", iIndex); 2484 /* Unquote the value and add it to the list: */ 2485 const QString strValue = strCap1.mid(1, strCap1.size() - 2); 2486 if (!arguments.isEmpty() && iIndex == iPosition) 2487 arguments.last() += strValue; 2488 else 2489 arguments << strValue; 2490 } 2491 /* Do we have single-quoted sequence? */ 2492 else if (!strCap2.isEmpty()) 2493 { 2494 //printf(" [S] single-quoted sequence starting at: %d\n", iIndex); 2495 /* Unquote the value and add it to the list: */ 2496 const QString strValue = strCap2.mid(1, strCap2.size() - 2); 2497 if (!arguments.isEmpty() && iIndex == iPosition) 2498 arguments.last() += strValue; 2499 else 2500 arguments << strValue; 2501 } 2502 /* Do we have unquoted sequence? */ 2503 else if (!strCap3.isEmpty()) 2504 { 2505 //printf(" [U] unquoted sequence starting at: %d\n", iIndex); 2506 /* Value wasn't unquoted, add it to the list: */ 2507 if (!arguments.isEmpty() && iIndex == iPosition) 2508 arguments.last() += strCap3; 2509 else 2510 arguments << strCap3; 2511 } 2512 2513 /* Advance position: */ 2514 iPosition = iIndex + strCap0.size(); 2515 /* Search for a next sequence: */ 2516 iIndex = re.indexIn(strArguments, iPosition); 2517 } 2518 2519 //printf("arguments processed:\n"); 2520 //foreach (const QString &strArgument, arguments) 2521 // printf(" %s\n", strArgument.toUtf8().constData()); 2522 2523 /* Return parsed arguments: */ 2524 return arguments; 2525 } 2526 #endif /* !VBOX_WS_WIN */ 2527 2442 2528 void UIVirtualBoxManager::updateMenuGroup(QMenu *pMenu) 2443 2529 { -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h
r85396 r85425 360 360 /** @} */ 361 361 362 /** @name V M add stuff.362 /** @name Various VM helpers. 363 363 * @{ */ 364 364 /** Opens add machine dialog specifying initial name with @a strFileName. */ 365 365 void openAddMachineDialog(const QString &strFileName = QString()); 366 /** Creates an uattended installer and uses that to install guest os to newly created vm. */ 366 367 /** Creates an unattended installer and uses it to install guest os to newly created vm. */ 367 368 void startUnattendedInstall(CUnattended &comUnattendedInstaller, const UIUnattendedInstallData &unattendedData); 368 /** @} */ 369 370 /** @name VM launching stuff. 371 * @{ */ 369 372 370 /** Launches or shows virtual machines represented by passed @a items in corresponding @a enmLaunchMode (for launch). */ 373 371 void performStartOrShowVirtualMachines(const QList<UIVirtualMachineItem*> &items, UICommon::LaunchMode enmLaunchMode); 372 373 #ifndef VBOX_WS_WIN 374 /** Parses serialized @a strArguments string according to shell rules. */ 375 QStringList parseShellArguments(const QString &strArguments); 376 #endif 374 377 /** @} */ 375 378
Note:
See TracChangeset
for help on using the changeset viewer.