示例#1
0
SrvCLI::SrvCLI()
    : connectionIsOnline (false)
{
    QObject::connect (&this->sslSocket, SIGNAL(disconnected()), this, SLOT(connectionClosedByServer()));
    QObject::connect (&this->sslSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error()));
    QObject::connect (&this->sslSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slot_sslErrors(QList<QSslError>)));
    QObject::connect (&this->sslSocket, SIGNAL(peerVerifyError(QSslError)), this, SLOT(slot_peerVerifyError(QSslError)));
    QObject::connect (&this->sslSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(slot_stateChanged(QAbstractSocket::SocketState)));
}
示例#2
0
Client::Client(QObject *parent) :
    QObject(parent)
{
    connect(&tcpSocket, SIGNAL(connected()), this, SLOT(sendData()));
    connect(&tcpSocket, SIGNAL(disconnected()),
            this, SLOT(connectionClosedByServer()));
    connect(&tcpSocket, SIGNAL(readyRead()),
            this, SLOT(getData()));
    connect(&tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(error()));
}
TripPlanner::TripPlanner(char *name,char *id, QObject *parent):QTcpSocket(parent)
{
  std::stringstream strValue;
  strValue << id;
  strValue >> busID;
  
  busName = QString(name);
  finished = false;
  lastStation = -1;
  
  // Determine Start Station
  station = 0.0;
  
  peopleGettingOff = 0;
  space = BUS_SPACE;
  
 // ... // Create widgets.
  //connectButton = new QPushButton("Connect");
  //exitButton = new QPushButton("Exit");
  //layout = new QHBoxLayout(this);
  
  
  // Connect button signals.
 // connect(connectButton, SIGNAL(clicked()),
  //this, SLOT(startSending()));
  
  /*connect(stopButton, SIGNAL(clicked()),
  this, SLOT(stopSearch()));
  connect(quitButton, SIGNAL(clicked()),
  this, SLOT(close()));*/

 // connect(exitButton, SIGNAL(clicked()), this, SLOT(close()));
  
  // Connect TCP socket signals.
  connect(this, SIGNAL(connected()),
  this, SLOT(sendRequest()));
  
  connect(this, SIGNAL(disconnected()),
  this, SLOT(connectionClosedByServer()));
  
  //connect(this, SIGNAL(readyRead()),
  //this, SLOT(updateTableWidget()));
  
  connect(this,
  SIGNAL(error(QAbstractSocket::SocketError)),
  this, SLOT(error()));
  
  //layout->addWidget(connectButton);
  //layout->addWidget(exitButton);

  //startSending();
}
示例#4
0
bool ChatWidget::Avvia(){
	if(!partito){
		reconnectButton->setVisible(false);
		if(!IsServer){
			TCPsocket=new QTcpSocket(this);

			connect(TCPsocket, SIGNAL(connected()), this, SLOT(Connesso()));
			connect(TCPsocket, SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(ErroreConnessione()));
			connect(TCPsocket, SIGNAL(disconnected()),this, SLOT(connectionClosedByServer()));
			connect(TCPsocket, SIGNAL(readyRead()),this, SLOT(Inbox()));
			if (fistTime){
				connect(this, SIGNAL(MessageRecieved(QString,bool)), this, SLOT(PrintMessage(QString,bool)));
			}
			TCPsocket->connectToHost(Host,port);
			nextBlockSize=0;
		}
TripPlanner::TripPlanner(char *name,char *id, QObject *parent):QTcpSocket(parent)
{
  std::stringstream strValue;
  strValue << id;
  strValue >> busID;
  
  busName = name;
  
  // Connect TCP socket signals.
  connect(this, SIGNAL(connected()),
  this, SLOT(sendRequest()));
  
  connect(this, SIGNAL(disconnected()),
  this, SLOT(connectionClosedByServer()));
  
  connect(this,
  SIGNAL(error(QAbstractSocket::SocketError)),
  this, SLOT(error()));
}
ResourceRequester::ResourceRequester(t_peer2res_version_map::iterator remote_res_peer,\
                                     t_peer2resid_map &peer2resid_map,\
                                     t_resid2peer_map &resid2peer_map,\
                                     t_resid2propertie &resid2pro_map\
                                     )\
    :remote_res_peer(remote_res_peer)\
    ,peer2resid_map(peer2resid_map)\
    ,resid2peer_map(resid2peer_map)\
    ,resid2pro_map(resid2pro_map)\
{
    //qDebug()<<"a starting......\n";
    connect(this, SIGNAL(connected()), this, SLOT(sendRequest()));
    connect(this, SIGNAL(disconnected()), this , SLOT(deleteLater()));
    connect(this, SIGNAL(readyRead()), this, SLOT(readMessage()));
    connect(this, SIGNAL(disconnected()), this , SLOT(connectionClosedByServer()));
    connect(this, SIGNAL(error(QAbstractSocket::SocketError)),\
            this, SLOT(errorHandler(QAbstractSocket::SocketError)));
    nextBlockSize = 0;
}
SessionManager::SessionManager(QWidget *parent) :
    QDialog(parent)
{
    needBind = false;
    needSess = false;
    firstTimeShowMainWindow = true;
    xmlTree = new QTreeWidget;
    xmlHandler = new SaxHandler(xmlTree);
    tcpSocket = new QTcpSocket();

    connect(tcpSocket, SIGNAL(readyRead()),
            this, SLOT(handleRead()));
    connect(tcpSocket, SIGNAL(disconnected()),
            this, SLOT(connectionClosedByServer()));
    connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(socketError()));
    connect(this, SIGNAL(send(QString)),
            this, SLOT(sendRequest(QString)));

    sessionId = random()%50;
}
AliveListRequester::AliveListRequester(quint32 &alive_list_version\
                                       ,const t_ip_port &tracker\
                                       ,t_peer2res_version_map &peer2res_version_map\
                                       ,t_peer_list &offline_res_peer_list\
                                       ,QObject *parent)\
    :QTcpSocket(parent)\
    ,alive_list_version(alive_list_version)\
    ,tracker(tracker)\
    ,peer2res_version_map(peer2res_version_map)
    ,offline_res_peer_list(offline_res_peer_list)
{
    //qDebug()<<"a starting......\n";
    connect(this, SIGNAL(connected()), this, SLOT(sendRequest()));
    connect(this, SIGNAL(disconnected()), this , SLOT(deleteLater()));
    connect(this, SIGNAL(readyRead()), this, SLOT(readMessage()));
    connect(this, SIGNAL(disconnected()), this, SLOT(connectionClosedByServer()));

    connect(this, SIGNAL(error(QAbstractSocket::SocketError)),\
            this, SLOT(errorHandler(QAbstractSocket::SocketError)));

    nextBlockSize = 0;
}
示例#9
0
TripPlanner::TripPlanner(QWidget *parent) :
    QDialog(parent)
{
    setupUi(this);
    searchButton = buttonBox->addButton(tr("&Search"),
                                        QDialogButtonBox::ActionRole);

    stopButton   = buttonBox->addButton(tr("S&top"),
                                        QDialogButtonBox::ActionRole);

    stopButton->setEnabled(false);
    buttonBox->button(QDialogButtonBox::Close)->setText(tr("&Quit"));

    QDateTime dateTime = QDateTime::currentDateTime();
    dateEdit->setDate(dateTime.date());
    timeEdit->setTime(QTime(dateTime.time().hour(), 0));

    progressBar->hide();
    progressBar->setSizePolicy(QSizePolicy::Preferred,
                               QSizePolicy::Ignored);

    tableWidget->verticalHeader()->hide();
    tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);

    connect(searchButton, SIGNAL(clicked(bool)),
            this, SLOT(connectToServer()));
    connect(stopButton, SIGNAL(clicked(bool)), this, SLOT(stopSearch()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    connect(&tcpSocket, SIGNAL(connected()), this, SLOT(sendRequest()));
    connect(&tcpSocket, SIGNAL(disconnected()),
            this, SLOT(connectionClosedByServer()));
    connect(&tcpSocket, SIGNAL(readyRead()),
            this, SLOT(updateTableWidget()));
    connect(&tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
            this, SLOT(error()));
}
int TCST::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0:
            button1Clicked();
            break;
        case 1:
            registerButtonClicked();
            break;
        case 2:
            browseForLocation();
            break;
        case 3:
            browseForFile();
            break;
        case 4:
            connectToServer();
            break;
        case 5:
            sendRequest();
            break;
        case 6:
            sendFile();
            break;
        case 7:
            updateLabels();
            break;
        case 8:
            confirmFile();
            break;
        case 9:
            displayError((*reinterpret_cast< QAbstractSocket::SocketError(*)>(_a[1])));
            break;
        case 10:
            connectionClosedByServer();
            break;
        case 11:
            sessionOpened();
            break;
        case 12:
            reloadMenu();
            break;
        case 13:
            registerWithServer();
            break;
        case 14:
            printStatus();
            break;
        case 15:
            reconnect();
            break;
        default:
            ;
        }
        _id -= 16;
    }
    return _id;
}