VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp@ 34329

Last change on this file since 34329 was 34329, checked in by vboxsync, 14 years ago

FE/Qt: Machine settings / Storage page: Rework for 5370.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 110.2 KB
Line 
1/* $Id: VBoxProblemReporter.cpp 34329 2010-11-24 15:18:40Z vboxsync $ */
2/** @file
3 *
4 * VBox frontends: Qt GUI ("VirtualBox"):
5 * VBoxProblemReporter class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2010 Oracle Corporation
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 */
19
20#include "VBoxProblemReporter.h"
21
22#include "VBoxGlobal.h"
23#include "VBoxSelectorWnd.h"
24#include "VBoxProgressDialog.h"
25#include "UIDownloaderUserManual.h"
26#include "UIMachine.h"
27
28#include "VBoxAboutDlg.h"
29
30#include "QIHotKeyEdit.h"
31
32#ifdef Q_WS_MAC
33# include "VBoxUtils-darwin.h"
34#endif
35
36/* Qt includes */
37#include <QDir>
38#include <QDesktopWidget>
39#include <QFileInfo>
40#ifdef Q_WS_MAC
41# include <QPushButton>
42#endif
43
44#include <iprt/err.h>
45#include <iprt/param.h>
46#include <iprt/path.h>
47
48#if defined (Q_WS_WIN32)
49#include <Htmlhelp.h>
50#endif
51
52////////////////////////////////////////////////////////////////////////////////
53// VBoxProblemReporter class
54////////////////////////////////////////////////////////////////////////////////
55
56/**
57 * Returns a reference to the global VirtualBox problem reporter instance.
58 */
59VBoxProblemReporter &VBoxProblemReporter::instance()
60{
61 static VBoxProblemReporter vboxProblem_instance;
62 return vboxProblem_instance;
63}
64
65bool VBoxProblemReporter::isValid() const
66{
67 return qApp != 0;
68}
69
70// Helpers
71/////////////////////////////////////////////////////////////////////////////
72
73bool VBoxProblemReporter::isAnyWarningShown()
74{
75 /* Check if at least one warning is alive!
76 * All warnings are stored in m_warnings list as live pointers,
77 * this is why if some warning was deleted from another place,
78 * its pointer here will equal NULL... */
79 for (int i = 0; i < m_warnings.size(); ++i)
80 if (m_warnings[i])
81 return true;
82 return false;
83}
84
85bool VBoxProblemReporter::isAlreadyShown(const QString &strWarningName) const
86{
87 return m_shownWarnings.contains(strWarningName);
88}
89
90void VBoxProblemReporter::setShownStatus(const QString &strWarningName)
91{
92 if (!m_shownWarnings.contains(strWarningName))
93 m_shownWarnings.append(strWarningName);
94}
95
96void VBoxProblemReporter::clearShownStatus(const QString &strWarningName)
97{
98 if (m_shownWarnings.contains(strWarningName))
99 m_shownWarnings.removeAll(strWarningName);
100}
101
102void VBoxProblemReporter::closeAllWarnings()
103{
104 /* Broadcast signal to perform emergent
105 * closing + deleting all the opened warnings. */
106 emit sigToCloseAllWarnings();
107}
108
109/**
110 * Shows a message box of the given type with the given text and with buttons
111 * according to arguments b1, b2 and b3 (in the same way as QMessageBox does
112 * it), and returns the user's choice.
113 *
114 * When all button arguments are zero, a single 'Ok' button is shown.
115 *
116 * If aAutoConfirmId is not null, then the message box will contain a
117 * checkbox "Don't show this message again" below the message text and its
118 * state will be saved in the global config. When the checkbox is in the
119 * checked state, this method doesn't actually show the message box but
120 * returns immediately. The return value in this case is the same as if the
121 * user has pressed the Enter key or the default button, but with
122 * AutoConfirmed bit set (AutoConfirmed alone is returned when no default
123 * button is defined in button arguments).
124 *
125 * @param aParent
126 * Parent widget or 0 to use the desktop as the parent. Also,
127 * #mainWindowShown can be used to determine the currently shown VBox
128 * main window (Selector or Console).
129 * @param aType
130 * One of values of the Type enum, that defines the message box
131 * title and icon.
132 * @param aMessage
133 * Message text to display (can contain simple Qt-html tags).
134 * @param aDetails
135 * Detailed message description displayed under the main message text using
136 * QTextEdit (that provides rich text support and scrollbars when necessary).
137 * If equals to QString::null, no details text box is shown.
138 * @param aAutoConfirmId
139 * ID used to save the auto confirmation state across calls. If null,
140 * the auto confirmation feature is turned off (and no checkbox is shown)
141 * @param aButton1
142 * First button code or 0, see QIMessageBox for a list of codes.
143 * @param aButton2
144 * Second button code or 0, see QIMessageBox for a list of codes.
145 * @param aButton3
146 * Third button code or 0, see QIMessageBox for a list of codes.
147 * @param aText1
148 * Optional custom text for the first button.
149 * @param aText2
150 * Optional custom text for the second button.
151 * @param aText3
152 * Optional custom text for the third button.
153 *
154 * @return
155 * code of the button pressed by the user
156 */
157int VBoxProblemReporter::message (QWidget *aParent, Type aType, const QString &aMessage,
158 const QString &aDetails /* = QString::null */,
159 const char *aAutoConfirmId /* = 0 */,
160 int aButton1 /* = 0 */, int aButton2 /* = 0 */,
161 int aButton3 /* = 0 */,
162 const QString &aText1 /* = QString::null */,
163 const QString &aText2 /* = QString::null */,
164 const QString &aText3 /* = QString::null */) const
165{
166 if (aButton1 == 0 && aButton2 == 0 && aButton3 == 0)
167 aButton1 = QIMessageBox::Ok | QIMessageBox::Default;
168
169 CVirtualBox vbox;
170 QStringList msgs;
171
172 if (aAutoConfirmId)
173 {
174 vbox = vboxGlobal().virtualBox();
175 msgs = vbox.GetExtraData (VBoxDefs::GUI_SuppressMessages).split (',');
176 if (msgs.contains (aAutoConfirmId)) {
177 int rc = AutoConfirmed;
178 if (aButton1 & QIMessageBox::Default)
179 rc |= (aButton1 & QIMessageBox::ButtonMask);
180 if (aButton2 & QIMessageBox::Default)
181 rc |= (aButton2 & QIMessageBox::ButtonMask);
182 if (aButton3 & QIMessageBox::Default)
183 rc |= (aButton3 & QIMessageBox::ButtonMask);
184 return rc;
185 }
186 }
187
188 QString title;
189 QIMessageBox::Icon icon;
190
191 switch (aType)
192 {
193 default:
194 case Info:
195 title = tr ("VirtualBox - Information", "msg box title");
196 icon = QIMessageBox::Information;
197 break;
198 case Question:
199 title = tr ("VirtualBox - Question", "msg box title");
200 icon = QIMessageBox::Question;
201 break;
202 case Warning:
203 title = tr ("VirtualBox - Warning", "msg box title");
204 icon = QIMessageBox::Warning;
205 break;
206 case Error:
207 title = tr ("VirtualBox - Error", "msg box title");
208 icon = QIMessageBox::Critical;
209 break;
210 case Critical:
211 title = tr ("VirtualBox - Critical Error", "msg box title");
212 icon = QIMessageBox::Critical;
213 break;
214 case GuruMeditation:
215 title = "VirtualBox - Guru Meditation"; /* don't translate this */
216 icon = QIMessageBox::GuruMeditation;
217 break;
218 }
219
220 QPointer<QIMessageBox> box = new QIMessageBox (title, aMessage, icon, aButton1, aButton2,
221 aButton3, aParent, aAutoConfirmId);
222 connect(this, SIGNAL(sigToCloseAllWarnings()), box, SLOT(deleteLater()));
223
224 if (!aText1.isNull())
225 box->setButtonText (0, aText1);
226 if (!aText2.isNull())
227 box->setButtonText (1, aText2);
228 if (!aText3.isNull())
229 box->setButtonText (2, aText3);
230
231 if (!aDetails.isEmpty())
232 box->setDetailsText (aDetails);
233
234 if (aAutoConfirmId)
235 {
236 box->setFlagText (tr ("Do not show this message again", "msg box flag"));
237 box->setFlagChecked (false);
238 }
239
240 m_warnings << box;
241 int rc = box->exec();
242 if (box && m_warnings.contains(box))
243 m_warnings.removeAll(box);
244
245 if (aAutoConfirmId)
246 {
247 if (box && box->isFlagChecked())
248 {
249 msgs << aAutoConfirmId;
250 vbox.SetExtraData (VBoxDefs::GUI_SuppressMessages, msgs.join (","));
251 }
252 }
253
254 if (box)
255 delete box;
256
257 return rc;
258}
259
260/** @fn message (QWidget *, Type, const QString &, const char *, int, int,
261 * int, const QString &, const QString &, const QString &)
262 *
263 * A shortcut to #message() that doesn't require to specify the details
264 * text (QString::null is assumed).
265 */
266
267/** @fn messageYesNo (QWidget *, Type, const QString &, const QString &, const char *)
268 *
269 * A shortcut to #message() that shows 'Yes' and 'No' buttons ('Yes' is the
270 * default) and returns true when the user selects Yes.
271 */
272
273/** @fn messageYesNo (QWidget *, Type, const QString &, const char *)
274 *
275 * A shortcut to #messageYesNo() that doesn't require to specify the details
276 * text (QString::null is assumed).
277 */
278
279/**
280 * Shows a modal progress dialog using a CProgress object passed as an
281 * argument to track the progress.
282 *
283 * @param aProgress progress object to track
284 * @param aTitle title prefix
285 * @param aParent parent widget
286 * @param aMinDuration time (ms) that must pass before the dialog appears
287 */
288bool VBoxProblemReporter::showModalProgressDialog (
289 CProgress &aProgress, const QString &aTitle, QWidget *aParent,
290 int aMinDuration)
291{
292 VBoxProgressDialog progressDlg (aProgress, aTitle, aMinDuration, aParent ? aParent : mainWindowShown());
293
294 /* Run the dialog with the 350 ms refresh interval. */
295 progressDlg.run (350);
296
297 return true;
298}
299
300/**
301 * Returns what main window (VM selector or main VM window) is now shown, or
302 * zero if none of them. Main VM window takes precedence.
303 */
304QWidget* VBoxProblemReporter::mainWindowShown() const
305{
306 /* It may happen that this method is called during VBoxGlobal
307 * initialization or even after it failed (for example, to show some
308 * error message). Return no main window in this case: */
309 if (!vboxGlobal().isValid())
310 return 0;
311
312 if (vboxGlobal().isVMConsoleProcess())
313 {
314 if (vboxGlobal().vmWindow() && vboxGlobal().vmWindow()->isVisible()) /* VM window is visible */
315 return vboxGlobal().vmWindow(); /* return that window */
316 }
317 else
318 {
319 if (vboxGlobal().selectorWnd().isVisible()) /* VM selector is visible */
320 return &vboxGlobal().selectorWnd(); /* return that window */
321 }
322
323 return 0;
324}
325
326/**
327 * Returns main machine window is now shown, or zero if none of them.
328 */
329QWidget* VBoxProblemReporter::mainMachineWindowShown() const
330{
331 /* It may happen that this method is called during VBoxGlobal
332 * initialization or even after it failed (for example, to show some
333 * error message). Return no main window in this case: */
334 if (!vboxGlobal().isValid())
335 return 0;
336
337 if (vboxGlobal().vmWindow() && vboxGlobal().vmWindow()->isVisible()) /* VM window is visible */
338 return vboxGlobal().vmWindow(); /* return that window */
339
340 return 0;
341}
342
343// Generic Problem handlers
344/////////////////////////////////////////////////////////////////////////////
345
346bool VBoxProblemReporter::askForOverridingFile (const QString& aPath, QWidget *aParent /* = NULL */) const
347{
348 return messageYesNo (aParent, Question, tr ("A file named <b>%1</b> already exists. Are you sure you want to replace it?<br /><br />Replacing it will overwrite its contents.").arg (aPath));
349}
350
351bool VBoxProblemReporter::askForOverridingFiles (const QVector<QString>& aPaths, QWidget *aParent /* = NULL */) const
352{
353 if (aPaths.size() == 1)
354 /* If it is only one file use the single question versions above */
355 return askForOverridingFile (aPaths.at (0), aParent);
356 else if (aPaths.size() > 1)
357 return messageYesNo (aParent, Question, tr ("The following files already exist:<br /><br />%1<br /><br />Are you sure you want to replace them? Replacing them will overwrite their contents.").arg (QStringList(aPaths.toList()).join ("<br />")));
358 else
359 return true;
360}
361
362bool VBoxProblemReporter::askForOverridingFileIfExists (const QString& aPath, QWidget *aParent /* = NULL */) const
363{
364 QFileInfo fi (aPath);
365 if (fi.exists())
366 return askForOverridingFile (aPath, aParent);
367 else
368 return true;
369}
370
371bool VBoxProblemReporter::askForOverridingFilesIfExists (const QVector<QString>& aPaths, QWidget *aParent /* = NULL */) const
372{
373 QVector<QString> existingFiles;
374 foreach (const QString &file, aPaths)
375 {
376 QFileInfo fi (file);
377 if (fi.exists())
378 existingFiles << fi.absoluteFilePath();
379 }
380 if (existingFiles.size() == 1)
381 /* If it is only one file use the single question versions above */
382 return askForOverridingFileIfExists (existingFiles.at (0), aParent);
383 else if (existingFiles.size() > 1)
384 return askForOverridingFiles (existingFiles, aParent);
385 else
386 return true;
387}
388
389void VBoxProblemReporter::cannotDeleteFile (const QString& path, QWidget *aParent /* = NULL */) const
390{
391 message (aParent, Error,
392 tr ("Failed to remove the file <b>%1</b>.<br /><br />Please try to remove the file yourself and try again.")
393 .arg (path));
394}
395
396void VBoxProblemReporter::checkForMountedWrongUSB() const
397{
398#ifdef RT_OS_LINUX
399 QFile file ("/proc/mounts");
400 if (file.exists() && file.open (QIODevice::ReadOnly | QIODevice::Text))
401 {
402 QStringList contents;
403 for (;;)
404 {
405 QByteArray line = file.readLine();
406 if (line.isEmpty())
407 break;
408 contents << line;
409 }
410 QStringList grep1 (contents.filter ("/sys/bus/usb/drivers"));
411 QStringList grep2 (grep1.filter ("usbfs"));
412 if (!grep2.isEmpty())
413 message (mainWindowShown(), Warning,
414 tr ("You seem to have the USBFS filesystem mounted at /sys/bus/usb/drivers. "
415 "We strongly recommend that you change this, as it is a severe mis-configuration of "
416 "your system which could cause USB devices to fail in unexpected ways."),
417 "checkForMountedWrongUSB");
418 }
419#endif
420}
421
422// Special Problem handlers
423/////////////////////////////////////////////////////////////////////////////
424
425void VBoxProblemReporter::showBETAWarning()
426{
427 message
428 (0, Warning,
429 tr ("You are running a prerelease version of VirtualBox. "
430 "This version is not suitable for production use."));
431}
432
433void VBoxProblemReporter::showBEBWarning()
434{
435 message
436 (0, Warning,
437 tr ("You are running an EXPERIMENTAL build of VirtualBox. "
438 "This version is not suitable for production use."));
439}
440
441#ifdef Q_WS_X11
442void VBoxProblemReporter::cannotFindLicenseFiles (const QString &aPath)
443{
444 message
445 (0, VBoxProblemReporter::Error,
446 tr ("Failed to find license files in "
447 "<nobr><b>%1</b></nobr>.")
448 .arg (aPath));
449}
450
451void VBoxProblemReporter::cannotOpenLicenseFile (QWidget *aParent,
452 const QString &aPath)
453{
454 message
455 (aParent, VBoxProblemReporter::Error,
456 tr ("Failed to open the license file <nobr><b>%1</b></nobr>. "
457 "Check file permissions.")
458 .arg (aPath));
459}
460#endif
461
462void VBoxProblemReporter::cannotOpenURL (const QString &aURL)
463{
464 message
465 (mainWindowShown(), VBoxProblemReporter::Error,
466 tr ("Failed to open <tt>%1</tt>. Make sure your desktop environment "
467 "can properly handle URLs of this type.")
468 .arg (aURL));
469}
470
471void VBoxProblemReporter::
472cannotCopyFile (const QString &aSrc, const QString &aDst, int aVRC)
473{
474 PCRTSTATUSMSG msg = RTErrGet (aVRC);
475 Assert (msg);
476
477 QString err = QString ("%1: %2").arg (msg->pszDefine, msg->pszMsgShort);
478 if (err.endsWith ("."))
479 err.truncate (err.length() - 1);
480
481 message (mainWindowShown(), VBoxProblemReporter::Error,
482 tr ("Failed to copy file <b><nobr>%1</nobr></b> to "
483 "<b><nobr>%2</nobr></b> (%3).")
484 .arg (aSrc, aDst, err));
485}
486
487void VBoxProblemReporter::cannotFindLanguage (const QString &aLangID,
488 const QString &aNlsPath)
489{
490 message (0, VBoxProblemReporter::Error,
491 tr ("<p>Could not find a language file for the language "
492 "<b>%1</b> in the directory <b><nobr>%2</nobr></b>.</p>"
493 "<p>The language will be temporarily reset to the system "
494 "default language. Please go to the <b>Preferences</b> "
495 "dialog which you can open from the <b>File</b> menu of the "
496 "main VirtualBox window, and select one of the existing "
497 "languages on the <b>Language</b> page.</p>")
498 .arg (aLangID).arg (aNlsPath));
499}
500
501void VBoxProblemReporter::cannotLoadLanguage (const QString &aLangFile)
502{
503 message (0, VBoxProblemReporter::Error,
504 tr ("<p>Could not load the language file <b><nobr>%1</nobr></b>. "
505 "<p>The language will be temporarily reset to English (built-in). "
506 "Please go to the <b>Preferences</b> "
507 "dialog which you can open from the <b>File</b> menu of the "
508 "main VirtualBox window, and select one of the existing "
509 "languages on the <b>Language</b> page.</p>")
510 .arg (aLangFile));
511}
512
513void VBoxProblemReporter::cannotInitCOM (HRESULT rc)
514{
515 message (0, Critical,
516 tr ("<p>Failed to initialize COM or to find the VirtualBox COM server. "
517 "Most likely, the VirtualBox server is not running "
518 "or failed to start.</p>"
519 "<p>The application will now terminate.</p>"),
520 formatErrorInfo (COMErrorInfo(), rc));
521}
522
523void VBoxProblemReporter::cannotCreateVirtualBox (const CVirtualBox &vbox)
524{
525 message (0, Critical,
526 tr ("<p>Failed to create the VirtualBox COM object.</p>"
527 "<p>The application will now terminate.</p>"),
528 formatErrorInfo (vbox));
529}
530
531void VBoxProblemReporter::cannotSaveGlobalSettings (const CVirtualBox &vbox,
532 QWidget *parent /* = 0 */)
533{
534 /* preserve the current error info before calling the object again */
535 COMResult res (vbox);
536
537 message (parent ? parent : mainWindowShown(), Error,
538 tr ("<p>Failed to save the global VirtualBox settings to "
539 "<b><nobr>%1</nobr></b>.</p>")
540 .arg (vbox.GetSettingsFilePath()),
541 formatErrorInfo (res));
542}
543
544void VBoxProblemReporter::cannotLoadGlobalConfig (const CVirtualBox &vbox,
545 const QString &error)
546{
547 /* preserve the current error info before calling the object again */
548 COMResult res (vbox);
549
550 message (mainWindowShown(), Critical,
551 tr ("<p>Failed to load the global GUI configuration from "
552 "<b><nobr>%1</nobr></b>.</p>"
553 "<p>The application will now terminate.</p>")
554 .arg (vbox.GetSettingsFilePath()),
555 !res.isOk() ? formatErrorInfo (res)
556 : QString ("<!--EOM--><p>%1</p>").arg (vboxGlobal().emphasize (error)));
557}
558
559void VBoxProblemReporter::cannotSaveGlobalConfig (const CVirtualBox &vbox)
560{
561 /* preserve the current error info before calling the object again */
562 COMResult res (vbox);
563
564 message (mainWindowShown(), Critical,
565 tr ("<p>Failed to save the global GUI configuration to "
566 "<b><nobr>%1</nobr></b>.</p>"
567 "<p>The application will now terminate.</p>")
568 .arg (vbox.GetSettingsFilePath()),
569 formatErrorInfo (res));
570}
571
572void VBoxProblemReporter::cannotSetSystemProperties (const CSystemProperties &props)
573{
574 message (mainWindowShown(), Critical,
575 tr ("Failed to set global VirtualBox properties."),
576 formatErrorInfo (props));
577}
578
579void VBoxProblemReporter::cannotAccessUSB (const COMBaseWithEI &aObj)
580{
581 /* If IMachine::GetUSBController(), IHost::GetUSBDevices() etc. return
582 * E_NOTIMPL, it means the USB support is intentionally missing
583 * (as in the OSE version). Don't show the error message in this case. */
584 COMResult res (aObj);
585 if (res.rc() == E_NOTIMPL)
586 return;
587
588#ifdef RT_OS_LINUX
589 /* xxx There is no macro to turn an error into a warning, but we need
590 * to do that here. */
591 if (res.rc() == (VBOX_E_HOST_ERROR & ~0x80000000))
592 {
593 message (mainWindowShown(), VBoxProblemReporter::Warning,
594 tr ("Could not access USB on the host system, because "
595 "neither the USB file system (usbfs) nor the DBus "
596 "and hal services are currently available. If you "
597 "wish to use host USB devices inside guest systems, "
598 "you must correct this and restart VirtualBox."),
599 formatErrorInfo (res),
600 "cannotAccessUSB" /* aAutoConfirmId */);
601 return;
602 }
603#endif
604 message (mainWindowShown(), res.isWarning() ? Warning : Error,
605 tr ("Failed to access the USB subsystem."),
606 formatErrorInfo (res),
607 "cannotAccessUSB");
608}
609
610void VBoxProblemReporter::cannotCreateMachine (const CVirtualBox &vbox,
611 QWidget *parent /* = 0 */)
612{
613 message (
614 parent ? parent : mainWindowShown(),
615 Error,
616 tr ("Failed to create a new virtual machine."),
617 formatErrorInfo (vbox)
618 );
619}
620
621void VBoxProblemReporter::cannotCreateMachine (const CVirtualBox &vbox,
622 const CMachine &machine,
623 QWidget *parent /* = 0 */)
624{
625 message (
626 parent ? parent : mainWindowShown(),
627 Error,
628 tr ("Failed to create a new virtual machine <b>%1</b>.")
629 .arg (machine.GetName()),
630 formatErrorInfo (vbox)
631 );
632}
633
634void VBoxProblemReporter::cannotOpenMachine(QWidget *pParent, const QString &strMachinePath, const CVirtualBox &vbox)
635{
636 message(pParent ? pParent : mainWindowShown(),
637 Error,
638 tr("Failed to open virtual machine located in %1.")
639 .arg(strMachinePath),
640 formatErrorInfo(vbox));
641}
642
643void VBoxProblemReporter::cannotReregisterMachine(QWidget *pParent, const QString &strMachinePath, const QString &strMachineName)
644{
645 message(pParent ? pParent : mainWindowShown(),
646 Error,
647 tr("Failed to add virtual machine <b>%1</b> located in <i>%2</i> because its already present.")
648 .arg(strMachineName).arg(strMachinePath));
649}
650
651void VBoxProblemReporter::
652cannotApplyMachineSettings (const CMachine &machine, const COMResult &res)
653{
654 message (
655 mainWindowShown(),
656 Error,
657 tr ("Failed to apply the settings to the virtual machine <b>%1</b>.")
658 .arg (machine.GetName()),
659 formatErrorInfo (res)
660 );
661}
662
663void VBoxProblemReporter::cannotSaveMachineSettings (const CMachine &machine,
664 QWidget *parent /* = 0 */)
665{
666 /* preserve the current error info before calling the object again */
667 COMResult res (machine);
668
669 message (parent ? parent : mainWindowShown(), Error,
670 tr ("Failed to save the settings of the virtual machine "
671 "<b>%1</b> to <b><nobr>%2</nobr></b>.")
672 .arg (machine.GetName(), machine.GetSettingsFilePath()),
673 formatErrorInfo (res));
674}
675
676/**
677 * @param strict If |false|, this method will silently return if the COM
678 * result code is E_NOTIMPL.
679 */
680void VBoxProblemReporter::cannotLoadMachineSettings (const CMachine &machine,
681 bool strict /* = true */,
682 QWidget *parent /* = 0 */)
683{
684 /* If COM result code is E_NOTIMPL, it means the requested object or
685 * function is intentionally missing (as in the OSE version). Don't show
686 * the error message in this case. */
687 COMResult res (machine);
688 if (!strict && res.rc() == E_NOTIMPL)
689 return;
690
691 message (parent ? parent : mainWindowShown(), Error,
692 tr ("Failed to load the settings of the virtual machine "
693 "<b>%1</b> from <b><nobr>%2</nobr></b>.")
694 .arg (machine.GetName(), machine.GetSettingsFilePath()),
695 formatErrorInfo (res));
696}
697
698void VBoxProblemReporter::cannotStartMachine (const CConsole &console)
699{
700 /* preserve the current error info before calling the object again */
701 COMResult res (console);
702
703 message (mainWindowShown(), Error,
704 tr ("Failed to start the virtual machine <b>%1</b>.")
705 .arg (console.GetMachine().GetName()),
706 formatErrorInfo (res));
707}
708
709void VBoxProblemReporter::cannotStartMachine (const CProgress &progress)
710{
711 AssertWrapperOk (progress);
712 CConsole console (CProgress (progress).GetInitiator());
713 AssertWrapperOk (console);
714
715 message (
716 mainWindowShown(),
717 Error,
718 tr ("Failed to start the virtual machine <b>%1</b>.")
719 .arg (console.GetMachine().GetName()),
720 formatErrorInfo (progress.GetErrorInfo())
721 );
722}
723
724void VBoxProblemReporter::cannotPauseMachine (const CConsole &console)
725{
726 /* preserve the current error info before calling the object again */
727 COMResult res (console);
728
729 message (mainWindowShown(), Error,
730 tr ("Failed to pause the execution of the virtual machine <b>%1</b>.")
731 .arg (console.GetMachine().GetName()),
732 formatErrorInfo (res));
733}
734
735void VBoxProblemReporter::cannotResumeMachine (const CConsole &console)
736{
737 /* preserve the current error info before calling the object again */
738 COMResult res (console);
739
740 message (mainWindowShown(), Error,
741 tr ("Failed to resume the execution of the virtual machine <b>%1</b>.")
742 .arg (console.GetMachine().GetName()),
743 formatErrorInfo (res));
744}
745
746void VBoxProblemReporter::cannotACPIShutdownMachine (const CConsole &console)
747{
748 /* preserve the current error info before calling the object again */
749 COMResult res (console);
750
751 message (mainWindowShown(), Error,
752 tr ("Failed to send the ACPI Power Button press event to the "
753 "virtual machine <b>%1</b>.")
754 .arg (console.GetMachine().GetName()),
755 formatErrorInfo (res));
756}
757
758void VBoxProblemReporter::cannotSaveMachineState (const CConsole &console)
759{
760 /* preserve the current error info before calling the object again */
761 COMResult res (console);
762
763 message (mainWindowShown(), Error,
764 tr ("Failed to save the state of the virtual machine <b>%1</b>.")
765 .arg (console.GetMachine().GetName()),
766 formatErrorInfo (res));
767}
768
769void VBoxProblemReporter::cannotSaveMachineState (const CProgress &progress)
770{
771 AssertWrapperOk (progress);
772 CConsole console (CProgress (progress).GetInitiator());
773 AssertWrapperOk (console);
774
775 message (
776 mainWindowShown(),
777 Error,
778 tr ("Failed to save the state of the virtual machine <b>%1</b>.")
779 .arg (console.GetMachine().GetName()),
780 formatErrorInfo (progress.GetErrorInfo())
781 );
782}
783
784void VBoxProblemReporter::cannotTakeSnapshot (const CConsole &console)
785{
786 /* preserve the current error info before calling the object again */
787 COMResult res (console);
788
789 message (mainWindowShown(), Error,
790 tr ("Failed to create a snapshot of the virtual machine <b>%1</b>.")
791 .arg (console.GetMachine().GetName()),
792 formatErrorInfo (res));
793}
794
795void VBoxProblemReporter::cannotTakeSnapshot (const CProgress &progress)
796{
797 AssertWrapperOk (progress);
798 CConsole console (CProgress (progress).GetInitiator());
799 AssertWrapperOk (console);
800
801 message (
802 mainWindowShown(),
803 Error,
804 tr ("Failed to create a snapshot of the virtual machine <b>%1</b>.")
805 .arg (console.GetMachine().GetName()),
806 formatErrorInfo (progress.GetErrorInfo())
807 );
808}
809
810void VBoxProblemReporter::cannotStopMachine (const CConsole &console)
811{
812 /* preserve the current error info before calling the object again */
813 COMResult res (console);
814
815 message (mainWindowShown(), Error,
816 tr ("Failed to stop the virtual machine <b>%1</b>.")
817 .arg (console.GetMachine().GetName()),
818 formatErrorInfo (res));
819}
820
821void VBoxProblemReporter::cannotStopMachine (const CProgress &progress)
822{
823 AssertWrapperOk (progress);
824 CConsole console (CProgress (progress).GetInitiator());
825 AssertWrapperOk (console);
826
827 message (mainWindowShown(), Error,
828 tr ("Failed to stop the virtual machine <b>%1</b>.")
829 .arg (console.GetMachine().GetName()),
830 formatErrorInfo (progress.GetErrorInfo()));
831}
832
833void VBoxProblemReporter::cannotDeleteMachine(const CMachine &machine)
834{
835 /* preserve the current error info before calling the object again */
836 COMResult res (machine);
837
838 message(mainWindowShown(),
839 Error,
840 tr("Failed to remove the virtual machine <b>%1</b>.").arg(machine.GetName()),
841 !machine.isOk() ? formatErrorInfo(machine) : formatErrorInfo(res));
842}
843
844void VBoxProblemReporter::cannotDiscardSavedState (const CConsole &console)
845{
846 /* preserve the current error info before calling the object again */
847 COMResult res (console);
848
849 message (mainWindowShown(), Error,
850 tr ("Failed to discard the saved state of the virtual machine <b>%1</b>.")
851 .arg (console.GetMachine().GetName()),
852 formatErrorInfo (res));
853}
854
855void VBoxProblemReporter::cannotSendACPIToMachine()
856{
857 message (mainWindowShown(), Warning,
858 tr ("You are trying to shut down the guest with the ACPI power "
859 "button. This is currently not possible because the guest "
860 "does not support software shutdown."));
861}
862
863bool VBoxProblemReporter::warnAboutVirtNotEnabled64BitsGuest(bool fHWVirtExSupported)
864{
865 if (fHWVirtExSupported)
866 return messageOkCancel (mainWindowShown(), Error,
867 tr ("<p>VT-x/AMD-V hardware acceleration has been enabled, but is "
868 "not operational. Your 64-bit guest will fail to detect a "
869 "64-bit CPU and will not be able to boot.</p><p>Please ensure "
870 "that you have enabled VT-x/AMD-V properly in the BIOS of your "
871 "host computer.</p>"),
872 0 /* aAutoConfirmId */,
873 tr ("Close VM"), tr ("Continue"));
874 else
875 return messageOkCancel (mainWindowShown(), Error,
876 tr ("<p>VT-x/AMD-V hardware acceleration is not available on your system. "
877 "Your 64-bit guest will fail to detect a 64-bit CPU and will "
878 "not be able to boot."),
879 0 /* aAutoConfirmId */,
880 tr ("Close VM"), tr ("Continue"));
881}
882
883bool VBoxProblemReporter::warnAboutVirtNotEnabledGuestRequired(bool fHWVirtExSupported)
884{
885 if (fHWVirtExSupported)
886 return messageOkCancel (mainWindowShown(), Error,
887 tr ("<p>VT-x/AMD-V hardware acceleration has been enabled, but is "
888 "not operational. Certain guests (e.g. OS/2 and QNX) require "
889 "this feature.</p><p>Please ensure "
890 "that you have enabled VT-x/AMD-V properly in the BIOS of your "
891 "host computer.</p>"),
892 0 /* aAutoConfirmId */,
893 tr ("Close VM"), tr ("Continue"));
894 else
895 return messageOkCancel (mainWindowShown(), Error,
896 tr ("<p>VT-x/AMD-V hardware acceleration is not available on your system. "
897 "Certain guests (e.g. OS/2 and QNX) require this feature and will "
898 "fail to boot without it.</p>"),
899 0 /* aAutoConfirmId */,
900 tr ("Close VM"), tr ("Continue"));
901}
902
903void VBoxProblemReporter::cannotSetSnapshotFolder (const CMachine &aMachine,
904 const QString &aPath)
905{
906 message (
907 mainWindowShown(),
908 Error,
909 tr ("Failed to change the snapshot folder path of the "
910 "virtual machine <b>%1<b> to <nobr><b>%2</b></nobr>.")
911 .arg (aMachine.GetName())
912 .arg (aPath),
913 formatErrorInfo (aMachine));
914}
915
916bool VBoxProblemReporter::askAboutSnapshotRestoring (const QString &aSnapshotName)
917{
918 return messageOkCancel (mainWindowShown(), Question,
919 tr ("<p>Are you sure you want to restore snapshot <b>%1</b>? "
920 "This will cause you to lose your current machine state, which cannot be recovered.</p>")
921 .arg (aSnapshotName),
922 /* Do NOT allow this message to be disabled! */
923 NULL /* aAutoConfirmId */,
924 tr ("Restore"), tr ("Cancel"));
925}
926
927bool VBoxProblemReporter::askAboutSnapshotDeleting (const QString &aSnapshotName)
928{
929 return messageOkCancel (mainWindowShown(), Question,
930 tr ("<p>Deleting the snapshot will cause the state information saved in it to be lost, and disk data spread over "
931 "several image files that VirtualBox has created together with the snapshot will be merged into one file. This can be a lengthy process, and the information "
932 "in the snapshot cannot be recovered.</p></p>Are you sure you want to delete the selected snapshot <b>%1</b>?</p>")
933 .arg (aSnapshotName),
934 /* Do NOT allow this message to be disabled! */
935 NULL /* aAutoConfirmId */,
936 tr ("Delete"), tr ("Cancel"));
937}
938
939bool VBoxProblemReporter::askAboutSnapshotDeletingFreeSpace (const QString &aSnapshotName,
940 const QString &aTargetImageName,
941 const QString &aTargetImageMaxSize,
942 const QString &aTargetFilesystemFree)
943{
944 return messageOkCancel (mainWindowShown(), Question,
945 tr ("<p>Deleting the snapshot %1 will temporarily need more disk space. In the worst case the size of image %2 will grow by %3, "
946 "however on this filesystem there is only %4 free.</p><p>Running out of disk space during the merge operation can result in "
947 "corruption of the image and the VM configuration, i.e. loss of the VM and its data.</p><p>You may continue with deleting "
948 "the snapshot at your own risk.</p>")
949 .arg (aSnapshotName)
950 .arg (aTargetImageName)
951 .arg (aTargetImageMaxSize)
952 .arg (aTargetFilesystemFree),
953 /* Do NOT allow this message to be disabled! */
954 NULL /* aAutoConfirmId */,
955 tr ("Delete"), tr ("Cancel"));
956}
957
958void VBoxProblemReporter::cannotRestoreSnapshot (const CConsole &aConsole,
959 const QString &aSnapshotName)
960{
961 message (mainWindowShown(), Error,
962 tr ("Failed to restore the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")
963 .arg (aSnapshotName)
964 .arg (CConsole (aConsole).GetMachine().GetName()),
965 formatErrorInfo (aConsole));
966}
967
968void VBoxProblemReporter::cannotRestoreSnapshot (const CProgress &aProgress,
969 const QString &aSnapshotName)
970{
971 CConsole console (CProgress (aProgress).GetInitiator());
972
973 message (mainWindowShown(), Error,
974 tr ("Failed to restore the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")
975 .arg (aSnapshotName)
976 .arg (console.GetMachine().GetName()),
977 formatErrorInfo (aProgress.GetErrorInfo()));
978}
979
980void VBoxProblemReporter::cannotDeleteSnapshot (const CConsole &aConsole,
981 const QString &aSnapshotName)
982{
983 message (mainWindowShown(), Error,
984 tr ("Failed to delete the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")
985 .arg (aSnapshotName)
986 .arg (CConsole (aConsole).GetMachine().GetName()),
987 formatErrorInfo (aConsole));
988}
989
990void VBoxProblemReporter::cannotDeleteSnapshot (const CProgress &aProgress,
991 const QString &aSnapshotName)
992{
993 CConsole console (CProgress (aProgress).GetInitiator());
994
995 message (mainWindowShown(), Error,
996 tr ("Failed to delete the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")
997 .arg (aSnapshotName)
998 .arg (console.GetMachine().GetName()),
999 formatErrorInfo (aProgress.GetErrorInfo()));
1000}
1001
1002void VBoxProblemReporter::cannotFindMachineByName (const CVirtualBox &vbox,
1003 const QString &name)
1004{
1005 message (
1006 QApplication::desktop()->screen(QApplication::desktop()->primaryScreen()),
1007 Error,
1008 tr ("There is no virtual machine named <b>%1</b>.")
1009 .arg (name),
1010 formatErrorInfo (vbox)
1011 );
1012}
1013
1014void VBoxProblemReporter::cannotEnterSeamlessMode (ULONG /* aWidth */,
1015 ULONG /* aHeight */,
1016 ULONG /* aBpp */,
1017 ULONG64 aMinVRAM)
1018{
1019 message (mainMachineWindowShown(), Error,
1020 tr ("<p>Could not enter seamless mode due to insufficient guest "
1021 "video memory.</p>"
1022 "<p>You should configure the virtual machine to have at "
1023 "least <b>%1</b> of video memory.</p>")
1024 .arg (VBoxGlobal::formatSize (aMinVRAM)));
1025}
1026
1027int VBoxProblemReporter::cannotEnterFullscreenMode (ULONG /* aWidth */,
1028 ULONG /* aHeight */,
1029 ULONG /* aBpp */,
1030 ULONG64 aMinVRAM)
1031{
1032 return message (mainMachineWindowShown(), Warning,
1033 tr ("<p>Could not switch the guest display to fullscreen mode due "
1034 "to insufficient guest video memory.</p>"
1035 "<p>You should configure the virtual machine to have at "
1036 "least <b>%1</b> of video memory.</p>"
1037 "<p>Press <b>Ignore</b> to switch to fullscreen mode anyway "
1038 "or press <b>Cancel</b> to cancel the operation.</p>")
1039 .arg (VBoxGlobal::formatSize (aMinVRAM)),
1040 0, /* aAutoConfirmId */
1041 QIMessageBox::Ignore | QIMessageBox::Default,
1042 QIMessageBox::Cancel | QIMessageBox::Escape);
1043}
1044
1045void VBoxProblemReporter::cannotSwitchScreenInSeamless(quint64 minVRAM)
1046{
1047 message(mainMachineWindowShown(), Error,
1048 tr("<p>Could not change the guest screen to this host screen "
1049 "due to insufficient guest video memory.</p>"
1050 "<p>You should configure the virtual machine to have at "
1051 "least <b>%1</b> of video memory.</p>")
1052 .arg(VBoxGlobal::formatSize(minVRAM)));
1053}
1054
1055int VBoxProblemReporter::cannotSwitchScreenInFullscreen(quint64 minVRAM)
1056{
1057 return message(mainMachineWindowShown(), Warning,
1058 tr("<p>Could not change the guest screen to this host screen "
1059 "due to insufficient guest video memory.</p>"
1060 "<p>You should configure the virtual machine to have at "
1061 "least <b>%1</b> of video memory.</p>"
1062 "<p>Press <b>Ignore</b> to switch the screen anyway "
1063 "or press <b>Cancel</b> to cancel the operation.</p>")
1064 .arg(VBoxGlobal::formatSize(minVRAM)),
1065 0, /* aAutoConfirmId */
1066 QIMessageBox::Ignore | QIMessageBox::Default,
1067 QIMessageBox::Cancel | QIMessageBox::Escape);
1068}
1069
1070int VBoxProblemReporter::cannotEnterFullscreenMode()
1071{
1072 return message(mainMachineWindowShown(), Error,
1073 tr ("<p>Can not switch the guest display to fullscreen mode. You "
1074 "have more virtual screens configured than physical screens are "
1075 "attached to your host.</p><p>Please either lower the virtual "
1076 "screens in your VM configuration or attach additional screens "
1077 "to your host.</p>"),
1078 0, /* aAutoConfirmId */
1079 QIMessageBox::Ok | QIMessageBox::Default);
1080}
1081
1082int VBoxProblemReporter::cannotEnterSeamlessMode()
1083{
1084 return message(mainMachineWindowShown(), Error,
1085 tr ("<p>Can not switch the guest display to seamless mode. You "
1086 "have more virtual screens configured than physical screens are "
1087 "attached to your host.</p><p>Please either lower the virtual "
1088 "screens in your VM configuration or attach additional screens "
1089 "to your host.</p>"),
1090 0, /* aAutoConfirmId */
1091 QIMessageBox::Ok | QIMessageBox::Default);
1092}
1093
1094int VBoxProblemReporter::confirmMachineDeletion(const CMachine &machine)
1095{
1096 if (machine.GetAccessible())
1097 {
1098 int cDisks = 0;
1099 const CMediumAttachmentVector &attachments = machine.GetMediumAttachments();
1100 for (int i = 0; i < attachments.size(); ++i)
1101 {
1102 const CMediumAttachment &attachment = attachments.at(i);
1103 /* Check if the medium is a harddisk: */
1104 if (attachment.GetType() == KDeviceType_HardDisk)
1105 {
1106 /* Check if the disk isn't shared.
1107 * If the disk is shared, it will be *never* deleted. */
1108 QVector<QString> ids = attachment.GetMedium().GetMachineIds();
1109 if (ids.size() == 1)
1110 ++cDisks;
1111 }
1112 }
1113 const QString strBase = tr("<p>You are about to remove the virtual machine <b>%1</b> from the machine list.</p>"
1114 "<p>Would you like to delete the files containing the virtual machine from your hard disk as well?</p>")
1115 .arg(machine.GetName());
1116 const QString strExtd = tr("<p>You are about to remove the virtual machine <b>%1</b> from the machine list.</p>"
1117 "<p>Would you like to delete the files containing the virtual machine from your hard disk as well? "
1118 "Doing this will also remove the files containing the machine's virtual hard disks "
1119 "if they are not in use by another machine.</p>")
1120 .arg(machine.GetName());
1121 return message(&vboxGlobal().selectorWnd(),
1122 Question,
1123 cDisks == 0 ? strBase : strExtd,
1124 0, /* auto-confirm id */
1125 QIMessageBox::Yes,
1126 QIMessageBox::No,
1127 QIMessageBox::Cancel | QIMessageBox::Escape | QIMessageBox::Default,
1128 tr("Delete all files"),
1129 tr("Remove only"));
1130 }
1131 else
1132 {
1133 /* This should be in sync with UIVMListBoxItem::recache(): */
1134 QFileInfo fi(machine.GetSettingsFilePath());
1135 const QString strName = VBoxGlobal::hasAllowedExtension(fi.completeSuffix(), VBoxDefs::VBoxFileExts) ? fi.completeBaseName() : fi.fileName();
1136 const QString strBase = tr("You are about to remove the inaccessible virtual machine "
1137 "<b>%1</b> from the machine list. Do you wish to proceed?")
1138 .arg(strName);
1139 return message(&vboxGlobal().selectorWnd(),
1140 Question,
1141 strBase,
1142 0, /* auto-confirm id */
1143 QIMessageBox::Ok,
1144 QIMessageBox::Cancel | QIMessageBox::Escape | QIMessageBox::Default,
1145 0,
1146 tr("Remove"));
1147 }
1148}
1149
1150bool VBoxProblemReporter::confirmDiscardSavedState (const CMachine &machine)
1151{
1152 return messageOkCancel (&vboxGlobal().selectorWnd(), Question,
1153 tr ("<p>Are you sure you want to discard the saved state of "
1154 "the virtual machine <b>%1</b>?</p>"
1155 "<p>This operation is equivalent to resetting or powering off "
1156 "the machine without doing a proper shutdown of the "
1157 "guest OS.</p>")
1158 .arg (machine.GetName()),
1159 0 /* aAutoConfirmId */,
1160 tr ("Discard", "saved state"));
1161}
1162
1163bool VBoxProblemReporter::confirmReleaseMedium (QWidget *aParent,
1164 const VBoxMedium &aMedium,
1165 const QString &aUsage)
1166{
1167 /** @todo (translation-related): the gender of "the" in translations
1168 * will depend on the gender of aMedium.type(). */
1169 return messageOkCancel (aParent, Question,
1170 tr ("<p>Are you sure you want to release the %1 "
1171 "<nobr><b>%2</b></nobr>?</p>"
1172 "<p>This will detach it from the "
1173 "following virtual machine(s): <b>%3</b>.</p>")
1174 .arg (mediumToAccusative (aMedium.type()))
1175 .arg (aMedium.location())
1176 .arg (aUsage),
1177 0 /* aAutoConfirmId */,
1178 tr ("Release", "detach medium"));
1179}
1180
1181bool VBoxProblemReporter::confirmRemoveMedium (QWidget *aParent,
1182 const VBoxMedium &aMedium)
1183{
1184 /** @todo (translation-related): the gender of "the" in translations
1185 * will depend on the gender of aMedium.type(). */
1186 QString msg =
1187 tr ("<p>Are you sure you want to remove the %1 "
1188 "<nobr><b>%2</b></nobr> from the list of known media?</p>")
1189 .arg (mediumToAccusative (aMedium.type()))
1190 .arg (aMedium.location());
1191
1192 if (aMedium.type() == VBoxDefs::MediumType_HardDisk)
1193 {
1194 if (aMedium.state() == KMediumState_Inaccessible)
1195 msg +=
1196 tr ("Note that as this hard disk is inaccessible its "
1197 "storage unit cannot be deleted right now.");
1198 else
1199 msg +=
1200 tr ("The next dialog will let you choose whether you also "
1201 "want to delete the storage unit of this hard disk or "
1202 "keep it for later usage.");
1203 }
1204 else
1205 msg +=
1206 tr ("<p>Note that the storage unit of this medium will not be "
1207 "deleted and that it will be possible to add it to "
1208 "the list later again.</p>");
1209
1210 return messageOkCancel (aParent, Question, msg,
1211 "confirmRemoveMedium", /* aAutoConfirmId */
1212 tr ("Remove", "medium"));
1213}
1214
1215void VBoxProblemReporter::sayCannotOverwriteHardDiskStorage (
1216 QWidget *aParent, const QString &aLocation)
1217{
1218 message (aParent, Info,
1219 tr ("<p>The hard disk storage unit at location <b>%1</b> already "
1220 "exists. You cannot create a new virtual hard disk that uses this "
1221 "location because it can be already used by another virtual hard "
1222 "disk.</p>"
1223 "<p>Please specify a different location.</p>")
1224 .arg (aLocation));
1225}
1226
1227int VBoxProblemReporter::confirmDeleteHardDiskStorage (
1228 QWidget *aParent, const QString &aLocation)
1229{
1230 return message (aParent, Question,
1231 tr ("<p>Do you want to delete the storage unit of the hard disk "
1232 "<nobr><b>%1</b></nobr>?</p>"
1233 "<p>If you select <b>Delete</b> then the specified storage unit "
1234 "will be permanently deleted. This operation <b>cannot be "
1235 "undone</b>.</p>"
1236 "<p>If you select <b>Keep</b> then the hard disk will be only "
1237 "removed from the list of known hard disks, but the storage unit "
1238 "will be left untouched which makes it possible to add this hard "
1239 "disk to the list later again.</p>")
1240 .arg (aLocation),
1241 0, /* aAutoConfirmId */
1242 QIMessageBox::Yes,
1243 QIMessageBox::No | QIMessageBox::Default,
1244 QIMessageBox::Cancel | QIMessageBox::Escape,
1245 tr ("Delete", "hard disk storage"),
1246 tr ("Keep", "hard disk storage"));
1247}
1248
1249void VBoxProblemReporter::cannotDeleteHardDiskStorage (QWidget *aParent,
1250 const CMedium &aHD,
1251 const CProgress &aProgress)
1252{
1253 /* below, we use CMedium (aHD) to preserve current error info
1254 * for formatErrorInfo() */
1255
1256 message (aParent, Error,
1257 tr ("Failed to delete the storage unit of the hard disk <b>%1</b>.")
1258 .arg (CMedium (aHD).GetLocation()),
1259 !aHD.isOk() ? formatErrorInfo (aHD) :
1260 !aProgress.isOk() ? formatErrorInfo (aProgress) :
1261 formatErrorInfo (aProgress.GetErrorInfo()));
1262}
1263
1264int VBoxProblemReporter::confirmDetachAddControllerSlots (QWidget *aParent) const
1265{
1266 return messageOkCancel (aParent, Question,
1267 tr ("<p>There are hard disks attached to ports of the additional controller. "
1268 "If you disable the additional controller, all these hard disks "
1269 "will be automatically detached.</p>"
1270 "<p>Are you sure you want to "
1271 "disable the additional controller?</p>"),
1272 0 /* aAutoConfirmId */,
1273 tr ("Disable", "hard disk"));
1274}
1275
1276int VBoxProblemReporter::confirmChangeAddControllerSlots (QWidget *aParent) const
1277{
1278 return messageOkCancel (aParent, Question,
1279 tr ("<p>There are hard disks attached to ports of the additional controller. "
1280 "If you change the additional controller, all these hard disks "
1281 "will be automatically detached.</p>"
1282 "<p>Are you sure you want to "
1283 "change the additional controller?</p>"),
1284 0 /* aAutoConfirmId */,
1285 tr ("Change", "hard disk"));
1286}
1287
1288int VBoxProblemReporter::askAboutHardDiskAttachmentCreation(QWidget *pParent,
1289 const QString &strControllerName)
1290{
1291 return message(pParent, Question,
1292 tr("<p>You are about to add a virtual hard disk to controller <b>%1</b>.</p>"
1293 "<p>Would you like to create a new, empty disk or select an existing one? "
1294 "You will be able to change the attached disk again at a later time "
1295 "if you wish using the button on the <b>Attributes</b> pane.</p>")
1296 .arg(strControllerName),
1297 0, /* aAutoConfirmId */
1298 QIMessageBox::Yes,
1299 QIMessageBox::No,
1300 QIMessageBox::Cancel | QIMessageBox::Default | QIMessageBox::Escape,
1301 tr("Create &new disk", "add attachment routine"),
1302 tr("&Choose existing disk", "add attachment routine"));
1303}
1304
1305int VBoxProblemReporter::askAboutOpticalAttachmentCreation(QWidget *pParent,
1306 const QString &strControllerName)
1307{
1308 return message(pParent, Question,
1309 tr("<p>You are about to add a new CD/DVD drive to controller <b>%1</b>.</p>"
1310 "<p>Would you like to choose a virtual CD/DVD disk to insert into the drive "
1311 "or to leave it empty for now? "
1312 "You will be able to change the disk inserted later or pass through a physical disk "
1313 "using the button on the <b>Attributes</b> pane or while the machine is running using the <b>Device</b> menu.</p>")
1314 .arg(strControllerName),
1315 0, /* aAutoConfirmId */
1316 QIMessageBox::Yes,
1317 QIMessageBox::No,
1318 QIMessageBox::Cancel | QIMessageBox::Default | QIMessageBox::Escape,
1319 tr("&Choose disk", "add attachment routine"),
1320 tr("Leave &empty", "add attachment routine"));
1321}
1322
1323int VBoxProblemReporter::askAboutFloppyAttachmentCreation(QWidget *pParent,
1324 const QString &strControllerName)
1325{
1326 return message(pParent, Question,
1327 tr("<p>You are about to add a new floppy drive to controller <b>%1</b>.</p>"
1328 "<p>Would you like to choose a virtual floppy disk to insert into the drive "
1329 "or to leave it empty for now? "
1330 "You will be able to change the disk inserted later or pass through a physical disk "
1331 "using the button on the <b>Attributes</b> pane or while the machine is running using the <b>Device</b> menu.</p>")
1332 .arg(strControllerName),
1333 0, /* aAutoConfirmId */
1334 QIMessageBox::Yes,
1335 QIMessageBox::No,
1336 QIMessageBox::Cancel | QIMessageBox::Default | QIMessageBox::Escape,
1337 tr("&Choose disk", "add attachment routine"),
1338 tr("Leave &empty", "add attachment routine"));
1339}
1340
1341int VBoxProblemReporter::confirmRemovingOfLastDVDDevice() const
1342{
1343 return messageOkCancel (QApplication::activeWindow(), Info,
1344 tr ("<p>Are you sure you want to delete the CD/DVD-ROM device?</p>"
1345 "<p>You will not be able to mount any CDs or ISO images "
1346 "or install the Guest Additions without it!</p>"),
1347 0, /* aAutoConfirmId */
1348 tr ("&Remove", "medium"));
1349}
1350
1351void VBoxProblemReporter::cannotCreateHardDiskStorage (
1352 QWidget *aParent, const CVirtualBox &aVBox, const QString &aLocation,
1353 const CMedium &aHD, const CProgress &aProgress)
1354{
1355 message (aParent, Error,
1356 tr ("Failed to create the hard disk storage <nobr><b>%1</b>.</nobr>")
1357 .arg (aLocation),
1358 !aVBox.isOk() ? formatErrorInfo (aVBox) :
1359 !aHD.isOk() ? formatErrorInfo (aHD) :
1360 !aProgress.isOk() ? formatErrorInfo (aProgress) :
1361 formatErrorInfo (aProgress.GetErrorInfo()));
1362}
1363
1364void VBoxProblemReporter::cannotAttachDevice (QWidget *aParent, const CMachine &aMachine,
1365 VBoxDefs::MediumType aType, const QString &aLocation,
1366 KStorageBus aBus, LONG aChannel, LONG aDevice)
1367{
1368 QString what (deviceToAccusative (aType));
1369 if (!aLocation.isNull())
1370 what += QString (" (<nobr><b>%1</b></nobr>)").arg (aLocation);
1371
1372 message (aParent, Error,
1373 tr ("Failed to attach the %1 to slot <i>%2</i> of the machine <b>%3</b>.")
1374 .arg (what)
1375 .arg (vboxGlobal().toString (StorageSlot (aBus, aChannel, aDevice)))
1376 .arg (CMachine (aMachine).GetName()),
1377 formatErrorInfo (aMachine));
1378}
1379
1380void VBoxProblemReporter::cannotDetachDevice (QWidget *aParent, const CMachine &aMachine,
1381 VBoxDefs::MediumType aType, const QString &aLocation,
1382 KStorageBus aBus, LONG aChannel, LONG aDevice)
1383{
1384 QString what (deviceToAccusative (aType));
1385 if (!aLocation.isNull())
1386 what += QString (" (<nobr><b>%1</b></nobr>)").arg (aLocation);
1387
1388 message (aParent, Error,
1389 tr ("Failed to detach the %1 from slot <i>%2</i> of the machine <b>%3</b>.")
1390 .arg (what)
1391 .arg (vboxGlobal().toString (StorageSlot (aBus, aChannel, aDevice)))
1392 .arg (CMachine (aMachine).GetName()),
1393 formatErrorInfo (aMachine));
1394}
1395
1396int VBoxProblemReporter::cannotRemountMedium (QWidget *aParent, const CMachine &aMachine,
1397 const VBoxMedium &aMedium, bool aMount, bool aRetry)
1398{
1399 /** @todo (translation-related): the gender of "the" in translations
1400 * will depend on the gender of aMedium.type(). */
1401 QString text;
1402 if (aMount)
1403 {
1404 text = tr ("Unable to mount the %1 <nobr><b>%2</b></nobr> on the machine <b>%3</b>.");
1405 if (aRetry) text += tr (" Would you like to force mounting of this medium?");
1406 }
1407 else
1408 {
1409 text = tr ("Unable to unmount the %1 <nobr><b>%2</b></nobr> from the machine <b>%3</b>.");
1410 if (aRetry) text += tr (" Would you like to force unmounting of this medium?");
1411 }
1412 if (aRetry)
1413 {
1414 return messageOkCancel (aParent ? aParent : mainWindowShown(), Question, text
1415 .arg (mediumToAccusative (aMedium.type(), aMedium.isHostDrive()))
1416 .arg (aMedium.isHostDrive() ? aMedium.name() : aMedium.location())
1417 .arg (CMachine (aMachine).GetName()),
1418 formatErrorInfo (aMachine),
1419 0 /* Auto Confirm ID */,
1420 tr ("Force Unmount"));
1421 }
1422 else
1423 {
1424 return message (aParent ? aParent : mainWindowShown(), Error, text
1425 .arg (mediumToAccusative (aMedium.type(), aMedium.isHostDrive()))
1426 .arg (aMedium.isHostDrive() ? aMedium.name() : aMedium.location())
1427 .arg (CMachine (aMachine).GetName()),
1428 formatErrorInfo (aMachine));
1429 }
1430}
1431
1432void VBoxProblemReporter::cannotOpenMedium (
1433 QWidget *aParent, const CVirtualBox &aVBox,
1434 VBoxDefs::MediumType aType, const QString &aLocation)
1435{
1436 /** @todo (translation-related): the gender of "the" in translations
1437 * will depend on the gender of aMedium.type(). */
1438 message (aParent ? aParent : mainWindowShown(), Error,
1439 tr ("Failed to open the %1 <nobr><b>%2</b></nobr>.")
1440 .arg (mediumToAccusative (aType))
1441 .arg (aLocation),
1442 formatErrorInfo (aVBox));
1443}
1444
1445void VBoxProblemReporter::cannotCloseMedium (
1446 QWidget *aParent, const VBoxMedium &aMedium, const COMResult &aResult)
1447{
1448 /** @todo (translation-related): the gender of "the" in translations
1449 * will depend on the gender of aMedium.type(). */
1450 message (aParent, Error,
1451 tr ("Failed to close the %1 <nobr><b>%2</b></nobr>.")
1452 .arg (mediumToAccusative (aMedium.type()))
1453 .arg (aMedium.location()),
1454 formatErrorInfo (aResult));
1455}
1456
1457void VBoxProblemReporter::cannotEjectDrive()
1458{
1459 message (mainWindowShown(), Warning,
1460 tr ("Failed to eject the disk from the virtual drive. "
1461 "The drive may be locked by the guest operating system. "
1462 "Please check this and try again."));
1463}
1464
1465void VBoxProblemReporter::cannotOpenSession (const CSession &session)
1466{
1467 Assert (session.isNull());
1468
1469 message (
1470 mainWindowShown(),
1471 Error,
1472 tr ("Failed to create a new session."),
1473 formatErrorInfo (session)
1474 );
1475}
1476
1477void VBoxProblemReporter::cannotOpenSession (
1478 const CVirtualBox &vbox, const CMachine &machine,
1479 const CProgress &progress
1480) {
1481 Assert (!vbox.isOk() || progress.isOk());
1482
1483 QString name = machine.GetName();
1484 if (name.isEmpty())
1485 name = QFileInfo (machine.GetSettingsFilePath()).baseName();
1486
1487 message (
1488 mainWindowShown(),
1489 Error,
1490 tr ("Failed to open a session for the virtual machine <b>%1</b>.")
1491 .arg (name),
1492 !vbox.isOk() ? formatErrorInfo (vbox) :
1493 formatErrorInfo (progress.GetErrorInfo())
1494 );
1495}
1496
1497void VBoxProblemReporter::cannotGetMediaAccessibility (const VBoxMedium &aMedium)
1498{
1499 message (qApp->activeWindow(), Error,
1500 tr ("Failed to determine the accessibility state of the medium "
1501 "<nobr><b>%1</b></nobr>.")
1502 .arg (aMedium.location()),
1503 formatErrorInfo (aMedium.result()));
1504}
1505
1506int VBoxProblemReporter::confirmDeletingHostInterface (const QString &aName,
1507 QWidget *aParent)
1508{
1509 return vboxProblem().message (aParent, VBoxProblemReporter::Question,
1510 tr ("<p>Deleting this host-only network will remove "
1511 "the host-only interface this network is based on. Do you want to "
1512 "remove the (host-only network) interface <nobr><b>%1</b>?</nobr></p>"
1513 "<p><b>Note:</b> this interface may be in use by one or more "
1514 "virtual network adapters belonging to one of your VMs. "
1515 "After it is removed, these adapters will no longer be usable until "
1516 "you correct their settings by either choosing a different interface "
1517 "name or a different adapter attachment type.</p>").arg (aName),
1518 0, /* autoConfirmId */
1519 QIMessageBox::Ok | QIMessageBox::Default,
1520 QIMessageBox::Cancel | QIMessageBox::Escape);
1521}
1522
1523void VBoxProblemReporter::cannotCreateHostInterface (
1524 const CHost &host, QWidget *parent)
1525{
1526 message (parent ? parent : mainWindowShown(), Error,
1527 tr ("Failed to create the host-only network interface."),
1528 formatErrorInfo (host));
1529}
1530
1531void VBoxProblemReporter::cannotCreateHostInterface (
1532 const CProgress &progress, QWidget *parent)
1533{
1534 message (parent ? parent : mainWindowShown(), Error,
1535 tr ("Failed to create the host-only network interface."),
1536 formatErrorInfo (progress.GetErrorInfo()));
1537}
1538
1539void VBoxProblemReporter::cannotRemoveHostInterface (
1540 const CHost &host, const CHostNetworkInterface &iface, QWidget *parent)
1541{
1542 message (parent ? parent : mainWindowShown(), Error,
1543 tr ("Failed to remove the host network interface <b>%1</b>.")
1544 .arg (iface.GetName()),
1545 formatErrorInfo (host));
1546}
1547
1548void VBoxProblemReporter::cannotRemoveHostInterface (
1549 const CProgress &progress, const CHostNetworkInterface &iface, QWidget *parent)
1550{
1551 message (parent ? parent : mainWindowShown(), Error,
1552 tr ("Failed to remove the host network interface <b>%1</b>.")
1553 .arg (iface.GetName()),
1554 formatErrorInfo (progress.GetErrorInfo()));
1555}
1556
1557void VBoxProblemReporter::cannotAttachUSBDevice (const CConsole &console,
1558 const QString &device)
1559{
1560 /* preserve the current error info before calling the object again */
1561 COMResult res (console);
1562
1563 message (mainMachineWindowShown(), Error,
1564 tr ("Failed to attach the USB device <b>%1</b> "
1565 "to the virtual machine <b>%2</b>.")
1566 .arg (device)
1567 .arg (console.GetMachine().GetName()),
1568 formatErrorInfo (res));
1569}
1570
1571void VBoxProblemReporter::cannotAttachUSBDevice (const CConsole &console,
1572 const QString &device,
1573 const CVirtualBoxErrorInfo &error)
1574{
1575 message (mainMachineWindowShown(), Error,
1576 tr ("Failed to attach the USB device <b>%1</b> "
1577 "to the virtual machine <b>%2</b>.")
1578 .arg (device)
1579 .arg (console.GetMachine().GetName()),
1580 formatErrorInfo (error));
1581}
1582
1583void VBoxProblemReporter::cannotDetachUSBDevice (const CConsole &console,
1584 const QString &device)
1585{
1586 /* preserve the current error info before calling the object again */
1587 COMResult res (console);
1588
1589 message (mainMachineWindowShown(), Error,
1590 tr ("Failed to detach the USB device <b>%1</b> "
1591 "from the virtual machine <b>%2</b>.")
1592 .arg (device)
1593 .arg (console.GetMachine().GetName()),
1594 formatErrorInfo (res));
1595}
1596
1597void VBoxProblemReporter::cannotDetachUSBDevice (const CConsole &console,
1598 const QString &device,
1599 const CVirtualBoxErrorInfo &error)
1600{
1601 message (mainMachineWindowShown(), Error,
1602 tr ("Failed to detach the USB device <b>%1</b> "
1603 "from the virtual machine <b>%2</b>.")
1604 .arg (device)
1605 .arg (console.GetMachine().GetName()),
1606 formatErrorInfo (error));
1607}
1608
1609void VBoxProblemReporter::cannotCreateSharedFolder (QWidget *aParent,
1610 const CMachine &aMachine,
1611 const QString &aName,
1612 const QString &aPath)
1613{
1614 /* preserve the current error info before calling the object again */
1615 COMResult res (aMachine);
1616
1617 message (aParent, Error,
1618 tr ("Failed to create the shared folder <b>%1</b> "
1619 "(pointing to <nobr><b>%2</b></nobr>) "
1620 "for the virtual machine <b>%3</b>.")
1621 .arg (aName)
1622 .arg (aPath)
1623 .arg (aMachine.GetName()),
1624 formatErrorInfo (res));
1625}
1626
1627void VBoxProblemReporter::cannotRemoveSharedFolder (QWidget *aParent,
1628 const CMachine &aMachine,
1629 const QString &aName,
1630 const QString &aPath)
1631{
1632 /* preserve the current error info before calling the object again */
1633 COMResult res (aMachine);
1634
1635 message (aParent, Error,
1636 tr ("Failed to remove the shared folder <b>%1</b> "
1637 "(pointing to <nobr><b>%2</b></nobr>) "
1638 "from the virtual machine <b>%3</b>.")
1639 .arg (aName)
1640 .arg (aPath)
1641 .arg (aMachine.GetName()),
1642 formatErrorInfo (res));
1643}
1644
1645void VBoxProblemReporter::cannotCreateSharedFolder (QWidget *aParent,
1646 const CConsole &aConsole,
1647 const QString &aName,
1648 const QString &aPath)
1649{
1650 /* preserve the current error info before calling the object again */
1651 COMResult res (aConsole);
1652
1653 message (aParent, Error,
1654 tr ("Failed to create the shared folder <b>%1</b> "
1655 "(pointing to <nobr><b>%2</b></nobr>) "
1656 "for the virtual machine <b>%3</b>.")
1657 .arg (aName)
1658 .arg (aPath)
1659 .arg (aConsole.GetMachine().GetName()),
1660 formatErrorInfo (res));
1661}
1662
1663void VBoxProblemReporter::cannotRemoveSharedFolder (QWidget *aParent,
1664 const CConsole &aConsole,
1665 const QString &aName,
1666 const QString &aPath)
1667{
1668 /* preserve the current error info before calling the object again */
1669 COMResult res (aConsole);
1670
1671 message (aParent, Error,
1672 tr ("<p>Failed to remove the shared folder <b>%1</b> "
1673 "(pointing to <nobr><b>%2</b></nobr>) "
1674 "from the virtual machine <b>%3</b>.</p>"
1675 "<p>Please close all programs in the guest OS that "
1676 "may be using this shared folder and try again.</p>")
1677 .arg (aName)
1678 .arg (aPath)
1679 .arg (aConsole.GetMachine().GetName()),
1680 formatErrorInfo (res));
1681}
1682
1683void VBoxProblemReporter::remindAboutGuestAdditionsAreNotActive(QWidget *pParent)
1684{
1685 message (pParent, Warning,
1686 tr("<p>The VirtualBox Guest Additions do not appear to be "
1687 "available on this virtual machine, and shared folders "
1688 "cannot be used without them. To use shared folders inside "
1689 "the virtual machine, please install the Guest Additions "
1690 "if they are not installed, or re-install them if they are "
1691 "not working correctly, by selecting <b>Install Guest Additions</b> "
1692 "from the <b>Machine</b> menu. "
1693 "If they are installed but the machine is not yet fully started "
1694 "then shared folders will be available once it is.</p>"),
1695 "remindAboutGuestAdditionsAreNotActive");
1696}
1697
1698int VBoxProblemReporter::cannotFindGuestAdditions (const QString &aSrc1,
1699 const QString &aSrc2)
1700{
1701 return message (mainMachineWindowShown(), Question,
1702 tr ("<p>Could not find the VirtualBox Guest Additions "
1703 "CD image file <nobr><b>%1</b></nobr> or "
1704 "<nobr><b>%2</b>.</nobr></p><p>Do you wish to "
1705 "download this CD image from the Internet?</p>")
1706 .arg (aSrc1).arg (aSrc2),
1707 0, /* aAutoConfirmId */
1708 QIMessageBox::Yes | QIMessageBox::Default,
1709 QIMessageBox::No | QIMessageBox::Escape);
1710}
1711
1712void VBoxProblemReporter::cannotDownloadGuestAdditions (const QString &aURL,
1713 const QString &aReason)
1714{
1715 message (mainMachineWindowShown(), Error,
1716 tr ("<p>Failed to download the VirtualBox Guest Additions CD "
1717 "image from <nobr><a href=\"%1\">%2</a>.</nobr></p><p>%3</p>")
1718 .arg (aURL).arg (aURL).arg (aReason));
1719}
1720
1721void VBoxProblemReporter::cannotMountGuestAdditions (const QString &aMachineName)
1722{
1723 message (mainMachineWindowShown(), Error,
1724 tr ("<p>Could not insert the VirtualBox Guest Additions "
1725 "installer CD image into the virtual machine <b>%1</b>, as the machine "
1726 "has no CD/DVD-ROM drives. Please add a drive using the "
1727 "storage page of the virtual machine settings dialog.</p>")
1728 .arg (aMachineName));
1729}
1730
1731bool VBoxProblemReporter::confirmDownloadAdditions (const QString &aURL,
1732 ulong aSize)
1733{
1734 return messageOkCancel (mainMachineWindowShown(), Question,
1735 tr ("<p>Are you sure you want to download the VirtualBox "
1736 "Guest Additions CD image from "
1737 "<nobr><a href=\"%1\">%2</a></nobr> "
1738 "(size %3 bytes)?</p>").arg (aURL).arg (aURL).arg (aSize),
1739 0, /* aAutoConfirmId */
1740 tr ("Download", "additions"));
1741}
1742
1743bool VBoxProblemReporter::confirmMountAdditions (const QString &aURL,
1744 const QString &aSrc)
1745{
1746 return messageOkCancel (mainMachineWindowShown(), Question,
1747 tr ("<p>The VirtualBox Guest Additions CD image has been "
1748 "successfully downloaded from "
1749 "<nobr><a href=\"%1\">%2</a></nobr> "
1750 "and saved locally as <nobr><b>%3</b>.</nobr></p>"
1751 "<p>Do you wish to register this CD image and mount it "
1752 "on the virtual CD/DVD drive?</p>")
1753 .arg (aURL).arg (aURL).arg (aSrc),
1754 0, /* aAutoConfirmId */
1755 tr ("Mount", "additions"));
1756}
1757
1758void VBoxProblemReporter::warnAboutTooOldAdditions (QWidget *aParent,
1759 const QString &aInstalledVer,
1760 const QString &aExpectedVer)
1761{
1762 message (aParent ? aParent : mainMachineWindowShown(), VBoxProblemReporter::Error,
1763 tr ("<p>The VirtualBox Guest Additions installed in the Guest OS are too "
1764 "old: the installed version is %1, the expected version is %2. "
1765 "Some features that require Guest Additions (mouse integration, "
1766 "guest display auto-resize) will most likely stop "
1767 "working properly.</p>"
1768 "<p>Please update the Guest Additions to the current version by choosing "
1769 "<b>Install Guest Additions</b> from the <b>Devices</b> "
1770 "menu.</p>")
1771 .arg (aInstalledVer).arg (aExpectedVer),
1772 "warnAboutTooOldAdditions");
1773}
1774
1775void VBoxProblemReporter::warnAboutOldAdditions (QWidget *aParent,
1776 const QString &aInstalledVer,
1777 const QString &aExpectedVer)
1778{
1779 message (aParent ? aParent : mainMachineWindowShown(), VBoxProblemReporter::Warning,
1780 tr ("<p>The VirtualBox Guest Additions installed in the Guest OS are "
1781 "outdated: the installed version is %1, the expected version is %2. "
1782 "Some features that require Guest Additions (mouse integration, "
1783 "guest display auto-resize) may not work as expected.</p>"
1784 "<p>It is recommended to update the Guest Additions to the current version "
1785 " by choosing <b>Install Guest Additions</b> from the <b>Devices</b> "
1786 "menu.</p>")
1787 .arg (aInstalledVer).arg (aExpectedVer),
1788 "warnAboutOldAdditions");
1789}
1790
1791void VBoxProblemReporter::warnAboutNewAdditions (QWidget *aParent,
1792 const QString &aInstalledVer,
1793 const QString &aExpectedVer)
1794{
1795 message (aParent ? aParent : mainMachineWindowShown(), VBoxProblemReporter::Error,
1796 tr ("<p>The VirtualBox Guest Additions installed in the Guest OS are "
1797 "too recent for this version of VirtualBox: the installed version "
1798 "is %1, the expected version is %2.</p>"
1799 "<p>Using a newer version of Additions with an older version of "
1800 "VirtualBox is not supported. Please install the current version "
1801 "of the Guest Additions by choosing <b>Install Guest Additions</b> "
1802 "from the <b>Devices</b> menu.</p>")
1803 .arg (aInstalledVer).arg (aExpectedVer),
1804 "warnAboutNewAdditions");
1805}
1806
1807bool VBoxProblemReporter::askAboutUserManualDownload(const QString &strMissedLocation)
1808{
1809 return messageOkCancel(mainWindowShown(), Question,
1810 tr("<p>Could not find the VirtualBox User Manual "
1811 "<nobr><b>%1</b>.</nobr></p><p>Do you wish to "
1812 "download this file from the Internet?</p>")
1813 .arg(strMissedLocation),
1814 0, /* Auto-confirm Id */
1815 tr ("Download", "additions"));
1816}
1817
1818bool VBoxProblemReporter::confirmUserManualDownload(const QString &strURL, ulong uSize)
1819{
1820 return messageOkCancel(mainWindowShown(), Question,
1821 tr ("<p>Are you sure you want to download the VirtualBox "
1822 "User Manual from "
1823 "<nobr><a href=\"%1\">%2</a></nobr> "
1824 "(size %3 bytes)?</p>").arg(strURL).arg(strURL).arg(uSize),
1825 0, /* Auto-confirm Id */
1826 tr ("Download", "additions"));
1827}
1828
1829void VBoxProblemReporter::warnAboutUserManualCantBeDownloaded(const QString &strURL, const QString &strReason)
1830{
1831 message(mainWindowShown(), Error,
1832 tr("<p>Failed to download the VirtualBox User Manual "
1833 "from <nobr><a href=\"%1\">%2</a>.</nobr></p><p>%3</p>")
1834 .arg(strURL).arg(strURL).arg(strReason));
1835}
1836
1837void VBoxProblemReporter::warnAboutUserManualDownloaded(const QString &strURL, const QString &strTarget)
1838{
1839 message(mainWindowShown(), Warning,
1840 tr("<p>The VirtualBox User Manual has been "
1841 "successfully downloaded from "
1842 "<nobr><a href=\"%1\">%2</a></nobr> "
1843 "and saved locally as <nobr><b>%3</b>.</nobr></p>")
1844 .arg(strURL).arg(strURL).arg(strTarget));
1845}
1846
1847void VBoxProblemReporter::warnAboutUserManualCantBeSaved(const QString &strURL, const QString &strTarget)
1848{
1849 message(mainWindowShown(), Error,
1850 tr("<p>The VirtualBox User Manual has been "
1851 "successfully downloaded from "
1852 "<nobr><a href=\"%1\">%2</a></nobr> "
1853 "but can't be saved locally as <nobr><b>%3</b>.</nobr></p>"
1854 "<p>Please choose another location for that file.</p>")
1855 .arg(strURL).arg(strURL).arg(strTarget));
1856}
1857
1858void VBoxProblemReporter::cannotConnectRegister (QWidget *aParent,
1859 const QString &aURL,
1860 const QString &aReason)
1861{
1862 /* we don't want to expose the registration script URL to the user
1863 * if he simply doesn't have an internet connection */
1864 Q_UNUSED (aURL);
1865
1866 message (aParent, Error,
1867 tr ("<p>Failed to connect to the VirtualBox online "
1868 "registration service due to the following error:</p><p><b>%1</b></p>")
1869 .arg (aReason));
1870}
1871
1872void VBoxProblemReporter::showRegisterResult (QWidget *aParent,
1873 const QString &aResult)
1874{
1875 if (aResult == "OK")
1876 {
1877 /* On successful registration attempt */
1878 message (aParent, Info,
1879 tr ("<p>Congratulations! You have been successfully registered "
1880 "as a user of VirtualBox.</p>"
1881 "<p>Thank you for finding time to fill out the "
1882 "registration form!</p>"));
1883 }
1884 else
1885 {
1886 QString parsed;
1887
1888 /* Else parse and translate special key-words */
1889 if (aResult == "AUTHFAILED")
1890 parsed = tr ("<p>Invalid e-mail address or password specified.</p>");
1891
1892 message (aParent, Error,
1893 tr ("<p>Failed to register the VirtualBox product.</p><p>%1</p>")
1894 .arg (parsed.isNull() ? aResult : parsed));
1895 }
1896}
1897
1898void VBoxProblemReporter::showUpdateSuccess (QWidget *aParent,
1899 const QString &aVersion,
1900 const QString &aLink)
1901{
1902 message (aParent, Info,
1903 tr ("<p>A new version of VirtualBox has been released! Version <b>%1</b> is available at <a href=\"http://www.virtualbox.org/\">virtualbox.org</a>.</p>"
1904 "<p>You can download this version using the link:</p>"
1905 "<p><a href=%2>%3</a></p>")
1906 .arg (aVersion, aLink, aLink));
1907}
1908
1909void VBoxProblemReporter::showUpdateFailure (QWidget *aParent,
1910 const QString &aReason)
1911{
1912 message (aParent, Error,
1913 tr ("<p>Unable to obtain the new version information "
1914 "due to the following error:</p><p><b>%1</b></p>")
1915 .arg (aReason));
1916}
1917
1918void VBoxProblemReporter::showUpdateNotFound (QWidget *aParent)
1919{
1920 message (aParent, Info,
1921 tr ("You are already running the most recent version of VirtualBox."
1922 ""));
1923}
1924
1925/**
1926 * @return @c true if the user has confirmed input capture (this is always
1927 * the case if the dialog was autoconfirmed). @a aAutoConfirmed, when not
1928 * NULL, will receive @c true if the dialog wasn't actually shown.
1929 */
1930bool VBoxProblemReporter::confirmInputCapture (bool *aAutoConfirmed /* = NULL */)
1931{
1932 int rc = message (mainMachineWindowShown(), Info,
1933 tr ("<p>You have <b>clicked the mouse</b> inside the Virtual Machine display "
1934 "or pressed the <b>host key</b>. This will cause the Virtual Machine to "
1935 "<b>capture</b> the host mouse pointer (only if the mouse pointer "
1936 "integration is not currently supported by the guest OS) and the "
1937 "keyboard, which will make them unavailable to other applications "
1938 "running on your host machine."
1939 "</p>"
1940 "<p>You can press the <b>host key</b> at any time to <b>uncapture</b> the "
1941 "keyboard and mouse (if it is captured) and return them to normal "
1942 "operation. The currently assigned host key is shown on the status bar "
1943 "at the bottom of the Virtual Machine window, next to the&nbsp;"
1944 "<img src=:/hostkey_16px.png/>&nbsp;icon. This icon, together "
1945 "with the mouse icon placed nearby, indicate the current keyboard "
1946 "and mouse capture state."
1947 "</p>") +
1948 tr ("<p>The host key is currently defined as <b>%1</b>.</p>",
1949 "additional message box paragraph")
1950 .arg (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())),
1951 "confirmInputCapture",
1952 QIMessageBox::Ok | QIMessageBox::Default,
1953 QIMessageBox::Cancel | QIMessageBox::Escape,
1954 0,
1955 tr ("Capture", "do input capture"));
1956
1957 if (aAutoConfirmed)
1958 *aAutoConfirmed = (rc & AutoConfirmed);
1959
1960 return (rc & QIMessageBox::ButtonMask) == QIMessageBox::Ok;
1961}
1962
1963void VBoxProblemReporter::remindAboutAutoCapture()
1964{
1965 message (mainMachineWindowShown(), Info,
1966 tr ("<p>You have the <b>Auto capture keyboard</b> option turned on. "
1967 "This will cause the Virtual Machine to automatically <b>capture</b> "
1968 "the keyboard every time the VM window is activated and make it "
1969 "unavailable to other applications running on your host machine: "
1970 "when the keyboard is captured, all keystrokes (including system ones "
1971 "like Alt-Tab) will be directed to the VM."
1972 "</p>"
1973 "<p>You can press the <b>host key</b> at any time to <b>uncapture</b> the "
1974 "keyboard and mouse (if it is captured) and return them to normal "
1975 "operation. The currently assigned host key is shown on the status bar "
1976 "at the bottom of the Virtual Machine window, next to the&nbsp;"
1977 "<img src=:/hostkey_16px.png/>&nbsp;icon. This icon, together "
1978 "with the mouse icon placed nearby, indicate the current keyboard "
1979 "and mouse capture state."
1980 "</p>") +
1981 tr ("<p>The host key is currently defined as <b>%1</b>.</p>",
1982 "additional message box paragraph")
1983 .arg (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())),
1984 "remindAboutAutoCapture");
1985}
1986
1987void VBoxProblemReporter::remindAboutMouseIntegration (bool aSupportsAbsolute)
1988{
1989 if (isAlreadyShown("remindAboutMouseIntegration"))
1990 return;
1991 setShownStatus("remindAboutMouseIntegration");
1992
1993 static const char *kNames [2] =
1994 {
1995 "remindAboutMouseIntegrationOff",
1996 "remindAboutMouseIntegrationOn"
1997 };
1998
1999 /* Close the previous (outdated) window if any. We use kName as
2000 * aAutoConfirmId which is also used as the widget name by default. */
2001 {
2002 QWidget *outdated =
2003 VBoxGlobal::findWidget (NULL, kNames [int (!aSupportsAbsolute)],
2004 "QIMessageBox");
2005 if (outdated)
2006 outdated->close();
2007 }
2008
2009 if (aSupportsAbsolute)
2010 {
2011 message (mainMachineWindowShown(), Info,
2012 tr ("<p>The Virtual Machine reports that the guest OS supports "
2013 "<b>mouse pointer integration</b>. This means that you do not "
2014 "need to <i>capture</i> the mouse pointer to be able to use it "
2015 "in your guest OS -- all "
2016 "mouse actions you perform when the mouse pointer is over the "
2017 "Virtual Machine's display are directly sent to the guest OS. "
2018 "If the mouse is currently captured, it will be automatically "
2019 "uncaptured."
2020 "</p>"
2021 "<p>The mouse icon on the status bar will look like&nbsp;"
2022 "<img src=:/mouse_seamless_16px.png/>&nbsp;to inform you that mouse "
2023 "pointer integration is supported by the guest OS and is "
2024 "currently turned on."
2025 "</p>"
2026 "<p><b>Note</b>: Some applications may behave incorrectly in "
2027 "mouse pointer integration mode. You can always disable it for "
2028 "the current session (and enable it again) by selecting the "
2029 "corresponding action from the menu bar."
2030 "</p>"),
2031 kNames [1] /* aAutoConfirmId */);
2032 }
2033 else
2034 {
2035 message (mainMachineWindowShown(), Info,
2036 tr ("<p>The Virtual Machine reports that the guest OS does not "
2037 "support <b>mouse pointer integration</b> in the current video "
2038 "mode. You need to capture the mouse (by clicking over the VM "
2039 "display or pressing the host key) in order to use the "
2040 "mouse inside the guest OS.</p>"),
2041 kNames [0] /* aAutoConfirmId */);
2042 }
2043
2044 clearShownStatus("remindAboutMouseIntegration");
2045}
2046
2047/**
2048 * @return @c false if the dialog wasn't actually shown (i.e. it was
2049 * autoconfirmed).
2050 */
2051bool VBoxProblemReporter::remindAboutPausedVMInput()
2052{
2053 int rc = message (
2054 mainMachineWindowShown(),
2055 Info,
2056 tr (
2057 "<p>The Virtual Machine is currently in the <b>Paused</b> state and "
2058 "not able to see any keyboard or mouse input. If you want to "
2059 "continue to work inside the VM, you need to resume it by selecting the "
2060 "corresponding action from the menu bar.</p>"
2061 ),
2062 "remindAboutPausedVMInput"
2063 );
2064 return !(rc & AutoConfirmed);
2065}
2066
2067/** @return true if the user has chosen to show the Disk Manager Window */
2068bool VBoxProblemReporter::remindAboutInaccessibleMedia()
2069{
2070 int rc = message (&vboxGlobal().selectorWnd(), Warning,
2071 tr ("<p>One or more virtual hard disks, CD/DVD or "
2072 "floppy media are not currently accessible. As a result, you will "
2073 "not be able to operate virtual machines that use these media until "
2074 "they become accessible later.</p>"
2075 "<p>Press <b>Check</b> to open the Virtual Media Manager window and "
2076 "see what media are inaccessible, or press <b>Ignore</b> to "
2077 "ignore this message.</p>"),
2078 "remindAboutInaccessibleMedia",
2079 QIMessageBox::Ok | QIMessageBox::Default,
2080 QIMessageBox::Ignore | QIMessageBox::Escape,
2081 0,
2082 tr ("Check", "inaccessible media message box"));
2083
2084 return rc == QIMessageBox::Ok; /* implies !AutoConfirmed */
2085}
2086
2087/**
2088 * Shows user a proposal to either convert configuration files or
2089 * Exit the application leaving all as already is.
2090 *
2091 * @param aFileList List of files for auto-conversion (may use Qt HTML).
2092 * @param aAfterRefresh @true when called after the VM refresh.
2093 *
2094 * @return QIMessageBox::Ok (Save + Backup), QIMessageBox::Cancel (Exit)
2095 */
2096int VBoxProblemReporter::warnAboutSettingsAutoConversion (const QString &aFileList,
2097 bool aAfterRefresh)
2098{
2099 if (!aAfterRefresh)
2100 {
2101 /* Common variant for all VMs */
2102 return message (mainWindowShown(), Info,
2103 tr ("<p>Your existing VirtualBox settings files will be automatically "
2104 "converted from the old format to a new format required by the "
2105 "new version of VirtualBox.</p>"
2106 "<p>Press <b>OK</b> to start VirtualBox now or press <b>Exit</b> if "
2107 "you want to terminate the VirtualBox "
2108 "application without any further actions.</p>"),
2109 NULL /* aAutoConfirmId */,
2110 QIMessageBox::Ok | QIMessageBox::Default,
2111 QIMessageBox::Cancel | QIMessageBox::Escape,
2112 0,
2113 0,
2114 tr ("E&xit", "warnAboutSettingsAutoConversion message box"));
2115 }
2116 else
2117 {
2118 /* Particular VM variant */
2119 return message (mainWindowShown(), Info,
2120 tr ("<p>The following VirtualBox settings files will be automatically "
2121 "converted from the old format to a new format required by the "
2122 "new version of VirtualBox.</p>"
2123 "<p>Press <b>OK</b> to start VirtualBox now or press <b>Exit</b> if "
2124 "you want to terminate the VirtualBox "
2125 "application without any further actions.</p>"),
2126 QString ("<!--EOM-->%1").arg (aFileList),
2127 NULL /* aAutoConfirmId */,
2128 QIMessageBox::Ok | QIMessageBox::Default,
2129 QIMessageBox::Cancel | QIMessageBox::Escape,
2130 0,
2131 0,
2132 tr ("E&xit", "warnAboutSettingsAutoConversion message box"));
2133 }
2134}
2135
2136/**
2137 * @param aHotKey Fullscreen hot key as defined in the menu.
2138 *
2139 * @return @c true if the user has chosen to go fullscreen (this is always
2140 * the case if the dialog was autoconfirmed).
2141 */
2142bool VBoxProblemReporter::confirmGoingFullscreen (const QString &aHotKey)
2143{
2144 return messageOkCancel (mainMachineWindowShown(), Info,
2145 tr ("<p>The virtual machine window will be now switched to "
2146 "<b>fullscreen</b> mode. "
2147 "You can go back to windowed mode at any time by pressing "
2148 "<b>%1</b>. Note that the <i>Host</i> key is currently "
2149 "defined as <b>%2</b>.</p>"
2150 "<p>Note that the main menu bar is hidden in fullscreen mode. You "
2151 "can access it by pressing <b>Host+Home</b>.</p>")
2152 .arg (aHotKey)
2153 .arg (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())),
2154 "confirmGoingFullscreen",
2155 tr ("Switch", "fullscreen"));
2156}
2157
2158/**
2159 * @param aHotKey Seamless hot key as defined in the menu.
2160 *
2161 * @return @c true if the user has chosen to go seamless (this is always
2162 * the case if the dialog was autoconfirmed).
2163 */
2164bool VBoxProblemReporter::confirmGoingSeamless (const QString &aHotKey)
2165{
2166 return messageOkCancel (mainMachineWindowShown(), Info,
2167 tr ("<p>The virtual machine window will be now switched to "
2168 "<b>Seamless</b> mode. "
2169 "You can go back to windowed mode at any time by pressing "
2170 "<b>%1</b>. Note that the <i>Host</i> key is currently "
2171 "defined as <b>%2</b>.</p>"
2172 "<p>Note that the main menu bar is hidden in seamless mode. You "
2173 "can access it by pressing <b>Host+Home</b>.</p>")
2174 .arg (aHotKey)
2175 .arg (QIHotKeyEdit::keyName (vboxGlobal().settings().hostKey())),
2176 "confirmGoingSeamless",
2177 tr ("Switch", "seamless"));
2178}
2179
2180void VBoxProblemReporter::remindAboutWrongColorDepth (ulong aRealBPP,
2181 ulong aWantedBPP)
2182{
2183 const char *kName = "remindAboutWrongColorDepth";
2184
2185 /* Close the previous (outdated) window if any. We use kName as
2186 * aAutoConfirmId which is also used as the widget name by default. */
2187 {
2188 QWidget *outdated = VBoxGlobal::findWidget (NULL, kName, "QIMessageBox");
2189 if (outdated)
2190 outdated->close();
2191 }
2192
2193 int rc = message (mainMachineWindowShown(), Info,
2194 tr ("<p>The virtual machine window is optimized to work in "
2195 "<b>%1&nbsp;bit</b> color mode but the "
2196 "virtual display is currently set to <b>%2&nbsp;bit</b>.</p>"
2197 "<p>Please open the display properties dialog of the guest OS and "
2198 "select a <b>%3&nbsp;bit</b> color mode, if it is available, for "
2199 "best possible performance of the virtual video subsystem.</p>"
2200 "<p><b>Note</b>. Some operating systems, like OS/2, may actually "
2201 "work in 32&nbsp;bit mode but report it as 24&nbsp;bit "
2202 "(16 million colors). You may try to select a different color "
2203 "mode to see if this message disappears or you can simply "
2204 "disable the message now if you are sure the required color "
2205 "mode (%4&nbsp;bit) is not available in the guest OS.</p>")
2206 .arg (aWantedBPP).arg (aRealBPP).arg (aWantedBPP).arg (aWantedBPP),
2207 kName);
2208 NOREF(rc);
2209}
2210
2211/**
2212 * Returns @c true if the user has selected to power off the machine.
2213 */
2214bool VBoxProblemReporter::remindAboutGuruMeditation (const CConsole &aConsole,
2215 const QString &aLogFolder)
2216{
2217 Q_UNUSED (aConsole);
2218
2219 int rc = message (mainMachineWindowShown(), GuruMeditation,
2220 tr ("<p>A critical error has occurred while running the virtual "
2221 "machine and the machine execution has been stopped.</p>"
2222 ""
2223 "<p>For help, please see the Community section on "
2224 "<a href=http://www.virtualbox.org>http://www.virtualbox.org</a> "
2225 "or your support contract. Please provide the contents of the "
2226 "log file <tt>VBox.log</tt> and the image file <tt>VBox.png</tt>, "
2227 "which you can find in the <nobr><b>%1</b></nobr> directory, "
2228 "as well as a description of what you were doing when this error "
2229 "happened. "
2230 ""
2231 "Note that you can also access the above files by selecting "
2232 "<b>Show Log</b> from the <b>Machine</b> menu of the main "
2233 "VirtualBox window.</p>"
2234 ""
2235 "<p>Press <b>OK</b> if you want to power off the machine "
2236 "or press <b>Ignore</b> if you want to leave it as is for debugging. "
2237 "Please note that debugging requires special knowledge and tools, so "
2238 "it is recommended to press <b>OK</b> now.</p>")
2239 .arg (aLogFolder),
2240 0, /* aAutoConfirmId */
2241 QIMessageBox::Ok | QIMessageBox::Default,
2242 QIMessageBox::Ignore | QIMessageBox::Escape);
2243
2244 return rc == QIMessageBox::Ok;
2245}
2246
2247/**
2248 * @return @c true if the user has selected to reset the machine.
2249 */
2250bool VBoxProblemReporter::confirmVMReset (QWidget *aParent)
2251{
2252 return messageOkCancel (aParent ? aParent : mainMachineWindowShown(), Question,
2253 tr ("<p>Do you really want to reset the virtual machine?</p>"
2254 "<p>This will cause any unsaved data in applications running inside "
2255 "it to be lost.</p>"),
2256 "confirmVMReset" /* aAutoConfirmId */,
2257 tr ("Reset", "machine"));
2258}
2259
2260/**
2261 * @return @c true if the user has selected to continue without attaching a
2262 * hard disk.
2263 */
2264bool VBoxProblemReporter::confirmHardDisklessMachine (QWidget *aParent)
2265{
2266 return message (aParent, Warning,
2267 tr ("<p>You didn't attach a hard disk to the new virtual machine. "
2268 "The machine will not be able to boot unless you attach "
2269 "a hard disk with a guest operating system or some other bootable "
2270 "media to it later using the machine settings dialog or the First "
2271 "Run Wizard.</p><p>Do you wish to continue?</p>"),
2272 0, /* aAutoConfirmId */
2273 QIMessageBox::Ok,
2274 QIMessageBox::Cancel | QIMessageBox::Default | QIMessageBox::Escape,
2275 0,
2276 tr ("Continue", "no hard disk attached"),
2277 tr ("Go Back", "no hard disk attached")) == QIMessageBox::Ok;
2278}
2279
2280void VBoxProblemReporter::cannotRunInSelectorMode()
2281{
2282 message (mainWindowShown(), Critical,
2283 tr ("<p>Cannot run VirtualBox in <i>VM Selector</i> "
2284 "mode due to local restrictions.</p>"
2285 "<p>The application will now terminate.</p>"));
2286}
2287
2288void VBoxProblemReporter::cannotImportAppliance (CAppliance *aAppliance, QWidget *aParent /* = NULL */) const
2289{
2290 if (aAppliance->isNull())
2291 {
2292 message (aParent ? aParent : mainWindowShown(),
2293 Error,
2294 tr ("Failed to open appliance."));
2295 }else
2296 {
2297 /* Preserve the current error info before calling the object again */
2298 COMResult res (*aAppliance);
2299
2300 /* Add the warnings in the case of an early error */
2301 QVector<QString> w = aAppliance->GetWarnings();
2302 QString wstr;
2303 foreach (const QString &str, w)
2304 wstr += QString ("<br />Warning: %1").arg (str);
2305 if (!wstr.isEmpty())
2306 wstr = "<br />" + wstr;
2307
2308 message (aParent ? aParent : mainWindowShown(),
2309 Error,
2310 tr ("Failed to open/interpret appliance <b>%1</b>.").arg (aAppliance->GetPath()),
2311 wstr +
2312 formatErrorInfo (res));
2313 }
2314}
2315
2316void VBoxProblemReporter::cannotImportAppliance (const CProgress &aProgress, CAppliance* aAppliance, QWidget *aParent /* = NULL */) const
2317{
2318 AssertWrapperOk (aProgress);
2319
2320 message (aParent ? aParent : mainWindowShown(),
2321 Error,
2322 tr ("Failed to import appliance <b>%1</b>.").arg (aAppliance->GetPath()),
2323 formatErrorInfo (aProgress.GetErrorInfo()));
2324}
2325
2326void VBoxProblemReporter::cannotCheckFiles (const CProgress &aProgress, QWidget *aParent /* = NULL */) const
2327{
2328 AssertWrapperOk (aProgress);
2329
2330 message (aParent ? aParent : mainWindowShown(),
2331 Error,
2332 tr ("Failed to check files."),
2333 formatErrorInfo (aProgress.GetErrorInfo()));
2334}
2335
2336void VBoxProblemReporter::cannotRemoveFiles (const CProgress &aProgress, QWidget *aParent /* = NULL */) const
2337{
2338 AssertWrapperOk (aProgress);
2339
2340 message (aParent ? aParent : mainWindowShown(),
2341 Error,
2342 tr ("Failed to remove file."),
2343 formatErrorInfo (aProgress.GetErrorInfo()));
2344}
2345
2346bool VBoxProblemReporter::confirmExportMachinesInSaveState(const QStringList &machineNames, QWidget * /* aParent = NULL */) const
2347{
2348 return messageOkCancel(mainWindowShown(), Warning,
2349 tr("<p>The virtual machine(s) <b>%1</b> are currently in a saved state.</p>"
2350 "<p>If you continue the runtime state of the exported machine(s) "
2351 "will be discarded. Note that the existing machine(s) are not "
2352 "changed.</p>", "",
2353 machineNames.size()).arg(VBoxGlobal::toHumanReadableList(machineNames)),
2354 0 /* aAutoConfirmId */,
2355 tr("Continue"), tr("Cancel"));
2356}
2357
2358void VBoxProblemReporter::cannotExportAppliance (CAppliance *aAppliance, QWidget *aParent /* = NULL */) const
2359{
2360 if (aAppliance->isNull())
2361 {
2362 message (aParent ? aParent : mainWindowShown(),
2363 Error,
2364 tr ("Failed to create appliance."));
2365 }else
2366 {
2367 /* Preserve the current error info before calling the object again */
2368 COMResult res (*aAppliance);
2369
2370 message (aParent ? aParent : mainWindowShown(),
2371 Error,
2372 tr ("Failed to prepare the export of the appliance <b>%1</b>.").arg (aAppliance->GetPath()),
2373 formatErrorInfo (res));
2374 }
2375}
2376
2377void VBoxProblemReporter::cannotExportAppliance (const CMachine &aMachine, CAppliance *aAppliance, QWidget *aParent /* = NULL */) const
2378{
2379 if (aAppliance->isNull() ||
2380 aMachine.isNull())
2381 {
2382 message (aParent ? aParent : mainWindowShown(),
2383 Error,
2384 tr ("Failed to create an appliance."));
2385 }else
2386 {
2387 message (aParent ? aParent : mainWindowShown(),
2388 Error,
2389 tr ("Failed to prepare the export of the appliance <b>%1</b>.").arg (aAppliance->GetPath()),
2390 formatErrorInfo (aMachine));
2391 }
2392}
2393
2394void VBoxProblemReporter::cannotExportAppliance (const CProgress &aProgress, CAppliance* aAppliance, QWidget *aParent /* = NULL */) const
2395{
2396 AssertWrapperOk (aProgress);
2397
2398 message (aParent ? aParent : mainWindowShown(),
2399 Error,
2400 tr ("Failed to export appliance <b>%1</b>.").arg (aAppliance->GetPath()),
2401 formatErrorInfo (aProgress.GetErrorInfo()));
2402}
2403
2404void VBoxProblemReporter::cannotUpdateGuestAdditions (const CProgress &aProgress, QWidget *aParent /* = NULL */) const
2405{
2406 AssertWrapperOk (aProgress);
2407
2408 message (aParent ? aParent : mainWindowShown(),
2409 Error,
2410 tr ("Failed to update Guest Additions. The Guest Additions installation image will be mounted to provide a manual installation."),
2411 formatErrorInfo (aProgress.GetErrorInfo()));
2412}
2413
2414void VBoxProblemReporter::warnAboutIncorrectPort (QWidget *pParent) const
2415{
2416 message(pParent, Error,
2417 tr("The current port forwarding rules are not valid. "
2418 "None of the host or guest port values may be set to zero."));
2419}
2420
2421bool VBoxProblemReporter::confirmCancelingPortForwardingDialog (QWidget *pParent) const
2422{
2423 return messageOkCancel(pParent, Question,
2424 tr("<p>There are unsaved changes in the port forwarding configuration.</p>"
2425 "<p>If you proceed your changes will be discarded.</p>"));
2426}
2427
2428void VBoxProblemReporter::showRuntimeError (const CConsole &aConsole, bool fatal,
2429 const QString &errorID,
2430 const QString &errorMsg) const
2431{
2432 /// @todo (r=dmik) it's just a preliminary box. We need to:
2433 // - for fatal errors and non-fatal with-retry errors, listen for a
2434 // VM state signal to automatically close the message if the VM
2435 // (externally) leaves the Paused state while it is shown.
2436 // - make warning messages modeless
2437 // - add common buttons like Retry/Save/PowerOff/whatever
2438
2439 QByteArray autoConfimId = "showRuntimeError.";
2440
2441 CConsole console = aConsole;
2442 KMachineState state = console.GetState();
2443 Type type;
2444 QString severity;
2445
2446 if (fatal)
2447 {
2448 /* the machine must be paused on fatal errors */
2449 Assert (state == KMachineState_Paused);
2450 if (state != KMachineState_Paused)
2451 console.Pause();
2452 type = Critical;
2453 severity = tr ("<nobr>Fatal Error</nobr>", "runtime error info");
2454 autoConfimId += "fatal.";
2455 }
2456 else if (state == KMachineState_Paused)
2457 {
2458 type = Error;
2459 severity = tr ("<nobr>Non-Fatal Error</nobr>", "runtime error info");
2460 autoConfimId += "error.";
2461 }
2462 else
2463 {
2464 type = Warning;
2465 severity = tr ("<nobr>Warning</nobr>", "runtime error info");
2466 autoConfimId += "warning.";
2467 }
2468
2469 autoConfimId += errorID.toUtf8();
2470
2471 QString formatted ("<!--EOM-->");
2472
2473 if (!errorMsg.isEmpty())
2474 formatted.prepend (QString ("<p>%1.</p>").arg (vboxGlobal().emphasize (errorMsg)));
2475
2476 if (!errorID.isEmpty())
2477 formatted += QString ("<table bgcolor=#EEEEEE border=0 cellspacing=0 "
2478 "cellpadding=0 width=100%>"
2479 "<tr><td>%1</td><td>%2</td></tr>"
2480 "<tr><td>%3</td><td>%4</td></tr>"
2481 "</table>")
2482 .arg (tr ("<nobr>Error ID: </nobr>", "runtime error info"),
2483 errorID)
2484 .arg (tr ("Severity: ", "runtime error info"),
2485 severity);
2486
2487 if (!formatted.isEmpty())
2488 formatted = "<qt>" + formatted + "</qt>";
2489
2490 int rc = 0;
2491
2492 if (type == Critical)
2493 {
2494 rc = message (mainMachineWindowShown(), type,
2495 tr ("<p>A fatal error has occurred during virtual machine execution! "
2496 "The virtual machine will be powered off. Please copy the "
2497 "following error message using the clipboard to help diagnose "
2498 "the problem:</p>"),
2499 formatted, autoConfimId.data());
2500
2501 /* always power down after a fatal error */
2502 console.PowerDown();
2503 }
2504 else if (type == Error)
2505 {
2506 rc = message (mainMachineWindowShown(), type,
2507 tr ("<p>An error has occurred during virtual machine execution! "
2508 "The error details are shown below. You may try to correct "
2509 "the error and resume the virtual machine "
2510 "execution.</p>"),
2511 formatted, autoConfimId.data());
2512 }
2513 else
2514 {
2515 rc = message (mainMachineWindowShown(), type,
2516 tr ("<p>The virtual machine execution may run into an error "
2517 "condition as described below. "
2518 "We suggest that you take "
2519 "an appropriate action to avert the error."
2520 "</p>"),
2521 formatted, autoConfimId.data());
2522 }
2523
2524 NOREF (rc);
2525}
2526
2527/* static */
2528QString VBoxProblemReporter::mediumToAccusative (VBoxDefs::MediumType aType, bool aIsHostDrive /* = false */)
2529{
2530 QString type =
2531 aType == VBoxDefs::MediumType_HardDisk ?
2532 tr ("hard disk", "failed to mount ...") :
2533 aType == VBoxDefs::MediumType_DVD && aIsHostDrive ?
2534 tr ("CD/DVD", "failed to mount ... host-drive") :
2535 aType == VBoxDefs::MediumType_DVD && !aIsHostDrive ?
2536 tr ("CD/DVD image", "failed to mount ...") :
2537 aType == VBoxDefs::MediumType_Floppy && aIsHostDrive ?
2538 tr ("floppy", "failed to mount ... host-drive") :
2539 aType == VBoxDefs::MediumType_Floppy && !aIsHostDrive ?
2540 tr ("floppy image", "failed to mount ...") :
2541 QString::null;
2542
2543 Assert (!type.isNull());
2544 return type;
2545}
2546
2547/* static */
2548QString VBoxProblemReporter::deviceToAccusative (VBoxDefs::MediumType aType)
2549{
2550 QString type =
2551 aType == VBoxDefs::MediumType_HardDisk ?
2552 tr ("hard disk", "failed to attach ...") :
2553 aType == VBoxDefs::MediumType_DVD ?
2554 tr ("CD/DVD device", "failed to attach ...") :
2555 aType == VBoxDefs::MediumType_Floppy ?
2556 tr ("floppy device", "failed to close ...") :
2557 QString::null;
2558
2559 Assert (!type.isNull());
2560 return type;
2561}
2562
2563/**
2564 * Formats the given COM result code as a human-readable string.
2565 *
2566 * If a mnemonic name for the given result code is found, a string in format
2567 * "MNEMONIC_NAME (0x12345678)" is returned where the hex number is the result
2568 * code as is. If no mnemonic name is found, then the raw hex number only is
2569 * returned (w/o parenthesis).
2570 *
2571 * @param aRC COM result code to format.
2572 */
2573/* static */
2574QString VBoxProblemReporter::formatRC (HRESULT aRC)
2575{
2576 QString str;
2577
2578 PCRTCOMERRMSG msg = NULL;
2579 const char *errMsg = NULL;
2580
2581 /* first, try as is (only set bit 31 bit for warnings) */
2582 if (SUCCEEDED_WARNING (aRC))
2583 msg = RTErrCOMGet (aRC | 0x80000000);
2584 else
2585 msg = RTErrCOMGet (aRC);
2586
2587 if (msg != NULL)
2588 errMsg = msg->pszDefine;
2589
2590#if defined (Q_WS_WIN)
2591
2592 PCRTWINERRMSG winMsg = NULL;
2593
2594 /* if not found, try again using RTErrWinGet with masked off top 16bit */
2595 if (msg == NULL)
2596 {
2597 winMsg = RTErrWinGet (aRC & 0xFFFF);
2598
2599 if (winMsg != NULL)
2600 errMsg = winMsg->pszDefine;
2601 }
2602
2603#endif
2604
2605 if (errMsg != NULL && *errMsg != '\0')
2606 str.sprintf ("%s (0x%08X)", errMsg, aRC);
2607 else
2608 str.sprintf ("0x%08X", aRC);
2609
2610 return str;
2611}
2612
2613/* static */
2614QString VBoxProblemReporter::formatErrorInfo (const COMErrorInfo &aInfo,
2615 HRESULT aWrapperRC /* = S_OK */)
2616{
2617 QString formatted = doFormatErrorInfo (aInfo, aWrapperRC);
2618 return QString ("<qt>%1</qt>").arg (formatted);
2619}
2620
2621/* static */
2622QString VBoxProblemReporter::doFormatErrorInfo (const COMErrorInfo &aInfo,
2623 HRESULT aWrapperRC /* = S_OK */)
2624{
2625 /* Compose complex details string with internal <!--EOM--> delimiter to
2626 * make it possible to split string into info & details parts which will
2627 * be used separately in QIMessageBox */
2628 QString formatted;
2629
2630 if (!aInfo.text().isEmpty())
2631 formatted += QString ("<p>%1.</p>").arg (vboxGlobal().emphasize (aInfo.text()));
2632
2633 formatted += "<!--EOM--><table bgcolor=#EEEEEE border=0 cellspacing=0 "
2634 "cellpadding=0 width=100%>";
2635
2636 bool haveResultCode = false;
2637
2638 if (aInfo.isBasicAvailable())
2639 {
2640#if defined (Q_WS_WIN)
2641 haveResultCode = aInfo.isFullAvailable();
2642 bool haveComponent = true;
2643 bool haveInterfaceID = true;
2644#else /* defined (Q_WS_WIN) */
2645 haveResultCode = true;
2646 bool haveComponent = aInfo.isFullAvailable();
2647 bool haveInterfaceID = aInfo.isFullAvailable();
2648#endif
2649
2650 if (haveResultCode)
2651 {
2652 formatted += QString ("<tr><td>%1</td><td><tt>%2</tt></td></tr>")
2653 .arg (tr ("Result&nbsp;Code: ", "error info"))
2654 .arg (formatRC (aInfo.resultCode()));
2655 }
2656
2657 if (haveComponent)
2658 formatted += QString ("<tr><td>%1</td><td>%2</td></tr>")
2659 .arg (tr ("Component: ", "error info"), aInfo.component());
2660
2661 if (haveInterfaceID)
2662 {
2663 QString s = aInfo.interfaceID();
2664 if (!aInfo.interfaceName().isEmpty())
2665 s = aInfo.interfaceName() + ' ' + s;
2666 formatted += QString ("<tr><td>%1</td><td>%2</td></tr>")
2667 .arg (tr ("Interface: ", "error info"), s);
2668 }
2669
2670 if (!aInfo.calleeIID().isNull() && aInfo.calleeIID() != aInfo.interfaceID())
2671 {
2672 QString s = aInfo.calleeIID();
2673 if (!aInfo.calleeName().isEmpty())
2674 s = aInfo.calleeName() + ' ' + s;
2675 formatted += QString ("<tr><td>%1</td><td>%2</td></tr>")
2676 .arg (tr ("Callee: ", "error info"), s);
2677 }
2678 }
2679
2680 if (FAILED (aWrapperRC) &&
2681 (!haveResultCode || aWrapperRC != aInfo.resultCode()))
2682 {
2683 formatted += QString ("<tr><td>%1</td><td><tt>%2</tt></td></tr>")
2684 .arg (tr ("Callee&nbsp;RC: ", "error info"))
2685 .arg (formatRC (aWrapperRC));
2686 }
2687
2688 formatted += "</table>";
2689
2690 if (aInfo.next())
2691 formatted = formatted + "<!--EOP-->" + doFormatErrorInfo (*aInfo.next());
2692
2693 return formatted;
2694}
2695
2696// Public slots
2697/////////////////////////////////////////////////////////////////////////////
2698
2699void VBoxProblemReporter::showHelpWebDialog()
2700{
2701 vboxGlobal().openURL ("http://www.virtualbox.org");
2702}
2703
2704void VBoxProblemReporter::showHelpAboutDialog()
2705{
2706 CVirtualBox vbox = vboxGlobal().virtualBox();
2707 QString fullVersion ;
2708 if (vboxGlobal().brandingIsActive())
2709 {
2710 fullVersion = (QString ("%1 r%2 - %3").arg (vbox.GetVersion())
2711 .arg (vbox.GetRevision())
2712 .arg (vboxGlobal().brandingGetKey("Name")));
2713 }
2714 else
2715 {
2716 fullVersion = (QString ("%1 r%2").arg (vbox.GetVersion())
2717 .arg (vbox.GetRevision()));
2718 }
2719 AssertWrapperOk (vbox);
2720
2721 // this (QWidget*) cast is necessary to work around a gcc-3.2 bug */
2722 VBoxAboutDlg ((QWidget*)mainWindowShown(), fullVersion).exec();
2723}
2724
2725void VBoxProblemReporter::showHelpHelpDialog()
2726{
2727#ifndef VBOX_OSE
2728 /* For non-OSE version we just open it: */
2729 sltShowUserManual(vboxGlobal().helpFile());
2730#else /* #ifndef VBOX_OSE */
2731 /* For OSE version we have to check if it present first: */
2732 QString strUserManualFileName1 = vboxGlobal().helpFile();
2733 QString strShortFileName = QFileInfo(strUserManualFileName1).fileName();
2734 QString strUserManualFileName2 = QDir(vboxGlobal().virtualBox().GetHomeFolder()).absoluteFilePath(strShortFileName);
2735 if (QFile::exists(strUserManualFileName1))
2736 {
2737 sltShowUserManual(strUserManualFileName1);
2738 }
2739 else if (QFile::exists(strUserManualFileName2))
2740 {
2741 sltShowUserManual(strUserManualFileName2);
2742 }
2743 else if (!UIDownloaderUserManual::current() && askAboutUserManualDownload(strUserManualFileName1))
2744 {
2745 /* Create User Manual downloader: */
2746 UIDownloaderUserManual *pDl = UIDownloaderUserManual::create();
2747 /* Configure User Manual downloader: */
2748 CVirtualBox vbox = vboxGlobal().virtualBox();
2749 pDl->addSource(QString("http://download.virtualbox.org/virtualbox/%1/").arg(vbox.GetVersion().remove("_OSE")) + strShortFileName);
2750 pDl->addSource(QString("http://download.virtualbox.org/virtualbox/") + strShortFileName);
2751 pDl->setTarget(strUserManualFileName2);
2752 pDl->setParentWidget(mainWindowShown());
2753 /* After the download is finished => show the document: */
2754 connect(pDl, SIGNAL(sigDownloadFinished(const QString&)), this, SLOT(sltShowUserManual(const QString&)));
2755 /* Notify listeners: */
2756 emit sigDownloaderUserManualCreated();
2757 /* Start the downloader: */
2758 pDl->startDownload();
2759 }
2760#endif /* #ifdef VBOX_OSE */
2761}
2762
2763void VBoxProblemReporter::resetSuppressedMessages()
2764{
2765 CVirtualBox vbox = vboxGlobal().virtualBox();
2766 vbox.SetExtraData (VBoxDefs::GUI_SuppressMessages, QString::null);
2767}
2768
2769void VBoxProblemReporter::sltShowUserManual(const QString &strLocation)
2770{
2771#if defined (Q_WS_WIN32)
2772 HtmlHelp(GetDesktopWindow(), strLocation.utf16(), HH_DISPLAY_TOPIC, NULL);
2773#elif defined (Q_WS_X11)
2774# ifndef VBOX_OSE
2775 char szViewerPath[RTPATH_MAX];
2776 int rc;
2777 rc = RTPathAppPrivateArch(szViewerPath, sizeof(szViewerPath));
2778 AssertRC(rc);
2779 QProcess::startDetached(QString(szViewerPath) + "/kchmviewer", QStringList(strLocation));
2780# else /* #ifndef VBOX_OSE */
2781 vboxGlobal().openURL("file://" + strLocation);
2782# endif /* #ifdef VBOX_OSE */
2783#elif defined (Q_WS_MAC)
2784 vboxGlobal().openURL("file://" + strLocation);
2785#endif
2786}
2787
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette