Exemple #1
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
        daemonApp->configuration()->setLastUser(user);
        daemonApp->configuration()->setLastSession(session);
        daemonApp->configuration()->save();

        // emit signal
        emit loginSucceeded(socket);
    }
Exemple #2
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
            if (mainConfig.Users.RememberLastUser.get())
                stateConfig.Last.User.set(m_auth->user());
            else
                stateConfig.Last.User.setDefault();
            if (mainConfig.Users.RememberLastSession.get())
                stateConfig.Last.Session.set(m_sessionName);
            else
                stateConfig.Last.Session.setDefault();
            stateConfig.save();

            // switch to the new VT for Wayland sessions
            if (m_lastSession.xdgSessionType() == QLatin1String("wayland"))
                VirtualTerminal::jumpToVt(m_lastSession.vt());

            if (m_socket)
                emit loginSucceeded(m_socket);
        } else if (m_socket) {
            qDebug() << "Authentication failure";
            emit loginFailed(m_socket);
        }
        m_socket = nullptr;
    }
void LoginPresenter::loggedIn(const void *sender, Poco::EventArgs &args)
{
    // The user has logged in, so tell the view to appear that way.
    m_view->showStatus(Mvp::View::AbstractLoginView::LoggedIn);

    // Emit poco signal so the state can do it's work to create a new IdleState.
    loginSucceeded(this, args);
}
Exemple #4
0
void LoginForm::handleChange(QUrl url){
    qDebug() << url;
    QString strUrl = url.toEncoded();
    if (strUrl.startsWith(REDIRECT_URL))
    {
        emit loginSucceeded();
        close();
    }
}
Exemple #5
0
void LoginWindow::attemptLoginSuccess( QString username, QString password, int minutes, int hold_items_count ) {
    qDebug("LoginWindow::attemptLoginSuccess");
    resetLoginScreen();

    emit loginSucceeded( username, password, minutes, hold_items_count );
    this->hide();

    isHidden = true;
}
Exemple #6
0
void LoginForm::consoleMessage(QString error)
{
    qDebug() << error;
    if (error.contains("Not allowed to load local resource") && error.contains(REDIRECT_URL))
    {
        emit loginSucceeded();
        close();
    }
}
Exemple #7
0
void SignUpForm::gotTokenUrl(QUrl url)
{
    settings->setConsumerKey(ui->lineEditKey->text());
    settings->setSharedSecret(ui->lineEditSharedSecret->text());
    settings->setApplicationName(ui->lineEditApplicationName->text());

    url.addQueryItem(STR(OAUTH_CONSUMER_KEY),ui->lineEditKey->text());

    qDebug() << url.toEncoded();
    if (loginForm != NULL)
    {
        loginForm->setParent(NULL);
        delete loginForm;
    }

    loginForm = new LoginForm(url,this);
    connect(loginForm,SIGNAL(loginSucceeded()),this,SLOT(loginSucceeded()));
    loginForm->show();
}
Exemple #8
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());
    }
}
Exemple #9
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;
    }
Exemple #10
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;
    }
Exemple #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()));
    }
