From a19e9744751d4278f56cb3b6ff885c0068f03a3d Mon Sep 17 00:00:00 2001 From: Alex Borisov Date: Sun, 27 Nov 2011 12:31:03 +0200 Subject: File downloading (no MD5 hash check yet). Various fixes --- client/SslClient.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'client/SslClient.cpp') diff --git a/client/SslClient.cpp b/client/SslClient.cpp index b3a2d15..b1841ed 100644 --- a/client/SslClient.cpp +++ b/client/SslClient.cpp @@ -1,4 +1,5 @@ +#include #include #include #include "SslClient.h" @@ -72,7 +73,8 @@ void SslClient::SendRequest(RequestType type) if (sslSocket.state() != QAbstractSocket::ConnectedState) { Logger::Trace("Connecting to server %s:%u\n", server.toLocal8Bit().data(), port); - sslSocket.connectToHostEncrypted(server, port); + //sslSocket.connectToHostEncrypted(server, port); + sslSocket.connectToHostEncrypted("127.0.0.1", port); } else { @@ -100,6 +102,33 @@ void SslClient::SendRequest(RequestType type) sslSocket.write(pkt); } +void SslClient::SendFileRequest(string filename) +{ + Logger::Trace("Sending request w code %x\n", RegularFile); + if (sslSocket.state() != QAbstractSocket::ConnectedState) + { + Logger::Trace("Connecting to server %s:%u\n", server.toLocal8Bit().data(), port); + sslSocket.connectToHostEncrypted(server, port); + } + else + { + Logger::Trace("Already connected to %s:%u\n", server.toLocal8Bit().data(), port); + } + + unsigned char rcode = 0x12; + const char *file = filename.c_str(); + size_t path_len = strlen(file); + char data[path_len + 5]; + data[0] = data[1] = 0x13; + data[2] = rcode; + strncpy(data + 3, file, path_len); + data[path_len - 1] = data[path_len - 2] = 0x14; + + QByteArray pkt(data); + sslSocket.write(pkt); +} + + /* * Signal handlers */ -- cgit v1.2.3