Ejemplo n.º 1
0
ChatDialog::ChatDialog(QWidget *parent, QString username, QString peername, QString peeraddr, ChatConnection *connection) :
    QDialog(parent)
{
    this->userName = username;
    this->chatSession = connection;

    if(DEBUG)
        qDebug() << "Peer addr string is: " << peeraddr;

    //this->iconLabel = new QLabel(QObject::tr("XXXXX\nXXXXX\nXXXXX"), this);
    //this->iconLabel->setAlignment(Qt::AlignCenter);
    this->peerName = new QLabel(this);
    this->peerAddress = new QLabel(this);
    this->logChat = new QTextEdit();
    this->msgSend = new QLineEdit();
    this->sendButton = new QPushButton(QObject::tr("Send"), this);
    this->msgSend->setFocusPolicy(Qt::StrongFocus);
    this->logChat->setFocusPolicy(Qt::NoFocus);
    this->logChat->setReadOnly(true);

    this->peerName->setText("Username: "******"Address: " + peeraddr);
    this->setWindowTitle(peername + "@" + peeraddr);
    this->initLayout();
    this->resize(QSize(480, 360));

    connect(sendButton, SIGNAL(clicked()), this, SLOT(handleToSendMessage()));
    connect(msgSend, SIGNAL(returnPressed()), this, SLOT(handleToSendMessage()));

    connect(chatSession, SIGNAL(newMessage(QString, QString)), this, SLOT(handleReceivedMssage(QString, QString)));
    connect(chatSession, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(handleConnectionError(QAbstractSocket::SocketError)));
    connect(this, SIGNAL(rejected()), this, SLOT(handleRejected()));
}
void WindowSystem::handleConnection()
{
    qDebug() << "SERVER: client connected";
    if (QTcpSocket *connection = m_server->nextPendingConnection()) {
        connect(connection, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(handleConnectionError()));
        connect(connection, SIGNAL(readyRead()), this, SLOT(handleRequest()));
        connect(connection, SIGNAL(disconnected()), this, SLOT(removeConnection()));
    }
}
Ejemplo n.º 3
0
void LocalServer::acceptConnection()
{
    uINFO << "client connected";
    emit requestShowWindow();
    m_tcpServerConnection = nextPendingConnection();
    connect(m_tcpServerConnection, SIGNAL(readyRead()), SLOT(handleMessage()));
    connect(m_tcpServerConnection, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(handleConnectionError(QAbstractSocket::SocketError)));

    m_tcpServerConnection->write((Globals::BUFFER_DIRECTORY + "\n").toLatin1());

    QVariantMap map;
    map.insert("CONNECTED", true);
    emit messageReceived(QtJson::serialize(map));
}
Ejemplo n.º 4
0
void SshRemoteProcessRunnerPrivate::run(const QByteArray &command)
{
    ASSERT_STATE(Inactive);
    setState(Connecting);

    m_command = command;
    connect(m_connection.data(), SIGNAL(error(Utils::SshError)),
        SLOT(handleConnectionError(Utils::SshError)));
    connect(m_connection.data(), SIGNAL(disconnected()),
        SLOT(handleDisconnected()));
    if (m_connection->state() == SshConnection::Connected) {
        handleConnected();
    } else {
        connect(m_connection.data(), SIGNAL(connected()),
            SLOT(handleConnected()));
        m_connection->connectToHost();
    }
}
void SshRemoteProcessRunner::runInternal(const QByteArray &command,
    const SshConnectionParameters &sshParams)
{
    setState(Connecting);

    d->m_lastConnectionError = SshNoError;
    d->m_lastConnectionErrorString.clear();
    d->m_processErrorString.clear();
    d->m_exitSignal = SshRemoteProcess::NoSignal;
    d->m_exitCode = -1;
    d->m_command = command;
    d->m_connection = SshConnectionManager::instance().acquireConnection(sshParams);
    connect(d->m_connection, SIGNAL(error(QSsh::SshError)),
        SLOT(handleConnectionError(QSsh::SshError)));
    connect(d->m_connection, SIGNAL(disconnected()), SLOT(handleDisconnected()));
    if (d->m_connection->state() == SshConnection::Connected) {
        handleConnected();
    } else {
        connect(d->m_connection, SIGNAL(connected()), SLOT(handleConnected()));
        if (d->m_connection->state() == SshConnection::Unconnected)
            d->m_connection->connectToHost();
    }
}