void LinkDoodService::initConnects()
{
    qDebug() << Q_FUNC_INFO ;

    QObject::connect(m_pChatObserver.get(),SIGNAL(avatarChangedBack(int64,QString)),this,
                     SLOT(onChatAvatarChanged(int64,QString)));
    QObject::connect(m_pChatObserver.get(),SIGNAL(offlineMsgNoticeBack(IMOfflineMsgList)),this,
                     SLOT(onChatOfflineMsgNotice(IMOfflineMsgList)));
    QObject::connect(m_pChatObserver.get(),SIGNAL(sendMessageBack(bool,int64,int64)),this,
                     SLOT(onChatSendMessageResult(bool,int64,int64)));
    QObject::connect(m_pChatObserver.get(),SIGNAL(getMessagesBack(bool,int64,MsgList)),this,
                     SLOT(onChatGetMessagesResult(bool,int64,MsgList)));
    QObject::connect(m_pChatObserver.get(),SIGNAL(removeChatBack(bool)),this,
                     SLOT(onChatRemoveChatResult(bool)));
    QObject::connect(m_pChatObserver.get(),SIGNAL(chatMessageNotice(Msg)),this,
                     SLOT(onChatMessageNotice(Msg)));
    QObject::connect(m_pChatObserver.get(),SIGNAL(sessionMessageNotice(QString,QString,QString,QString,QString,QString,QString)),this,
                     SLOT(onSessionMessageNotice(QString,QString,QString,QString, QString,QString,QString)));
    QObject::connect(m_pChatObserver.get(),SIGNAL(deleteMessagesBack(int)),this,
                     SLOT(onChatDeleteMessagesResult(int)));

    QObject::connect(m_pChatObserver.get(), SIGNAL(uploadAvatarBack(std::string,std::string,int)), this, SLOT(onChatUploadAvatar(QString,QString,int)));
    QObject::connect(m_pChatObserver.get(), SIGNAL(uploadFileBack(std::string,std::string,int)), this, SLOT(onChatUploadFile(QString,QString,int)));
    QObject::connect(m_pChatObserver.get(), SIGNAL(fileProgressBack(std::string,std::string,int)), this, SLOT(onChatFileProgress(QString,QString,int)));
    QObject::connect(m_pChatObserver.get(), SIGNAL(downloadFileBack(std::string,std::string,int)), this, SLOT(onChatDownloadFile(QString,QString,int)));
    QObject::connect(m_pChatObserver.get(), SIGNAL(uploadImageBack(std::string,std::string,int)), this, SLOT(onChatupLoadImage(QString,QString,int)));
    QObject::connect(m_pChatObserver.get(), SIGNAL(downloadImageBack(std::string,std::string,int)), this, SLOT(onChatDownloadImage(QString,QString,int)));
    QObject::connect(m_pChatObserver.get(), SIGNAL(getFileListBack(std::string,std::string,int)), this, SLOT(onChatGetFileList(QString,QString,int)));





    QObject::connect(m_pEnterpriseControler.get(),SIGNAL(getSonOrgsResult(int ,OrgList ,OrgUserList )),this,
                     SLOT(onGetSonOrgsResult(int,OrgList,OrgUserList )));
    QObject::connect(m_pEnterpriseControler.get(),SIGNAL(getOnlineStatesResult(QOnlineStateList)),this,
                     SLOT(onGetOnlineStatesResult(QOnlineStateList)));
    QObject::connect(m_pEnterpriseControler.get(),SIGNAL(getOrgUserInfoResult(int,OrgUser)),this,
                     SLOT(onGetorgUserInfoResult(int,OrgUser)));


    QObject::connect(m_pAuth.get(),SIGNAL(getLoginHistoryResult(LoginInfoList)),this,
                     SLOT(onGetLoginHistoryResult(LoginInfoList)));
    QObject::connect(m_pAuth.get(),SIGNAL(loginSucceeded()),this,
                     SLOT(onLoginSucceeded()));
    QObject::connect(m_pAuth.get(),SIGNAL(loginFailed(int)),this,
                     SLOT(onLoginFailed(int)));

    QObject::connect(m_pAuth.get(),SIGNAL(loginoutRelust(bool)),this,
                     SLOT(onLoginoutRelust(bool)));
    QObject::connect(m_pAuth.get(),SIGNAL(loginResultObserver(int,QString)),this,
                     SLOT(onLoginResultObserver(int,QString)));
    QObject::connect(m_pAuth.get(),SIGNAL(accountInfoChanged(Contact)),this,
                     SLOT(onAccountInfoChanged(Contact)));

    QObject::connect(m_pChatObserver.get(),SIGNAL(chatListChanged(Chat_UIList)),this,
                     SLOT(onChatListChanged(Chat_UIList)));
    QObject::connect(m_pContactObserver.get(),SIGNAL(contactListChanged(int,ContactList)),this,
                     SLOT(onContactListChanged(int,ContactList)));
    QObject::connect(m_pContactObserver.get(),SIGNAL(contactInfoChanged(int,Contact)),this,
                     SLOT(onContactInfoChanged(int,Contact)));
    QObject::connect(m_pContactObserver.get(),SIGNAL(contactOnlineChanged(QString,QString)),this,SLOT(onOnlineChanged(QString,QString)));
}
void LinkDoodService::onLoginSucceeded()
{
    qDebug() << Q_FUNC_INFO;
    emit loginSucceeded();
}
Exemple #14
0
    GreeterApp::GreeterApp(int argc, char **argv) :
