コード例 #1
0
ファイル: AJAXChat.cpp プロジェクト: Maluen/botanna
/** Get a message node element, extrapolate its type (public msg, private msg, channelEnter, etc.) and emit
    the specific signal */
void AJAXChat::emitChatData(const QDomElement &message)
{
    QString messageText = message.firstChildElement("text").text();
    // decode html entities from the message text and simplify it
    QTextEdit t;
    t.setHtml(messageText);
    messageText = t.toPlainText().simplified();

    if (messageText.startsWith("/")) {
        QStringList messageParts = messageText.split(" ");
        if (messageText.startsWith("/privmsg")) {
            const int userID = message.attribute("userID").toInt();
            emit newPrivateMessage(messageParts.at(1), getUser(userID).text());
        } else if (messageText.startsWith("/login")) {
            emit userLoggedIn(messageParts.at(1));
        } else if (messageText.startsWith("/logout")) {
            emit userLoggedOut(messageParts.at(1));
            qDebug("Logged out: " + getUser(messageParts.at(1)).text().toUtf8());
        } else if (messageText.startsWith("/channelEnter")) {
            emit userJoinChannel(messageParts.at(1));
        } else if (messageText.startsWith("/channelLeave")) {
            emit userLeaveChannel(messageParts.at(1));
        } else if (messageText.startsWith("/kick")) {
            emit userKicked(messageParts.at(1));
        } else if (messageText.startsWith("/nick")) {
            emit userChangeNick(messageParts.at(1), messageParts.at(2));
        }
    } else {
        const int userID = message.attribute("userID").toInt();
        emit newPublicMessage(messageText, getUser(userID).text());
    }
}
コード例 #2
0
ファイル: timeguard.cpp プロジェクト: byebye/TimeGuard
void TimeGuard::initLoggedUser()
{
  emit userLoggedIn(user->getName());
  setTimeIfLimitIsSet();
  if(user->isLimitEnabled())
  {
    ui->timerLCD->startTime();
    emit userTimeStarted(user->getName(), user->getTimeRemaining().toString());
  }
}
コード例 #3
0
ファイル: sessionserver.cpp プロジェクト: Rambo2015/Drawpile
/**
 * @brief Handle the move of a client from the lobby to a session
 * @param session
 * @param client
 */
