VirtualBox

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

Last change on this file since 16694 was 16617, checked in by vboxsync, 16 years ago

FE/Qt4-OVF: Initial support for OVF import in the GUI.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.2 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;
33class QAction;
34class 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 */
51struct 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 */
88class VBoxProblemReporter : public QObject
89{
90 Q_OBJECT
91
92public:
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();
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);
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)
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)
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)
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)
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)
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();
184
185 // problem handlers
186
187#ifdef Q_WS_X11
188 void cannotFindLicenseFiles (const QString &aPath);
189 void cannotOpenLicenseFile (QWidget *aParent, const QString &aPath);
190#endif
191
192 void cannotOpenURL (const QString &aURL);
193 void cannotCopyFile (const QString &aSrc, const QString &aDst, int aVRC);
194
195 void cannotFindLanguage (const QString &aLangID, const QString &aNlsPath);
196 void cannotLoadLanguage (const QString &aLangFile);
197
198 void cannotInitCOM (HRESULT rc);
199 void cannotCreateVirtualBox (const CVirtualBox &vbox);
200
201 void cannotSaveGlobalSettings (const CVirtualBox &vbox,
202 QWidget *parent = 0);
203
204 void cannotLoadGlobalConfig (const CVirtualBox &vbox, const QString &error);
205 void cannotSaveGlobalConfig (const CVirtualBox &vbox);
206 void cannotSetSystemProperties (const CSystemProperties &props);
207 void cannotAccessUSB (const COMBaseWithEI &aObj);
208
209 void cannotCreateMachine (const CVirtualBox &vbox,
210 QWidget *parent = 0);
211 void cannotCreateMachine (const CVirtualBox &vbox, const CMachine &machine,
212 QWidget *parent = 0);
213 void cannotApplyMachineSettings (const CMachine &machine, const COMResult &res);
214 void cannotSaveMachineSettings (const CMachine &machine,
215 QWidget *parent = 0);
216 void cannotLoadMachineSettings (const CMachine &machine,
217 bool strict = true,
218 QWidget *parent = 0);
219
220 void cannotStartMachine (const CConsole &console);
221 void cannotStartMachine (const CProgress &progress);
222 void cannotPauseMachine (const CConsole &console);
223 void cannotResumeMachine (const CConsole &console);
224 void cannotACPIShutdownMachine (const CConsole &console);
225 void cannotSaveMachineState (const CConsole &console);
226 void cannotSaveMachineState (const CProgress &progress);
227 void cannotTakeSnapshot (const CConsole &console);
228 void cannotTakeSnapshot (const CProgress &progress);
229 void cannotStopMachine (const CConsole &console);
230 void cannotStopMachine (const CProgress &progress);
231 void cannotDeleteMachine (const CVirtualBox &vbox, const CMachine &machine);
232 void cannotDiscardSavedState (const CConsole &console);
233
234 void cannotSendACPIToMachine();
235 bool warnAboutVirtNotEnabled();
236
237 void cannotSetSnapshotFolder (const CMachine &aMachine, const QString &aPath);
238 void cannotDiscardSnapshot (const CConsole &aConsole,
239 const QString &aSnapshotName);
240 void cannotDiscardSnapshot (const CProgress &aProgress,
241 const QString &aSnapshotName);
242 void cannotDiscardCurrentState (const CConsole &console);
243 void cannotDiscardCurrentState (const CProgress &progress);
244 void cannotDiscardCurrentSnapshotAndState (const CConsole &console);
245 void cannotDiscardCurrentSnapshotAndState (const CProgress &progress);
246
247 void cannotFindMachineByName (const CVirtualBox &vbox, const QString &name);
248
249 void cannotEnterSeamlessMode (ULONG aWidth, ULONG aHeight,
250 ULONG aBpp, ULONG64 aMinVRAM);
251 int cannotEnterFullscreenMode (ULONG aWidth, ULONG aHeight,
252 ULONG aBpp, ULONG64 aMinVRAM);
253
254 bool confirmMachineDeletion (const CMachine &machine);
255 bool confirmDiscardSavedState (const CMachine &machine);
256
257 bool confirmReleaseMedium (QWidget *aParent, const VBoxMedium &aMedium,
258 const QString &aUsage);
259
260 bool confirmRemoveMedium (QWidget *aParent, const VBoxMedium &aMedium);
261
262 void sayCannotOverwriteHardDiskStorage (QWidget *aParent,
263 const QString &aLocation);
264 int confirmDeleteHardDiskStorage (QWidget *aParent,
265 const QString &aLocation);
266 void cannotDeleteHardDiskStorage (QWidget *aParent, const CHardDisk2 &aHD,
267 const CProgress &aProgress);
268
269 int confirmDetachSATASlots (QWidget *aParent);
270 int confirmRunNewHDWzdOrVDM (QWidget* aParent);
271
272 void cannotCreateHardDiskStorage (QWidget *aParent, const CVirtualBox &aVBox,
273 const QString &aLocaiton,
274 const CHardDisk2 &aHD,
275 const CProgress &aProgress);
276 void cannotAttachHardDisk (QWidget *aParent, const CMachine &aMachine,
277 const QString &aLocation, KStorageBus aBus,
278 LONG aChannel, LONG aDevice);
279 void cannotDetachHardDisk (QWidget *aParent, const CMachine &aMachine,
280 const QString &aLocation, KStorageBus aBus,
281 LONG aChannel, LONG aDevice);
282
283 void cannotMountMedium (QWidget *aParent, const CMachine &aMachine,
284 const VBoxMedium &aMedium, const COMResult &aResult);
285 void cannotUnmountMedium (QWidget *aParent, const CMachine &aMachine,
286 const VBoxMedium &aMedium, const COMResult &aResult);
287 void cannotOpenMedium (QWidget *aParent, const CVirtualBox &aVBox,
288 VBoxDefs::MediaType aType, const QString &aLocation);
289 void cannotCloseMedium (QWidget *aParent, const VBoxMedium &aMedium,
290 const COMResult &aResult);
291
292 void cannotOpenSession (const CSession &session);
293 void cannotOpenSession (const CVirtualBox &vbox, const CMachine &machine,
294 const CProgress &progress = CProgress());
295
296 void cannotGetMediaAccessibility (const VBoxMedium &aMedium);
297
298#if defined Q_WS_WIN
299 void cannotCreateHostInterface (const CHost &host, const QString &name,
300 QWidget *parent = 0);
301 void cannotCreateHostInterface (const CProgress &progress, const QString &name,
302 QWidget *parent = 0);
303 void cannotRemoveHostInterface (const CHost &host,
304 const CHostNetworkInterface &iface,
305 QWidget *parent = 0);
306 void cannotRemoveHostInterface (const CProgress &progress,
307 const CHostNetworkInterface &iface,
308 QWidget *parent = 0);
309#endif
310
311 void cannotAttachUSBDevice (const CConsole &console, const QString &device);
312 void cannotAttachUSBDevice (const CConsole &console, const QString &device,
313 const CVirtualBoxErrorInfo &error);
314 void cannotDetachUSBDevice (const CConsole &console, const QString &device);
315 void cannotDetachUSBDevice (const CConsole &console, const QString &device,
316 const CVirtualBoxErrorInfo &error);
317
318 void cannotCreateSharedFolder (QWidget *, const CMachine &,
319 const QString &, const QString &);
320 void cannotRemoveSharedFolder (QWidget *, const CMachine &,
321 const QString &, const QString &);
322 void cannotCreateSharedFolder (QWidget *, const CConsole &,
323 const QString &, const QString &);
324 void cannotRemoveSharedFolder (QWidget *, const CConsole &,
325 const QString &, const QString &);
326
327 int cannotFindGuestAdditions (const QString &aSrc1, const QString &aSrc2);
328 void cannotDownloadGuestAdditions (const QString &aURL,
329 const QString &aReason);
330 bool confirmDownloadAdditions (const QString &aURL, ulong aSize);
331 bool confirmMountAdditions (const QString &aURL, const QString &aSrc);
332 void warnAboutTooOldAdditions (QWidget *, const QString &, const QString &);
333 void warnAboutOldAdditions (QWidget *, const QString &, const QString &);
334 void warnAboutNewAdditions (QWidget *, const QString &, const QString &);
335
336 void cannotConnectRegister (QWidget *aParent,
337 const QString &aURL,
338 const QString &aReason);
339 void showRegisterResult (QWidget *aParent,
340 const QString &aResult);
341
342 void showUpdateSuccess (QWidget *aParent,
343 const QString &aVersion,
344 const QString &aLink);
345 void showUpdateFailure (QWidget *aParent,
346 const QString &aReason);
347 void showUpdateNotFound (QWidget *aParent);
348
349 bool confirmInputCapture (bool *aAutoConfirmed = NULL);
350 void remindAboutAutoCapture();
351 void remindAboutMouseIntegration (bool aSupportsAbsolute);
352 bool remindAboutPausedVMInput();
353
354 int warnAboutAutoConvertedSettings (const QString &aFormatVersion,
355 const QString &aFileList,
356 bool aAfterRefresh);
357
358 bool remindAboutInaccessibleMedia();
359
360 bool confirmGoingFullscreen (const QString &aHotKey);
361 bool confirmGoingSeamless (const QString &aHotKey);
362
363 void remindAboutWrongColorDepth (ulong aRealBPP, ulong aWantedBPP);
364
365 bool remindAboutGuruMeditation (const CConsole &aConsole,
366 const QString &aLogFolder);
367
368 bool confirmVMReset (QWidget *aParent);
369
370 bool confirmHardDisklessMachine (QWidget *aParent);
371
372 void cannotRunInSelectorMode();
373
374 void cannotImportAppliance (const CAppliance &aAppliance);
375 void cannotImportAppliance (const CProgress &aProgress, const CAppliance &aAppliance);
376
377 void showRuntimeError (const CConsole &console, bool fatal,
378 const QString &errorID,
379 const QString &errorMsg);
380
381 static QString toAccusative (VBoxDefs::MediaType aType);
382
383 static QString formatRC (HRESULT aRC);
384
385 static QString formatErrorInfo (const COMErrorInfo &aInfo,
386 HRESULT aWrapperRC = S_OK);
387
388 static QString formatErrorInfo (const CVirtualBoxErrorInfo &aInfo)
389 {
390 return formatErrorInfo (COMErrorInfo (aInfo));
391 }
392
393 static QString formatErrorInfo (const COMBaseWithEI &aWrapper)
394 {
395 Assert (aWrapper.lastRC() != S_OK);
396 return formatErrorInfo (aWrapper.errorInfo(), aWrapper.lastRC());
397 }
398
399 static QString formatErrorInfo (const COMResult &aRC)
400 {
401 Assert (aRC.rc() != S_OK);
402 return formatErrorInfo (aRC.errorInfo(), aRC.rc());
403 }
404
405public slots:
406
407 void showHelpWebDialog();
408 void showHelpAboutDialog();
409 void showHelpHelpDialog();
410 void resetSuppressedMessages();
411
412private:
413
414 friend VBoxProblemReporter &vboxProblem();
415
416 static QString doFormatErrorInfo (const COMErrorInfo &aInfo,
417 HRESULT aWrapperRC = S_OK);
418};
419
420/**
421 * Shortcut to the static VBoxProblemReporter::instance() method, for
422 * convenience.
423 */
424inline VBoxProblemReporter &vboxProblem() { return VBoxProblemReporter::instance(); }
425
426#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