VirtualBox

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

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

FE/Qt4: confirm based on the attached disks count

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