VirtualBox

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

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

FE/Qt4: more cleanup (this is used since ages ago)

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