From 29043c381edb0fa8934a187be3cfd757cf787996 Mon Sep 17 00:00:00 2001 From: Alex Borisov Date: Mon, 28 Nov 2011 23:02:47 +0200 Subject: Code to test file transfer --- client/DownloadClient.cpp | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'client/DownloadClient.cpp') diff --git a/client/DownloadClient.cpp b/client/DownloadClient.cpp index df4da25..b834622 100644 --- a/client/DownloadClient.cpp +++ b/client/DownloadClient.cpp @@ -19,7 +19,7 @@ void DownloadClient::Download(const string &filename) pair file(filename, 0); vector > fileList; fileList.push_back(file); - Download(fileList); + Download(fileList); } void DownloadClient::Download(const pair &file) @@ -46,6 +46,28 @@ void DownloadClient::Download(const vector > &fileList) DoDownload(); } +void DownloadClient::DoDownload() +{ + if (currentId < (int)files.size()) + { + currentId++; + pair file = files[currentId]; + QString filename = QString::fromLocal8Bit(file.first.c_str()); + string md5 = file.second; + current = new QFile(filename); + current->open(QIODevice::ReadWrite); + + Logger::Info("Downloading file %s\n", file.first.c_str()); + SendFileRequest(file.first); + } + else + { + Logger::Info("All files have been downloaded."); + isDownloading = false; + emit downloadFinished(); + } +} + void DownloadClient::FileDataRecieved(SslClient::RequestType &type, QByteArray &data) { if (type != RegularFile) @@ -86,25 +108,3 @@ void DownloadClient::FileDataRecieved(SslClient::RequestType &type, QByteArray & DoDownload(); } } - -void DownloadClient::DoDownload() -{ - if (currentId < (int)files.size()) - { - currentId++; - pair file = files[currentId]; - QString filename = QString::fromLocal8Bit(file.first.c_str()); - string md5 = file.second; - current = new QFile(filename); - current->open(QIODevice::ReadWrite); - - Logger::Info("Downloading file %s\n", file.first.c_str()); - SendFileRequest(file.first); - } - else - { - Logger::Info("All files have been downloaded."); - isDownloading = false; - emit downloadFinished(); - } -} -- cgit v1.2.3