From f1de6e30f425713c4cef07a39310ca17f6dfdc55 Mon Sep 17 00:00:00 2001 From: rylek Date: Tue, 8 Dec 2009 15:23:58 +0000 Subject: [PATCH] Updated FtpClient::WhenProgress callback to get in sync with other progress callbacks in U++, i.e. a Gate2 (kohait00's contribution) git-svn-id: svn://ultimatepp.org/upp/trunk@1789 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/plugin/ftp/ftp.cpp | 18 +++++++++--------- uppsrc/plugin/ftp/ftp.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/uppsrc/plugin/ftp/ftp.cpp b/uppsrc/plugin/ftp/ftp.cpp index d120e41b4..610877eb2 100644 --- a/uppsrc/plugin/ftp/ftp.cpp +++ b/uppsrc/plugin/ftp/ftp.cpp @@ -37,7 +37,7 @@ bool FtpClient::Connect(const char *host, const char *user, const char *password Close(); char perror[512]; LLOG("FtpConnect(" << host << ")"); - if(WhenProgress()) { + if(WhenProgress(0,0)) { error = "connect aborted"; return false; } @@ -62,7 +62,7 @@ bool FtpClient::Connect(const char *host, const char *user, const char *password int FtpClient::Callback(netbuf *nControl, int xfered, void *arg) { - return !((FtpClient *)arg)->WhenProgress(); + return !((FtpClient *)arg)->WhenProgress(0,0); } void FtpClient::Close() @@ -89,7 +89,7 @@ String FtpClient::Load(const char *path) return String::GetVoid(); netbuf *ftpdata; LLOG("FtpAccess(" << path << ")"); - if(WhenProgress()) { + if(WhenProgress(0,0)) { error = t_("aborted"); return String::GetVoid(); } @@ -99,7 +99,7 @@ String FtpClient::Load(const char *path) } load_data = Null; int p = 0; - while(!WhenProgress()) { + while(!WhenProgress(0,0)) { byte buffer[1024]; int ndata = FtpRead(buffer, sizeof(buffer), ftpdata); LLOG("FtpRead -> " << ndata); @@ -138,14 +138,14 @@ int FtpClient::SaveCount(const char *path, String data) if(!CheckOpen()) return 0; LLOG("FtpAccess(" << path << ")"); - if(WhenProgress()) + if(WhenProgress(0,data.GetLength())) return 0; if(!FtpAccess(path, FTPLIB_FILE_WRITE, FTPLIB_IMAGE, ftpconn, &ftpdata)) { error = FtpError(ftpconn); return 0; } while(save_pos < data.GetLength()) { - if(WhenProgress()) { + if(WhenProgress(save_pos, data.GetLength())) { error = NFormat(t_("write aborted after %d bytes(s)"), save_pos); FtpClose(ftpdata); return save_pos; @@ -165,7 +165,7 @@ int FtpClient::SaveCount(const char *path, String data) ; #endif } - WhenProgress(); + WhenProgress(save_pos, data.GetLength()); LLOG("FtpClose"); FtpClose(ftpdata); return save_pos; @@ -223,7 +223,7 @@ String FtpClient::List(const char *path) return String::GetVoid(); netbuf *ftpdata; LLOG("FtpAccess(" << path << ")"); - if(WhenProgress()) { + if(WhenProgress(0,0)) { error = t_("aborted"); return String::GetVoid(); } @@ -232,7 +232,7 @@ String FtpClient::List(const char *path) return String::GetVoid(); } int p = 0; - while(!WhenProgress()) { + while(!WhenProgress(0,0)) { byte buffer[1024]; int ndata = FtpRead(buffer, sizeof(buffer), ftpdata); LLOG("FtpRead -> " << ndata); diff --git a/uppsrc/plugin/ftp/ftp.h b/uppsrc/plugin/ftp/ftp.h index 711735c31..efa467f65 100644 --- a/uppsrc/plugin/ftp/ftp.h +++ b/uppsrc/plugin/ftp/ftp.h @@ -41,7 +41,7 @@ public: bool CheckOpen(); public: - Gate WhenProgress; + Gate2 WhenProgress; private: static int Callback(netbuf *nControl, int xfered, void *arg);