Example #1
0
void LinTORManager::receiveAuthToken()
{
  QJson::Parser parser;

  bool ok;

  QVariantMap result = parser.parse(authReply->readAll(), &ok).toMap();

  authReply->deleteLater();
  authReply = 0;

  if (!ok)
  {
    qWarning() << "Failed to parse The Old Reader authorization data";
    emit loginFailed();
    return;
  }

  authToken = result["Auth"].toString();

  authHeaderString = "GoogleLogin auth=";
  authHeaderString += authToken;

  qDebug() << "Authentication: " << authHeaderString;

  // Initialize the display:
  getFolders();
//  getUnread();
//  getSubscriptions();
}
Example #2
0
void Statistic::onFTPLoad()
{
	ui.mFTPButton->setEnabled(false);

	CXSettings* settings = CXSettings::inst();
	//считываем настройки
	host = settings->value(E_FTPHost).toString();
  user = CXSettings::inst()->value(E_TelnetUser).toString();
  password = CXSettings::inst()->value(E_TelnetPassword).toString();

  //приходится каждый раз убивать, так как не дает переподключатся
  if(tlClient != NULL){
    delete tlClient;
    tlClient = NULL;
  }
  ui.curOperationLabel->setText(trUtf8("Соединение с сервером..."));
  setCursor(Qt::WaitCursor);
  tlClient = new QtTelnet(this);

  connect(tlClient, SIGNAL(loginRequired()), this, SLOT(telnetLoginRequired()));
  connect(tlClient, SIGNAL(loginFailed()), this, SLOT(telnetLoginFailed()));
  connect(tlClient, SIGNAL(connectionError(QAbstractSocket::SocketError)),
      this, SLOT(telnetConnectionError(QAbstractSocket::SocketError)));
  connect(tlClient, SIGNAL(message(const QString &)),this, SLOT(telnetMessage(const QString &)));

  //соединяемся с telnet клиентом
  if(!tlClient->connectToHost(host, TELNET_PORT)){
    onFtpError(trUtf8("Не удалось подключиться к Telnet-серверу. Сервер недоступен.\n[%1]").arg(host));
  };
}
Example #3
0
    void Display::slotAuthError(const QString &message, Auth::Error error) {
        // TODO: handle more errors
        qWarning() << "Authentication error:" << message;

        if (!m_socket)
            return;

        if (error == Auth::ERROR_AUTHENTICATION)
            emit loginFailed(m_socket);
    }
