VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp@ 82781

Last change on this file since 82781 was 82008, checked in by vboxsync, 5 years ago

FE/Qt: GUI coding-style fixes for r134761; Some places too old to be updated, but new taken into account.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 139.7 KB
Line 
1/* $Id: UIMessageCenter.cpp 82008 2019-11-19 20:50:14Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIMessageCenter class implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/* Qt includes: */
19#include <QDir>
20#include <QFileInfo>
21#include <QLocale>
22#include <QThread>
23#include <QProcess>
24#ifdef VBOX_WS_MAC
25# include <QPushButton>
26#endif
27
28/* GUI includes: */
29#include "QIMessageBox.h"
30#include "UICommon.h"
31#include "UIConverter.h"
32#include "UIMessageCenter.h"
33#include "UIProgressDialog.h"
34#include "UIErrorString.h"
35#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
36# include "UINetworkManager.h"
37# include "UINetworkManagerDialog.h"
38#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
39#include "UIModalWindowManager.h"
40#include "UIExtraDataManager.h"
41#include "UIMedium.h"
42#ifdef VBOX_OSE
43# include "UIDownloaderUserManual.h"
44#endif /* VBOX_OSE */
45#include "VBoxAboutDlg.h"
46#include "UIHostComboEditor.h"
47#ifdef VBOX_WS_MAC
48# include "VBoxUtils-darwin.h"
49#endif
50#ifdef VBOX_WS_WIN
51# include <Htmlhelp.h>
52#endif
53
54/* COM includes: */
55#include "CAudioAdapter.h"
56#include "CBooleanFormValue.h"
57#include "CChoiceFormValue.h"
58#include "CCloudClient.h"
59#include "CCloudProfile.h"
60#include "CCloudProvider.h"
61#include "CCloudProviderManager.h"
62#include "CDHCPServer.h"
63#include "CGraphicsAdapter.h"
64#include "CNATEngine.h"
65#include "CNATNetwork.h"
66#include "CNetworkAdapter.h"
67#include "CRangedIntegerFormValue.h"
68#include "CSerialPort.h"
69#include "CSharedFolder.h"
70#include "CSnapshot.h"
71#include "CStorageController.h"
72#include "CStringFormValue.h"
73#include "CConsole.h"
74#include "CMachine.h"
75#include "CSystemProperties.h"
76#include "CVirtualBoxErrorInfo.h"
77#include "CMediumAttachment.h"
78#include "CMediumFormat.h"
79#include "CAppliance.h"
80#include "CExtPackManager.h"
81#include "CExtPackFile.h"
82#include "CHostNetworkInterface.h"
83#include "CVFSExplorer.h"
84#include "CVirtualSystemDescription.h"
85#include "CVirtualSystemDescriptionForm.h"
86#ifdef VBOX_WITH_DRAG_AND_DROP
87# include "CGuest.h"
88# include "CDnDSource.h"
89# include "CDnDTarget.h"
90#endif /* VBOX_WITH_DRAG_AND_DROP */
91
92/* Other VBox includes: */
93#include <iprt/param.h>
94#include <iprt/path.h>
95
96#include <iprt/errcore.h>
97
98
99/* static */
100UIMessageCenter *UIMessageCenter::s_pInstance = 0;
101UIMessageCenter *UIMessageCenter::instance() { return s_pInstance; }
102
103/* static */
104void UIMessageCenter::create()
105{
106 /* Make sure instance is NOT created yet: */
107 if (s_pInstance)
108 {
109 AssertMsgFailed(("UIMessageCenter instance is already created!"));
110 return;
111 }
112
113 /* Create instance: */
114 new UIMessageCenter;
115 /* Prepare instance: */
116 s_pInstance->prepare();
117}
118
119/* static */
120void UIMessageCenter::destroy()
121{
122 /* Make sure instance is NOT destroyed yet: */
123 if (!s_pInstance)
124 {
125 AssertMsgFailed(("UIMessageCenter instance is already destroyed!"));
126 return;
127 }
128
129 /* Cleanup instance: */
130 s_pInstance->cleanup();
131 /* Destroy instance: */
132 delete s_pInstance;
133}
134
135void UIMessageCenter::setWarningShown(const QString &strWarningName, bool fWarningShown) const
136{
137 if (fWarningShown && !m_warnings.contains(strWarningName))
138 m_warnings.append(strWarningName);
139 else if (!fWarningShown && m_warnings.contains(strWarningName))
140 m_warnings.removeAll(strWarningName);
141}
142
143bool UIMessageCenter::warningShown(const QString &strWarningName) const
144{
145 return m_warnings.contains(strWarningName);
146}
147
148int UIMessageCenter::message(QWidget *pParent, MessageType enmType,
149 const QString &strMessage,
150 const QString &strDetails,
151 const char *pcszAutoConfirmId /* = 0*/,
152 int iButton1 /* = 0*/,
153 int iButton2 /* = 0*/,
154 int iButton3 /* = 0*/,
155 const QString &strButtonText1 /* = QString() */,
156 const QString &strButtonText2 /* = QString() */,
157 const QString &strButtonText3 /* = QString() */) const
158{
159 /* If this is NOT a GUI thread: */
160 if (thread() != QThread::currentThread())
161 {
162 /* We have to throw a blocking signal
163 * to show a message-box in the GUI thread: */
164 emit sigToShowMessageBox(pParent, enmType,
165 strMessage, strDetails,
166 iButton1, iButton2, iButton3,
167 strButtonText1, strButtonText2, strButtonText3,
168 QString(pcszAutoConfirmId));
169 /* Inter-thread communications are not yet implemented: */
170 return 0;
171 }
172 /* In usual case we can chow a message-box directly: */
173 return showMessageBox(pParent, enmType,
174 strMessage, strDetails,
175 iButton1, iButton2, iButton3,
176 strButtonText1, strButtonText2, strButtonText3,
177 QString(pcszAutoConfirmId));
178}
179
180void UIMessageCenter::error(QWidget *pParent, MessageType enmType,
181 const QString &strMessage,
182 const QString &strDetails,
183 const char *pcszAutoConfirmId /* = 0*/) const
184{
185 message(pParent, enmType, strMessage, strDetails, pcszAutoConfirmId,
186 AlertButton_Ok | AlertButtonOption_Default | AlertButtonOption_Escape);
187}
188
189bool UIMessageCenter::errorWithQuestion(QWidget *pParent, MessageType enmType,
190 const QString &strMessage,
191 const QString &strDetails,
192 const char *pcszAutoConfirmId /* = 0*/,
193 const QString &strOkButtonText /* = QString()*/,
194 const QString &strCancelButtonText /* = QString()*/) const
195{
196 return (message(pParent, enmType, strMessage, strDetails, pcszAutoConfirmId,
197 AlertButton_Ok | AlertButtonOption_Default,
198 AlertButton_Cancel | AlertButtonOption_Escape,
199 0 /* third button */,
200 strOkButtonText,
201 strCancelButtonText,
202 QString() /* third button */) &
203 AlertButtonMask) == AlertButton_Ok;
204}
205
206void UIMessageCenter::alert(QWidget *pParent, MessageType enmType,
207 const QString &strMessage,
208 const char *pcszAutoConfirmId /* = 0*/) const
209{
210 error(pParent, enmType, strMessage, QString(), pcszAutoConfirmId);
211}
212
213int UIMessageCenter::question(QWidget *pParent, MessageType enmType,
214 const QString &strMessage,
215 const char *pcszAutoConfirmId/* = 0*/,
216 int iButton1 /* = 0*/,
217 int iButton2 /* = 0*/,
218 int iButton3 /* = 0*/,
219 const QString &strButtonText1 /* = QString()*/,
220 const QString &strButtonText2 /* = QString()*/,
221 const QString &strButtonText3 /* = QString()*/) const
222{
223 return message(pParent, enmType, strMessage, QString(), pcszAutoConfirmId,
224 iButton1, iButton2, iButton3, strButtonText1, strButtonText2, strButtonText3);
225}
226
227bool UIMessageCenter::questionBinary(QWidget *pParent, MessageType enmType,
228 const QString &strMessage,
229 const char *pcszAutoConfirmId /* = 0*/,
230 const QString &strOkButtonText /* = QString()*/,
231 const QString &strCancelButtonText /* = QString()*/,
232 bool fDefaultFocusForOk /* = true*/) const
233{
234 return fDefaultFocusForOk ?
235 ((question(pParent, enmType, strMessage, pcszAutoConfirmId,
236 AlertButton_Ok | AlertButtonOption_Default,
237 AlertButton_Cancel | AlertButtonOption_Escape,
238 0 /* third button */,
239 strOkButtonText,
240 strCancelButtonText,
241 QString() /* third button */) &
242 AlertButtonMask) == AlertButton_Ok) :
243 ((question(pParent, enmType, strMessage, pcszAutoConfirmId,
244 AlertButton_Ok,
245 AlertButton_Cancel | AlertButtonOption_Default | AlertButtonOption_Escape,
246 0 /* third button */,
247 strOkButtonText,
248 strCancelButtonText,
249 QString() /* third button */) &
250 AlertButtonMask) == AlertButton_Ok);
251}
252
253int UIMessageCenter::questionTrinary(QWidget *pParent, MessageType enmType,
254 const QString &strMessage,
255 const char *pcszAutoConfirmId /* = 0*/,
256 const QString &strChoice1ButtonText /* = QString()*/,
257 const QString &strChoice2ButtonText /* = QString()*/,
258 const QString &strCancelButtonText /* = QString()*/) const
259{
260 return question(pParent, enmType, strMessage, pcszAutoConfirmId,
261 AlertButton_Choice1,
262 AlertButton_Choice2 | AlertButtonOption_Default,
263 AlertButton_Cancel | AlertButtonOption_Escape,
264 strChoice1ButtonText,
265 strChoice2ButtonText,
266 strCancelButtonText);
267}
268
269int UIMessageCenter::messageWithOption(QWidget *pParent, MessageType enmType,
270 const QString &strMessage,
271 const QString &strOptionText,
272 bool fDefaultOptionValue /* = true */,
273 int iButton1 /* = 0*/,
274 int iButton2 /* = 0*/,
275 int iButton3 /* = 0*/,
276 const QString &strButtonName1 /* = QString() */,
277 const QString &strButtonName2 /* = QString() */,
278 const QString &strButtonName3 /* = QString() */) const
279{
280 /* If no buttons are set, using single 'OK' button: */
281 if (iButton1 == 0 && iButton2 == 0 && iButton3 == 0)
282 iButton1 = AlertButton_Ok | AlertButtonOption_Default;
283
284 /* Assign corresponding title and icon: */
285 QString strTitle;
286 AlertIconType icon;
287 switch (enmType)
288 {
289 default:
290 case MessageType_Info:
291 strTitle = tr("VirtualBox - Information", "msg box title");
292 icon = AlertIconType_Information;
293 break;
294 case MessageType_Question:
295 strTitle = tr("VirtualBox - Question", "msg box title");
296 icon = AlertIconType_Question;
297 break;
298 case MessageType_Warning:
299 strTitle = tr("VirtualBox - Warning", "msg box title");
300 icon = AlertIconType_Warning;
301 break;
302 case MessageType_Error:
303 strTitle = tr("VirtualBox - Error", "msg box title");
304 icon = AlertIconType_Critical;
305 break;
306 case MessageType_Critical:
307 strTitle = tr("VirtualBox - Critical Error", "msg box title");
308 icon = AlertIconType_Critical;
309 break;
310 case MessageType_GuruMeditation:
311 strTitle = "VirtualBox - Guru Meditation"; /* don't translate this */
312 icon = AlertIconType_GuruMeditation;
313 break;
314 }
315
316 /* Create message-box: */
317 QWidget *pBoxParent = windowManager().realParentWindow(pParent ? pParent : windowManager().mainWindowShown());
318 QPointer<QIMessageBox> pBox = new QIMessageBox(strTitle, strMessage, icon,
319 iButton1, iButton2, iButton3, pBoxParent);
320 windowManager().registerNewParent(pBox, pBoxParent);
321
322 /* Load option: */
323 if (!strOptionText.isNull())
324 {
325 pBox->setFlagText(strOptionText);
326 pBox->setFlagChecked(fDefaultOptionValue);
327 }
328
329 /* Configure button-text: */
330 if (!strButtonName1.isNull())
331 pBox->setButtonText(0, strButtonName1);
332 if (!strButtonName2.isNull())
333 pBox->setButtonText(1, strButtonName2);
334 if (!strButtonName3.isNull())
335 pBox->setButtonText(2, strButtonName3);
336
337 /* Show box: */
338 int rc = pBox->exec();
339
340 /* Make sure box still valid: */
341 if (!pBox)
342 return rc;
343
344 /* Save option: */
345 if (pBox->flagChecked())
346 rc |= AlertOption_CheckBox;
347
348 /* Delete message-box: */
349 if (pBox)
350 delete pBox;
351
352 return rc;
353}
354
355bool UIMessageCenter::showModalProgressDialog(CProgress &progress,
356 const QString &strTitle,
357 const QString &strImage /* = "" */,
358 QWidget *pParent /* = 0*/,
359 int cMinDuration /* = 2000 */)
360{
361 /* Prepare pixmap: */
362 QPixmap *pPixmap = NULL;
363 if (!strImage.isEmpty())
364 pPixmap = new QPixmap(strImage);
365
366 /* Create progress-dialog: */
367 QWidget *pDlgParent = windowManager().realParentWindow(pParent ? pParent : windowManager().mainWindowShown());
368 QPointer<UIProgressDialog> pProgressDlg = new UIProgressDialog(progress, strTitle, pPixmap, cMinDuration, pDlgParent);
369 windowManager().registerNewParent(pProgressDlg, pDlgParent);
370
371 /* Run the dialog with the 350 ms refresh interval. */
372 pProgressDlg->run(350);
373
374 /* Make sure progress-dialog still valid: */
375 bool fRc;
376 if (pProgressDlg)
377 {
378 /* Delete progress-dialog: */
379 delete pProgressDlg;
380
381 fRc = true;
382 }
383 else
384 fRc = false;
385
386 /* Cleanup pixmap: */
387 if (pPixmap)
388 delete pPixmap;
389
390 return fRc;
391}
392
393void UIMessageCenter::warnAboutUnknownOptionType(const QString &strOption)
394{
395 alert(0, MessageType_Error,
396 tr("Unknown option <b>%1</b>.")
397 .arg(strOption));
398}
399
400void UIMessageCenter::warnAboutUnrelatedOptionType(const QString &strOption)
401{
402 alert(0, MessageType_Error,
403 tr("<b>%1</b> is an option for the VirtualBox VM runner (VirtualBoxVM) application, not the VirtualBox Manager.")
404 .arg(strOption));
405}
406
407#ifdef RT_OS_LINUX
408void UIMessageCenter::warnAboutWrongUSBMounted() const
409{
410 alert(0, MessageType_Warning,
411 tr("You seem to have the USBFS filesystem mounted at /sys/bus/usb/drivers. "
412 "We strongly recommend that you change this, as it is a severe mis-configuration of "
413 "your system which could cause USB devices to fail in unexpected ways."),
414 "warnAboutWrongUSBMounted");
415}
416#endif /* RT_OS_LINUX */
417
418void UIMessageCenter::cannotStartSelector() const
419{
420 alert(0, MessageType_Critical,
421 tr("<p>Cannot start the VirtualBox Manager due to local restrictions.</p>"
422 "<p>The application will now terminate.</p>"));
423}
424
425void UIMessageCenter::cannotStartRuntime() const
426{
427 /* Prepare error string: */
428 const QString strError = tr("<p>You must specify a machine to start, using the command line.</p><p>%1</p>",
429 "There will be a usage text passed as argument.");
430
431 /* Prepare Usage, it can change in future: */
432 const QString strTable = QString("<table cellspacing=0 style='white-space:pre'>%1</table>");
433 const QString strUsage = tr("<tr>"
434 "<td>Usage: VirtualBoxVM --startvm &lt;name|UUID&gt;</td>"
435 "</tr>"
436 "<tr>"
437 "<td>Starts the VirtualBox virtual machine with the given "
438 "name or unique identifier (UUID).</td>"
439 "</tr>");
440
441 /* Show error: */
442 alert(0, MessageType_Error, strError.arg(strTable.arg(strUsage)));
443}
444
445void UIMessageCenter::showBetaBuildWarning() const
446{
447 alert(0, MessageType_Warning,
448 tr("You are running a prerelease version of VirtualBox. "
449 "This version is not suitable for production use."));
450}
451
452void UIMessageCenter::showExperimentalBuildWarning() const
453{
454 alert(0, MessageType_Warning,
455 tr("You are running an EXPERIMENTAL build of VirtualBox. "
456 "This version is not suitable for production use."));
457}
458
459void UIMessageCenter::cannotInitUserHome(const QString &strUserHome) const
460{
461 error(0, MessageType_Critical,
462 tr("<p>Failed to initialize COM because the VirtualBox global "
463 "configuration directory <b><nobr>%1</nobr></b> is not accessible. "
464 "Please check the permissions of this directory and of its parent directory.</p>"
465 "<p>The application will now terminate.</p>")
466 .arg(strUserHome),
467 UIErrorString::formatErrorInfo(COMErrorInfo()));
468}
469
470void UIMessageCenter::cannotInitCOM(HRESULT rc) const
471{
472 error(0, MessageType_Critical,
473 tr("<p>Failed to initialize COM or to find the VirtualBox COM server. "
474 "Most likely, the VirtualBox server is not running or failed to start.</p>"
475 "<p>The application will now terminate.</p>"),
476 UIErrorString::formatErrorInfo(COMErrorInfo(), rc));
477}
478
479void UIMessageCenter::cannotCreateVirtualBoxClient(const CVirtualBoxClient &client) const
480{
481 error(0, MessageType_Critical,
482 tr("<p>Failed to create the VirtualBoxClient COM object.</p>"
483 "<p>The application will now terminate.</p>"),
484 UIErrorString::formatErrorInfo(client));
485}
486
487void UIMessageCenter::cannotAcquireVirtualBox(const CVirtualBoxClient &client) const
488{
489 QString err = tr("<p>Failed to acquire the VirtualBox COM object.</p>"
490 "<p>The application will now terminate.</p>");
491#if defined(VBOX_WS_X11) || defined(VBOX_WS_MAC)
492 if (client.lastRC() == NS_ERROR_SOCKET_FAIL)
493 err += tr("<p>The reason for this error are most likely wrong permissions of the IPC "
494 "daemon socket due to an installation problem. Please check the permissions of "
495 "<font color=blue>'/tmp'</font> and <font color=blue>'/tmp/.vbox-*-ipc/'</font></p>");
496#endif
497 error(0, MessageType_Critical, err, UIErrorString::formatErrorInfo(client));
498}
499
500void UIMessageCenter::cannotFindLanguage(const QString &strLangId, const QString &strNlsPath) const
501{
502 alert(0, MessageType_Error,
503 tr("<p>Could not find a language file for the language <b>%1</b> in the directory <b><nobr>%2</nobr></b>.</p>"
504 "<p>The language will be temporarily reset to the system default language. "
505 "Please go to the <b>Preferences</b> window which you can open from the <b>File</b> menu of the "
506 "VirtualBox Manager window, and select one of the existing languages on the <b>Language</b> page.</p>")
507 .arg(strLangId).arg(strNlsPath));
508}
509
510void UIMessageCenter::cannotLoadLanguage(const QString &strLangFile) const
511{
512 alert(0, MessageType_Error,
513 tr("<p>Could not load the language file <b><nobr>%1</nobr></b>. "
514 "<p>The language will be temporarily reset to English (built-in). "
515 "Please go to the <b>Preferences</b> window which you can open from the <b>File</b> menu of the "
516 "VirtualBox Manager window, and select one of the existing languages on the <b>Language</b> page.</p>")
517 .arg(strLangFile));
518}
519
520void UIMessageCenter::cannotFindMachineByName(const CVirtualBox &vbox, const QString &strName) const
521{
522 error(0, MessageType_Error,
523 tr("There is no virtual machine named <b>%1</b>.")
524 .arg(strName),
525 UIErrorString::formatErrorInfo(vbox));
526}
527
528void UIMessageCenter::cannotFindMachineById(const CVirtualBox &vbox, const QUuid &uId) const
529{
530 error(0, MessageType_Error,
531 tr("There is no virtual machine with the identifier <b>%1</b>.")
532 .arg(uId.toString()),
533 UIErrorString::formatErrorInfo(vbox));
534}
535
536void UIMessageCenter::cannotOpenSession(const CSession &session) const
537{
538 error(0, MessageType_Error,
539 tr("Failed to create a new session."),
540 UIErrorString::formatErrorInfo(session));
541}
542
543void UIMessageCenter::cannotOpenSession(const CMachine &machine) const
544{
545 error(0, MessageType_Error,
546 tr("Failed to open a session for the virtual machine <b>%1</b>.")
547 .arg(CMachine(machine).GetName()),
548 UIErrorString::formatErrorInfo(machine));
549}
550
551void UIMessageCenter::cannotOpenSession(const CProgress &progress, const QString &strMachineName) const
552{
553 error(0, MessageType_Error,
554 tr("Failed to open a session for the virtual machine <b>%1</b>.")
555 .arg(strMachineName),
556 UIErrorString::formatErrorInfo(progress));
557}
558
559void UIMessageCenter::cannotGetMediaAccessibility(const UIMedium &medium) const
560{
561 error(0, MessageType_Error,
562 tr("Failed to access the disk image file <nobr><b>%1</b></nobr>.")
563 .arg(medium.location()),
564 UIErrorString::formatErrorInfo(medium.result()));
565}
566
567void UIMessageCenter::cannotOpenURL(const QString &strUrl) const
568{
569 alert(0, MessageType_Error,
570 tr("Failed to open <tt>%1</tt>. "
571 "Make sure your desktop environment can properly handle URLs of this type.")
572 .arg(strUrl));
573}
574
575void UIMessageCenter::cannotSetExtraData(const CVirtualBox &vbox, const QString &strKey, const QString &strValue)
576{
577 error(0, MessageType_Error,
578 tr("Failed to set the global VirtualBox extra data for key <i>%1</i> to value <i>{%2}</i>.")
579 .arg(strKey, strValue),
580 UIErrorString::formatErrorInfo(vbox));
581}
582
583void UIMessageCenter::cannotSetExtraData(const CMachine &machine, const QString &strKey, const QString &strValue)
584{
585 error(0, MessageType_Error,
586 tr("Failed to set the extra data for key <i>%1</i> of machine <i>%2</i> to value <i>{%3}</i>.")
587 .arg(strKey, CMachine(machine).GetName(), strValue),
588 UIErrorString::formatErrorInfo(machine));
589}
590
591void UIMessageCenter::warnAboutInvalidEncryptionPassword(const QString &strPasswordId, QWidget *pParent /* = 0 */)
592{
593 alert(pParent, MessageType_Error,
594 tr("Encryption password for <nobr>ID = '%1'</nobr> is invalid.")
595 .arg(strPasswordId));
596}
597
598void UIMessageCenter::cannotAcquireMachineParameter(const CMachine &comMachine, QWidget *pParent /* = 0 */) const
599{
600 /* Show the error: */
601 error(pParent, MessageType_Error,
602 tr("Failed to acquire machine parameter."), UIErrorString::formatErrorInfo(comMachine));
603}
604
605void UIMessageCenter::cannotOpenMachine(const CVirtualBox &vbox, const QString &strMachinePath) const
606{
607 error(0, MessageType_Error,
608 tr("Failed to open virtual machine located in %1.")
609 .arg(strMachinePath),
610 UIErrorString::formatErrorInfo(vbox));
611}
612
613void UIMessageCenter::cannotReregisterExistingMachine(const QString &strMachinePath, const QString &strMachineName) const
614{
615 alert(0, MessageType_Error,
616 tr("Failed to add virtual machine <b>%1</b> located in <i>%2</i> because its already present.")
617 .arg(strMachineName, strMachinePath));
618}
619
620void UIMessageCenter::cannotResolveCollisionAutomatically(const QString &strCollisionName, const QString &strGroupName) const
621{
622 alert(0, MessageType_Error,
623 tr("<p>You are trying to move machine <nobr><b>%1</b></nobr> "
624 "to group <nobr><b>%2</b></nobr> which already have sub-group <nobr><b>%1</b></nobr>.</p>"
625 "<p>Please resolve this name-conflict and try again.</p>")
626 .arg(strCollisionName, strGroupName));
627}
628
629bool UIMessageCenter::confirmAutomaticCollisionResolve(const QString &strName, const QString &strGroupName) const
630{
631 return questionBinary(0, MessageType_Question,
632 tr("<p>You are trying to move group <nobr><b>%1</b></nobr> "
633 "to group <nobr><b>%2</b></nobr> which already have another item with the same name.</p>"
634 "<p>Would you like to automatically rename it?</p>")
635 .arg(strName, strGroupName),
636 0 /* auto-confirm id */,
637 tr("Rename"));
638}
639
640void UIMessageCenter::cannotSetGroups(const CMachine &machine) const
641{
642 /* Compose machine name: */
643 QString strName = CMachine(machine).GetName();
644 if (strName.isEmpty())
645 strName = QFileInfo(CMachine(machine).GetSettingsFilePath()).baseName();
646 /* Show the error: */
647 error(0, MessageType_Error,
648 tr("Failed to set groups of the virtual machine <b>%1</b>.")
649 .arg(strName),
650 UIErrorString::formatErrorInfo(machine));
651}
652
653bool UIMessageCenter::confirmMachineItemRemoval(const QStringList &names) const
654{
655 return questionBinary(0, MessageType_Question,
656 tr("<p>You are about to remove following virtual machine items from the machine list:</p>"
657 "<p><b>%1</b></p><p>Do you wish to proceed?</p>")
658 .arg(names.join(", ")),
659 0 /* auto-confirm id */,
660 tr("Remove") /* ok button text */,
661 QString() /* cancel button text */,
662 false /* ok button by default? */);
663}
664
665int UIMessageCenter::confirmMachineRemoval(const QList<CMachine> &machines) const
666{
667 /* Enumerate the machines: */
668 int cInacessibleMachineCount = 0;
669 bool fMachineWithHardDiskPresent = false;
670 QString strMachineNames;
671 foreach (const CMachine &machine, machines)
672 {
673 /* Prepare machine name: */
674 QString strMachineName;
675 if (machine.GetAccessible())
676 {
677 /* Just get machine name: */
678 strMachineName = machine.GetName();
679 /* Enumerate the attachments: */
680 const CMediumAttachmentVector &attachments = machine.GetMediumAttachments();
681 foreach (const CMediumAttachment &attachment, attachments)
682 {
683 /* Check if the medium is a hard disk: */
684 if (attachment.GetType() == KDeviceType_HardDisk)
685 {
686 /* Check if that hard disk isn't shared.
687 * If hard disk is shared, it will *never* be deleted: */
688 QVector<QUuid> usedMachineList = attachment.GetMedium().GetMachineIds();
689 if (usedMachineList.size() == 1)
690 {
691 fMachineWithHardDiskPresent = true;
692 break;
693 }
694 }
695 }
696 }
697 else
698 {
699 /* Compose machine name: */
700 QFileInfo fi(machine.GetSettingsFilePath());
701 strMachineName = UICommon::hasAllowedExtension(fi.completeSuffix(), VBoxFileExts) ? fi.completeBaseName() : fi.fileName();
702 /* Increment inacessible machine count: */
703 ++cInacessibleMachineCount;
704 }
705 /* Append machine name to the full name string: */
706 strMachineNames += QString(strMachineNames.isEmpty() ? "<b>%1</b>" : ", <b>%1</b>").arg(strMachineName);
707 }
708
709 /* Prepare message text: */
710 QString strText = cInacessibleMachineCount == machines.size() ?
711 tr("<p>You are about to remove following inaccessible virtual machines from the machine list:</p>"
712 "<p>%1</p>"
713 "<p>Do you wish to proceed?</p>")
714 .arg(strMachineNames) :
715 fMachineWithHardDiskPresent ?
716 tr("<p>You are about to remove following virtual machines from the machine list:</p>"
717 "<p>%1</p>"
718 "<p>Would you like to delete the files containing the virtual machine from your hard disk as well? "
719 "Doing this will also remove the files containing the machine's virtual hard disks "
720 "if they are not in use by another machine.</p>")
721 .arg(strMachineNames) :
722 tr("<p>You are about to remove following virtual machines from the machine list:</p>"
723 "<p>%1</p>"
724 "<p>Would you like to delete the files containing the virtual machine from your hard disk as well?</p>")
725 .arg(strMachineNames);
726
727 /* Prepare message itself: */
728 return cInacessibleMachineCount == machines.size() ?
729 message(0, MessageType_Question,
730 strText, QString(),
731 0 /* auto-confirm id */,
732 AlertButton_Ok,
733 AlertButton_Cancel | AlertButtonOption_Default | AlertButtonOption_Escape,
734 0,
735 tr("Remove")) :
736 message(0, MessageType_Question,
737 strText, QString(),
738 0 /* auto-confirm id */,
739 AlertButton_Choice1,
740 AlertButton_Choice2,
741 AlertButton_Cancel | AlertButtonOption_Default | AlertButtonOption_Escape,
742 tr("Delete all files"),
743 tr("Remove only"));
744}
745
746void UIMessageCenter::cannotRemoveMachine(const CMachine &machine) const
747{
748 error(0, MessageType_Error,
749 tr("Failed to remove the virtual machine <b>%1</b>.")
750 .arg(CMachine(machine).GetName()),
751 UIErrorString::formatErrorInfo(machine));
752}
753
754void UIMessageCenter::cannotRemoveMachine(const CMachine &machine, const CProgress &progress) const
755{
756 error(0, MessageType_Error,
757 tr("Failed to remove the virtual machine <b>%1</b>.")
758 .arg(CMachine(machine).GetName()),
759 UIErrorString::formatErrorInfo(progress));
760}
761
762bool UIMessageCenter::warnAboutInaccessibleMedia() const
763{
764 return questionBinary(0, MessageType_Warning,
765 tr("<p>One or more disk image files are not currently accessible. As a result, you will "
766 "not be able to operate virtual machines that use these files until "
767 "they become accessible later.</p>"
768 "<p>Press <b>Check</b> to open the Virtual Media Manager window and "
769 "see which files are inaccessible, or press <b>Ignore</b> to "
770 "ignore this message.</p>"),
771 "warnAboutInaccessibleMedia",
772 tr("Check", "inaccessible media message box"), tr("Ignore"));
773}
774
775bool UIMessageCenter::confirmDiscardSavedState(const QString &strNames) const
776{
777 return questionBinary(0, MessageType_Question,
778 tr("<p>Are you sure you want to discard the saved state of "
779 "the following virtual machines?</p><p><b>%1</b></p>"
780 "<p>This operation is equivalent to resetting or powering off "
781 "the machine without doing a proper shutdown of the guest OS.</p>")
782 .arg(strNames),
783 0 /* auto-confirm id */,
784 tr("Discard", "saved state"));
785}
786
787bool UIMessageCenter::confirmResetMachine(const QString &strNames) const
788{
789 return questionBinary(0, MessageType_Question,
790 tr("<p>Do you really want to reset the following virtual machines?</p>"
791 "<p><b>%1</b></p><p>This will cause any unsaved data "
792 "in applications running inside it to be lost.</p>")
793 .arg(strNames),
794 "confirmResetMachine" /* auto-confirm id */,
795 tr("Reset", "machine"));
796}
797
798bool UIMessageCenter::confirmACPIShutdownMachine(const QString &strNames) const
799{
800 return questionBinary(0, MessageType_Question,
801 tr("<p>Do you really want to send an ACPI shutdown signal "
802 "to the following virtual machines?</p><p><b>%1</b></p>")
803 .arg(strNames),
804 "confirmACPIShutdownMachine" /* auto-confirm id */,
805 tr("ACPI Shutdown", "machine"));
806}
807
808bool UIMessageCenter::confirmPowerOffMachine(const QString &strNames) const
809{
810 return questionBinary(0, MessageType_Question,
811 tr("<p>Do you really want to power off the following virtual machines?</p>"
812 "<p><b>%1</b></p><p>This will cause any unsaved data in applications "
813 "running inside it to be lost.</p>")
814 .arg(strNames),
815 "confirmPowerOffMachine" /* auto-confirm id */,
816 tr("Power Off", "machine"));
817}
818
819void UIMessageCenter::cannotPauseMachine(const CConsole &console) const
820{
821 error(0, MessageType_Error,
822 tr("Failed to pause the execution of the virtual machine <b>%1</b>.")
823 .arg(CConsole(console).GetMachine().GetName()),
824 UIErrorString::formatErrorInfo(console));
825}
826
827void UIMessageCenter::cannotResumeMachine(const CConsole &console) const
828{
829 error(0, MessageType_Error,
830 tr("Failed to resume the execution of the virtual machine <b>%1</b>.")
831 .arg(CConsole(console).GetMachine().GetName()),
832 UIErrorString::formatErrorInfo(console));
833}
834
835void UIMessageCenter::cannotDiscardSavedState(const CMachine &machine) const
836{
837 error(0, MessageType_Error,
838 tr("Failed to discard the saved state of the virtual machine <b>%1</b>.")
839 .arg(machine.GetName()),
840 UIErrorString::formatErrorInfo(machine));
841}
842
843void UIMessageCenter::cannotSaveMachineState(const CMachine &machine)
844{
845 error(0, MessageType_Error,
846 tr("Failed to save the state of the virtual machine <b>%1</b>.")
847 .arg(machine.GetName()),
848 UIErrorString::formatErrorInfo(machine));
849}
850
851void UIMessageCenter::cannotSaveMachineState(const CProgress &progress, const QString &strMachineName)
852{
853 error(0, MessageType_Error,
854 tr("Failed to save the state of the virtual machine <b>%1</b>.")
855 .arg(strMachineName),
856 UIErrorString::formatErrorInfo(progress));
857}
858
859void UIMessageCenter::cannotACPIShutdownMachine(const CConsole &console) const
860{
861 error(0, MessageType_Error,
862 tr("Failed to send the ACPI Power Button press event to the virtual machine <b>%1</b>.")
863 .arg(CConsole(console).GetMachine().GetName()),
864 UIErrorString::formatErrorInfo(console));
865}
866
867void UIMessageCenter::cannotPowerDownMachine(const CConsole &console) const
868{
869 error(0, MessageType_Error,
870 tr("Failed to stop the virtual machine <b>%1</b>.")
871 .arg(CConsole(console).GetMachine().GetName()),
872 UIErrorString::formatErrorInfo(console));
873}
874
875void UIMessageCenter::cannotPowerDownMachine(const CProgress &progress, const QString &strMachineName) const
876{
877 error(0, MessageType_Error,
878 tr("Failed to stop the virtual machine <b>%1</b>.")
879 .arg(strMachineName),
880 UIErrorString::formatErrorInfo(progress));
881}
882
883bool UIMessageCenter::confirmStartMultipleMachines(const QString &strNames) const
884{
885 return questionBinary(0, MessageType_Question,
886 tr("<p>You are about to start all of the following virtual machines:</p>"
887 "<p><b>%1</b></p><p>This could take some time and consume a lot of "
888 "host system resources. Do you wish to proceed?</p>").arg(strNames),
889 "confirmStartMultipleMachines" /* auto-confirm id */);
890}
891
892void UIMessageCenter::cannotMoveMachine(const CMachine &machine, QWidget *pParent /* = 0 */) const
893{
894 error(pParent, MessageType_Error,
895 tr("Failed to move the virtual machine <b>%1</b>.")
896 .arg(CMachine(machine).GetName()),
897 UIErrorString::formatErrorInfo(machine));
898}
899
900void UIMessageCenter::cannotMoveMachine(const CProgress &progress, const QString &strMachineName, QWidget *pParent /* = 0 */) const
901{
902 error(pParent, MessageType_Error,
903 tr("Failed to move the virtual machine <b>%1</b>.")
904 .arg(strMachineName),
905 UIErrorString::formatErrorInfo(progress));
906}
907
908
909int UIMessageCenter::confirmSnapshotRestoring(const QString &strSnapshotName, bool fAlsoCreateNewSnapshot) const
910{
911 return fAlsoCreateNewSnapshot ?
912 messageWithOption(0, MessageType_Question,
913 tr("<p>You are about to restore snapshot <nobr><b>%1</b></nobr>.</p>"
914 "<p>You can create a snapshot of the current state of the virtual machine first by checking the box below; "
915 "if you do not do this the current state will be permanently lost. Do you wish to proceed?</p>")
916 .arg(strSnapshotName),
917 tr("Create a snapshot of the current machine state"),
918 !gEDataManager->messagesWithInvertedOption().contains("confirmSnapshotRestoring"),
919 AlertButton_Ok,
920 AlertButton_Cancel | AlertButtonOption_Default | AlertButtonOption_Escape,
921 0 /* 3rd button */,
922 tr("Restore"), tr("Cancel"), QString() /* 3rd button text */) :
923 message(0, MessageType_Question,
924 tr("<p>Are you sure you want to restore snapshot <nobr><b>%1</b></nobr>?</p>")
925 .arg(strSnapshotName),
926 QString() /* details */,
927 0 /* auto-confirm id */,
928 AlertButton_Ok,
929 AlertButton_Cancel | AlertButtonOption_Default | AlertButtonOption_Escape,
930 0 /* 3rd button */,
931 tr("Restore"), tr("Cancel"), QString() /* 3rd button text */);
932}
933
934bool UIMessageCenter::confirmSnapshotRemoval(const QString &strSnapshotName) const
935{
936 return questionBinary(0, MessageType_Question,
937 tr("<p>Deleting the snapshot will cause the state information saved in it to be lost, and storage data spread over "
938 "several image files that VirtualBox has created together with the snapshot will be merged into one file. "
939 "This can be a lengthy process, and the information in the snapshot cannot be recovered.</p>"
940 "</p>Are you sure you want to delete the selected snapshot <b>%1</b>?</p>")
941 .arg(strSnapshotName),
942 0 /* auto-confirm id */,
943 tr("Delete") /* ok button text */,
944 QString() /* cancel button text */,
945 false /* ok button by default? */);
946}
947
948bool UIMessageCenter::warnAboutSnapshotRemovalFreeSpace(const QString &strSnapshotName,
949 const QString &strTargetImageName,
950 const QString &strTargetImageMaxSize,
951 const QString &strTargetFileSystemFree) const
952{
953 return questionBinary(0, MessageType_Question,
954 tr("<p>Deleting the snapshot %1 will temporarily need more storage space. In the worst case the size of image %2 will grow by %3, "
955 "however on this filesystem there is only %4 free.</p><p>Running out of storage space during the merge operation can result in "
956 "corruption of the image and the VM configuration, i.e. loss of the VM and its data.</p><p>You may continue with deleting "
957 "the snapshot at your own risk.</p>")
958 .arg(strSnapshotName, strTargetImageName, strTargetImageMaxSize, strTargetFileSystemFree),
959 0 /* auto-confirm id */,
960 tr("Delete") /* ok button text */,
961 QString() /* cancel button text */,
962 false /* ok button by default? */);
963}
964
965void UIMessageCenter::cannotTakeSnapshot(const CMachine &machine, const QString &strMachineName, QWidget *pParent /* = 0*/) const
966{
967 error(pParent, MessageType_Error,
968 tr("Failed to create a snapshot of the virtual machine <b>%1</b>.")
969 .arg(strMachineName),
970 UIErrorString::formatErrorInfo(machine));
971}
972
973void UIMessageCenter::cannotTakeSnapshot(const CProgress &progress, const QString &strMachineName, QWidget *pParent /* = 0*/) const
974{
975 error(pParent, MessageType_Error,
976 tr("Failed to create a snapshot of the virtual machine <b>%1</b>.")
977 .arg(strMachineName),
978 UIErrorString::formatErrorInfo(progress));
979}
980
981bool UIMessageCenter::cannotRestoreSnapshot(const CMachine &machine, const QString &strSnapshotName, const QString &strMachineName) const
982{
983 error(0, MessageType_Error,
984 tr("Failed to restore the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")
985 .arg(strSnapshotName, strMachineName),
986 UIErrorString::formatErrorInfo(machine));
987 return false;
988}
989
990bool UIMessageCenter::cannotRestoreSnapshot(const CProgress &progress, const QString &strSnapshotName, const QString &strMachineName) const
991{
992 error(0, MessageType_Error,
993 tr("Failed to restore the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")
994 .arg(strSnapshotName, strMachineName),
995 UIErrorString::formatErrorInfo(progress));
996 return false;
997}
998
999void UIMessageCenter::cannotRemoveSnapshot(const CMachine &machine, const QString &strSnapshotName, const QString &strMachineName) const
1000{
1001 error(0, MessageType_Error,
1002 tr("Failed to delete the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")
1003 .arg(strSnapshotName, strMachineName),
1004 UIErrorString::formatErrorInfo(machine));
1005}
1006
1007void UIMessageCenter::cannotRemoveSnapshot(const CProgress &progress, const QString &strSnapshotName, const QString &strMachineName) const
1008{
1009 error(0, MessageType_Error,
1010 tr("Failed to delete the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")
1011 .arg(strSnapshotName).arg(strMachineName),
1012 UIErrorString::formatErrorInfo(progress));
1013}
1014
1015void UIMessageCenter::cannotChangeSnapshot(const CSnapshot &comSnapshot, const QString &strSnapshotName, const QString &strMachineName) const
1016{
1017 error(0, MessageType_Error,
1018 tr("Failed to change the snapshot <b>%1</b> of the virtual machine <b>%2</b>.")
1019 .arg(strSnapshotName).arg(strMachineName),
1020 UIErrorString::formatErrorInfo(comSnapshot));
1021}
1022
1023void UIMessageCenter::cannotFindSnapshotByName(const CMachine &comMachine,
1024 const QString &strName,
1025 QWidget *pParent /* = 0*/) const
1026{
1027 error(pParent, MessageType_Error,
1028 tr("Can't find snapshot named <b>%1</b>.")
1029 .arg(strName),
1030 UIErrorString::formatErrorInfo(comMachine));
1031}
1032
1033void UIMessageCenter::cannotFindSnapshotById(const CMachine &comMachine,
1034 const QUuid &uId,
1035 QWidget *pParent /* = 0 */) const
1036{
1037 error(pParent, MessageType_Error,
1038 tr("Can't find snapshot with ID=<b>%1</b>.")
1039 .arg(uId.toString()),
1040 UIErrorString::formatErrorInfo(comMachine));
1041}
1042
1043void UIMessageCenter::cannotAcquireSnapshotAttributes(const CSnapshot &comSnapshot,
1044 QWidget *pParent /* = 0 */)
1045{
1046 error(pParent, MessageType_Error,
1047 tr("Can't acquire snapshot attributes."),
1048 UIErrorString::formatErrorInfo(comSnapshot));
1049}
1050
1051void UIMessageCenter::cannotSaveSettings(const QString strDetails, QWidget *pParent /* = 0 */) const
1052{
1053 error(pParent, MessageType_Error,
1054 tr("Failed to save the settings."),
1055 strDetails);
1056}
1057
1058bool UIMessageCenter::confirmNATNetworkRemoval(const QString &strName, QWidget *pParent /* = 0*/) const
1059{
1060 return questionBinary(pParent, MessageType_Question,
1061 tr("<p>Do you want to remove the NAT network <nobr><b>%1</b>?</nobr></p>"
1062 "<p>If this network is in use by one or more virtual "
1063 "machine network adapters these adapters will no longer be "
1064 "usable until you correct their settings by either choosing "
1065 "a different network name or a different adapter attachment "
1066 "type.</p>")
1067 .arg(strName),
1068 0 /* auto-confirm id */,
1069 tr("Remove") /* ok button text */,
1070 QString() /* cancel button text */,
1071 false /* ok button by default? */);
1072}
1073
1074void UIMessageCenter::cannotSetSystemProperties(const CSystemProperties &properties, QWidget *pParent /* = 0*/) const
1075{
1076 error(pParent, MessageType_Critical,
1077 tr("Failed to set global VirtualBox properties."),
1078 UIErrorString::formatErrorInfo(properties));
1079}
1080
1081void UIMessageCenter::warnAboutUnaccessibleUSB(const COMBaseWithEI &object, QWidget *pParent /* = 0*/) const
1082{
1083 /* If IMachine::GetUSBController(), IHost::GetUSBDevices() etc. return
1084 * E_NOTIMPL, it means the USB support is intentionally missing
1085 * (as in the OSE version). Don't show the error message in this case. */
1086 COMResult res(object);
1087 if (res.rc() == E_NOTIMPL)
1088 return;
1089 /* Show the error: */
1090 error(pParent, res.isWarning() ? MessageType_Warning : MessageType_Error,
1091 tr("Failed to access the USB subsystem."),
1092 UIErrorString::formatErrorInfo(res),
1093 "warnAboutUnaccessibleUSB");
1094}
1095
1096void UIMessageCenter::warnAboutStateChange(QWidget *pParent /* = 0*/) const
1097{
1098 if (warningShown("warnAboutStateChange"))
1099 return;
1100 setWarningShown("warnAboutStateChange", true);
1101
1102 alert(pParent, MessageType_Warning,
1103 tr("The virtual machine that you are changing has been started. "
1104 "Only certain settings can be changed while a machine is running. "
1105 "All other changes will be lost if you close this window now."));
1106
1107 setWarningShown("warnAboutStateChange", false);
1108}
1109
1110bool UIMessageCenter::confirmSettingsReloading(QWidget *pParent /* = 0*/) const
1111{
1112 return questionBinary(pParent, MessageType_Question,
1113 tr("<p>The machine settings were changed while you were editing them. "
1114 "You currently have unsaved setting changes.</p>"
1115 "<p>Would you like to reload the changed settings or to keep your own changes?</p>"),
1116 0 /* auto-confirm id */,
1117 tr("Reload settings"), tr("Keep changes"));
1118}
1119
1120int UIMessageCenter::confirmRemovingOfLastDVDDevice(QWidget *pParent /* = 0*/) const
1121{
1122 return questionBinary(pParent, MessageType_Info,
1123 tr("<p>Are you sure you want to delete the optical drive?</p>"
1124 "<p>You will not be able to insert any optical disks or ISO images "
1125 "or install the Guest Additions without it!</p>"),
1126 0 /* auto-confirm id */,
1127 tr("&Remove", "medium") /* ok button text */,
1128 QString() /* cancel button text */,
1129 false /* ok button by default? */);
1130}
1131
1132bool UIMessageCenter::confirmStorageBusChangeWithOpticalRemoval(QWidget *pParent /* = 0 */) const
1133{
1134 return questionBinary(pParent, MessageType_Question,
1135 tr("<p>This controller has optical devices attached. You have requested storage bus "
1136 "change to type which doesn't support optical devices.</p><p>If you proceed optical "
1137 "devices will be removed.</p>"));
1138}
1139
1140bool UIMessageCenter::confirmStorageBusChangeWithExcessiveRemoval(QWidget *pParent /* = 0 */) const
1141{
1142 return questionBinary(pParent, MessageType_Question,
1143 tr("<p>This controller has devices attached. You have requested storage bus change to "
1144 "type which supports smaller amount of attached devices.</p><p>If you proceed "
1145 "excessive devices will be removed.</p>"));
1146}
1147
1148void UIMessageCenter::cannotAttachDevice(const CMachine &machine, UIMediumDeviceType enmType,
1149 const QString &strLocation, const StorageSlot &storageSlot,
1150 QWidget *pParent /* = 0*/)
1151{
1152 QString strMessage;
1153 switch (enmType)
1154 {
1155 case UIMediumDeviceType_HardDisk:
1156 {
1157 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>.")
1158 .arg(strLocation).arg(gpConverter->toString(storageSlot)).arg(CMachine(machine).GetName());
1159 break;
1160 }
1161 case UIMediumDeviceType_DVD:
1162 {
1163 strMessage = tr("Failed to attach the optical drive (<nobr><b>%1</b></nobr>) to the slot <i>%2</i> of the machine <b>%3</b>.")
1164 .arg(strLocation).arg(gpConverter->toString(storageSlot)).arg(CMachine(machine).GetName());
1165 break;
1166 }
1167 case UIMediumDeviceType_Floppy:
1168 {
1169 strMessage = tr("Failed to attach the floppy drive (<nobr><b>%1</b></nobr>) to the slot <i>%2</i> of the machine <b>%3</b>.")
1170 .arg(strLocation).arg(gpConverter->toString(storageSlot)).arg(CMachine(machine).GetName());
1171 break;
1172 }
1173 default:
1174 break;
1175 }
1176 error(pParent, MessageType_Error,
1177 strMessage, UIErrorString::formatErrorInfo(machine));
1178}
1179
1180bool UIMessageCenter::warnAboutIncorrectPort(QWidget *pParent /* = 0 */) const
1181{
1182 alert(pParent, MessageType_Error,
1183 tr("The current port forwarding rules are not valid. "
1184 "None of the host or guest port values may be set to zero."));
1185 return false;
1186}
1187
1188bool UIMessageCenter::warnAboutIncorrectAddress(QWidget *pParent /* = 0 */) const
1189{
1190 alert(pParent, MessageType_Error,
1191 tr("The current port forwarding rules are not valid. "
1192 "All of the host or guest address values should be correct or empty."));
1193 return false;
1194}
1195
1196bool UIMessageCenter::warnAboutEmptyGuestAddress(QWidget *pParent /* = 0 */) const
1197{
1198 alert(pParent, MessageType_Error,
1199 tr("The current port forwarding rules are not valid. "
1200 "None of the guest address values may be empty."));
1201 return false;
1202}
1203
1204bool UIMessageCenter::warnAboutNameShouldBeUnique(QWidget *pParent /* = 0 */) const
1205{
1206 alert(pParent, MessageType_Error,
1207 tr("The current port forwarding rules are not valid. "
1208 "Rule names should be unique."));
1209 return false;
1210}
1211
1212bool UIMessageCenter::warnAboutRulesConflict(QWidget *pParent /* = 0 */) const
1213{
1214 alert(pParent, MessageType_Error,
1215 tr("The current port forwarding rules are not valid. "
1216 "Few rules have same host ports and conflicting IP addresses."));
1217 return false;
1218}
1219
1220bool UIMessageCenter::confirmCancelingPortForwardingDialog(QWidget *pParent /* = 0*/) const
1221{
1222 return questionBinary(pParent, MessageType_Question,
1223 tr("<p>There are unsaved changes in the port forwarding configuration.</p>"
1224 "<p>If you proceed your changes will be discarded.</p>"),
1225 0 /* auto-confirm id */,
1226 QString() /* ok button text */,
1227 QString() /* cancel button text */,
1228 false /* ok button by default? */);
1229}
1230
1231void UIMessageCenter::cannotChangeMachineAttribute(const CMachine &comMachine, QWidget *pParent /* = 0 */) const
1232{
1233 error(pParent, MessageType_Error,
1234 tr("Failed to change the attribute of the virtual machine <b>%1</b>.")
1235 .arg(comMachine.GetName()),
1236 UIErrorString::formatErrorInfo(comMachine));
1237}
1238
1239void UIMessageCenter::cannotSaveMachineSettings(const CMachine &machine, QWidget *pParent /* = 0*/) const
1240{
1241 error(pParent, MessageType_Error,
1242 tr("Failed to save the settings of the virtual machine <b>%1</b> to <b><nobr>%2</nobr></b>.")
1243 .arg(machine.GetName(), CMachine(machine).GetSettingsFilePath()),
1244 UIErrorString::formatErrorInfo(machine));
1245}
1246
1247void UIMessageCenter::cannotChangeGraphicsAdapterAttribute(const CGraphicsAdapter &comAdapter, QWidget *pParent /* = 0 */) const
1248{
1249 error(pParent, MessageType_Error,
1250 tr("Failed to change graphics adapter attribute."),
1251 UIErrorString::formatErrorInfo(comAdapter));
1252}
1253
1254void UIMessageCenter::cannotChangeAudioAdapterAttribute(const CAudioAdapter &comAdapter, QWidget *pParent /* = 0 */) const
1255{
1256 error(pParent, MessageType_Error,
1257 tr("Failed to change audio adapter attribute."),
1258 UIErrorString::formatErrorInfo(comAdapter));
1259}
1260
1261void UIMessageCenter::cannotChangeNetworkAdapterAttribute(const CNetworkAdapter &comAdapter, QWidget *pParent /* = 0 */) const
1262{
1263 error(pParent, MessageType_Error,
1264 tr("Failed to change network adapter attribute."),
1265 UIErrorString::formatErrorInfo(comAdapter));
1266}
1267
1268void UIMessageCenter::cannotChangeMediumType(const CMedium &medium, KMediumType oldMediumType, KMediumType newMediumType, QWidget *pParent /* = 0*/) const
1269{
1270 error(pParent, MessageType_Error,
1271 tr("<p>Error changing disk image mode from <b>%1</b> to <b>%2</b>.</p>")
1272 .arg(gpConverter->toString(oldMediumType)).arg(gpConverter->toString(newMediumType)),
1273 UIErrorString::formatErrorInfo(medium));
1274}
1275
1276void UIMessageCenter::cannotMoveMediumStorage(const CMedium &comMedium, const QString &strLocationOld, const QString &strLocationNew, QWidget *pParent /* = 0 */) const
1277{
1278 error(pParent, MessageType_Error,
1279 tr("Failed to move the storage unit of the disk image <b>%1</b> to <b>%2</b>.")
1280 .arg(strLocationOld, strLocationNew),
1281 UIErrorString::formatErrorInfo(comMedium));
1282}
1283
1284void UIMessageCenter::cannotMoveMediumStorage(const CProgress &comProgress, const QString &strLocationOld, const QString &strLocationNew, QWidget *pParent /* = 0 */) const
1285{
1286 error(pParent, MessageType_Error,
1287 tr("Failed to move the storage unit of the disk image <b>%1</b> to <b>%2</b>.")
1288 .arg(strLocationOld, strLocationNew),
1289 UIErrorString::formatErrorInfo(comProgress));
1290}
1291
1292void UIMessageCenter::cannotChangeMediumDescription(const CMedium &comMedium, const QString &strLocation, QWidget *pParent /* = 0 */) const
1293{
1294 error(pParent, MessageType_Error,
1295 tr("<p>Error changing the description of the disk image <b>%1</b>.</p>")
1296 .arg(strLocation),
1297 UIErrorString::formatErrorInfo(comMedium));
1298}
1299
1300bool UIMessageCenter::confirmMediumRelease(const UIMedium &medium, bool fInduced, QWidget *pParent /* = 0 */) const
1301{
1302 /* Prepare the usage: */
1303 QStringList usage;
1304 CVirtualBox vbox = uiCommon().virtualBox();
1305 foreach (const QUuid &uMachineID, medium.curStateMachineIds())
1306 {
1307 CMachine machine = vbox.FindMachine(uMachineID.toString());
1308 if (!vbox.isOk() || machine.isNull())
1309 continue;
1310 usage << machine.GetName();
1311 }
1312 /* Show the question: */
1313 return !fInduced
1314 ? questionBinary(pParent, MessageType_Question,
1315 tr("<p>Are you sure you want to release the disk image file <nobr><b>%1</b></nobr>?</p>"
1316 "<p>This will detach it from the following virtual machine(s): <b>%2</b>.</p>")
1317 .arg(medium.location(), usage.join(", ")),
1318 0 /* auto-confirm id */,
1319 tr("Release", "detach medium"))
1320 : questionBinary(pParent, MessageType_Question,
1321 tr("<p>The changes you requested require this disk to "
1322 "be released from the machines it is attached to.</p>"
1323 "<p>Are you sure you want to release the disk image file <nobr><b>%1</b></nobr>?</p>"
1324 "<p>This will detach it from the following virtual machine(s): <b>%2</b>.</p>")
1325 .arg(medium.location(), usage.join(", ")),
1326 0 /* auto-confirm id */,
1327 tr("Release", "detach medium"));
1328}
1329
1330bool UIMessageCenter::confirmMediumRemoval(const UIMedium &medium, QWidget *pParent /* = 0*/) const
1331{
1332 /* Prepare the message: */
1333 QString strMessage;
1334 switch (medium.type())
1335 {
1336 case UIMediumDeviceType_HardDisk:
1337 {
1338 strMessage = tr("<p>Are you sure you want to remove the virtual hard disk "
1339 "<nobr><b>%1</b></nobr> from the list of known disk image files?</p>");
1340 /* Compose capabilities flag: */
1341 qulonglong caps = 0;
1342 QVector<KMediumFormatCapabilities> capabilities;
1343 capabilities = medium.medium().GetMediumFormat().GetCapabilities();
1344 for (int i = 0; i < capabilities.size(); ++i)
1345 caps |= capabilities[i];
1346 /* Check capabilities for additional options: */
1347 if (caps & KMediumFormatCapabilities_File)
1348 {
1349 if (medium.state() == KMediumState_Inaccessible)
1350 strMessage += tr("<p>As this hard disk is inaccessible its image file"
1351 " can not be deleted.</p>");
1352 }
1353 break;
1354 }
1355 case UIMediumDeviceType_DVD:
1356 {
1357 strMessage = tr("<p>Are you sure you want to remove the virtual optical disk "
1358 "<nobr><b>%1</b></nobr> from the list of known disk image files?</p>");
1359 strMessage += tr("<p>Note that the storage unit of this medium will not be "
1360 "deleted and that it will be possible to use it later again.</p>");
1361 break;
1362 }
1363 case UIMediumDeviceType_Floppy:
1364 {
1365 strMessage = tr("<p>Are you sure you want to remove the virtual floppy disk "
1366 "<nobr><b>%1</b></nobr> from the list of known disk image files?</p>");
1367 strMessage += tr("<p>Note that the storage unit of this medium will not be "
1368 "deleted and that it will be possible to use it later again.</p>");
1369 break;
1370 }
1371 default:
1372 break;
1373 }
1374 /* Show the question: */
1375 return questionBinary(pParent, MessageType_Question,
1376 strMessage.arg(medium.location()),
1377 0 /* auto-confirm id */,
1378 tr("Remove", "medium") /* ok button text */,
1379 QString() /* cancel button text */,
1380 false /* ok button by default? */);
1381}
1382
1383int UIMessageCenter::confirmDeleteHardDiskStorage(const QString &strLocation, QWidget *pParent /* = 0*/) const
1384{
1385 return questionTrinary(pParent, MessageType_Question,
1386 tr("<p>Do you want to delete the storage unit of the virtual hard disk "
1387 "<nobr><b>%1</b></nobr>?</p>"
1388 "<p>If you select <b>Delete</b> then the specified storage unit "
1389 "will be permanently deleted. This operation <b>cannot be "
1390 "undone</b>.</p>"
1391 "<p>If you select <b>Keep</b> then the hard disk will be only "
1392 "removed from the list of known hard disks, but the storage unit "
1393 "will be left untouched which makes it possible to add this hard "
1394 "disk to the list later again.</p>")
1395 .arg(strLocation),
1396 0 /* auto-confirm id */,
1397 tr("Delete", "hard disk storage"),
1398 tr("Keep", "hard disk storage"));
1399}
1400
1401void UIMessageCenter::cannotDeleteHardDiskStorage(const CMedium &medium, const QString &strLocation, QWidget *pParent /* = 0*/) const
1402{
1403 error(pParent, MessageType_Error,
1404 tr("Failed to delete the storage unit of the hard disk <b>%1</b>.")
1405 .arg(strLocation),
1406 UIErrorString::formatErrorInfo(medium));
1407}
1408
1409void UIMessageCenter::cannotDeleteHardDiskStorage(const CProgress &progress, const QString &strLocation, QWidget *pParent /* = 0*/) const
1410{
1411 error(pParent, MessageType_Error,
1412 tr("Failed to delete the storage unit of the hard disk <b>%1</b>.")
1413 .arg(strLocation),
1414 UIErrorString::formatErrorInfo(progress));
1415}
1416
1417void UIMessageCenter::cannotResizeHardDiskStorage(const CMedium &comMedium, const QString &strLocation, const QString &strSizeOld, const QString &strSizeNew, QWidget *pParent /* = 0 */) const
1418{
1419 error(pParent, MessageType_Error,
1420 tr("Failed to resize the storage unit of the hard disk <b>%1</b> from <b>%2</b> to <b>%3</b>.")
1421 .arg(strLocation, strSizeOld, strSizeNew),
1422 UIErrorString::formatErrorInfo(comMedium));
1423}
1424
1425void UIMessageCenter::cannotResizeHardDiskStorage(const CProgress &comProgress, const QString &strLocation, const QString &strSizeOld, const QString &strSizeNew, QWidget *pParent /* = 0 */) const
1426{
1427 error(pParent, MessageType_Error,
1428 tr("Failed to resize the storage unit of the hard disk <b>%1</b> from <b>%2</b> to <b>%3</b>.")
1429 .arg(strLocation, strSizeOld, strSizeNew),
1430 UIErrorString::formatErrorInfo(comProgress));
1431}
1432
1433void UIMessageCenter::cannotDetachDevice(const CMachine &machine, UIMediumDeviceType enmType, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent /* = 0*/) const
1434{
1435 /* Prepare the message: */
1436 QString strMessage;
1437 switch (enmType)
1438 {
1439 case UIMediumDeviceType_HardDisk:
1440 {
1441 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>.")
1442 .arg(strLocation, gpConverter->toString(storageSlot), CMachine(machine).GetName());
1443 break;
1444 }
1445 case UIMediumDeviceType_DVD:
1446 {
1447 strMessage = tr("Failed to detach the optical drive (<nobr><b>%1</b></nobr>) from the slot <i>%2</i> of the machine <b>%3</b>.")
1448 .arg(strLocation, gpConverter->toString(storageSlot), CMachine(machine).GetName());
1449 break;
1450 }
1451 case UIMediumDeviceType_Floppy:
1452 {
1453 strMessage = tr("Failed to detach the floppy drive (<nobr><b>%1</b></nobr>) from the slot <i>%2</i> of the machine <b>%3</b>.")
1454 .arg(strLocation, gpConverter->toString(storageSlot), CMachine(machine).GetName());
1455 break;
1456 }
1457 default:
1458 break;
1459 }
1460 /* Show the error: */
1461 error(pParent, MessageType_Error, strMessage, UIErrorString::formatErrorInfo(machine));
1462}
1463
1464bool UIMessageCenter::cannotRemountMedium(const CMachine &machine, const UIMedium &medium, bool fMount, bool fRetry, QWidget *pParent /* = 0*/) const
1465{
1466 /* Compose the message: */
1467 QString strMessage;
1468 switch (medium.type())
1469 {
1470 case UIMediumDeviceType_DVD:
1471 {
1472 if (fMount)
1473 {
1474 strMessage = tr("<p>Unable to insert the virtual optical disk <nobr><b>%1</b></nobr> into the machine <b>%2</b>.</p>");
1475 if (fRetry)
1476 strMessage += tr("<p>Would you like to try to force insertion of this disk?</p>");
1477 }
1478 else
1479 {
1480 strMessage = tr("<p>Unable to eject the virtual optical disk <nobr><b>%1</b></nobr> from the machine <b>%2</b>.</p>");
1481 if (fRetry)
1482 strMessage += tr("<p>Would you like to try to force ejection of this disk?</p>");
1483 }
1484 break;
1485 }
1486 case UIMediumDeviceType_Floppy:
1487 {
1488 if (fMount)
1489 {
1490 strMessage = tr("<p>Unable to insert the virtual floppy disk <nobr><b>%1</b></nobr> into the machine <b>%2</b>.</p>");
1491 if (fRetry)
1492 strMessage += tr("<p>Would you like to try to force insertion of this disk?</p>");
1493 }
1494 else
1495 {
1496 strMessage = tr("<p>Unable to eject the virtual floppy disk <nobr><b>%1</b></nobr> from the machine <b>%2</b>.</p>");
1497 if (fRetry)
1498 strMessage += tr("<p>Would you like to try to force ejection of this disk?</p>");
1499 }
1500 break;
1501 }
1502 default:
1503 break;
1504 }
1505 /* Show the messsage: */
1506 if (fRetry)
1507 return errorWithQuestion(pParent, MessageType_Question,
1508 strMessage.arg(medium.isHostDrive() ? medium.name() : medium.location(), CMachine(machine).GetName()),
1509 UIErrorString::formatErrorInfo(machine),
1510 0 /* Auto Confirm ID */,
1511 tr("Force Unmount"));
1512 error(pParent, MessageType_Error,
1513 strMessage.arg(medium.isHostDrive() ? medium.name() : medium.location(), CMachine(machine).GetName()),
1514 UIErrorString::formatErrorInfo(machine));
1515 return false;
1516}
1517
1518void UIMessageCenter::cannotOpenMedium(const CVirtualBox &comVBox, const QString &strLocation, QWidget *pParent /* = 0 */) const
1519{
1520 /* Show the error: */
1521 error(pParent, MessageType_Error,
1522 tr("Failed to open the disk image file <nobr><b>%1</b></nobr>.").arg(strLocation), UIErrorString::formatErrorInfo(comVBox));
1523}
1524
1525void UIMessageCenter::cannotOpenKnownMedium(const CVirtualBox &comVBox, const QUuid &uMediumId, QWidget *pParent /* = 0 */) const
1526{
1527 /* Show the error: */
1528 error(pParent, MessageType_Error,
1529 tr("Failed to open the medium with following ID: <nobr><b>%1</b></nobr>.").arg(uMediumId.toString()), UIErrorString::formatErrorInfo(comVBox));
1530}
1531
1532void UIMessageCenter::cannotAcquireAttachmentParameter(const CMediumAttachment &comAttachment, QWidget *pParent /* = 0 */) const
1533{
1534 /* Show the error: */
1535 error(pParent, MessageType_Error,
1536 tr("Failed to acquire attachment parameter."), UIErrorString::formatErrorInfo(comAttachment));
1537}
1538
1539void UIMessageCenter::cannotAcquireMediumAttribute(const CMedium &comMedium, QWidget *pParent /* = 0 */) const
1540{
1541 /* Show the error: */
1542 error(pParent, MessageType_Error,
1543 tr("Failed to acquire medium attribute."), UIErrorString::formatErrorInfo(comMedium));
1544}
1545
1546void UIMessageCenter::cannotCloseMedium(const UIMedium &medium, const COMResult &rc, QWidget *pParent /* = 0*/) const
1547{
1548 /* Show the error: */
1549 error(pParent, MessageType_Error,
1550 tr("Failed to close the disk image file <nobr><b>%1</b></nobr>.").arg(medium.location()), UIErrorString::formatErrorInfo(rc));
1551}
1552
1553bool UIMessageCenter::confirmHostOnlyInterfaceRemoval(const QString &strName, QWidget *pParent /* = 0 */) const
1554{
1555 return questionBinary(pParent, MessageType_Question,
1556 tr("<p>Deleting this host-only network will remove "
1557 "the host-only interface this network is based on. Do you want to "
1558 "remove the (host-only network) interface <nobr><b>%1</b>?</nobr></p>"
1559 "<p><b>Note:</b> this interface may be in use by one or more "
1560 "virtual network adapters belonging to one of your VMs. "
1561 "After it is removed, these adapters will no longer be usable until "
1562 "you correct their settings by either choosing a different interface "
1563 "name or a different adapter attachment type.</p>")
1564 .arg(strName),
1565 0 /* auto-confirm id */,
1566 tr("Remove") /* ok button text */,
1567 QString() /* cancel button text */,
1568 false /* ok button by default? */);
1569}
1570
1571void UIMessageCenter::cannotAcquireHostNetworkInterfaces(const CHost &comHost, QWidget *pParent /* = 0 */) const
1572{
1573 error(pParent, MessageType_Error,
1574 tr("Failed to acquire host network interfaces."),
1575 UIErrorString::formatErrorInfo(comHost));
1576}
1577
1578void UIMessageCenter::cannotFindHostNetworkInterface(const CHost &comHost, const QString &strInterfaceName, QWidget *pParent /* = 0 */) const
1579{
1580 error(pParent, MessageType_Error,
1581 tr("Unable to find the host network interface <b>%1</b>.")
1582 .arg(strInterfaceName),
1583 UIErrorString::formatErrorInfo(comHost));
1584}
1585
1586void UIMessageCenter::cannotCreateHostNetworkInterface(const CHost &comHost, QWidget *pParent /* = 0 */) const
1587{
1588 error(pParent, MessageType_Error,
1589 tr("Failed to create a host network interface."),
1590 UIErrorString::formatErrorInfo(comHost));
1591}
1592
1593void UIMessageCenter::cannotCreateHostNetworkInterface(const CProgress &progress, QWidget *pParent /* = 0 */) const
1594{
1595 error(pParent, MessageType_Error,
1596 tr("Failed to create a host network interface."),
1597 UIErrorString::formatErrorInfo(progress));
1598}
1599
1600void UIMessageCenter::cannotRemoveHostNetworkInterface(const CHost &comHost, const QString &strInterfaceName, QWidget *pParent /* = 0 */) const
1601{
1602 error(pParent, MessageType_Error,
1603 tr("Failed to remove the host network interface <b>%1</b>.")
1604 .arg(strInterfaceName),
1605 UIErrorString::formatErrorInfo(comHost));
1606}
1607
1608void UIMessageCenter::cannotRemoveHostNetworkInterface(const CProgress &progress, const QString &strInterfaceName, QWidget *pParent /* = 0 */) const
1609{
1610 error(pParent, MessageType_Error,
1611 tr("Failed to remove the host network interface <b>%1</b>.")
1612 .arg(strInterfaceName),
1613 UIErrorString::formatErrorInfo(progress));
1614}
1615
1616void UIMessageCenter::cannotAcquireHostNetworkInterfaceParameter(const CHostNetworkInterface &comInterface, QWidget *pParent /* = 0 */) const
1617{
1618 error(pParent, MessageType_Error,
1619 tr("Failed to acquire host network interface parameter."),
1620 UIErrorString::formatErrorInfo(comInterface));
1621}
1622
1623void UIMessageCenter::cannotSaveHostNetworkInterfaceParameter(const CHostNetworkInterface &comInterface, QWidget *pParent /* = 0 */) const
1624{
1625 error(pParent, MessageType_Error,
1626 tr("Failed to save host network interface parameter."),
1627 UIErrorString::formatErrorInfo(comInterface));
1628}
1629
1630void UIMessageCenter::cannotCreateDHCPServer(const CVirtualBox &comVBox, const QString &strInterfaceName, QWidget *pParent /* = 0 */) const
1631{
1632 error(pParent, MessageType_Error,
1633 tr("Failed to create a DHCP server for the network interface <b>%1</b>.")
1634 .arg(strInterfaceName),
1635 UIErrorString::formatErrorInfo(comVBox));
1636}
1637
1638void UIMessageCenter::cannotRemoveDHCPServer(const CVirtualBox &comVBox, const QString &strInterfaceName, QWidget *pParent /* = 0 */) const
1639{
1640 error(pParent, MessageType_Error,
1641 tr("Failed to remove the DHCP server for the network interface <b>%1</b>.")
1642 .arg(strInterfaceName),
1643 UIErrorString::formatErrorInfo(comVBox));
1644}
1645
1646void UIMessageCenter::cannotAcquireDHCPServerParameter(const CDHCPServer &comServer, QWidget *pParent /* = 0 */) const
1647{
1648 error(pParent, MessageType_Error,
1649 tr("Failed to acquire DHCP server parameter."),
1650 UIErrorString::formatErrorInfo(comServer));
1651}
1652
1653void UIMessageCenter::cannotSaveDHCPServerParameter(const CDHCPServer &comServer, QWidget *pParent /* = 0 */) const
1654{
1655 error(pParent, MessageType_Error,
1656 tr("Failed to save DHCP server parameter."),
1657 UIErrorString::formatErrorInfo(comServer));
1658}
1659
1660void UIMessageCenter::cannotAcquireCloudProviderManager(const CVirtualBox &comVBox, QWidget *pParent /* = 0 */) const
1661{
1662 error(pParent, MessageType_Error,
1663 tr("Failed to acquire cloud provider manager."),
1664 UIErrorString::formatErrorInfo(comVBox));
1665}
1666
1667void UIMessageCenter::cannotAcquireCloudProviderManagerParameter(const CCloudProviderManager &comManager, QWidget *pParent /* = 0 */) const
1668{
1669 error(pParent, MessageType_Error,
1670 tr("Failed to acquire cloud provider manager parameter."),
1671 UIErrorString::formatErrorInfo(comManager));
1672}
1673
1674void UIMessageCenter::cannotFindCloudProvider(const CCloudProviderManager &comManager, const QUuid &uId, QWidget *pParent /* = 0 */) const
1675{
1676 error(pParent, MessageType_Error,
1677 tr("Failed to find cloud provider with following uuid: <b>%1</b>.").arg(uId.toString()),
1678 UIErrorString::formatErrorInfo(comManager));
1679}
1680
1681void UIMessageCenter::cannotAcquireCloudProviderParameter(const CCloudProvider &comProvider, QWidget *pParent /* = 0 */) const
1682{
1683 error(pParent, MessageType_Error,
1684 tr("Failed to acquire cloud provider parameter."),
1685 UIErrorString::formatErrorInfo(comProvider));
1686}
1687
1688void UIMessageCenter::cannotFindCloudProfile(const CCloudProvider &comProvider, const QString &strName, QWidget *pParent /* = 0 */) const
1689{
1690 error(pParent, MessageType_Error,
1691 tr("Failed to find cloud profile with following name: <b>%1</b>.").arg(strName),
1692 UIErrorString::formatErrorInfo(comProvider));
1693}
1694
1695void UIMessageCenter::cannotCreateCloudProfle(const CCloudProvider &comProvider, QWidget *pParent /* = 0 */) const
1696{
1697 error(pParent, MessageType_Error,
1698 tr("Failed to create cloud profile."),
1699 UIErrorString::formatErrorInfo(comProvider));
1700}
1701
1702void UIMessageCenter::cannotSaveCloudProfiles(const CCloudProvider &comProvider, QWidget *pParent /* = 0 */) const
1703{
1704 error(pParent, MessageType_Error,
1705 tr("Failed to save cloud profiles."),
1706 UIErrorString::formatErrorInfo(comProvider));
1707}
1708
1709void UIMessageCenter::cannotImportCloudProfiles(const CCloudProvider &comProvider, QWidget *pParent /* = 0 */) const
1710{
1711 error(pParent, MessageType_Error,
1712 tr("Failed to import cloud profiles."),
1713 UIErrorString::formatErrorInfo(comProvider));
1714}
1715
1716void UIMessageCenter::cannotAcquireCloudProfileParameter(const CCloudProfile &comProfile, QWidget *pParent /* = 0 */) const
1717{
1718 error(pParent, MessageType_Error,
1719 tr("Failed to acquire cloud profile parameter."),
1720 UIErrorString::formatErrorInfo(comProfile));
1721}
1722
1723void UIMessageCenter::cannotAssignCloudProfileParameter(const CCloudProfile &comProfile, QWidget *pParent /* = 0 */) const
1724{
1725 error(pParent, MessageType_Error,
1726 tr("Failed to assign cloud profile parameter."),
1727 UIErrorString::formatErrorInfo(comProfile));
1728}
1729
1730void UIMessageCenter::cannotCreateCloudClient(const CCloudProfile &comProfile, QWidget *pParent /* = 0 */) const
1731{
1732 error(pParent, MessageType_Error,
1733 tr("Failed to create cloud client."),
1734 UIErrorString::formatErrorInfo(comProfile));
1735}
1736
1737void UIMessageCenter::cannotCreateCloudMachine(const CCloudClient &comClient, QWidget *pParent /* = 0 */) const
1738{
1739 error(pParent, MessageType_Error,
1740 tr("Failed to create cloud machine."),
1741 UIErrorString::formatErrorInfo(comClient));
1742}
1743
1744void UIMessageCenter::cannotCreateCloudMachine(const CProgress &comProgress, QWidget *pParent /* = 0 */) const
1745{
1746 error(pParent, MessageType_Error,
1747 tr("Failed to create cloud machine."),
1748 UIErrorString::formatErrorInfo(comProgress));
1749}
1750
1751void UIMessageCenter::cannotAcquireCloudClientParameter(const CCloudClient &comClient, QWidget *pParent /* = 0 */) const
1752{
1753 error(pParent, MessageType_Error,
1754 tr("Failed to acquire cloud client parameter."),
1755 UIErrorString::formatErrorInfo(comClient));
1756}
1757
1758void UIMessageCenter::cannotAcquireCloudClientParameter(const CProgress &comProgress, QWidget *pParent /* = 0 */) const
1759{
1760 error(pParent, MessageType_Error,
1761 tr("Failed to acquire cloud client parameter."),
1762 UIErrorString::formatErrorInfo(comProgress));
1763}
1764
1765bool UIMessageCenter::confirmCloudProfileRemoval(const QString &strName, QWidget *pParent /* = 0 */) const
1766{
1767 return questionBinary(pParent, MessageType_Question,
1768 tr("<p>Do you want to remove the cloud profile <nobr><b>%1</b>?</nobr></p>")
1769 .arg(strName),
1770 0 /* auto-confirm id */,
1771 tr("Remove") /* ok button text */,
1772 QString() /* cancel button text */,
1773 false /* ok button by default? */);
1774}
1775
1776bool UIMessageCenter::confirmCloudProfilesImport(QWidget *pParent /* = 0 */) const
1777{
1778 return questionBinary(pParent, MessageType_Question,
1779 tr("<p>Do you want to import cloud profiles from external files?</p>"
1780 "<p>VirtualBox cloud profiles will be overwritten and their data will be lost.</p>"),
1781 0 /* auto-confirm id */,
1782 tr("Import") /* ok button text */,
1783 QString() /* cancel button text */,
1784 false /* ok button by default? */);
1785}
1786
1787void UIMessageCenter::cannotAssignFormValue(const CBooleanFormValue &comValue, QWidget *pParent /* = 0 */) const
1788{
1789 error(pParent, MessageType_Error,
1790 tr("Failed to assign form value."),
1791 UIErrorString::formatErrorInfo(comValue));
1792}
1793
1794void UIMessageCenter::cannotAssignFormValue(const CStringFormValue &comValue, QWidget *pParent /* = 0 */) const
1795{
1796 error(pParent, MessageType_Error,
1797 tr("Failed to assign form value."),
1798 UIErrorString::formatErrorInfo(comValue));
1799}
1800
1801void UIMessageCenter::cannotAssignFormValue(const CChoiceFormValue &comValue, QWidget *pParent /* = 0 */) const
1802{
1803 error(pParent, MessageType_Error,
1804 tr("Failed to assign form value."),
1805 UIErrorString::formatErrorInfo(comValue));
1806}
1807
1808void UIMessageCenter::cannotAssignFormValue(const CRangedIntegerFormValue &comValue, QWidget *pParent /* = 0 */) const
1809{
1810 error(pParent, MessageType_Error,
1811 tr("Failed to assign form value."),
1812 UIErrorString::formatErrorInfo(comValue));
1813}
1814
1815void UIMessageCenter::cannotAssignFormValue(const CProgress &comProgress, QWidget *pParent /* = 0 */) const
1816{
1817 error(pParent, MessageType_Error,
1818 tr("Failed to assign form value."),
1819 UIErrorString::formatErrorInfo(comProgress));
1820}
1821
1822bool UIMessageCenter::confirmHardDisklessMachine(QWidget *pParent /* = 0*/) const
1823{
1824 return questionBinary(pParent, MessageType_Warning,
1825 tr("You are about to create a new virtual machine without a hard disk. "
1826 "You will not be able to install an operating system on the machine "
1827 "until you add one. In the mean time you will only be able to start the "
1828 "machine using a virtual optical disk or from the network."),
1829 0 /* auto-confirm id */,
1830 tr("Continue", "no hard disk attached"),
1831 tr("Go Back", "no hard disk attached"));
1832}
1833
1834void UIMessageCenter::cannotCreateMachine(const CVirtualBox &vbox, QWidget *pParent /* = 0*/) const
1835{
1836 error(pParent, MessageType_Error,
1837 tr("Failed to create a new virtual machine."),
1838 UIErrorString::formatErrorInfo(vbox));
1839}
1840
1841void UIMessageCenter::cannotRegisterMachine(const CVirtualBox &vbox, const QString &strMachineName, QWidget *pParent /* = 0*/) const
1842{
1843 error(pParent, MessageType_Error,
1844 tr("Failed to register the virtual machine <b>%1</b>.")
1845 .arg(strMachineName),
1846 UIErrorString::formatErrorInfo(vbox));
1847}
1848
1849void UIMessageCenter::cannotCreateClone(const CMachine &machine, QWidget *pParent /* = 0*/) const
1850{
1851 error(pParent, MessageType_Error,
1852 tr("Failed to clone the virtual machine <b>%1</b>.")
1853 .arg(CMachine(machine).GetName()),
1854 UIErrorString::formatErrorInfo(machine));
1855}
1856
1857void UIMessageCenter::cannotCreateClone(const CProgress &progress, const QString &strMachineName, QWidget *pParent /* = 0*/) const
1858{
1859 error(pParent, MessageType_Error,
1860 tr("Failed to clone the virtual machine <b>%1</b>.")
1861 .arg(strMachineName),
1862 UIErrorString::formatErrorInfo(progress));
1863}
1864
1865void UIMessageCenter::cannotOverwriteHardDiskStorage(const QString &strLocation, QWidget *pParent /* = 0*/) const
1866{
1867 alert(pParent, MessageType_Info,
1868 tr("<p>The hard disk storage unit at location <b>%1</b> already exists. "
1869 "You cannot create a new virtual hard disk that uses this location "
1870 "because it can be already used by another virtual hard disk.</p>"
1871 "<p>Please specify a different location.</p>")
1872 .arg(strLocation));
1873}
1874
1875void UIMessageCenter::cannotCreateHardDiskStorage(const CVirtualBox &vbox, const QString &strLocation, QWidget *pParent /* = 0*/) const
1876{
1877 error(pParent, MessageType_Error,
1878 tr("Failed to create the hard disk storage <nobr><b>%1</b>.</nobr>")
1879 .arg(strLocation),
1880 UIErrorString::formatErrorInfo(vbox));
1881}
1882
1883void UIMessageCenter::cannotCreateHardDiskStorage(const CMedium &medium, const QString &strLocation, QWidget *pParent /* = 0*/) const
1884{
1885 error(pParent, MessageType_Error,
1886 tr("Failed to create the hard disk storage <nobr><b>%1</b>.</nobr>")
1887 .arg(strLocation),
1888 UIErrorString::formatErrorInfo(medium));
1889}
1890
1891void UIMessageCenter::cannotCreateHardDiskStorage(const CProgress &progress, const QString &strLocation, QWidget *pParent /* = 0*/) const
1892{
1893 error(pParent, MessageType_Error,
1894 tr("Failed to create the hard disk storage <nobr><b>%1</b>.</nobr>")
1895 .arg(strLocation),
1896 UIErrorString::formatErrorInfo(progress));
1897}
1898
1899void UIMessageCenter::cannotCreateHardDiskStorageInFAT(const QString &strLocation, QWidget *pParent /* = 0 */) const
1900{
1901 alert(pParent, MessageType_Info,
1902 tr("Failed to create the hard disk storage <nobr><b>%1</b>.</nobr> FAT file systems have 4GB file size limit.")
1903 .arg(strLocation));
1904}
1905
1906void UIMessageCenter::cannotCreateMediumStorage(const CVirtualBox &comVBox, const QString &strLocation, QWidget *pParent /* = 0 */) const
1907{
1908 error(pParent, MessageType_Error,
1909 tr("Failed to create the virtual disk image storage <nobr><b>%1</b>.</nobr>")
1910 .arg(strLocation),
1911 UIErrorString::formatErrorInfo(comVBox));
1912}
1913
1914void UIMessageCenter::cannotCreateMediumStorage(const CMedium &comMedium, const QString &strLocation, QWidget *pParent /* = 0 */) const
1915{
1916 error(pParent, MessageType_Error,
1917 tr("Failed to create the virtual disk image storage <nobr><b>%1</b>.</nobr>")
1918 .arg(strLocation),
1919 UIErrorString::formatErrorInfo(comMedium));
1920}
1921
1922void UIMessageCenter::cannotCreateMediumStorage(const CProgress &comProgress, const QString &strLocation, QWidget *pParent /* = 0 */) const
1923{
1924 error(pParent, MessageType_Error,
1925 tr("Failed to create the virtual disk image storage <nobr><b>%1</b>.</nobr>")
1926 .arg(strLocation),
1927 UIErrorString::formatErrorInfo(comProgress));
1928}
1929
1930void UIMessageCenter::cannotRemoveMachineFolder(const QString &strFolderName, QWidget *pParent /* = 0*/) const
1931{
1932 alert(pParent, MessageType_Critical,
1933 tr("<p>Cannot remove the machine folder <nobr><b>%1</b>.</nobr></p>"
1934 "<p>Please check that this folder really exists and that you have permissions to remove it.</p>")
1935 .arg(QFileInfo(strFolderName).fileName()));
1936}
1937
1938void UIMessageCenter::cannotRewriteMachineFolder(const QString &strFolderName, QWidget *pParent /* = 0*/) const
1939{
1940 QFileInfo fi(strFolderName);
1941 alert(pParent, MessageType_Critical,
1942 tr("<p>Cannot create the machine folder <b>%1</b> in the parent folder <nobr><b>%2</b>.</nobr></p>"
1943 "<p>This folder already exists and possibly belongs to another machine.</p>")
1944 .arg(fi.fileName()).arg(fi.absolutePath()));
1945}
1946
1947void UIMessageCenter::cannotCreateMachineFolder(const QString &strFolderName, QWidget *pParent /* = 0*/) const
1948{
1949 QFileInfo fi(strFolderName);
1950 alert(pParent, MessageType_Critical,
1951 tr("<p>Cannot create the machine folder <b>%1</b> in the parent folder <nobr><b>%2</b>.</nobr></p>"
1952 "<p>Please check that the parent really exists and that you have permissions to create the machine folder.</p>")
1953 .arg(fi.fileName()).arg(fi.absolutePath()));
1954}
1955
1956void UIMessageCenter::cannotCreateAppliance(const CVirtualBox &comVBox, QWidget *pParent /* = 0 */) const
1957{
1958 error(pParent, MessageType_Critical, tr("<p>Cannot create a virtual appliance.</p>"),
1959 UIErrorString::formatErrorInfo(comVBox));
1960}
1961
1962void UIMessageCenter::cannotCreateVirtualSystemDescription(const CAppliance &comAppliance, QWidget *pParent /* = 0 */) const
1963{
1964 error(pParent, MessageType_Critical, tr("<p>Cannot create a virtual system description.</p>"),
1965 UIErrorString::formatErrorInfo(comAppliance));
1966}
1967
1968void UIMessageCenter::cannotAcquireVirtualSystemDescription(const CAppliance &comAppliance, QWidget *pParent /* = 0 */) const
1969{
1970 error(pParent, MessageType_Critical, tr("<p>Cannot create a virtual system description.</p>"),
1971 UIErrorString::formatErrorInfo(comAppliance));
1972}
1973
1974void UIMessageCenter::cannotAddVirtualSystemDescriptionValue(const CVirtualSystemDescription &comDescription,
1975 QWidget *pParent /* = 0 */) const
1976{
1977 error(pParent, MessageType_Critical, tr("<p>Cannot add a virtual system description value.</p>"),
1978 UIErrorString::formatErrorInfo(comDescription));
1979}
1980
1981void UIMessageCenter::cannotAcquireVirtualSystemDescriptionFormProperty(const CVirtualSystemDescriptionForm &comForm,
1982 QWidget *pParent /* = 0 */) const
1983{
1984 error(pParent, MessageType_Critical, tr("<p>Cannot acquire a virtual system description property.</p>"),
1985 UIErrorString::formatErrorInfo(comForm));
1986}
1987
1988void UIMessageCenter::cannotImportAppliance(CAppliance &appliance, QWidget *pParent /* = 0*/) const
1989{
1990 /* Preserve error-info: */
1991 QString strErrorInfo = UIErrorString::formatErrorInfo(appliance);
1992 /* Add the warnings in the case of an early error: */
1993 QString strWarningInfo;
1994 foreach(const QString &strWarning, appliance.GetWarnings())
1995 strWarningInfo += QString("<br />Warning: %1").arg(strWarning);
1996 if (!strWarningInfo.isEmpty())
1997 strWarningInfo = "<br />" + strWarningInfo;
1998 /* Show the error: */
1999 error(pParent, MessageType_Error,
2000 tr("Failed to open/interpret appliance <b>%1</b>.")
2001 .arg(appliance.GetPath()),
2002 strWarningInfo + strErrorInfo);
2003}
2004
2005void UIMessageCenter::cannotImportAppliance(const CProgress &progress, const QString &strPath, QWidget *pParent /* = 0*/) const
2006{
2007 error(pParent, MessageType_Error,
2008 tr("Failed to import appliance <b>%1</b>.")
2009 .arg(strPath),
2010 UIErrorString::formatErrorInfo(progress));
2011}
2012
2013bool UIMessageCenter::cannotCheckFiles(const CAppliance &comAppliance, QWidget *pParent /* = 0 */) const
2014{
2015 error(pParent, MessageType_Error,
2016 tr("Failed to check files."),
2017 UIErrorString::formatErrorInfo(comAppliance));
2018 return false;
2019}
2020
2021bool UIMessageCenter::cannotCheckFiles(const CVFSExplorer &comVFSExplorer, QWidget *pParent /* = 0 */) const
2022{
2023 error(pParent, MessageType_Error,
2024 tr("Failed to check files."),
2025 UIErrorString::formatErrorInfo(comVFSExplorer));
2026 return false;
2027}
2028
2029bool UIMessageCenter::cannotCheckFiles(const CProgress &comProgress, QWidget *pParent /* = 0 */) const
2030{
2031 error(pParent, MessageType_Error,
2032 tr("Failed to check files."),
2033 UIErrorString::formatErrorInfo(comProgress));
2034 return false;
2035}
2036
2037bool UIMessageCenter::cannotRemoveFiles(const CVFSExplorer &comVFSExplorer, QWidget *pParent /* = 0 */) const
2038{
2039 error(pParent, MessageType_Error,
2040 tr("Failed to remove file."),
2041 UIErrorString::formatErrorInfo(comVFSExplorer));
2042 return false;
2043}
2044
2045bool UIMessageCenter::cannotRemoveFiles(const CProgress &comProgress, QWidget *pParent /* = 0 */) const
2046{
2047 error(pParent, MessageType_Error,
2048 tr("Failed to remove file."),
2049 UIErrorString::formatErrorInfo(comProgress));
2050 return false;
2051}
2052
2053bool UIMessageCenter::confirmExportMachinesInSaveState(const QStringList &machineNames, QWidget *pParent /* = 0*/) const
2054{
2055 return questionBinary(pParent, MessageType_Warning,
2056 tr("<p>The %n following virtual machine(s) are currently in a saved state: <b>%1</b></p>"
2057 "<p>If you continue the runtime state of the exported machine(s) will be discarded. "
2058 "The other machine(s) will not be changed.</p>",
2059 "This text is never used with n == 0. Feel free to drop the %n where possible, "
2060 "we only included it because of problems with Qt Linguist (but the user can see "
2061 "how many machines are in the list and doesn't need to be told).", machineNames.size())
2062 .arg(machineNames.join(", ")),
2063 0 /* auto-confirm id */,
2064 tr("Continue"));
2065}
2066
2067bool UIMessageCenter::cannotExportAppliance(const CAppliance &comAppliance, QWidget *pParent /* = 0 */) const
2068{
2069 error(pParent, MessageType_Error,
2070 tr("Failed to prepare the export of the appliance <b>%1</b>.")
2071 .arg(CAppliance(comAppliance).GetPath()),
2072 UIErrorString::formatErrorInfo(comAppliance));
2073 return false;
2074}
2075
2076void UIMessageCenter::cannotExportAppliance(const CMachine &machine, const QString &strPath, QWidget *pParent /* = 0 */) const
2077{
2078 error(pParent, MessageType_Error,
2079 tr("Failed to prepare the export of the appliance <b>%1</b>.")
2080 .arg(strPath),
2081 UIErrorString::formatErrorInfo(machine));
2082}
2083
2084bool UIMessageCenter::cannotExportAppliance(const CProgress &comProgress, const QString &strPath, QWidget *pParent /* = 0 */) const
2085{
2086 error(pParent, MessageType_Error,
2087 tr("Failed to export appliance <b>%1</b>.")
2088 .arg(strPath),
2089 UIErrorString::formatErrorInfo(comProgress));
2090 return false;
2091}
2092
2093bool UIMessageCenter::cannotAddDiskEncryptionPassword(const CAppliance &comAppliance, QWidget *pParent /* = 0 */)
2094{
2095 error(pParent, MessageType_Error,
2096 tr("Bad password or authentication failure."),
2097 UIErrorString::formatErrorInfo(comAppliance));
2098 return false;
2099}
2100
2101void UIMessageCenter::showRuntimeError(const CConsole &console, bool fFatal, const QString &strErrorId, const QString &strErrorMsg) const
2102{
2103 /* Prepare auto-confirm id: */
2104 QByteArray autoConfimId = "showRuntimeError.";
2105
2106 /* Prepare variables: */
2107 CConsole console1 = console;
2108 KMachineState state = console1.GetState();
2109 MessageType enmType;
2110 QString severity;
2111
2112 /// @todo Move to Runtime UI!
2113 /* Preprocessing: */
2114 if (fFatal)
2115 {
2116 /* The machine must be paused on fFatal errors: */
2117 Assert(state == KMachineState_Paused);
2118 if (state != KMachineState_Paused)
2119 console1.Pause();
2120 }
2121
2122 /* Compose type, severity, advance confirm id: */
2123 if (fFatal)
2124 {
2125 enmType = MessageType_Critical;
2126 severity = tr("<nobr>Fatal Error</nobr>", "runtime error info");
2127 autoConfimId += "fatal.";
2128 }
2129 else if (state == KMachineState_Paused)
2130 {
2131 enmType = MessageType_Error;
2132 severity = tr("<nobr>Non-Fatal Error</nobr>", "runtime error info");
2133 autoConfimId += "error.";
2134 }
2135 else
2136 {
2137 enmType = MessageType_Warning;
2138 severity = tr("<nobr>Warning</nobr>", "runtime error info");
2139 autoConfimId += "warning.";
2140 }
2141 /* Advance auto-confirm id: */
2142 autoConfimId += strErrorId.toUtf8();
2143
2144 /* Format error-details: */
2145 QString formatted("<!--EOM-->");
2146 if (!strErrorMsg.isEmpty())
2147 formatted.prepend(QString("<p>%1.</p>").arg(uiCommon().emphasize(strErrorMsg)));
2148 if (!strErrorId.isEmpty())
2149 formatted += QString("<table bgcolor=#EEEEEE border=0 cellspacing=5 "
2150 "cellpadding=0 width=100%>"
2151 "<tr><td>%1</td><td>%2</td></tr>"
2152 "<tr><td>%3</td><td>%4</td></tr>"
2153 "</table>")
2154 .arg(tr("<nobr>Error ID: </nobr>", "runtime error info"), strErrorId)
2155 .arg(tr("Severity: ", "runtime error info"), severity);
2156 if (!formatted.isEmpty())
2157 formatted = "<qt>" + formatted + "</qt>";
2158
2159 /* Show the error: */
2160 if (enmType == MessageType_Critical)
2161 {
2162 error(0, enmType,
2163 tr("<p>A fatal error has occurred during virtual machine execution! "
2164 "The virtual machine will be powered off. Please copy the following error message "
2165 "using the clipboard to help diagnose the problem:</p>"),
2166 formatted, autoConfimId.data());
2167 }
2168 else if (enmType == MessageType_Error)
2169 {
2170 error(0, enmType,
2171 tr("<p>An error has occurred during virtual machine execution! "
2172 "The error details are shown below. You may try to correct the error "
2173 "and resume the virtual machine execution.</p>"),
2174 formatted, autoConfimId.data());
2175 }
2176 else
2177 {
2178 /** @todo r=bird: This is a very annoying message as it refers to invisible text
2179 * below. User have to expand "Details" to see what actually went wrong.
2180 * Probably a good idea to check strErrorId and see if we can come up with better
2181 * messages here, at least for common stuff like DvdOrFloppyImageInaccesssible... */
2182 error(0, enmType,
2183 tr("<p>The virtual machine execution ran into a non-fatal problem as described below. "
2184 "We suggest that you take appropriate action to prevent the problem from recurring.</p>"),
2185 formatted, autoConfimId.data());
2186 }
2187
2188 /// @todo Move to Runtime UI!
2189 /* Postprocessing: */
2190 if (fFatal)
2191 {
2192 /* Power down after a fFatal error: */
2193 LogRel(("GUI: Powering VM down after a fatal runtime error...\n"));
2194 console1.PowerDown();
2195 }
2196}
2197
2198bool UIMessageCenter::remindAboutGuruMeditation(const QString &strLogFolder)
2199{
2200 return questionBinary(0, MessageType_GuruMeditation,
2201 tr("<p>A critical error has occurred while running the virtual "
2202 "machine and the machine execution has been stopped.</p>"
2203 ""
2204 "<p>For help, please see the Community section on "
2205 "<a href=https://www.virtualbox.org>https://www.virtualbox.org</a> "
2206 "or your support contract. Please provide the contents of the "
2207 "log file <tt>VBox.log</tt> and the image file <tt>VBox.png</tt>, "
2208 "which you can find in the <nobr><b>%1</b></nobr> directory, "
2209 "as well as a description of what you were doing when this error happened. "
2210 ""
2211 "Note that you can also access the above files by selecting <b>Show Log</b> "
2212 "from the <b>Machine</b> menu of the main VirtualBox window.</p>"
2213 ""
2214 "<p>Press <b>OK</b> if you want to power off the machine "
2215 "or press <b>Ignore</b> if you want to leave it as is for debugging. "
2216 "Please note that debugging requires special knowledge and tools, "
2217 "so it is recommended to press <b>OK</b> now.</p>")
2218 .arg(strLogFolder),
2219 0 /* auto-confirm id */,
2220 QIMessageBox::tr("OK"),
2221 tr("Ignore"));
2222}
2223
2224void UIMessageCenter::warnAboutVBoxSVCUnavailable() const
2225{
2226 alert(0, MessageType_Critical,
2227 tr("<p>A critical error has occurred while running the virtual "
2228 "machine and the machine execution should be stopped.</p>"
2229 ""
2230 "<p>For help, please see the Community section on "
2231 "<a href=https://www.virtualbox.org>https://www.virtualbox.org</a> "
2232 "or your support contract. Please provide the contents of the "
2233 "log file <tt>VBox.log</tt>, "
2234 "which you can find in the virtual machine log directory, "
2235 "as well as a description of what you were doing when this error happened. "
2236 ""
2237 "Note that you can also access the above file by selecting <b>Show Log</b> "
2238 "from the <b>Machine</b> menu of the main VirtualBox window.</p>"
2239 ""
2240 "<p>Press <b>OK</b> to power off the machine.</p>"),
2241 0 /* auto-confirm id */);
2242}
2243
2244bool UIMessageCenter::warnAboutVirtExInactiveFor64BitsGuest(bool fHWVirtExSupported) const
2245{
2246 if (fHWVirtExSupported)
2247 return questionBinary(0, MessageType_Error,
2248 tr("<p>VT-x/AMD-V hardware acceleration has been enabled, but is not operational. "
2249 "Your 64-bit guest will fail to detect a 64-bit CPU and will not be able to boot.</p>"
2250 "<p>Please ensure that you have enabled VT-x/AMD-V properly in the BIOS of your host computer.</p>"),
2251 0 /* auto-confirm id */,
2252 tr("Close VM"), tr("Continue"));
2253 else
2254 return questionBinary(0, MessageType_Error,
2255 tr("<p>VT-x/AMD-V hardware acceleration is not available on your system. "
2256 "Your 64-bit guest will fail to detect a 64-bit CPU and will not be able to boot."),
2257 0 /* auto-confirm id */,
2258 tr("Close VM"), tr("Continue"));
2259}
2260
2261bool UIMessageCenter::warnAboutVirtExInactiveForRecommendedGuest(bool fHWVirtExSupported) const
2262{
2263 if (fHWVirtExSupported)
2264 return questionBinary(0, MessageType_Error,
2265 tr("<p>VT-x/AMD-V hardware acceleration has been enabled, but is not operational. "
2266 "Certain guests (e.g. OS/2 and QNX) require this feature.</p>"
2267 "<p>Please ensure that you have enabled VT-x/AMD-V properly in the BIOS of your host computer.</p>"),
2268 0 /* auto-confirm id */,
2269 tr("Close VM"), tr("Continue"));
2270 else
2271 return questionBinary(0, MessageType_Error,
2272 tr("<p>VT-x/AMD-V hardware acceleration is not available on your system. "
2273 "Certain guests (e.g. OS/2 and QNX) require this feature and will fail to boot without it.</p>"),
2274 0 /* auto-confirm id */,
2275 tr("Close VM"), tr("Continue"));
2276}
2277
2278bool UIMessageCenter::cannotStartWithoutNetworkIf(const QString &strMachineName, const QString &strIfNames) const
2279{
2280 return questionBinary(0, MessageType_Error,
2281 tr("<p>Could not start the machine <b>%1</b> because the following "
2282 "physical network interfaces were not found:</p><p><b>%2</b></p>"
2283 "<p>You can either change the machine's network settings or stop the machine.</p>")
2284 .arg(strMachineName, strIfNames),
2285 0 /* auto-confirm id */,
2286 tr("Change Network Settings"), tr("Close VM"));
2287}
2288
2289void UIMessageCenter::cannotStartMachine(const CConsole &console, const QString &strName) const
2290{
2291 error(0, MessageType_Error,
2292 tr("Failed to start the virtual machine <b>%1</b>.")
2293 .arg(strName),
2294 UIErrorString::formatErrorInfo(console));
2295}
2296
2297void UIMessageCenter::cannotStartMachine(const CProgress &progress, const QString &strName) const
2298{
2299 error(0, MessageType_Error,
2300 tr("Failed to start the virtual machine <b>%1</b>.")
2301 .arg(strName),
2302 UIErrorString::formatErrorInfo(progress));
2303}
2304
2305bool UIMessageCenter::confirmInputCapture(bool &fAutoConfirmed) const
2306{
2307 int rc = question(0, MessageType_Info,
2308 tr("<p>You have <b>clicked the mouse</b> inside the Virtual Machine display or pressed the <b>host key</b>. "
2309 "This will cause the Virtual Machine to <b>capture</b> the host mouse pointer (only if the mouse pointer "
2310 "integration is not currently supported by the guest OS) and the keyboard, which will make them "
2311 "unavailable to other applications running on your host machine.</p>"
2312 "<p>You can press the <b>host key</b> at any time to <b>uncapture</b> the keyboard and mouse "
2313 "(if it is captured) and return them to normal operation. "
2314 "The currently assigned host key is shown on the status bar at the bottom of the Virtual Machine window, "
2315 "next to the&nbsp;<img src=:/hostkey_16px.png/>&nbsp;icon. "
2316 "This icon, together with the mouse icon placed nearby, indicate the current keyboard and mouse capture state.</p>") +
2317 tr("<p>The host key is currently defined as <b>%1</b>.</p>", "additional message box paragraph")
2318 .arg(UIHostCombo::toReadableString(gEDataManager->hostKeyCombination())),
2319 "confirmInputCapture",
2320 AlertButton_Ok | AlertButtonOption_Default,
2321 AlertButton_Cancel | AlertButtonOption_Escape,
2322 0,
2323 tr("Capture", "do input capture"));
2324 /* Was the message auto-confirmed? */
2325 fAutoConfirmed = (rc & AlertOption_AutoConfirmed);
2326 /* True if "Ok" was pressed: */
2327 return (rc & AlertButtonMask) == AlertButton_Ok;
2328}
2329
2330bool UIMessageCenter::confirmGoingFullscreen(const QString &strHotKey) const
2331{
2332 return questionBinary(0, MessageType_Info,
2333 tr("<p>The virtual machine window will be now switched to <b>full-screen</b> mode. "
2334 "You can go back to windowed mode at any time by pressing <b>%1</b>.</p>"
2335 "<p>Note that the <i>Host</i> key is currently defined as <b>%2</b>.</p>"
2336 "<p>Note that the main menu bar is hidden in full-screen mode. "
2337 "You can access it by pressing <b>Host+Home</b>.</p>")
2338 .arg(strHotKey, UIHostCombo::toReadableString(gEDataManager->hostKeyCombination())),
2339 "confirmGoingFullscreen",
2340 tr("Switch"));
2341}
2342
2343bool UIMessageCenter::confirmGoingSeamless(const QString &strHotKey) const
2344{
2345 return questionBinary(0, MessageType_Info,
2346 tr("<p>The virtual machine window will be now switched to <b>Seamless</b> mode. "
2347 "You can go back to windowed mode at any time by pressing <b>%1</b>.</p>"
2348 "<p>Note that the <i>Host</i> key is currently defined as <b>%2</b>.</p>"
2349 "<p>Note that the main menu bar is hidden in seamless mode. "
2350 "You can access it by pressing <b>Host+Home</b>.</p>")
2351 .arg(strHotKey, UIHostCombo::toReadableString(gEDataManager->hostKeyCombination())),
2352 "confirmGoingSeamless",
2353 tr("Switch"));
2354}
2355
2356bool UIMessageCenter::confirmGoingScale(const QString &strHotKey) const
2357{
2358 return questionBinary(0, MessageType_Info,
2359 tr("<p>The virtual machine window will be now switched to <b>Scale</b> mode. "
2360 "You can go back to windowed mode at any time by pressing <b>%1</b>.</p>"
2361 "<p>Note that the <i>Host</i> key is currently defined as <b>%2</b>.</p>"
2362 "<p>Note that the main menu bar is hidden in scaled mode. "
2363 "You can access it by pressing <b>Host+Home</b>.</p>")
2364 .arg(strHotKey, UIHostCombo::toReadableString(gEDataManager->hostKeyCombination())),
2365 "confirmGoingScale",
2366 tr("Switch"));
2367}
2368
2369bool UIMessageCenter::cannotEnterFullscreenMode(ULONG /* uWidth */, ULONG /* uHeight */, ULONG /* uBpp */, ULONG64 uMinVRAM) const
2370{
2371 return questionBinary(0, MessageType_Warning,
2372 tr("<p>Could not switch the guest display to full-screen mode due to insufficient guest video memory.</p>"
2373 "<p>You should configure the virtual machine to have at least <b>%1</b> of video memory.</p>"
2374 "<p>Press <b>Ignore</b> to switch to full-screen mode anyway or press <b>Cancel</b> to cancel the operation.</p>")
2375 .arg(UICommon::formatSize(uMinVRAM)),
2376 0 /* auto-confirm id */,
2377 tr("Ignore"));
2378}
2379
2380void UIMessageCenter::cannotEnterSeamlessMode(ULONG /* uWidth */, ULONG /* uHeight */, ULONG /* uBpp */, ULONG64 uMinVRAM) const
2381{
2382 alert(0, MessageType_Error,
2383 tr("<p>Could not enter seamless mode due to insufficient guest "
2384 "video memory.</p>"
2385 "<p>You should configure the virtual machine to have at "
2386 "least <b>%1</b> of video memory.</p>")
2387 .arg(UICommon::formatSize(uMinVRAM)));
2388}
2389
2390bool UIMessageCenter::cannotSwitchScreenInFullscreen(quint64 uMinVRAM) const
2391{
2392 return questionBinary(0, MessageType_Warning,
2393 tr("<p>Could not change the guest screen to this host screen due to insufficient guest video memory.</p>"
2394 "<p>You should configure the virtual machine to have at least <b>%1</b> of video memory.</p>"
2395 "<p>Press <b>Ignore</b> to switch the screen anyway or press <b>Cancel</b> to cancel the operation.</p>")
2396 .arg(UICommon::formatSize(uMinVRAM)),
2397 0 /* auto-confirm id */,
2398 tr("Ignore"));
2399}
2400
2401void UIMessageCenter::cannotSwitchScreenInSeamless(quint64 uMinVRAM) const
2402{
2403 alert(0, MessageType_Error,
2404 tr("<p>Could not change the guest screen to this host screen "
2405 "due to insufficient guest video memory.</p>"
2406 "<p>You should configure the virtual machine to have at "
2407 "least <b>%1</b> of video memory.</p>")
2408 .arg(UICommon::formatSize(uMinVRAM)));
2409}
2410
2411void UIMessageCenter::cannotAddDiskEncryptionPassword(const CConsole &console)
2412{
2413 error(0, MessageType_Error,
2414 tr("Bad password or authentication failure."),
2415 UIErrorString::formatErrorInfo(console));
2416}
2417
2418#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
2419bool UIMessageCenter::confirmCancelingAllNetworkRequests() const
2420{
2421 return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
2422 tr("Do you wish to cancel all current network operations?"));
2423}
2424
2425void UIMessageCenter::showUpdateSuccess(const QString &strVersion, const QString &strLink) const
2426{
2427 alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Info,
2428 tr("<p>A new version of VirtualBox has been released! Version <b>%1</b> is available "
2429 "at <a href=\"https://www.virtualbox.org/\">virtualbox.org</a>.</p>"
2430 "<p>You can download this version using the link:</p>"
2431 "<p><a href=%2>%3</a></p>")
2432 .arg(strVersion, strLink, strLink));
2433}
2434
2435void UIMessageCenter::showUpdateNotFound() const
2436{
2437 alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Info,
2438 tr("You are already running the most recent version of VirtualBox."));
2439}
2440
2441void UIMessageCenter::askUserToDownloadExtensionPack(const QString &strExtPackName, const QString &strExtPackVersion, const QString &strVBoxVersion) const
2442{
2443 alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Info,
2444 tr("<p>You have version %1 of the <b><nobr>%2</nobr></b> installed.</p>"
2445 "<p>You should download and install version %3 of this extension pack from Oracle!</p>")
2446 .arg(strExtPackVersion).arg(strExtPackName).arg(strVBoxVersion));
2447}
2448
2449bool UIMessageCenter::cannotFindGuestAdditions() const
2450{
2451 return questionBinary(0, MessageType_Question,
2452 tr("<p>Could not find the <b>VirtualBox Guest Additions</b> disk image file.</p>"
2453 "<p>Do you wish to download this disk image file from the Internet?</p>"),
2454 0 /* auto-confirm id */,
2455 tr("Download"));
2456}
2457
2458bool UIMessageCenter::confirmDownloadGuestAdditions(const QString &strUrl, qulonglong uSize) const
2459{
2460 return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
2461 tr("<p>Are you sure you want to download the <b>VirtualBox Guest Additions</b> disk image file "
2462 "from <nobr><a href=\"%1\">%1</a></nobr> (size %2 bytes)?</p>")
2463 .arg(strUrl, QLocale(UICommon::languageId()).toString(uSize)),
2464 0 /* auto-confirm id */,
2465 tr("Download"));
2466}
2467
2468void UIMessageCenter::cannotSaveGuestAdditions(const QString &strURL, const QString &strTarget) const
2469{
2470 alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Error,
2471 tr("<p>The <b>VirtualBox Guest Additions</b> disk image file has been successfully downloaded "
2472 "from <nobr><a href=\"%1\">%1</a></nobr> "
2473 "but can't be saved locally as <nobr><b>%2</b>.</nobr></p>"
2474 "<p>Please choose another location for that file.</p>")
2475 .arg(strURL, strTarget));
2476}
2477
2478bool UIMessageCenter::proposeMountGuestAdditions(const QString &strUrl, const QString &strSrc) const
2479{
2480 return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
2481 tr("<p>The <b>VirtualBox Guest Additions</b> disk image file has been successfully downloaded "
2482 "from <nobr><a href=\"%1\">%1</a></nobr> "
2483 "and saved locally as <nobr><b>%2</b>.</nobr></p>"
2484 "<p>Do you wish to register this disk image file and insert it into the virtual optical drive?</p>")
2485 .arg(strUrl, strSrc),
2486 0 /* auto-confirm id */,
2487 tr("Insert", "additions"));
2488}
2489
2490void UIMessageCenter::cannotValidateGuestAdditionsSHA256Sum(const QString &strUrl, const QString &strSrc) const
2491{
2492 alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Error,
2493 tr("<p>The <b>VirtualBox Guest Additions</b> disk image file has been successfully downloaded "
2494 "from <nobr><a href=\"%1\">%1</a></nobr> "
2495 "and saved locally as <nobr><b>%2</b>, </nobr>"
2496 "but the SHA-256 checksum verification failed.</p>"
2497 "<p>Please do the download, installation and verification manually.</p>")
2498 .arg(strUrl, strSrc));
2499}
2500
2501void UIMessageCenter::cannotUpdateGuestAdditions(const CProgress &progress) const
2502{
2503 error(0, MessageType_Error,
2504 tr("Failed to update Guest Additions. "
2505 "The Guest Additions disk image file will be inserted for user installation."),
2506 UIErrorString::formatErrorInfo(progress));
2507}
2508
2509bool UIMessageCenter::cannotFindUserManual(const QString &strMissedLocation) const
2510{
2511 return questionBinary(0, MessageType_Question,
2512 tr("<p>Could not find the <b>VirtualBox User Manual</b> <nobr><b>%1</b>.</nobr></p>"
2513 "<p>Do you wish to download this file from the Internet?</p>")
2514 .arg(strMissedLocation),
2515 0 /* auto-confirm id */,
2516 tr("Download"));
2517}
2518
2519bool UIMessageCenter::confirmDownloadUserManual(const QString &strURL, qulonglong uSize) const
2520{
2521 return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
2522 tr("<p>Are you sure you want to download the <b>VirtualBox User Manual</b> "
2523 "from <nobr><a href=\"%1\">%1</a></nobr> (size %2 bytes)?</p>")
2524 .arg(strURL, QLocale(UICommon::languageId()).toString(uSize)),
2525 0 /* auto-confirm id */,
2526 tr("Download"));
2527}
2528
2529void UIMessageCenter::cannotSaveUserManual(const QString &strURL, const QString &strTarget) const
2530{
2531 alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Error,
2532 tr("<p>The VirtualBox User Manual has been successfully downloaded "
2533 "from <nobr><a href=\"%1\">%1</a></nobr> "
2534 "but can't be saved locally as <nobr><b>%2</b>.</nobr></p>"
2535 "<p>Please choose another location for that file.</p>")
2536 .arg(strURL, strTarget));
2537}
2538
2539void UIMessageCenter::warnAboutUserManualDownloaded(const QString &strURL, const QString &strTarget) const
2540{
2541 alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Warning,
2542 tr("<p>The VirtualBox User Manual has been successfully downloaded "
2543 "from <nobr><a href=\"%1\">%1</a></nobr> "
2544 "and saved locally as <nobr><b>%2</b>.</nobr></p>")
2545 .arg(strURL, strTarget));
2546}
2547
2548bool UIMessageCenter::warnAboutOutdatedExtensionPack(const QString &strExtPackName, const QString &strExtPackVersion) const
2549{
2550 return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
2551 tr("<p>You have an old version (%1) of the <b><nobr>%2</nobr></b> installed.</p>"
2552 "<p>Do you wish to download latest one from the Internet?</p>")
2553 .arg(strExtPackVersion).arg(strExtPackName),
2554 0 /* auto-confirm id */,
2555 tr("Download"));
2556}
2557
2558bool UIMessageCenter::confirmDownloadExtensionPack(const QString &strExtPackName, const QString &strURL, qulonglong uSize) const
2559{
2560 return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
2561 tr("<p>Are you sure you want to download the <b><nobr>%1</nobr></b> "
2562 "from <nobr><a href=\"%2\">%2</a></nobr> (size %3 bytes)?</p>")
2563 .arg(strExtPackName, strURL, QLocale(UICommon::languageId()).toString(uSize)),
2564 0 /* auto-confirm id */,
2565 tr("Download"));
2566}
2567
2568void UIMessageCenter::cannotSaveExtensionPack(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const
2569{
2570 alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Error,
2571 tr("<p>The <b><nobr>%1</nobr></b> has been successfully downloaded "
2572 "from <nobr><a href=\"%2\">%2</a></nobr> "
2573 "but can't be saved locally as <nobr><b>%3</b>.</nobr></p>"
2574 "<p>Please choose another location for that file.</p>")
2575 .arg(strExtPackName, strFrom, strTo));
2576}
2577
2578bool UIMessageCenter::proposeInstallExtentionPack(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const
2579{
2580 return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
2581 tr("<p>The <b><nobr>%1</nobr></b> has been successfully downloaded "
2582 "from <nobr><a href=\"%2\">%2</a></nobr> "
2583 "and saved locally as <nobr><b>%3</b>.</nobr></p>"
2584 "<p>Do you wish to install this extension pack?</p>")
2585 .arg(strExtPackName, strFrom, strTo),
2586 0 /* auto-confirm id */,
2587 tr("Install", "extension pack"));
2588}
2589
2590void UIMessageCenter::cannotValidateExtentionPackSHA256Sum(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const
2591{
2592 alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Error,
2593 tr("<p>The <b><nobr>%1</nobr></b> has been successfully downloaded "
2594 "from <nobr><a href=\"%2\">%2</a></nobr> "
2595 "and saved locally as <nobr><b>%3</b>, </nobr>"
2596 "but the SHA-256 checksum verification failed.</p>"
2597 "<p>Please do the download, installation and verification manually.</p>")
2598 .arg(strExtPackName, strFrom, strTo));
2599}
2600
2601bool UIMessageCenter::proposeDeleteExtentionPack(const QString &strTo) const
2602{
2603 return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
2604 tr("Do you want to delete the downloaded file <nobr><b>%1</b></nobr>?")
2605 .arg(strTo),
2606 0 /* auto-confirm id */,
2607 tr("Delete", "extension pack"));
2608}
2609
2610bool UIMessageCenter::proposeDeleteOldExtentionPacks(const QStringList &strFiles) const
2611{
2612 return questionBinary(windowManager().networkManagerOrMainWindowShown(), MessageType_Question,
2613 tr("Do you want to delete following list of files <nobr><b>%1</b></nobr>?")
2614 .arg(strFiles.join(",")),
2615 0 /* auto-confirm id */,
2616 tr("Delete", "extension pack"));
2617}
2618#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
2619
2620bool UIMessageCenter::confirmInstallExtensionPack(const QString &strPackName, const QString &strPackVersion,
2621 const QString &strPackDescription, QWidget *pParent /* = 0*/) const
2622{
2623 return questionBinary(pParent, MessageType_Question,
2624 tr("<p>You are about to install a VirtualBox extension pack. "
2625 "Extension packs complement the functionality of VirtualBox and can contain system level software "
2626 "that could be potentially harmful to your system. Please review the description below and only proceed "
2627 "if you have obtained the extension pack from a trusted source.</p>"
2628 "<p><table cellpadding=0 cellspacing=5>"
2629 "<tr><td><b>Name:&nbsp;&nbsp;</b></td><td>%1</td></tr>"
2630 "<tr><td><b>Version:&nbsp;&nbsp;</b></td><td>%2</td></tr>"
2631 "<tr><td><b>Description:&nbsp;&nbsp;</b></td><td>%3</td></tr>"
2632 "</table></p>")
2633 .arg(strPackName).arg(strPackVersion).arg(strPackDescription),
2634 0 /* auto-confirm id */,
2635 tr("Install", "extension pack"));
2636}
2637
2638bool UIMessageCenter::confirmReplaceExtensionPack(const QString &strPackName, const QString &strPackVersionNew,
2639 const QString &strPackVersionOld, const QString &strPackDescription,
2640 QWidget *pParent /* = 0*/) const
2641{
2642 /* Prepare initial message: */
2643 QString strBelehrung = tr("Extension packs complement the functionality of VirtualBox and can contain "
2644 "system level software that could be potentially harmful to your system. "
2645 "Please review the description below and only proceed if you have obtained "
2646 "the extension pack from a trusted source.");
2647
2648 /* Compare versions: */
2649 QByteArray ba1 = strPackVersionNew.toUtf8();
2650 QByteArray ba2 = strPackVersionOld.toUtf8();
2651 int iVerCmp = RTStrVersionCompare(ba1.constData(), ba2.constData());
2652
2653 /* Show the question: */
2654 bool fRc;
2655 if (iVerCmp > 0)
2656 fRc = questionBinary(pParent, MessageType_Question,
2657 tr("<p>An older version of the extension pack is already installed, would you like to upgrade? "
2658 "<p>%1</p>"
2659 "<p><table cellpadding=0 cellspacing=5>"
2660 "<tr><td><b>Name:&nbsp;&nbsp;</b></td><td>%2</td></tr>"
2661 "<tr><td><b>New Version:&nbsp;&nbsp;</b></td><td>%3</td></tr>"
2662 "<tr><td><b>Current Version:&nbsp;&nbsp;</b></td><td>%4</td></tr>"
2663 "<tr><td><b>Description:&nbsp;&nbsp;</b></td><td>%5</td></tr>"
2664 "</table></p>")
2665 .arg(strBelehrung).arg(strPackName).arg(strPackVersionNew).arg(strPackVersionOld).arg(strPackDescription),
2666 0 /* auto-confirm id */,
2667 tr("&Upgrade"));
2668 else if (iVerCmp < 0)
2669 fRc = questionBinary(pParent, MessageType_Question,
2670 tr("<p>An newer version of the extension pack is already installed, would you like to downgrade? "
2671 "<p>%1</p>"
2672 "<p><table cellpadding=0 cellspacing=5>"
2673 "<tr><td><b>Name:&nbsp;&nbsp;</b></td><td>%2</td></tr>"
2674 "<tr><td><b>New Version:&nbsp;&nbsp;</b></td><td>%3</td></tr>"
2675 "<tr><td><b>Current Version:&nbsp;&nbsp;</b></td><td>%4</td></tr>"
2676 "<tr><td><b>Description:&nbsp;&nbsp;</b></td><td>%5</td></tr>"
2677 "</table></p>")
2678 .arg(strBelehrung).arg(strPackName).arg(strPackVersionNew).arg(strPackVersionOld).arg(strPackDescription),
2679 0 /* auto-confirm id */,
2680 tr("&Downgrade"));
2681 else
2682 fRc = questionBinary(pParent, MessageType_Question,
2683 tr("<p>The extension pack is already installed with the same version, would you like reinstall it? "
2684 "<p>%1</p>"
2685 "<p><table cellpadding=0 cellspacing=5>"
2686 "<tr><td><b>Name:&nbsp;&nbsp;</b></td><td>%2</td></tr>"
2687 "<tr><td><b>Version:&nbsp;&nbsp;</b></td><td>%3</td></tr>"
2688 "<tr><td><b>Description:&nbsp;&nbsp;</b></td><td>%4</td></tr>"
2689 "</table></p>")
2690 .arg(strBelehrung).arg(strPackName).arg(strPackVersionOld).arg(strPackDescription),
2691 0 /* auto-confirm id */,
2692 tr("&Reinstall"));
2693 return fRc;
2694}
2695
2696bool UIMessageCenter::confirmRemoveExtensionPack(const QString &strPackName, QWidget *pParent /* = 0*/) const
2697{
2698 return questionBinary(pParent, MessageType_Question,
2699 tr("<p>You are about to remove the VirtualBox extension pack <b>%1</b>.</p>"
2700 "<p>Are you sure you want to proceed?</p>")
2701 .arg(strPackName),
2702 0 /* auto-confirm id */,
2703 tr("&Remove") /* ok button text */,
2704 QString() /* cancel button text */,
2705 false /* ok button by default? */);
2706}
2707
2708void UIMessageCenter::cannotOpenExtPack(const QString &strFilename, const CExtPackManager &extPackManager, QWidget *pParent /* = 0*/) const
2709{
2710 error(pParent, MessageType_Error,
2711 tr("Failed to open the Extension Pack <b>%1</b>.").arg(strFilename),
2712 UIErrorString::formatErrorInfo(extPackManager));
2713}
2714
2715void UIMessageCenter::warnAboutBadExtPackFile(const QString &strFilename, const CExtPackFile &extPackFile, QWidget *pParent /* = 0*/) const
2716{
2717 error(pParent, MessageType_Error,
2718 tr("Failed to open the Extension Pack <b>%1</b>.").arg(strFilename),
2719 "<!--EOM-->" + extPackFile.GetWhyUnusable());
2720}
2721
2722void UIMessageCenter::cannotInstallExtPack(const CExtPackFile &extPackFile, const QString &strFilename, QWidget *pParent /* = 0*/) const
2723{
2724 error(pParent, MessageType_Error,
2725 tr("Failed to install the Extension Pack <b>%1</b>.")
2726 .arg(strFilename),
2727 UIErrorString::formatErrorInfo(extPackFile));
2728}
2729
2730void UIMessageCenter::cannotInstallExtPack(const CProgress &progress, const QString &strFilename, QWidget *pParent /* = 0*/) const
2731{
2732 error(pParent, MessageType_Error,
2733 tr("Failed to install the Extension Pack <b>%1</b>.")
2734 .arg(strFilename),
2735 UIErrorString::formatErrorInfo(progress));
2736}
2737
2738void UIMessageCenter::cannotUninstallExtPack(const CExtPackManager &extPackManager, const QString &strPackName, QWidget *pParent /* = 0*/) const
2739{
2740 error(pParent, MessageType_Error,
2741 tr("Failed to uninstall the Extension Pack <b>%1</b>.")
2742 .arg(strPackName),
2743 UIErrorString::formatErrorInfo(extPackManager));
2744}
2745
2746void UIMessageCenter::cannotUninstallExtPack(const CProgress &progress, const QString &strPackName, QWidget *pParent /* = 0*/) const
2747{
2748 error(pParent, MessageType_Error,
2749 tr("Failed to uninstall the Extension Pack <b>%1</b>.")
2750 .arg(strPackName),
2751 UIErrorString::formatErrorInfo(progress));
2752}
2753
2754void UIMessageCenter::warnAboutExtPackInstalled(const QString &strPackName, QWidget *pParent /* = 0*/) const
2755{
2756 alert(pParent, MessageType_Info,
2757 tr("The extension pack <br><nobr><b>%1</b><nobr><br> was installed successfully.")
2758 .arg(strPackName));
2759}
2760
2761#ifdef VBOX_WITH_DRAG_AND_DROP
2762void UIMessageCenter::cannotDropDataToGuest(const CDnDTarget &dndTarget, QWidget *pParent /* = 0 */) const
2763{
2764 error(pParent, MessageType_Error,
2765 tr("Drag and drop operation from host to guest failed."),
2766 UIErrorString::formatErrorInfo(dndTarget));
2767}
2768
2769void UIMessageCenter::cannotDropDataToGuest(const CProgress &progress, QWidget *pParent /* = 0 */) const
2770{
2771 error(pParent, MessageType_Error,
2772 tr("Drag and drop operation from host to guest failed."),
2773 UIErrorString::formatErrorInfo(progress));
2774}
2775
2776void UIMessageCenter::cannotCancelDropToGuest(const CDnDTarget &dndTarget, QWidget *pParent /* = 0 */) const
2777{
2778 error(pParent, MessageType_Error,
2779 tr("Unable to cancel host to guest drag and drop operation."),
2780 UIErrorString::formatErrorInfo(dndTarget));
2781}
2782
2783void UIMessageCenter::cannotDropDataToHost(const CDnDSource &dndSource, QWidget *pParent /* = 0 */) const
2784{
2785 error(pParent, MessageType_Error,
2786 tr("Drag and drop operation from guest to host failed."),
2787 UIErrorString::formatErrorInfo(dndSource));
2788}
2789
2790void UIMessageCenter::cannotDropDataToHost(const CProgress &progress, QWidget *pParent /* = 0 */) const
2791{
2792 error(pParent, MessageType_Error,
2793 tr("Drag and drop operation from guest to host failed."),
2794 UIErrorString::formatErrorInfo(progress));
2795}
2796#endif /* VBOX_WITH_DRAG_AND_DROP */
2797
2798void UIMessageCenter::cannotOpenLicenseFile(const QString &strPath, QWidget *pParent /* = 0*/) const
2799{
2800 alert(pParent, MessageType_Error,
2801 tr("Failed to open the license file <nobr><b>%1</b></nobr>. Check file permissions.")
2802 .arg(strPath));
2803}
2804
2805bool UIMessageCenter::confirmOverridingFile(const QString &strPath, QWidget *pParent /* = 0*/) const
2806{
2807 return questionBinary(pParent, MessageType_Question,
2808 tr("A file named <b>%1</b> already exists. "
2809 "Are you sure you want to replace it?<br /><br />"
2810 "Replacing it will overwrite its contents.")
2811 .arg(strPath),
2812 0 /* auto-confirm id */,
2813 QString() /* ok button text */,
2814 QString() /* cancel button text */,
2815 false /* ok button by default? */);
2816}
2817
2818bool UIMessageCenter::confirmOverridingFiles(const QVector<QString> &strPaths, QWidget *pParent /* = 0*/) const
2819{
2820 /* If it is only one file use the single question versions above: */
2821 if (strPaths.size() == 1)
2822 return confirmOverridingFile(strPaths.at(0), pParent);
2823 else if (strPaths.size() > 1)
2824 return questionBinary(pParent, MessageType_Question,
2825 tr("The following files already exist:<br /><br />%1<br /><br />"
2826 "Are you sure you want to replace them? "
2827 "Replacing them will overwrite their contents.")
2828 .arg(QStringList(strPaths.toList()).join("<br />")),
2829 0 /* auto-confirm id */,
2830 QString() /* ok button text */,
2831 QString() /* cancel button text */,
2832 false /* ok button by default? */);
2833 else
2834 return true;
2835}
2836
2837bool UIMessageCenter::confirmOverridingFileIfExists(const QString &strPath, QWidget *pParent /* = 0*/) const
2838{
2839 QFileInfo fi(strPath);
2840 if (fi.exists())
2841 return confirmOverridingFile(strPath, pParent);
2842 else
2843 return true;
2844}
2845
2846bool UIMessageCenter::confirmOverridingFilesIfExists(const QVector<QString> &strPaths, QWidget *pParent /* = 0*/) const
2847{
2848 QVector<QString> existingFiles;
2849 foreach(const QString &file, strPaths)
2850 {
2851 QFileInfo fi(file);
2852 if (fi.exists())
2853 existingFiles << fi.absoluteFilePath();
2854 }
2855 /* If it is only one file use the single question versions above: */
2856 if (existingFiles.size() == 1)
2857 return confirmOverridingFileIfExists(existingFiles.at(0), pParent);
2858 else if (existingFiles.size() > 1)
2859 return confirmOverridingFiles(existingFiles, pParent);
2860 else
2861 return true;
2862}
2863
2864void UIMessageCenter::sltShowHelpWebDialog()
2865{
2866 uiCommon().openURL("https://www.virtualbox.org");
2867}
2868
2869void UIMessageCenter::sltShowBugTracker()
2870{
2871 uiCommon().openURL("https://www.virtualbox.org/wiki/Bugtracker");
2872}
2873
2874void UIMessageCenter::sltShowForums()
2875{
2876 uiCommon().openURL("https://forums.virtualbox.org/");
2877}
2878
2879void UIMessageCenter::sltShowOracle()
2880{
2881 uiCommon().openURL("http://www.oracle.com/us/technologies/virtualization/virtualbox/overview/index.html");
2882}
2883
2884void UIMessageCenter::sltShowHelpAboutDialog()
2885{
2886 CVirtualBox vbox = uiCommon().virtualBox();
2887 QString strFullVersion;
2888 if (uiCommon().brandingIsActive())
2889 {
2890 strFullVersion = QString("%1 r%2 - %3").arg(vbox.GetVersion())
2891 .arg(vbox.GetRevision())
2892 .arg(uiCommon().brandingGetKey("Name"));
2893 }
2894 else
2895 {
2896 strFullVersion = QString("%1 r%2").arg(vbox.GetVersion())
2897 .arg(vbox.GetRevision());
2898 }
2899 AssertWrapperOk(vbox);
2900
2901 (new VBoxAboutDlg(windowManager().mainWindowShown(), strFullVersion))->show();
2902}
2903
2904void UIMessageCenter::sltShowHelpHelpDialog()
2905{
2906#ifndef VBOX_OSE
2907 /* For non-OSE version we just open it: */
2908 sltShowUserManual(uiCommon().helpFile());
2909#else /* #ifndef VBOX_OSE */
2910 /* For OSE version we have to check if it present first: */
2911 QString strUserManualFileName1 = uiCommon().helpFile();
2912 QString strShortFileName = QFileInfo(strUserManualFileName1).fileName();
2913 QString strUserManualFileName2 = QDir(uiCommon().homeFolder()).absoluteFilePath(strShortFileName);
2914 /* Show if user manual already present: */
2915 if (QFile::exists(strUserManualFileName1))
2916 sltShowUserManual(strUserManualFileName1);
2917 else if (QFile::exists(strUserManualFileName2))
2918 sltShowUserManual(strUserManualFileName2);
2919 /* If downloader is running already: */
2920 else if (UIDownloaderUserManual::current())
2921 {
2922 /* Just show network access manager: */
2923 gNetworkManager->show();
2924 }
2925 /* Else propose to download user manual: */
2926 else if (cannotFindUserManual(strUserManualFileName1))
2927 {
2928 /* Create User Manual downloader: */
2929 UIDownloaderUserManual *pDl = UIDownloaderUserManual::create();
2930 /* After downloading finished => show User Manual: */
2931 connect(pDl, &UIDownloaderUserManual::sigDownloadFinished, this, &UIMessageCenter::sltShowUserManual);
2932 /* Start downloading: */
2933 pDl->start();
2934 }
2935#endif /* #ifdef VBOX_OSE */
2936}
2937
2938void UIMessageCenter::sltResetSuppressedMessages()
2939{
2940 /* Nullify suppressed message list: */
2941 gEDataManager->setSuppressedMessages(QStringList());
2942}
2943
2944void UIMessageCenter::sltShowUserManual(const QString &strLocation)
2945{
2946#if defined (VBOX_WS_WIN)
2947 HtmlHelp(GetDesktopWindow(), strLocation.utf16(), HH_DISPLAY_TOPIC, NULL);
2948#elif defined (VBOX_WS_X11)
2949# ifndef VBOX_OSE
2950 char szViewerPath[RTPATH_MAX];
2951 int rc;
2952 rc = RTPathAppPrivateArch(szViewerPath, sizeof(szViewerPath));
2953 AssertRC(rc);
2954 QProcess::startDetached(QString(szViewerPath) + "/kchmviewer", QStringList(strLocation));
2955# else /* #ifndef VBOX_OSE */
2956 uiCommon().openURL("file://" + strLocation);
2957# endif /* #ifdef VBOX_OSE */
2958#elif defined (VBOX_WS_MAC)
2959 uiCommon().openURL("file://" + strLocation);
2960#endif
2961}
2962
2963void UIMessageCenter::sltShowMessageBox(QWidget *pParent, MessageType enmType,
2964 const QString &strMessage, const QString &strDetails,
2965 int iButton1, int iButton2, int iButton3,
2966 const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3,
2967 const QString &strAutoConfirmId) const
2968{
2969 /* Now we can show a message-box directly: */
2970 showMessageBox(pParent, enmType,
2971 strMessage, strDetails,
2972 iButton1, iButton2, iButton3,
2973 strButtonText1, strButtonText2, strButtonText3,
2974 strAutoConfirmId);
2975}
2976
2977UIMessageCenter::UIMessageCenter()
2978{
2979 /* Assign instance: */
2980 s_pInstance = this;
2981}
2982
2983UIMessageCenter::~UIMessageCenter()
2984{
2985 /* Unassign instance: */
2986 s_pInstance = 0;
2987}
2988
2989void UIMessageCenter::prepare()
2990{
2991 /* Register required objects as meta-types: */
2992 qRegisterMetaType<CProgress>();
2993 qRegisterMetaType<CHost>();
2994 qRegisterMetaType<CMachine>();
2995 qRegisterMetaType<CConsole>();
2996 qRegisterMetaType<CHostNetworkInterface>();
2997 qRegisterMetaType<UIMediumDeviceType>();
2998 qRegisterMetaType<StorageSlot>();
2999
3000 /* Prepare interthread connection: */
3001 qRegisterMetaType<MessageType>();
3002 // Won't go until we are supporting C++11 or at least variadic templates everywhere.
3003 // connect(this, &UIMessageCenter::sigToShowMessageBox,
3004 // this, &UIMessageCenter::sltShowMessageBox,
3005 connect(this, SIGNAL(sigToShowMessageBox(QWidget*, MessageType,
3006 const QString&, const QString&,
3007 int, int, int,
3008 const QString&, const QString&, const QString&,
3009 const QString&)),
3010 this, SLOT(sltShowMessageBox(QWidget*, MessageType,
3011 const QString&, const QString&,
3012 int, int, int,
3013 const QString&, const QString&, const QString&,
3014 const QString&)),
3015 Qt::BlockingQueuedConnection);
3016
3017 /* Translations for Main.
3018 * Please make sure they corresponds to the strings coming from Main one-by-one symbol! */
3019 tr("Could not load the Host USB Proxy Service (VERR_FILE_NOT_FOUND). The service might not be installed on the host computer");
3020 tr("VirtualBox is not currently allowed to access USB devices. You can change this by adding your user to the 'vboxusers' group. Please see the user manual for a more detailed explanation");
3021 tr("VirtualBox is not currently allowed to access USB devices. You can change this by allowing your user to access the 'usbfs' folder and files. Please see the user manual for a more detailed explanation");
3022 tr("The USB Proxy Service has not yet been ported to this host");
3023 tr("Could not load the Host USB Proxy service");
3024}
3025
3026void UIMessageCenter::cleanup()
3027{
3028 /* Nothing for now... */
3029}
3030
3031int UIMessageCenter::showMessageBox(QWidget *pParent, MessageType enmType,
3032 const QString &strMessage, const QString &strDetails,
3033 int iButton1, int iButton2, int iButton3,
3034 const QString &strButtonText1, const QString &strButtonText2, const QString &strButtonText3,
3035 const QString &strAutoConfirmId) const
3036{
3037 /* Choose the 'default' button: */
3038 if (iButton1 == 0 && iButton2 == 0 && iButton3 == 0)
3039 iButton1 = AlertButton_Ok | AlertButtonOption_Default;
3040
3041 /* Check if message-box was auto-confirmed before: */
3042 QStringList confirmedMessageList;
3043 if (!strAutoConfirmId.isEmpty())
3044 {
3045 const QUuid uID = uiCommon().uiType() == UICommon::UIType_RuntimeUI
3046 ? uiCommon().managedVMUuid()
3047 : UIExtraDataManager::GlobalID;
3048 confirmedMessageList = gEDataManager->suppressedMessages(uID);
3049 if ( confirmedMessageList.contains(strAutoConfirmId)
3050 || confirmedMessageList.contains("allMessageBoxes")
3051 || confirmedMessageList.contains("all") )
3052 {
3053 int iResultCode = AlertOption_AutoConfirmed;
3054 if (iButton1 & AlertButtonOption_Default)
3055 iResultCode |= (iButton1 & AlertButtonMask);
3056 if (iButton2 & AlertButtonOption_Default)
3057 iResultCode |= (iButton2 & AlertButtonMask);
3058 if (iButton3 & AlertButtonOption_Default)
3059 iResultCode |= (iButton3 & AlertButtonMask);
3060 return iResultCode;
3061 }
3062 }
3063
3064 /* Choose title and icon: */
3065 QString title;
3066 AlertIconType icon;
3067 switch (enmType)
3068 {
3069 default:
3070 case MessageType_Info:
3071 title = tr("VirtualBox - Information", "msg box title");
3072 icon = AlertIconType_Information;
3073 break;
3074 case MessageType_Question:
3075 title = tr("VirtualBox - Question", "msg box title");
3076 icon = AlertIconType_Question;
3077 break;
3078 case MessageType_Warning:
3079 title = tr("VirtualBox - Warning", "msg box title");
3080 icon = AlertIconType_Warning;
3081 break;
3082 case MessageType_Error:
3083 title = tr("VirtualBox - Error", "msg box title");
3084 icon = AlertIconType_Critical;
3085 break;
3086 case MessageType_Critical:
3087 title = tr("VirtualBox - Critical Error", "msg box title");
3088 icon = AlertIconType_Critical;
3089 break;
3090 case MessageType_GuruMeditation:
3091 title = "VirtualBox - Guru Meditation"; /* don't translate this */
3092 icon = AlertIconType_GuruMeditation;
3093 break;
3094 }
3095
3096 /* Create message-box: */
3097 QWidget *pMessageBoxParent = windowManager().realParentWindow(pParent ? pParent : windowManager().mainWindowShown());
3098 QPointer<QIMessageBox> pMessageBox = new QIMessageBox(title, strMessage, icon,
3099 iButton1, iButton2, iButton3,
3100 pMessageBoxParent);
3101 windowManager().registerNewParent(pMessageBox, pMessageBoxParent);
3102
3103 /* Prepare auto-confirmation check-box: */
3104 if (!strAutoConfirmId.isEmpty())
3105 {
3106 pMessageBox->setFlagText(tr("Do not show this message again", "msg box flag"));
3107 pMessageBox->setFlagChecked(false);
3108 }
3109
3110 /* Configure details: */
3111 if (!strDetails.isEmpty())
3112 pMessageBox->setDetailsText(strDetails);
3113
3114 /* Configure button-text: */
3115 if (!strButtonText1.isNull())
3116 pMessageBox->setButtonText(0, strButtonText1);
3117 if (!strButtonText2.isNull())
3118 pMessageBox->setButtonText(1, strButtonText2);
3119 if (!strButtonText3.isNull())
3120 pMessageBox->setButtonText(2, strButtonText3);
3121
3122 /* Show message-box: */
3123 int iResultCode = pMessageBox->exec();
3124
3125 /* Make sure message-box still valid: */
3126 if (!pMessageBox)
3127 return iResultCode;
3128
3129 /* Remember auto-confirmation check-box value: */
3130 if (!strAutoConfirmId.isEmpty())
3131 {
3132 if (pMessageBox->flagChecked())
3133 {
3134 confirmedMessageList << strAutoConfirmId;
3135 gEDataManager->setSuppressedMessages(confirmedMessageList);
3136 }
3137 }
3138
3139 /* Delete message-box: */
3140 delete pMessageBox;
3141
3142 /* Return result-code: */
3143 return iResultCode;
3144}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use