author | zautrix <zautrix> | 2004-10-31 08:38:17 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-31 08:38:17 (UTC) |
commit | f77a9457e676a11520c8f52b33265cd825db0c79 (patch) (unidiff) | |
tree | d35fc3ef29edf54f413c40621ae760407f659d0c | |
parent | c48af43f15e8917a441fc8ca4e1bc3adfd1d822e (diff) | |
download | kdepimpi-f77a9457e676a11520c8f52b33265cd825db0c79.zip kdepimpi-f77a9457e676a11520c8f52b33265cd825db0c79.tar.gz kdepimpi-f77a9457e676a11520c8f52b33265cd825db0c79.tar.bz2 |
added delete dir to ompi
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 3 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.cpp | 57 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mhwrapper.h | 1 |
3 files changed, 36 insertions, 25 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 3aec13d..110583f 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,945 +1,946 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include <qpe/global.h> | 4 | #include <qpe/global.h> |
5 | #include <qapplication.h> | 5 | #include <qapplication.h> |
6 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
7 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
8 | #include "logindialog.h" | 8 | #include "logindialog.h" |
9 | #include <qprogressbar.h> | 9 | #include <qprogressbar.h> |
10 | #include "genericwrapper.h" | 10 | #include "genericwrapper.h" |
11 | #include <kglobal.h> | 11 | #include <kglobal.h> |
12 | 12 | ||
13 | using namespace Opie::Core; | 13 | using namespace Opie::Core; |
14 | int IMAPwrapper::mMax = 0; | 14 | int IMAPwrapper::mMax = 0; |
15 | int IMAPwrapper::mCurrent = 0; | 15 | int IMAPwrapper::mCurrent = 0; |
16 | 16 | ||
17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
18 | : AbstractMail() | 18 | : AbstractMail() |
19 | { | 19 | { |
20 | account = a; | 20 | account = a; |
21 | m_imap = 0; | 21 | m_imap = 0; |
22 | m_Lastmbox = ""; | 22 | m_Lastmbox = ""; |
23 | mCurrent = 0; | 23 | mCurrent = 0; |
24 | mMax = 0; | 24 | mMax = 0; |
25 | } | 25 | } |
26 | 26 | ||
27 | IMAPwrapper::~IMAPwrapper() | 27 | IMAPwrapper::~IMAPwrapper() |
28 | { | 28 | { |
29 | logout(); | 29 | logout(); |
30 | } | 30 | } |
31 | 31 | ||
32 | /* to avoid to often select statements in loops etc. | 32 | /* to avoid to often select statements in loops etc. |
33 | we trust that we are logged in and connection is established!*/ | 33 | we trust that we are logged in and connection is established!*/ |
34 | int IMAPwrapper::selectMbox(const QString&mbox) | 34 | int IMAPwrapper::selectMbox(const QString&mbox) |
35 | { | 35 | { |
36 | if (mbox == m_Lastmbox) { | 36 | if (mbox == m_Lastmbox) { |
37 | return MAILIMAP_NO_ERROR; | 37 | return MAILIMAP_NO_ERROR; |
38 | } | 38 | } |
39 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 39 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
40 | if ( err != MAILIMAP_NO_ERROR ) { | 40 | if ( err != MAILIMAP_NO_ERROR ) { |
41 | m_Lastmbox = ""; | 41 | m_Lastmbox = ""; |
42 | return err; | 42 | return err; |
43 | } | 43 | } |
44 | m_Lastmbox = mbox; | 44 | m_Lastmbox = mbox; |
45 | return err; | 45 | return err; |
46 | } | 46 | } |
47 | 47 | ||
48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
49 | { | 49 | { |
50 | //qDebug("imap progress %d of %d ",current,maximum ); | 50 | //qDebug("imap progress %d of %d ",current,maximum ); |
51 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); | 51 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); |
52 | //qApp->processEvents() | 52 | //qApp->processEvents() |
53 | static int last = 0; | 53 | static int last = 0; |
54 | if ( last != current ) | 54 | if ( last != current ) |
55 | IMAPwrapper::progress(); | 55 | IMAPwrapper::progress(); |
56 | last = current; | 56 | last = current; |
57 | } | 57 | } |
58 | void IMAPwrapper::progress( QString m ) | 58 | void IMAPwrapper::progress( QString m ) |
59 | { | 59 | { |
60 | 60 | ||
61 | static QString mProgrMess; | 61 | static QString mProgrMess; |
62 | if ( m != QString::null ) { | 62 | if ( m != QString::null ) { |
63 | mProgrMess = m; | 63 | mProgrMess = m; |
64 | mCurrent = 1; | 64 | mCurrent = 1; |
65 | return; | 65 | return; |
66 | } | 66 | } |
67 | QString mess; | 67 | QString mess; |
68 | //qDebug("progress "); | 68 | //qDebug("progress "); |
69 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); | 69 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); |
70 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); | 70 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); |
71 | Global::statusMessage(mess); | 71 | Global::statusMessage(mess); |
72 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); | 72 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); |
73 | qApp->processEvents(); | 73 | qApp->processEvents(); |
74 | } | 74 | } |
75 | bool IMAPwrapper::start_tls(bool force_tls) | 75 | bool IMAPwrapper::start_tls(bool force_tls) |
76 | { | 76 | { |
77 | int err; | 77 | int err; |
78 | bool try_tls; | 78 | bool try_tls; |
79 | mailimap_capability_data * cap_data = 0; | 79 | mailimap_capability_data * cap_data = 0; |
80 | 80 | ||
81 | err = mailimap_capability(m_imap,&cap_data); | 81 | err = mailimap_capability(m_imap,&cap_data); |
82 | if (err != MAILIMAP_NO_ERROR) { | 82 | if (err != MAILIMAP_NO_ERROR) { |
83 | Global::statusMessage("error getting capabilities!"); | 83 | Global::statusMessage("error getting capabilities!"); |
84 | return false; | 84 | return false; |
85 | } | 85 | } |
86 | clistiter * cur; | 86 | clistiter * cur; |
87 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 87 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
88 | struct mailimap_capability * cap; | 88 | struct mailimap_capability * cap; |
89 | cap = (struct mailimap_capability *)clist_content(cur); | 89 | cap = (struct mailimap_capability *)clist_content(cur); |
90 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 90 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
91 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 91 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
92 | try_tls = true; | 92 | try_tls = true; |
93 | break; | 93 | break; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | if (cap_data) { | 97 | if (cap_data) { |
98 | mailimap_capability_data_free(cap_data); | 98 | mailimap_capability_data_free(cap_data); |
99 | } | 99 | } |
100 | if (try_tls) { | 100 | if (try_tls) { |
101 | err = mailimap_starttls(m_imap); | 101 | err = mailimap_starttls(m_imap); |
102 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 102 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
103 | Global::statusMessage(i18n("Server has no TLS support!")); | 103 | Global::statusMessage(i18n("Server has no TLS support!")); |
104 | try_tls = false; | 104 | try_tls = false; |
105 | } else { | 105 | } else { |
106 | mailstream_low * low; | 106 | mailstream_low * low; |
107 | mailstream_low * new_low; | 107 | mailstream_low * new_low; |
108 | low = mailstream_get_low(m_imap->imap_stream); | 108 | low = mailstream_get_low(m_imap->imap_stream); |
109 | if (!low) { | 109 | if (!low) { |
110 | try_tls = false; | 110 | try_tls = false; |
111 | } else { | 111 | } else { |
112 | int fd = mailstream_low_get_fd(low); | 112 | int fd = mailstream_low_get_fd(low); |
113 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 113 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
114 | mailstream_low_free(low); | 114 | mailstream_low_free(low); |
115 | mailstream_set_low(m_imap->imap_stream, new_low); | 115 | mailstream_set_low(m_imap->imap_stream, new_low); |
116 | } else { | 116 | } else { |
117 | try_tls = false; | 117 | try_tls = false; |
118 | } | 118 | } |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
122 | return try_tls; | 122 | return try_tls; |
123 | } | 123 | } |
124 | 124 | ||
125 | void IMAPwrapper::login() | 125 | void IMAPwrapper::login() |
126 | { | 126 | { |
127 | QString server, user, pass; | 127 | QString server, user, pass; |
128 | uint16_t port; | 128 | uint16_t port; |
129 | int err = MAILIMAP_NO_ERROR; | 129 | int err = MAILIMAP_NO_ERROR; |
130 | 130 | ||
131 | if (account->getOffline()) return; | 131 | if (account->getOffline()) return; |
132 | /* we are connected this moment */ | 132 | /* we are connected this moment */ |
133 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 133 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
134 | if (m_imap) { | 134 | if (m_imap) { |
135 | err = mailimap_noop(m_imap); | 135 | err = mailimap_noop(m_imap); |
136 | if (err!=MAILIMAP_NO_ERROR) { | 136 | if (err!=MAILIMAP_NO_ERROR) { |
137 | logout(); | 137 | logout(); |
138 | } else { | 138 | } else { |
139 | mailstream_flush(m_imap->imap_stream); | 139 | mailstream_flush(m_imap->imap_stream); |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | server = account->getServer(); | 143 | server = account->getServer(); |
144 | port = account->getPort().toUInt(); | 144 | port = account->getPort().toUInt(); |
145 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 145 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
146 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 146 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
147 | login.show(); | 147 | login.show(); |
148 | if ( QDialog::Accepted == login.exec() ) { | 148 | if ( QDialog::Accepted == login.exec() ) { |
149 | // ok | 149 | // ok |
150 | user = login.getUser(); | 150 | user = login.getUser(); |
151 | pass = login.getPassword(); | 151 | pass = login.getPassword(); |
152 | } else { | 152 | } else { |
153 | // cancel | 153 | // cancel |
154 | return; | 154 | return; |
155 | } | 155 | } |
156 | } else { | 156 | } else { |
157 | user = account->getUser(); | 157 | user = account->getUser(); |
158 | pass = account->getPassword(); | 158 | pass = account->getPassword(); |
159 | } | 159 | } |
160 | 160 | ||
161 | m_imap = mailimap_new( 20, &imap_progress ); | 161 | m_imap = mailimap_new( 20, &imap_progress ); |
162 | 162 | ||
163 | /* connect */ | 163 | /* connect */ |
164 | bool ssl = false; | 164 | bool ssl = false; |
165 | bool try_tls = false; | 165 | bool try_tls = false; |
166 | bool force_tls = false; | 166 | bool force_tls = false; |
167 | 167 | ||
168 | if ( account->ConnectionType() == 2 ) { | 168 | if ( account->ConnectionType() == 2 ) { |
169 | ssl = true; | 169 | ssl = true; |
170 | } | 170 | } |
171 | if (account->ConnectionType()==1) { | 171 | if (account->ConnectionType()==1) { |
172 | force_tls = true; | 172 | force_tls = true; |
173 | } | 173 | } |
174 | 174 | ||
175 | if ( ssl ) { | 175 | if ( ssl ) { |
176 | //qDebug("using ssl "); | 176 | qDebug("using ssl "); |
177 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); | 177 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); |
178 | qDebug("back "); | ||
178 | } else { | 179 | } else { |
179 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); | 180 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); |
180 | } | 181 | } |
181 | 182 | ||
182 | if ( err != MAILIMAP_NO_ERROR && | 183 | if ( err != MAILIMAP_NO_ERROR && |
183 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 184 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
184 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 185 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
185 | QString failure = ""; | 186 | QString failure = ""; |
186 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 187 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
187 | failure="Connection refused"; | 188 | failure="Connection refused"; |
188 | } else { | 189 | } else { |
189 | failure="Unknown failure"; | 190 | failure="Unknown failure"; |
190 | } | 191 | } |
191 | Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); | 192 | Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); |
192 | mailimap_free( m_imap ); | 193 | mailimap_free( m_imap ); |
193 | m_imap = 0; | 194 | m_imap = 0; |
194 | return; | 195 | return; |
195 | } | 196 | } |
196 | 197 | ||
197 | if (!ssl) { | 198 | if (!ssl) { |
198 | try_tls = start_tls(force_tls); | 199 | try_tls = start_tls(force_tls); |
199 | } | 200 | } |
200 | 201 | ||
201 | bool ok = true; | 202 | bool ok = true; |
202 | if (force_tls && !try_tls) { | 203 | if (force_tls && !try_tls) { |
203 | Global::statusMessage(i18n("Server has no TLS support!")); | 204 | Global::statusMessage(i18n("Server has no TLS support!")); |
204 | ok = false; | 205 | ok = false; |
205 | } | 206 | } |
206 | 207 | ||
207 | 208 | ||
208 | /* login */ | 209 | /* login */ |
209 | 210 | ||
210 | if (ok) { | 211 | if (ok) { |
211 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); | 212 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); |
212 | if ( err != MAILIMAP_NO_ERROR ) { | 213 | if ( err != MAILIMAP_NO_ERROR ) { |
213 | Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); | 214 | Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); |
214 | ok = false; | 215 | ok = false; |
215 | } | 216 | } |
216 | } | 217 | } |
217 | if (!ok) { | 218 | if (!ok) { |
218 | err = mailimap_close( m_imap ); | 219 | err = mailimap_close( m_imap ); |
219 | mailimap_free( m_imap ); | 220 | mailimap_free( m_imap ); |
220 | m_imap = 0; | 221 | m_imap = 0; |
221 | } | 222 | } |
222 | } | 223 | } |
223 | 224 | ||
224 | void IMAPwrapper::logout() | 225 | void IMAPwrapper::logout() |
225 | { | 226 | { |
226 | int err = MAILIMAP_NO_ERROR; | 227 | int err = MAILIMAP_NO_ERROR; |
227 | if (!m_imap) return; | 228 | if (!m_imap) return; |
228 | err = mailimap_logout( m_imap ); | 229 | err = mailimap_logout( m_imap ); |
229 | err = mailimap_close( m_imap ); | 230 | err = mailimap_close( m_imap ); |
230 | mailimap_free( m_imap ); | 231 | mailimap_free( m_imap ); |
231 | m_imap = 0; | 232 | m_imap = 0; |
232 | m_Lastmbox = ""; | 233 | m_Lastmbox = ""; |
233 | } | 234 | } |
234 | 235 | ||
235 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) | 236 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) |
236 | { | 237 | { |
237 | 238 | ||
238 | int tryAgain = 1; | 239 | int tryAgain = 1; |
239 | while ( tryAgain >= 0 ) { | 240 | while ( tryAgain >= 0 ) { |
240 | int err = MAILIMAP_NO_ERROR; | 241 | int err = MAILIMAP_NO_ERROR; |
241 | clist *result = 0; | 242 | clist *result = 0; |
242 | clistcell *current; | 243 | clistcell *current; |
243 | mailimap_fetch_type *fetchType = 0; | 244 | mailimap_fetch_type *fetchType = 0; |
244 | mailimap_set *set = 0; | 245 | mailimap_set *set = 0; |
245 | 246 | ||
246 | login(); | 247 | login(); |
247 | if (!m_imap) { | 248 | if (!m_imap) { |
248 | return; | 249 | return; |
249 | } | 250 | } |
250 | /* select mailbox READONLY for operations */ | 251 | /* select mailbox READONLY for operations */ |
251 | err = selectMbox(mailbox); | 252 | err = selectMbox(mailbox); |
252 | if ( err != MAILIMAP_NO_ERROR ) { | 253 | if ( err != MAILIMAP_NO_ERROR ) { |
253 | return; | 254 | return; |
254 | } | 255 | } |
255 | 256 | ||
256 | int last = m_imap->imap_selection_info->sel_exists; | 257 | int last = m_imap->imap_selection_info->sel_exists; |
257 | 258 | ||
258 | if (last == 0) { | 259 | if (last == 0) { |
259 | Global::statusMessage(i18n("Mailbox has no mails")); | 260 | Global::statusMessage(i18n("Mailbox has no mails")); |
260 | return; | 261 | return; |
261 | } else { | 262 | } else { |
262 | } | 263 | } |
263 | progress( i18n("Fetch ")); | 264 | progress( i18n("Fetch ")); |
264 | mMax = last; | 265 | mMax = last; |
265 | //qDebug("last %d ", last); | 266 | //qDebug("last %d ", last); |
266 | Global::statusMessage(i18n("Fetching header list")); | 267 | Global::statusMessage(i18n("Fetching header list")); |
267 | qApp->processEvents(); | 268 | qApp->processEvents(); |
268 | /* the range has to start at 1!!! not with 0!!!! */ | 269 | /* the range has to start at 1!!! not with 0!!!! */ |
269 | //LR the access to web.de imap server is no working with value 1 | 270 | //LR the access to web.de imap server is no working with value 1 |
270 | //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); | 271 | //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); |
271 | set = mailimap_set_new_interval( tryAgain, last ); | 272 | set = mailimap_set_new_interval( tryAgain, last ); |
272 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 273 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
273 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 274 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
274 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 275 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
275 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 276 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
276 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 277 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
277 | 278 | ||
278 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 279 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
279 | mailimap_set_free( set ); | 280 | mailimap_set_free( set ); |
280 | mailimap_fetch_type_free( fetchType ); | 281 | mailimap_fetch_type_free( fetchType ); |
281 | 282 | ||
282 | QString date,subject,from; | 283 | QString date,subject,from; |
283 | 284 | ||
284 | if ( err == MAILIMAP_NO_ERROR ) { | 285 | if ( err == MAILIMAP_NO_ERROR ) { |
285 | tryAgain = -1; | 286 | tryAgain = -1; |
286 | mailimap_msg_att * msg_att; | 287 | mailimap_msg_att * msg_att; |
287 | int i = 0; | 288 | int i = 0; |
288 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 289 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
289 | ++i; | 290 | ++i; |
290 | //qDebug("iii %d ",i); | 291 | //qDebug("iii %d ",i); |
291 | msg_att = (mailimap_msg_att*)current->data; | 292 | msg_att = (mailimap_msg_att*)current->data; |
292 | RecMail*m = parse_list_result(msg_att); | 293 | RecMail*m = parse_list_result(msg_att); |
293 | if (m) { | 294 | if (m) { |
294 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { | 295 | if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { |
295 | m->setNumber(i); | 296 | m->setNumber(i); |
296 | m->setMbox(mailbox); | 297 | m->setMbox(mailbox); |
297 | m->setWrapper(this); | 298 | m->setWrapper(this); |
298 | target.append(m); | 299 | target.append(m); |
299 | } | 300 | } |
300 | } | 301 | } |
301 | } | 302 | } |
302 | Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); | 303 | Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); |
303 | } else { | 304 | } else { |
304 | --tryAgain; | 305 | --tryAgain; |
305 | --tryAgain;//disabled tryagain by adding this line | 306 | --tryAgain;//disabled tryagain by adding this line |
306 | if ( tryAgain < 0 ) | 307 | if ( tryAgain < 0 ) |
307 | Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); | 308 | Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); |
308 | else | 309 | else |
309 | qDebug("try again... "); | 310 | qDebug("try again... "); |
310 | } | 311 | } |
311 | 312 | ||
312 | if (result) mailimap_fetch_list_free(result); | 313 | if (result) mailimap_fetch_list_free(result); |
313 | } | 314 | } |
314 | } | 315 | } |
315 | 316 | ||
316 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 317 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
317 | { | 318 | { |
318 | const char *path, *mask; | 319 | const char *path, *mask; |
319 | int err = MAILIMAP_NO_ERROR; | 320 | int err = MAILIMAP_NO_ERROR; |
320 | clist *result = 0; | 321 | clist *result = 0; |
321 | clistcell *current = 0; | 322 | clistcell *current = 0; |
322 | clistcell*cur_flag = 0; | 323 | clistcell*cur_flag = 0; |
323 | mailimap_mbx_list_flags*bflags = 0; | 324 | mailimap_mbx_list_flags*bflags = 0; |
324 | 325 | ||
325 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 326 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
326 | login(); | 327 | login(); |
327 | if (!m_imap) { | 328 | if (!m_imap) { |
328 | return folders; | 329 | return folders; |
329 | } | 330 | } |
330 | 331 | ||
331 | /* | 332 | /* |
332 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 333 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
333 | * We must not forget to filter them out in next loop! | 334 | * We must not forget to filter them out in next loop! |
334 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 335 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
335 | */ | 336 | */ |
336 | Global::statusMessage(i18n("Fetching folder list")); | 337 | Global::statusMessage(i18n("Fetching folder list")); |
337 | qApp->processEvents(); | 338 | qApp->processEvents(); |
338 | QString temp; | 339 | QString temp; |
339 | mask = "INBOX" ; | 340 | mask = "INBOX" ; |
340 | mailimap_mailbox_list *list; | 341 | mailimap_mailbox_list *list; |
341 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 342 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
342 | QString del; | 343 | QString del; |
343 | bool selectable = true; | 344 | bool selectable = true; |
344 | bool no_inferiors = false; | 345 | bool no_inferiors = false; |
345 | if ( err == MAILIMAP_NO_ERROR ) { | 346 | if ( err == MAILIMAP_NO_ERROR ) { |
346 | current = result->first; | 347 | current = result->first; |
347 | for ( int i = result->count; i > 0; i-- ) { | 348 | for ( int i = result->count; i > 0; i-- ) { |
348 | list = (mailimap_mailbox_list *) current->data; | 349 | list = (mailimap_mailbox_list *) current->data; |
349 | // it is better use the deep copy mechanism of qt itself | 350 | // it is better use the deep copy mechanism of qt itself |
350 | // instead of using strdup! | 351 | // instead of using strdup! |
351 | temp = list->mb_name; | 352 | temp = list->mb_name; |
352 | del = list->mb_delimiter; | 353 | del = list->mb_delimiter; |
353 | current = current->next; | 354 | current = current->next; |
354 | if ( (bflags = list->mb_flag) ) { | 355 | if ( (bflags = list->mb_flag) ) { |
355 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 356 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
356 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 357 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
357 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 358 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
358 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 359 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
359 | no_inferiors = true; | 360 | no_inferiors = true; |
360 | } | 361 | } |
361 | } | 362 | } |
362 | } | 363 | } |
363 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 364 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
364 | } | 365 | } |
365 | } else { | 366 | } else { |
366 | qDebug("error fetching folders: "); | 367 | qDebug("error fetching folders: "); |
367 | 368 | ||
368 | } | 369 | } |
369 | mailimap_list_result_free( result ); | 370 | mailimap_list_result_free( result ); |
370 | 371 | ||
371 | /* | 372 | /* |
372 | * second stage - get the other then inbox folders | 373 | * second stage - get the other then inbox folders |
373 | */ | 374 | */ |
374 | mask = "*" ; | 375 | mask = "*" ; |
375 | path = account->getPrefix().latin1(); | 376 | path = account->getPrefix().latin1(); |
376 | if (!path) path = ""; | 377 | if (!path) path = ""; |
377 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 378 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
378 | if ( err == MAILIMAP_NO_ERROR ) { | 379 | if ( err == MAILIMAP_NO_ERROR ) { |
379 | current = result->first; | 380 | current = result->first; |
380 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 381 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
381 | no_inferiors = false; | 382 | no_inferiors = false; |
382 | list = (mailimap_mailbox_list *) current->data; | 383 | list = (mailimap_mailbox_list *) current->data; |
383 | // it is better use the deep copy mechanism of qt itself | 384 | // it is better use the deep copy mechanism of qt itself |
384 | // instead of using strdup! | 385 | // instead of using strdup! |
385 | temp = list->mb_name; | 386 | temp = list->mb_name; |
386 | if (temp.lower()=="inbox") | 387 | if (temp.lower()=="inbox") |
387 | continue; | 388 | continue; |
388 | if (temp.lower()==account->getPrefix().lower()) | 389 | if (temp.lower()==account->getPrefix().lower()) |
389 | continue; | 390 | continue; |
390 | if ( (bflags = list->mb_flag) ) { | 391 | if ( (bflags = list->mb_flag) ) { |
391 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 392 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
392 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 393 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
393 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 394 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
394 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 395 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
395 | no_inferiors = true; | 396 | no_inferiors = true; |
396 | } | 397 | } |
397 | } | 398 | } |
398 | } | 399 | } |
399 | del = list->mb_delimiter; | 400 | del = list->mb_delimiter; |
400 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 401 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
401 | } | 402 | } |
402 | } else { | 403 | } else { |
403 | qDebug("error fetching folders "); | 404 | qDebug("error fetching folders "); |
404 | 405 | ||
405 | } | 406 | } |
406 | if (result) mailimap_list_result_free( result ); | 407 | if (result) mailimap_list_result_free( result ); |
407 | return folders; | 408 | return folders; |
408 | } | 409 | } |
409 | 410 | ||
410 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 411 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
411 | { | 412 | { |
412 | RecMail * m = 0; | 413 | RecMail * m = 0; |
413 | mailimap_msg_att_item *item=0; | 414 | mailimap_msg_att_item *item=0; |
414 | clistcell *current,*c,*cf; | 415 | clistcell *current,*c,*cf; |
415 | mailimap_msg_att_dynamic*flist; | 416 | mailimap_msg_att_dynamic*flist; |
416 | mailimap_flag_fetch*cflag; | 417 | mailimap_flag_fetch*cflag; |
417 | int size; | 418 | int size; |
418 | QBitArray mFlags(7); | 419 | QBitArray mFlags(7); |
419 | QStringList addresslist; | 420 | QStringList addresslist; |
420 | 421 | ||
421 | if (!m_att) { | 422 | if (!m_att) { |
422 | return m; | 423 | return m; |
423 | } | 424 | } |
424 | m = new RecMail(); | 425 | m = new RecMail(); |
425 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 426 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
426 | current = c; | 427 | current = c; |
427 | size = 0; | 428 | size = 0; |
428 | item = (mailimap_msg_att_item*)current->data; | 429 | item = (mailimap_msg_att_item*)current->data; |
429 | if ( !item ) | 430 | if ( !item ) |
430 | continue; | 431 | continue; |
431 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 432 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
432 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 433 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
433 | if (!flist || !flist->att_list) { | 434 | if (!flist || !flist->att_list) { |
434 | continue; | 435 | continue; |
435 | } | 436 | } |
436 | cf = flist->att_list->first; | 437 | cf = flist->att_list->first; |
437 | if( ! cf ) | 438 | if( ! cf ) |
438 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 439 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
439 | cflag = (mailimap_flag_fetch*)cf->data; | 440 | cflag = (mailimap_flag_fetch*)cf->data; |
440 | if( ! cflag ) | 441 | if( ! cflag ) |
441 | qDebug("imap:not cflag "); | 442 | qDebug("imap:not cflag "); |
442 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 443 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
443 | switch (cflag->fl_flag->fl_type) { | 444 | switch (cflag->fl_flag->fl_type) { |
444 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 445 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
445 | mFlags.setBit(FLAG_ANSWERED); | 446 | mFlags.setBit(FLAG_ANSWERED); |
446 | break; | 447 | break; |
447 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 448 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
448 | mFlags.setBit(FLAG_FLAGGED); | 449 | mFlags.setBit(FLAG_FLAGGED); |
449 | break; | 450 | break; |
450 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 451 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
451 | mFlags.setBit(FLAG_DELETED); | 452 | mFlags.setBit(FLAG_DELETED); |
452 | break; | 453 | break; |
453 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 454 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
454 | mFlags.setBit(FLAG_SEEN); | 455 | mFlags.setBit(FLAG_SEEN); |
455 | break; | 456 | break; |
456 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 457 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
457 | mFlags.setBit(FLAG_DRAFT); | 458 | mFlags.setBit(FLAG_DRAFT); |
458 | break; | 459 | break; |
459 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 460 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
460 | break; | 461 | break; |
461 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 462 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
462 | break; | 463 | break; |
463 | default: | 464 | default: |
464 | break; | 465 | break; |
465 | } | 466 | } |
466 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 467 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
467 | mFlags.setBit(FLAG_RECENT); | 468 | mFlags.setBit(FLAG_RECENT); |
468 | } | 469 | } |
469 | } | 470 | } |
470 | continue; | 471 | continue; |
471 | } | 472 | } |
472 | if ( item->att_data.att_static == NULL ) | 473 | if ( item->att_data.att_static == NULL ) |
473 | continue; | 474 | continue; |
474 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 475 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
475 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 476 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
476 | if ( head == NULL ) | 477 | if ( head == NULL ) |
477 | continue; | 478 | continue; |
478 | if ( head->env_date != NULL ) { | 479 | if ( head->env_date != NULL ) { |
479 | m->setDate(head->env_date); | 480 | m->setDate(head->env_date); |
480 | struct mailimf_date_time result; | 481 | struct mailimf_date_time result; |
481 | struct mailimf_date_time* date = &result; | 482 | struct mailimf_date_time* date = &result; |
482 | struct mailimf_date_time **re = &date; | 483 | struct mailimf_date_time **re = &date; |
483 | size_t length = m->getDate().length(); | 484 | size_t length = m->getDate().length(); |
484 | size_t index = 0; | 485 | size_t index = 0; |
485 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { | 486 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { |
486 | QDateTime dt = Genericwrapper::parseDateTime( date ); | 487 | QDateTime dt = Genericwrapper::parseDateTime( date ); |
487 | QString ret; | 488 | QString ret; |
488 | if ( dt.date() == QDate::currentDate () ) | 489 | if ( dt.date() == QDate::currentDate () ) |
489 | ret = KGlobal::locale()->formatTime( dt.time(),true); | 490 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
490 | else { | 491 | else { |
491 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 492 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
492 | } | 493 | } |
493 | m->setDate( ret ); | 494 | m->setDate( ret ); |
494 | char tmp[20]; | 495 | char tmp[20]; |
495 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", | 496 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", |
496 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); | 497 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); |
497 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); | 498 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); |
498 | m->setIsoDate( QString( tmp ) ); | 499 | m->setIsoDate( QString( tmp ) ); |
499 | } else { | 500 | } else { |
500 | m->setIsoDate(head->env_date); | 501 | m->setIsoDate(head->env_date); |
501 | } | 502 | } |
502 | } | 503 | } |
503 | if ( head->env_subject != NULL ) | 504 | if ( head->env_subject != NULL ) |
504 | m->setSubject(convert_String((const char*)head->env_subject)); | 505 | m->setSubject(convert_String((const char*)head->env_subject)); |
505 | //m->setSubject(head->env_subject); | 506 | //m->setSubject(head->env_subject); |
506 | if (head->env_from!=NULL) { | 507 | if (head->env_from!=NULL) { |
507 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 508 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
508 | if (addresslist.count()) { | 509 | if (addresslist.count()) { |
509 | m->setFrom(addresslist.first()); | 510 | m->setFrom(addresslist.first()); |
510 | } | 511 | } |
511 | } | 512 | } |
512 | if (head->env_to!=NULL) { | 513 | if (head->env_to!=NULL) { |
513 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 514 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
514 | m->setTo(addresslist); | 515 | m->setTo(addresslist); |
515 | } | 516 | } |
516 | if (head->env_cc!=NULL) { | 517 | if (head->env_cc!=NULL) { |
517 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 518 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
518 | m->setCC(addresslist); | 519 | m->setCC(addresslist); |
519 | } | 520 | } |
520 | if (head->env_bcc!=NULL) { | 521 | if (head->env_bcc!=NULL) { |
521 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 522 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
522 | m->setBcc(addresslist); | 523 | m->setBcc(addresslist); |
523 | } | 524 | } |
524 | /* reply to address, eg. email. */ | 525 | /* reply to address, eg. email. */ |
525 | if (head->env_reply_to!=NULL) { | 526 | if (head->env_reply_to!=NULL) { |
526 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 527 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
527 | if (addresslist.count()) { | 528 | if (addresslist.count()) { |
528 | m->setReplyto(addresslist.first()); | 529 | m->setReplyto(addresslist.first()); |
529 | } | 530 | } |
530 | } | 531 | } |
531 | if (head->env_in_reply_to!=NULL) { | 532 | if (head->env_in_reply_to!=NULL) { |
532 | QString h(head->env_in_reply_to); | 533 | QString h(head->env_in_reply_to); |
533 | while (h.length()>0 && h[0]=='<') { | 534 | while (h.length()>0 && h[0]=='<') { |
534 | h.remove(0,1); | 535 | h.remove(0,1); |
535 | } | 536 | } |
536 | while (h.length()>0 && h[h.length()-1]=='>') { | 537 | while (h.length()>0 && h[h.length()-1]=='>') { |
537 | h.remove(h.length()-1,1); | 538 | h.remove(h.length()-1,1); |
538 | } | 539 | } |
539 | if (h.length()>0) { | 540 | if (h.length()>0) { |
540 | m->setInreply(QStringList(h)); | 541 | m->setInreply(QStringList(h)); |
541 | } | 542 | } |
542 | } | 543 | } |
543 | if (head->env_message_id != NULL) { | 544 | if (head->env_message_id != NULL) { |
544 | m->setMsgid(QString(head->env_message_id)); | 545 | m->setMsgid(QString(head->env_message_id)); |
545 | } | 546 | } |
546 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 547 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
547 | #if 0 | 548 | #if 0 |
548 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 549 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
549 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 550 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
550 | qDebug("time %s ",da.toString().latin1() ); | 551 | qDebug("time %s ",da.toString().latin1() ); |
551 | #endif | 552 | #endif |
552 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 553 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
553 | size = item->att_data.att_static->att_data.att_rfc822_size; | 554 | size = item->att_data.att_static->att_data.att_rfc822_size; |
554 | } | 555 | } |
555 | } | 556 | } |
556 | /* msg is already deleted */ | 557 | /* msg is already deleted */ |
557 | if (mFlags.testBit(FLAG_DELETED) && m) { | 558 | if (mFlags.testBit(FLAG_DELETED) && m) { |
558 | delete m; | 559 | delete m; |
559 | m = 0; | 560 | m = 0; |
560 | } | 561 | } |
561 | if (m) { | 562 | if (m) { |
562 | m->setFlags(mFlags); | 563 | m->setFlags(mFlags); |
563 | m->setMsgsize(size); | 564 | m->setMsgsize(size); |
564 | } | 565 | } |
565 | return m; | 566 | return m; |
566 | } | 567 | } |
567 | 568 | ||
568 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 569 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
569 | { | 570 | { |
570 | RecBodyP body = new RecBody(); | 571 | RecBodyP body = new RecBody(); |
571 | const char *mb; | 572 | const char *mb; |
572 | int err = MAILIMAP_NO_ERROR; | 573 | int err = MAILIMAP_NO_ERROR; |
573 | clist *result = 0; | 574 | clist *result = 0; |
574 | clistcell *current; | 575 | clistcell *current; |
575 | mailimap_fetch_att *fetchAtt = 0; | 576 | mailimap_fetch_att *fetchAtt = 0; |
576 | mailimap_fetch_type *fetchType = 0; | 577 | mailimap_fetch_type *fetchType = 0; |
577 | mailimap_set *set = 0; | 578 | mailimap_set *set = 0; |
578 | mailimap_body*body_desc = 0; | 579 | mailimap_body*body_desc = 0; |
579 | 580 | ||
580 | mb = mail->getMbox().latin1(); | 581 | mb = mail->getMbox().latin1(); |
581 | 582 | ||
582 | login(); | 583 | login(); |
583 | if (!m_imap) { | 584 | if (!m_imap) { |
584 | return body; | 585 | return body; |
585 | } | 586 | } |
586 | err = selectMbox(mail->getMbox()); | 587 | err = selectMbox(mail->getMbox()); |
587 | if ( err != MAILIMAP_NO_ERROR ) { | 588 | if ( err != MAILIMAP_NO_ERROR ) { |
588 | return body; | 589 | return body; |
589 | } | 590 | } |
590 | 591 | ||
591 | /* the range has to start at 1!!! not with 0!!!! */ | 592 | /* the range has to start at 1!!! not with 0!!!! */ |
592 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); | 593 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
593 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 594 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
594 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 595 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
595 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 596 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
596 | mailimap_set_free( set ); | 597 | mailimap_set_free( set ); |
597 | mailimap_fetch_type_free( fetchType ); | 598 | mailimap_fetch_type_free( fetchType ); |
598 | 599 | ||
599 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 600 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
600 | mailimap_msg_att * msg_att; | 601 | mailimap_msg_att * msg_att; |
601 | msg_att = (mailimap_msg_att*)current->data; | 602 | msg_att = (mailimap_msg_att*)current->data; |
602 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 603 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
603 | QValueList<int> path; | 604 | QValueList<int> path; |
604 | body_desc = item->att_data.att_static->att_data.att_body; | 605 | body_desc = item->att_data.att_static->att_data.att_body; |
605 | traverseBody(mail,body_desc,body,0,path); | 606 | traverseBody(mail,body_desc,body,0,path); |
606 | } else { | 607 | } else { |
607 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; | 608 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; |
608 | } | 609 | } |
609 | if (result) mailimap_fetch_list_free(result); | 610 | if (result) mailimap_fetch_list_free(result); |
610 | return body; | 611 | return body; |
611 | } | 612 | } |
612 | 613 | ||
613 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 614 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
614 | { | 615 | { |
615 | QStringList l; | 616 | QStringList l; |
616 | QString from; | 617 | QString from; |
617 | bool named_from; | 618 | bool named_from; |
618 | clistcell *current = NULL; | 619 | clistcell *current = NULL; |
619 | mailimap_address * current_address=NULL; | 620 | mailimap_address * current_address=NULL; |
620 | if (!list) { | 621 | if (!list) { |
621 | return l; | 622 | return l; |
622 | } | 623 | } |
623 | unsigned int count = 0; | 624 | unsigned int count = 0; |
624 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 625 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
625 | from = ""; | 626 | from = ""; |
626 | named_from = false; | 627 | named_from = false; |
627 | current_address=(mailimap_address*)current->data; | 628 | current_address=(mailimap_address*)current->data; |
628 | if (current_address->ad_personal_name){ | 629 | if (current_address->ad_personal_name){ |
629 | from+=convert_String((const char*)current_address->ad_personal_name); | 630 | from+=convert_String((const char*)current_address->ad_personal_name); |
630 | from+=" "; | 631 | from+=" "; |
631 | named_from = true; | 632 | named_from = true; |
632 | } | 633 | } |
633 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 634 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
634 | from+="<"; | 635 | from+="<"; |
635 | } | 636 | } |
636 | if (current_address->ad_mailbox_name) { | 637 | if (current_address->ad_mailbox_name) { |
637 | from+=QString(current_address->ad_mailbox_name); | 638 | from+=QString(current_address->ad_mailbox_name); |
638 | from+="@"; | 639 | from+="@"; |
639 | } | 640 | } |
640 | if (current_address->ad_host_name) { | 641 | if (current_address->ad_host_name) { |
641 | from+=QString(current_address->ad_host_name); | 642 | from+=QString(current_address->ad_host_name); |
642 | } | 643 | } |
643 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 644 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
644 | from+=">"; | 645 | from+=">"; |
645 | } | 646 | } |
646 | l.append(QString(from)); | 647 | l.append(QString(from)); |
647 | if (++count > 99) { | 648 | if (++count > 99) { |
648 | break; | 649 | break; |
649 | } | 650 | } |
650 | } | 651 | } |
651 | return l; | 652 | return l; |
652 | } | 653 | } |
653 | 654 | ||
654 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) | 655 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) |
655 | { | 656 | { |
656 | encodedString*res=new encodedString; | 657 | encodedString*res=new encodedString; |
657 | int err; | 658 | int err; |
658 | mailimap_fetch_type *fetchType; | 659 | mailimap_fetch_type *fetchType; |
659 | mailimap_set *set; | 660 | mailimap_set *set; |
660 | clistcell*current,*cur; | 661 | clistcell*current,*cur; |
661 | mailimap_section_part * section_part = 0; | 662 | mailimap_section_part * section_part = 0; |
662 | mailimap_section_spec * section_spec = 0; | 663 | mailimap_section_spec * section_spec = 0; |
663 | mailimap_section * section = 0; | 664 | mailimap_section * section = 0; |
664 | mailimap_fetch_att * fetch_att = 0; | 665 | mailimap_fetch_att * fetch_att = 0; |
665 | 666 | ||
666 | login(); | 667 | login(); |
667 | if (!m_imap) { | 668 | if (!m_imap) { |
668 | return res; | 669 | return res; |
669 | } | 670 | } |
670 | if (!internal_call) { | 671 | if (!internal_call) { |
671 | err = selectMbox(mail->getMbox()); | 672 | err = selectMbox(mail->getMbox()); |
672 | if ( err != MAILIMAP_NO_ERROR ) { | 673 | if ( err != MAILIMAP_NO_ERROR ) { |
673 | return res; | 674 | return res; |
674 | } | 675 | } |
675 | } | 676 | } |
676 | set = mailimap_set_new_single(mail->getNumber()); | 677 | set = mailimap_set_new_single(mail->getNumber()); |
677 | 678 | ||
678 | clist*id_list = 0; | 679 | clist*id_list = 0; |
679 | 680 | ||
680 | /* if path == empty then its a request for the whole rfc822 mail and generates | 681 | /* if path == empty then its a request for the whole rfc822 mail and generates |
681 | a "fetch <id> (body[])" statement on imap server */ | 682 | a "fetch <id> (body[])" statement on imap server */ |
682 | if (path.count()>0 ) { | 683 | if (path.count()>0 ) { |
683 | id_list = clist_new(); | 684 | id_list = clist_new(); |
684 | for (unsigned j=0; j < path.count();++j) { | 685 | for (unsigned j=0; j < path.count();++j) { |
685 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 686 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
686 | *p_id = path[j]; | 687 | *p_id = path[j]; |
687 | clist_append(id_list,p_id); | 688 | clist_append(id_list,p_id); |
688 | } | 689 | } |
689 | section_part = mailimap_section_part_new(id_list); | 690 | section_part = mailimap_section_part_new(id_list); |
690 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 691 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
691 | } | 692 | } |
692 | 693 | ||
693 | section = mailimap_section_new(section_spec); | 694 | section = mailimap_section_new(section_spec); |
694 | fetch_att = mailimap_fetch_att_new_body_section(section); | 695 | fetch_att = mailimap_fetch_att_new_body_section(section); |
695 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 696 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
696 | 697 | ||
697 | clist*result = 0; | 698 | clist*result = 0; |
698 | 699 | ||
699 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 700 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
700 | mailimap_set_free( set ); | 701 | mailimap_set_free( set ); |
701 | mailimap_fetch_type_free( fetchType ); | 702 | mailimap_fetch_type_free( fetchType ); |
702 | 703 | ||
703 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 704 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
704 | mailimap_msg_att * msg_att; | 705 | mailimap_msg_att * msg_att; |
705 | msg_att = (mailimap_msg_att*)current->data; | 706 | msg_att = (mailimap_msg_att*)current->data; |
706 | mailimap_msg_att_item*msg_att_item; | 707 | mailimap_msg_att_item*msg_att_item; |
707 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 708 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
708 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 709 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
709 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 710 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
710 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 711 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
711 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 712 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
712 | /* detach - we take over the content */ | 713 | /* detach - we take over the content */ |
713 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 714 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
714 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 715 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
715 | } | 716 | } |
716 | } | 717 | } |
717 | } | 718 | } |
718 | } else { | 719 | } else { |
719 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; | 720 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; |
720 | } | 721 | } |
721 | if (result) mailimap_fetch_list_free(result); | 722 | if (result) mailimap_fetch_list_free(result); |
722 | return res; | 723 | return res; |
723 | } | 724 | } |
724 | 725 | ||
725 | /* current_recursion is for recursive calls. | 726 | /* current_recursion is for recursive calls. |
726 | current_count means the position inside the internal loop! */ | 727 | current_count means the position inside the internal loop! */ |
727 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, | 728 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, |
728 | int current_recursion,QValueList<int>recList,int current_count) | 729 | int current_recursion,QValueList<int>recList,int current_count) |
729 | { | 730 | { |
730 | if (!body || current_recursion>=10) { | 731 | if (!body || current_recursion>=10) { |
731 | return; | 732 | return; |
732 | } | 733 | } |
733 | switch (body->bd_type) { | 734 | switch (body->bd_type) { |
734 | case MAILIMAP_BODY_1PART: | 735 | case MAILIMAP_BODY_1PART: |
735 | { | 736 | { |
736 | QValueList<int>countlist = recList; | 737 | QValueList<int>countlist = recList; |
737 | countlist.append(current_count); | 738 | countlist.append(current_count); |
738 | RecPartP currentPart = new RecPart(); | 739 | RecPartP currentPart = new RecPart(); |
739 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 740 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
740 | QString id(""); | 741 | QString id(""); |
741 | currentPart->setPositionlist(countlist); | 742 | currentPart->setPositionlist(countlist); |
742 | for (unsigned int j = 0; j < countlist.count();++j) { | 743 | for (unsigned int j = 0; j < countlist.count();++j) { |
743 | id+=(j>0?" ":""); | 744 | id+=(j>0?" ":""); |
744 | id+=QString("%1").arg(countlist[j]); | 745 | id+=QString("%1").arg(countlist[j]); |
745 | } | 746 | } |
746 | //odebug << "ID = " << id.latin1() << "" << oendl; | 747 | //odebug << "ID = " << id.latin1() << "" << oendl; |
747 | currentPart->setIdentifier(id); | 748 | currentPart->setIdentifier(id); |
748 | fillSinglePart(currentPart,part1); | 749 | fillSinglePart(currentPart,part1); |
749 | /* important: Check for is NULL 'cause a body can be empty! | 750 | /* important: Check for is NULL 'cause a body can be empty! |
750 | And we put it only into the mail if it is the FIRST part */ | 751 | And we put it only into the mail if it is the FIRST part */ |
751 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { | 752 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { |
752 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); | 753 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); |
753 | target_body->setDescription(currentPart); | 754 | target_body->setDescription(currentPart); |
754 | target_body->setBodytext(body_text); | 755 | target_body->setBodytext(body_text); |
755 | if (countlist.count()>1) { | 756 | if (countlist.count()>1) { |
756 | target_body->addPart(currentPart); | 757 | target_body->addPart(currentPart); |
757 | } | 758 | } |
758 | } else { | 759 | } else { |
759 | target_body->addPart(currentPart); | 760 | target_body->addPart(currentPart); |
760 | } | 761 | } |
761 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { | 762 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { |
762 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); | 763 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); |
763 | } | 764 | } |
764 | } | 765 | } |
765 | break; | 766 | break; |
766 | case MAILIMAP_BODY_MPART: | 767 | case MAILIMAP_BODY_MPART: |
767 | { | 768 | { |
768 | QValueList<int>countlist = recList; | 769 | QValueList<int>countlist = recList; |
769 | clistcell*current=0; | 770 | clistcell*current=0; |
770 | mailimap_body*current_body=0; | 771 | mailimap_body*current_body=0; |
771 | unsigned int ccount = 1; | 772 | unsigned int ccount = 1; |
772 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; | 773 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; |
773 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 774 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
774 | current_body = (mailimap_body*)current->data; | 775 | current_body = (mailimap_body*)current->data; |
775 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 776 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
776 | RecPartP targetPart = new RecPart(); | 777 | RecPartP targetPart = new RecPart(); |
777 | targetPart->setType("multipart"); | 778 | targetPart->setType("multipart"); |
778 | fillMultiPart(targetPart,mailDescription); | 779 | fillMultiPart(targetPart,mailDescription); |
779 | countlist.append(current_count); | 780 | countlist.append(current_count); |
780 | targetPart->setPositionlist(countlist); | 781 | targetPart->setPositionlist(countlist); |
781 | target_body->addPart(targetPart); | 782 | target_body->addPart(targetPart); |
782 | QString id(""); | 783 | QString id(""); |
783 | for (unsigned int j = 0; j < countlist.count();++j) { | 784 | for (unsigned int j = 0; j < countlist.count();++j) { |
784 | id+=(j>0?" ":""); | 785 | id+=(j>0?" ":""); |
785 | id+=QString("%1").arg(countlist[j]); | 786 | id+=QString("%1").arg(countlist[j]); |
786 | } | 787 | } |
787 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; | 788 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; |
788 | } | 789 | } |
789 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | 790 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); |
790 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 791 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
791 | countlist = recList; | 792 | countlist = recList; |
792 | } | 793 | } |
793 | ++ccount; | 794 | ++ccount; |
794 | } | 795 | } |
795 | } | 796 | } |
796 | break; | 797 | break; |
797 | default: | 798 | default: |
798 | break; | 799 | break; |
799 | } | 800 | } |
800 | } | 801 | } |
801 | 802 | ||
802 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) | 803 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) |
803 | { | 804 | { |
804 | if (!Description) { | 805 | if (!Description) { |
805 | return; | 806 | return; |
806 | } | 807 | } |
807 | switch (Description->bd_type) { | 808 | switch (Description->bd_type) { |
808 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 809 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
809 | target_part->setType("text"); | 810 | target_part->setType("text"); |
810 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 811 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
811 | break; | 812 | break; |
812 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 813 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
813 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 814 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
814 | break; | 815 | break; |
815 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 816 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
816 | target_part->setType("message"); | 817 | target_part->setType("message"); |
817 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | 818 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); |
818 | break; | 819 | break; |
819 | default: | 820 | default: |
820 | break; | 821 | break; |
821 | } | 822 | } |
822 | } | 823 | } |
823 | 824 | ||
824 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) | 825 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) |
825 | { | 826 | { |
826 | if (!which) { | 827 | if (!which) { |
827 | return; | 828 | return; |
828 | } | 829 | } |
829 | QString sub; | 830 | QString sub; |
830 | sub = which->bd_media_text; | 831 | sub = which->bd_media_text; |
831 | //odebug << "Type= text/" << which->bd_media_text << "" << oendl; | 832 | //odebug << "Type= text/" << which->bd_media_text << "" << oendl; |
832 | target_part->setSubtype(sub.lower()); | 833 | target_part->setSubtype(sub.lower()); |
833 | target_part->setLines(which->bd_lines); | 834 | target_part->setLines(which->bd_lines); |
834 | fillBodyFields(target_part,which->bd_fields); | 835 | fillBodyFields(target_part,which->bd_fields); |
835 | } | 836 | } |
836 | 837 | ||
837 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) | 838 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) |
838 | { | 839 | { |
839 | if (!which) { | 840 | if (!which) { |
840 | return; | 841 | return; |
841 | } | 842 | } |
842 | target_part->setSubtype("rfc822"); | 843 | target_part->setSubtype("rfc822"); |
843 | //odebug << "Message part" << oendl; | 844 | //odebug << "Message part" << oendl; |
844 | /* we set this type to text/plain */ | 845 | /* we set this type to text/plain */ |
845 | target_part->setLines(which->bd_lines); | 846 | target_part->setLines(which->bd_lines); |
846 | fillBodyFields(target_part,which->bd_fields); | 847 | fillBodyFields(target_part,which->bd_fields); |
847 | } | 848 | } |
848 | 849 | ||
849 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) | 850 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) |
850 | { | 851 | { |
851 | if (!which) return; | 852 | if (!which) return; |
852 | QString sub = which->bd_media_subtype; | 853 | QString sub = which->bd_media_subtype; |
853 | target_part->setSubtype(sub.lower()); | 854 | target_part->setSubtype(sub.lower()); |
854 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | 855 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { |
855 | clistcell*cur = 0; | 856 | clistcell*cur = 0; |
856 | mailimap_single_body_fld_param*param=0; | 857 | mailimap_single_body_fld_param*param=0; |
857 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 858 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
858 | param = (mailimap_single_body_fld_param*)cur->data; | 859 | param = (mailimap_single_body_fld_param*)cur->data; |
859 | if (param) { | 860 | if (param) { |
860 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 861 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
861 | } | 862 | } |
862 | } | 863 | } |
863 | } | 864 | } |
864 | } | 865 | } |
865 | 866 | ||
866 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) | 867 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) |
867 | { | 868 | { |
868 | if (!which) { | 869 | if (!which) { |
869 | return; | 870 | return; |
870 | } | 871 | } |
871 | QString type,sub; | 872 | QString type,sub; |
872 | switch (which->bd_media_basic->med_type) { | 873 | switch (which->bd_media_basic->med_type) { |
873 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | 874 | case MAILIMAP_MEDIA_BASIC_APPLICATION: |
874 | type = "application"; | 875 | type = "application"; |
875 | break; | 876 | break; |
876 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 877 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
877 | type = "audio"; | 878 | type = "audio"; |
878 | break; | 879 | break; |
879 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 880 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
880 | type = "image"; | 881 | type = "image"; |
881 | break; | 882 | break; |
882 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 883 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
883 | type = "message"; | 884 | type = "message"; |
884 | break; | 885 | break; |
885 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 886 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
886 | type = "video"; | 887 | type = "video"; |
887 | break; | 888 | break; |
888 | case MAILIMAP_MEDIA_BASIC_OTHER: | 889 | case MAILIMAP_MEDIA_BASIC_OTHER: |
889 | default: | 890 | default: |
890 | if (which->bd_media_basic->med_basic_type) { | 891 | if (which->bd_media_basic->med_basic_type) { |
891 | type = which->bd_media_basic->med_basic_type; | 892 | type = which->bd_media_basic->med_basic_type; |
892 | } else { | 893 | } else { |
893 | type = ""; | 894 | type = ""; |
894 | } | 895 | } |
895 | break; | 896 | break; |
896 | } | 897 | } |
897 | if (which->bd_media_basic->med_subtype) { | 898 | if (which->bd_media_basic->med_subtype) { |
898 | sub = which->bd_media_basic->med_subtype; | 899 | sub = which->bd_media_basic->med_subtype; |
899 | } else { | 900 | } else { |
900 | sub = ""; | 901 | sub = ""; |
901 | } | 902 | } |
902 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; | 903 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; |
903 | target_part->setType(type.lower()); | 904 | target_part->setType(type.lower()); |
904 | target_part->setSubtype(sub.lower()); | 905 | target_part->setSubtype(sub.lower()); |
905 | fillBodyFields(target_part,which->bd_fields); | 906 | fillBodyFields(target_part,which->bd_fields); |
906 | } | 907 | } |
907 | 908 | ||
908 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) | 909 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) |
909 | { | 910 | { |
910 | if (!which) return; | 911 | if (!which) return; |
911 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { | 912 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { |
912 | clistcell*cur; | 913 | clistcell*cur; |
913 | mailimap_single_body_fld_param*param=0; | 914 | mailimap_single_body_fld_param*param=0; |
914 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 915 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
915 | param = (mailimap_single_body_fld_param*)cur->data; | 916 | param = (mailimap_single_body_fld_param*)cur->data; |
916 | if (param) { | 917 | if (param) { |
917 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 918 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
918 | } | 919 | } |
919 | } | 920 | } |
920 | } | 921 | } |
921 | mailimap_body_fld_enc*enc = which->bd_encoding; | 922 | mailimap_body_fld_enc*enc = which->bd_encoding; |
922 | QString encoding(""); | 923 | QString encoding(""); |
923 | switch (enc->enc_type) { | 924 | switch (enc->enc_type) { |
924 | case MAILIMAP_BODY_FLD_ENC_7BIT: | 925 | case MAILIMAP_BODY_FLD_ENC_7BIT: |
925 | encoding = "7bit"; | 926 | encoding = "7bit"; |
926 | break; | 927 | break; |
927 | case MAILIMAP_BODY_FLD_ENC_8BIT: | 928 | case MAILIMAP_BODY_FLD_ENC_8BIT: |
928 | encoding = "8bit"; | 929 | encoding = "8bit"; |
929 | break; | 930 | break; |
930 | case MAILIMAP_BODY_FLD_ENC_BINARY: | 931 | case MAILIMAP_BODY_FLD_ENC_BINARY: |
931 | encoding="binary"; | 932 | encoding="binary"; |
932 | break; | 933 | break; |
933 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 934 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
934 | encoding="base64"; | 935 | encoding="base64"; |
935 | break; | 936 | break; |
936 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | 937 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: |
937 | encoding="quoted-printable"; | 938 | encoding="quoted-printable"; |
938 | break; | 939 | break; |
939 | case MAILIMAP_BODY_FLD_ENC_OTHER: | 940 | case MAILIMAP_BODY_FLD_ENC_OTHER: |
940 | default: | 941 | default: |
941 | if (enc->enc_value) { | 942 | if (enc->enc_value) { |
942 | char*t=enc->enc_value; | 943 | char*t=enc->enc_value; |
943 | encoding=QString(enc->enc_value); | 944 | encoding=QString(enc->enc_value); |
944 | enc->enc_value=0L; | 945 | enc->enc_value=0L; |
945 | free(t); | 946 | free(t); |
diff --git a/kmicromail/libmailwrapper/mhwrapper.cpp b/kmicromail/libmailwrapper/mhwrapper.cpp index de6d220..90b5d23 100644 --- a/kmicromail/libmailwrapper/mhwrapper.cpp +++ b/kmicromail/libmailwrapper/mhwrapper.cpp | |||
@@ -1,441 +1,450 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "mhwrapper.h" | 2 | #include "mhwrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "mailwrapper.h" | 4 | #include "mailwrapper.h" |
5 | #include <libetpan/libetpan.h> | 5 | #include <libetpan/libetpan.h> |
6 | #include <qdir.h> | 6 | #include <qdir.h> |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qpe/global.h> | 9 | #include <qpe/global.h> |
10 | #include <klocale.h> | 10 | #include <klocale.h> |
11 | #include <kglobal.h> | 11 | #include <kglobal.h> |
12 | //#include <opie2/odebug.h> | 12 | //#include <opie2/odebug.h> |
13 | 13 | ||
14 | using namespace Opie::Core; | 14 | using namespace Opie::Core; |
15 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | 15 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) |
16 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) | 16 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) |
17 | { | 17 | { |
18 | if (MHPath.length()>0) { | 18 | if (MHPath.length()>0) { |
19 | if (MHPath[MHPath.length()-1]=='/') { | 19 | if (MHPath[MHPath.length()-1]=='/') { |
20 | MHPath=MHPath.left(MHPath.length()-1); | 20 | MHPath=MHPath.left(MHPath.length()-1); |
21 | } | 21 | } |
22 | //odebug << MHPath << oendl; | 22 | //odebug << MHPath << oendl; |
23 | QDir dir(MHPath); | 23 | QDir dir(MHPath); |
24 | if (!dir.exists()) { | 24 | if (!dir.exists()) { |
25 | dir.mkdir(MHPath); | 25 | dir.mkdir(MHPath); |
26 | } | 26 | } |
27 | init_storage(); | 27 | init_storage(); |
28 | } | 28 | } |
29 | } | 29 | } |
30 | 30 | ||
31 | void MHwrapper::init_storage() | 31 | void MHwrapper::init_storage() |
32 | { | 32 | { |
33 | int r; | 33 | int r; |
34 | QString pre = MHPath; | 34 | QString pre = MHPath; |
35 | if (!m_storage) { | 35 | if (!m_storage) { |
36 | m_storage = mailstorage_new(NULL); | 36 | m_storage = mailstorage_new(NULL); |
37 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); | 37 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); |
38 | if (r != MAIL_NO_ERROR) { | 38 | if (r != MAIL_NO_ERROR) { |
39 | qDebug(" error init storage "); | 39 | qDebug(" error init storage "); |
40 | mailstorage_free(m_storage); | 40 | mailstorage_free(m_storage); |
41 | m_storage = 0; | 41 | m_storage = 0; |
42 | return; | 42 | return; |
43 | } | 43 | } |
44 | } | 44 | } |
45 | r = mailstorage_connect(m_storage); | 45 | r = mailstorage_connect(m_storage); |
46 | if (r!=MAIL_NO_ERROR) { | 46 | if (r!=MAIL_NO_ERROR) { |
47 | qDebug("error connecting storage "); | 47 | qDebug("error connecting storage "); |
48 | mailstorage_free(m_storage); | 48 | mailstorage_free(m_storage); |
49 | m_storage = 0; | 49 | m_storage = 0; |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | void MHwrapper::clean_storage() | 53 | void MHwrapper::clean_storage() |
54 | { | 54 | { |
55 | if (m_storage) { | 55 | if (m_storage) { |
56 | mailstorage_disconnect(m_storage); | 56 | mailstorage_disconnect(m_storage); |
57 | mailstorage_free(m_storage); | 57 | mailstorage_free(m_storage); |
58 | m_storage = 0; | 58 | m_storage = 0; |
59 | } | 59 | } |
60 | } | 60 | } |
61 | 61 | ||
62 | MHwrapper::~MHwrapper() | 62 | MHwrapper::~MHwrapper() |
63 | { | 63 | { |
64 | clean_storage(); | 64 | clean_storage(); |
65 | } | 65 | } |
66 | 66 | ||
67 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) | 67 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) |
68 | { | 68 | { |
69 | init_storage(); | 69 | init_storage(); |
70 | if (!m_storage) { | 70 | if (!m_storage) { |
71 | return; | 71 | return; |
72 | } | 72 | } |
73 | QString f = buildPath(mailbox); | 73 | QString f = buildPath(mailbox); |
74 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 74 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
75 | if (r!=MAIL_NO_ERROR) { | 75 | if (r!=MAIL_NO_ERROR) { |
76 | qDebug("listMessages: error selecting folder! "); | 76 | qDebug("listMessages: error selecting folder! "); |
77 | return; | 77 | return; |
78 | } | 78 | } |
79 | parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); | 79 | parseList(target,m_storage->sto_session,f, false, maxSizeInKb ); |
80 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); | 80 | Global::statusMessage(i18n("Mailbox has %1 mail(s)").arg(target.count())); |
81 | } | 81 | } |
82 | 82 | ||
83 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() | 83 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() |
84 | { | 84 | { |
85 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 85 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
86 | /* this is needed! */ | 86 | /* this is needed! */ |
87 | if (m_storage) mailstorage_disconnect(m_storage); | 87 | if (m_storage) mailstorage_disconnect(m_storage); |
88 | init_storage(); | 88 | init_storage(); |
89 | if (!m_storage) { | 89 | if (!m_storage) { |
90 | return folders; | 90 | return folders; |
91 | } | 91 | } |
92 | mail_list*flist = 0; | 92 | mail_list*flist = 0; |
93 | clistcell*current=0; | 93 | clistcell*current=0; |
94 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 94 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
95 | if (r != MAIL_NO_ERROR || !flist) { | 95 | if (r != MAIL_NO_ERROR || !flist) { |
96 | qDebug("error getting folder list "); | 96 | qDebug("error getting folder list "); |
97 | return folders; | 97 | return folders; |
98 | } | 98 | } |
99 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 99 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
100 | QString t = (char*)current->data; | 100 | QString t = (char*)current->data; |
101 | t.replace(0,MHPath.length(),""); | 101 | t.replace(0,MHPath.length(),""); |
102 | folders->append(new MHFolder(t,MHPath)); | 102 | folders->append(new MHFolder(t,MHPath)); |
103 | } | 103 | } |
104 | mail_list_free(flist); | 104 | mail_list_free(flist); |
105 | return folders; | 105 | return folders; |
106 | } | 106 | } |
107 | 107 | ||
108 | void MHwrapper::deleteMail(const RecMailP&mail) | 108 | void MHwrapper::deleteMail(const RecMailP&mail) |
109 | { | 109 | { |
110 | init_storage(); | 110 | init_storage(); |
111 | if (!m_storage) { | 111 | if (!m_storage) { |
112 | return; | 112 | return; |
113 | } | 113 | } |
114 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 114 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
115 | if (r!=MAIL_NO_ERROR) { | 115 | if (r!=MAIL_NO_ERROR) { |
116 | qDebug("error selecting folder! "); | 116 | qDebug("error selecting folder! "); |
117 | return; | 117 | return; |
118 | } | 118 | } |
119 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); | 119 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); |
120 | if (r != MAIL_NO_ERROR) { | 120 | if (r != MAIL_NO_ERROR) { |
121 | qDebug("error deleting mail "); | 121 | qDebug("error deleting mail "); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | void MHwrapper::answeredMail(const RecMailP&) | 125 | void MHwrapper::answeredMail(const RecMailP&) |
126 | { | 126 | { |
127 | } | 127 | } |
128 | 128 | ||
129 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) | 129 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) |
130 | { | 130 | { |
131 | RecBodyP body = new RecBody(); | 131 | RecBodyP body = new RecBody(); |
132 | init_storage(); | 132 | init_storage(); |
133 | if (!m_storage) { | 133 | if (!m_storage) { |
134 | return body; | 134 | return body; |
135 | } | 135 | } |
136 | mailmessage * msg; | 136 | mailmessage * msg; |
137 | char*data=0; | 137 | char*data=0; |
138 | 138 | ||
139 | /* mail should hold the complete path! */ | 139 | /* mail should hold the complete path! */ |
140 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 140 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
141 | if (r != MAIL_NO_ERROR) { | 141 | if (r != MAIL_NO_ERROR) { |
142 | return body; | 142 | return body; |
143 | } | 143 | } |
144 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 144 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
145 | if (r != MAIL_NO_ERROR) { | 145 | if (r != MAIL_NO_ERROR) { |
146 | qDebug("Error fetching mail "); | 146 | qDebug("Error fetching mail "); |
147 | 147 | ||
148 | return body; | 148 | return body; |
149 | } | 149 | } |
150 | body = parseMail(msg); | 150 | body = parseMail(msg); |
151 | mailmessage_fetch_result_free(msg,data); | 151 | mailmessage_fetch_result_free(msg,data); |
152 | return body; | 152 | return body; |
153 | } | 153 | } |
154 | 154 | ||
155 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) | 155 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) |
156 | { | 156 | { |
157 | qDebug("MBox Progress %d of %d",current,maximum ); | 157 | qDebug("MBox Progress %d of %d",current,maximum ); |
158 | //odebug << "MH " << current << " von " << maximum << "" << oendl; | 158 | //odebug << "MH " << current << " von " << maximum << "" << oendl; |
159 | } | 159 | } |
160 | 160 | ||
161 | QString MHwrapper::buildPath(const QString&p) | 161 | QString MHwrapper::buildPath(const QString&p) |
162 | { | 162 | { |
163 | QString f=""; | 163 | QString f=""; |
164 | if (p.length()==0||p=="/") | 164 | if (p.length()==0||p=="/") |
165 | return MHPath; | 165 | return MHPath; |
166 | if (!p.startsWith(MHPath)) { | 166 | if (!p.startsWith(MHPath)) { |
167 | f+=MHPath; | 167 | f+=MHPath; |
168 | } | 168 | } |
169 | if (!p.startsWith("/")) { | 169 | if (!p.startsWith("/")) { |
170 | f+="/"; | 170 | f+="/"; |
171 | } | 171 | } |
172 | f+=p; | 172 | f+=p; |
173 | return f; | 173 | return f; |
174 | } | 174 | } |
175 | 175 | ||
176 | int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) | 176 | int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) |
177 | { | 177 | { |
178 | init_storage(); | 178 | init_storage(); |
179 | if (!m_storage) { | 179 | if (!m_storage) { |
180 | return 0; | 180 | return 0; |
181 | } | 181 | } |
182 | QString f; | 182 | QString f; |
183 | if (!pfolder) { | 183 | if (!pfolder) { |
184 | // toplevel folder | 184 | // toplevel folder |
185 | f = buildPath(folder); | 185 | f = buildPath(folder); |
186 | } else { | 186 | } else { |
187 | f = pfolder->getName(); | 187 | f = pfolder->getName(); |
188 | f+="/"; | 188 | f+="/"; |
189 | f+=folder; | 189 | f+=folder; |
190 | } | 190 | } |
191 | 191 | ||
192 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); | 192 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); |
193 | if (r != MAIL_NO_ERROR) { | 193 | if (r != MAIL_NO_ERROR) { |
194 | qDebug("error creating folder "); | 194 | qDebug("error creating folder "); |
195 | return 0; | 195 | return 0; |
196 | } | 196 | } |
197 | return 1; | 197 | return 1; |
198 | } | 198 | } |
199 | 199 | ||
200 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) | 200 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) |
201 | { | 201 | { |
202 | init_storage(); | 202 | init_storage(); |
203 | if (!m_storage) { | 203 | if (!m_storage) { |
204 | return; | 204 | return; |
205 | } | 205 | } |
206 | QString f = buildPath(Folder); | 206 | QString f = buildPath(Folder); |
207 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 207 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
208 | if (r!=MAIL_NO_ERROR) { | 208 | if (r!=MAIL_NO_ERROR) { |
209 | qDebug("error selecting folder! "); | 209 | qDebug("error selecting folder! "); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); | 212 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); |
213 | if (r!=MAIL_NO_ERROR) { | 213 | if (r!=MAIL_NO_ERROR) { |
214 | qDebug("error storing mail "); | 214 | qDebug("error storing mail "); |
215 | } | 215 | } |
216 | return; | 216 | return; |
217 | } | 217 | } |
218 | 218 | ||
219 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) | 219 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) |
220 | { | 220 | { |
221 | encodedString*result = 0; | 221 | encodedString*result = 0; |
222 | init_storage(); | 222 | init_storage(); |
223 | if (!m_storage) { | 223 | if (!m_storage) { |
224 | return result; | 224 | return result; |
225 | } | 225 | } |
226 | mailmessage * msg = 0; | 226 | mailmessage * msg = 0; |
227 | char*data=0; | 227 | char*data=0; |
228 | size_t size; | 228 | size_t size; |
229 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 229 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
230 | if (r!=MAIL_NO_ERROR) { | 230 | if (r!=MAIL_NO_ERROR) { |
231 | qDebug("error selecting folder! "); | 231 | qDebug("error selecting folder! "); |
232 | return result; | 232 | return result; |
233 | } | 233 | } |
234 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 234 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
235 | if (r != MAIL_NO_ERROR) { | 235 | if (r != MAIL_NO_ERROR) { |
236 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); | 236 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
237 | return 0; | 237 | return 0; |
238 | } | 238 | } |
239 | r = mailmessage_fetch(msg,&data,&size); | 239 | r = mailmessage_fetch(msg,&data,&size); |
240 | if (r != MAIL_NO_ERROR) { | 240 | if (r != MAIL_NO_ERROR) { |
241 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); | 241 | Global::statusMessage(i18n("Error fetching mail %i").arg(mail->getNumber())); |
242 | if (msg) mailmessage_free(msg); | 242 | if (msg) mailmessage_free(msg); |
243 | return 0; | 243 | return 0; |
244 | } | 244 | } |
245 | result = new encodedString(data,size); | 245 | result = new encodedString(data,size); |
246 | if (msg) mailmessage_free(msg); | 246 | if (msg) mailmessage_free(msg); |
247 | return result; | 247 | return result; |
248 | } | 248 | } |
249 | 249 | ||
250 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) | 250 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) |
251 | { | 251 | { |
252 | QString f = buildPath(mailbox); | 252 | QString f = buildPath(mailbox); |
253 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 253 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
254 | if (r!=MAIL_NO_ERROR) { | 254 | if (r!=MAIL_NO_ERROR) { |
255 | qDebug("deleteMails: error selecting folder! "); | 255 | qDebug("deleteMails: error selecting folder! "); |
256 | return; | 256 | return; |
257 | } | 257 | } |
258 | QValueList<RecMailP>::ConstIterator it; | 258 | QValueList<RecMailP>::ConstIterator it; |
259 | for (it=target.begin(); it!=target.end();++it) { | 259 | for (it=target.begin(); it!=target.end();++it) { |
260 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); | 260 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); |
261 | if (r != MAIL_NO_ERROR) { | 261 | if (r != MAIL_NO_ERROR) { |
262 | qDebug("error deleting mail "); | 262 | qDebug("error deleting mail "); |
263 | break; | 263 | break; |
264 | } | 264 | } |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | int MHwrapper::deleteAllMail(const FolderP&tfolder) | 268 | int MHwrapper::deleteAllMail(const FolderP&tfolder) |
269 | { | 269 | { |
270 | init_storage(); | 270 | init_storage(); |
271 | if (!m_storage) { | 271 | if (!m_storage) { |
272 | return 0; | 272 | return 0; |
273 | } | 273 | } |
274 | int res = 1; | 274 | int res = 1; |
275 | if (!tfolder) return 0; | 275 | if (!tfolder) return 0; |
276 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 276 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
277 | if (r!=MAIL_NO_ERROR) { | 277 | if (r!=MAIL_NO_ERROR) { |
278 | qDebug("error selecting folder! "); | 278 | qDebug("error selecting folder! "); |
279 | return 0; | 279 | return 0; |
280 | } | 280 | } |
281 | mailmessage_list*l=0; | 281 | mailmessage_list*l=0; |
282 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 282 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
283 | if (r != MAIL_NO_ERROR) { | 283 | if (r != MAIL_NO_ERROR) { |
284 | qDebug("Error message list "); | 284 | qDebug("Error message list "); |
285 | res = 0; | 285 | res = 0; |
286 | } | 286 | } |
287 | unsigned j = 0; | 287 | unsigned j = 0; |
288 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 288 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
289 | mailmessage * msg; | 289 | mailmessage * msg; |
290 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 290 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
291 | j = msg->msg_index; | 291 | j = msg->msg_index; |
292 | r = mailsession_remove_message(m_storage->sto_session,j); | 292 | r = mailsession_remove_message(m_storage->sto_session,j); |
293 | if (r != MAIL_NO_ERROR) { | 293 | if (r != MAIL_NO_ERROR) { |
294 | Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); | 294 | Global::statusMessage(i18n("Error deleting mail %1").arg(i+1)); |
295 | res = 0; | 295 | res = 0; |
296 | break; | 296 | break; |
297 | } | 297 | } |
298 | } | 298 | } |
299 | if (l) mailmessage_list_free(l); | 299 | if (l) mailmessage_list_free(l); |
300 | return res; | 300 | return res; |
301 | } | 301 | } |
302 | 302 | bool MHwrapper::rmDir(QString folder) // absolute path! | |
303 | { | ||
304 | QDir dir ( folder ); | ||
305 | if ( !dir.exists() ) | ||
306 | return false; | ||
307 | int i; | ||
308 | // qDebug("rmdir %s ",folder.latin1()); | ||
309 | QStringList list = dir.entryList(QDir::Dirs|QDir::Files|QDir::NoSymLinks|QDir::Hidden ); | ||
310 | for (i=0; i<list.count(); i++ ) { | ||
311 | bool result = true; | ||
312 | QString entry = folder+"/"+ list[i] ; | ||
313 | //qDebug("entry %s ",entry.latin1() ); | ||
314 | |||
315 | QFileInfo fi ( entry ); | ||
316 | if ( fi.isFile() ) { | ||
317 | //qDebug("file %s ",entry.latin1() ); | ||
318 | result = QFile::remove ( entry ) ; | ||
319 | } else { | ||
320 | //qDebug("dir %s ",entry.latin1()); | ||
321 | if ( list[i] != "." && list[i] != ".." ) | ||
322 | result = rmDir( entry ); | ||
323 | } | ||
324 | if ( ! result ) | ||
325 | return false; | ||
326 | } | ||
327 | //qDebug("removing... "); | ||
328 | return QDir::root().rmdir ( folder, true ); | ||
329 | } | ||
303 | int MHwrapper::deleteMbox(const FolderP&tfolder) | 330 | int MHwrapper::deleteMbox(const FolderP&tfolder) |
304 | { | 331 | { |
305 | init_storage(); | 332 | init_storage(); |
306 | if (!m_storage) { | 333 | if (!m_storage) { |
307 | return 0; | 334 | return 0; |
308 | } | 335 | } |
309 | if (!tfolder) return 0; | 336 | if (!tfolder) return 0; |
310 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; | 337 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; |
311 | 338 | ||
312 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 339 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
313 | 340 | ||
314 | if (r != MAIL_NO_ERROR) { | 341 | if (r != MAIL_NO_ERROR) { |
315 | qDebug("error deleting mail box "); | 342 | qDebug("error deleting mail box "); |
316 | return 0; | 343 | return 0; |
317 | } | 344 | } |
318 | QString delDir = locateLocal( "apps", "kopiemail")+ "localmail"; | 345 | //qDebug("*****************\ndel %s %s ", delDir.latin1(),tfolder->getName().latin1() ); |
319 | qDebug("*****************\ndel %s %s ", delDir.latin1(),tfolder->getName().latin1() ); | 346 | if ( !rmDir( tfolder->getName() )) { |
320 | #if 0 | 347 | qDebug("error deleteing folder %s ",tfolder->getName().latin1()); |
321 | QString cmd = "rm -rf "+tfolder->getName(); | ||
322 | QStringList command; | ||
323 | command << "/bin/sh"; | ||
324 | command << "-c"; | ||
325 | command << cmd.latin1(); | ||
326 | OProcess *process = new OProcess(); | ||
327 | |||
328 | /* | ||
329 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), | ||
330 | this, SLOT( processEnded(Opie::Core::OProcess*))); | ||
331 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), | ||
332 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); | ||
333 | */ | ||
334 | *process << command; | ||
335 | removeMboxfailed = false; | ||
336 | if(!process->start(OProcess::Block, OProcess::All) ) { | ||
337 | qDebug("could not start process "); | ||
338 | return 0; | ||
339 | } | 348 | } |
340 | #endif | 349 | else |
341 | qDebug("mail box deleted "); | 350 | qDebug("mail box deleted %s ", tfolder->getName().latin1()); |
342 | return 1; | 351 | return 1; |
343 | } | 352 | } |
344 | 353 | ||
345 | 354 | ||
346 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 355 | void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
347 | { | 356 | { |
348 | init_storage(); | 357 | init_storage(); |
349 | if (!m_storage) { | 358 | if (!m_storage) { |
350 | return; | 359 | return; |
351 | } | 360 | } |
352 | target_stat.message_count = 0; | 361 | target_stat.message_count = 0; |
353 | target_stat.message_unseen = 0; | 362 | target_stat.message_unseen = 0; |
354 | target_stat.message_recent = 0; | 363 | target_stat.message_recent = 0; |
355 | QString f = buildPath(mailbox); | 364 | QString f = buildPath(mailbox); |
356 | int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, | 365 | int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, |
357 | &target_stat.message_recent,&target_stat.message_unseen); | 366 | &target_stat.message_recent,&target_stat.message_unseen); |
358 | if (r != MAIL_NO_ERROR) { | 367 | if (r != MAIL_NO_ERROR) { |
359 | Global::statusMessage(i18n("Error retrieving status")); | 368 | Global::statusMessage(i18n("Error retrieving status")); |
360 | } | 369 | } |
361 | } | 370 | } |
362 | 371 | ||
363 | MAILLIB::ATYPE MHwrapper::getType()const | 372 | MAILLIB::ATYPE MHwrapper::getType()const |
364 | { | 373 | { |
365 | return MAILLIB::A_MH; | 374 | return MAILLIB::A_MH; |
366 | } | 375 | } |
367 | 376 | ||
368 | const QString&MHwrapper::getName()const | 377 | const QString&MHwrapper::getName()const |
369 | { | 378 | { |
370 | return MHName; | 379 | return MHName; |
371 | } | 380 | } |
372 | void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 381 | void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
373 | { | 382 | { |
374 | init_storage(); | 383 | init_storage(); |
375 | if (!m_storage) { | 384 | if (!m_storage) { |
376 | return; | 385 | return; |
377 | } | 386 | } |
378 | if (targetWrapper != this) { | 387 | if (targetWrapper != this) { |
379 | qDebug("Using generic "); | 388 | qDebug("Using generic "); |
380 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 389 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
381 | return; | 390 | return; |
382 | } | 391 | } |
383 | qDebug("Using internal routines for move/copy "); | 392 | qDebug("Using internal routines for move/copy "); |
384 | QString tf = buildPath(targetFolder); | 393 | QString tf = buildPath(targetFolder); |
385 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 394 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
386 | if (r != MAIL_NO_ERROR) { | 395 | if (r != MAIL_NO_ERROR) { |
387 | qDebug("Error selecting source mailbox "); | 396 | qDebug("Error selecting source mailbox "); |
388 | return; | 397 | return; |
389 | } | 398 | } |
390 | if (moveit) { | 399 | if (moveit) { |
391 | r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); | 400 | r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); |
392 | } else { | 401 | } else { |
393 | r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); | 402 | r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); |
394 | } | 403 | } |
395 | if (r != MAIL_NO_ERROR) { | 404 | if (r != MAIL_NO_ERROR) { |
396 | qDebug("Error copy/moving mail internal "); | 405 | qDebug("Error copy/moving mail internal "); |
397 | } | 406 | } |
398 | } | 407 | } |
399 | 408 | ||
400 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, | 409 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, |
401 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 410 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
402 | { | 411 | { |
403 | init_storage(); | 412 | init_storage(); |
404 | if (!m_storage) { | 413 | if (!m_storage) { |
405 | return; | 414 | return; |
406 | } | 415 | } |
407 | if (targetWrapper != this) { | 416 | if (targetWrapper != this) { |
408 | qDebug("Using generic "); | 417 | qDebug("Using generic "); |
409 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 418 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
410 | return; | 419 | return; |
411 | } | 420 | } |
412 | if (!fromFolder) return; | 421 | if (!fromFolder) return; |
413 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); | 422 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); |
414 | if (r!=MAIL_NO_ERROR) { | 423 | if (r!=MAIL_NO_ERROR) { |
415 | qDebug("error selecting source folder! "); | 424 | qDebug("error selecting source folder! "); |
416 | return; | 425 | return; |
417 | } | 426 | } |
418 | QString tf = buildPath(targetFolder); | 427 | QString tf = buildPath(targetFolder); |
419 | mailmessage_list*l=0; | 428 | mailmessage_list*l=0; |
420 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 429 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
421 | if (r != MAIL_NO_ERROR) { | 430 | if (r != MAIL_NO_ERROR) { |
422 | qDebug("Error message list "); | 431 | qDebug("Error message list "); |
423 | } | 432 | } |
424 | unsigned j = 0; | 433 | unsigned j = 0; |
425 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { | 434 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { |
426 | mailmessage * msg; | 435 | mailmessage * msg; |
427 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 436 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
428 | j = msg->msg_index; | 437 | j = msg->msg_index; |
429 | if (moveit) { | 438 | if (moveit) { |
430 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); | 439 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); |
431 | } else { | 440 | } else { |
432 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); | 441 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); |
433 | } | 442 | } |
434 | if (r != MAIL_NO_ERROR) { | 443 | if (r != MAIL_NO_ERROR) { |
435 | qDebug("Error copy/moving mail interna "); | 444 | qDebug("Error copy/moving mail interna "); |
436 | 445 | ||
437 | break; | 446 | break; |
438 | } | 447 | } |
439 | } | 448 | } |
440 | if (l) mailmessage_list_free(l); | 449 | if (l) mailmessage_list_free(l); |
441 | } | 450 | } |
diff --git a/kmicromail/libmailwrapper/mhwrapper.h b/kmicromail/libmailwrapper/mhwrapper.h index 87f8ca1..36a443a 100644 --- a/kmicromail/libmailwrapper/mhwrapper.h +++ b/kmicromail/libmailwrapper/mhwrapper.h | |||
@@ -1,58 +1,59 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef __MH_WRAPPER_H | 2 | #ifndef __MH_WRAPPER_H |
3 | #define __MH_WRAPPER_H | 3 | #define __MH_WRAPPER_H |
4 | 4 | ||
5 | #include "maildefines.h" | 5 | #include "maildefines.h" |
6 | 6 | ||
7 | #include "genericwrapper.h" | 7 | #include "genericwrapper.h" |
8 | #include <qstring.h> | 8 | #include <qstring.h> |
9 | 9 | ||
10 | class encodedString; | 10 | class encodedString; |
11 | struct mailmbox_folder; | 11 | struct mailmbox_folder; |
12 | class MHwrapper : public Genericwrapper | 12 | class MHwrapper : public Genericwrapper |
13 | { | 13 | { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | public: | 15 | public: |
16 | MHwrapper(const QString & dir,const QString&name); | 16 | MHwrapper(const QString & dir,const QString&name); |
17 | virtual ~MHwrapper(); | 17 | virtual ~MHwrapper(); |
18 | 18 | ||
19 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); | 19 | virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb = 0 ); |
20 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); | 20 | virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders(); |
21 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); | 21 | virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); |
22 | 22 | ||
23 | virtual void deleteMail(const RecMailP&mail); | 23 | virtual void deleteMail(const RecMailP&mail); |
24 | virtual void answeredMail(const RecMailP&mail); | 24 | virtual void answeredMail(const RecMailP&mail); |
25 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 25 | virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
26 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, | 26 | virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder, |
27 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); | 27 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); |
28 | 28 | ||
29 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, | 29 | virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0, |
30 | const QString&d="",bool s=false); | 30 | const QString&d="",bool s=false); |
31 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); | 31 | virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&); |
32 | 32 | ||
33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); | 33 | virtual void storeMessage(const char*msg,size_t length, const QString&folder); |
34 | 34 | ||
35 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 35 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
36 | static void mbox_progress( size_t current, size_t maximum ); | 36 | static void mbox_progress( size_t current, size_t maximum ); |
37 | 37 | ||
38 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 38 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
39 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target); | 39 | virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target); |
40 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); | 40 | virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&); |
41 | virtual MAILLIB::ATYPE getType()const; | 41 | virtual MAILLIB::ATYPE getType()const; |
42 | virtual const QString&getName()const; | 42 | virtual const QString&getName()const; |
43 | virtual Account* getAccount() { return 0; }; | 43 | virtual Account* getAccount() { return 0; }; |
44 | 44 | ||
45 | public slots: | 45 | public slots: |
46 | 46 | ||
47 | protected: | 47 | protected: |
48 | QString buildPath(const QString&p); | 48 | QString buildPath(const QString&p); |
49 | QString MHPath; | 49 | QString MHPath; |
50 | QString MHName; | 50 | QString MHName; |
51 | 51 | ||
52 | void init_storage(); | 52 | void init_storage(); |
53 | void clean_storage(); | 53 | void clean_storage(); |
54 | bool rmDir(QString folderabspath); | ||
54 | 55 | ||
55 | bool removeMboxfailed; | 56 | bool removeMboxfailed; |
56 | }; | 57 | }; |
57 | 58 | ||
58 | #endif | 59 | #endif |