Example #4
0
void LoginService::authetication(MsvServerMessage* model){
	if (model->isAuthentication()) {
		if (model->getAuthInfoModel()){
			if (model->getAuthInfoModel()->isAuthenticated()) {
				qDebug() << "LoginService::authetication# LoginService::authetication# Authentication succesfull !" << endl;
				emit loginSuccesful(model->getAuthInfoModel()->getPlayerModel());
				return;
			}
			qDebug() << "LoginService::authetication# LoginService::authetication# Auth failed, incorrect password " << endl;
			emit loginFailed();
			return;
		}
		qDebug() << "LoginService::authetication# Warning !!! why AuthInfoModel is null ?? " << endl;
		emit loginFailed();
		return;
	}
	qDebug() << "LoginService::authetication# Warning !!! it isn't authentication message " << endl;
	emit loginFailed();
}
void LoginWidget::displayLoginFailedMessage(const QString errorMessage){
  emit loginFailed();
  DataStore::setCredentialsDirty();
  showMainWidget();
  setCurrentWidget(loginDisplay);
  QMessageBox::critical(
    this,
    tr("Login Failed"),
    errorMessage);
}
Example #6
0
Statistic::Statistic(QWidget *parent, Qt::WFlags flags) : QWidget(parent, flags)
{
	Engine::removeOldDirs();

	ui.setupUi(this);
	QString title = trUtf8("Статистика v") + VERSION;
	title += trUtf8(", сборка от "); title +=  __DATE__;
	this->setWindowTitle(title);

	mSettingsDialog = new CXSettingsDialog(this);

	mFtp = new QFtp(this);
	mLoadFile = NULL;
	waitTimer = -1;
	mIsArchiveAccept = false;
	start_arch = false;

	CXSettings* settings = CXSettings::inst();

	if (settings->value(E_StartDate).toDateTime().isValid())
	{
		ui.mStartDateEdit->setDateTime(settings->value(E_StartDate).toDateTime());
		ui.mStartTimeEdit->setTime(settings->value(E_StartDate).toDateTime().time());
	}

	if (settings->value(E_EndDate).toDateTime().isValid())
	{
		ui.mEndDateEdit->setDateTime(settings->value(E_EndDate).toDateTime());
		ui.mEndTimeEdit->setTime(settings->value(E_EndDate).toDateTime().time());
	}

	connect(ui.mArchiveButton,	SIGNAL(clicked()), this, SLOT(onArchiveLoad()));
	connect(ui.mFTPButton,		SIGNAL(clicked()), this, SLOT(onFTPLoad()));
	connect(ui.mReportButton,	SIGNAL(clicked()), this, SLOT(onReport()));
	connect(ui.mSaveReportButton,	SIGNAL(clicked()), this, SLOT(onSaveReport()));
	connect(ui.mSettingsButton,	SIGNAL(clicked()), mSettingsDialog, SLOT(exec()));

	connect(mFtp, SIGNAL(commandStarted(int)), this, SLOT(onCommandStarted(int)));
	connect(mFtp, SIGNAL(commandFinished(int,bool)), this, SLOT(onFtpCommandFinish(int,bool)));
	connect(mFtp, SIGNAL(listInfo(const QUrlInfo&)), this, SLOT(onListInfo(const QUrlInfo&)));
//	connect(mFtp, SIGNAL(readyRead()), this, SLOT(onReadyRead()));

	tlClient = new QtTelnet(this);

	connect(tlClient, SIGNAL(loginRequired()), this, SLOT(telnetLoginRequired()));
  connect(tlClient, SIGNAL(loginFailed()), this, SLOT(telnetLoginFailed()));
  connect(tlClient, SIGNAL(connectionError(QAbstractSocket::SocketError)),
      this, SLOT(telnetConnectionError(QAbstractSocket::SocketError)));
  connect(tlClient, SIGNAL(message(const QString &)),this, SLOT(telnetMessage(const QString &)));

//#ifdef QT_NO_DEBUG
//	ui.mErrorGroupBox->hide();
//#endif
}
Example #7
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();
}
Example #8
0
DataLayer::DataLayer(QObject *parent) :
    QObject(parent)
{
    _currentDay = NULL;
    _isPending = false;
    _authRequired = false;

    connect(&_webClient,SIGNAL(dataUpdated(Day*)),this,SLOT(setDataModel(Day*)));
    connect(&_webClient,SIGNAL(authRequiered()),this,SLOT(authenticationRequired()));
    connect(&_webClient,SIGNAL(loginFailed()),this,SLOT(authenticationRequired()));

    loadDataFromFile();
}
NXClientLib::NXClientLib(QObject *parent) : QObject(parent)
{
	isFinished = false;
	proxyData.encrypted = false;
	password = false;
	
	connect(&session, SIGNAL(authenticated()), this, SLOT(doneAuth()));
	connect(&session, SIGNAL(loginFailed()), this, SLOT(failedLogin()));
	connect(&session, SIGNAL(finished()), this, SLOT(finished()));
	connect(&session, SIGNAL(sessionsSignal(QList<NXResumeData>)), this, SLOT(suspendedSessions(QList<NXResumeData>)));
	connect(&session, SIGNAL(noSessions()), this, SLOT(noSuspendedSessions()));
	
	connect(&nxproxyProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(reset()));
}
Example #10
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()) );

    GluonPlayer::ServiceProvider *serviceProvider = GluonPlayer::ServiceProvider::instance();
    connect(serviceProvider, SIGNAL(providerInitialized()), SLOT(initDone()));
    connect(serviceProvider, SIGNAL(failedToInitialize()), SLOT(initFailed()));
    connect(serviceProvider, SIGNAL(loggedIn()), SLOT(loginDone()));
    connect(serviceProvider, SIGNAL(loginFailed(QString)), SLOT(loginFailed()));

    initialize();
}
Example #11
0
    void Display::login(QLocalSocket *socket, const QString &user, const QString &password, const QString &session) {
        // authenticate
        if (!m_authenticator->authenticate(user, password)) {
            // emit signal
            emit loginFailed(socket);

            // return
            return;
        }

        // start session
        if (!m_authenticator->start(user, session)) {
            // emit signal
            emit loginFailed(socket);

            // return
            return;
        }

        // save last user and last session
        Configuration::instance()->setLastUser(user);
        Configuration::instance()->setLastSession(session);
        Configuration::instance()->save();

        // emit signal
        emit loginSucceeded(socket);

        // wait until session ends
        m_authenticator->waitForFinished();

        // stop
        stop();

        // restart display
        QTimer::singleShot(1, this, SLOT(start()));
    }
Example #12
0
void Pastebin::onLoginFinished() {
    QNetworkReply *networkReply = qobject_cast<QNetworkReply *>(sender());
    QVariant statusCode = networkReply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
    qDebug() << "Login complete:" << statusCode.toInt();

    if(networkReply->error() == QNetworkReply::NoError) {
        QString response = networkReply->readAll();

        qDebug() << "Response:" << response;

        if(response.startsWith("Bad API request")) {
            emit loginFailed(response);
        }
        else {
            QNetworkRequest networkRequest = networkReply->request();

            emit loginComplete(response);
        }
    }
    else {
        qWarning() << "Error:" << networkReply->errorString();
        emit loginFailed(QString::null);
    }
}
Example #13
0
void MainWindow::doLogin ( QString inst, const QString& errorMsg )
{
	LoginDialog* loginDlg = new LoginDialog ( this, errorMsg );
	if ( loginDlg->exec() )
	{
		UserInfo uInfo ( loginDlg->getUsername(), loginDlg->getPassword() );

		TaskDialog* tDialog = new TaskDialog ( this );
		LoginTask* loginTask = new LoginTask ( uInfo, inst, tDialog );
		connect ( loginTask, SIGNAL ( loginComplete ( QString, LoginResponse ) ),
		          SLOT ( onLoginComplete ( QString, LoginResponse ) ), Qt::QueuedConnection );
		connect ( loginTask, SIGNAL ( loginFailed ( QString, QString ) ),
		          SLOT ( onLoginFailed( QString, QString ) ), Qt::QueuedConnection );
		tDialog->exec ( loginTask );
	}
}
Example #14
0
void AuthControler::_loginResult(service::ErrorInfo &info, long long userId)
{
    qDebug() << Q_FUNC_INFO << info.code() << userId;
    if(info.code() == 0 )
    {
        QString fileName = LinkDoodService::instance()->dataPath()+ "config.ini";
        QSettings settings(fileName, QSettings::IniFormat);
        settings.setValue("myId",QString::number(userId));
        emit loginSucceeded(QString::number(userId));

        emit loginResultObserver(0,QString::number(userId));
    }
    else
    {
        qDebug() << Q_FUNC_INFO << "loginFailed = " << info.code();
        emit loginFailed(info.code());
    }
}
Example #15
0
    void Display::login(QLocalSocket *socket, const QString &user, const QString &password, const QString &session) {
        // start session
        if (!m_authenticator->start(user, password, session)) {
            // emit signal
            emit loginFailed(socket);

            // return
            return;
        }

        // save last user and last session
        daemonApp->configuration()->setLastUser(user);
        daemonApp->configuration()->setLastSession(session);
        daemonApp->configuration()->save();

        // emit signal
        emit loginSucceeded(socket);
    }
