void StravaUploadDialog::uploadToStrava() { show(); overwrite = true; if(activityId.length()>0) { overwrite = false; dialog = new QDialog(); QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layoutLabel = new QVBoxLayout(); QLabel *label = new QLabel(); label->setText(tr("This Ride is marked as already on Strava. Are you sure you want to upload it?")); layoutLabel->addWidget(label); QPushButton *ok = new QPushButton(tr("OK"), this); QPushButton *cancel = new QPushButton(tr("Cancel"), this); QHBoxLayout *buttons = new QHBoxLayout(); buttons->addStretch(); buttons->addWidget(cancel); buttons->addWidget(ok); connect(ok, SIGNAL(clicked()), this, SLOT(okClicked())); connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked())); layout->addLayout(layoutLabel); layout->addLayout(buttons); dialog->setLayout(layout); if (!dialog->exec()) return; } requestLogin(); if(!loggedIn) { /*QMessageBox aMsgBox; aMsgBox.setText(tr("Cannot login to Strava. Check username/password")); aMsgBox.exec();*/ reject(); } requestUpload(); if(!uploadSuccessful) { progressLabel->setText("Error uploading to Strava"); } else { //requestVerifyUpload(); progressLabel->setText(tr("Successfully uploaded to Strava\n")+uploadStatus); } uploadButton->setVisible(false); cancelButton->setText("OK"); QApplication::processEvents(); }
void TimeSpiderSettingsDialog::initialize( ) { setupUi( this ); m_soap.setHost( m_settings.serviceHost, m_settings.serviceUseSSL, m_settings.servicePort ); connect( &m_soap, SIGNAL( responseReady( const QtSoapMessage& ) ), SLOT( getResponse( const QtSoapMessage& ) ) ); connect( buttonBox->button( QDialogButtonBox::Save ), SIGNAL( clicked( ) ), SLOT( apply( ) ) ); connect( buttonBox->button( QDialogButtonBox::Cancel ), SIGNAL( clicked( ) ), SLOT( cancel( ) ) ); connect( buttonBox->button( QDialogButtonBox::RestoreDefaults ), SIGNAL( clicked( ) ), SLOT( restoreDefaults( ) ) ); connect( requestLoginButton, SIGNAL( clicked( ) ), SLOT( requestLogin( ) ) ); qDebug( ) << "Setting auth state ok?" << m_authOk; if( m_authOk ) { authState->setText( "" ); } else { authState->setText( "authentication failed" ); } }
// Пройти аутентификацию int passAuthentication(struct Connection *connection) { switch (connection->auth.status) { case LOGIN_REQUEST: requestLogin(connection); break; case LOGIN_CHECK: checkLogin(connection); break; case PASSWORD_REQUEST: requestPassword(connection); break; case PASSWORD_CHECK: checkPassword(connection); break; default: fprintf(stderr, "Error: wrong authentication status of connectionfd %d\n", connection->connectionfd); return -1; } return 0; }
// Проверяем логин int checkLogin(struct Connection *connection) { char *login = NULL; if (readNonBlock(connection->connectionfd, &login, 0) == -1) { fprintf(stderr, "Error: receiving login from connection %d\n", connection->connectionfd); return -1; } connection->pair = getPair(login); if (connection->pair == NULL) { if (sendMsg(connection->connectionfd, "Wrong login, try again\n") == -1) { fprintf(stderr, "Error: sending wrong login msg\n"); return -1; } requestLogin(connection); } else { connection->auth.status = PASSWORD_REQUEST; requestPassword(connection); } free(login); return 0; }
void StravaUploadDialog::getActivityFromStrava() { if (token.length()==0) requestLogin(); if(!loggedIn) { /*QMessageBox aMsgBox; aMsgBox.setText(tr("Cannot login to Strava. Check username/password")); aMsgBox.exec();*/ reject(); } requestSearchRide(); //verifyUpload(); //QMessageBox aMsgBox; //aMsgBox.setText(tr("Successfully uploaded to Strava\n")+uploadStatus); //aMsgBox.exec(); return; }
void FLoginController::setWidget(FLoginWindow *w) { display = w; connect(display, SIGNAL(loginRequested(QString,QString)), this, SLOT(requestLogin(QString,QString))); }
LogicPasteApp::LogicPasteApp(Application *app) : QObject(app), loginSheet_(NULL), ignoreSettingsEvent_(false) { qDebug() << "LogicPasteApp::LogicPasteApp()"; QCoreApplication::setOrganizationName("LogicProbe"); QCoreApplication::setApplicationName("LogicPaste"); qRegisterMetaType<PasteListing>("PasteListing"); pasteModel_ = new PasteModel(this); QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); qml->setContextProperty("cs", this); qml->setContextProperty("model", pasteModel_); AppSettings *appSettings = AppSettings::instance(); if(!qml->hasErrors()) { tabbedPane_ = qml->createRootObject<TabbedPane>(); if(tabbedPane_) { // Paste page pastePage_ = tabbedPane_->findChild<Page*>("pastePage"); connect(pastePage_, SIGNAL(submitPaste()), this, SLOT(onSubmitPaste())); replaceDropDown(pastePage_, "formatDropDown"); // History page historyNav_ = tabbedPane_->findChild<NavigationPane*>("historyPage"); connect(historyNav_, SIGNAL(popTransitionEnded(bb::cascades::Page*)), this, SLOT(onPopFinished(bb::cascades::Page*))); historyPage_ = historyNav_->findChild<Page*>("pasteListPage"); connect(historyPage_, SIGNAL(refreshPage()), pasteModel_, SLOT(refreshHistory())); ListView *historyList = historyPage_->findChild<ListView*>("pasteList"); historyList->setDataModel(pasteModel_->historyModel()); connect(historyList, SIGNAL(openPaste(QString)), this, SLOT(onOpenHistoryPaste(QString))); connect(historyList, SIGNAL(copyUrl(QString)), this, SLOT(onCopyText(QString))); connect(historyList, SIGNAL(deletePaste(QString)), this, SLOT(onDeleteHistoryPaste(QString))); connect(pasteModel_, SIGNAL(historyUpdating()), historyPage_, SLOT(onRefreshStarted())); connect(pasteModel_, SIGNAL(historyUpdated(bool)), this, SLOT(onHistoryRefreshComplete(bool))); // Trending page trendingNav_ = tabbedPane_->findChild<NavigationPane*>("trendingPage"); connect(trendingNav_, SIGNAL(popTransitionEnded(bb::cascades::Page*)), this, SLOT(onPopFinished(bb::cascades::Page*))); trendingPage_ = trendingNav_->findChild<Page*>("pasteListPage"); trendingPage_->findChild<ActionItem*>("refreshAction")->setEnabled(true); connect(trendingPage_, SIGNAL(refreshPage()), pasteModel_, SLOT(refreshTrending())); ListView *trendingList = trendingPage_->findChild<ListView*>("pasteList"); trendingList->setDataModel(pasteModel_->trendingModel()); connect(trendingList, SIGNAL(openPaste(QString)), this, SLOT(onOpenTrendingPaste(QString))); connect(trendingList, SIGNAL(copyUrl(QString)), this, SLOT(onCopyText(QString))); connect(pasteModel_, SIGNAL(trendingUpdating()), trendingPage_, SLOT(onRefreshStarted())); connect(pasteModel_, SIGNAL(trendingUpdated(bool)), this, SLOT(onTrendingRefreshComplete(bool))); // Settings page settingsPage_ = tabbedPane_->findChild<Page*>("settingsPage"); CheckBox *sslCheckBox = settingsPage_->findChild<CheckBox *>("sslCheckBox"); sslCheckBox->setChecked(appSettings->useSsl()); CheckBox *formatterEnable = settingsPage_->findChild<CheckBox*>("formatterEnable"); formatterEnable->setChecked(appSettings->formatterEnabled()); CheckBox *formatterLineNumbering = settingsPage_->findChild<CheckBox*>("formatterLineNumbering"); formatterLineNumbering->setChecked(appSettings->formatterLineNumbering()); DropDown *formatterStyle = settingsPage_->findChild<DropDown*>("formatterStyle"); for(int i = formatterStyle->count() - 1; i >= 0; --i) { if(formatterStyle->at(i)->value() == appSettings->formatterStyle()) { formatterStyle->setSelectedIndex(i); break; } } connect(settingsPage_, SIGNAL(requestLogin()), this, SLOT(onRequestLogin())); connect(settingsPage_, SIGNAL(requestLogout()), this, SLOT(onRequestLogout())); connect(settingsPage_, SIGNAL(refreshUserDetails()), pasteModel_, SLOT(refreshUserDetails())); connect(settingsPage_, SIGNAL(connectionSettingsChanged()), this, SLOT(onConnectionSettingsChanged())); connect(settingsPage_, SIGNAL(pasteSettingsChanged()), this, SLOT(onPasteSettingsChanged())); connect(settingsPage_, SIGNAL(formatterSettingsChanged()), this, SLOT(onFormatterSettingsChanged())); connect(pasteModel_, SIGNAL(userDetailsUpdated()), this, SLOT(onUserDetailsUpdated())); connect(pasteModel_, SIGNAL(userDetailsError(QString)), this, SLOT(onUserDetailsError(QString))); connect(pasteModel_, SIGNAL(userAvatarUpdated()), this, SLOT(onUserAvatarUpdated())); connect(pasteModel_, SIGNAL(deletePasteError(PasteListing,QString)), this, SLOT(onDeletePasteError(PasteListing,QString))); FormatDropDown *formatDropDown = replaceDropDown(settingsPage_, "formatDropDown"); connect(formatDropDown, SIGNAL(selectedIndexChanged(int)), this, SLOT(onPasteSettingsChanged())); // Tabbed pane connect(tabbedPane_, SIGNAL(activePaneChanged(bb::cascades::AbstractPane*)), this, SLOT(onActivePaneChanged(bb::cascades::AbstractPane*))); app->setScene(tabbedPane_); // Create the pull-down menu ActionItem *aboutItem = ActionItem::create() .title(tr("About")) .image(QUrl("asset:///images/action-about.png")); connect(aboutItem, SIGNAL(triggered()), this, SLOT(onAboutActionTriggered())); Menu *menu = Menu::create() .addAction(aboutItem); app->setMenu(menu); if(pasteModel_->isAuthenticated()) { onUserDetailsUpdated(); onUserAvatarUpdated(); } refreshPastePageDefaults(); refreshMainActions(); } }