예제 #1
0
void ChatServer::checkKeepAliveResponses() {
    qDebug() << "Keep Alive Check" << m_stillAliveUsers;
    m_userList = m_stillAliveUsers;
    m_stillAliveUsers.clear();
    m_userList.sort();
    emit userListChanged();
}
예제 #2
0
bool ChatServer::logout(const QString& userName)
{
    if (!m_userList.contains(userName)) {
        return false;
    } else {
        m_userList.removeAt(m_userList.indexOf(userName));
        emit userListChanged();
        emit userCountChanged();
        return true;
    }
}
예제 #3
0
파일: group.cpp 프로젝트: barry-ran/qTox
void Group::updatePeer(int peerId, QString name)
{
    ToxPk peerKey = Core::getInstance()->getGroupPeerPk(groupId, peerId);
    toxpks[peerKey] = name;

    Friend* f = FriendList::findFriend(peerKey);
    if (f != nullptr) {
        // use the displayed name from the friends list
        toxpks[peerKey] = f->getDisplayedName();
    } else {
        emit userListChanged(groupId, toxpks);
    }
}
예제 #4
0
파일: irc.cpp 프로젝트: Apkawa/leechcraft
IrcLayer::IrcLayer(QObject * parent, QString ircUri) : QObject(parent)
{
	qDebug() << "Creating new IRC layer" << ircUri;
	fSettings settings;
	m_active=0;
	// Protocol regexes
	initRegexes();
	m_encoding = "UTF-8";
	m_ircServer=0;
	m_joined=0;
	m_codec = QTextCodec::codecForName(m_encoding);
	ircUseUri(ircUri);
	connect(this, SIGNAL(gotKick(QHash<QString, QString>)), this, SLOT(checkKicked(QHash<QString, QString>)));
	connect(this, SIGNAL(gotNames(QStringList)), this, SLOT(addNames(QStringList)));

	connect(this, SIGNAL(gotPart(QHash<QString, QString>)), this, SIGNAL(userListChanged()));
	connect(this, SIGNAL(gotJoin(QHash<QString, QString>)), this, SIGNAL(userListChanged()));
	connect(this, SIGNAL(gotQuit(QHash<QString, QString>)), this, SIGNAL(userListChanged()));
	connect(this, SIGNAL(gotNick(QHash<QString, QString>)), this, SIGNAL(userListChanged()));
	connect(this, SIGNAL(gotKick(QHash<QString, QString>)), this, SIGNAL(userListChanged()));
//	connect(m_socket, SIGNAL(error()), this, SLOT(gotError()));
}
clientController::clientController(QObject *parent) : QObject(parent)
{
    m_w = new clientConnectWindow();
    m_userWindow = new userListWindow();

    connect(m_w, SIGNAL(tryConnect(QString,QString,QString)), this, SLOT(on_tryConnect(QString,QString,QString)));


    connect(this, SIGNAL(userListChanged(QStringList)), m_userWindow, SLOT(updateUserList(QStringList)));
    connect(m_userWindow, SIGNAL(tryChatConnect(QString)), this, SLOT(on_tryStartChat(QString)));
    connect(this, SIGNAL(newMessage(QString,QString)), this, SLOT(on_newMessage(QString,QString)));
    connect(this, SIGNAL(rcvDisconnect(QString, QString)), this, SLOT(on_rcvDisconnect(QString,QString)));

    m_w->show();
}
예제 #6
0
bool ChatServer::login(const QString& userName)
{
    //stop keepAliveCheck, when a new user logged in
    if (m_keepAliveCheckTimer->isActive()) {
        m_keepAliveCheckTimer->stop();
        m_stillAliveUsers.clear();
    }

    if (m_userList.contains(userName)) {
        return false;
    }

    qDebug() << "User logged in:" << userName;
    m_userList.append(userName);
    m_userList.sort();
    emit userListChanged();
    emit userCountChanged();
    return true;
}
예제 #7
0
파일: group.cpp 프로젝트: barry-ran/qTox
void Group::regeneratePeerList()
{
    const Core* core = Core::getInstance();

    QStringList peers = core->getGroupPeerNames(groupId);
    toxpks.clear();
    const int nPeers = peers.size();
    for (int i = 0; i < nPeers; ++i) {
        const auto pk = core->getGroupPeerPk(groupId, i);

        toxpks[pk] = peers[i];
        if (toxpks[pk].isEmpty()) {
            toxpks[pk] =
                tr("<Empty>", "Placeholder when someone's name in a group chat is empty");
        }

        Friend* f = FriendList::findFriend(pk);
        if (f != nullptr && f->hasAlias()) {
            toxpks[pk] = f->getDisplayedName();
        }
    }

    emit userListChanged(groupId, toxpks);
}
예제 #8
0
PrinterBehavior::PrinterBehavior(const QString &destName, bool isClass, QWidget *parent) :
    PrinterPage(parent),
    ui(new Ui::PrinterBehavior),
    m_destName(destName),
    m_isClass(isClass),
    m_changes(0)
{
    ui->setupUi(this);

    connect(ui->errorPolicyCB, SIGNAL(currentIndexChanged(int)),
            this, SLOT(currentIndexChangedCB(int)));
    connect(ui->operationPolicyCB, SIGNAL(currentIndexChanged(int)),
            this, SLOT(currentIndexChangedCB(int)));

    connect(ui->startingBannerCB, SIGNAL(currentIndexChanged(int)),
            this, SLOT(currentIndexChangedCB(int)));
    connect(ui->endingBannerCB, SIGNAL(currentIndexChanged(int)),
            this, SLOT(currentIndexChangedCB(int)));

    connect(ui->usersELB, SIGNAL(changed()),
            this, SLOT(userListChanged()));
    connect(ui->allowRB, SIGNAL(toggled(bool)),
            this, SLOT(userListChanged()));
}
void clientController::on_tryConnect(QString server, QString port, QString name)
{
    m_secureSocket = new QSslSocket(this);


    // special slot to handle errors with the certificates
    // in particular the fact that they are self-signed
    connect(m_secureSocket, SIGNAL(sslErrors(QList<QSslError>)), this,
            SLOT(handleSSLError(QList<QSslError>)));


    m_secureSocket->connectToHostEncrypted(server, port.toInt());

    if (!m_secureSocket->waitForEncrypted(3000)){
        QMessageBox::critical(m_w, "ERROR", "Error: Couldn't connect to host");
        return;
    }
    //displayCertificateWindow();

    if(name.isEmpty())
        name=m_secureSocket->peerAddress().toString();

    QString msg = "0\n" + name + "\n";
    m_secureSocket->write(msg.toUtf8());

    if(!m_secureSocket->waitForReadyRead(15000)){
        QMessageBox timeOut;
        timeOut.setText("The server timed out on this request try again");
        timeOut.exec();
        return;
    }

    //qDebug() << client->readAll();fromUtf8(client->readLine()).trimmed()
    bool isValid = false;
    int state = QString::fromUtf8(m_secureSocket->readLine()).trimmed().toInt(&isValid,10);
    if (!isValid){
        qDebug() << "first readline is not a number for the namecheck";
    }

    if(state == 4){//on error;
        QMessageBox dupName;
        dupName.setText(m_secureSocket->readLine().trimmed());
        dupName.exec();
        return;
    }

    else if(state == 0){//on success join
        m_w->close();

        m_secureSocket->flush();
        m_clientName = name;

        msg = m_secureSocket->readLine();
        if(!msg.trimmed().compare("1")){
            msg = m_secureSocket->readLine();
            QStringList names = msg.split(",");
            names.last().remove('\n');
            emit userListChanged(names);
        }

        connect(m_secureSocket, SIGNAL(readyRead()), this, SLOT(readyRead()));
        m_userWindow->setWindowTitle(name.trimmed() + "'s user list");
        m_userWindow->show();
    }

    else
        qDebug()<<"a bad state was received trying to connect\n";
}