VirtualBox

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

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

Frontends/VirtualBox: add problem reporter method to warn the user of insufficient disk space. not used yet, but putting it in early will give the translators more time.

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