VirtualBox

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

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

FE/Qt4: implemented new deletion possibilities in the GUI

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