summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper/storemail.cpp
authorzautrix <zautrix>2004-07-03 16:33:12 (UTC)
committer zautrix <zautrix>2004-07-03 16:33:12 (UTC)
commite3b89230f065c48c84b48c88edb6eb088374c487 (patch) (side-by-side diff)
tree162ea2ef909a6f82ccfcedf45d80d6c821174912 /kmicromail/libmailwrapper/storemail.cpp
parent2dd6ac0b2d24c91d35ce674a6c26351352df2b15 (diff)
downloadkdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.zip
kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.gz
kdepimpi-e3b89230f065c48c84b48c88edb6eb088374c487.tar.bz2
Initial revision
Diffstat (limited to 'kmicromail/libmailwrapper/storemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/storemail.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/kmicromail/libmailwrapper/storemail.cpp b/kmicromail/libmailwrapper/storemail.cpp
new file mode 100644
index 0000000..ed1d44a
--- a/dev/null
+++ b/kmicromail/libmailwrapper/storemail.cpp
@@ -0,0 +1,90 @@
+#include "storemail.h"
+#include "mailwrapper.h"
+#include "settings.h"
+#include "abstractmail.h"
+
+#include <libetpan/libetpan.h>
+#include <qstring.h>
+
+#include <stdlib.h>
+
+using namespace Opie::Core;
+Storemail::Storemail(Account*aAccount,const QString&aFolder)
+ : Generatemail()
+{
+ wrapper = 0;
+ m_Account = aAccount;
+ m_tfolder = aFolder;
+ wrapper = AbstractMail::getWrapper(m_Account);
+ if (wrapper) {
+ wrapper->createMbox(m_tfolder);
+ }
+}
+
+Storemail::Storemail(const QString&dir,const QString&aFolder)
+ : Generatemail()
+{
+ wrapper = 0;
+ m_Account = 0;
+ m_tfolder = aFolder;
+ wrapper = AbstractMail::getWrapper(dir);
+ if (wrapper) {
+ wrapper->createMbox(m_tfolder);
+ }
+}
+
+Storemail::Storemail(const QString&aFolder)
+ : Generatemail()
+{
+ wrapper = 0;
+ m_Account = 0;
+ m_tfolder = aFolder;
+ wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder());
+ if (wrapper) {
+ wrapper->createMbox(m_tfolder);
+ }
+}
+
+Storemail::~Storemail()
+{
+}
+
+int Storemail::storeMail(const Opie::Core::OSmartPointer<Mail>&mail)
+{
+ if (!wrapper) return 0;
+ int ret = 1;
+
+ mailmime * mimeMail = 0;
+ mimeMail = createMimeMail(mail );
+ if ( mimeMail == NULL ) {
+ qDebug("storeMail: error creating mime mail ");
+ return 0;
+ }
+ char *data;
+ size_t size;
+ data = 0;
+
+ mailmessage * msg = 0;
+ msg = mime_message_init(mimeMail);
+ mime_message_set_tmpdir(msg,getenv( "HOME" ));
+ int r = mailmessage_fetch(msg,&data,&size);
+ mime_message_detach_mime(msg);
+ mailmessage_free(msg);
+ msg = 0;
+ if (r != MAIL_NO_ERROR || !data) {
+ qDebug("Error fetching mime... ");
+ ret = 0;
+ }
+
+ if (ret) {
+ wrapper->storeMessage(data,size,m_tfolder);
+ }
+
+ if (data) {
+ free(data);
+ }
+ if (mimeMail) {
+ mailmime_free( mimeMail );
+ }
+ return ret;
+}