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 |
|
---|
32 | class 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 | */
|
---|
51 | class VBoxProblemReporter : public QObject
|
---|
52 | {
|
---|
53 | Q_OBJECT;
|
---|
54 |
|
---|
55 | public:
|
---|
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 | /* Special problem handlers */
|
---|
156 | void showBETAWarning();
|
---|
157 | void showBEBWarning();
|
---|
158 |
|
---|
159 | #ifdef Q_WS_X11
|
---|
160 | void cannotFindLicenseFiles (const QString &aPath);
|
---|
161 | void cannotOpenLicenseFile (QWidget *aParent, const QString &aPath);
|
---|
162 | #endif
|
---|
163 |
|
---|
164 | void cannotOpenURL (const QString &aURL);
|
---|
165 | void cannotCopyFile (const QString &aSrc, const QString &aDst, int aVRC);
|
---|
166 |
|
---|
167 | void cannotFindLanguage (const QString &aLangID, const QString &aNlsPath);
|
---|
168 | void cannotLoadLanguage (const QString &aLangFile);
|
---|
169 |
|
---|
170 | void cannotInitCOM (HRESULT rc);
|
---|
171 | void cannotCreateVirtualBox (const CVirtualBox &vbox);
|
---|
172 |
|
---|
173 | void cannotSaveGlobalSettings (const CVirtualBox &vbox,
|
---|
174 | QWidget *parent = 0);
|
---|
175 |
|
---|
176 | void cannotLoadGlobalConfig (const CVirtualBox &vbox, const QString &error);
|
---|
177 | void cannotSaveGlobalConfig (const CVirtualBox &vbox);
|
---|
178 | void cannotSetSystemProperties (const CSystemProperties &props);
|
---|
179 | void cannotAccessUSB (const COMBaseWithEI &aObj);
|
---|
180 |
|
---|
181 | void cannotCreateMachine (const CVirtualBox &vbox,
|
---|
182 | QWidget *parent = 0);
|
---|
183 | void cannotCreateMachine (const CVirtualBox &vbox, const CMachine &machine,
|
---|
184 | QWidget *parent = 0);
|
---|
185 | void cannotApplyMachineSettings (const CMachine &machine, const COMResult &res);
|
---|
186 | void cannotSaveMachineSettings (const CMachine &machine,
|
---|
187 | QWidget *parent = 0);
|
---|
188 | void cannotLoadMachineSettings (const CMachine &machine,
|
---|
189 | bool strict = true,
|
---|
190 | QWidget *parent = 0);
|
---|
191 |
|
---|
192 | void cannotStartMachine (const CConsole &console);
|
---|
193 | void cannotStartMachine (const CProgress &progress);
|
---|
194 | void cannotPauseMachine (const CConsole &console);
|
---|
195 | void cannotResumeMachine (const CConsole &console);
|
---|
196 | void cannotACPIShutdownMachine (const CConsole &console);
|
---|
197 | void cannotSaveMachineState (const CConsole &console);
|
---|
198 | void cannotSaveMachineState (const CProgress &progress);
|
---|
199 | void cannotTakeSnapshot (const CConsole &console);
|
---|
200 | void cannotTakeSnapshot (const CProgress &progress);
|
---|
201 | void cannotStopMachine (const CConsole &console);
|
---|
202 | void cannotStopMachine (const CProgress &progress);
|
---|
203 | void cannotDeleteMachine (const CVirtualBox &vbox, const CMachine &machine);
|
---|
204 | void cannotDiscardSavedState (const CConsole &console);
|
---|
205 |
|
---|
206 | void cannotSendACPIToMachine();
|
---|
207 | bool warnAboutVirtNotEnabled64BitsGuest();
|
---|
208 | bool warnAboutVirtNotEnabledGuestRequired();
|
---|
209 |
|
---|
210 | void cannotSetSnapshotFolder (const CMachine &aMachine, const QString &aPath);
|
---|
211 | bool askAboutSnapshotAndStateDiscarding();
|
---|
212 | bool askAboutSnapshotDiscarding();
|
---|
213 | void cannotDiscardSnapshot (const CConsole &aConsole,
|
---|
214 | const QString &aSnapshotName);
|
---|
215 | void cannotDiscardSnapshot (const CProgress &aProgress,
|
---|
216 | const QString &aSnapshotName);
|
---|
217 | void cannotDiscardCurrentState (const CConsole &console);
|
---|
218 | void cannotDiscardCurrentState (const CProgress &progress);
|
---|
219 | void cannotDiscardCurrentSnapshotAndState (const CConsole &console);
|
---|
220 | void cannotDiscardCurrentSnapshotAndState (const CProgress &progress);
|
---|
221 |
|
---|
222 | void cannotFindMachineByName (const CVirtualBox &vbox, const QString &name);
|
---|
223 |
|
---|
224 | void cannotEnterSeamlessMode (ULONG aWidth, ULONG aHeight,
|
---|
225 | ULONG aBpp, ULONG64 aMinVRAM);
|
---|
226 | int cannotEnterFullscreenMode (ULONG aWidth, ULONG aHeight,
|
---|
227 | ULONG aBpp, ULONG64 aMinVRAM);
|
---|
228 |
|
---|
229 | bool confirmMachineDeletion (const CMachine &machine);
|
---|
230 | bool confirmDiscardSavedState (const CMachine &machine);
|
---|
231 |
|
---|
232 | bool confirmReleaseMedium (QWidget *aParent, const VBoxMedium &aMedium,
|
---|
233 | const QString &aUsage);
|
---|
234 |
|
---|
235 | bool confirmRemoveMedium (QWidget *aParent, const VBoxMedium &aMedium);
|
---|
236 |
|
---|
237 | void sayCannotOverwriteHardDiskStorage (QWidget *aParent,
|
---|
238 | const QString &aLocation);
|
---|
239 | int confirmDeleteHardDiskStorage (QWidget *aParent,
|
---|
240 | const QString &aLocation);
|
---|
241 | void cannotDeleteHardDiskStorage (QWidget *aParent, const CMedium &aHD,
|
---|
242 | const CProgress &aProgress);
|
---|
243 |
|
---|
244 | int confirmDetachAddControllerSlots (QWidget *aParent) const;
|
---|
245 | int confirmChangeAddControllerSlots (QWidget *aParent) const;
|
---|
246 | int confirmRunNewHDWzdOrVDM (KDeviceType aDeviceType);
|
---|
247 |
|
---|
248 | void cannotCreateHardDiskStorage (QWidget *aParent, const CVirtualBox &aVBox,
|
---|
249 | const QString &aLocaiton,
|
---|
250 | const CMedium &aHD,
|
---|
251 | const CProgress &aProgress);
|
---|
252 | void cannotAttachHardDisk (QWidget *aParent, const CMachine &aMachine,
|
---|
253 | const QString &aLocation, KStorageBus aBus,
|
---|
254 | LONG aChannel, LONG aDevice);
|
---|
255 | void cannotDetachHardDisk (QWidget *aParent, const CMachine &aMachine,
|
---|
256 | const QString &aLocation, KStorageBus aBus,
|
---|
257 | LONG aChannel, LONG aDevice);
|
---|
258 |
|
---|
259 | void cannotMountMedium (QWidget *aParent, const CMachine &aMachine,
|
---|
260 | const VBoxMedium &aMedium, const COMResult &aResult);
|
---|
261 | void cannotUnmountMedium (QWidget *aParent, const CMachine &aMachine,
|
---|
262 | const VBoxMedium &aMedium, const COMResult &aResult);
|
---|
263 | void cannotOpenMedium (QWidget *aParent, const CVirtualBox &aVBox,
|
---|
264 | VBoxDefs::MediumType aType, const QString &aLocation);
|
---|
265 | void cannotCloseMedium (QWidget *aParent, const VBoxMedium &aMedium,
|
---|
266 | const COMResult &aResult);
|
---|
267 | void cannotEjectDrive();
|
---|
268 |
|
---|
269 | void cannotOpenSession (const CSession &session);
|
---|
270 | void cannotOpenSession (const CVirtualBox &vbox, const CMachine &machine,
|
---|
271 | const CProgress &progress = CProgress());
|
---|
272 |
|
---|
273 | void cannotGetMediaAccessibility (const VBoxMedium &aMedium);
|
---|
274 |
|
---|
275 | int confirmDeletingHostInterface (const QString &aName, QWidget *aParent = 0);
|
---|
276 | void cannotCreateHostInterface (const CHost &aHost, QWidget *aParent = 0);
|
---|
277 | void cannotCreateHostInterface (const CProgress &aProgress, QWidget *aParent = 0);
|
---|
278 | void cannotRemoveHostInterface (const CHost &aHost,
|
---|
279 | const CHostNetworkInterface &aIface,
|
---|
280 | QWidget *aParent = 0);
|
---|
281 | void cannotRemoveHostInterface (const CProgress &aProgress,
|
---|
282 | const CHostNetworkInterface &aIface,
|
---|
283 | QWidget *aParent = 0);
|
---|
284 |
|
---|
285 | void cannotAttachUSBDevice (const CConsole &console, const QString &device);
|
---|
286 | void cannotAttachUSBDevice (const CConsole &console, const QString &device,
|
---|
287 | const CVirtualBoxErrorInfo &error);
|
---|
288 | void cannotDetachUSBDevice (const CConsole &console, const QString &device);
|
---|
289 | void cannotDetachUSBDevice (const CConsole &console, const QString &device,
|
---|
290 | const CVirtualBoxErrorInfo &error);
|
---|
291 |
|
---|
292 | void cannotCreateSharedFolder (QWidget *, const CMachine &,
|
---|
293 | const QString &, const QString &);
|
---|
294 | void cannotRemoveSharedFolder (QWidget *, const CMachine &,
|
---|
295 | const QString &, const QString &);
|
---|
296 | void cannotCreateSharedFolder (QWidget *, const CConsole &,
|
---|
297 | const QString &, const QString &);
|
---|
298 | void cannotRemoveSharedFolder (QWidget *, const CConsole &,
|
---|
299 | const QString &, const QString &);
|
---|
300 |
|
---|
301 | int cannotFindGuestAdditions (const QString &aSrc1, const QString &aSrc2);
|
---|
302 | void cannotDownloadGuestAdditions (const QString &aURL,
|
---|
303 | const QString &aReason);
|
---|
304 | bool confirmDownloadAdditions (const QString &aURL, ulong aSize);
|
---|
305 | bool confirmMountAdditions (const QString &aURL, const QString &aSrc);
|
---|
306 | void warnAboutTooOldAdditions (QWidget *, const QString &, const QString &);
|
---|
307 | void warnAboutOldAdditions (QWidget *, const QString &, const QString &);
|
---|
308 | void warnAboutNewAdditions (QWidget *, const QString &, const QString &);
|
---|
309 |
|
---|
310 | void cannotConnectRegister (QWidget *aParent,
|
---|
311 | const QString &aURL,
|
---|
312 | const QString &aReason);
|
---|
313 | void showRegisterResult (QWidget *aParent,
|
---|
314 | const QString &aResult);
|
---|
315 |
|
---|
316 | void showUpdateSuccess (QWidget *aParent,
|
---|
317 | const QString &aVersion,
|
---|
318 | const QString &aLink);
|
---|
319 | void showUpdateFailure (QWidget *aParent,
|
---|
320 | const QString &aReason);
|
---|
321 | void showUpdateNotFound (QWidget *aParent);
|
---|
322 |
|
---|
323 | bool confirmInputCapture (bool *aAutoConfirmed = NULL);
|
---|
324 | void remindAboutAutoCapture();
|
---|
325 | void remindAboutMouseIntegration (bool aSupportsAbsolute);
|
---|
326 | bool remindAboutPausedVMInput();
|
---|
327 |
|
---|
328 | int warnAboutSettingsAutoConversion (const QString &aFileList, bool aAfterRefresh);
|
---|
329 |
|
---|
330 | bool remindAboutInaccessibleMedia();
|
---|
331 |
|
---|
332 | bool confirmGoingFullscreen (const QString &aHotKey);
|
---|
333 | bool confirmGoingSeamless (const QString &aHotKey);
|
---|
334 |
|
---|
335 | void remindAboutWrongColorDepth (ulong aRealBPP, ulong aWantedBPP);
|
---|
336 |
|
---|
337 | bool remindAboutGuruMeditation (const CConsole &aConsole,
|
---|
338 | const QString &aLogFolder);
|
---|
339 |
|
---|
340 | bool confirmVMReset (QWidget *aParent);
|
---|
341 |
|
---|
342 | bool confirmHardDisklessMachine (QWidget *aParent);
|
---|
343 |
|
---|
344 | void cannotRunInSelectorMode();
|
---|
345 |
|
---|
346 | void cannotImportAppliance (CAppliance *aAppliance, QWidget *aParent = NULL) const;
|
---|
347 | void cannotImportAppliance (const CProgress &aProgress, CAppliance *aAppliance, QWidget *aParent = NULL) const;
|
---|
348 |
|
---|
349 | void cannotCheckFiles (const CProgress &aProgress, QWidget *aParent = NULL) const;
|
---|
350 | void cannotRemoveFiles (const CProgress &aProgress, QWidget *aParent = NULL) const;
|
---|
351 |
|
---|
352 | void cannotExportAppliance (CAppliance *aAppliance, QWidget *aParent = NULL) const;
|
---|
353 | void cannotExportAppliance (const CMachine &aMachine, CAppliance *aAppliance, QWidget *aParent = NULL) const;
|
---|
354 | void cannotExportAppliance (const CProgress &aProgress, CAppliance *aAppliance, QWidget *aParent = NULL) const;
|
---|
355 |
|
---|
356 | void showRuntimeError (const CConsole &console, bool fatal,
|
---|
357 | const QString &errorID,
|
---|
358 | const QString &errorMsg) const;
|
---|
359 |
|
---|
360 | static QString toAccusative (VBoxDefs::MediumType aType);
|
---|
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 | public slots:
|
---|
385 |
|
---|
386 | void showHelpWebDialog();
|
---|
387 | void showHelpAboutDialog();
|
---|
388 | void showHelpHelpDialog();
|
---|
389 | void resetSuppressedMessages();
|
---|
390 |
|
---|
391 | private:
|
---|
392 |
|
---|
393 | friend VBoxProblemReporter &vboxProblem();
|
---|
394 |
|
---|
395 | static QString doFormatErrorInfo (const COMErrorInfo &aInfo,
|
---|
396 | HRESULT aWrapperRC = S_OK);
|
---|
397 | };
|
---|
398 |
|
---|
399 | /**
|
---|
400 | * Shortcut to the static VBoxProblemReporter::instance() method, for
|
---|
401 | * convenience.
|
---|
402 | */
|
---|
403 | inline VBoxProblemReporter &vboxProblem() { return VBoxProblemReporter::instance(); }
|
---|
404 |
|
---|
405 | #endif // __VBoxProblemReporter_h__
|
---|