aboutsummaryrefslogtreecommitdiffstats
path: root/src/utility/stream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utility/stream.cpp')
-rw-r--r--src/utility/stream.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/utility/stream.cpp b/src/utility/stream.cpp
index 397bf20b..3899eb52 100644
--- a/src/utility/stream.cpp
+++ b/src/utility/stream.cpp
@@ -23,6 +23,10 @@
#include <algorithm> // for std::copy
#include <iterator> // for std::back_inserter
+#if VMIME_HAVE_MESSAGING_FEATURES
+ #include "vmime/messaging/socket.hpp"
+#endif
+
namespace vmime {
namespace utility {
@@ -46,9 +50,19 @@ outputStream& operator<<(outputStream& os, const string& str)
const stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os)
{
+ return bufferedStreamCopy(is, os, 0, NULL);
+}
+
+
+const stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os,
+ const stream::size_type length, progressionListener* progress)
+{
stream::value_type buffer[65536];
stream::size_type total = 0;
+ if (progress != NULL)
+ progress->start(length);
+
while (!is.eof())
{
const stream::size_type read = is.read(buffer, sizeof(buffer));
@@ -57,9 +71,15 @@ const stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os)
{
os.write(buffer, read);
total += read;
+
+ if (progress != NULL)
+ progress->progress(total, std::max(total, length));
}
}
+ if (progress != NULL)
+ progress->stop(total);
+
return (total);
}
@@ -299,5 +319,28 @@ const stream::size_type inputStreamPointerAdapter::skip(const size_type count)
}
+// outputStreamSocketAdapter
+
+#ifdef VMIME_HAVE_MESSAGING_FEATURES
+
+
+outputStreamSocketAdapter::outputStreamSocketAdapter(messaging::socket& sok)
+ : m_socket(sok)
+{
+}
+
+
+void outputStreamSocketAdapter::write
+ (const value_type* const data, const size_type count)
+{
+ m_socket.sendRaw(data, count);
+}
+
+
+#endif // VMIME_HAVE_MESSAGING_FEATURES
+
+
+
+
} // utility
} // vmime