void SlideShare::afterLogin()
{
    qDebug() << ">>>>>>>>> SlideShare::afterLogin()";
    if(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 302) {
        if(reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toString().contains(*username))
            emit loginDone(true);
    } else
        emit loginDone(false);
}
Exemplo n.º 2
0
void OAuth2::startLogin(bool bForce)
{
    QSettings settings(m_strCompanyName, m_strAppName);
    QString str = settings.value("access_token", "").toString();

    qDebug() << "OAuth2::startLogin, token from Settings" << str;
    if(m_strClientID == "YOUR_CLIENT_ID_HERE" || m_strRedirectURI == "YOUR_REDIRECT_URI_HERE")
    {
        QMessageBox::warning(m_pParent, "Warning",
                             "To work with application you need to register your own application in <b>Google</b>.\n"
                             "Learn more from <a href='http://code.google.com/p/qt-google-tasks/wiki/HowToRegisterYourAppIicationInGoogle'>here</a>");
        return;
    }


    if(str.isEmpty() || bForce)
    {
        m_pLoginDialog->setLoginUrl(loginUrl());
        m_pLoginDialog->show();
    }
    else
    {
        m_strAccessToken = str;
        emit loginDone();
    }
}
Exemplo n.º 3
0
LoginForm::LoginForm( QGraphicsItem* parent, Qt::WindowFlags wFlags )
    : Overlay( parent, wFlags )
    , m_usernameEdit( new Plasma::LineEdit( this ) )
    , m_passwordEdit( new Plasma::LineEdit( this ) )
    , m_loginButton( new Plasma::PushButton( this ) )
    , m_busyWidget( new Plasma::BusyWidget( this ) )
    , m_usernameLabel( new Plasma::Label( this ) )
{
    m_usernameEdit->nativeWidget()->setClickMessage( i18nc( "The name of the user", "Username" ) );
    m_passwordEdit->nativeWidget()->setClickMessage( i18n( "Password" ) );
    m_passwordEdit->nativeWidget()->setPasswordMode( true );
    m_loginButton->setIcon( KIcon( "network-connect" ) );
    m_loginButton->setText( i18n( "Login" ) );
    m_loginButton->setEnabled( false );

    m_busyWidget->hide();
    m_usernameLabel->setText( i18n( "Not Logged In" ) );

    QGraphicsLinearLayout* layout1 = new QGraphicsLinearLayout( m_contentLayout );
    layout1->addItem( m_busyWidget );
    layout1->addItem( m_usernameLabel );

    m_contentLayout->addItem( layout1 );
    m_contentLayout->addItem( m_usernameEdit );
    m_contentLayout->addItem( m_passwordEdit );
    m_contentLayout->addItem( m_loginButton );

    connect( m_loginButton, SIGNAL( clicked() ), SLOT( doLogin() ) );
    connect(GluonPlayer::OcsProvider::instance(), SIGNAL(providerInitialized()), SLOT(initDone()));
    connect(GluonPlayer::OcsProvider::instance(), SIGNAL(failedToInitialize()), SLOT(initFailed()));
    connect(GluonPlayer::OcsProvider::instance(), SIGNAL(loggedIn()), SLOT(loginDone()));
    connect(GluonPlayer::OcsProvider::instance(), SIGNAL(loginFailed()), SLOT(loginFailed()));

    initialize();
}
Exemplo n.º 4
0
void OAuth2::accessTokenObtained()
{
    QSettings settings(m_strCompanyName, m_strAppName);
    m_strAccessToken = m_pLoginDialog->accessToken();
    settings.setValue("access_token", m_strAccessToken);
    emit loginDone();

}
Exemplo n.º 5
0
/*! \brief This slot called only form Google Login dialog in case of response_type=token
 *
 */
