VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h@ 25045

Last change on this file since 25045 was 24557, checked in by vboxsync, 15 years ago

FE/Qt4: Force-remounting support.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.3 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VBoxProblemReporter class declaration
5 */
6
7/*
8 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23#ifndef __VBoxProblemReporter_h__
24#define __VBoxProblemReporter_h__
25
26#include "COMDefs.h"
27#include "QIMessageBox.h"
28
29/* Qt icludes */
30#include <QObject>
31
32class VBoxMedium;
33
34// VBoxProblemReporter class
35////////////////////////////////////////////////////////////////////////////////
36
37/**
38 * The VBoxProblemReporter class is a central place to handle all problem/error
39 * situations that happen during application runtime and require the user's
40 * attention.
41 *
42 * The role of this class is to describe the problem and/or the cause of the
43 * error to the user and give him the opportunity to select an action (when
44 * appropriate).
45 *
46 * Every problem sutiation has its own (correspondingly named) method in this
47 * class that takes a list of arguments necessary to describe the situation and
48 * to provide the appropriate actions. The method then returns the choice to the
49 * caller.
50 */
51class VBoxProblemReporter : public QObject
52{
53 Q_OBJECT;
54
55public:
56
57 enum Type
58 {
59 Info = 1,
60 Question,
61 Warning,
62 Error,
63 Critical,
64 GuruMeditation
65 };
66
67 enum
68 {
69 AutoConfirmed = 0x8000
70 };
71
72 static VBoxProblemReporter &instance();
73
74 bool isValid() const;
75
76 // helpers
77
78 int message (QWidget *aParent, Type aType, const QString &aMessage,
79 const QString &aDetails = QString::null,
80 const char *aAutoConfirmId = 0,
81 int aButton1 = 0, int aButton2 = 0, int aButton3 = 0,
82 const QString &aText1 = QString::null,
83 const QString &aText2 = QString::null,
84 const QString &aText3 = QString::null) const;
85
86 int message (QWidget *aParent, Type aType, const QString &aMessage,
87 const char *aAutoConfirmId,
88 int aButton1 = 0, int aButton2 = 0, int aButton3 = 0,
89 const QString &aText1 = QString::null,
90 const QString &aText2 = QString::null,
91 const QString &aText3 = QString::null) const
92 {
93 return message (aParent, aType, aMessage, QString::null, aAutoConfirmId,
94 aButton1, aButton2, aButton3, aText1, aText2, aText3);
95 }
96
97 bool messageYesNo (QWidget *aParent, Type aType, const QString &aMessage,
98 const QString &aDetails = QString::null,
99 const char *aAutoConfirmId = 0,
100 const QString &aYesText = QString::null,
101 const QString &aNoText = QString::null) const
102 {
103 return (message (aParent, aType, aMessage, aDetails, aAutoConfirmId,
104 QIMessageBox::Yes | QIMessageBox::Default,
105 QIMessageBox::No | QIMessageBox::Escape,
106 0,
107 aYesText, aNoText, QString::null) &
108 QIMessageBox::ButtonMask) == QIMessageBox::Yes;
109 }
110
111 bool messageYesNo (QWidget *aParent, Type aType, const QString &aMessage,
112 const char *aAutoConfirmId,
113 const QString &aYesText = QString::null,
114 const QString &aNoText = QString::null) const
115 {
116 return messageYesNo (aParent, aType, aMessage, QString::null,
117 aAutoConfirmId, aYesText, aNoText);
118 }
119
120 bool messageOkCancel (QWidget *aParent, Type aType, const QString &aMessage,
121 const QString &aDetails = QString::null,
122 const char *aAutoConfirmId = 0,
123 const QString &aOkText = QString::null,
124 const QString &aCancelText = QString::null) const
125 {
126 return (message (aParent, aType, aMessage, aDetails, aAutoConfirmId,
127 QIMessageBox::Ok | QIMessageBox::Default,
128 QIMessageBox::Cancel | QIMessageBox::Escape,
129 0,
130 aOkText, aCancelText, QString::null) &
131 QIMessageBox::ButtonMask) == QIMessageBox::Ok;
132 }
133
134 bool messageOkCancel (QWidget *aParent, Type aType, const QString &aMessage,
135 const char *aAutoConfirmId,
136 const QString &aOkText = QString::null,
137 const QString &aCancelText = QString::null) const
138 {
139 return messageOkCancel (aParent, aType, aMessage, QString::null,
140 aAutoConfirmId, aOkText, aCancelText); }
141
142 bool showModalProgressDialog (CProgress &aProgress, const QString &aTitle,
143 QWidget *aParent, int aMinDuration = 2000);
144
145 QWidget *mainWindowShown() const;
146
147 /* Generic problem handlers */
148 bool askForOverridingFile (const QString& aPath, QWidget *aParent = NULL) const;
149 bool askForOverridingFiles (const QVector<QString>& aPaths, QWidget *aParent = NULL) const;
150 bool askForOverridingFileIfExists (const QString& path, QWidget *aParent = NULL) const;
151 bool askForOverridingFilesIfExists (const QVector<QString>& aPaths, QWidget *aParent = NULL) const;
152
153 void cannotDeleteFile (const QString& path, QWidget *aParent = NULL) const;
154
155 void checkForMountedWrongUSB() const;
156
157 /* Special problem handlers */
158 void showBETAWarning();
159 void showBEBWarning();
160
161#ifdef Q_WS_X11
162 void cannotFindLicenseFiles (const QString &aPath);
163 void cannotOpenLicenseFile (QWidget *aParent, const QString &aPath);
164#endif
165
166 void cannotOpenURL (const QString &aURL);
167 void cannotCopyFile (const QString &aSrc, const QString &aDst, int aVRC);
168
169 void cannotFindLanguage (const QString &aLangID, const QString &aNlsPath);
170 void cannotLoadLanguage (const QString &aLangFile);
171
172 void cannotInitCOM (HRESULT rc);
173 void cannotCreateVirtualBox (const CVirtualBox &vbox);
174
175 void cannotSaveGlobalSettings (const CVirtualBox &vbox,
176 QWidget *parent = 0);
177
178 void cannotLoadGlobalConfig (const CVirtualBox &vbox, const QString &error);
179 void cannotSaveGlobalConfig (const CVirtualBox &vbox);
180 void cannotSetSystemProperties (const CSystemProperties &props);
181 void cannotAccessUSB (const COMBaseWithEI &aObj);
182
183 void cannotCreateMachine (const CVirtualBox &vbox,
184 QWidget *parent = 0);
185 void cannotCreateMachine (const CVirtualBox &vbox, const CMachine &machine,
186 QWidget *parent = 0);
187 void cannotApplyMachineSettings (const CMachine &machine, const COMResult &res);
188 void cannotSaveMachineSettings (const CMachine &machine,
189 QWidget *parent = 0);
190 void cannotLoadMachineSettings (const CMachine &machine,
191 bool strict = true,
192 QWidget *parent = 0);
193
194 void cannotStartMachine (const CConsole &console);
195 void cannotStartMachine (const CProgress &progress);
196 void cannotPauseMachine (const CConsole &console);
197 void cannotResumeMachine (const CConsole &console);
198 void cannotACPIShutdownMachine (const CConsole &console);
199 void cannotSaveMachineState (const CConsole &console);
200 void cannotSaveMachineState (const CProgress &progress);
201 void cannotTakeSnapshot (const CConsole &console);
202 void cannotTakeSnapshot (const CProgress &progress);
203 void cannotStopMachine (const CConsole &console);
204 void cannotStopMachine (const CProgress &progress);
205 void cannotDeleteMachine (const CVirtualBox &vbox, const CMachine &machine);
206 void cannotDiscardSavedState (const CConsole &console);
207
208 void cannotSendACPIToMachine();
209 bool warnAboutVirtNotEnabled64BitsGuest();
210 bool warnAboutVirtNotEnabledGuestRequired();
211
212 void cannotSetSnapshotFolder (const CMachine &aMachine, const QString &aPath);
213
214 bool askAboutSnapshotRestoring (const QString &aSnapshotName);
215 bool askAboutSnapshotDeleting (const QString &aSnapshotName);
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
228 bool confirmMachineDeletion (const CMachine &machine);
229 bool confirmDiscardSavedState (const CMachine &machine);
230
231 bool confirmReleaseMedium (QWidget *aParent, const VBoxMedium &aMedium,
232 const QString &aUsage);
233
234 bool confirmRemoveMedium (QWidget *aParent, const VBoxMedium &aMedium);
235
236 void sayCannotOverwriteHardDiskStorage (QWidget *aParent,
237 const QString &aLocation);
238 int confirmDeleteHardDiskStorage (QWidget *aParent,
239 const QString &aLocation);
240 void cannotDeleteHardDiskStorage (QWidget *aParent, const CMedium &aHD,
241 const CProgress &aProgress);
242
243 int confirmDetachAddControllerSlots (QWidget *aParent) const;
244 int confirmChangeAddControllerSlots (QWidget *aParent) const;
245 int confirmRunNewHDWzdOrVDM (KDeviceType aDeviceType);
246
247 void cannotCreateHardDiskStorage (QWidget *aParent, const CVirtualBox &aVBox,
248 const QString &aLocaiton,
249 const CMedium &aHD,
250 const CProgress &aProgress);
251 void cannotAttachDevice (QWidget *aParent, const CMachine &aMachine,
252 VBoxDefs::MediumType aType, const QString &aLocation,
253 KStorageBus aBus, LONG aChannel, LONG aDevice);
254 void cannotDetachDevice (QWidget *aParent, const CMachine &aMachine,
255 VBoxDefs::MediumType aType, const QString &aLocation,
256 KStorageBus aBus, LONG aChannel, LONG aDevice);
257
258 int cannotRemountMedium (QWidget *aParent, const CMachine &aMachine, const VBoxMedium &aMedium, bool aMount, bool aRetry);
259 void cannotOpenMedium (QWidget *aParent, const CVirtualBox &aVBox,
260 VBoxDefs::MediumType aType, const QString &aLocation);
261 void cannotCloseMedium (QWidget *aParent, const VBoxMedium &aMedium,
262 const COMResult &aResult);
263 void cannotEjectDrive();
264
265 void cannotOpenSession (const CSession &session);
266 void cannotOpenSession (const CVirtualBox &vbox, const CMachine &machine,
267 const CProgress &progress = CProgress());
268
269 void cannotGetMediaAccessibility (const VBoxMedium &aMedium);
270
271 int confirmDeletingHostInterface (const QString &aName, QWidget *aParent = 0);
272 void cannotCreateHostInterface (const CHost &aHost, QWidget *aParent = 0);
273 void cannotCreateHostInterface (const CProgress &aProgress, QWidget *aParent = 0);
274 void cannotRemoveHostInterface (const CHost &aHost,
275 const CHostNetworkInterface &aIface,
276 QWidget *aParent = 0);
277 void cannotRemoveHostInterface (const CProgress &aProgress,
278 const CHostNetworkInterface &aIface,
279 QWidget *aParent = 0);
280
281 void cannotAttachUSBDevice (const CConsole &console, const QString &device);
282 void cannotAttachUSBDevice (const CConsole &console, const QString &device,
283 const CVirtualBoxErrorInfo &error);
284 void cannotDetachUSBDevice (const CConsole &console, const QString &device);
285 void cannotDetachUSBDevice (const CConsole &console, const QString &device,
286 const CVirtualBoxErrorInfo &error);
287
288 void cannotCreateSharedFolder (QWidget *, const CMachine &,
289 const QString &, const QString &);
290 void cannotRemoveSharedFolder (QWidget *, const CMachine &,
291 const QString &, const QString &);
292 void cannotCreateSharedFolder (QWidget *, const CConsole &,
293 const QString &, const QString &);
294 void cannotRemoveSharedFolder (QWidget *, const CConsole &,
295 const QString &, const QString &);
296
297 int cannotFindGuestAdditions (const QString &aSrc1, const QString &aSrc2);
298 void cannotDownloadGuestAdditions (const QString &aURL, const QString &aReason);
299 void cannotMountGuestAdditions (const QString &aMachineName);
300 bool confirmDownloadAdditions (const QString &aURL, ulong aSize);
301 bool confirmMountAdditions (const QString &aURL, const QString &aSrc);
302 void warnAboutTooOldAdditions (QWidget *, const QString &, const QString &);
303 void warnAboutOldAdditions (QWidget *, const QString &, const QString &);
304 void warnAboutNewAdditions (QWidget *, const QString &, const QString &);
305
306 void cannotConnectRegister (QWidget *aParent,
307 const QString &aURL,
308 const QString &aReason);
309 void showRegisterResult (QWidget *aParent,
310 const QString &aResult);
311
312 void showUpdateSuccess (QWidget *aParent,
313 const QString &aVersion,
314 const QString &aLink);
315 void showUpdateFailure (QWidget *aParent,
316 const QString &aReason);
317 void showUpdateNotFound (QWidget *aParent);
318
319 bool confirmInputCapture (bool *aAutoConfirmed = NULL);
320 void remindAboutAutoCapture();
321 void remindAboutMouseIntegration (bool aSupportsAbsolute);
322 bool remindAboutPausedVMInput();
323
324 int warnAboutSettingsAutoConversion (const QString &aFileList, bool aAfterRefresh);
325
326 bool remindAboutInaccessibleMedia();
327
328 bool confirmGoingFullscreen (const QString &aHotKey);
329 bool confirmGoingSeamless (const QString &aHotKey);
330
331 void remindAboutWrongColorDepth (ulong aRealBPP, ulong aWantedBPP);
332
333 bool remindAboutGuruMeditation (const CConsole &aConsole,
334 const QString &aLogFolder);
335
336 bool confirmVMReset (QWidget *aParent);
337
338 bool confirmHardDisklessMachine (QWidget *aParent);
339
340 void cannotRunInSelectorMode();
341
342 void cannotImportAppliance (CAppliance *aAppliance, QWidget *aParent = NULL) const;
343 void cannotImportAppliance (const CProgress &aProgress, CAppliance *aAppliance, QWidget *aParent = NULL) const;
344
345 void cannotCheckFiles (const CProgress &aProgress, QWidget *aParent = NULL) const;
346 void cannotRemoveFiles (const CProgress &aProgress, QWidget *aParent = NULL) const;
347
348 void cannotExportAppliance (CAppliance *aAppliance, QWidget *aParent = NULL) const;
349 void cannotExportAppliance (const CMachine &aMachine, CAppliance *aAppliance, QWidget *aParent = NULL) const;
350 void cannotExportAppliance (const CProgress &aProgress, CAppliance *aAppliance, QWidget *aParent = NULL) const;
351
352 void showRuntimeError (const CConsole &console, bool fatal,
353 const QString &errorID,
354 const QString &errorMsg) const;
355
356 static QString mediumToAccusative (VBoxDefs::MediumType aType, bool aIsHostDrive = false);
357 static QString deviceToAccusative (VBoxDefs::MediumType aType);
358
359 static QString formatRC (HRESULT aRC);
360
361 static QString formatErrorInfo (const COMErrorInfo &aInfo,
362 HRESULT aWrapperRC = S_OK);
363
364 static QString formatErrorInfo (const CVirtualBoxErrorInfo &aInfo)
365 {
366 return formatErrorInfo (COMErrorInfo (aInfo));
367 }
368
369 static QString formatErrorInfo (const COMBaseWithEI &aWrapper)
370 {
371 Assert (aWrapper.lastRC() != S_OK);
372 return formatErrorInfo (aWrapper.errorInfo(), aWrapper.lastRC());
373 }
374
375 static QString formatErrorInfo (const COMResult &aRC)
376 {
377 Assert (aRC.rc() != S_OK);
378 return formatErrorInfo (aRC.errorInfo(), aRC.rc());
379 }
380
381public slots:
382
383 void showHelpWebDialog();
384 void showHelpAboutDialog();
385 void showHelpHelpDialog();
386 void resetSuppressedMessages();
387
388private:
389
390 friend VBoxProblemReporter &vboxProblem();
391
392 static QString doFormatErrorInfo (const COMErrorInfo &aInfo,
393 HRESULT aWrapperRC = S_OK);
394};
395
396/**
397 * Shortcut to the static VBoxProblemReporter::instance() method, for
398 * convenience.
399 */
400inline VBoxProblemReporter &vboxProblem() { return VBoxProblemReporter::instance(); }
401
402#endif // __VBoxProblemReporter_h__
Note: See TracBrowser for help on using the repository browser.

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