VirtualBox

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

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

Guest Copy/Guest Additions: Update.

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

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