Example #1
0
void Dialog::on_pushButtonSend_clicked()
{
	cleanQuit = false;
	sendBytes = 0;
	blockNumber = 0;
	maxBytes = 0;
	if(ui->lineEditTag->text().isEmpty() || ui->lineEditFile->text().isEmpty())
	{
		QMessageBox::information(this, tr("Error"), tr("Tag and File can not be empty."));
		return;
	}
	ui->pushButtonSend->setEnabled(false);
	nfClient* client = new nfClient(this);
	connect(client, SIGNAL(disconnected()), client, SLOT(deleteLater()));
	connect(client, SIGNAL(disconnected()), this, SLOT(on_socketDisconnected()));
	connect(client, SIGNAL(fileSize(qint64)), this, SLOT(setProccessBar(qint64)));
	connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(updateProccessBar(qint64)));
	connect(client, SIGNAL(message(QString)), this, SLOT(updateStatusLabel(QString)));
	connect(client, SIGNAL(onError(qint32)), this, SLOT(on_socketError(qint32)));
	client->sendFile(ui->lineEditFile->text(), ui->lineEditTag->text());
}
Example #2
0
void u3HClient::on_clientThread_Started()
{
	m_clientSocket = new QTcpSocket(this);
	if(m_clientSocket->setSocketDescriptor(m_socketDescriptor)) 
	{
		// when data ready to be read
		connect(m_clientSocket, SIGNAL(readyRead()), this, SLOT(on_clientSocket_DataReady()));
		connect(m_clientSocket, SIGNAL(disconnected()), this, SLOT(on_socketDisconnected()));

		packetBuilder *b = new packetBuilder(_hello, newclient);
		b->FinalizePacket();
		SendPacket(b);
	}
	else 
	{
		emit ClientFatalError(m_clientID, tr("Can't set descriptor on socket"));
		emit TerminateClient();
	}

	LogEvent("New client from : " + GetClientEndPointString());

}