VirtualBox

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

Last change on this file since 29794 was 29794, checked in by vboxsync, 15 years ago

FE/Qt4: remove old core

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

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