Ejemplo n.º 1
0
STNewAccountAuthorizeView::STNewAccountAuthorizeView(KQOAuthManager *manager, QString token,QGraphicsItem *parent) :
    QGraphicsObject(parent),m_size(0,0),m_manager(manager),m_temporaryTokenString(token)
{
    setCacheMode(DeviceCoordinateCache);
    //setFlag(ItemDoesntPropagateOpacityToChildren);
    setAcceptsHoverEvents(true);
    setFlag(ItemIsFocusable);


    QImage pix;
    pix.load(":/stella/res/AuthorizeWindow.png");

    // draw title bar and so on
    QString title=tr("Login");
    STFont *font=STFont::defaultBoldFont();

    font->drawString(pix, QPointF(14, 18-1), QColor(0,0,0,96), title);
    font->drawString(pix, QPointF(14, 18), QColor(230,230,230), title);

    m_window=new QGraphicsPixmapItem(QPixmap::fromImage(pix), this);
    m_window->setOffset(-pix.width()/2,-pix.height()/2);

    m_cancelButton=new STAuthorizeCancelButton();
    m_cancelButtonProxy=new QGraphicsProxyWidget(m_window);
    m_cancelButtonProxy->setWidget(m_cancelButton);
    m_cancelButtonProxy->setPos(QPointF(239,11)+m_window->offset());

    m_animView=new STStripeAnimationView(m_window);
    m_animView->setVisible(false);
    m_animView->setPos(10+m_window->offset().x(), 36+413-20+m_window->offset().y());
    m_animView->setSize(QSize(320, 20));

    connect(m_cancelButton, SIGNAL(clicked()),
            this, SLOT(cancelled()));
    //m_cancelButtonProxy->setCacheMode(DeviceCoordinateCache);

    m_authView=NULL;
    m_request=NULL;

    m_fadeAnimation=new STSimpleAnimator(this);
    m_cancelAnimation=new STSimpleAnimator(this);
    connect(m_fadeAnimation, SIGNAL(valueChanged(float)),
            this, SLOT(fadeAnimated(float)));
    connect(m_cancelAnimation, SIGNAL(valueChanged(float)),
            this, SLOT(fadeAnimated(float)));
    m_cancelAnimation->setValue(1.f);
    m_fadeAnimation->setValue(0);

    connect(m_manager, SIGNAL(authorizationReceived(QString,QString)),
            this, SLOT(authorizationReceived(QString,QString)));
    connect(m_manager, SIGNAL(accessTokenReceived(QString,QString)),
            this, SLOT(accessTokenReceived(QString,QString)));


}
Ejemplo n.º 2
0
void Kaqtoos::setupConnections()
{
	// OAUTH
	connect(oauthManager, SIGNAL(temporaryTokenReceived(QString,QString)),
	        this, SLOT(onTemporaryTokenReceived(QString, QString)));

	connect(oauthManager, SIGNAL(authorizationReceived(QString,QString)),
	        this, SLOT(onAuthorizationReceived(QString, QString)));

	connect(oauthManager, SIGNAL(accessTokenReceived(QString,QString)),
	        this, SLOT(onAccessTokenReceived(QString,QString)));

	connect(oauthManager, SIGNAL(requestReady(QByteArray)),
	        this, SLOT(onRequestReady(QByteArray)));

	// Network
	connect(&downloadManager, SIGNAL(getDownload(QBuffer *, const QString &)),
	        this, SLOT(receiveBuffer(QBuffer *, const QString &)));

	// UI
	connect(connectAction, SIGNAL(triggered()), this, SLOT(getAccess()));
	connect(disconnectAction, SIGNAL(triggered()), this, SLOT(deleteUserOAuthConnection()));

	connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
	connect(aboutAction, SIGNAL(triggered()), this, SLOT(openAbout()));
}
Ejemplo n.º 3
0
void TwitterInterface::GetAccess ()
{
#ifdef WP_DEBUG
    qDebug() << Q_FUNC_INFO;
#endif
    connect (OAuthManager_,
             SIGNAL (temporaryTokenReceived (QString, QString)),
             this,
             SLOT (onTemporaryTokenReceived (QString, QString)));

    connect (OAuthManager_,
             SIGNAL (authorizationReceived (QString, QString)),
             this,
             SLOT (onAuthorizationReceived (QString, QString)));

    connect (OAuthManager_,
             SIGNAL (accessTokenReceived (QString, QString)),
             this,
             SLOT (onAccessTokenReceived (QString, QString)));

    connect (OAuthManager_,
             SIGNAL (authorizationPageRequested (QUrl)),
             this,
             SLOT (onAuthorizationPageRequested (QUrl)));

    OAuthRequest_->initRequest (KQOAuthRequest::TemporaryCredentials,
                                QUrl ("https://api.twitter.com/oauth/request_token"));
    OAuthRequest_->setConsumerKey (ConsumerKey_);
    OAuthRequest_->setConsumerSecretKey (ConsumerKeySecret_);
    OAuthManager_->setHandleUserAuthorization (true);
    OAuthManager_->setHandleAuthorizationPageOpening (false);

    OAuthManager_->executeRequest (OAuthRequest_);
}
Ejemplo n.º 4
0
void VimeoAuth::getAccess() {
    connect(oauthManager, SIGNAL(temporaryTokenReceived(QString,QString)), this, SLOT(onTemporaryTokenReceived(QString, QString)));
    connect(oauthManager, SIGNAL(authorizationReceived(QString,QString)), this, SLOT( onAuthorizationReceived(QString, QString)));
    connect(oauthManager, SIGNAL(accessTokenReceived(QString,QString)), this, SLOT(onAccessTokenReceived(QString, QString)));
    connect(oauthManager, SIGNAL(requestReady(QByteArray)), this, SLOT(onRequestReady(QByteArray)));

    oauthRequest->initRequest(KQOAuthRequest::TemporaryCredentials, QUrl("https://vimeo.com/oauth/request_token"));
    oauthRequest->setConsumerKey(CONSUMER_KEY);
    oauthRequest->setConsumerSecretKey(CONSUMER_SECRET);
    oauthManager->setHandleUserAuthorization(true);
    oauthManager->executeRequest(oauthRequest);
}
Ejemplo n.º 5
0
void FoursquareApi::login()
{
    connect(oauthManager, SIGNAL(authorizationReceived(QString,QString)), this, SLOT( onAuthorizationReceived(QString, QString)));
    KQOAuthParameters params;
    oauthManager->getOauth2UserAuthorization(QUrl("https://foursquare.com/oauth2/authenticate"),CONSUMER_KEY,params);
}
Ejemplo n.º 6
0
OAuthDialog::OAuthDialog(Context *context, OAuthSite site) :
    context(context), site(site)
{

    setAttribute(Qt::WA_DeleteOnClose);
    setWindowTitle(tr("OAuth"));

    // check if SSL is available - if not - message and end
    if (!QSslSocket::supportsSsl()) {
        QString text = QString(tr("SSL Security Libraries required for 'Authorise' are missing in this installation."));
        QMessageBox sslMissing(QMessageBox::Critical, tr("Authorization Error"), text);
        sslMissing.exec();
        noSSLlib = true;
        return;
    }

    // SSL is available - so authorisation can take place
    noSSLlib = false;

    layout = new QVBoxLayout();
    layout->setSpacing(0);
    layout->setContentsMargins(2,0,2,2);
    setLayout(layout);


    #if QT_VERSION < 0x050000 || !defined(Q_OS_MAC)
    view = new QWebView();
    #else
    view = new QWebEngineView();
    #endif

    view->setContentsMargins(0,0,0,0);
    view->page()->view()->setContentsMargins(0,0,0,0);
    view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    view->setAcceptDrops(false);
    layout->addWidget(view);

    QString urlstr = "";
    if (site == STRAVA) {
        urlstr = QString("https://www.strava.com/oauth/authorize?");
        urlstr.append("client_id=").append(GC_STRAVA_CLIENT_ID).append("&");
        urlstr.append("scope=view_private,write&");
        urlstr.append("redirect_uri=http://www.goldencheetah.org/&");
        urlstr.append("response_type=code&");
        urlstr.append("approval_prompt=force");

    } else if (site == DROPBOX) {

        urlstr = QString("https://www.dropbox.com/1/oauth2/authorize?");

#ifdef GC_DROPBOX_CLIENT_ID
        urlstr.append("client_id=").append(GC_DROPBOX_CLIENT_ID).append("&");
#endif
        urlstr.append("redirect_uri=https://goldencheetah.github.io/blank.html&");
        urlstr.append("response_type=code&");
        urlstr.append("force_reapprove=true");

    } else if (site == TWITTER) {

#ifdef GC_HAVE_KQOAUTH
        oauthRequest = new KQOAuthRequest;
        oauthManager = new KQOAuthManager(this);

        connect(oauthManager, SIGNAL(temporaryTokenReceived(QString,QString)),
                this, SLOT(onTemporaryTokenReceived(QString, QString)));

        connect(oauthManager, SIGNAL(authorizationReceived(QString,QString)),
                this, SLOT( onAuthorizationReceived(QString, QString)));

        connect(oauthManager, SIGNAL(accessTokenReceived(QString,QString)),
                this, SLOT(onAccessTokenReceived(QString,QString)));

        connect(oauthManager, SIGNAL(requestReady(QByteArray)),
                this, SLOT(onRequestReady(QByteArray)));

        connect(oauthManager, SIGNAL(authorizationPageRequested(QUrl)),
                this, SLOT(onAuthorizationPageRequested(QUrl)));


        oauthRequest->initRequest(KQOAuthRequest::TemporaryCredentials, QUrl("https://api.twitter.com/oauth/request_token"));

        oauthRequest->setConsumerKey(GC_TWITTER_CONSUMER_KEY);
        oauthRequest->setConsumerSecretKey(GC_TWITTER_CONSUMER_SECRET);

        oauthManager->setHandleUserAuthorization(true);
        oauthManager->setHandleAuthorizationPageOpening(false);

        oauthManager->executeRequest(oauthRequest);

#endif
    } else if (site == CYCLING_ANALYTICS) {

        urlstr = QString("https://www.cyclinganalytics.com/api/auth?");
        urlstr.append("client_id=").append(GC_CYCLINGANALYTICS_CLIENT_ID).append("&");
        urlstr.append("scope=modify_rides&");
        urlstr.append("redirect_uri=http://www.goldencheetah.org/&");
        urlstr.append("response_type=code&");
        urlstr.append("approval_prompt=force");

    } else if (site == GOOGLE_CALENDAR) {

        // OAUTH 2.0 - Google flow for installed applications
        urlstr = QString("https://accounts.google.com/o/oauth2/auth?");
        urlstr.append("scope=https://www.googleapis.com/auth/calendar&");
        urlstr.append("redirect_uri=urn:ietf:wg:oauth:2.0:oob&");
        urlstr.append("response_type=code&");
        urlstr.append("client_id=").append(GC_GOOGLE_CALENDAR_CLIENT_ID);
    }

    // different process to get the token for STRAVA, CYCLINGANALYTICS vs. TWITTER
    if (site == DROPBOX || site == STRAVA || site == CYCLING_ANALYTICS || site == GOOGLE_CALENDAR ) {


        url = QUrl(urlstr);
        view->setUrl(url);

        // connects
        connect(view, SIGNAL(urlChanged(const QUrl&)), this, SLOT(urlChanged(const QUrl&)));
        connect(view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
    }