void QDiscordWsComponent::error_(QAbstractSocket::SocketError err)
{
	emit error(err);
	if(_tryReconnecting)
	{
		QTimer::singleShot(_reconnectTime,
						   this, &QDiscordWsComponent::reconnect);
	}
	else
	{
		_token = "";
		_gateway = "";
		emit loginFailed();

#ifdef QDISCORD_LIBRARY_DEBUG
		qDebug()<<this<<"login failed: "<<err;
#endif
	}
}
Example #17
0
    void Display::slotAuthenticationFinished(const QString &user, bool success) {
        if (success) {
            qDebug() << "Authenticated successfully";

            m_auth->setCookie(qobject_cast<XorgDisplayServer *>(m_displayServer)->cookie());

            // save last user and last session
            stateConfig.Last.User.set(m_auth->user());
            stateConfig.Last.Session.set(m_sessionName);
            stateConfig.save();

            if (m_socket)
                emit loginSucceeded(m_socket);
        } else if (m_socket) {
            qDebug() << "Authentication failure";
            emit loginFailed(m_socket);
        }
        m_socket = nullptr;
    }
Example #18
0
void ClientSyncer::coreHasData() {
  QVariant item;
  while(SignalProxy::readDataFromDevice(_socket, _blockSize, item)) {
    emit recvPartialItem(1,1);
    QVariantMap msg = item.toMap();
    if(!msg.contains("MsgType")) {
      // This core is way too old and does not even speak our init protocol...
      emit connectionError(tr("The Quassel Core you try to connect to is too old! Please consider upgrading."));
      disconnectFromCore();
      return;
    }
    if(msg["MsgType"] == "ClientInitAck") {
      clientInitAck(msg);
    } else if(msg["MsgType"] == "ClientInitReject") {
      emit connectionError(msg["Error"].toString());
      disconnectFromCore();
      return;
    } else if(msg["MsgType"] == "CoreSetupAck") {
      emit coreSetupSuccess();
    } else if(msg["MsgType"] == "CoreSetupReject") {
      emit coreSetupFailed(msg["Error"].toString());
    } else if(msg["MsgType"] == "ClientLoginReject") {
      emit loginFailed(msg["Error"].toString());
    } else if(msg["MsgType"] == "ClientLoginAck") {
      // prevent multiple signal connections
      disconnect(this, SIGNAL(recvPartialItem(quint32, quint32)), this, SIGNAL(sessionProgress(quint32, quint32)));
      connect(this, SIGNAL(recvPartialItem(quint32, quint32)), this, SIGNAL(sessionProgress(quint32, quint32)));
      emit loginSuccess();
    } else if(msg["MsgType"] == "SessionInit") {
      sessionStateReceived(msg["SessionState"].toMap());
      break; // this is definitively the last message we process here!
    } else {
      emit connectionError(tr("<b>Invalid data received from core!</b><br>Disconnecting."));
      disconnectFromCore();
      return;
    }
  }
  if(_blockSize > 0) {
    emit recvPartialItem(_socket->bytesAvailable(), _blockSize);
  }
}
Example #19
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    t = new QtTelnet;

    connect(t, SIGNAL(message(const QString &)),
                   this, SLOT(telnetMessage(const QString &)));
    connect(t, SIGNAL(loginRequired()),
                    this, SLOT(telnetLoginRequired()));
    connect(t, SIGNAL(loginFailed()),
                    this, SLOT(telnetLoginFailed()));
    connect(t, SIGNAL(loggedOut()),
                   this, SLOT(telnetLoggedOut()));
    connect(t, SIGNAL(loggedIn()),
                   this, SLOT(telnetLoggedIn()));
    connect(t, SIGNAL(connectionError(QAbstractSocket::SocketError)),
                    this, SLOT(telnetConnectionError(QAbstractSocket::SocketError)));

}
Example #20
0
    void Display::slotAuthenticationFinished(const QString &user, bool success) {
        if (success) {
            qDebug() << "Authenticated successfully";

            struct passwd *pw = getpwnam(qPrintable(user));
            if (pw) {
                qobject_cast<XorgDisplayServer *>(m_displayServer)->addCookie(QString("%1/.Xauthority").arg(pw->pw_dir));
                chown(qPrintable(QString("%1/.Xauthority").arg(pw->pw_dir)), pw->pw_uid, pw->pw_gid);
            }

            // save last user and last session
            stateConfig.Last.User.set(m_auth->user());
            stateConfig.Last.Session.set(m_sessionName);
            stateConfig.save();

            if (m_socket)
                emit loginSucceeded(m_socket);
        } else if (m_socket) {
            qDebug() << "Authentication failure";
            emit loginFailed(m_socket);
        }
        m_socket = nullptr;
    }
