VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h@ 35740

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

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

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.3 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VBoxProblemReporter class declaration
5 */
6
7/*
8 * Copyright (C) 2006-2010 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef __VBoxProblemReporter_h__
20#define __VBoxProblemReporter_h__
21
22/* Global includes */
23#include <QObject>
24#include <QPointer>
25
26/* Local includes */
27#include "COMDefs.h"
28#include "QIMessageBox.h"
29
30/* Forward declarations */
31class VBoxMedium;
32struct StorageSlot;
33
34/**
35 * The VBoxProblemReporter class is a central place to handle all problem/error
36 * situations that happen during application runtime and require the user's
37 * attention.
38 *
39 * The role of this class is to describe the problem and/or the cause of the
40 * error to the user and give him the opportunity to select an action (when
41 * appropriate).
42 *
43 * Every problem situation has its own (correspondingly named) method in this
44 * class that takes a list of arguments necessary to describe the situation and
45 * to provide the appropriate actions. The method then returns the choice to the
46 * caller.
47 */
48class VBoxProblemReporter : public QObject
49{
50 Q_OBJECT;
51
52public:
53
54 enum Type
55 {
56 Info = 1,
57 Question,
58 Warning,
59 Error,
60 Critical,
61 GuruMeditation
62 };
63
64 enum
65 {
66 AutoConfirmed = 0x8000
67 };
68
69 bool isAnyWarningShown();
70 bool isAlreadyShown(const QString &strGuardBlockName) const;
71 void setShownStatus(const QString &strGuardBlockName);
72 void clearShownStatus(const QString &strGuardBlockName);
73 void closeAllWarnings();
74
75 int message (QWidget *aParent, Type aType, const QString &aMessage,
76 const QString &aDetails = QString::null,
77 const char *aAutoConfirmId = 0,
78 int aButton1 = 0, int aButton2 = 0, int aButton3 = 0,
79 const QString &aText1 = QString::null,
80 const QString &aText2 = QString::null,
81 const QString &aText3 = QString::null) const;
82
83 int message (QWidget *aParent, Type aType, const QString &aMessage,
84 const char *aAutoConfirmId,
85 int aButton1 = 0, int aButton2 = 0, int aButton3 = 0,
86 const QString &aText1 = QString::null,
87 const QString &aText2 = QString::null,
88 const QString &aText3 = QString::null) const
89 {
90 return message (aParent, aType, aMessage, QString::null, aAutoConfirmId,
91 aButton1, aButton2, aButton3, aText1, aText2, aText3);
92 }
93
94 bool messageYesNo (QWidget *aParent, Type aType, const QString &aMessage,
95 const QString &aDetails = QString::null,
96 const char *aAutoConfirmId = 0,
97 const QString &aYesText = QString::null,
98 const QString &aNoText = QString::null) const
99 {
100 return (message (aParent, aType, aMessage, aDetails, aAutoConfirmId,
101 QIMessageBox::Yes | QIMessageBox::Default,
102 QIMessageBox::No | QIMessageBox::Escape,
103 0,
104 aYesText, aNoText, QString::null) &
105 QIMessageBox::ButtonMask) == QIMessageBox::Yes;
106 }
107
108 bool messageYesNo (QWidget *aParent, Type aType, const QString &aMessage,
109 const char *aAutoConfirmId,
110 const QString &aYesText = QString::null,
111 const QString &aNoText = QString::null) const
112 {
113 return messageYesNo (aParent, aType, aMessage, QString::null,
114 aAutoConfirmId, aYesText, aNoText);
115 }
116
117 bool messageOkCancel (QWidget *aParent, Type aType, const QString &aMessage,
118 const QString &aDetails = QString::null,
119 const char *aAutoConfirmId = 0,
120 const QString &aOkText = QString::null,
121 const QString &aCancelText = QString::null) const
122 {
123 return (message (aParent, aType, aMessage, aDetails, aAutoConfirmId,
124 QIMessageBox::Ok | QIMessageBox::Default,
125 QIMessageBox::Cancel | QIMessageBox::Escape,
126 0,
127 aOkText, aCancelText, QString::null) &
128 QIMessageBox::ButtonMask) == QIMessageBox::Ok;
129 }
130
131 bool messageOkCancel (QWidget *aParent, Type aType, const QString &aMessage,
132 const char *aAutoConfirmId,
133 const QString &aOkText = QString::null,
134 const QString &aCancelText = QString::null) const
135 {
136 return messageOkCancel (aParent, aType, aMessage, QString::null,
137 aAutoConfirmId, aOkText, aCancelText);
138 }
139
140 bool showModalProgressDialog(CProgress &progress, const QString &strTitle,
141 const QString &strImage = "", QWidget *pParent = 0,
142 bool fSheetOnDarwin = false, int cMinDuration = 2000);
143
144 QWidget* mainWindowShown() const;
145 QWidget* mainMachineWindowShown() const;
146
147 bool askForOverridingFile (const QString& aPath, QWidget *aParent = NULL) const;
148 bool askForOverridingFiles (const QVector<QString>& aPaths, QWidget *aParent = NULL) const;
149 bool askForOverridingFileIfExists (const QString& path, QWidget *aParent = NULL) const;
150 bool askForOverridingFilesIfExists (const QVector<QString>& aPaths, QWidget *aParent = NULL) const;
151
152 void checkForMountedWrongUSB() const;
153
154 void showBETAWarning();
155 void showBEBWarning();
156
157#ifdef Q_WS_X11
158 void cannotFindLicenseFiles (const QString &aPath);
159#endif
160 void cannotOpenLicenseFile (QWidget *aParent, const QString &aPath);
161
162 void cannotOpenURL (const QString &aURL);
163
164 void cannotFindLanguage (const QString &aLangID, const QString &aNlsPath);
165 void cannotLoadLanguage (const QString &aLangFile);
166
167 void cannotInitCOM (HRESULT rc);
168 void cannotCreateVirtualBox (const CVirtualBox &vbox);
169
170 void cannotLoadGlobalConfig (const CVirtualBox &vbox, const QString &error);
171 void cannotSaveGlobalConfig (const CVirtualBox &vbox);
172 void cannotSetSystemProperties (const CSystemProperties &props);
173
174 void cannotAccessUSB (const COMBaseWithEI &aObj);
175
176 void cannotCreateMachine (const CVirtualBox &vbox,
177 QWidget *parent = 0);
178 void cannotCreateMachine (const CVirtualBox &vbox, const CMachine &machine,
179 QWidget *parent = 0);
180
181 void cannotOpenMachine(QWidget *pParent, const QString &strMachinePath, const CVirtualBox &vbox);
182 void cannotReregisterMachine(QWidget *pParent, const QString &strMachinePath, const QString &strMachineName);
183
184 void cannotApplyMachineSettings (const CMachine &machine, const COMResult &res);
185 void cannotSaveMachineSettings (const CMachine &machine,
186 QWidget *parent = 0);
187 void cannotLoadMachineSettings (const CMachine &machine,
188 bool strict = true,
189 QWidget *parent = 0);
190
191 void cannotStartMachine (const CConsole &console);
192 void cannotStartMachine (const CProgress &progress);
193 void cannotPauseMachine (const CConsole &console);
194 void cannotResumeMachine (const CConsole &console);
195 void cannotACPIShutdownMachine (const CConsole &console);
196 void cannotSaveMachineState (const CConsole &console);
197 void cannotSaveMachineState (const CProgress &progress);
198 void cannotTakeSnapshot (const CConsole &console);
199 void cannotTakeSnapshot (const CProgress &progress);
200 void cannotStopMachine (const CConsole &console);
201 void cannotStopMachine (const CProgress &progress);
202 void cannotDeleteMachine (const CMachine &machine);
203 void cannotDiscardSavedState (const CConsole &console);
204
205 void cannotSendACPIToMachine();
206
207 bool warnAboutVirtNotEnabled64BitsGuest(bool fHWVirtExSupported);
208 bool warnAboutVirtNotEnabledGuestRequired(bool fHWVirtExSupported);
209
210 bool askAboutSnapshotRestoring (const QString &aSnapshotName);
211 bool askAboutSnapshotDeleting (const QString &aSnapshotName);
212 bool askAboutSnapshotDeletingFreeSpace (const QString &aSnapshotName,
213 const QString &aTargetImageName,
214 const QString &aTargetImageMaxSize,
215 const QString &aTargetFilesystemFree);
216 void cannotRestoreSnapshot (const CConsole &aConsole, const QString &aSnapshotName);
217 void cannotRestoreSnapshot (const CProgress &aProgress, const QString &aSnapshotName);
218 void cannotDeleteSnapshot (const CConsole &aConsole, const QString &aSnapshotName);
219 void cannotDeleteSnapshot (const CProgress &aProgress, const QString &aSnapshotName);
220
221 void cannotFindMachineByName (const CVirtualBox &vbox, const QString &name);
222
223 void cannotEnterSeamlessMode (ULONG aWidth, ULONG aHeight,
224 ULONG aBpp, ULONG64 aMinVRAM);
225 int cannotEnterFullscreenMode (ULONG aWidth, ULONG aHeight,
226 ULONG aBpp, ULONG64 aMinVRAM);
227 void cannotSwitchScreenInSeamless(quint64 minVRAM);
228 int cannotSwitchScreenInFullscreen(quint64 minVRAM);
229 int cannotEnterFullscreenMode();
230 int cannotEnterSeamlessMode();
231
232 int confirmMachineDeletion(const CMachine &machine);
233 bool confirmDiscardSavedState (const CMachine &machine);
234
235 bool confirmReleaseMedium (QWidget *aParent, const VBoxMedium &aMedium,
236 const QString &aUsage);
237
238 bool confirmRemoveMedium (QWidget *aParent, const VBoxMedium &aMedium);
239
240 void sayCannotOverwriteHardDiskStorage (QWidget *aParent,
241 const QString &aLocation);
242 int confirmDeleteHardDiskStorage (QWidget *aParent,
243 const QString &aLocation);
244 void cannotDeleteHardDiskStorage (QWidget *aParent, const CMedium &aHD,
245 const CProgress &aProgress);
246
247 int askAboutHardDiskAttachmentCreation(QWidget *pParent, const QString &strControllerName);
248 int askAboutOpticalAttachmentCreation(QWidget *pParent, const QString &strControllerName);
249 int askAboutFloppyAttachmentCreation(QWidget *pParent, const QString &strControllerName);
250
251 int confirmRemovingOfLastDVDDevice() const;
252
253 void cannotCreateHardDiskStorage (QWidget *aParent, const CVirtualBox &aVBox,
254 const QString &aLocaiton,
255 const CMedium &aHD,
256 const CProgress &aProgress);
257 void cannotDetachDevice(QWidget *pParent, const CMachine &machine,
258 VBoxDefs::MediumType type, const QString &strLocation, const StorageSlot &storageSlot);
259
260 int cannotRemountMedium (QWidget *aParent, const CMachine &aMachine, const VBoxMedium &aMedium, bool aMount, bool aRetry);
261 void cannotOpenMedium (QWidget *aParent, const CVirtualBox &aVBox,
262 VBoxDefs::MediumType aType, const QString &aLocation);
263 void cannotCloseMedium (QWidget *aParent, const VBoxMedium &aMedium,
264 const COMResult &aResult);
265
266 void cannotOpenSession (const CSession &session);
267 void cannotOpenSession (const CVirtualBox &vbox, const CMachine &machine,
268 const CProgress &progress = CProgress());
269
270 void cannotGetMediaAccessibility (const VBoxMedium &aMedium);
271
272 int confirmDeletingHostInterface (const QString &aName, QWidget *aParent = 0);
273
274 void cannotAttachUSBDevice (const CConsole &console, const QString &device);
275 void cannotAttachUSBDevice (const CConsole &console, const QString &device,
276 const CVirtualBoxErrorInfo &error);
277 void cannotDetachUSBDevice (const CConsole &console, const QString &device);
278 void cannotDetachUSBDevice (const CConsole &console, const QString &device,
279 const CVirtualBoxErrorInfo &error);
280
281 void remindAboutGuestAdditionsAreNotActive(QWidget *pParent);
282 int cannotFindGuestAdditions (const QString &aSrc1, const QString &aSrc2);
283 void cannotDownloadGuestAdditions (const QString &aURL, const QString &aReason);
284 void cannotMountGuestAdditions (const QString &aMachineName);
285 bool confirmDownloadAdditions (const QString &aURL, ulong aSize);
286 bool confirmMountAdditions (const QString &aURL, const QString &aSrc);
287
288 bool askAboutUserManualDownload(const QString &strMissedLocation);
289 bool confirmUserManualDownload(const QString &strURL, ulong uSize);
290 void warnAboutUserManualCantBeDownloaded(const QString &strURL, const QString &strReason);
291 void warnAboutUserManualDownloaded(const QString &strURL, const QString &strTarget);
292 void warnAboutUserManualCantBeSaved(const QString &strURL, const QString &strTarget);
293
294 void cannotConnectRegister (QWidget *aParent,
295 const QString &aURL,
296 const QString &aReason);
297 void showRegisterResult (QWidget *aParent,
298 const QString &aResult);
299
300 void showUpdateSuccess (QWidget *aParent,
301 const QString &aVersion,
302 const QString &aLink);
303 void showUpdateFailure (QWidget *aParent,
304 const QString &aReason);
305 void showUpdateNotFound (QWidget *aParent);
306
307 bool confirmInputCapture (bool *aAutoConfirmed = NULL);
308 void remindAboutAutoCapture();
309 void remindAboutMouseIntegration (bool aSupportsAbsolute);
310 bool remindAboutPausedVMInput();
311
312 int warnAboutSettingsAutoConversion (const QString &aFileList, bool aAfterRefresh);
313
314 bool remindAboutInaccessibleMedia();
315
316 bool confirmGoingFullscreen (const QString &aHotKey);
317 bool confirmGoingSeamless (const QString &aHotKey);
318 bool confirmGoingScale (const QString &aHotKey);
319
320 bool remindAboutGuruMeditation (const CConsole &aConsole,
321 const QString &aLogFolder);
322
323 bool confirmVMReset (QWidget *aParent);
324
325 void warnAboutCannotCreateMachineFolder(QWidget *pParent, const QString &strFolderName);
326 bool confirmHardDisklessMachine (QWidget *aParent);
327
328 void cannotRunInSelectorMode();
329
330 void cannotImportAppliance (CAppliance *aAppliance, QWidget *aParent = NULL) const;
331 void cannotImportAppliance (const CProgress &aProgress, CAppliance *aAppliance, QWidget *aParent = NULL) const;
332
333 void cannotCheckFiles (const CProgress &aProgress, QWidget *aParent = NULL) const;
334 void cannotRemoveFiles (const CProgress &aProgress, QWidget *aParent = NULL) const;
335
336 bool confirmExportMachinesInSaveState(const QStringList &machineNames, QWidget *aParent = NULL) const;
337 void cannotExportAppliance (CAppliance *aAppliance, QWidget *aParent = NULL) const;
338 void cannotExportAppliance (const CMachine &aMachine, CAppliance *aAppliance, QWidget *aParent = NULL) const;
339 void cannotExportAppliance (const CProgress &aProgress, CAppliance *aAppliance, QWidget *aParent = NULL) const;
340
341 void cannotUpdateGuestAdditions (const CProgress &aProgress, QWidget *aParent /* = NULL */) const;
342
343 void cannotOpenExtPack(const QString &strFilename, const CExtPackManager &extPackManager, QWidget *pParent);
344 void badExtPackFile(const QString &strFilename, const CExtPackFile &extPackFile, QWidget *pParent);
345 void cannotInstallExtPack(const QString &strFilename, const CExtPackFile &extPackFile, const CProgress &progress, QWidget *pParent);
346 void cannotUninstallExtPack(const QString &strPackName, const CExtPackManager &extPackManager, const CProgress &progress, QWidget *pParent);
347 bool confirmInstallingPackage(const QString &strPackName, const QString &strPackVersion, const QString &strPackDescription, QWidget *pParent);
348 bool confirmReplacePackage(const QString &strPackName, const QString &strPackVersionNew, const QString &strPackVersionOld,
349 const QString &strPackDescription, QWidget *pParent);
350 bool confirmRemovingPackage(const QString &strPackName, QWidget *pParent);
351 void notifyAboutExtPackInstalled(const QString &strPackName, QWidget *pParent);
352
353 void warnAboutIncorrectPort(QWidget *pParent) const;
354 bool confirmCancelingPortForwardingDialog(QWidget *pParent) const;
355
356 void showRuntimeError (const CConsole &console, bool fatal,
357 const QString &errorID,
358 const QString &errorMsg) const;
359
360 static QString mediumToAccusative (VBoxDefs::MediumType aType, bool aIsHostDrive = false);
361
362 static QString formatRC (HRESULT aRC);
363
364 static QString formatErrorInfo (const COMErrorInfo &aInfo,
365 HRESULT aWrapperRC = S_OK);
366
367 static QString formatErrorInfo (const CVirtualBoxErrorInfo &aInfo)
368 {
369 return formatErrorInfo (COMErrorInfo (aInfo));
370 }
371
372 static QString formatErrorInfo (const COMBaseWithEI &aWrapper)
373 {
374 Assert (aWrapper.lastRC() != S_OK);
375 return formatErrorInfo (aWrapper.errorInfo(), aWrapper.lastRC());
376 }
377
378 static QString formatErrorInfo (const COMResult &aRC)
379 {
380 Assert (aRC.rc() != S_OK);
381 return formatErrorInfo (aRC.errorInfo(), aRC.rc());
382 }
383
384 /* Stuff supporting interthreading: */
385 void cannotCreateHostInterface(const CHost &host, QWidget *pParent = 0);
386 void cannotCreateHostInterface(const CProgress &progress, QWidget *pParent = 0);
387 void cannotRemoveHostInterface(const CHost &host, const CHostNetworkInterface &iface, QWidget *pParent = 0);
388 void cannotRemoveHostInterface(const CProgress &progress, const CHostNetworkInterface &iface, QWidget *pParent = 0);
389 void cannotAttachDevice(const CMachine &machine, VBoxDefs::MediumType type,
390 const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent = 0);
391 void cannotCreateSharedFolder(const CMachine &machine, const QString &strName,
392 const QString &strPath, QWidget *pParent = 0);
393 void cannotRemoveSharedFolder(const CMachine &machine, const QString &strName,
394 const QString &strPath, QWidget *pParent = 0);
395 void cannotCreateSharedFolder(const CConsole &console, const QString &strName,
396 const QString &strPath, QWidget *pParent = 0);
397 void cannotRemoveSharedFolder(const CConsole &console, const QString &strName,
398 const QString &strPath, QWidget *pParent = 0);
399 void remindAboutWrongColorDepth(ulong uRealBPP, ulong uWantedBPP);
400
401signals:
402
403 void sigDownloaderUserManualCreated();
404 void sigToCloseAllWarnings();
405
406 /* Stuff supporting interthreading: */
407 void sigCannotCreateHostInterface(const CHost &host, QWidget *pParent);
408 void sigCannotCreateHostInterface(const CProgress &progress, QWidget *pParent);
409 void sigCannotRemoveHostInterface(const CHost &host, const CHostNetworkInterface &iface, QWidget *pParent);
410 void sigCannotRemoveHostInterface(const CProgress &progress, const CHostNetworkInterface &iface, QWidget *pParent);
411 void sigCannotAttachDevice(const CMachine &machine, VBoxDefs::MediumType type,
412 const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent);
413 void sigCannotCreateSharedFolder(const CMachine &machine, const QString &strName,
414 const QString &strPath, QWidget *pParent);
415 void sigCannotRemoveSharedFolder(const CMachine &machine, const QString &strName,
416 const QString &strPath, QWidget *pParent);
417 void sigCannotCreateSharedFolder(const CConsole &console, const QString &strName,
418 const QString &strPath, QWidget *pParent);
419 void sigCannotRemoveSharedFolder(const CConsole &console, const QString &strName,
420 const QString &strPath, QWidget *pParent);
421 void sigRemindAboutWrongColorDepth(ulong uRealBPP, ulong uWantedBPP);
422
423public slots:
424
425 void showHelpWebDialog();
426 void showHelpAboutDialog();
427 void showHelpHelpDialog();
428 void resetSuppressedMessages();
429 void sltShowUserManual(const QString &strLocation);
430
431private slots:
432
433 /* Stuff supporting interthreading: */
434 void sltCannotCreateHostInterface(const CHost &host, QWidget *pParent);
435 void sltCannotCreateHostInterface(const CProgress &progress, QWidget *pParent);
436 void sltCannotRemoveHostInterface(const CHost &host, const CHostNetworkInterface &iface, QWidget *pParent);
437 void sltCannotRemoveHostInterface(const CProgress &progress, const CHostNetworkInterface &iface, QWidget *pParent);
438 void sltCannotAttachDevice(const CMachine &machine, VBoxDefs::MediumType type,
439 const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent);
440 void sltCannotCreateSharedFolder(const CMachine &machine, const QString &strName,
441 const QString &strPath, QWidget *pParent);
442 void sltCannotRemoveSharedFolder(const CMachine &machine, const QString &strName,
443 const QString &strPath, QWidget *pParent);
444 void sltCannotCreateSharedFolder(const CConsole &console, const QString &strName,
445 const QString &strPath, QWidget *pParent);
446 void sltCannotRemoveSharedFolder(const CConsole &console, const QString &strName,
447 const QString &strPath, QWidget *pParent);
448 void sltRemindAboutWrongColorDepth(ulong uRealBPP, ulong uWantedBPP);
449
450private:
451
452 VBoxProblemReporter();
453
454 static VBoxProblemReporter &instance();
455
456 friend VBoxProblemReporter &vboxProblem();
457
458 static QString doFormatErrorInfo (const COMErrorInfo &aInfo,
459 HRESULT aWrapperRC = S_OK);
460
461 QStringList m_shownWarnings;
462 mutable QList<QPointer<QIMessageBox> > m_warnings;
463};
464
465/* Shortcut to the static VBoxProblemReporter::instance() method, for convenience. */
466inline VBoxProblemReporter &vboxProblem() { return VBoxProblemReporter::instance(); }
467
468#endif // __VBoxProblemReporter_h__
469
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use