Пример #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
}
void CClientComWorker::run()
{
	MYLOG4CPP_DEBUG<<"CClientComWorker::run() begin";

	{
		QMutexLocker lock(&m_mutex_SocketW);
		m_pSocketHandle = new QTcpSocket();
		m_pSocketInfo = new CSocketInfo();
	}
	//
	QObject::connect(m_pSocketHandle, SIGNAL(connected()), this, SLOT(slotConnected()), Qt::AutoConnection);
	QObject::connect(m_pSocketHandle, SIGNAL(disconnected()), this, SLOT(slotDisconnected()), Qt::AutoConnection);
	QObject::connect(m_pSocketHandle, SIGNAL(readyRead()), this, SLOT(slotReadyRead()), Qt::AutoConnection);//Qt::AutoConnection Qt::BlockingQueuedConnection
	QObject::connect(m_pSocketHandle, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError(QAbstractSocket::SocketError)), Qt::AutoConnection);

	m_WorkerState = WORK_STATE_BEGIN;
	m_WorkerState = WORK_STATE_WORKING;

	//slotConnectToServer();
	MYLOG4CPP_DEBUG<<" "<<"m_strID="<<m_pSocketInfo->m_strID
		<<" "<<"class:"<<" "<<"CClientComWorker"
		<<" "<<"fun:"<<" "<<"run"
		<<" "<<"emit signalDisconnected()"
		<<" "<<"param:"<<" "<<"m_nHandle="<<m_nHandle;

	emit signalDisconnected(m_nHandle);

	MYLOG4CPP_DEBUG<<"CClientComWorker::run() exec() begin";

	//QThread::exec() waits until QThread::exit() called
	exec();

	MYLOG4CPP_DEBUG<<"CClientComWorker::run() exec() end";


	//
	QObject::disconnect(m_pSocketHandle, SIGNAL(connected()), this, SLOT(slotConnected()));
	QObject::disconnect(m_pSocketHandle, SIGNAL(disconnected()), this, SLOT(slotDisconnected()));
	QObject::disconnect(m_pSocketHandle, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
	QObject::disconnect(m_pSocketHandle, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError(QAbstractSocket::SocketError)));

	{
		QMutexLocker lock(&m_mutex_SocketW);
		if (NULL != m_pSocketHandle)
		{
			//m_pSocketHandle->waitForDisconnected();
			m_pSocketHandle->close();
			delete m_pSocketHandle;
			m_pSocketHandle = NULL;
		}
		if (NULL != m_pSocketInfo)
		{
			delete m_pSocketInfo;
			m_pSocketInfo = NULL;
		}
	}
	m_WorkerState = WORK_STATE_END;
	MYLOG4CPP_DEBUG<<"CClientComWorker::run() end";
}
Пример #3
0
MyClient::MyClient(const QString & hoststr, int port, QWidget * pwgt)
  : QWidget(pwgt), nextBlockSize(0) {
  tcpSocket = new QTcpSocket(this);
  // установить связь с сервером
  tcpSocket->connectToHost(hoststr, port);
  // сокет отправляет сигнал connected() как только будет создано соединение
  connect(tcpSocket, SIGNAL(connected()), SLOT(slotConnected()));
  // сокет отправляет сигнал readyRead() при готовности предоставить данные для чтения
  connect(tcpSocket, SIGNAL(readyRead()), SLOT(slotReadyRead()));
  // в случае возникновения ошибки сокет отправляет сигнал error
  connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
          this, SLOT(slotError(QAbstractSocket::SocketError)));
  textInfo = new QTextEdit;
  textInput = new QLineEdit;
  textInfo->setReadOnly(true);

  QPushButton * cmd = new QPushButton("&Send");
  connect(cmd, SIGNAL(clicked()), SLOT(slotSendToServer()));
  connect(textInput, SIGNAL(returnPressed()), this, SLOT(slotSendToServer()));

  QVBoxLayout * mainLayout = new QVBoxLayout;
  mainLayout->addWidget(new QLabel("<H1>Client</H1>"));
  mainLayout->addWidget(textInfo);
  mainLayout->addWidget(textInput);
  mainLayout->addWidget(cmd);
  setLayout(mainLayout);
}
Пример #4
0
Client::Client(const QString &host, int port, QWidget *parent) : QWidget(parent), blockSize(0)
{
    socket = new QTcpSocket(this);

    socket->connectToHost(host, port);
    connect(socket, SIGNAL(connected()), SLOT(slotConnected()));
    connect(socket, SIGNAL(readyRead()), SLOT(slotReadyRead()));
    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(slotError(QAbstractSocket::SocketError)));

    info = new QTextEdit;
    input = new QLineEdit;

    info->setReadOnly(true);

    QPushButton* button = new QPushButton("&Send");
    connect(button, SIGNAL(clicked()), SLOT(slotSendToServer()));
    connect(input, SIGNAL(returnPressed()), SLOT(slotSendToServer()));

    QVBoxLayout* layout = new QVBoxLayout;
    layout->addWidget(new QLabel("<h1>Client</h1>"));
    layout->addWidget(info);
    layout->addWidget(input);
    layout->addWidget(button);

    setLayout(layout);
}
Пример #5
0
xmppClient::xmppClient(QObject *parent)
    : QXmppClient(parent)
    , m_turnPort(0)
    , m_turnFinished(false)
{
    bool check;
    Q_UNUSED(check);

    // add QXmppCallManager extension
    callManager = new QXmppCallManager;
    addExtension(callManager);

    check = connect(this, SIGNAL(connected()),
                    this, SLOT(slotConnected()));
    Q_ASSERT(check);

    check = connect(this, SIGNAL(presenceReceived(QXmppPresence)),
                    this, SLOT(slotPresenceReceived(QXmppPresence)));
    Q_ASSERT(check);

    check = connect(callManager, SIGNAL(callReceived(QXmppCall*)),
                    this, SLOT(slotCallReceived(QXmppCall*)));
    Q_ASSERT(check);

    check = connect(&m_dns, SIGNAL(finished()),
                    this, SLOT(slotDnsLookupFinished()));
    Q_ASSERT(check);
}
Пример #6
0
MainWindow::MainWindow()
{
    setUnifiedTitleAndToolBarOnMac( true );

    r = new Comms();

    createActions();
    createToolBars();
    createDocks();

    contactsList = new QListWidget();
    contactsList->setMinimumWidth( 150 );
    contactsList->setMinimumHeight( 250 );
    contactsList->setUniformItemSizes( true );
    contactsList->setSpacing( 3 );
    contactsList->setWordWrap( true );

    connectBox = new ConnectBox();
    setCentralWidget( connectBox );

    QObject::connect( r, SIGNAL( sigConnected() ), this, SLOT( slotConnected() ) );
    QObject::connect( r, SIGNAL( sigRoster( QStringList* ) ), this, SLOT( slotRoster( QStringList* ) ) );
    QObject::connect( r, SIGNAL( sigRosterPresence(QString, QString) ), this, SLOT( slotRosterPresence(QString, QString) ) );
    QObject::connect( r, SIGNAL( sigVCardReceived(QString,QString) ), this, SLOT( slotVCardReceived(QString,QString) ) );
    QObject::connect( r, SIGNAL( sigMessage(QString,QString) ), this, SLOT( slotMessage(QString,QString) ) );

    QObject::connect( connectBox, SIGNAL( tryConnection(QString,QString) ), this, SLOT( setIdents(QString,QString) ) );

    timer = new QTimer( this );
    QObject::connect( timer, SIGNAL( timeout() ), r, SLOT( slotReceive() ) );

    QObject::connect( contactsList, SIGNAL( itemDoubleClicked(QListWidgetItem*) ), this, SLOT( slotLocalSession(QListWidgetItem*) ) );
}
Пример #7
0
Client::Client(const QString &strHost, int port, QWidget *parent) :
    QWidget(parent),
    nextBlockSize(0)
{
    mySocket = new QTcpSocket();

    mySocket->connectToHost(strHost, port);
    connect(mySocket, SIGNAL(connected()), this, SLOT(slotConnected()));
    connect(mySocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
    connect(mySocket, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(slotError(QAbstractSocket::SocketError)));

    txtInfo = new QTextEdit();
    txtInput = new QLineEdit();

    txtInfo->setReadOnly(true);
    QPushButton *send = new QPushButton("&Send");

    connect(send, SIGNAL(clicked()), this, SLOT(slotSendToServer()));
    connect(txtInput, SIGNAL(returnPressed()), this, SLOT(slotSendToServer()));

    QVBoxLayout *form = new QVBoxLayout(this);
    form->addWidget(new QLabel("<H1>Client</H1>"));
    form->addWidget(txtInfo);
    form->addWidget(txtInput);
    form->addWidget(send);
}
Пример #8
0
void SkServer::start()
{
  if (m_server)
  {
    delete m_server;
  }

  m_server = new QTcpServer(this);

  qDebug() << "listen" << m_port;
  if (!m_server->listen(QHostAddress::Any, m_port))
  {
    qDebug() << "error";
    QMessageBox::critical(NULL, tr("SkytechX Server"),
                                tr("Unable to start the server: %1.")
                                .arg(m_server->errorString()));
    stateChange();
    return;
  }
  else
  {
    m_server->setMaxPendingConnections(1);
    qDebug() << "listening" << m_server->isListening();
  }

  stateChange();

  connect(m_server, SIGNAL(newConnection()), this, SLOT(slotConnected()));
}
Пример #9
0
Dialog::Dialog(QWidget *parent) :
	QDialog(parent),
	ui(new Ui::Dialog)
{
	ui->setupUi(this);

	//setAttribute(Qt::WA_TranslucentBackground);
	setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);

	m_socket = 0;
	m_server = new QLocalServer(this);


	if ( !m_server->listen("TouchButtonServer") )
	{
		QMessageBox::critical(this, tr("LocalServer"), tr("Unable to start the server: %1").arg(m_server->errorString()));
		delete m_server;
		m_server = 0;
		return;
	}

	connect(m_server, SIGNAL(newConnection()), this, SLOT(slotConnected()));

	qDebug("server created");
}
Пример #10
0
Server::Server(QObject *parent) : QObject(parent)
{
    m_socket = 0;
    m_server = new QLocalServer(this);

    QFile::remove("/tmp/tbs.local");

    if ( !m_server->listen("tbs.local") )
    {
        qDebug("[Server::] Unable to start the server: %s", qPrintable(m_server->errorString()));

        delete m_server;
        m_server = 0;
        return;
    }

    connect(m_server, SIGNAL(newConnection()), this, SLOT(slotConnected()));


    m_button = new ButtonDialog[2];

    m_button[0].setId(0);
    m_button[0].move(100, 0);
    m_button[1].setId(1);
    m_button[1].move(200, 0);

    connect(this, SIGNAL(signalCommandReceived(QString)), this, SLOT(slotCommandReceived(QString)));

    qDebug("[Server::] server created");
}
Пример #11
0
NetClient::NetClient() : blockSize(0)
{
    tcpSocket = new QTcpSocket(this);
    connect(tcpSocket, SIGNAL(connected()), SLOT(slotConnected()));
    connect(tcpSocket, SIGNAL(readyRead()), SLOT(getResponse()));
    connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
            SLOT(netError(QAbstractSocket::SocketError)));
}
Пример #12
0
/*! \~russian
 * \brief Метод предназначен для соединения внутренних сигналов и слотов класса.
 */
