VirtualBox

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

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

FE/Qt: New VM Wizard: Warn the user if the machine folder can not be created due to lack of permissions.

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