Changeset 24557 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Nov 10, 2009 3:49:35 PM (15 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h
r24500 r24557 256 256 KStorageBus aBus, LONG aChannel, LONG aDevice); 257 257 258 void cannotMountMedium (QWidget *aParent, const CMachine &aMachine, const VBoxMedium &aMedium); 259 void cannotUnmountMedium (QWidget *aParent, const CMachine &aMachine, const VBoxMedium &aMedium); 258 int cannotRemountMedium (QWidget *aParent, const CMachine &aMachine, const VBoxMedium &aMedium, bool aMount, bool aRetry); 260 259 void cannotOpenMedium (QWidget *aParent, const CVirtualBox &aVBox, 261 260 VBoxDefs::MediumType aType, const QString &aLocation); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleWnd.cpp
r24511 r24557 198 198 struct MountTarget 199 199 { 200 MountTarget() : name (QString ("")), port (0), device (0), id (QString ("")), type (VBoxDefs::MediumType_Invalid) {}200 MountTarget() : name (QString ("")), port (0), device (0), id (QString()), type (VBoxDefs::MediumType_Invalid) {} 201 201 MountTarget (const QString &aName, LONG aPort, LONG aDevice) 202 : name (aName), port (aPort), device (aDevice), id (QString ("")), type (VBoxDefs::MediumType_Invalid) {}202 : name (aName), port (aPort), device (aDevice), id (QString()), type (VBoxDefs::MediumType_Invalid) {} 203 203 MountTarget (const QString &aName, LONG aPort, LONG aDevice, const QString &aId) 204 204 : name (aName), port (aPort), device (aDevice), id (aId), type (VBoxDefs::MediumType_Invalid) {} 205 MountTarget (const QString &aName, LONG aPort, LONG aDevice, const QString &aId,VBoxDefs::MediumType aType)206 : name (aName), port (aPort), device (aDevice), id ( aId), type (aType) {}205 MountTarget (const QString &aName, LONG aPort, LONG aDevice, VBoxDefs::MediumType aType) 206 : name (aName), port (aPort), device (aDevice), id (QString()), type (aType) {} 207 207 QString name; 208 208 LONG port; … … 327 327 *aSelf = this; 328 328 329 /* Cache IMedium data! */ 330 vboxGlobal().startEnumeratingMedia(); 331 329 332 #if !(defined (Q_WS_WIN) || defined (Q_WS_MAC)) 330 333 /* The default application icon (will change to the VM-specific icon in … … 1054 1057 1055 1058 if (!vbox.isOk()) 1056 return vboxProblem().cannotOpenMedium (this, vbox, 1057 VBoxDefs::MediumType_DVD, aSource); 1059 return vboxProblem().cannotOpenMedium (this, vbox, VBoxDefs::MediumType_DVD, aSource); 1058 1060 1059 1061 Assert (!uuid.isNull()); … … 1088 1090 if (!ctrName.isNull()) 1089 1091 { 1092 bool isMounted = false; 1093 1094 /* Mount medium to the predefined port/device */ 1090 1095 m.MountMedium (ctrName, ctrPort, ctrDevice, uuid, false /* force */); 1091 AssertWrapperOk (m);1092 1096 if (m.isOk()) 1093 { 1094 if (mIsAutoSaveMedia) 1097 isMounted = true; 1098 else 1099 { 1100 /* Ask for force mounting */ 1101 if (vboxProblem().cannotRemountMedium (this, m, VBoxMedium (image, VBoxDefs::MediumType_DVD), true /* mount? */, true /* retry? */) == QIMessageBox::Ok) 1095 1102 { 1096 m.SaveSettings(); 1097 if (!m.isOk()) 1098 vboxProblem().cannotSaveMachineSettings (m); 1103 /* Force mount medium to the predefined port/device */ 1104 m.MountMedium (ctrName, ctrPort, ctrDevice, uuid, true /* force */); 1105 if (m.isOk()) 1106 isMounted = true; 1107 else 1108 vboxProblem().cannotRemountMedium (this, m, VBoxMedium (image, VBoxDefs::MediumType_DVD), true /* mount? */, false /* retry? */); 1099 1109 } 1100 1110 } 1111 1112 /* Save medium mounted at runtime */ 1113 if (isMounted && mIsAutoSaveMedia) 1114 { 1115 m.SaveSettings(); 1116 if (!m.isOk()) 1117 vboxProblem().cannotSaveMachineSettings (m); 1118 } 1101 1119 } 1102 1120 else 1103 {1104 1121 vboxProblem().cannotMountGuestAdditions (m.GetName()); 1105 }1106 1122 } 1107 1123 … … 2270 2286 attachment.GetPort(), 2271 2287 attachment.GetDevice(), 2272 QString (""),2273 2288 mediumType))); 2274 2289 connect (callVMMAction, SIGNAL (triggered (bool)), this, SLOT (mountMedium())); … … 2344 2359 void VBoxConsoleWnd::mountMedium() 2345 2360 { 2361 /* Get sender action */ 2346 2362 QAction *action = qobject_cast <QAction*> (sender()); 2347 2363 Assert (action); 2348 2364 2365 /* Get current machine */ 2366 CMachine machine = mSession.GetMachine(); 2367 2368 /* Get mount-target */ 2349 2369 MountTarget target = action->data().value <MountTarget>(); 2350 CMachine machine = mSession.GetMachine(); 2351 CMediumAttachment attachment = machine.GetMediumAttachment (target.name, target.port, target.device); 2352 CMedium medium = attachment.GetMedium(); 2353 2354 if (target.type != VBoxDefs::MediumType_Invalid) 2370 2371 /* Current mount-target attributes */ 2372 CMediumAttachment currentAttachment = machine.GetMediumAttachment (target.name, target.port, target.device); 2373 CMedium currentMedium = currentAttachment.GetMedium(); 2374 QString currentId = currentMedium.isNull() ? QString ("") : currentMedium.GetId(); 2375 2376 /* New mount-target attributes */ 2377 QString newId = QString (""); 2378 bool selectWithMediaManager = target.type != VBoxDefs::MediumType_Invalid; 2379 2380 /* Open Virtual Media Manager to select image id */ 2381 if (selectWithMediaManager) 2355 2382 { 2356 2383 /* Search for already used images */ 2357 2384 QStringList usedImages; 2358 const CMediumAttachmentVector &attachments = mSession.GetMachine().GetMediumAttachments();2359 foreach (const CMediumAttachment &index, attachments)2360 {2361 if ( index != attachment && !index.GetMedium().isNull() && !index.GetMedium().GetHostDrive())2362 usedImages << index.GetMedium().GetId();2385 foreach (const CMediumAttachment &attachment, machine.GetMediumAttachments()) 2386 { 2387 CMedium medium = attachment.GetMedium(); 2388 if (attachment != currentAttachment && !medium.isNull() && !medium.GetHostDrive()) 2389 usedImages << medium.GetId(); 2363 2390 } 2364 2391 /* Open VMM Dialog */ 2365 2392 VBoxMediaManagerDlg dlg (this); 2366 dlg.setup (target.type, true /* do select? */, true /* do refresh? */, 2367 mSession.GetMachine(), QString(), true, usedImages); 2393 dlg.setup (target.type, true /* select? */, true /* refresh? */, machine, currentId, true, usedImages); 2368 2394 if (dlg.exec() == QDialog::Accepted) 2369 target.id = dlg.selectedId();2395 newId = dlg.selectedId(); 2370 2396 else return; 2371 2397 } 2372 2373 machine.MountMedium (target.name, target.port, target.device, 2374 target.id.isEmpty() || medium.isNull() || medium.GetId() != target.id || 2375 target.type != VBoxDefs::MediumType_Invalid ? target.id : QString (""), false /* force */); 2398 /* Use medium which was sent */ 2399 else if (!target.id.isNull() && target.id != currentId) 2400 newId = target.id; 2401 2402 bool mount = !newId.isEmpty(); 2403 2404 /* Remount medium to the predefined port/device */ 2405 machine.MountMedium (target.name, target.port, target.device, newId, false /* force */); 2406 if (!machine.isOk()) 2407 { 2408 /* Ask for force remounting */ 2409 if (vboxProblem().cannotRemountMedium (this, machine, vboxGlobal().findMedium (mount ? newId : currentId), mount, true /* retry? */) == QIMessageBox::Ok) 2410 { 2411 /* Force remount medium to the predefined port/device. */ 2412 machine.MountMedium (target.name, target.port, target.device, newId, true /* force */); 2413 if (!machine.isOk()) 2414 vboxProblem().cannotRemountMedium (this, machine, vboxGlobal().findMedium (mount ? newId : currentId), mount, false /* retry? */); 2415 } 2416 } 2376 2417 } 2377 2418 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp
r24511 r24557 1205 1205 if (!machine.isOk()) 1206 1206 { 1207 CStorageController controller = machine.GetStorageControllerByName (attachment.GetController()); 1208 vboxProblem().cannotUnmountMedium (this, machine, aMedium); 1207 vboxProblem().cannotRemountMedium (this, machine, aMedium, false /* mount? */, false /* retry? */); 1209 1208 success = false; 1210 1209 break; … … 1227 1226 if (!machine.isOk()) 1228 1227 { 1229 CStorageController controller = machine.GetStorageControllerByName (attachment.GetController()); 1230 vboxProblem().cannotUnmountMedium (this, machine, aMedium); 1228 vboxProblem().cannotRemountMedium (this, machine, aMedium, false /* mount? */, false /* retry? */); 1231 1229 success = false; 1232 1230 break; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp
r24500 r24557 1187 1187 } 1188 1188 1189 void VBoxProblemReporter::cannotMountMedium (QWidget *aParent, const CMachine &aMachine,1190 const VBoxMedium &aMedium)1189 int VBoxProblemReporter::cannotRemountMedium (QWidget *aParent, const CMachine &aMachine, 1190 const VBoxMedium &aMedium, bool aMount, bool aRetry) 1191 1191 { 1192 1192 /** @todo (translation-related): the gender of "the" in translations 1193 1193 * will depend on the gender of aMedium.type(). */ 1194 message (aParent, Error, 1195 tr ("Failed to mount the %1 <nobr><b>%2</b></nobr> " 1196 "to the machine <b>%3</b>.") 1197 .arg (mediumToAccusative (aMedium.type(), aMedium.isHostDrive())) 1198 .arg (aMedium.isHostDrive() ? aMedium.name() : aMedium.location()) 1199 .arg (CMachine (aMachine).GetName()), 1200 formatErrorInfo (aMachine)); 1201 } 1202 1203 void VBoxProblemReporter::cannotUnmountMedium (QWidget *aParent, const CMachine &aMachine, 1204 const VBoxMedium &aMedium) 1205 { 1206 /** @todo (translation-related): the gender of "the" in translations 1207 * will depend on the gender of aMedium.type(). */ 1208 message (aParent, Error, 1209 tr ("Failed to unmount the %1 <nobr><b>%2</b></nobr> " 1210 "from the machine <b>%3</b>.") 1211 .arg (mediumToAccusative (aMedium.type(), aMedium.isHostDrive())) 1212 .arg (aMedium.isHostDrive() ? aMedium.name() : aMedium.location()) 1213 .arg (CMachine (aMachine).GetName()), 1214 formatErrorInfo (aMachine)); 1194 QString text; 1195 if (aMount) 1196 { 1197 text = tr ("Unable to mount the %1 <nobr><b>%2</b></nobr> to the machine <b>%3</b>."); 1198 if (aRetry) text += tr (" Would you like to forcedly mount this medium?"); 1199 } 1200 else 1201 { 1202 text = tr ("Unable to unmount the %1 <nobr><b>%2</b></nobr> from the machine <b>%3</b>."); 1203 if (aRetry) text += tr (" Would you like to forcedly unmount this medium?"); 1204 } 1205 if (aRetry) 1206 { 1207 return messageOkCancel (aParent, Question, text 1208 .arg (mediumToAccusative (aMedium.type(), aMedium.isHostDrive())) 1209 .arg (aMedium.isHostDrive() ? aMedium.name() : aMedium.location()) 1210 .arg (CMachine (aMachine).GetName()), 1211 formatErrorInfo (aMachine), 1212 0 /* Auto Confirm ID */, 1213 tr ("Force Unmount")); 1214 } 1215 else 1216 { 1217 return message (aParent, Error, text 1218 .arg (mediumToAccusative (aMedium.type(), aMedium.isHostDrive())) 1219 .arg (aMedium.isHostDrive() ? aMedium.name() : aMedium.location()) 1220 .arg (CMachine (aMachine).GetName()), 1221 formatErrorInfo (aMachine)); 1222 } 1215 1223 } 1216 1224 -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMFirstRunWzd.cpp
r24493 r24557 110 110 QIAbstractWizard::accept(); 111 111 else 112 vboxProblem().cannot MountMedium (this, mMachine, vboxGlobal().findMedium (mCbMedia->id()));112 vboxProblem().cannotRemountMedium (this, mMachine, vboxGlobal().findMedium (mCbMedia->id()), true /* mount? */, false /* retry? */); 113 113 } 114 114
Note:
See TracChangeset
for help on using the changeset viewer.