m_type = type;
}
-bool
-Attachment::isSupported(GpgME::DataProvider::Operation op) const
+GpgME::Data &
+Attachment::get_data()
{
- return op == GpgME::DataProvider::Read ||
- op == GpgME::DataProvider::Write ||
- op == GpgME::DataProvider::Seek ||
- op == GpgME::DataProvider::Release;
-}
-
-ssize_t
-Attachment::read(void *buffer, size_t bufSize)
-{
- return m_data.read (buffer, bufSize);
-}
-
-ssize_t
-Attachment::write(const void *data, size_t size)
-{
- return m_data.write (data, size);
-}
-
-off_t Attachment::seek(off_t offset, int whence)
-{
- return m_data.seek (offset, whence);
-}
-
-void Attachment::release()
-{
- /* No op. */
- log_debug ("%s:%s", SRCNAME, __func__);
+ return m_data;
}
#include <string>
-#include <gpgme++/interfaces/dataprovider.h>
#include <gpgme++/data.h>
/** Helper class for attachment actions. */
-class Attachment : public GpgME::DataProvider
+class Attachment
{
public:
/** Creates and opens a new in memory attachment. */
void set_attach_type(attachtype_t type);
- /* Dataprovider interface */
- bool isSupported(Operation) const;
- ssize_t read(void *buffer, size_t bufSize);
- ssize_t write(const void *buffer, size_t bufSize);
- off_t seek(off_t offset, int whence);
- void release();
+ /* get the underlying data structure */
+ GpgME::Data& get_data();
private:
GpgME::Data m_data;
}
else if (m_mime_ctx->current_attachment && len)
{
- m_mime_ctx->current_attachment->write(linebuf, len);
+ m_mime_ctx->current_attachment->get_data().write(linebuf, len);
if (!m_mime_ctx->is_base64_encoded && !slbrk)
{
- m_mime_ctx->current_attachment->write("\r\n", 2);
+ m_mime_ctx->current_attachment->get_data().write("\r\n", 2);
}
}
else