#ifdef USE_QT5
    QGuiApplication(argc, argv)
#else
    QApplication(argc, argv)
#endif
    {
        // point instance to this
        self = this;

        // Parse arguments
        bool testing = false;

        if (arguments().contains("--test"))
            testing = true;

        // get socket name
        QString socket = parameter(arguments(), "--socket", "");

        // get theme path
        m_themePath = parameter(arguments(), "--theme", "");

        // Initialize
    #ifdef USE_QT5
        // create view
        m_view = new QQuickView();
        m_view->setResizeMode(QQuickView::SizeRootObjectToView);
    #else
        // create view
        m_view = new QDeclarativeView();
        m_view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
    #endif

        m_view->engine()->addImportPath(IMPORTS_INSTALL_DIR);

        // create configuration instance
        m_configuration = new Configuration(CONFIG_FILE);

        // read theme metadata
        m_metadata = new ThemeMetadata(QString("%1/metadata.desktop").arg(m_themePath));

        // get theme config file
        QString configFile = QString("%1/%2").arg(m_themePath).arg(m_metadata->configFile());

        // read theme config
        m_themeConfig = new ThemeConfig(configFile);

        // create models

        m_sessionModel = new SessionModel();
        m_screenModel = new ScreenModel();
        m_userModel = new UserModel();
        m_proxy = new GreeterProxy(socket);

        if(!testing && !m_proxy->isConnected()) {
            qCritical() << "Cannot connect to the daemon - is it running?";
            exit(EXIT_FAILURE);
        }

        m_proxy->setSessionModel(m_sessionModel);

        // connect proxy signals
        QObject::connect(m_proxy, SIGNAL(loginSucceeded()), m_view, SLOT(close()));

        // connect screen update signals
        connect(m_screenModel, SIGNAL(screensChanged()), this, SLOT(initView()));

        initView();
    }
Exemple #15
0
    GreeterApp::GreeterApp(int argc, char **argv) :
#ifdef USE_QT5
    QGuiApplication(argc, argv)
#else
    QApplication(argc, argv)
#endif
    {
        // point instance to this
        self = this;

        // Parse arguments
        bool testing = false;

        if (arguments().contains("--test"))
            testing = true;

        // get socket name
        QString socket = parameter(arguments(), "--socket", "");

        // get theme path
        QString themePath = parameter(arguments(), "--theme", "");

        // Initialize
    #ifdef USE_QT5
        // create view
        m_view = new QQuickView();
        m_view->setResizeMode(QQuickView::SizeRootObjectToView);
    #else
        // create view
        m_view = new QDeclarativeView();
        m_view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
    #endif

        m_view->engine()->addImportPath(IMPORTS_INSTALL_DIR);

        // create configuration instance
        m_configuration = new Configuration(CONFIG_FILE);

        // read theme metadata
        m_metadata = new ThemeMetadata(QString("%1/metadata.desktop").arg(themePath));

        // get theme config file
        QString configFile = QString("%1/%2").arg(themePath).arg(m_metadata->configFile());

        // read theme config
        m_themeConfig = new ThemeConfig(configFile);

        // create models

        m_sessionModel = new SessionModel();
        m_screenModel = new ScreenModel();
        m_userModel = new UserModel();
        m_proxy = new GreeterProxy(socket);
        m_keyboard = new KeyboardModel();

        if(!testing && !m_proxy->isConnected()) {
            qCritical() << "Cannot connect to the daemon - is it running?";
            exit(EXIT_FAILURE);
        }

        // Set numlock upon start
        if (m_keyboard->enabled()) {
            if (m_configuration->numlock() == Configuration::NUM_SET_ON)
                m_keyboard->setNumLockState(true);
            else if (m_configuration->numlock() == Configuration::NUM_SET_OFF)
                m_keyboard->setNumLockState(false);
        }

        m_proxy->setSessionModel(m_sessionModel);

        // connect proxy signals
        QObject::connect(m_proxy, SIGNAL(loginSucceeded()), m_view, SLOT(close()));

        // set context properties
        m_view->rootContext()->setContextProperty("sessionModel", m_sessionModel);
        m_view->rootContext()->setContextProperty("screenModel", m_screenModel);
        m_view->rootContext()->setContextProperty("userModel", m_userModel);
        m_view->rootContext()->setContextProperty("config", *m_themeConfig);
        m_view->rootContext()->setContextProperty("sddm", m_proxy);
        m_view->rootContext()->setContextProperty("keyboard", m_keyboard);

        // get theme main script
        QString mainScript = QString("%1/%2").arg(themePath).arg(m_metadata->mainScript());

        // set main script as source
        m_view->setSource(QUrl::fromLocalFile(mainScript));

        // connect screen update signals
        connect(m_screenModel, SIGNAL(primaryChanged()), this, SLOT(show()));

        show();
#ifndef USE_QT5
        m_view->showFullScreen();
#endif
    }