void OAuth2::accessTokenObtained()
{
    m_strAccessToken = m_pLoginDialog->accessToken();
    emit loginDone();
    if (m_pLoginDialog != NULL) {
        m_pLoginDialog->deleteLater();
        m_pLoginDialog = NULL;
    }
}
Exemplo n.º 6
0
void OAuth2::accessTokenObtained()
{
    QSettings settings("ICS", "Google API Calendar Client");
    m_strAccessToken = m_pLoginDialog->accessToken();
    settings.setValue("access_token", m_strAccessToken);
    m_pLoginDialog->setLoginUrl("");
    emit loginDone();

}
Exemplo n.º 7
0
void LoginForm::doLogin()
{
    if( m_usernameEdit->text().isEmpty() || m_passwordEdit->text().isEmpty() )
    {
        return;
    }

    m_loginButton->setEnabled( false );
    m_busyWidget->show();
    GluonPlayer::OcsProvider::instance()->login(m_usernameEdit->text(), m_passwordEdit->text());
    connect(GluonPlayer::OcsProvider::instance(), SIGNAL(loggedIn()), SLOT(loginDone()));
    m_usernameLabel->setText( i18n( "Logging in" ) );
}
Exemplo n.º 8
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);


    m_pOAuth2 = new OAuth2(this);
    m_API_key = m_pOAuth2->getSimpleAPIKey();

    connect(m_pOAuth2, SIGNAL(loginDone()), this, SLOT(loginDone()));


    m_managerPrediction.setAPIKey(m_API_key);

    connect(&m_managerPrediction, SIGNAL(replyText(QString)), this, SLOT(addReplyText(QString)));
    connect(&m_managerPrediction, SIGNAL(recvModelsList(QVariantList)), this, SLOT(recvModelsList(QVariantList)));
    connect(&m_managerPrediction, SIGNAL(recvModelDescription(QVariant)), this, SLOT(recvModelDescription(QVariant)));
    connect(&m_managerPrediction, SIGNAL(recvPredictionResult(QVariant)), this, SLOT(recvPredictionResult(QVariant)));
    connect(&m_managerPrediction, SIGNAL(recvAddToModelComplete(bool)), this, SLOT(recvAddToModelComplete(bool)));

    connect(ui->lwModelsList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedModelChanged()));

    connect(ui->actionDeleteModel, SIGNAL(triggered()), this, SLOT(deleteModel()));
    connect(ui->actionNewModel, SIGNAL(triggered()), this, SLOT(newModel()));
    connect(ui->actionUpdateModelsList, SIGNAL(triggered()), this, SLOT(updateModelsList()));
    connect(ui->actionUpdateModelInfo, SIGNAL(triggered()), this, SLOT(updateModelInfo()));
    connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->predictButton, SIGNAL(clicked()), this, SLOT(predict()));


    connect(ui->lineEditTextToPredict, SIGNAL(returnPressed()), this, SLOT(predict()));
    connect(ui->actionLogin, SIGNAL(triggered()), this, SLOT(login()));

    connect(&timerTest, SIGNAL(timeout()), this, SLOT(testSendRequest()));

    startLogin(false);
}
Exemplo n.º 9
0
void OAuth2::replyFinished(QNetworkReply* reply)
{
    QString json = reply->readAll();

    QJson::Parser parser;
    bool ok;
    // json is a QString containing the data to convert
    QVariant result = parser.parse (json.toLatin1(), &ok);

    if( !ok )
    {
        emit sigErrorOccured(QString("Cannot convert to QJson object: %1").arg(json));
        return;
    }
    if (result.toMap().contains("error")) {
        emit sigErrorOccured(result.toMap()["error"].toString());
        return;
    }

    QString str = result.toMap()["refresh_token"].toString();
    if (!str.isEmpty() && str != m_strRefreshToken) {
        m_strRefreshToken = str;
        if (m_pSettings != NULL) {
            m_pSettings->setValue("refresh_token",m_strRefreshToken);
        }
    }

    QString prevAccessToken = m_strAccessToken;
    str = result.toMap()["access_token"].toString();
    int expires_in = result.toMap()["expires_in"].toInt();
    if(!str.isEmpty())
    {
        //After 55 min update access_token
        QTimer::singleShot ( (expires_in - 120)*1000, this, SLOT(getAccessTokenFromRefreshToken()) );
    }
    if(!str.isEmpty() && str != prevAccessToken)
    {
        m_strAccessToken = str;
        if (m_pSettings != NULL) {
            m_pSettings->setValue("access_token",m_strAccessToken);
        }
        emit loginDone();
    }
    if (m_pLoginDialog != NULL) {
        delete m_pLoginDialog;
        m_pLoginDialog = NULL;
    }
}
Exemplo n.º 10
0
void MainWindow::startLogin(bool bForce)
{
    //Now we allow to start logging in when m_oauth2.isAuthorized().
    //User can log in using another Google account.
    if (bForce) {
        m_pOAuth2->startLogin(true);
        return;
    }

    if(!m_pOAuth2->isAuthorized())
    {
        m_pOAuth2->startLogin(bForce); //this is a parent widget for a login dialog.
    }
    else
    {
        loginDone();
    }
}
Exemplo n.º 11
0
LoginForm::LoginForm( QWidget* parent, Qt::WindowFlags wFlags )
    : Overlay( parent, wFlags )
    , m_usernameLineEdit( new QLineEdit( this ) )
    , m_passwordLineEdit( new QLineEdit( this ) )
    , m_loginButton( new QPushButton( this ) )
    , m_busyWidget( new QProgressBar( this ) )
    , m_usernameLabel( new QLabel( this ) )
    , m_passwordLabel( new QLabel( this ) )
    , m_rememberMeCheckBox( new QCheckBox( this ) )
{
    m_usernameLabel->setText( tr( "Username" ) );
    m_passwordLabel->setText( tr( "Password" ) );
    m_loginButton->setIcon( QIcon( "network-connect" ) );
    m_loginButton->setText( tr( "Login" ) );
    m_loginButton->setEnabled( false );

    m_busyWidget->hide();

    QGridLayout* layout1 = static_cast<QGridLayout*>(layout());
    layout1->addWidget( m_usernameLabel, 0, 0 );
    layout1->addWidget( m_passwordLabel, 0, 1);
    layout1->addWidget( m_usernameLineEdit, 1, 0 );
    layout1->addWidget( m_passwordLineEdit, 1, 1 );
    layout1->addWidget( m_loginButton, 2, 0 );
    layout1->addWidget( m_rememberMeCheckBox, 2, 1 );
    // layout1->addWidget( m_busyWidget );

    // m_contentLayout->addItem( layout1 );
    // m_contentLayout->addItem( m_usernameLineEdit );
    // m_contentLayout->addItem( m_passwordLineEdit );
    // m_contentLayout->addItem( m_loginButton );

    connect( m_loginButton, SIGNAL( clicked() ), SLOT( doLogin() ) );
    connect( GluonPlayer::Authentication::instance(), SIGNAL( initialized() ), SLOT( initDone() ) );
    connect( GluonPlayer::Authentication::instance(), SIGNAL( initFailed() ), SLOT( initFailed() ) );
    connect( GluonPlayer::Authentication::instance(), SIGNAL( loggedIn() ), SLOT( loginDone() ) );
    connect( GluonPlayer::Authentication::instance(), SIGNAL( loginFailed() ), SLOT( loginFailed() ) );

    initialize();
}
Exemplo n.º 12
0
void OAuth2::startLogin(bool bForce)
{
    qDebug() << "OAuth2::startLogin";
    QSettings settings("ICS", "Google API Calendar Client");
    QString str = settings.value("access_token", "").toString();

    qDebug() << "OAuth2::startLogin, token from Settings" << str;

    if(m_strClientID == "YOUR_CLIENT_ID_HERE" || m_strRedirectURI == "YOUR_REDIRECT_URI_HERE")
    {
        QMessageBox::warning(m_pParent, "Warning",
                             "To work with application you need to register your own application in <b>Google</b>.\n"
                             "Learn more from <a href='http://code.google.com/p/qt-google-calendar/wiki/HowToRegisterYourApplicationInGoogle'>here</a>");
        return;
    }


    if(str.isEmpty() || bForce)
    {
        //LoginDialog* dlg = new LoginDialog(parent);
        //m_pLoginDialog->setParent(parent);
        m_pLoginDialog->setLoginUrl(loginUrl());
        m_pLoginDialog->show();
//        int res = dlg.exec();
//        if(res == QDialog::Accepted)
//        {
//            m_strAccessToken = dlg.accessToken();
//            settings.setValue("access_token", m_strAccessToken);
//            emit loginDone();
//        }
    }
    else
    {
        m_strAccessToken = str;
        emit loginDone();
    }
}
Exemplo n.º 13
0
	void setupUi(WeiboDialog *ui) {
		QObject::connect(api, SIGNAL(error(QString)), ui, SLOT(doError(QString)));
        QObject::connect(api, SIGNAL(loginOk()), ui, SLOT(loginDone()));
        ui->resize(qApp->desktop()->width()/2 - 11, qApp->desktop()->height() -22);
	}
