[sword-svn] r2932 - in trunk: include src/mgr src/modules utilities

scribe at crosswire.org scribe at crosswire.org
Wed Jul 31 07:07:01 MST 2013


Author: scribe
Date: 2013-07-31 07:07:01 -0700 (Wed, 31 Jul 2013)
New Revision: 2932

Modified:
   trunk/include/remotetrans.h
   trunk/src/mgr/curlftpt.cpp
   trunk/src/mgr/curlhttpt.cpp
   trunk/src/mgr/remotetrans.cpp
   trunk/src/modules/swmodule.cpp
   trunk/utilities/installmgr.cpp
Log:
Added better signature suggested by Jaak for StatusUpdater
updated utilities to use new signature
deprecated old signature
fixed unsafe memory return from stripText


Modified: trunk/include/remotetrans.h
===================================================================
--- trunk/include/remotetrans.h	2013-07-31 13:07:26 UTC (rev 2931)
+++ trunk/include/remotetrans.h	2013-07-31 14:07:01 UTC (rev 2932)
@@ -39,7 +39,8 @@
 	virtual void preStatus(long totalBytes, long completedBytes, const char *message);
 
 	/** frequently called throughout a download, to report status */
-	virtual void statusUpdate(double dtTotal, double dlNow);
+	SWDEPRECATED virtual void statusUpdate(double dtTotal, double dlNow);
+	virtual void update(unsigned long totalBytes, unsigned long completedBytes);
 };
 
 

Modified: trunk/src/mgr/curlftpt.cpp
===================================================================
--- trunk/src/mgr/curlftpt.cpp	2013-07-31 13:07:26 UTC (rev 2931)
+++ trunk/src/mgr/curlftpt.cpp	2013-07-31 14:07:01 UTC (rev 2932)
@@ -81,7 +81,10 @@
 		MyProgressData *pd = (MyProgressData *)clientp;
 SWLog::getSystemLog()->logDebug("CURLFTPTransport report progress: totalSize: %ld; xfered: %ld\n", (long)dltotal, (long)dlnow);
 		if (pd->sr) {
-			pd->sr->statusUpdate(dltotal, dlnow);
+			if (dltotal < 0) dltotal = 0;
+			if (dlnow < 0) dlnow = 0;
+			if (dlnow > dltotal) dlnow = dltotal;
+			pd->sr->update(dltotal, dlnow);
 		}
 		if (*(pd->term)) return 1;
 	}

Modified: trunk/src/mgr/curlhttpt.cpp
===================================================================
--- trunk/src/mgr/curlhttpt.cpp	2013-07-31 13:07:26 UTC (rev 2931)
+++ trunk/src/mgr/curlhttpt.cpp	2013-07-31 14:07:01 UTC (rev 2932)
@@ -78,7 +78,10 @@
 
 int my_httpfprogress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) {
 	if (clientp) {
-		((StatusReporter *)clientp)->statusUpdate(dltotal, dlnow);
+		if (dltotal < 0) dltotal = 0;
+		if (dlnow < 0) dlnow = 0;
+		if (dlnow > dltotal) dlnow = dltotal;
+		((StatusReporter *)clientp)->update(dltotal, dlnow);
 	}
 	return 0;
 }

Modified: trunk/src/mgr/remotetrans.cpp
===================================================================
--- trunk/src/mgr/remotetrans.cpp	2013-07-31 13:07:26 UTC (rev 2931)
+++ trunk/src/mgr/remotetrans.cpp	2013-07-31 14:07:01 UTC (rev 2932)
@@ -191,6 +191,12 @@
 	return retVal;
 }
 
+void StatusReporter::update(unsigned long totalBytes, unsigned long completedBytes) {
+#if defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
+	statusUpdate(totalBytes, completedBytes);
+}
 
 SWORD_NAMESPACE_END
 

Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp	2013-07-31 13:07:26 UTC (rev 2931)
+++ trunk/src/modules/swmodule.cpp	2013-07-31 14:07:01 UTC (rev 2932)
@@ -791,7 +791,9 @@
  */
 
 const char *SWModule::stripText(const char *buf, int len) {
-	return renderText(buf, len, false);
+	static SWBuf local;
+	local = renderText(buf, len, false);
+	return local.c_str();
 }
 
 

Modified: trunk/utilities/installmgr.cpp
===================================================================
--- trunk/utilities/installmgr.cpp	2013-07-31 13:07:26 UTC (rev 2931)
+++ trunk/utilities/installmgr.cpp	2013-07-31 14:07:01 UTC (rev 2932)
@@ -86,12 +86,12 @@
 
 class MyStatusReporter : public StatusReporter {
 	int last;
-        virtual void statusUpdate(double dltotal, double dlnow) {
-		int p = (int)(74.0 * (dlnow / dltotal));
+        virtual void update(unsigned long totalBytes, unsigned long completedBytes) {
+		int p = (totalBytes > 0) ? (int)(74.0 * ((double)completedBytes / (double)totalBytes)) : 0;
 		for (;last < p; ++last) {
 			if (!last) {
 				SWBuf output;
-				output.setFormatted("[ File Bytes: %ld", (long)dltotal);
+				output.setFormatted("[ File Bytes: %ld", totalBytes);
 				while (output.size() < 75) output += " ";
 				output += "]";
 				cout << output.c_str() << "\n ";




More information about the sword-cvs mailing list