void
SpotifySettingsDialog::slotTryLogin()
{
    DEBUG_BLOCK
    Spotify::Controller* controller = The::SpotifyController();

    Q_ASSERT( controller );

    if( !controller->running() || !controller->loaded() )
    {
        controller->setFilePath( Collections::SpotifyCollection::resolverPath() );
        controller->start();
    }

    connect(controller, SIGNAL(customMessage(QString,QVariantMap)),
                        SLOT(slotCustomMessage(QString,QVariantMap)));
    connect(controller, SIGNAL(loginSuccess(QString)), SLOT(slotLoginSuccess(QString)));
    connect(controller, SIGNAL(loginFailed(QString)), SLOT(slotLoginFailed(QString)));

    controller->login( m_settingsWidget->lineUsername->text(),
                       m_settingsWidget->linePassword->text(),
                       m_settingsWidget->checkHighQuality->isChecked() );
    save();
}
Example #22
0
void Client::clientDisconnected()
{
    qDebug() << "Client has disconnected server.";
    QTimer::singleShot(0, this, SIGNAL( loginFailed() ));
}
Example #23
0
Application::Application(int & argc, char ** argv) :
    QAPP(argc, argv)
{
    HardwareUtils::Instance()->setParent(this);

    connect(HardwareUtils::Instance(), SIGNAL(networkStatusChanged()),
            this, SLOT(networkStatusChanged()));

    connect(HardwareUtils::Instance(), &HardwareUtils::applicationWillResignActive, [=]()
    {
        qDebug() << "Application is in background, logout";
        startedWithOptHandled = false;
        logout();
    });

    connect(HardwareUtils::Instance(), &HardwareUtils::applicationBecomeActive, [=]()
    {
        qDebug() << "Application is in foreground, login again";
        QTimer::singleShot(0, [=]()
        {
            login(get_username(), get_password(), get_hostname());
        });
    });

    QCoreApplication::setOrganizationName("Calaos");
    QCoreApplication::setOrganizationDomain("calaos.fr");
    QCoreApplication::setApplicationName("CalaosHome");

    Common::registerQml();

#ifdef Q_OS_ANDROID
    QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;");
    QAndroidJniObject resource = activity.callObjectMethod("getResources","()Landroid/content/res/Resources;");
    QAndroidJniObject metrics = resource.callObjectMethod("getDisplayMetrics","()Landroid/util/DisplayMetrics;");
    update_density(metrics.getField<float>("density"));

    update_needBackButton(false);
    // Need to fix a bug on Android where text is scratched at runtime on some devices
    qputenv("QML_USE_GLYPHCACHE_WORKAROUND", QByteArray("1"));

    update_isAndroid(true);
    update_isIOS(false);
    update_isDesktop(false);
#else
    if (arguments().contains("--force-hdpi"))
        update_density(2.0);
    else
        update_density(1.0);

    update_needBackButton(true);

#ifdef Q_OS_IOS
    update_isAndroid(false);
    update_isIOS(true);
    update_isDesktop(false);
#else
    update_isAndroid(false);
    update_isIOS(false);
    update_isDesktop(true);
#endif
#endif

    loadSettings();

    update_applicationStatus(Common::NotConnected);

    calaosConnect = new CalaosConnection(this);
    connect(calaosConnect, SIGNAL(homeLoaded(QVariantMap)),
            this, SLOT(homeLoaded(QVariantMap)));
    connect(calaosConnect, SIGNAL(loginFailed()),
            this, SLOT(loginFailed()));
    connect(calaosConnect, &CalaosConnection::disconnected, [=]()
    {
        update_applicationStatus(Common::NotConnected);
    });

    scenarioModel = new ScenarioModel(&engine, calaosConnect, this);
    scenarioSortModel = new ScenarioSortModel(&engine, this);
    scenarioSortModel->setSourceModel(scenarioModel);
    engine.rootContext()->setContextProperty("scenarioModel", scenarioSortModel);
    lightOnModel = new LightOnModel(&engine, calaosConnect, this);
    engine.rootContext()->setContextProperty("lightOnModel", lightOnModel);
    homeModel = new HomeModel(&engine, calaosConnect, scenarioModel, lightOnModel, this);
    engine.rootContext()->setContextProperty("homeModel", homeModel);
    audioModel = new AudioModel(&engine, calaosConnect, this);
    engine.rootContext()->setContextProperty("audioModel", audioModel);
    favModel = new FavoritesModel(&engine, calaosConnect, this);
    engine.rootContext()->setContextProperty("favoritesModel", favModel);
    favHomeModel = new HomeFavModel(&engine, calaosConnect, this);
    engine.rootContext()->setContextProperty("favoritesHomeModel", favHomeModel);
    cameraModel = new CameraModel(&engine, calaosConnect);
    engine.rootContext()->setContextProperty("cameraModel", cameraModel);

    engine.rootContext()->setContextProperty("calaosApp", this);
    engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));

    //Start autologin
    QTimer::singleShot(100, [=]()
    {
        login(get_username(), get_password(), get_hostname());
    });
}
Example #24
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
	ui->setupUi(this);
	setWindowIcon(QIcon(":icon.ico"));

	MainWindow::appPath = qApp->applicationDirPath();

	loadStyle();

	// member initialization
	dockWidget	 = new DockWidget;
	calWidget	= new BrowserWidget;
	crmWidget   = new BrowserWidget;

	toolBar		= new QToolBar(tr("Aktionen"));
	accountList = new AccountList(this);
	contactList = new ContactList(this);
	mainLayout	= new QStackedLayout();
	settings	= SugarSettings::getInstance();
	settingsDialog = new SettingsDialog;

	addDockWidget(Qt::BottomDockWidgetArea, dockWidget);
	dockWidget->hide();
	accountList->hide();
	calWidget->setAddress(QUrl(settings->calendarUrl));
	crmWidget->setAddress(QUrl(settings->crmUrl));
	mainLayout->addWidget(accountList);
	mainLayout->addWidget(contactList);
	//mainLayout->addWidget(projectList);
	mainLayout->addWidget(calWidget);
	mainLayout->addWidget(crmWidget);
	mainLayout->addWidget(settingsDialog);

	toolBar->setIconSize(QSize(14, 14));
	toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
	toolBar->setMovable(false);

	QAction *accountsAct = new QAction(QIcon(":accounts.png"), tr("Firmen"), this);
	QAction *contactsAct = new QAction(QIcon(":contacts.png"), tr("Kontakte"), this);
	QAction *projectsAct = new QAction(QIcon(":projects.png"), tr("Projekte"), this);
	openCalAct			 = new QAction(QIcon(":calendar.png"), tr("Kalender"), this);
	openCrmAct			 = new QAction(QIcon(":calendar.png"), tr("SugarCrm"), this);

	addAccountAct			= new QAction(QIcon(":add-account.png"), tr("Neue Firma"), this);
	QAction *addContactAct	= new QAction(QIcon(":add-contact.png"), tr("Neuer Kontakt"), this);
	QAction *addProjectAct	= new QAction(QIcon(":add-project.png"), tr("Neues Projekt"), this);
	QAction *addTaskAct		= new QAction(QIcon(":add-task.png"),    tr("Neue Aufgabe"), this);
	pressViewAct			= new QAction(QIcon(":news.png"), tr("Pressekontakte"), this);

	connect(addAccountAct, SIGNAL(triggered()),
			this, SLOT(addAccount()));
	connect(openCalAct, SIGNAL(triggered()),
			this, SLOT(displayCalendar()));
	connect(openCrmAct, SIGNAL(triggered()),
			this, SLOT(displayCrm()));
	//connect(pressViewAct, SIGNAL(triggered()),
	//		this, SLOT(displayPressList()));
	connect(accountsAct, SIGNAL(triggered()),
			this, SLOT(displayAccounts()));
	connect(contactsAct, SIGNAL(triggered()),
			this, SLOT(displayContacts()));

	toolBar->addWidget(new QLabel(tr("Ansichten")));
	toolBar->addAction(accountsAct);
	toolBar->addAction(contactsAct);
	toolBar->addAction(projectsAct);
	toolBar->addAction(openCalAct);
	toolBar->addAction(openCrmAct);
	toolBar->addWidget(new QLabel(tr("Aktionen")));
	// TODO: fix this
	toolBar->addAction(addAccountAct);
	toolBar->addAction(addContactAct);
	toolBar->addAction(addProjectAct);
	toolBar->addAction(addTaskAct);
	//toolBar->addAction(pressViewAct);

	addToolBar(Qt::LeftToolBarArea, toolBar);
	toolBar->hide();

	QPushButton *loginBtn = new QPushButton(QIcon(":login.png"), tr("Login"), this);
	connect(loginBtn, SIGNAL(pressed()),
			this, SLOT(login()));
	QGridLayout *l = new QGridLayout(this);
	QWidget *c = new QWidget(this);
	QWidget *w = new QWidget(this);

	l->addWidget(loginBtn, 1, 1, Qt::AlignCenter);
	c->setLayout(l);
	mainLayout->addWidget(c);
	mainLayout->setCurrentWidget(c);
	w->setLayout(mainLayout);
	setCentralWidget(w);

	// initialize dialogs
	loadingDialog = new LoadingDialog(this);
	loginDialog   = new LoginDialog(this);
	loadingDialog->setVisible(false);
	loginDialog->setVisible(false);

	crm = SugarCrm::getInstance();
	accountModel = AccountModel::getInstance();
	contactModel = ContactModel::getInstance();

	accountsFilterModel = new AccountProxyModel(this);
	contactsFilterModel = new ContactProxyModel(this);

	//filterModel = new AccountProxyModel(this);
	//filterModel->setSourceModel(accountModel);

	accountsFilterModel->setSourceModel(accountModel);
	contactsFilterModel->setSourceModel(contactModel);

	restoreGeometry(settings->windowGeometry);

	// QML display
	//centerView = new QmlView(this);

	//centerView->setUrl(QUrl("SugarCrm.qml"));
	//centerView->setAttribute(Qt::WA_OpaquePaintEvent);
	//centerView->setAttribute(Qt::WA_NoSystemBackground);
	//centerView->setFocus();

	//contx = centerView->rootContext();
	//contx->addDefaultObject(this);
	//contx->setContextProperty("qmlViewer", this);
	//contx->setContextProperty("accountModel", proxyModel);

	// connecting ui actions
	connect(ui->actionLogin, SIGNAL(triggered()),
			this, SLOT(login()));
	connect(ui->actionEinstellungen, SIGNAL(triggered()),
			this, SLOT(displaySettings()));
	connect(ui->actionLogout, SIGNAL(triggered()),
			qApp, SLOT(quit()));
	connect(ui->actionServer_Zeit, SIGNAL(triggered()),
			crm, SLOT(getServerTime()));
	connect(ui->actionSugarFlavor, SIGNAL(triggered()),
			crm, SLOT(getSugarFlavor()));
	connect(ui->actionReloadStyle, SIGNAL(triggered()),
			this, SLOT(loadStyle()));
	connect(ui->actionAboutQt, SIGNAL(triggered()),
			qApp, SLOT(aboutQt()));
	connect(ui->actionWebsite, SIGNAL(triggered()),
			this, SLOT(openProjectHomepage()));
	connect(ui->actionSpenden, SIGNAL(triggered()),
			this, SLOT(openDonationWebsite()));
	connect(qApp, SIGNAL(aboutToQuit()),
			this, SLOT(cleanup()));

	// DEBUG XML COMMUNICATION
	//connect(crm, SIGNAL(sendingMessage(QString)),
	//		this, SLOT(debug(QString)));
	//connect(crm->trans, SIGNAL(newSoapMessage(QString)),
	//		this, SLOT(debug(QString)));

	connect(crm, SIGNAL(unknownAction(QString)),
			this, SLOT(unknownAction(QString)));

	// login response
	connect(crm, SIGNAL(loginFailed()),
			this, SLOT(loginResponse()));

	connect(crm, SIGNAL(loginSuccessful()),
			this, SLOT(loginResponse()));

	// soap error handling
	// TODO: improve!
	connect(crm, SIGNAL(returnedFaultyMessage(QString)),
			loadingDialog, SLOT(hide()));

	connect(crm, SIGNAL(returnedFaultyMessage(QString)),
			this, SLOT(setStatusMsg(QString)));

	connect(accountModel, SIGNAL(dataReady()),
			this, SLOT(displayAccounts()));

	//TODO: change this when it works
	//setCentralWidget(centerView);
	//centerView->execute();

	//rootComponent = centerView->root();
	//QVariant *tmp = new QVariant(contx->property("authView"));
	//QmlComponent authComponent((QObject *) tmp);  // centerView->engine(), QUrl("content/AuthView.qml"));
	//authView = authComponent.create(contx);
	//qDebug() << authView->dynamicPropertyN();

	//connect(rootComponent, SIGNAL(loggingIn()),
	//		this, SLOT(login()));
	//connect(rootComponent, SIGNAL(searching()),
	//		this, SLOT(doSearch()));
	/*connect(accountModel, SIGNAL(dataReady()),
			this, SLOT(assignData()));
	connect(this, SIGNAL(listReady()),
			rootComponent, SLOT(displayAccounts()));*/
	//connect(accountModel, SIGNAL(dataReady()),
	//		rootComponent, SLOT(displayAccounts()));

	setStatusMsg(tr("Bereit"), 2500);
}
Example #25
0
doubanFM::doubanFM(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::doubanFM)
{
    qDebug() << Q_FUNC_INFO;
    ui->setupUi(this);


    currentSongIndex = 0;
    pauseState = false;

    _channelListWidget = new channelList(this);
    _channelListWidget->setchannelId(currentChannelId);
    _channelListWidget->move(-_channelListWidget->getInvisibleWidth(),this->geometry().y());

    _pauseMaskWidget = new pauseMaskWidget(this);
    _pauseMaskWidget->move(250,0);
    _pauseMaskWidget->setVisible(false);


    _loginwidget = new doubanLogin(this);
    _loginwidget->move(this->geometry().x(),-_loginwidget->geometry().height());

    _mediaObject = new Phonon::MediaObject(this);
    _audioOutput = new Phonon::AudioOutput(this);
    Phonon::createPath(_mediaObject,_audioOutput);
    ui->seekSlider->setMediaObject(_mediaObject);


    albumImageManager = new QNetworkAccessManager(this);
    _mydouban = new Douban(this);

    readSettings();
    qDebug() << "read setting" << _mydouban->hasLogin();
    if(_mydouban->hasLogin())
    {
        ui->userLoginButton->setToolTip(tr("click to logout"));
        ui->userLabel->setText(_mydouban->getDoubanUser().name);
    }
    else
    {
        ui->userLoginButton->setToolTip(tr("click to login"));
        ui->userLabel->setText(tr("Logout"));
    }

    nextShortCut = new QxtGlobalShortcut(QKeySequence("Alt+s"),this);
    pauseShortCut = new QxtGlobalShortcut(QKeySequence("Alt+p"),this);
    rateShortCut = new QxtGlobalShortcut(QKeySequence("Alt+r"),this);
    trashShortCut = new QxtGlobalShortcut(QKeySequence("Alt+t"),this);

    connect(nextShortCut,SIGNAL(activated()),this,SLOT(onSkipButtonClicked()));
    connect(pauseShortCut,SIGNAL(activated()),this,SLOT(onPauseButtonClicked()));
    connect(rateShortCut,SIGNAL(activated()),this,SLOT(onRateButtonClicked()));
    connect(trashShortCut,SIGNAL(activated()),this,SLOT(onTrashButtonClicked()));


    //connect the mainwidget signals and the slots
    connect(ui->volumeSlider,SIGNAL(valueChanged(int)),this,SLOT(onVolumneChange(int)));
    connect(ui->pauseButton,SIGNAL(clicked()),this,SLOT(onPauseButtonClicked()));
    connect(ui->userLoginButton,SIGNAL(clicked()),this,SLOT(onLoginButtonClicked()));
    connect(_mediaObject,SIGNAL(tick(qint64)),this,SLOT(playTick(qint64)));
    connect(albumImageManager,SIGNAL(finished(QNetworkReply*)),this,SLOT(receiveAlbumImage(QNetworkReply*)));
    connect(this,SIGNAL(albumImageRequest(QString)),this,SLOT(onAlbumImage(QString)));
    connect(ui->rateSongButton,SIGNAL(clicked()),this,SLOT(onRateButtonClicked()));
    connect(ui->nextSongButton,SIGNAL(clicked()),this,SLOT(onSkipButtonClicked()));
    connect(ui->byeSongButton,SIGNAL(clicked()),this,SLOT(onTrashButtonClicked()));
    connect(_mediaObject,SIGNAL(currentSourceChanged(Phonon::MediaSource)),this,SLOT(sourceChanged(Phonon::MediaSource)));
    connect(_mediaObject,SIGNAL(stateChanged(Phonon::State,Phonon::State)),this,SLOT(stateChanged(Phonon::State,Phonon::State)));

//    connect the mainwidget signals and the slots of other widget
    connect(this,SIGNAL(sendlogoutRequest()),_mydouban,SLOT(logoutRequest()));
    connect(this,SIGNAL(sendSongListRequest(qint32,quint32,double)),_mydouban,SLOT(newSongListRequest(qint32,quint32,double)));
    connect(this,SIGNAL(sendSkipSongRequest(qint32,quint32,double)),_mydouban,SLOT(skipSongRequest(qint32,quint32,double)));
    connect(this,SIGNAL(sendRateSongRequest(qint32,quint32,double,bool)),_mydouban,SLOT(rateSongRequest(qint32,quint32,double,bool)));
    connect(this,SIGNAL(sendEndSongRequest(qint32,quint32,double)),_mydouban,SLOT(endSongRequest(qint32,quint32,double)));
    connect(this,SIGNAL(sendByeSongRequest(qint32,quint32,double)),_mydouban,SLOT(byeSongRequest(qint32,quint32,double)));

//  connect the signals of other widget and the mainwidget slot
    connect(_mydouban,SIGNAL(loginSucceed(DoubanUser)),this,SLOT(loginSucceed(DoubanUser)));
    connect(_mydouban,SIGNAL(sendSongList(QList<DoubanFMSong>)),this,SLOT(receiveSongList(QList<DoubanFMSong>)));
    connect(_mydouban,SIGNAL(sendRateSong(bool)),this,SLOT(receiveRateSong(bool)));
    connect(_mydouban,SIGNAL(sendSkipSong(bool)),this,SLOT(receiveSkipSong(bool)));
    connect(_mydouban,SIGNAL(sendByeSong(bool)),this,SLOT(receiveByeSong(bool)));
    connect(_mydouban,SIGNAL(sendEndSong(bool)),this,SLOT(receiveEndSong(bool)));
    connect(_mydouban,SIGNAL(sendChannelList(QList<DoubanChannel>,bool)),this,SLOT(receiveChannelList(QList<DoubanChannel>,bool)));
    connect(_mydouban,SIGNAL(sendLogoutSucceed(bool)),this,SLOT(logoutSucceed(bool)));
    connect(_pauseMaskWidget,SIGNAL(mousePressed()),this,SLOT(pauseMaskWidgetPressed()));
    connect(_channelListWidget,SIGNAL(channelChanged(qint32)),this,SLOT(receiveChannelChange(qint32)));


    //connect the other widget signal and slots
    connect(_mydouban,SIGNAL(captchaImageLoad(QPixmap)),_loginwidget,SLOT(onCaptchaImageLoad(QPixmap)));
    connect(_mydouban,SIGNAL(loginFailed(QString)),_loginwidget,SLOT(onLoginFailed(QString)));
    connect(_mydouban,SIGNAL(sendChannelList(QList<DoubanChannel>,bool)),_channelListWidget,SLOT(onReceiveChannelList(QList<DoubanChannel>,bool)));
    connect(_loginwidget,SIGNAL(loginRequest(QString,QString,QString)),_mydouban,SLOT(loginRequest(QString,QString,QString)));

    _mydouban->channelListRequest();
}
void NXClientLib::failedLogin()
{
	emit loginFailed();
	nxsshProcess.terminate();
}
void LoginDialog::onFetchAccountInfoFailed(const ApiError& error)
{
    loginFailed(error);
}
Example #28
0
void Application::createQmlApp()
{
    loadSettings();

    engine.addImportPath("qrc:/qml/");

    connect(HardwareUtils::Instance(), SIGNAL(networkStatusChanged()),
            this, SLOT(networkStatusChanged()));
    connect(HardwareUtils::Instance(), SIGNAL(calaosServerDetected()),
            this, SLOT(calaosServerDetected()));

    connect(HardwareUtils::Instance(), &HardwareUtils::applicationWillResignActive, [=]()
    {
        qDebug() << "Application is in background, logout";
        startedWithOptHandled = false;
        logout();
    });

    connect(HardwareUtils::Instance(), &HardwareUtils::applicationBecomeActive, [=]()
    {
        qDebug() << "Application is in foreground, login again";
        QTimer::singleShot(0, [=]()
        {
            login(get_username(), get_password(), get_hostname());
        });
    });

    Common::registerQml();

#ifdef Q_OS_ANDROID
    QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;");
    QAndroidJniObject resource = activity.callObjectMethod("getResources","()Landroid/content/res/Resources;");
    QAndroidJniObject metrics = resource.callObjectMethod("getDisplayMetrics","()Landroid/util/DisplayMetrics;");
    update_density(metrics.getField<float>("density"));

    update_needBackButton(false);
    // Need to fix a bug on Android where text is scratched at runtime on some devices
    qputenv("QML_USE_GLYPHCACHE_WORKAROUND", QByteArray("1"));

    update_isAndroid(true);
    update_isIOS(false);
    update_isDesktop(false);
#else
    if (arguments().contains("--force-hdpi"))
        update_density(2.0);
    else
        update_density(1.0);

    update_needBackButton(true);

#ifdef Q_OS_IOS
    update_isAndroid(false);
    update_isIOS(true);
    update_isDesktop(false);
#else
    update_isAndroid(false);
    update_isIOS(false);
    update_isDesktop(true);
#endif
#endif

    update_applicationStatus(Common::NotConnected);

    calaosConnect = new CalaosConnection(this);
    connect(calaosConnect, SIGNAL(homeLoaded(QVariantMap)),
            this, SLOT(homeLoaded(QVariantMap)));
    connect(calaosConnect, SIGNAL(loginFailed()),
            this, SLOT(loginFailed()));
    connect(calaosConnect, &CalaosConnection::disconnected, [=]()
    {
        update_applicationStatus(Common::NotConnected);

#ifdef CALAOS_DESKTOP
        HardwareUtils::Instance()->showAlertMessage(tr("Network error"),
                                                    tr("The connection to calaos_server was lost."
                                                       "It will reconnect automatically when calaos_server"
                                                       "is available again."),
                                                    tr("Close"));

        //restart autologin, only on desktop to continually try to connect
        QTimer::singleShot(1000, [=]()
        {
            //reload settings in case it was changed
            loadSettings();
            login(get_username(), get_password(), get_hostname());
        });
#endif
    });

    scenarioModel = new ScenarioModel(&engine, calaosConnect, this);
    scenarioSortModel = new ScenarioSortModel(&engine, this);
    scenarioSortModel->setSourceModel(scenarioModel);
    engine.rootContext()->setContextProperty("scenarioModel", scenarioSortModel);
    lightOnModel = new LightOnModel(&engine, calaosConnect, this);
    engine.rootContext()->setContextProperty("lightOnModel", lightOnModel);
    homeModel = new HomeModel(&engine, calaosConnect, scenarioModel, lightOnModel, this);
    engine.rootContext()->setContextProperty("homeModel", homeModel);
    audioModel = new AudioModel(&engine, calaosConnect, this);
    engine.rootContext()->setContextProperty("audioModel", audioModel);
    favModel = new FavoritesModel(&engine, calaosConnect, this);
    engine.rootContext()->setContextProperty("favoritesModel", favModel);
    favHomeModel = new HomeFavModel(&engine, calaosConnect, this);
    engine.rootContext()->setContextProperty("favoritesHomeModel", favHomeModel);
    cameraModel = new CameraModel(&engine, calaosConnect);
    engine.rootContext()->setContextProperty("cameraModel", cameraModel);

#ifdef CALAOS_DESKTOP
    CalaosWidgetModel::Instance()->loadFromDisk();
    engine.rootContext()->setContextProperty("widgetsModel", CalaosWidgetModel::Instance());
#endif

    engine.rootContext()->setContextProperty("calaosApp", this);

    //Register Units singleton
    //qmlRegisterSingletonType(QUrl("qrc:/qml/Units.qml"), "Units", 1, 0, "Units");

    qmlRegisterType<RoomFilterModel>("Calaos", 1, 0, "RoomFilterModel");

#if defined(CALAOS_MOBILE)
    engine.load(QUrl(QStringLiteral("qrc:///qml/mobile/main.qml")));
#elif defined(CALAOS_DESKTOP)
    engine.load(QUrl(QStringLiteral("qrc:///qml/desktop/main.qml")));
#else
#error "Unknown UI type!"
#endif

#ifndef CALAOS_DESKTOP
    //Start autologin, only on mobile. On desktop we wait for calaos_server detection
    QTimer::singleShot(100, [=]()
    {
        login(get_username(), get_password(), get_hostname());
    });
#endif
}
Example #29
0
void LoginWidget::login(){
	qDebug() << "LoginWidget::login# Login button submited " << endl;
	connect(loginService,SIGNAL(loginFailed()),this,SLOT(loginFailed()));
	connect(loginService,SIGNAL(loginSuccesful(PokerPlayerModel*)),this,SLOT(loginSuccesful(PokerPlayerModel*)));
    loginService->login(loginEdit->text(),passwordEdit->text());
}
Example #30
0
    void GreeterProxy::readyRead() {
        // input stream
        QDataStream input(d->socket);

        while (input.device()->bytesAvailable()) {
            // read message
            quint32 message;
            input >> message;

            switch (DaemonMessages(message)) {
                case DaemonMessages::Capabilities: {
                    // log message
                    qDebug() << "Message received from daemon: Capabilities";

                    // read capabilities
                    quint32 capabilities;
                    input >> capabilities;

                    // parse capabilities
                    d->canPowerOff = capabilities & Capability::PowerOff;
                    d->canReboot = capabilities & Capability::Reboot;
                    d->canSuspend = capabilities & Capability::Suspend;
                    d->canHibernate = capabilities & Capability::Hibernate;
                    d->canHybridSleep = capabilities & Capability::HybridSleep;

                    // emit signals
                    emit canPowerOffChanged(d->canPowerOff);
                    emit canRebootChanged(d->canReboot);
                    emit canSuspendChanged(d->canSuspend);
                    emit canHibernateChanged(d->canHibernate);
                    emit canHybridSleepChanged(d->canHybridSleep);
                }
                break;
                case DaemonMessages::HostName: {
                    // log message
                    qDebug() << "Message received from daemon: HostName";

                    // read host name
                    input >> d->hostName;

                    // emit signal
                    emit hostNameChanged(d->hostName);
                }
                break;
                case DaemonMessages::LoginSucceeded: {
                    // log message
                    qDebug() << "Message received from daemon: LoginSucceeded";

                    // emit signal
                    emit loginSucceeded();
                }
                break;
                case DaemonMessages::LoginFailed: {
                    // log message
                    qDebug() << "Message received from daemon: LoginFailed";

                    // emit signal
                    emit loginFailed();
                }
                break;
                default: {
                    // log message
                    qWarning() << "Unknown message received from daemon.";
                }
            }
        }
    }