Exemplo n.º 14
0
statswinimpl::statswinimpl(Hero *h) 
: QWidget(0,0)
{
	setupUi(this);
	hero = h;
	hwin = new herowinimpl(hero);
	diary = new diarywinimpl();
	
	stayontopToggle(false);
	connect(hero, SIGNAL(done(QString)), this, SLOT(loginDone(QString)));
	
	//трей

#ifdef Q_WS_WIN
        QResource res = QResource("bin/icon.bmp");
#else
        QResource res = QResource("src/icon_128.png");
#endif
	QPixmap pix;
        pix.loadFromData(res.data(), res.size());
	QIcon ico = QIcon(pix);
	tray = new QSystemTrayIcon(ico);
	tray->setVisible(true);
	connect(tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
	
	//меню
	QMenu *menu = new QMenu();
	QAction *hideshow = menu->addAction(tr("Скрыть/Показать"));
	connect(hideshow, SIGNAL(triggered()), this, SLOT(hideshow()));
	menu->addSeparator();
	showmess = menu->addAction(tr("Показывать сообщения"));
	showmess->setCheckable(true);
	showmess->setChecked(true);
	QAction *stayontop = menu->addAction(tr("Поверх всех окон"));
	stayontop->setCheckable(true);
	stayontop->setChecked(false);
	connect(stayontop, SIGNAL(toggled(bool)), this, SLOT(stayontopToggle(bool)));
	menu->addSeparator();
	
	QAction *herotrbt = menu->addAction(tr("Герой"));
	connect(herotrbt, SIGNAL(triggered()), this, SLOT(on_btInfo_pressed()));
	QAction *diarytrbt = menu->addAction(tr("Дневник"));
	connect(diarytrbt, SIGNAL(triggered()), this, SLOT(on_btDiary_pressed()));
	menu->addSeparator();

        settingsDialog = new Dialog(this);
        connect(settingsDialog,SIGNAL(accepted()),this,SLOT(updateSettings()));
        QAction *settingstrbt = menu->addAction(tr("Настройки"));
        connect(settingstrbt,SIGNAL(triggered()),this,SLOT(settings()));
        menu->addSeparator();
        //settingstrbt->setEnabled(false);
	
	QAction *exit = menu->addAction(tr("Выход"));
	connect(exit, SIGNAL(triggered()), qApp, SLOT(quit()));
	connect(exit, SIGNAL(triggered()), tray, SLOT(hide()));
	
	tray->setContextMenu(menu);
	
	//таймер
	timer = new QTimer(this);
	timer->start(15000);
	connect(timer, SIGNAL(timeout()), this, SLOT(update()));
	
        mess = new HeroMessager();

        QSettings settings("godville.net", "godvilleQT");
        restoreGeometry(settings.value("statWinGeometry").toByteArray());
        this->setWindowOpacity(settings.value("statWinOp",100).toInt()/100);
}