Changeset 5051 in vbox
- Timestamp:
- Sep 26, 2007 2:57:45 PM (17 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h
r5022 r5051 164 164 static const char* GUI_LicenseKey; 165 165 #endif 166 static const char* GUI_RegistrationTr yLeft;166 static const char* GUI_RegistrationTriesLeft; 167 167 static const char* GUI_RegistrationDlgWinID; 168 168 }; -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h
r5047 r5051 404 404 /* various helpers */ 405 405 406 bool openURL (const QString &aURL);407 408 406 QString languageName() const; 409 407 QString languageCountry() const; … … 510 508 void snapshotChanged (const VBoxSnapshotEvent &e); 511 509 510 public slots: 511 512 bool openURL (const QString &aURL); 513 512 514 protected: 513 515 514 516 bool event (QEvent *e); 515 517 bool eventFilter (QObject *, QEvent *); 516 517 private slots:518 519 void onOpenURL (const QString &aURL) { openURL (aURL); }520 518 521 519 private: -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxDefs.cpp
r5022 r5051 32 32 const char* VBoxDefs::GUI_LicenseKey = "GUI/LicenseAgreed"; 33 33 #endif 34 const char* VBoxDefs::GUI_RegistrationTr yLeft = "GUI/RegistrationTryLeft";34 const char* VBoxDefs::GUI_RegistrationTriesLeft = "GUI/RegistrationTriesLeft"; 35 35 const char* VBoxDefs::GUI_RegistrationDlgWinID = "GUI/RegistrationDlgWinID"; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp
r5043 r5051 1647 1647 { 1648 1648 /* check if the registration already passed */ 1649 if (virtualBox().GetExtraData (VBoxDefs::GUI_RegistrationTr yLeft) == "0")1649 if (virtualBox().GetExtraData (VBoxDefs::GUI_RegistrationTriesLeft) == "0") 1650 1650 return; 1651 1651 … … 1923 1923 1924 1924 /** 1925 * Opens the specified URL using OS/Desktop capabilities.1926 *1927 * @param aURL URL to open1928 *1929 * @return true on success and false otherwise1930 */1931 bool VBoxGlobal::openURL (const QString &aURL)1932 {1933 #if defined (Q_WS_WIN)1934 /* We cannot use ShellExecute() on the main UI thread because we've1935 * initialized COM with CoInitializeEx(COINIT_MULTITHREADED). See1936 * http://support.microsoft.com/default.aspx?scid=kb;en-us;2870871937 * for more details. */1938 class Thread : public QThread1939 {1940 public:1941 1942 Thread (const QString &aURL, QObject *aObject)1943 : mObject (aObject), mURL (aURL) {}1944 1945 void run()1946 {1947 int rc = (int) ShellExecute (NULL, NULL, mURL.ucs2(), NULL, NULL, SW_SHOW);1948 bool ok = rc > 32;1949 QApplication::postEvent1950 (mObject,1951 new VBoxShellExecuteEvent (this, mURL, ok));1952 }1953 1954 QString mURL;1955 QObject *mObject;1956 };1957 1958 Thread *thread = new Thread (aURL, this);1959 thread->start();1960 /* thread will be deleted in the VBoxShellExecuteEvent handler */1961 1962 return true;1963 1964 #elif defined (Q_WS_X11)1965 1966 static const char * const commands[] =1967 { "kfmclient:exec", "gnome-open", "x-www-browser", "firefox", "konqueror" };1968 1969 for (size_t i = 0; i < ELEMENTS (commands); ++ i)1970 {1971 QStringList args = QStringList::split (':', commands [i]);1972 args += aURL;1973 QProcess cmd (args);1974 if (cmd.start())1975 return true;1976 }1977 1978 #elif defined (Q_WS_MAC)1979 1980 /* The code below is taken from Psi 0.10 sources1981 * (http://www.psi-im.org) */1982 1983 /* Use Internet Config to hand the URL to the appropriate application, as1984 * set by the user in the Internet Preferences pane.1985 * NOTE: ICStart could be called once at Psi startup, saving the1986 * ICInstance in a global variable, as a minor optimization.1987 * ICStop should then be called at Psi shutdown if ICStart1988 * succeeded. */1989 ICInstance icInstance;1990 OSType psiSignature = 'psi ';1991 OSStatus error = ::ICStart (&icInstance, psiSignature);1992 if (error == noErr)1993 {1994 ConstStr255Param hint (0x0);1995 QCString cs = aURL.local8Bit();1996 const char* data = cs.data();1997 long length = cs.length();1998 long start (0);1999 long end (length);2000 /* Don't bother testing return value (error); launched application2001 * will report problems. */2002 ::ICLaunchURL (icInstance, hint, data, length, &start, &end);2003 ICStop (icInstance);2004 }2005 2006 #else2007 vboxProblem().message2008 (NULL, VBoxProblemReporter::Error,2009 tr ("Opening URLs is not implemented yet."));2010 return false;2011 #endif2012 2013 /* if we go here it means we couldn't open the URL */2014 vboxProblem().cannotOpenURL (aURL);2015 2016 return false;2017 }2018 2019 /**2020 1925 * Native language name of the currently installed translation. 2021 1926 * Returns "English" if no translation is installed … … 3387 3292 } 3388 3293 3294 // Public slots 3295 //////////////////////////////////////////////////////////////////////////////// 3296 3297 /** 3298 * Opens the specified URL using OS/Desktop capabilities. 3299 * 3300 * @param aURL URL to open 3301 * 3302 * @return true on success and false otherwise 3303 */ 3304 bool VBoxGlobal::openURL (const QString &aURL) 3305 { 3306 #if defined (Q_WS_WIN) 3307 /* We cannot use ShellExecute() on the main UI thread because we've 3308 * initialized COM with CoInitializeEx(COINIT_MULTITHREADED). See 3309 * http://support.microsoft.com/default.aspx?scid=kb;en-us;287087 3310 * for more details. */ 3311 class Thread : public QThread 3312 { 3313 public: 3314 3315 Thread (const QString &aURL, QObject *aObject) 3316 : mObject (aObject), mURL (aURL) {} 3317 3318 void run() 3319 { 3320 int rc = (int) ShellExecute (NULL, NULL, mURL.ucs2(), NULL, NULL, SW_SHOW); 3321 bool ok = rc > 32; 3322 QApplication::postEvent 3323 (mObject, 3324 new VBoxShellExecuteEvent (this, mURL, ok)); 3325 } 3326 3327 QString mURL; 3328 QObject *mObject; 3329 }; 3330 3331 Thread *thread = new Thread (aURL, this); 3332 thread->start(); 3333 /* thread will be deleted in the VBoxShellExecuteEvent handler */ 3334 3335 return true; 3336 3337 #elif defined (Q_WS_X11) 3338 3339 static const char * const commands[] = 3340 { "kfmclient:exec", "gnome-open", "x-www-browser", "firefox", "konqueror" }; 3341 3342 for (size_t i = 0; i < ELEMENTS (commands); ++ i) 3343 { 3344 QStringList args = QStringList::split (':', commands [i]); 3345 args += aURL; 3346 QProcess cmd (args); 3347 if (cmd.start()) 3348 return true; 3349 } 3350 3351 #elif defined (Q_WS_MAC) 3352 3353 /* The code below is taken from Psi 0.10 sources 3354 * (http://www.psi-im.org) */ 3355 3356 /* Use Internet Config to hand the URL to the appropriate application, as 3357 * set by the user in the Internet Preferences pane. 3358 * NOTE: ICStart could be called once at Psi startup, saving the 3359 * ICInstance in a global variable, as a minor optimization. 3360 * ICStop should then be called at Psi shutdown if ICStart 3361 * succeeded. */ 3362 ICInstance icInstance; 3363 OSType psiSignature = 'psi '; 3364 OSStatus error = ::ICStart (&icInstance, psiSignature); 3365 if (error == noErr) 3366 { 3367 ConstStr255Param hint (0x0); 3368 QCString cs = aURL.local8Bit(); 3369 const char* data = cs.data(); 3370 long length = cs.length(); 3371 long start (0); 3372 long end (length); 3373 /* Don't bother testing return value (error); launched application 3374 * will report problems. */ 3375 ::ICLaunchURL (icInstance, hint, data, length, &start, &end); 3376 ICStop (icInstance); 3377 } 3378 3379 #else 3380 vboxProblem().message 3381 (NULL, VBoxProblemReporter::Error, 3382 tr ("Opening URLs is not implemented yet.")); 3383 return false; 3384 #endif 3385 3386 /* if we go here it means we couldn't open the URL */ 3387 vboxProblem().cannotOpenURL (aURL); 3388 3389 return false; 3390 } 3391 3389 3392 // Protected members 3390 3393 ////////////////////////////////////////////////////////////////////////////////
Note:
See TracChangeset
for help on using the changeset viewer.