VirtualBox

Changeset 5051 in vbox


Ignore:
Timestamp:
Sep 26, 2007 2:57:45 PM (17 years ago)
Author:
vboxsync
Message:

FE/Qt: GUI/RegistrationTryLeft => GUI/RegistrationTriesLeft.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h

    r5022 r5051  
    164164    static const char* GUI_LicenseKey;
    165165#endif
    166     static const char* GUI_RegistrationTryLeft;
     166    static const char* GUI_RegistrationTriesLeft;
    167167    static const char* GUI_RegistrationDlgWinID;
    168168};
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h

    r5047 r5051  
    404404    /* various helpers */
    405405
    406     bool openURL (const QString &aURL);
    407 
    408406    QString languageName() const;
    409407    QString languageCountry() const;
     
    510508    void snapshotChanged (const VBoxSnapshotEvent &e);
    511509
     510public slots:
     511
     512    bool openURL (const QString &aURL);
     513
    512514protected:
    513515
    514516    bool event (QEvent *e);
    515517    bool eventFilter (QObject *, QEvent *);
    516 
    517 private slots:
    518 
    519     void onOpenURL (const QString &aURL) { openURL (aURL); }
    520518
    521519private:
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxDefs.cpp

    r5022 r5051  
    3232const char* VBoxDefs::GUI_LicenseKey = "GUI/LicenseAgreed";
    3333#endif
    34 const char* VBoxDefs::GUI_RegistrationTryLeft = "GUI/RegistrationTryLeft";
     34const char* VBoxDefs::GUI_RegistrationTriesLeft = "GUI/RegistrationTriesLeft";
    3535const char* VBoxDefs::GUI_RegistrationDlgWinID = "GUI/RegistrationDlgWinID";
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r5043 r5051  
    16471647{
    16481648    /* check if the registration already passed */
    1649     if (virtualBox().GetExtraData (VBoxDefs::GUI_RegistrationTryLeft) == "0")
     1649    if (virtualBox().GetExtraData (VBoxDefs::GUI_RegistrationTriesLeft) == "0")
    16501650        return;
    16511651
     
    19231923
    19241924/**
    1925  * Opens the specified URL using OS/Desktop capabilities.
    1926  *
    1927  * @param aURL URL to open
    1928  *
    1929  * @return true on success and false otherwise
    1930  */
    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've
    1935      * initialized COM with CoInitializeEx(COINIT_MULTITHREADED). See
    1936      * http://support.microsoft.com/default.aspx?scid=kb;en-us;287087
    1937      * for more details. */
    1938     class Thread : public QThread
    1939     {
    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::postEvent
    1950                 (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 sources
    1981      * (http://www.psi-im.org) */
    1982 
    1983     /* Use Internet Config to hand the URL to the appropriate application, as
    1984      * set by the user in the Internet Preferences pane.
    1985      * NOTE: ICStart could be called once at Psi startup, saving the
    1986      *       ICInstance in a global variable, as a minor optimization.
    1987      *       ICStop should then be called at Psi shutdown if ICStart
    1988      *       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 application
    2001          * will report problems. */
    2002         ::ICLaunchURL (icInstance, hint, data, length, &start, &end);
    2003         ICStop (icInstance);
    2004     }
    2005 
    2006 #else
    2007     vboxProblem().message
    2008         (NULL, VBoxProblemReporter::Error,
    2009          tr ("Opening URLs is not implemented yet."));
    2010     return false;
    2011 #endif
    2012 
    2013     /* if we go here it means we couldn't open the URL */
    2014     vboxProblem().cannotOpenURL (aURL);
    2015 
    2016     return false;
    2017 }
    2018 
    2019 /**
    20201925 *  Native language name of the currently installed translation.
    20211926 *  Returns "English" if no translation is installed
     
    33873292}
    33883293
     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 */
     3304bool 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
    33893392// Protected members
    33903393////////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.

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