Exemple #16
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.";
                }
            }
        }
    }
Exemple #17
0
    void GreeterApp::addViewForScreen(QScreen *screen) {
        // create view
        QQuickView *view = new QQuickView();
        view->setScreen(screen);
        view->setResizeMode(QQuickView::SizeRootObjectToView);
        //view->setGeometry(QRect(QPoint(0, 0), screen->geometry().size()));
        view->setGeometry(screen->geometry());
        m_views.append(view);

        // remove the view when the screen is removed, but we
        // need to be careful here since Qt will move the view to
        // another screen before this signal is emitted so we
        // pass a pointer to the view to our slot
        connect(this, &GreeterApp::screenRemoved, this, [view, this](QScreen *) {
            removeViewForScreen(view);
        });

        // always resize when the screen geometry changes
        connect(screen, &QScreen::geometryChanged, this, [view](const QRect &r) {
            view->setGeometry(r);
        });

        view->engine()->addImportPath(QStringLiteral(IMPORTS_INSTALL_DIR));

        // connect proxy signals
        connect(m_proxy, SIGNAL(loginSucceeded()), view, SLOT(close()));

        // we used to have only one window as big as the virtual desktop,
        // QML took care of creating an item for each screen by iterating on
        // the screen model. However we now have a better approach: we create
        // a view for each screen that compose the virtual desktop and thus
        // the QML code for each screen is responsible for drawing only its
        // screen. By doing so we actually make the screen model useless, but
        // we want to keep it for compatibility reasons, we do however create
        // one for each view and expose only the screen that the view belongs to
        // in order to avoid creating items with different sizes.
        ScreenModel *screenModel = new ScreenModel(screen, view);

        // set context properties
        view->rootContext()->setContextProperty(QStringLiteral("sessionModel"), m_sessionModel);
        view->rootContext()->setContextProperty(QStringLiteral("screenModel"), screenModel);
        view->rootContext()->setContextProperty(QStringLiteral("userModel"), m_userModel);
        view->rootContext()->setContextProperty(QStringLiteral("config"), *m_themeConfig);
        view->rootContext()->setContextProperty(QStringLiteral("sddm"), m_proxy);
        view->rootContext()->setContextProperty(QStringLiteral("keyboard"), m_keyboard);
        view->rootContext()->setContextProperty(QStringLiteral("primaryScreen"), QGuiApplication::primaryScreen() == screen);
        view->rootContext()->setContextProperty(QStringLiteral("__sddm_errors"), QString());

        // get theme main script
        QString mainScript = QStringLiteral("%1/%2").arg(m_themePath).arg(m_metadata->mainScript());
        QUrl mainScriptUrl;
        if (m_themePath.startsWith(QLatin1String("qrc:/")))
            mainScriptUrl = QUrl(mainScript);
        else
            mainScriptUrl = QUrl::fromLocalFile(mainScript);

        // load theme from resources when an error has occurred
        connect(view, &QQuickView::statusChanged, this, [view](QQuickView::Status status) {
            if (status != QQuickView::Error)
                return;

            QString errors;
            Q_FOREACH(const QQmlError &e, view->errors()) {
                qWarning() << e;
                errors += QLatin1String("\n") + e.toString();
            }

            qWarning() << "Fallback to embedded theme";
            view->rootContext()->setContextProperty(QStringLiteral("__sddm_errors"), errors);
            view->setSource(QUrl(QStringLiteral("qrc:/theme/Main.qml")));
        });
Exemple #18
0
    GreeterApp::GreeterApp(int &argc, char **argv) : QGuiApplication(argc, argv) {
        // point instance to this
        self = this;

        // Parse arguments
        bool testing = false;

        if (arguments().contains("--test-mode"))
            testing = true;

        // get socket name
        QString socket = parameter(arguments(), "--socket", "");

        // get theme path
        QString themePath = parameter(arguments(), "--theme", "");

        // create view
        m_view = new QQuickView();
        m_view->setResizeMode(QQuickView::SizeRootObjectToView);

        m_view->engine()->addImportPath(IMPORTS_INSTALL_DIR);

        // read theme metadata
        m_metadata = new ThemeMetadata(QString("%1/metadata.desktop").arg(themePath));

        // Translations
        // Components translation
        m_components_tranlator = new QTranslator();
        if (m_components_tranlator->load(QLocale::system(), "", "", COMPONENTS_TRANSLATION_DIR))
            installTranslator(m_components_tranlator);

        // Theme specific translation
        m_theme_translator = new QTranslator();
        if (m_theme_translator->load(QLocale::system(), "", "",
                           QString("%1/%2/").arg(themePath, m_metadata->translationsDirectory())))
            installTranslator(m_theme_translator);

        // get theme config file
        QString configFile = QString("%1/%2").arg(themePath).arg(m_metadata->configFile());

        // read theme config
        m_themeConfig = new ThemeConfig(configFile);

        // create models

        m_sessionModel = new SessionModel();
        m_screenModel = new ScreenModel();
        m_userModel = new UserModel();
        m_proxy = new GreeterProxy(socket);
        m_keyboard = new KeyboardModel();

        if(!testing && !m_proxy->isConnected()) {
            qCritical() << "Cannot connect to the daemon - is it running?";
            exit(EXIT_FAILURE);
        }

        // Set numlock upon start
        if (m_keyboard->enabled()) {
            if (mainConfig.Numlock.get() == MainConfig::NUM_SET_ON)
                m_keyboard->setNumLockState(true);
            else if (mainConfig.Numlock.get() == MainConfig::NUM_SET_OFF)
                m_keyboard->setNumLockState(false);
        }

        m_proxy->setSessionModel(m_sessionModel);

        // connect proxy signals
        QObject::connect(m_proxy, SIGNAL(loginSucceeded()), m_view, SLOT(close()));

        // set context properties
        m_view->rootContext()->setContextProperty("sessionModel", m_sessionModel);
        m_view->rootContext()->setContextProperty("screenModel", m_screenModel);
        m_view->rootContext()->setContextProperty("userModel", m_userModel);
        m_view->rootContext()->setContextProperty("config", *m_themeConfig);
        m_view->rootContext()->setContextProperty("sddm", m_proxy);
        m_view->rootContext()->setContextProperty("keyboard", m_keyboard);

        // get theme main script
        QString mainScript = QString("%1/%2").arg(themePath).arg(m_metadata->mainScript());

        // set main script as source
        m_view->setSource(QUrl::fromLocalFile(mainScript));

        // connect screen update signals
        connect(m_screenModel, SIGNAL(primaryChanged()), this, SLOT(show()));

        show();
    }