author | zautrix <zautrix> | 2004-08-31 21:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-31 21:01:18 (UTC) |
commit | 3f5c51234c8068f3d4826a2a0066648ace21a19f (patch) (unidiff) | |
tree | 91b76c1c7ddec6628c573e409070070747d99feb /kmicromail/libmailwrapper/abstractmail.cpp | |
parent | 95f8d4f1de557bd25ae38807d970208399cec5d1 (diff) | |
download | kdepimpi-3f5c51234c8068f3d4826a2a0066648ace21a19f.zip kdepimpi-3f5c51234c8068f3d4826a2a0066648ace21a19f.tar.gz kdepimpi-3f5c51234c8068f3d4826a2a0066648ace21a19f.tar.bz2 |
Enhancements of kopiemail
Diffstat (limited to 'kmicromail/libmailwrapper/abstractmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kmicromail/libmailwrapper/abstractmail.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/kmicromail/libmailwrapper/abstractmail.cpp b/kmicromail/libmailwrapper/abstractmail.cpp index 128a7c0..3998abd 100644 --- a/kmicromail/libmailwrapper/abstractmail.cpp +++ b/kmicromail/libmailwrapper/abstractmail.cpp | |||
@@ -1,48 +1,49 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | ||
1 | #include "abstractmail.h" | 2 | #include "abstractmail.h" |
2 | #include "imapwrapper.h" | 3 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | 4 | #include "pop3wrapper.h" |
4 | #include "nntpwrapper.h" | 5 | #include "nntpwrapper.h" |
5 | #include "mhwrapper.h" | 6 | #include "mhwrapper.h" |
6 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
7 | 8 | ||
8 | 9 | ||
9 | 10 | ||
10 | #include <kdecore/kstandarddirs.h> | 11 | #include <kdecore/kstandarddirs.h> |
11 | #include <qfile.h> | 12 | #include <qfile.h> |
12 | #include <qtextstream.h> | 13 | #include <qtextstream.h> |
13 | #include <stdlib.h> | 14 | #include <stdlib.h> |
14 | #include <libetpan/mailmime_content.h> | 15 | #include <libetpan/mailmime_content.h> |
15 | #include <libetpan/mailmime.h> | 16 | #include <libetpan/mailmime.h> |
16 | 17 | ||
17 | using namespace Opie::Core; | 18 | using namespace Opie::Core; |
18 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 19 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
19 | { | 20 | { |
20 | return new IMAPwrapper(a); | 21 | return new IMAPwrapper(a); |
21 | } | 22 | } |
22 | 23 | ||
23 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 24 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
24 | { | 25 | { |
25 | return new POP3wrapper(a); | 26 | return new POP3wrapper(a); |
26 | } | 27 | } |
27 | 28 | ||
28 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) | 29 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) |
29 | { | 30 | { |
30 | return new NNTPwrapper(a); | 31 | return new NNTPwrapper(a); |
31 | } | 32 | } |
32 | 33 | ||
33 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) | 34 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) |
34 | { | 35 | { |
35 | return new MHwrapper(a,name); | 36 | return new MHwrapper(a,name); |
36 | } | 37 | } |
37 | 38 | ||
38 | AbstractMail* AbstractMail::getWrapper(Account*a) | 39 | AbstractMail* AbstractMail::getWrapper(Account*a) |
39 | { | 40 | { |
40 | if (!a) return 0; | 41 | if (!a) return 0; |
41 | switch (a->getType()) { | 42 | switch (a->getType()) { |
42 | case MAILLIB::A_IMAP: | 43 | case MAILLIB::A_IMAP: |
43 | return new IMAPwrapper((IMAPaccount*)a); | 44 | return new IMAPwrapper((IMAPaccount*)a); |
44 | break; | 45 | break; |
45 | case MAILLIB::A_POP3: | 46 | case MAILLIB::A_POP3: |
46 | return new POP3wrapper((POP3account*)a); | 47 | return new POP3wrapper((POP3account*)a); |
47 | break; | 48 | break; |
48 | case MAILLIB::A_NNTP: | 49 | case MAILLIB::A_NNTP: |
@@ -92,81 +93,95 @@ QString AbstractMail::convert_String(const char*text) | |||
92 | QString result(text); | 93 | QString result(text); |
93 | 94 | ||
94 | /* due a bug in libetpan it isn't usable this moment */ | 95 | /* due a bug in libetpan it isn't usable this moment */ |
95 | /* int err = mailmime_encoded_phrase_parse("iso-8859-1", | 96 | /* int err = mailmime_encoded_phrase_parse("iso-8859-1", |
96 | text, strlen(text),&index, "iso-8859-1",&res);*/ | 97 | text, strlen(text),&index, "iso-8859-1",&res);*/ |
97 | //odebug << "Input: " << text << "" << oendl; | 98 | //odebug << "Input: " << text << "" << oendl; |
98 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { | 99 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { |
99 | // result = QString(res); | 100 | // result = QString(res); |
100 | // odebug << "Res: " << res << ", length: " << strlen(res) << "" << oendl; | 101 | // odebug << "Res: " << res << ", length: " << strlen(res) << "" << oendl; |
101 | } | 102 | } |
102 | if (res) free(res); | 103 | if (res) free(res); |
103 | return result; | 104 | return result; |
104 | } | 105 | } |
105 | 106 | ||
106 | /* cp & paste from launcher */ | 107 | /* cp & paste from launcher */ |
107 | QString AbstractMail::gen_attachment_id() | 108 | QString AbstractMail::gen_attachment_id() |
108 | { | 109 | { |
109 | QFile file( "/proc/sys/kernel/random/uuid" ); | 110 | QFile file( "/proc/sys/kernel/random/uuid" ); |
110 | if (!file.open(IO_ReadOnly ) ) | 111 | if (!file.open(IO_ReadOnly ) ) |
111 | return QString::null; | 112 | return QString::null; |
112 | 113 | ||
113 | QTextStream stream(&file); | 114 | QTextStream stream(&file); |
114 | 115 | ||
115 | return "{" + stream.read().stripWhiteSpace() + "}"; | 116 | return "{" + stream.read().stripWhiteSpace() + "}"; |
116 | } | 117 | } |
117 | 118 | ||
118 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) | 119 | int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) |
119 | { | 120 | { |
120 | return 0; | 121 | return 0; |
121 | } | 122 | } |
122 | 123 | ||
123 | QString AbstractMail::defaultLocalfolder() | 124 | QString AbstractMail::defaultLocalfolder() |
124 | { | 125 | { |
125 | // QString f = getenv( "HOME" ); | 126 | // QString f = getenv( "HOME" ); |
126 | QString f = locateLocal( "data", "kmicromail/localmail"); | 127 | QString f = locateLocal( "data", "kmicromail/localmail"); |
127 | // f += "/Applications/opiemail/localmail"; | 128 | // f += "/Applications/opiemail/localmail"; |
128 | return f; | 129 | return f; |
129 | } | 130 | } |
130 | 131 | ||
131 | QString AbstractMail::draftFolder() | 132 | QString AbstractMail::draftFolder() |
132 | { | 133 | { |
133 | return QString("Drafts"); | 134 | return QString("Drafts"); |
134 | } | 135 | } |
135 | 136 | ||
136 | /* temporary - will be removed when implemented in all classes */ | 137 | /* temporary - will be removed when implemented in all classes */ |
137 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) | 138 | void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &) |
138 | { | 139 | { |
139 | } | 140 | } |
141 | void AbstractMail::deleteMailList(const QValueList<RecMailP>&target) | ||
142 | { | ||
143 | qDebug("AbstractMail::deleteMailList:: Please reimplement! "); | ||
140 | 144 | ||
145 | } | ||
141 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, | 146 | void AbstractMail::mvcpAllMails(const FolderP&fromFolder, |
142 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 147 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
148 | { | ||
149 | QValueList<RecMailP> t; | ||
150 | listMessages(fromFolder->getName(),t, maxSizeInKb); | ||
151 | mvcpMailList( t,targetFolder,targetWrapper,moveit); | ||
152 | |||
153 | } | ||
154 | void AbstractMail::mvcpMailList(const QValueList<RecMailP>& t, | ||
155 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | ||
143 | { | 156 | { |
144 | QValueList<RecMailP> t; | 157 | |
145 | listMessages(fromFolder->getName(),t); | ||
146 | encodedString*st = 0; | 158 | encodedString*st = 0; |
147 | while (t.count()>0) { | 159 | int iii = 0; |
148 | RecMailP r = (*t.begin()); | 160 | int count = t.count(); |
161 | while (iii < count ) { | ||
162 | RecMailP r = (*t.at( iii )); | ||
149 | st = fetchRawBody(r); | 163 | st = fetchRawBody(r); |
150 | if (st) { | 164 | if (st) { |
151 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 165 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
152 | delete st; | 166 | delete st; |
153 | } | 167 | } |
154 | t.remove(t.begin()); | 168 | ++iii; |
155 | } | 169 | } |
156 | if (moveit) { | 170 | if (moveit) { |
157 | deleteAllMail(fromFolder); | 171 | deleteMailList( t ); |
172 | //deleteAllMail(fromFolder); | ||
158 | } | 173 | } |
159 | } | 174 | } |
160 | 175 | ||
161 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 176 | void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
162 | { | 177 | { |
163 | encodedString*st = 0; | 178 | encodedString*st = 0; |
164 | st = fetchRawBody(mail); | 179 | st = fetchRawBody(mail); |
165 | if (st) { | 180 | if (st) { |
166 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 181 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
167 | delete st; | 182 | delete st; |
168 | } | 183 | } |
169 | if (moveit) { | 184 | if (moveit) { |
170 | deleteMail(mail); | 185 | deleteMail(mail); |
171 | } | 186 | } |
172 | } | 187 | } |