Exemplo n.º 1
0
ICQClientSocket::ICQClientSocket(QSocket *s)
#endif
{
    sock = s;
    if (sock == NULL)
#ifdef HAVE_KEXTSOCK_H
        sock = new KExtendedSocket;
    sock->setSocketFlags(KExtendedSocket::outputBufferedSocket );
#else
        sock = new QSocket(this);
    bConnected = false;
#endif
#ifdef HAVE_KEXTSOCK_H
    QObject::connect(sock, SIGNAL(connectionSuccess()), this, SLOT(slotConnected()));
    QObject::connect(sock, SIGNAL(lookupFinished(int)), this, SLOT(slotLookupFinished(int)));
    QObject::connect(sock, SIGNAL(connectionFailed(int)), this, SLOT(slotError(int)));
    QObject::connect(sock, SIGNAL(closed(int)), this, SLOT(slotError(int)));
#else
    QObject::connect(sock, SIGNAL(connected()), this, SLOT(slotConnected()));
    QObject::connect(sock, SIGNAL(connectionClosed()), this, SLOT(slotConnectionClosed()));
    QObject::connect(sock, SIGNAL(error(int)), this, SLOT(slotError(int)));
#endif
    QObject::connect(sock, SIGNAL(readyRead()), this, SLOT(slotReadReady()));
    QObject::connect(sock, SIGNAL(bytesWritten(int)), this, SLOT(slotBytesWritten(int)));
    bInWrite = false;
#ifdef HAVE_KEXTSOCK_H
    if (s) sock->enableRead(true);
#endif
}
Exemplo n.º 2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->chatTimeout = true;
    this->connected = false;
    this->currColorId = 2; // czarny
    this->lastColorButton = ui->blackPushButton;
    this->graphicsScene = new QGraphicsScene();
    ui->graphicsView->setScene(graphicsScene);
    this->currentPen.setColor(QColor("black"));


    connect(ui->graphicsView,SIGNAL(drawPoint(QPoint)),this,SLOT(drawPoint(QPoint)));
    connect(ui->graphicsView,SIGNAL(drawLineTo(QPoint)),this,SLOT(drawLineTo(QPoint)));

    connect(ui->clearPushButton,SIGNAL(clicked()),this,SLOT(clearView()));
    connect(ui->redPushButton,SIGNAL(clicked()),this,SLOT(switchColor()));
    connect(ui->greenPushButton,SIGNAL(clicked()),this,SLOT(switchColor()));
    connect(ui->blackPushButton,SIGNAL(clicked()),this,SLOT(switchColor()));
    connect(ui->sendMessagePushButton,SIGNAL(clicked()),this,SLOT(sendMessage()));
    connect(ui->chatLineEdit,SIGNAL(returnPressed()),this,SLOT(sendMessage()));

    this->socket = new KalSocket();
    this->chatTimer = new QTimer();

    connect(socket,SIGNAL(connected()),this,SLOT(connectionSuccess()));
    connect(socket,SIGNAL(error(QAbstractSocket::SocketError)),
            this,SLOT(displayError(QAbstractSocket::SocketError)));
    connect(socket,SIGNAL(pointsReceived(int,int,int,KalSocket::DrawType)),
            this,SLOT(pointsReceived(int,int,int,KalSocket::DrawType)));
    connect(socket,SIGNAL(clear()),graphicsScene,SLOT(clear()));
    connect(socket,SIGNAL(someoneLoggedIn(QString)),this,SLOT(someoneLoggedIn(QString)));
    connect(socket,SIGNAL(chatMessage(QString,QString)),this,SLOT(addMessage(QString,QString)));
    connect(socket,SIGNAL(nicknames(QList<QString>)),this,SLOT(getNicknames(QList<QString>)));
    connect(socket,SIGNAL(logout(QString)),this,SLOT(someoneLoggedOut(QString)));
    connect(socket,SIGNAL(drawStart(QString)),this,SLOT(drawStart(QString)));
    connect(socket,SIGNAL(gotSettings(ServerSettings)),this,SLOT(getSettings(ServerSettings)));
    connect(socket,SIGNAL(errorMessage(QString)),this,SLOT(showMessage(QString)));

    connect(ui->wantDrawCheckBox,SIGNAL(toggled(bool)),this,SLOT(wantDrawToggled(bool)));

    // actiony z menu: Polaczenie
    connect(ui->actionPo_cz,SIGNAL(triggered()),this,SLOT(connectWindowExec())); // laczymy sie
    connect(ui->actionRoz_cz,SIGNAL(triggered()),this,SLOT(disconnect())); // rozlaczamy sie
    connect(ui->actionZako_cz,SIGNAL(triggered()),this,SLOT(close())); // koniec programu

    // timer
    connect(chatTimer,SIGNAL(timeout()),this,SLOT(timeout()));
    connect(ui->progressBar,SIGNAL(full()),this,SLOT(drawTimeout()));

    // inne
    this->disableActions(false); // Polacz - aktywne, Rozlacz - nieaktywne
}
Exemplo n.º 3
0
TelnetClient::TelnetClient(QObject *parent) :
    QObject(parent)
{
    _connection_tries=0;
    _status=0;
    _hostname = "127.0.0.1";
    _port= CONTROL_PORT;
    _socket = new QTcpSocket;
    QObject::connect(_socket,SIGNAL(error(QAbstractSocket::SocketError )),this,SLOT(connectionFailed(QAbstractSocket::SocketError)));
    QObject::connect(_socket,SIGNAL(connected()),this,SLOT(connectionSuccess()));
    QObject::connect(_socket,SIGNAL(readyRead()),this,SLOT(processData()));

}
Exemplo n.º 4
0
AtlantikNetwork::AtlantikNetwork(AtlanticCore *atlanticCore) : KExtendedSocket(0, 0, KExtendedSocket::inputBufferedSocket)
{
	m_atlanticCore = atlanticCore;
	m_textStream = new QTextStream(this);
	m_textStream->setCodec(QTextCodec::codecForName("utf8"));
	m_playerId = -1;
	m_serverVersion = "";

	QObject::connect(this, SIGNAL(readyRead()), this, SLOT(slotRead()));
	QObject::connect(this, SIGNAL(lookupFinished(int)),
	                 this, SLOT(slotLookupFinished(int)));
	QObject::connect(this, SIGNAL(connectionSuccess()),
	                 this, SLOT(slotConnectionSuccess()));
	QObject::connect(this, SIGNAL(connectionFailed(int)),
	                 this, SLOT(slotConnectionFailed(int)));
}
Exemplo n.º 5
0
void Network2::downloadMap(int your_id, QString map)
{
    your_id_ = your_id;
    map_url_ = map;
    if (map == "no_map")
    {
        is_good_ = true;
        emit connectionSuccess(your_id, map);
        return;
    }

    qDebug() << "Begin download map from " << map_url_;

    QUrl url(map);
    QNetworkRequest r(url);

    net_manager_->get(r);
}
Exemplo n.º 6
0
void StreamClient::handleConnect(const boost::system::error_code& error,
                                 tcp::resolver::iterator endpoint_iterator)
{
    if (!error)
    {
        emit connectionSuccess();
        newReadCycle();
    } else if (endpoint_iterator != tcp::resolver::iterator()) {
        m_socket.close();
        tcp::endpoint endpoint = *endpoint_iterator;
        m_socket.async_connect(endpoint,
                              boost::bind(&StreamClient::handleConnect, this,
                                          boost::asio::placeholders::error, ++endpoint_iterator));
    } else {
        m_exit_result = CONNECTION_FAILED;
        m_socket.close();
        emit connectionFailure();
    }
}
Exemplo n.º 7
0
void Network2::mapDownloaded(QNetworkReply* reply)
{
    if (reply->request().url() != map_url_)
    {
        qDebug() << "End map upload";
        return;
    }

    if (reply->error() != QNetworkReply::NoError)
    {
        emit connectionFailed("Unable download map: " + reply->errorString());
        reply->deleteLater();
        return;
    }

    map_data_ = reply->readAll();
    reply->deleteLater();

    qDebug() << "Map length: " << map_data_.length();

    is_good_ = true;
    emit connectionSuccess(your_id_, "map_buffer");
}
TcpClient::TcpClient(QObject * parent)
    : QObject(parent)
{
    QObject::connect(&m_Socket, SIGNAL(connected()), this, SLOT(connectionSuccess()));
    QObject::connect(&m_Socket, SIGNAL(readyRead()), this, SLOT(readServerMsg()));
}