void SessionServer::moveFromLobby(Session *session, Client *client)
{
	logger::debug() << client << "moved from lobby to" << session;
	Q_ASSERT(_lobby.contains(client));
	_lobby.removeOne(client);

	// the session handles disconnect events from now on
	disconnect(client, &Client::loggedOff, this, &SessionServer::lobbyDisconnectedEvent);

	emit userLoggedIn();
	emit sessionChanged(SessionDescription(*session));
}
コード例 #4
0
ファイル: LoginWindow.cpp プロジェクト: jpugliesi/netflix_104
void LoginWindow::loginButtonClicked(){
  
  bool success = netflix->loginUser(login->text().toStdString());
  if(success){
    //user successfully logged in. Emit signal to open MainWindow
    emit userLoggedIn();
    this->close();
  } else {
    QMessageBox badUsernameMessage;
    badUsernameMessage.setText("That username does not exist. Please try again.");
    badUsernameMessage.exec();
  }

}
コード例 #5
0
ファイル: timeguard.cpp プロジェクト: byebye/TimeGuard
void TimeGuard::setupLogger()
{
  connect(this, SIGNAL(adminLoggedIn()), logger, SLOT(logAdminLoggedIn()));
  connect(this, SIGNAL(adminLoggedOff()), logger, SLOT(logAdminLoggedOff()));
  connect(this, SIGNAL(adminPasswordChanged()), logger, SLOT(logAdminPasswordChanged()));
  connect(this, SIGNAL(userLoggedIn(QString)), logger, SLOT(logUserLoggedIn(QString)));
  connect(this, SIGNAL(userLoggedOff(QString)),logger, SLOT(logUserLoggedOff(QString)));
  connect(this, SIGNAL(userLimitEnabled(QString)), logger, SLOT(logUserLimitEnabled(QString)));
  connect(this, SIGNAL(userLimitDisabled(QString)), logger, SLOT(logUserLimitDisabled(QString)));
  connect(this, SIGNAL(userLimitChanged(QString,QString,FileManager::SettingName)),
          logger, SLOT(logUserLimitChanged(QString,QString,FileManager::SettingName)));
  connect(this, SIGNAL(userTimePaused(QString,QString)), logger, SLOT(logUserTimePaused(QString,QString)));
  connect(this, SIGNAL(userTimeStarted(QString,QString)), logger, SLOT(logUserTimeStarted(QString,QString)));
  connect(this, SIGNAL(userTimeReset(QString,QString)), logger, SLOT(logUserTimeReset(QString,QString)));
}
コード例 #6
0
ファイル: multiserver.cpp プロジェクト: GreenReaper/Drawpile
MultiServer::MultiServer(QObject *parent)
	: QObject(parent),
	_server(0),
	_state(NOT_STARTED),
	_autoStop(false)
{
	_sessions = new SessionServer(this);

	connect(_sessions, SIGNAL(sessionCreated(SessionState*)), this, SLOT(assignRecording(SessionState*)));
	connect(_sessions, SIGNAL(sessionEnded(QString)), this, SLOT(tryAutoStop()));
	connect(_sessions, SIGNAL(userLoggedIn()), this, SLOT(printStatusUpdate()));
	connect(_sessions, &SessionServer::userDisconnected, [this]() {
		printStatusUpdate();
		// The server will be fully stopped after all users have disconnected
		if(_state == STOPPING)
			stop();
		else
			tryAutoStop();
	});
}
コード例 #7
0
void SuggestAnAppPage::_authenticationChallengeHappened() {
    connect(Authorization::sharedAuthorization(), SIGNAL(userLoggedIn()), this, SLOT(_sendButtonPressed()));
    connect(Authorization::sharedAuthorization(), SIGNAL(userLoginCommunicationError(QString)), this, SLOT(_communicationError(QString)));
    connect(Authorization::sharedAuthorization(), SIGNAL(userLoginAborted()), this, SLOT(_requestFailed()));
}
コード例 #8
0
ファイル: client.cpp プロジェクト: rudilee/OrangeServer
void Client::checkAuthentication(QString authentication, bool encrypted)
{
    QString status = "failed",
            message = QString();

    if (encrypted)
        authentication = QByteArray::fromBase64(authentication.toLatin1());

    QStringList usernamePassword = QString(authentication).split(":");
    QString hashedPassword = QCryptographicHash::hash(usernamePassword[1].toLatin1(), QCryptographicHash::Md5).toHex();

    socketOut.writeStartElement("authentication");
    socketOut.writeAttribute("id", "status");

    QSqlQuery retrieveUser;
    retrieveUser.prepare("SELECT acd_agent_id, name, password, fullname, level "
                         "FROM acd_agent "
                         "WHERE name = :username AND password = :password");

    retrieveUser.bindValue(":username", usernamePassword[0]);
    retrieveUser.bindValue(":password", hashedPassword);

    if (retrieveUser.exec()) {
        if (retrieveUser.next()) {
            username = usernamePassword[0];
            fullname = retrieveUser.value(3).toString();
            level = (Level) retrieveUser.value(4).toUInt();
            agentId = retrieveUser.value(0).toUInt();
            status = "ok";

            socketOut.writeTextElement("level", QString::number(level));
            socketOut.writeTextElement("login", QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"));

            if (!extension.isEmpty())
                socketOut.writeTextElement("extension", extension);
            else
                retrieveExtension();

            retrieveSkills();
            retrieveGroups();
            startSession();
            startStatus(Login);

            emit userLoggedIn();
        } else {
            message = "Username/Password incorrect";
        }
    } else {
        message = "Retrieve user query error";

        logFailedQuery(&retrieveUser, "retrieving user");
    }

    socketOut.writeTextElement("status", status);

    if (!message.isEmpty())
        socketOut.writeTextElement("message", message);

    socketOut.writeEndElement(); // authentication

    socket->write("\n");
}
コード例 #9
0
ファイル: mainwindow.cpp プロジェクト: riless/smoky
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{

    setCentralWidget(new QWidget);
    QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
    layout->setContentsMargins(0,0,0,0);
    layout->setSpacing(0);

    layout->addWidget( ui.header = new Header( this ) );
    connect( &Socket::sock(), SIGNAL(userLoggedIn(QString)), ui.header, SLOT(onUserConnected(QString)) );
    connect( &Socket::sock(), SIGNAL(userLoggedOut()), ui.header, SLOT(onUserDisconnected()) );
    connect( ui.header, SIGNAL(disconnectClicked()), &Socket::sock(), SLOT(logout()) );
    // mettre obligatoirement ici pour corriger un petit bug d'affichage

//    /*temp refresh button*/
//    QPushButton *refreshBtn = new QPushButton( "Refresh" );
//    refreshBtn->setObjectName( "refreshBtn" );
//    mainLayout->addWidget( refreshBtn );
//    connect(refreshBtn, SIGNAL(clicked()), ui.header, SLOT( onRefreshClicked() ) );

    QHBoxLayout* centralLayout = new QHBoxLayout( );
    centralLayout->addWidget( ui.sideBar = new SideBar( this ) );
    centralLayout->addWidget( ui.stackedWidget = new StackedWidget( this ) );

    layout->addLayout( centralLayout );

    connect(ui.sideBar, SIGNAL( currentChanged( int ) ), ui.stackedWidget, SLOT( setCurrentIndex( int ) ) );
    connect(ui.sideBar, SIGNAL( currentChanged( int ) ), SLOT( loadViewData( int ) ) );


    // LOG
    connect( &Socket::sock(), SIGNAL(clientEvent(int)), &Socket::sock(), SLOT(log(int)) );


    // LIGHT BOX
    lightBox = new QLightBoxWidget(this);
    QHBoxLayout *mainLayout = new QHBoxLayout( lightBox );

    QWidget *fm = new QWidget();
    fm->setObjectName("connexionFrame");
    mainLayout->addWidget( fm );

    QGridLayout *lightBoxLayout = new QGridLayout( fm );
    lightBoxLayout->setRowStretch(1, 1);

    settings = new QSettings("smoky.ini",QSettings::IniFormat);


    lightBoxLayout->addWidget( new QLabel( "IP du serveur" ), 0, 0);
    lightBoxLayout->addWidget( serverIpEdt = new QLineEdit(), 0, 1 );
    serverIpEdt->setInputMask( "000.000.000.000; " );
    serverIpEdt->setText( settings->value("serverIp").toString() );
    serverIpEdt->setObjectName( "serverIpEdt" );

    lightBoxLayout->addWidget( localhostCbx = new QCheckBox("localhost"), 1,1);
    localhostCbx->setObjectName( "localhostCbx" );
    connect( localhostCbx, SIGNAL( stateChanged(int)), SLOT(onLocalhostCbx(int)) );

    lightBoxLayout->addWidget( loginIndication = new QLabel(), 1, 0);
    loginIndication->setObjectName( "loginIndication" );
    loginIndication->setText("<center><small>Placez votre visage<br>face à la caméra</small></center>");

    lightBoxLayout->addWidget( loginAvatarLbl = new QLabel(""), 2, 0, 2, 1);
    loginAvatarLbl->setObjectName( "loginAvatarLbl" );

    lightBoxLayout->addWidget( loginUserEdt = new QLineEdit(), 2, 1);
    loginUserEdt->setPlaceholderText("Nom d'utilisateur");
    loginUserEdt->setObjectName( "loginUserEdt" );

    lightBoxLayout->addWidget( loginPasswordEdt = new QLineEdit(), 3, 1);
    loginPasswordEdt->setObjectName( "loginPasswordEdt" );
    loginPasswordEdt->setEchoMode( QLineEdit::Password );
    loginPasswordEdt->setPlaceholderText("Mot de passe");


    lightBoxLayout->addWidget( loginSubmitBtn = new QPushButton("Connexion"), 4, 1);
    loginSubmitBtn->setObjectName( "loginSubmitBtn" );

    lightBoxLayout->addWidget( statLbl = new QLabel( "" ), 5,0, 1, 2 );
    statLbl->setObjectName( "statLbl" );

    lightBox->show();



    Camera *cam = new Camera();
    t = new QThread();

    mTimer = new QTimer();
    mTimer->setInterval(1000/24);
    connect(mTimer, SIGNAL(timeout()), cam, SLOT(queryFrame()) );
    connect( this, SIGNAL(startWork()), cam, SLOT(openCamera()) );
    connect( this, SIGNAL(startWork()), mTimer, SLOT(start()) );

    connect( cam, SIGNAL(stopCamera()), mTimer, SLOT(stop()) );
    connect( this, SIGNAL(stopWork()), cam, SLOT(closeCamera()) );

    /*destruction*/
    // connect( qApp, SIGNAL(aboutToQuit()),mTimer, SLOT(stop()) );
    // connect( qApp, SIGNAL(aboutToQuit()),mTimer, SLOT(deleteLater()) );

    // connect( qApp, SIGNAL(aboutToQuit()), cam, SLOT(closeCamera()) );
    // connect( qApp, SIGNAL(aboutToQuit()), cam, SLOT(deleteLater()) );

    connect(t, SIGNAL(finished()), cam, SLOT(deleteLater()));
    // connect(this, &Controller::operate, worker, &Worker::doWork);

    //connect( qApp, SIGNAL(aboutToQuit()), t, SLOT(quit()) );
    // connect( t, SIGNAL(finished()), t, SLOT(deleteLater()) );

    // user logged out
    connect( &Socket::sock(), SIGNAL(userLoggedOut()), SLOT(startCamera()) );

    // user logged in
    connect( &Socket::sock(), SIGNAL(userLoggedIn(QString)), SLOT(stopCamera()) );

    cam->moveToThread( t );
    mTimer->moveToThread( t );
    t->start( QThread::IdlePriority );

    emit startWork();

    connect(cam, SIGNAL(sendShot(QImage, QRect)), SLOT(onShotSent(QImage)) ); // receive shots

    connect( &Socket::sock(), SIGNAL(userLoggedIn(QString)), loginPasswordEdt, SLOT(clear()) );
    connect( &Socket::sock(), SIGNAL(userLoggedIn(QString)), lightBox, SLOT(hide()) );

    // rendre la page d'accueil
    connect( &Socket::sock(), SIGNAL(userLoggedOut()), SLOT(resetThings()) );

    connect( &Socket::sock(), SIGNAL(invalidCred()), SLOT(onInvalidCred()) );

    connect( loginSubmitBtn, SIGNAL(clicked()), SLOT(connectUser()) );


    connect( &Socket::sock(), SIGNAL(connexionError(int)), SLOT(onConnexionError(int)) );

    // move(QApplication::desktop()->screen()->rect().center() - this->rect().center());
    /*
        QDesktopWidget desktop;
        QRect desktop_geometry = desktop.screenGeometry();
    */

    // resize( 780, 650 );

    /*int x = desktop_geometry.width()/2 - width()/2;
    int y = desktop_geometry.height()/2 - height()/2;
    move( x, y );*/

    // showMaximized();
}