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 | class QAction;
|
---|
34 | class QMenu;
|
---|
35 |
|
---|
36 | // VBoxHelpActions class
|
---|
37 | ////////////////////////////////////////////////////////////////////////////////
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Help Menu action container.
|
---|
41 | *
|
---|
42 | * Contains actions for all help menu items and methods to insert them to a
|
---|
43 | * QMenu and to perform NLS string translation.
|
---|
44 | *
|
---|
45 | * Instances of this class are to be created as members of QWidget classes that
|
---|
46 | * need a Help menu. The containing class usually passes itself as an argument
|
---|
47 | * to the #setup() method and then calls #addTo() to add actions to its Help
|
---|
48 | * menu. The #retranslateUi() method is called when it is necessary to
|
---|
49 | * re-translate all action NLS according to the current language.
|
---|
50 | */
|
---|
51 | struct VBoxHelpActions
|
---|
52 | {
|
---|
53 | VBoxHelpActions()
|
---|
54 | : contentsAction (NULL), webAction (NULL)
|
---|
55 | , resetMessagesAction (NULL), registerAction (NULL)
|
---|
56 | , updateAction (NULL), aboutAction (NULL)
|
---|
57 | {}
|
---|
58 |
|
---|
59 | void setup (QObject *aParent);
|
---|
60 | void addTo (QMenu *aMenu);
|
---|
61 | void retranslateUi();
|
---|
62 |
|
---|
63 | QAction *contentsAction;
|
---|
64 | QAction *webAction;
|
---|
65 | QAction *resetMessagesAction;
|
---|
66 | QAction *registerAction;
|
---|
67 | QAction *updateAction;
|
---|
68 | QAction *aboutAction;
|
---|
69 | };
|
---|
70 |
|
---|
71 | // VBoxProblemReporter class
|
---|
72 | ////////////////////////////////////////////////////////////////////////////////
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * The VBoxProblemReporter class is a central place to handle all problem/error
|
---|
76 | * situations that happen during application runtime and require the user's
|
---|
77 | * attention.
|
---|
78 | *
|
---|
79 | * The role of this class is to describe the problem and/or the cause of the
|
---|
80 | * error to the user and give him the opportunity to select an action (when
|
---|
81 | * appropriate).
|
---|
82 | *
|
---|
83 | * Every problem sutiation has its own (correspondingly named) method in this
|
---|
84 | * class that takes a list of arguments necessary to describe the situation and
|
---|
85 | * to provide the appropriate actions. The method then returns the choice to the
|
---|
86 | * caller.
|
---|
87 | */
|
---|
88 | class VBoxProblemReporter : public QObject
|
---|
89 | {
|
---|
90 | Q_OBJECT;
|
---|
91 |
|
---|
92 | public:
|
---|
93 |
|
---|
94 | enum Type
|
---|
95 | {
|
---|
96 | Info = 1,
|
---|
97 | Question,
|
---|
98 | Warning,
|
---|
99 | Error,
|
---|
100 | Critical,
|
---|
101 | GuruMeditation
|
---|
102 | };
|
---|
103 |
|
---|
104 | enum
|
---|
105 | {
|
---|
106 | AutoConfirmed = 0x8000
|
---|
107 | };
|
---|
108 |
|
---|
109 | static VBoxProblemReporter &instance();
|
---|
110 |
|
---|
111 | bool isValid() const;
|
---|
112 |
|
---|
113 | // helpers
|
---|
114 |
|
---|
115 | int message (QWidget *aParent, Type aType, const QString &aMessage,
|
---|
116 | const QString &aDetails = QString::null,
|
---|
117 | const char *aAutoConfirmId = 0,
|
---|
118 | int aButton1 = 0, int aButton2 = 0, int aButton3 = 0,
|
---|
119 | const QString &aText1 = QString::null,
|
---|
120 | const QString &aText2 = QString::null,
|
---|
121 | const QString &aText3 = QString::null) const;
|
---|
122 |
|
---|
123 | int message (QWidget *aParent, Type aType, const QString &aMessage,
|
---|
124 | const char *aAutoConfirmId,
|
---|
125 | int aButton1 = 0, int aButton2 = 0, int aButton3 = 0,
|
---|
126 | const QString &aText1 = QString::null,
|
---|
127 | const QString &aText2 = QString::null,
|
---|
128 | const QString &aText3 = QString::null) const
|
---|
129 | {
|
---|
130 | return message (aParent, aType, aMessage, QString::null, aAutoConfirmId,
|
---|
131 | aButton1, aButton2, aButton3, aText1, aText2, aText3);
|
---|
132 | }
|
---|
133 |
|
---|
134 | bool messageYesNo (QWidget *aParent, Type aType, const QString &aMessage,
|
---|
135 | const QString &aDetails = QString::null,
|
---|
136 | const char *aAutoConfirmId = 0,
|
---|
137 | const QString &aYesText = QString::null,
|
---|
138 | const QString &aNoText = QString::null) const
|
---|
139 | {
|
---|
140 | return (message (aParent, aType, aMessage, aDetails, aAutoConfirmId,
|
---|
141 | QIMessageBox::Yes | QIMessageBox::Default,
|
---|
142 | QIMessageBox::No | QIMessageBox::Escape,
|
---|
143 | 0,
|
---|
144 | aYesText, aNoText, QString::null) &
|
---|
145 | QIMessageBox::ButtonMask) == QIMessageBox::Yes;
|
---|
146 | }
|
---|
147 |
|
---|
148 | bool messageYesNo (QWidget *aParent, Type aType, const QString &aMessage,
|
---|
149 | const char *aAutoConfirmId,
|
---|
150 | const QString &aYesText = QString::null,
|
---|
151 | const QString &aNoText = QString::null) const
|
---|
152 | {
|
---|
153 | return messageYesNo (aParent, aType, aMessage, QString::null,
|
---|
154 | aAutoConfirmId, aYesText, aNoText);
|
---|
155 | }
|
---|
156 |
|
---|
157 | bool messageOkCancel (QWidget *aParent, Type aType, const QString &aMessage,
|
---|
158 | const QString &aDetails = QString::null,
|
---|
159 | const char *aAutoConfirmId = 0,
|
---|
160 | const QString &aOkText = QString::null,
|
---|
161 | const QString &aCancelText = QString::null) const
|
---|
162 | {
|
---|
163 | return (message (aParent, aType, aMessage, aDetails, aAutoConfirmId,
|
---|
164 | QIMessageBox::Ok | QIMessageBox::Default,
|
---|
165 | QIMessageBox::Cancel | QIMessageBox::Escape,
|
---|
166 | 0,
|
---|
167 | aOkText, aCancelText, QString::null) &
|
---|
168 | QIMessageBox::ButtonMask) == QIMessageBox::Ok;
|
---|
169 | }
|
---|
170 |
|
---|
171 | bool messageOkCancel (QWidget *aParent, Type aType, const QString &aMessage,
|
---|
172 | const char *aAutoConfirmId,
|
---|
173 | const QString &aOkText = QString::null,
|
---|
174 | const QString &aCancelText = QString::null) const
|
---|
175 | {
|
---|
176 | return messageOkCancel (aParent, aType, aMessage, QString::null,
|
---|
177 | aAutoConfirmId, aOkText, aCancelText);
|
---|
178 | }
|
---|
179 |
|
---|
180 | bool showModalProgressDialog (CProgress &aProgress, const QString &aTitle,
|
---|
181 | QWidget *aParent, int aMinDuration = 2000);
|
---|
182 |
|
---|
183 | QWidget *mainWindowShown() const;
|
---|
184 |
|
---|
185 | /* Generic problem handlers */
|
---|
186 | bool askForOverridingFileIfExists (const QString& path, QWidget *aParent = NULL) const;
|
---|
187 |
|
---|
188 | /* Special problem handlers */
|
---|
189 | #ifdef Q_WS_X11
|
---|
190 | void cannotFindLicenseFiles (const QString &aPath);
|
---|
191 | void cannotOpenLicenseFile (QWidget *aParent, const QString &aPath);
|
---|
192 | #endif
|
---|
193 |
|
---|
194 | void cannotOpenURL (const QString &aURL);
|
---|
195 | void cannotCopyFile (const QString &aSrc, const QString &aDst, int aVRC);
|
---|
196 |
|
---|
197 | void cannotFindLanguage (const QString &aLangID, const QString &aNlsPath);
|
---|
198 | void cannotLoadLanguage (const QString &aLangFile);
|
---|
199 |
|
---|
200 | void cannotInitCOM (HRESULT rc);
|
---|
201 | void cannotCreateVirtualBox (const CVirtualBox &vbox);
|
---|
202 |
|
---|
203 | void cannotSaveGlobalSettings (const CVirtualBox &vbox,
|
---|
204 | QWidget *parent = 0);
|
---|
205 |
|
---|
206 | void cannotLoadGlobalConfig (const CVirtualBox &vbox, const QString &error);
|
---|
207 | void cannotSaveGlobalConfig (const CVirtualBox &vbox);
|
---|
208 | void cannotSetSystemProperties (const CSystemProperties &props);
|
---|
209 | void cannotAccessUSB (const COMBaseWithEI &aObj);
|
---|
210 |
|
---|
211 | void cannotCreateMachine (const CVirtualBox &vbox,
|
---|
212 | QWidget *parent = 0);
|
---|
213 | void cannotCreateMachine (const CVirtualBox &vbox, const CMachine &machine,
|
---|
214 | QWidget *parent = 0);
|
---|
215 | void cannotApplyMachineSettings (const CMachine &machine, const COMResult &res);
|
---|
216 | void cannotSaveMachineSettings (const CMachine &machine,
|
---|
217 | QWidget *parent = 0);
|
---|
218 | void cannotLoadMachineSettings (const CMachine &machine,
|
---|
219 | bool strict = true,
|
---|
220 | QWidget *parent = 0);
|
---|
221 |
|
---|
222 | void cannotStartMachine (const CConsole &console);
|
---|
223 | void cannotStartMachine (const CProgress &progress);
|
---|
224 | void cannotPauseMachine (const CConsole &console);
|
---|
225 | void cannotResumeMachine (const CConsole &console);
|
---|
226 | void cannotACPIShutdownMachine (const CConsole &console);
|
---|
227 | void cannotSaveMachineState (const CConsole &console);
|
---|
228 | void cannotSaveMachineState (const CProgress &progress);
|
---|
229 | void cannotTakeSnapshot (const CConsole &console);
|
---|
230 | void cannotTakeSnapshot (const CProgress &progress);
|
---|
231 | void cannotStopMachine (const CConsole &console);
|
---|
232 | void cannotStopMachine (const CProgress &progress);
|
---|
233 | void cannotDeleteMachine (const CVirtualBox &vbox, const CMachine &machine);
|
---|
234 | void cannotDiscardSavedState (const CConsole &console);
|
---|
235 |
|
---|
236 | void cannotSendACPIToMachine();
|
---|
237 | bool warnAboutVirtNotEnabled();
|
---|
238 |
|
---|
239 | void cannotSetSnapshotFolder (const CMachine &aMachine, const QString &aPath);
|
---|
240 | void cannotDiscardSnapshot (const CConsole &aConsole,
|
---|
241 | const QString &aSnapshotName);
|
---|
242 | void cannotDiscardSnapshot (const CProgress &aProgress,
|
---|
243 | const QString &aSnapshotName);
|
---|
244 | void cannotDiscardCurrentState (const CConsole &console);
|
---|
245 | void cannotDiscardCurrentState (const CProgress &progress);
|
---|
246 | void cannotDiscardCurrentSnapshotAndState (const CConsole &console);
|
---|
247 | void cannotDiscardCurrentSnapshotAndState (const CProgress &progress);
|
---|
248 |
|
---|
249 | void cannotFindMachineByName (const CVirtualBox &vbox, const QString &name);
|
---|
250 |
|
---|
251 | void cannotEnterSeamlessMode (ULONG aWidth, ULONG aHeight,
|
---|
252 | ULONG aBpp, ULONG64 aMinVRAM);
|
---|
253 | int cannotEnterFullscreenMode (ULONG aWidth, ULONG aHeight,
|
---|
254 | ULONG aBpp, ULONG64 aMinVRAM);
|
---|
255 |
|
---|
256 | bool confirmMachineDeletion (const CMachine &machine);
|
---|
257 | bool confirmDiscardSavedState (const CMachine &machine);
|
---|
258 |
|
---|
259 | bool confirmReleaseMedium (QWidget *aParent, const VBoxMedium &aMedium,
|
---|
260 | const QString &aUsage);
|
---|
261 |
|
---|
262 | bool confirmRemoveMedium (QWidget *aParent, const VBoxMedium &aMedium);
|
---|
263 |
|
---|
264 | void sayCannotOverwriteHardDiskStorage (QWidget *aParent,
|
---|
265 | const QString &aLocation);
|
---|
266 | int confirmDeleteHardDiskStorage (QWidget *aParent,
|
---|
267 | const QString &aLocation);
|
---|
268 | void cannotDeleteHardDiskStorage (QWidget *aParent, const CHardDisk &aHD,
|
---|
269 | const CProgress &aProgress);
|
---|
270 |
|
---|
271 | int confirmDetachSATASlots (QWidget *aParent);
|
---|
272 | int confirmRunNewHDWzdOrVDM (QWidget* aParent);
|
---|
273 |
|
---|
274 | void cannotCreateHardDiskStorage (QWidget *aParent, const CVirtualBox &aVBox,
|
---|
275 | const QString &aLocaiton,
|
---|
276 | const CHardDisk &aHD,
|
---|
277 | const CProgress &aProgress);
|
---|
278 | void cannotAttachHardDisk (QWidget *aParent, const CMachine &aMachine,
|
---|
279 | const QString &aLocation, KStorageBus aBus,
|
---|
280 | LONG aChannel, LONG aDevice);
|
---|
281 | void cannotDetachHardDisk (QWidget *aParent, const CMachine &aMachine,
|
---|
282 | const QString &aLocation, KStorageBus aBus,
|
---|
283 | LONG aChannel, LONG aDevice);
|
---|
284 |
|
---|
285 | void cannotMountMedium (QWidget *aParent, const CMachine &aMachine,
|
---|
286 | const VBoxMedium &aMedium, const COMResult &aResult);
|
---|
287 | void cannotUnmountMedium (QWidget *aParent, const CMachine &aMachine,
|
---|
288 | const VBoxMedium &aMedium, const COMResult &aResult);
|
---|
289 | void cannotOpenMedium (QWidget *aParent, const CVirtualBox &aVBox,
|
---|
290 | VBoxDefs::MediaType aType, const QString &aLocation);
|
---|
291 | void cannotCloseMedium (QWidget *aParent, const VBoxMedium &aMedium,
|
---|
292 | const COMResult &aResult);
|
---|
293 |
|
---|
294 | void cannotOpenSession (const CSession &session);
|
---|
295 | void cannotOpenSession (const CVirtualBox &vbox, const CMachine &machine,
|
---|
296 | const CProgress &progress = CProgress());
|
---|
297 |
|
---|
298 | void cannotGetMediaAccessibility (const VBoxMedium &aMedium);
|
---|
299 |
|
---|
300 | #if defined Q_WS_WIN
|
---|
301 | int confirmDeletingHostInterface (const QString &aName, QWidget *aParent = 0);
|
---|
302 | void cannotCreateHostInterface (const CHost &aHost,
|
---|
303 | QWidget *aParent = 0);
|
---|
304 | void cannotCreateHostInterface (const CProgress &aProgress, const QString &aName,
|
---|
305 | QWidget *aParent = 0);
|
---|
306 | void cannotRemoveHostInterface (const CHost &aHost,
|
---|
307 | const CHostNetworkInterface &aIface,
|
---|
308 | QWidget *aParent = 0);
|
---|
309 | void cannotRemoveHostInterface (const CProgress &aProgress,
|
---|
310 | const CHostNetworkInterface &aIface,
|
---|
311 | QWidget *aParent = 0);
|
---|
312 | #endif
|
---|
313 |
|
---|
314 | void cannotAttachUSBDevice (const CConsole &console, const QString &device);
|
---|
315 | void cannotAttachUSBDevice (const CConsole &console, const QString &device,
|
---|
316 | const CVirtualBoxErrorInfo &error);
|
---|
317 | void cannotDetachUSBDevice (const CConsole &console, const QString &device);
|
---|
318 | void cannotDetachUSBDevice (const CConsole &console, const QString &device,
|
---|
319 | const CVirtualBoxErrorInfo &error);
|
---|
320 |
|
---|
321 | void cannotCreateSharedFolder (QWidget *, const CMachine &,
|
---|
322 | const QString &, const QString &);
|
---|
323 | void cannotRemoveSharedFolder (QWidget *, const CMachine &,
|
---|
324 | const QString &, const QString &);
|
---|
325 | void cannotCreateSharedFolder (QWidget *, const CConsole &,
|
---|
326 | const QString &, const QString &);
|
---|
327 | void cannotRemoveSharedFolder (QWidget *, const CConsole &,
|
---|
328 | const QString &, const QString &);
|
---|
329 |
|
---|
330 | int cannotFindGuestAdditions (const QString &aSrc1, const QString &aSrc2);
|
---|
331 | void cannotDownloadGuestAdditions (const QString &aURL,
|
---|
332 | const QString &aReason);
|
---|
333 | bool confirmDownloadAdditions (const QString &aURL, ulong aSize);
|
---|
334 | bool confirmMountAdditions (const QString &aURL, const QString &aSrc);
|
---|
335 | void warnAboutTooOldAdditions (QWidget *, const QString &, const QString &);
|
---|
336 | void warnAboutOldAdditions (QWidget *, const QString &, const QString &);
|
---|
337 | void warnAboutNewAdditions (QWidget *, const QString &, const QString &);
|
---|
338 |
|
---|
339 | void cannotConnectRegister (QWidget *aParent,
|
---|
340 | const QString &aURL,
|
---|
341 | const QString &aReason);
|
---|
342 | void showRegisterResult (QWidget *aParent,
|
---|
343 | const QString &aResult);
|
---|
344 |
|
---|
345 | void showUpdateSuccess (QWidget *aParent,
|
---|
346 | const QString &aVersion,
|
---|
347 | const QString &aLink);
|
---|
348 | void showUpdateFailure (QWidget *aParent,
|
---|
349 | const QString &aReason);
|
---|
350 | void showUpdateNotFound (QWidget *aParent);
|
---|
351 |
|
---|
352 | bool confirmInputCapture (bool *aAutoConfirmed = NULL);
|
---|
353 | void remindAboutAutoCapture();
|
---|
354 | void remindAboutMouseIntegration (bool aSupportsAbsolute);
|
---|
355 | bool remindAboutPausedVMInput();
|
---|
356 |
|
---|
357 | int warnAboutAutoConvertedSettings (const QString &aFormatVersion,
|
---|
358 | const QString &aFileList,
|
---|
359 | bool aAfterRefresh);
|
---|
360 |
|
---|
361 | bool remindAboutInaccessibleMedia();
|
---|
362 |
|
---|
363 | bool confirmGoingFullscreen (const QString &aHotKey);
|
---|
364 | bool confirmGoingSeamless (const QString &aHotKey);
|
---|
365 |
|
---|
366 | void remindAboutWrongColorDepth (ulong aRealBPP, ulong aWantedBPP);
|
---|
367 |
|
---|
368 | bool remindAboutGuruMeditation (const CConsole &aConsole,
|
---|
369 | const QString &aLogFolder);
|
---|
370 |
|
---|
371 | bool confirmVMReset (QWidget *aParent);
|
---|
372 |
|
---|
373 | bool confirmHardDisklessMachine (QWidget *aParent);
|
---|
374 |
|
---|
375 | void cannotRunInSelectorMode();
|
---|
376 |
|
---|
377 | void cannotImportAppliance (CAppliance *aAppliance, QWidget *aParent = NULL) const;
|
---|
378 | void cannotImportAppliance (const CProgress &aProgress, CAppliance *aAppliance, QWidget *aParent = NULL) const;
|
---|
379 |
|
---|
380 | void cannotExportAppliance (CAppliance *aAppliance, QWidget *aParent = NULL) const;
|
---|
381 | void cannotExportAppliance (const CProgress &aProgress, CAppliance *aAppliance, QWidget *aParent = NULL) const;
|
---|
382 |
|
---|
383 | void showRuntimeError (const CConsole &console, bool fatal,
|
---|
384 | const QString &errorID,
|
---|
385 | const QString &errorMsg) const;
|
---|
386 |
|
---|
387 | static QString toAccusative (VBoxDefs::MediaType aType);
|
---|
388 |
|
---|
389 | static QString formatRC (HRESULT aRC);
|
---|
390 |
|
---|
391 | static QString formatErrorInfo (const COMErrorInfo &aInfo,
|
---|
392 | HRESULT aWrapperRC = S_OK);
|
---|
393 |
|
---|
394 | static QString formatErrorInfo (const CVirtualBoxErrorInfo &aInfo)
|
---|
395 | {
|
---|
396 | return formatErrorInfo (COMErrorInfo (aInfo));
|
---|
397 | }
|
---|
398 |
|
---|
399 | static QString formatErrorInfo (const COMBaseWithEI &aWrapper)
|
---|
400 | {
|
---|
401 | Assert (aWrapper.lastRC() != S_OK);
|
---|
402 | return formatErrorInfo (aWrapper.errorInfo(), aWrapper.lastRC());
|
---|
403 | }
|
---|
404 |
|
---|
405 | static QString formatErrorInfo (const COMResult &aRC)
|
---|
406 | {
|
---|
407 | Assert (aRC.rc() != S_OK);
|
---|
408 | return formatErrorInfo (aRC.errorInfo(), aRC.rc());
|
---|
409 | }
|
---|
410 |
|
---|
411 | public slots:
|
---|
412 |
|
---|
413 | void showHelpWebDialog();
|
---|
414 | void showHelpAboutDialog();
|
---|
415 | void showHelpHelpDialog();
|
---|
416 | void resetSuppressedMessages();
|
---|
417 |
|
---|
418 | private:
|
---|
419 |
|
---|
420 | friend VBoxProblemReporter &vboxProblem();
|
---|
421 |
|
---|
422 | static QString doFormatErrorInfo (const COMErrorInfo &aInfo,
|
---|
423 | HRESULT aWrapperRC = S_OK);
|
---|
424 | };
|
---|
425 |
|
---|
426 | /**
|
---|
427 | * Shortcut to the static VBoxProblemReporter::instance() method, for
|
---|
428 | * convenience.
|
---|
429 | */
|
---|
430 | inline VBoxProblemReporter &vboxProblem() { return VBoxProblemReporter::instance(); }
|
---|
431 |
|
---|
432 | #endif // __VBoxProblemReporter_h__
|
---|