void TcpClient::connectSignalsAndSlots()
{
    connect(&_socket, SIGNAL(connected()), SLOT(slotConnected()));
    connect(&_socket, SIGNAL(readyRead()), SLOT(slotReadyRead()));
    connect(&_socket, SIGNAL(error(QAbstractSocket::SocketError)),
            this,       SLOT(slotError(QAbstractSocket::SocketError))
            );
}
Пример #13
0
Referee::Referee(int teamID, QObject *parent) :
	QObject(parent), messengerOfTheGods(new Hermes(this)), wLimit(1024), myTeamID(teamID), messageSize(0), connection(
			false), testMode(false), verbose(true), ready(false)
{
	connect(messengerOfTheGods, SIGNAL(readyRead()), this, SLOT(slotRead()));
	connect(messengerOfTheGods, SIGNAL(connected()), this, SLOT(slotConnected()));
	connect(messengerOfTheGods, SIGNAL(disconnected()), this, SLOT(slotDisconnected()));
}
Пример #14
0
void TcpClient::disconnectHost()
{
    m_pTcpSocket->disconnectFromHost();
    disconnect(m_pTcpSocket, SIGNAL(connected()), this, SLOT(slotConnected()));
    disconnect(m_pTcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
    disconnect(m_pTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
               this,         SLOT(slotError(QAbstractSocket::SocketError)));
    emit connected(m_connectionState = -1);
}
Пример #15
0
QXmppSocksClient::QXmppSocksClient(const QString &proxyHost, quint16 proxyPort, QObject *parent)
    : QTcpSocket(parent),
    m_proxyHost(proxyHost),
    m_proxyPort(proxyPort),
    m_step(ConnectState)
{
    connect(this, SIGNAL(connected()), this, SLOT(slotConnected()));
    connect(this, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
}
Пример #16
0
checkguest::checkguest(bool s,QString n, QString p, QObject *parent)
    :QObject(parent)
{
    signorlog=s;
    m_name=n;
    m_passwd=p;
    m_tcpSocket=new QTcpSocket(this);
    m_tcpSocket->connectToHost(QHostAddress("223.3.78.22"),31300);
    connect(this->m_tcpSocket,SIGNAL(connected()),this,SLOT(slotConnected()));
}
Пример #17
0
OwnCloudClient::OwnCloudClient(QObject *parent) : QObject(parent)
{
	connect(&m_networkManager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
			this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));
	connect(&m_networkManager, SIGNAL(finished(QNetworkReply*)),
				this, SLOT(slotReplyFinished(QNetworkReply*)));
    connect(&m_networkManager, SIGNAL(networkSessionConnected()),
                this, SLOT(slotConnected()));
//	connect(&m_networkManager, SIGNAL())
}
Пример #18
0
/// private function
   void CServerManager::connectToServer(const std::string& serverIP,
      const unsigned int m_serverPort)
   {
      m_tcpSocket = new QTcpSocket(this);

      m_tcpSocket->connectToHost(QString(serverIP.c_str()), m_serverPort);
      connect(m_tcpSocket, SIGNAL(connected()), this, SLOT(slotConnected()));
      connect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
      connect(m_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
         this,SLOT(slotError(QAbstractSocket::SocketError)));      
   }
Пример #19
0
client::client(QString host)
{
    m_pTcpSocket = new QTcpSocket(this);
    m_pTcpSocket->connectToHost(host, nPort);

    connect(m_pTcpSocket, SIGNAL(connected()), SLOT(slotConnected()));
    connect(m_pTcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
    connect(m_pTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError()));

    game = NULL;
}
Пример #20
0
SIMClientSocket::SIMClientSocket(QSocket *s)
{
    sock = s;
    if (sock == NULL)
        sock = new QSocket(this);
    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)));
    QObject::connect(sock, SIGNAL(readyRead()), this, SLOT(slotReadReady()));
    QObject::connect(sock, SIGNAL(bytesWritten(int)), this, SLOT(slotBytesWritten(int)));
    bInWrite = false;
}
Пример #21
0
void GameClient::connectToServer(const QString &server)
{
    serverAddr = server;
    int socketNumber = 2327;

    tcpSocket = new QTcpSocket(this);
    tcpSocket->connectToHost(serverAddr, socketNumber);

    connect(tcpSocket, SIGNAL(connected()), SLOT(slotConnected()));
    connect(tcpSocket, SIGNAL(readyRead()), SLOT(slotReadyRead()));
    connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
            SLOT(slotError(QAbstractSocket::SocketError)));
}
Пример #22
0
void MainWindow::connectToHost()
{
    if (ui->le_connect->text() != "...")
    {
    m_pTcpSocket->connectToHost(ui->le_connect->text(), nPort);
    connect(m_pTcpSocket, SIGNAL(connected()), SLOT(slotConnected()));
    connect(m_pTcpSocket, SIGNAL(readyRead()), SLOT(slotReadyRead()));
    }
    else
    {
        ui->statusBar->showMessage("Enter Server IP Adress!");
    }
}
Пример #23
0
KNetworkConnector::KNetworkConnector( QObject *parent, const char */*name*/ )
		: Connector( parent )
{
	kdDebug( 14151 ) << k_funcinfo << "New KNetwork connector." << endl;

	mErrorCode = KNetwork::KSocketBase::NoError;

	mByteStream = new KNetworkByteStream( this );

	connect( mByteStream, SIGNAL ( connected () ), this, SLOT ( slotConnected () ) );
	connect( mByteStream, SIGNAL ( error ( int ) ), this, SLOT ( slotError ( int ) ) );
	mPort = 0;
}
Пример #24
0
JabberConnector::JabberConnector ( QObject *parent )
 : XMPP::Connector ( parent )
{
	kDebug() << "New Jabber connector.";

	mErrorCode = 0;

	mByteStream = new JabberByteStream ( this );

	connect ( mByteStream, SIGNAL (connected()), this, SLOT (slotConnected()) );
	connect ( mByteStream, SIGNAL (error(int)), this, SLOT (slotError(int)) );

}
Пример #25
0
void xmppClient::slotCallReceived(QXmppCall *call)
{
    qDebug() << "Got call from:" << call->jid();

    bool check = connect(call, SIGNAL(connected()), this, SLOT(slotConnected()));
    Q_ASSERT(check);

    check = connect(call, SIGNAL(finished()), this, SLOT(slotFinished()));
    Q_ASSERT(check);

    // accept call    
    call->accept();
}
Пример #26
0
KNetworkConnector::KNetworkConnector( QObject *parent )
		: Connector( parent )
{
	kdDebug( YAHOO_RAW_DEBUG ) << "New KNetwork connector." << endl;

	mErrorCode = KNetwork::KSocketBase::NoError;

	mByteStream = new KNetworkByteStream( this );

	connect( mByteStream, SIGNAL ( connected () ), this, SLOT ( slotConnected () ) );
	connect( mByteStream, SIGNAL ( error ( int ) ), this, SLOT ( slotError ( int ) ) );
	mPort = 5510;
}
Пример #27
0
Widget::Widget( QWidget * parent )
	: QWidget( parent )
{
	createWidgets();

	setWindowTitle( tr("Echo client %1").arg( PORT ) );

	connect( &socket, SIGNAL( connected() ), SLOT( slotConnected() ) );
	connect( &socket, SIGNAL( disconnected() ), SLOT( slotDisconnected() ) );
	connect( &socket, SIGNAL( readyRead() ), SLOT( slotRead() ) );

	tcpConnect();
}
Пример #28
0
KNetworkConnector::KNetworkConnector ( QObject *parent )
 : Connector ( parent )
{
	kDebug () << "New KNetwork connector.";

	mErrorCode = 0;

	mByteStream = new KNetworkByteStream ( this );

	connect ( mByteStream, SIGNAL (connected()), this, SLOT (slotConnected()) );
	connect ( mByteStream, SIGNAL (error(int)), this, SLOT (slotError(int)) );
	mPort = 0;
}
/// \cond
void QXmppBookmarkManager::setClient(QXmppClient *client)
{
    bool check;
    Q_UNUSED(check);

    QXmppClientExtension::setClient(client);

    check = connect(client, SIGNAL(connected()),
                    this, SLOT(slotConnected()));
    Q_ASSERT(check);

    check = connect(client, SIGNAL(disconnected()),
                    this, SLOT(slotDisconnected()));
    Q_ASSERT(check);
}
Пример #30
0
   void CServerManager::disconnectFromServer()
   {
      m_connectToServer = false;
      m_tcpSocket->waitForDisconnected(0);
      m_tcpSocket->disconnectFromHost();

      disconnect(m_tcpSocket, SIGNAL(connected()), this, SLOT(slotConnected()));
      disconnect(m_tcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
      disconnect(m_tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
         this,SLOT(slotError(QAbstractSocket::SocketError)));

      delete m_tcpSocket;

      qDebug("Disconnect from server - end");
   }