VirtualBox

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

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

FE/Qt: Problem reporter: spelling fix for r67756.

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

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