author | zautrix <zautrix> | 2005-01-23 16:22:03 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-23 16:22:03 (UTC) |
commit | ec69f34e62250f95a1f8757c5d58da0bf330678a (patch) (unidiff) | |
tree | a487425ea28b2dfe706dbca22c1351baddc52549 | |
parent | abe5f73892c123110faec5648b484628b3265fd6 (diff) | |
download | kdepimpi-ec69f34e62250f95a1f8757c5d58da0bf330678a.zip kdepimpi-ec69f34e62250f95a1f8757c5d58da0bf330678a.tar.gz kdepimpi-ec69f34e62250f95a1f8757c5d58da0bf330678a.tar.bz2 |
xxx
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 1 | ||||
-rw-r--r-- | kmicromail/mainwindow.cpp | 2 | ||||
-rw-r--r-- | kmicromail/mainwindow.h | 1 |
3 files changed, 2 insertions, 2 deletions
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index b890725..d9496af 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,1361 +1,1360 @@ | |||
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 | qApp->processEvents(); | 50 | qApp->processEvents(); |
51 | return; | 51 | return; |
52 | //qDebug("imap progress %d of %d ",current,maximum ); | 52 | //qDebug("imap progress %d of %d ",current,maximum ); |
53 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); | 53 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); |
54 | //qApp->processEvents() | 54 | //qApp->processEvents() |
55 | static unsigned int last = 0; | 55 | static unsigned int last = 0; |
56 | if ( last != current ) | 56 | if ( last != current ) |
57 | IMAPwrapper::progress(); | 57 | IMAPwrapper::progress(); |
58 | last = current; | 58 | last = current; |
59 | } | 59 | } |
60 | void IMAPwrapper::progress( QString m ) | 60 | void IMAPwrapper::progress( QString m ) |
61 | { | 61 | { |
62 | |||
63 | static QString mProgrMess; | 62 | static QString mProgrMess; |
64 | if ( m != QString::null ) { | 63 | if ( m != QString::null ) { |
65 | mProgrMess = m; | 64 | mProgrMess = m; |
66 | mCurrent = 1; | 65 | mCurrent = 1; |
67 | return; | 66 | return; |
68 | } | 67 | } |
69 | QString mess; | 68 | QString mess; |
70 | //qDebug("progress "); | 69 | //qDebug("progress "); |
71 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); | 70 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); |
72 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); | 71 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); |
73 | Global::statusMessage(mess); | 72 | Global::statusMessage(mess); |
74 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); | 73 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); |
75 | qApp->processEvents(); | 74 | qApp->processEvents(); |
76 | } | 75 | } |
77 | bool IMAPwrapper::start_tls(bool force_tls) | 76 | bool IMAPwrapper::start_tls(bool force_tls) |
78 | { | 77 | { |
79 | int err; | 78 | int err; |
80 | bool try_tls = force_tls; | 79 | bool try_tls = force_tls; |
81 | mailimap_capability_data * cap_data = 0; | 80 | mailimap_capability_data * cap_data = 0; |
82 | 81 | ||
83 | err = mailimap_capability(m_imap,&cap_data); | 82 | err = mailimap_capability(m_imap,&cap_data); |
84 | if (err != MAILIMAP_NO_ERROR) { | 83 | if (err != MAILIMAP_NO_ERROR) { |
85 | Global::statusMessage("error getting capabilities!"); | 84 | Global::statusMessage("error getting capabilities!"); |
86 | return false; | 85 | return false; |
87 | } | 86 | } |
88 | clistiter * cur; | 87 | clistiter * cur; |
89 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 88 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
90 | struct mailimap_capability * cap; | 89 | struct mailimap_capability * cap; |
91 | cap = (struct mailimap_capability *)clist_content(cur); | 90 | cap = (struct mailimap_capability *)clist_content(cur); |
92 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 91 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
93 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 92 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
94 | try_tls = true; | 93 | try_tls = true; |
95 | break; | 94 | break; |
96 | } | 95 | } |
97 | } | 96 | } |
98 | } | 97 | } |
99 | if (cap_data) { | 98 | if (cap_data) { |
100 | mailimap_capability_data_free(cap_data); | 99 | mailimap_capability_data_free(cap_data); |
101 | } | 100 | } |
102 | if (try_tls) { | 101 | if (try_tls) { |
103 | err = mailimap_starttls(m_imap); | 102 | err = mailimap_starttls(m_imap); |
104 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 103 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
105 | Global::statusMessage(i18n("Server has no TLS support!")); | 104 | Global::statusMessage(i18n("Server has no TLS support!")); |
106 | try_tls = false; | 105 | try_tls = false; |
107 | } else { | 106 | } else { |
108 | mailstream_low * low; | 107 | mailstream_low * low; |
109 | mailstream_low * new_low; | 108 | mailstream_low * new_low; |
110 | low = mailstream_get_low(m_imap->imap_stream); | 109 | low = mailstream_get_low(m_imap->imap_stream); |
111 | if (!low) { | 110 | if (!low) { |
112 | try_tls = false; | 111 | try_tls = false; |
113 | } else { | 112 | } else { |
114 | int fd = mailstream_low_get_fd(low); | 113 | int fd = mailstream_low_get_fd(low); |
115 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 114 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
116 | mailstream_low_free(low); | 115 | mailstream_low_free(low); |
117 | mailstream_set_low(m_imap->imap_stream, new_low); | 116 | mailstream_set_low(m_imap->imap_stream, new_low); |
118 | } else { | 117 | } else { |
119 | try_tls = false; | 118 | try_tls = false; |
120 | } | 119 | } |
121 | } | 120 | } |
122 | } | 121 | } |
123 | } | 122 | } |
124 | return try_tls; | 123 | return try_tls; |
125 | } | 124 | } |
126 | 125 | ||
127 | void IMAPwrapper::login() | 126 | void IMAPwrapper::login() |
128 | { | 127 | { |
129 | QString server, user, pass; | 128 | QString server, user, pass; |
130 | uint16_t port; | 129 | uint16_t port; |
131 | int err = MAILIMAP_NO_ERROR; | 130 | int err = MAILIMAP_NO_ERROR; |
132 | 131 | ||
133 | if (account->getOffline()) return; | 132 | if (account->getOffline()) return; |
134 | /* we are connected this moment */ | 133 | /* we are connected this moment */ |
135 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 134 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
136 | if (m_imap) { | 135 | if (m_imap) { |
137 | err = mailimap_noop(m_imap); | 136 | err = mailimap_noop(m_imap); |
138 | if (err!=MAILIMAP_NO_ERROR) { | 137 | if (err!=MAILIMAP_NO_ERROR) { |
139 | logout(); | 138 | logout(); |
140 | } else { | 139 | } else { |
141 | mailstream_flush(m_imap->imap_stream); | 140 | mailstream_flush(m_imap->imap_stream); |
142 | return; | 141 | return; |
143 | } | 142 | } |
144 | } | 143 | } |
145 | server = account->getServer(); | 144 | server = account->getServer(); |
146 | port = account->getPort().toUInt(); | 145 | port = account->getPort().toUInt(); |
147 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 146 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
148 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 147 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
149 | login.show(); | 148 | login.show(); |
150 | if ( QDialog::Accepted == login.exec() ) { | 149 | if ( QDialog::Accepted == login.exec() ) { |
151 | // ok | 150 | // ok |
152 | user = login.getUser(); | 151 | user = login.getUser(); |
153 | pass = login.getPassword(); | 152 | pass = login.getPassword(); |
154 | } else { | 153 | } else { |
155 | // cancel | 154 | // cancel |
156 | return; | 155 | return; |
157 | } | 156 | } |
158 | } else { | 157 | } else { |
159 | user = account->getUser(); | 158 | user = account->getUser(); |
160 | pass = account->getPassword(); | 159 | pass = account->getPassword(); |
161 | } | 160 | } |
162 | 161 | ||
163 | m_imap = mailimap_new( 20, &imap_progress ); | 162 | m_imap = mailimap_new( 20, &imap_progress ); |
164 | 163 | ||
165 | /* connect */ | 164 | /* connect */ |
166 | bool ssl = false; | 165 | bool ssl = false; |
167 | bool try_tls = false; | 166 | bool try_tls = false; |
168 | bool force_tls = false; | 167 | bool force_tls = false; |
169 | 168 | ||
170 | if ( account->ConnectionType() == 2 ) { | 169 | if ( account->ConnectionType() == 2 ) { |
171 | ssl = true; | 170 | ssl = true; |
172 | } | 171 | } |
173 | if (account->ConnectionType()==1) { | 172 | if (account->ConnectionType()==1) { |
174 | force_tls = true; | 173 | force_tls = true; |
175 | } | 174 | } |
176 | 175 | ||
177 | if ( ssl ) { | 176 | if ( ssl ) { |
178 | qDebug("using ssl "); | 177 | qDebug("using ssl "); |
179 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); | 178 | err = mailimap_ssl_connect( m_imap, (char*)server.latin1(), port ); |
180 | qDebug("back "); | 179 | qDebug("back "); |
181 | } else { | 180 | } else { |
182 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); | 181 | err = mailimap_socket_connect( m_imap, (char*)server.latin1(), port ); |
183 | } | 182 | } |
184 | 183 | ||
185 | if ( err != MAILIMAP_NO_ERROR && | 184 | if ( err != MAILIMAP_NO_ERROR && |
186 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 185 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
187 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 186 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
188 | QString failure = ""; | 187 | QString failure = ""; |
189 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 188 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
190 | failure="Connection refused"; | 189 | failure="Connection refused"; |
191 | } else { | 190 | } else { |
192 | failure="Unknown failure"; | 191 | failure="Unknown failure"; |
193 | } | 192 | } |
194 | Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); | 193 | Global::statusMessage(i18n("error connecting imap server: %1").arg(failure)); |
195 | mailimap_free( m_imap ); | 194 | mailimap_free( m_imap ); |
196 | m_imap = 0; | 195 | m_imap = 0; |
197 | return; | 196 | return; |
198 | } | 197 | } |
199 | 198 | ||
200 | if (!ssl) { | 199 | if (!ssl) { |
201 | try_tls = start_tls(force_tls); | 200 | try_tls = start_tls(force_tls); |
202 | } | 201 | } |
203 | 202 | ||
204 | bool ok = true; | 203 | bool ok = true; |
205 | if (force_tls && !try_tls) { | 204 | if (force_tls && !try_tls) { |
206 | Global::statusMessage(i18n("Server has no TLS support!")); | 205 | Global::statusMessage(i18n("Server has no TLS support!")); |
207 | ok = false; | 206 | ok = false; |
208 | } | 207 | } |
209 | 208 | ||
210 | 209 | ||
211 | /* login */ | 210 | /* login */ |
212 | 211 | ||
213 | if (ok) { | 212 | if (ok) { |
214 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); | 213 | err = mailimap_login_simple( m_imap, (char*)user.latin1(), (char*)pass.latin1() ); |
215 | if ( err != MAILIMAP_NO_ERROR ) { | 214 | if ( err != MAILIMAP_NO_ERROR ) { |
216 | Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); | 215 | Global::statusMessage(i18n("error logging in imap server: %1").arg(m_imap->imap_response)); |
217 | ok = false; | 216 | ok = false; |
218 | } | 217 | } |
219 | } | 218 | } |
220 | if (!ok) { | 219 | if (!ok) { |
221 | err = mailimap_close( m_imap ); | 220 | err = mailimap_close( m_imap ); |
222 | mailimap_free( m_imap ); | 221 | mailimap_free( m_imap ); |
223 | m_imap = 0; | 222 | m_imap = 0; |
224 | } | 223 | } |
225 | } | 224 | } |
226 | 225 | ||
227 | void IMAPwrapper::logout() | 226 | void IMAPwrapper::logout() |
228 | { | 227 | { |
229 | int err = MAILIMAP_NO_ERROR; | 228 | int err = MAILIMAP_NO_ERROR; |
230 | if (!m_imap) return; | 229 | if (!m_imap) return; |
231 | err = mailimap_logout( m_imap ); | 230 | err = mailimap_logout( m_imap ); |
232 | err = mailimap_close( m_imap ); | 231 | err = mailimap_close( m_imap ); |
233 | mailimap_free( m_imap ); | 232 | mailimap_free( m_imap ); |
234 | m_imap = 0; | 233 | m_imap = 0; |
235 | m_Lastmbox = ""; | 234 | m_Lastmbox = ""; |
236 | } | 235 | } |
237 | 236 | ||
238 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) | 237 | void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target , int maxSizeInKb) |
239 | { | 238 | { |
240 | 239 | ||
241 | int tryAgain = 1; | 240 | int tryAgain = 1; |
242 | while ( tryAgain >= 0 ) { | 241 | while ( tryAgain >= 0 ) { |
243 | int err = MAILIMAP_NO_ERROR; | 242 | int err = MAILIMAP_NO_ERROR; |
244 | clist *result = 0; | 243 | clist *result = 0; |
245 | clistcell *current; | 244 | clistcell *current; |
246 | mailimap_fetch_type *fetchType = 0; | 245 | mailimap_fetch_type *fetchType = 0; |
247 | mailimap_set *set = 0; | 246 | mailimap_set *set = 0; |
248 | 247 | ||
249 | login(); | 248 | login(); |
250 | if (!m_imap) { | 249 | if (!m_imap) { |
251 | return; | 250 | return; |
252 | } | 251 | } |
253 | /* select mailbox READONLY for operations */ | 252 | /* select mailbox READONLY for operations */ |
254 | err = selectMbox(mailbox); | 253 | err = selectMbox(mailbox); |
255 | if ( err != MAILIMAP_NO_ERROR ) { | 254 | if ( err != MAILIMAP_NO_ERROR ) { |
256 | return; | 255 | return; |
257 | } | 256 | } |
258 | 257 | ||
259 | int last = m_imap->imap_selection_info->sel_exists; | 258 | int last = m_imap->imap_selection_info->sel_exists; |
260 | 259 | ||
261 | if (last == 0) { | 260 | if (last == 0) { |
262 | Global::statusMessage(i18n("Mailbox has no mails")); | 261 | Global::statusMessage(i18n("Mailbox has no mails")); |
263 | return; | 262 | return; |
264 | } else { | 263 | } else { |
265 | } | 264 | } |
266 | progress( i18n("Fetch ")); | 265 | progress( i18n("Fetch ")); |
267 | mMax = last; | 266 | mMax = last; |
268 | //qDebug("last %d ", last); | 267 | //qDebug("last %d ", last); |
269 | Global::statusMessage(i18n("Fetching header list")); | 268 | Global::statusMessage(i18n("Fetching header list")); |
270 | qApp->processEvents(); | 269 | qApp->processEvents(); |
271 | /* the range has to start at 1!!! not with 0!!!! */ | 270 | /* the range has to start at 1!!! not with 0!!!! */ |
272 | //LR the access to web.de imap server is no working with value 1 | 271 | //LR the access to web.de imap server is no working with value 1 |
273 | //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); | 272 | //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); |
274 | set = mailimap_set_new_interval( tryAgain, last ); | 273 | set = mailimap_set_new_interval( tryAgain, last ); |
275 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 274 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
276 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 275 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
277 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 276 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
278 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 277 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
279 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 278 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
280 | 279 | ||
281 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 280 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
282 | mailimap_set_free( set ); | 281 | mailimap_set_free( set ); |
283 | mailimap_fetch_type_free( fetchType ); | 282 | mailimap_fetch_type_free( fetchType ); |
284 | 283 | ||
285 | QString date,subject,from; | 284 | QString date,subject,from; |
286 | 285 | ||
287 | if ( err == MAILIMAP_NO_ERROR ) { | 286 | if ( err == MAILIMAP_NO_ERROR ) { |
288 | tryAgain = -1; | 287 | tryAgain = -1; |
289 | mailimap_msg_att * msg_att; | 288 | mailimap_msg_att * msg_att; |
290 | int i = 0; | 289 | int i = 0; |
291 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 290 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
292 | ++i; | 291 | ++i; |
293 | //qDebug("iii %d ",i); | 292 | //qDebug("iii %d ",i); |
294 | msg_att = (mailimap_msg_att*)current->data; | 293 | msg_att = (mailimap_msg_att*)current->data; |
295 | RecMail*m = parse_list_result(msg_att); | 294 | RecMail*m = parse_list_result(msg_att); |
296 | if (m) { | 295 | if (m) { |
297 | if ( maxSizeInKb == 0 || m->Msgsize()<=(unsigned int ) maxSizeInKb*1024 ) { | 296 | if ( maxSizeInKb == 0 || m->Msgsize()<=(unsigned int ) maxSizeInKb*1024 ) { |
298 | m->setNumber(i); | 297 | m->setNumber(i); |
299 | m->setMbox(mailbox); | 298 | m->setMbox(mailbox); |
300 | m->setWrapper(this); | 299 | m->setWrapper(this); |
301 | target.append(m); | 300 | target.append(m); |
302 | } | 301 | } |
303 | } | 302 | } |
304 | } | 303 | } |
305 | Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); | 304 | Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); |
306 | } else { | 305 | } else { |
307 | --tryAgain; | 306 | --tryAgain; |
308 | --tryAgain;//disabled tryagain by adding this line | 307 | --tryAgain;//disabled tryagain by adding this line |
309 | if ( tryAgain < 0 ) | 308 | if ( tryAgain < 0 ) |
310 | Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); | 309 | Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); |
311 | else | 310 | else |
312 | qDebug("try again... "); | 311 | qDebug("try again... "); |
313 | } | 312 | } |
314 | 313 | ||
315 | if (result) mailimap_fetch_list_free(result); | 314 | if (result) mailimap_fetch_list_free(result); |
316 | } | 315 | } |
317 | } | 316 | } |
318 | 317 | ||
319 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | 318 | QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() |
320 | { | 319 | { |
321 | const char *path, *mask; | 320 | const char *path, *mask; |
322 | int err = MAILIMAP_NO_ERROR; | 321 | int err = MAILIMAP_NO_ERROR; |
323 | clist *result = 0; | 322 | clist *result = 0; |
324 | clistcell *current = 0; | 323 | clistcell *current = 0; |
325 | clistcell*cur_flag = 0; | 324 | clistcell*cur_flag = 0; |
326 | mailimap_mbx_list_flags*bflags = 0; | 325 | mailimap_mbx_list_flags*bflags = 0; |
327 | 326 | ||
328 | QValueList<FolderP>* folders = new QValueList<FolderP>(); | 327 | QValueList<FolderP>* folders = new QValueList<FolderP>(); |
329 | login(); | 328 | login(); |
330 | if (!m_imap) { | 329 | if (!m_imap) { |
331 | return folders; | 330 | return folders; |
332 | } | 331 | } |
333 | 332 | ||
334 | /* | 333 | /* |
335 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 334 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
336 | * We must not forget to filter them out in next loop! | 335 | * We must not forget to filter them out in next loop! |
337 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 336 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
338 | */ | 337 | */ |
339 | Global::statusMessage(i18n("Fetching folder list")); | 338 | Global::statusMessage(i18n("Fetching folder list")); |
340 | qApp->processEvents(); | 339 | qApp->processEvents(); |
341 | QString temp; | 340 | QString temp; |
342 | mask = "INBOX" ; | 341 | mask = "INBOX" ; |
343 | mailimap_mailbox_list *list; | 342 | mailimap_mailbox_list *list; |
344 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 343 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
345 | QString del; | 344 | QString del; |
346 | bool selectable = true; | 345 | bool selectable = true; |
347 | bool no_inferiors = false; | 346 | bool no_inferiors = false; |
348 | if ( err == MAILIMAP_NO_ERROR ) { | 347 | if ( err == MAILIMAP_NO_ERROR ) { |
349 | current = result->first; | 348 | current = result->first; |
350 | for ( int i = result->count; i > 0; i-- ) { | 349 | for ( int i = result->count; i > 0; i-- ) { |
351 | list = (mailimap_mailbox_list *) current->data; | 350 | list = (mailimap_mailbox_list *) current->data; |
352 | // it is better use the deep copy mechanism of qt itself | 351 | // it is better use the deep copy mechanism of qt itself |
353 | // instead of using strdup! | 352 | // instead of using strdup! |
354 | temp = list->mb_name; | 353 | temp = list->mb_name; |
355 | del = list->mb_delimiter; | 354 | del = list->mb_delimiter; |
356 | current = current->next; | 355 | current = current->next; |
357 | if ( (bflags = list->mb_flag) ) { | 356 | if ( (bflags = list->mb_flag) ) { |
358 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 357 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
359 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 358 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
360 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 359 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
361 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 360 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
362 | no_inferiors = true; | 361 | no_inferiors = true; |
363 | } | 362 | } |
364 | } | 363 | } |
365 | } | 364 | } |
366 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 365 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
367 | } | 366 | } |
368 | } else { | 367 | } else { |
369 | qDebug("error fetching folders: "); | 368 | qDebug("error fetching folders: "); |
370 | 369 | ||
371 | } | 370 | } |
372 | mailimap_list_result_free( result ); | 371 | mailimap_list_result_free( result ); |
373 | 372 | ||
374 | /* | 373 | /* |
375 | * second stage - get the other then inbox folders | 374 | * second stage - get the other then inbox folders |
376 | */ | 375 | */ |
377 | mask = "*" ; | 376 | mask = "*" ; |
378 | path = account->getPrefix().latin1(); | 377 | path = account->getPrefix().latin1(); |
379 | if (!path) path = ""; | 378 | if (!path) path = ""; |
380 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 379 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
381 | if ( err == MAILIMAP_NO_ERROR ) { | 380 | if ( err == MAILIMAP_NO_ERROR ) { |
382 | current = result->first; | 381 | current = result->first; |
383 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 382 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
384 | no_inferiors = false; | 383 | no_inferiors = false; |
385 | list = (mailimap_mailbox_list *) current->data; | 384 | list = (mailimap_mailbox_list *) current->data; |
386 | // it is better use the deep copy mechanism of qt itself | 385 | // it is better use the deep copy mechanism of qt itself |
387 | // instead of using strdup! | 386 | // instead of using strdup! |
388 | temp = list->mb_name; | 387 | temp = list->mb_name; |
389 | if (temp.lower()=="inbox") | 388 | if (temp.lower()=="inbox") |
390 | continue; | 389 | continue; |
391 | if (temp.lower()==account->getPrefix().lower()) | 390 | if (temp.lower()==account->getPrefix().lower()) |
392 | continue; | 391 | continue; |
393 | if ( (bflags = list->mb_flag) ) { | 392 | if ( (bflags = list->mb_flag) ) { |
394 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 393 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
395 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 394 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
396 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 395 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
397 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 396 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
398 | no_inferiors = true; | 397 | no_inferiors = true; |
399 | } | 398 | } |
400 | } | 399 | } |
401 | } | 400 | } |
402 | del = list->mb_delimiter; | 401 | del = list->mb_delimiter; |
403 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 402 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
404 | } | 403 | } |
405 | } else { | 404 | } else { |
406 | qDebug("error fetching folders "); | 405 | qDebug("error fetching folders "); |
407 | 406 | ||
408 | } | 407 | } |
409 | if (result) mailimap_list_result_free( result ); | 408 | if (result) mailimap_list_result_free( result ); |
410 | return folders; | 409 | return folders; |
411 | } | 410 | } |
412 | 411 | ||
413 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 412 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
414 | { | 413 | { |
415 | RecMail * m = 0; | 414 | RecMail * m = 0; |
416 | mailimap_msg_att_item *item=0; | 415 | mailimap_msg_att_item *item=0; |
417 | clistcell *current,*c,*cf; | 416 | clistcell *current,*c,*cf; |
418 | mailimap_msg_att_dynamic*flist; | 417 | mailimap_msg_att_dynamic*flist; |
419 | mailimap_flag_fetch*cflag; | 418 | mailimap_flag_fetch*cflag; |
420 | int size = 0; | 419 | int size = 0; |
421 | QBitArray mFlags(7); | 420 | QBitArray mFlags(7); |
422 | QStringList addresslist; | 421 | QStringList addresslist; |
423 | 422 | ||
424 | if (!m_att) { | 423 | if (!m_att) { |
425 | return m; | 424 | return m; |
426 | } | 425 | } |
427 | m = new RecMail(); | 426 | m = new RecMail(); |
428 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 427 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
429 | current = c; | 428 | current = c; |
430 | size = 0; | 429 | size = 0; |
431 | item = (mailimap_msg_att_item*)current->data; | 430 | item = (mailimap_msg_att_item*)current->data; |
432 | if ( !item ) | 431 | if ( !item ) |
433 | continue; | 432 | continue; |
434 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 433 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
435 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 434 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
436 | if (!flist || !flist->att_list) { | 435 | if (!flist || !flist->att_list) { |
437 | continue; | 436 | continue; |
438 | } | 437 | } |
439 | cf = flist->att_list->first; | 438 | cf = flist->att_list->first; |
440 | if( ! cf ) | 439 | if( ! cf ) |
441 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 440 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
442 | cflag = (mailimap_flag_fetch*)cf->data; | 441 | cflag = (mailimap_flag_fetch*)cf->data; |
443 | if( ! cflag ) | 442 | if( ! cflag ) |
444 | qDebug("imap:not cflag "); | 443 | qDebug("imap:not cflag "); |
445 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 444 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
446 | switch (cflag->fl_flag->fl_type) { | 445 | switch (cflag->fl_flag->fl_type) { |
447 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 446 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
448 | mFlags.setBit(FLAG_ANSWERED); | 447 | mFlags.setBit(FLAG_ANSWERED); |
449 | break; | 448 | break; |
450 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 449 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
451 | mFlags.setBit(FLAG_FLAGGED); | 450 | mFlags.setBit(FLAG_FLAGGED); |
452 | break; | 451 | break; |
453 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 452 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
454 | mFlags.setBit(FLAG_DELETED); | 453 | mFlags.setBit(FLAG_DELETED); |
455 | break; | 454 | break; |
456 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 455 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
457 | mFlags.setBit(FLAG_SEEN); | 456 | mFlags.setBit(FLAG_SEEN); |
458 | break; | 457 | break; |
459 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 458 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
460 | mFlags.setBit(FLAG_DRAFT); | 459 | mFlags.setBit(FLAG_DRAFT); |
461 | break; | 460 | break; |
462 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 461 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
463 | break; | 462 | break; |
464 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 463 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
465 | break; | 464 | break; |
466 | default: | 465 | default: |
467 | break; | 466 | break; |
468 | } | 467 | } |
469 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 468 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
470 | mFlags.setBit(FLAG_RECENT); | 469 | mFlags.setBit(FLAG_RECENT); |
471 | } | 470 | } |
472 | } | 471 | } |
473 | continue; | 472 | continue; |
474 | } | 473 | } |
475 | if ( item->att_data.att_static == NULL ) | 474 | if ( item->att_data.att_static == NULL ) |
476 | continue; | 475 | continue; |
477 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 476 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
478 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 477 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
479 | if ( head == NULL ) | 478 | if ( head == NULL ) |
480 | continue; | 479 | continue; |
481 | if ( head->env_date != NULL ) { | 480 | if ( head->env_date != NULL ) { |
482 | m->setDate(head->env_date); | 481 | m->setDate(head->env_date); |
483 | //struct mailimf_date_time result; | 482 | //struct mailimf_date_time result; |
484 | struct mailimf_date_time* date;// = &result; | 483 | struct mailimf_date_time* date;// = &result; |
485 | struct mailimf_date_time **re = &date; | 484 | struct mailimf_date_time **re = &date; |
486 | size_t length = m->getDate().length(); | 485 | size_t length = m->getDate().length(); |
487 | size_t index = 0; | 486 | size_t index = 0; |
488 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { | 487 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { |
489 | QDateTime dt = Genericwrapper::parseDateTime( date ); | 488 | QDateTime dt = Genericwrapper::parseDateTime( date ); |
490 | QString ret; | 489 | QString ret; |
491 | if ( dt.date() == QDate::currentDate () ) | 490 | if ( dt.date() == QDate::currentDate () ) |
492 | ret = KGlobal::locale()->formatTime( dt.time(),true); | 491 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
493 | else { | 492 | else { |
494 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 493 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
495 | } | 494 | } |
496 | m->setDate( ret ); | 495 | m->setDate( ret ); |
497 | char tmp[20]; | 496 | char tmp[20]; |
498 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", | 497 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", |
499 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); | 498 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); |
500 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); | 499 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); |
501 | m->setIsoDate( QString( tmp ) ); | 500 | m->setIsoDate( QString( tmp ) ); |
502 | mailimf_date_time_free ( date ); | 501 | mailimf_date_time_free ( date ); |
503 | } else { | 502 | } else { |
504 | m->setIsoDate(head->env_date); | 503 | m->setIsoDate(head->env_date); |
505 | } | 504 | } |
506 | } | 505 | } |
507 | if ( head->env_subject != NULL ) | 506 | if ( head->env_subject != NULL ) |
508 | m->setSubject(convert_String((const char*)head->env_subject)); | 507 | m->setSubject(convert_String((const char*)head->env_subject)); |
509 | //m->setSubject(head->env_subject); | 508 | //m->setSubject(head->env_subject); |
510 | if (head->env_from!=NULL) { | 509 | if (head->env_from!=NULL) { |
511 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 510 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
512 | if (addresslist.count()) { | 511 | if (addresslist.count()) { |
513 | m->setFrom(addresslist.first()); | 512 | m->setFrom(addresslist.first()); |
514 | } | 513 | } |
515 | } | 514 | } |
516 | if (head->env_to!=NULL) { | 515 | if (head->env_to!=NULL) { |
517 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 516 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
518 | m->setTo(addresslist); | 517 | m->setTo(addresslist); |
519 | } | 518 | } |
520 | if (head->env_cc!=NULL) { | 519 | if (head->env_cc!=NULL) { |
521 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 520 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
522 | m->setCC(addresslist); | 521 | m->setCC(addresslist); |
523 | } | 522 | } |
524 | if (head->env_bcc!=NULL) { | 523 | if (head->env_bcc!=NULL) { |
525 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 524 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
526 | m->setBcc(addresslist); | 525 | m->setBcc(addresslist); |
527 | } | 526 | } |
528 | /* reply to address, eg. email. */ | 527 | /* reply to address, eg. email. */ |
529 | if (head->env_reply_to!=NULL) { | 528 | if (head->env_reply_to!=NULL) { |
530 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 529 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
531 | if (addresslist.count()) { | 530 | if (addresslist.count()) { |
532 | m->setReplyto(addresslist.first()); | 531 | m->setReplyto(addresslist.first()); |
533 | } | 532 | } |
534 | } | 533 | } |
535 | if (head->env_in_reply_to!=NULL) { | 534 | if (head->env_in_reply_to!=NULL) { |
536 | QString h(head->env_in_reply_to); | 535 | QString h(head->env_in_reply_to); |
537 | while (h.length()>0 && h[0]=='<') { | 536 | while (h.length()>0 && h[0]=='<') { |
538 | h.remove(0,1); | 537 | h.remove(0,1); |
539 | } | 538 | } |
540 | while (h.length()>0 && h[h.length()-1]=='>') { | 539 | while (h.length()>0 && h[h.length()-1]=='>') { |
541 | h.remove(h.length()-1,1); | 540 | h.remove(h.length()-1,1); |
542 | } | 541 | } |
543 | if (h.length()>0) { | 542 | if (h.length()>0) { |
544 | m->setInreply(QStringList(h)); | 543 | m->setInreply(QStringList(h)); |
545 | } | 544 | } |
546 | } | 545 | } |
547 | if (head->env_message_id != NULL) { | 546 | if (head->env_message_id != NULL) { |
548 | m->setMsgid(QString(head->env_message_id)); | 547 | m->setMsgid(QString(head->env_message_id)); |
549 | } | 548 | } |
550 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 549 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
551 | #if 0 | 550 | #if 0 |
552 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 551 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
553 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 552 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
554 | qDebug("time %s ",da.toString().latin1() ); | 553 | qDebug("time %s ",da.toString().latin1() ); |
555 | #endif | 554 | #endif |
556 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 555 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
557 | size = item->att_data.att_static->att_data.att_rfc822_size; | 556 | size = item->att_data.att_static->att_data.att_rfc822_size; |
558 | } | 557 | } |
559 | } | 558 | } |
560 | /* msg is already deleted */ | 559 | /* msg is already deleted */ |
561 | if (mFlags.testBit(FLAG_DELETED) && m) { | 560 | if (mFlags.testBit(FLAG_DELETED) && m) { |
562 | delete m; | 561 | delete m; |
563 | m = 0; | 562 | m = 0; |
564 | } | 563 | } |
565 | if (m) { | 564 | if (m) { |
566 | m->setFlags(mFlags); | 565 | m->setFlags(mFlags); |
567 | m->setMsgsize(size); | 566 | m->setMsgsize(size); |
568 | } | 567 | } |
569 | return m; | 568 | return m; |
570 | } | 569 | } |
571 | 570 | ||
572 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 571 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
573 | { | 572 | { |
574 | RecBodyP body = new RecBody(); | 573 | RecBodyP body = new RecBody(); |
575 | const char *mb; | 574 | const char *mb; |
576 | int err = MAILIMAP_NO_ERROR; | 575 | int err = MAILIMAP_NO_ERROR; |
577 | clist *result = 0; | 576 | clist *result = 0; |
578 | clistcell *current; | 577 | clistcell *current; |
579 | mailimap_fetch_att *fetchAtt = 0; | 578 | mailimap_fetch_att *fetchAtt = 0; |
580 | mailimap_fetch_type *fetchType = 0; | 579 | mailimap_fetch_type *fetchType = 0; |
581 | mailimap_set *set = 0; | 580 | mailimap_set *set = 0; |
582 | mailimap_body*body_desc = 0; | 581 | mailimap_body*body_desc = 0; |
583 | 582 | ||
584 | mb = mail->getMbox().latin1(); | 583 | mb = mail->getMbox().latin1(); |
585 | 584 | ||
586 | login(); | 585 | login(); |
587 | if (!m_imap) { | 586 | if (!m_imap) { |
588 | return body; | 587 | return body; |
589 | } | 588 | } |
590 | err = selectMbox(mail->getMbox()); | 589 | err = selectMbox(mail->getMbox()); |
591 | if ( err != MAILIMAP_NO_ERROR ) { | 590 | if ( err != MAILIMAP_NO_ERROR ) { |
592 | return body; | 591 | return body; |
593 | } | 592 | } |
594 | 593 | ||
595 | /* the range has to start at 1!!! not with 0!!!! */ | 594 | /* the range has to start at 1!!! not with 0!!!! */ |
596 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); | 595 | set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); |
597 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 596 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
598 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 597 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
599 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 598 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
600 | mailimap_set_free( set ); | 599 | mailimap_set_free( set ); |
601 | mailimap_fetch_type_free( fetchType ); | 600 | mailimap_fetch_type_free( fetchType ); |
602 | 601 | ||
603 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 602 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
604 | mailimap_msg_att * msg_att; | 603 | mailimap_msg_att * msg_att; |
605 | msg_att = (mailimap_msg_att*)current->data; | 604 | msg_att = (mailimap_msg_att*)current->data; |
606 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 605 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
607 | QValueList<int> path; | 606 | QValueList<int> path; |
608 | body_desc = item->att_data.att_static->att_data.att_body; | 607 | body_desc = item->att_data.att_static->att_data.att_body; |
609 | traverseBody(mail,body_desc,body,0,path); | 608 | traverseBody(mail,body_desc,body,0,path); |
610 | } else { | 609 | } else { |
611 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; | 610 | //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; |
612 | } | 611 | } |
613 | if (result) mailimap_fetch_list_free(result); | 612 | if (result) mailimap_fetch_list_free(result); |
614 | return body; | 613 | return body; |
615 | } | 614 | } |
616 | 615 | ||
617 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 616 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
618 | { | 617 | { |
619 | QStringList l; | 618 | QStringList l; |
620 | QString from; | 619 | QString from; |
621 | bool named_from; | 620 | bool named_from; |
622 | clistcell *current = NULL; | 621 | clistcell *current = NULL; |
623 | mailimap_address * current_address=NULL; | 622 | mailimap_address * current_address=NULL; |
624 | if (!list) { | 623 | if (!list) { |
625 | return l; | 624 | return l; |
626 | } | 625 | } |
627 | unsigned int count = 0; | 626 | unsigned int count = 0; |
628 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 627 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
629 | from = ""; | 628 | from = ""; |
630 | named_from = false; | 629 | named_from = false; |
631 | current_address=(mailimap_address*)current->data; | 630 | current_address=(mailimap_address*)current->data; |
632 | if (current_address->ad_personal_name){ | 631 | if (current_address->ad_personal_name){ |
633 | from+=convert_String((const char*)current_address->ad_personal_name); | 632 | from+=convert_String((const char*)current_address->ad_personal_name); |
634 | from+=" "; | 633 | from+=" "; |
635 | named_from = true; | 634 | named_from = true; |
636 | } | 635 | } |
637 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 636 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
638 | from+="<"; | 637 | from+="<"; |
639 | } | 638 | } |
640 | if (current_address->ad_mailbox_name) { | 639 | if (current_address->ad_mailbox_name) { |
641 | from+=QString(current_address->ad_mailbox_name); | 640 | from+=QString(current_address->ad_mailbox_name); |
642 | from+="@"; | 641 | from+="@"; |
643 | } | 642 | } |
644 | if (current_address->ad_host_name) { | 643 | if (current_address->ad_host_name) { |
645 | from+=QString(current_address->ad_host_name); | 644 | from+=QString(current_address->ad_host_name); |
646 | } | 645 | } |
647 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 646 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
648 | from+=">"; | 647 | from+=">"; |
649 | } | 648 | } |
650 | l.append(QString(from)); | 649 | l.append(QString(from)); |
651 | if (++count > 99) { | 650 | if (++count > 99) { |
652 | break; | 651 | break; |
653 | } | 652 | } |
654 | } | 653 | } |
655 | return l; | 654 | return l; |
656 | } | 655 | } |
657 | 656 | ||
658 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) | 657 | encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) |
659 | { | 658 | { |
660 | encodedString*res=new encodedString; | 659 | encodedString*res=new encodedString; |
661 | int err; | 660 | int err; |
662 | mailimap_fetch_type *fetchType; | 661 | mailimap_fetch_type *fetchType; |
663 | mailimap_set *set; | 662 | mailimap_set *set; |
664 | clistcell*current,*cur; | 663 | clistcell*current,*cur; |
665 | mailimap_section_part * section_part = 0; | 664 | mailimap_section_part * section_part = 0; |
666 | mailimap_section_spec * section_spec = 0; | 665 | mailimap_section_spec * section_spec = 0; |
667 | mailimap_section * section = 0; | 666 | mailimap_section * section = 0; |
668 | mailimap_fetch_att * fetch_att = 0; | 667 | mailimap_fetch_att * fetch_att = 0; |
669 | 668 | ||
670 | login(); | 669 | login(); |
671 | if (!m_imap) { | 670 | if (!m_imap) { |
672 | return res; | 671 | return res; |
673 | } | 672 | } |
674 | if (!internal_call) { | 673 | if (!internal_call) { |
675 | err = selectMbox(mail->getMbox()); | 674 | err = selectMbox(mail->getMbox()); |
676 | if ( err != MAILIMAP_NO_ERROR ) { | 675 | if ( err != MAILIMAP_NO_ERROR ) { |
677 | return res; | 676 | return res; |
678 | } | 677 | } |
679 | } | 678 | } |
680 | set = mailimap_set_new_single(mail->getNumber()); | 679 | set = mailimap_set_new_single(mail->getNumber()); |
681 | 680 | ||
682 | clist*id_list = 0; | 681 | clist*id_list = 0; |
683 | 682 | ||
684 | /* if path == empty then its a request for the whole rfc822 mail and generates | 683 | /* if path == empty then its a request for the whole rfc822 mail and generates |
685 | a "fetch <id> (body[])" statement on imap server */ | 684 | a "fetch <id> (body[])" statement on imap server */ |
686 | if (path.count()>0 ) { | 685 | if (path.count()>0 ) { |
687 | id_list = clist_new(); | 686 | id_list = clist_new(); |
688 | for (unsigned j=0; j < path.count();++j) { | 687 | for (unsigned j=0; j < path.count();++j) { |
689 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 688 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
690 | *p_id = path[j]; | 689 | *p_id = path[j]; |
691 | clist_append(id_list,p_id); | 690 | clist_append(id_list,p_id); |
692 | } | 691 | } |
693 | section_part = mailimap_section_part_new(id_list); | 692 | section_part = mailimap_section_part_new(id_list); |
694 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 693 | section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
695 | } | 694 | } |
696 | 695 | ||
697 | section = mailimap_section_new(section_spec); | 696 | section = mailimap_section_new(section_spec); |
698 | fetch_att = mailimap_fetch_att_new_body_section(section); | 697 | fetch_att = mailimap_fetch_att_new_body_section(section); |
699 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 698 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
700 | 699 | ||
701 | clist*result = 0; | 700 | clist*result = 0; |
702 | 701 | ||
703 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 702 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
704 | mailimap_set_free( set ); | 703 | mailimap_set_free( set ); |
705 | mailimap_fetch_type_free( fetchType ); | 704 | mailimap_fetch_type_free( fetchType ); |
706 | 705 | ||
707 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 706 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
708 | mailimap_msg_att * msg_att; | 707 | mailimap_msg_att * msg_att; |
709 | msg_att = (mailimap_msg_att*)current->data; | 708 | msg_att = (mailimap_msg_att*)current->data; |
710 | mailimap_msg_att_item*msg_att_item; | 709 | mailimap_msg_att_item*msg_att_item; |
711 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 710 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
712 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 711 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
713 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 712 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
714 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 713 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
715 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 714 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
716 | /* detach - we take over the content */ | 715 | /* detach - we take over the content */ |
717 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 716 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
718 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 717 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
719 | } | 718 | } |
720 | } | 719 | } |
721 | } | 720 | } |
722 | } else { | 721 | } else { |
723 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; | 722 | ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; |
724 | } | 723 | } |
725 | if (result) mailimap_fetch_list_free(result); | 724 | if (result) mailimap_fetch_list_free(result); |
726 | return res; | 725 | return res; |
727 | } | 726 | } |
728 | 727 | ||
729 | /* current_recursion is for recursive calls. | 728 | /* current_recursion is for recursive calls. |
730 | current_count means the position inside the internal loop! */ | 729 | current_count means the position inside the internal loop! */ |
731 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, | 730 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, |
732 | int current_recursion,QValueList<int>recList,int current_count) | 731 | int current_recursion,QValueList<int>recList,int current_count) |
733 | { | 732 | { |
734 | if (!body || current_recursion>=10) { | 733 | if (!body || current_recursion>=10) { |
735 | return; | 734 | return; |
736 | } | 735 | } |
737 | switch (body->bd_type) { | 736 | switch (body->bd_type) { |
738 | case MAILIMAP_BODY_1PART: | 737 | case MAILIMAP_BODY_1PART: |
739 | { | 738 | { |
740 | QValueList<int>countlist = recList; | 739 | QValueList<int>countlist = recList; |
741 | countlist.append(current_count); | 740 | countlist.append(current_count); |
742 | RecPartP currentPart = new RecPart(); | 741 | RecPartP currentPart = new RecPart(); |
743 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 742 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
744 | QString id(""); | 743 | QString id(""); |
745 | currentPart->setPositionlist(countlist); | 744 | currentPart->setPositionlist(countlist); |
746 | for (unsigned int j = 0; j < countlist.count();++j) { | 745 | for (unsigned int j = 0; j < countlist.count();++j) { |
747 | id+=(j>0?" ":""); | 746 | id+=(j>0?" ":""); |
748 | id+=QString("%1").arg(countlist[j]); | 747 | id+=QString("%1").arg(countlist[j]); |
749 | } | 748 | } |
750 | //odebug << "ID = " << id.latin1() << "" << oendl; | 749 | //odebug << "ID = " << id.latin1() << "" << oendl; |
751 | currentPart->setIdentifier(id); | 750 | currentPart->setIdentifier(id); |
752 | fillSinglePart(currentPart,part1); | 751 | fillSinglePart(currentPart,part1); |
753 | /* important: Check for is NULL 'cause a body can be empty! | 752 | /* important: Check for is NULL 'cause a body can be empty! |
754 | And we put it only into the mail if it is the FIRST part */ | 753 | And we put it only into the mail if it is the FIRST part */ |
755 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { | 754 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { |
756 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); | 755 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); |
757 | 756 | ||
758 | size_t index = 0; | 757 | size_t index = 0; |
759 | char*res = 0; | 758 | char*res = 0; |
760 | int err = MAILIMF_NO_ERROR; | 759 | int err = MAILIMF_NO_ERROR; |
761 | 760 | ||
762 | QString charset = currentPart->searchParamter( "charset"); | 761 | QString charset = currentPart->searchParamter( "charset"); |
763 | qDebug("CHARSET %s ",charset.latin1() ); | 762 | qDebug("CHARSET %s ",charset.latin1() ); |
764 | if ( false ) { | 763 | if ( false ) { |
765 | //if ( !charset.isEmpty() ) { | 764 | //if ( !charset.isEmpty() ) { |
766 | target_body->setCharset( charset ); | 765 | target_body->setCharset( charset ); |
767 | //err = mailmime_encoded_phrase_parse("iso-8859-1", | 766 | //err = mailmime_encoded_phrase_parse("iso-8859-1", |
768 | // text, strlen(text),&index, "iso-8859-1",&res); | 767 | // text, strlen(text),&index, "iso-8859-1",&res); |
769 | err = mailmime_encoded_phrase_parse(charset.latin1(), | 768 | err = mailmime_encoded_phrase_parse(charset.latin1(), |
770 | body_text.latin1(), body_text.length(),&index, "utf-8",&res); | 769 | body_text.latin1(), body_text.length(),&index, "utf-8",&res); |
771 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { | 770 | if (err == MAILIMF_NO_ERROR && res && strlen(res)) { |
772 | //qDebug("res %d %s ", index, res); | 771 | //qDebug("res %d %s ", index, res); |
773 | body_text = QString::fromUtf8(res); | 772 | body_text = QString::fromUtf8(res); |
774 | } | 773 | } |
775 | if (res) free(res); | 774 | if (res) free(res); |
776 | } | 775 | } |
777 | //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); | 776 | //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); |
778 | target_body->setDescription(currentPart); | 777 | target_body->setDescription(currentPart); |
779 | target_body->setBodytext(body_text); | 778 | target_body->setBodytext(body_text); |
780 | if (countlist.count()>1) { | 779 | if (countlist.count()>1) { |
781 | target_body->addPart(currentPart); | 780 | target_body->addPart(currentPart); |
782 | } | 781 | } |
783 | } else { | 782 | } else { |
784 | target_body->addPart(currentPart); | 783 | target_body->addPart(currentPart); |
785 | } | 784 | } |
786 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { | 785 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { |
787 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); | 786 | traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); |
788 | } | 787 | } |
789 | } | 788 | } |
790 | break; | 789 | break; |
791 | case MAILIMAP_BODY_MPART: | 790 | case MAILIMAP_BODY_MPART: |
792 | { | 791 | { |
793 | QValueList<int>countlist = recList; | 792 | QValueList<int>countlist = recList; |
794 | clistcell*current=0; | 793 | clistcell*current=0; |
795 | mailimap_body*current_body=0; | 794 | mailimap_body*current_body=0; |
796 | unsigned int ccount = 1; | 795 | unsigned int ccount = 1; |
797 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; | 796 | mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; |
798 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 797 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
799 | current_body = (mailimap_body*)current->data; | 798 | current_body = (mailimap_body*)current->data; |
800 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 799 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
801 | RecPartP targetPart = new RecPart(); | 800 | RecPartP targetPart = new RecPart(); |
802 | targetPart->setType("multipart"); | 801 | targetPart->setType("multipart"); |
803 | fillMultiPart(targetPart,mailDescription); | 802 | fillMultiPart(targetPart,mailDescription); |
804 | countlist.append(current_count); | 803 | countlist.append(current_count); |
805 | targetPart->setPositionlist(countlist); | 804 | targetPart->setPositionlist(countlist); |
806 | target_body->addPart(targetPart); | 805 | target_body->addPart(targetPart); |
807 | QString id(""); | 806 | QString id(""); |
808 | for (unsigned int j = 0; j < countlist.count();++j) { | 807 | for (unsigned int j = 0; j < countlist.count();++j) { |
809 | id+=(j>0?" ":""); | 808 | id+=(j>0?" ":""); |
810 | id+=QString("%1").arg(countlist[j]); | 809 | id+=QString("%1").arg(countlist[j]); |
811 | } | 810 | } |
812 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; | 811 | // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; |
813 | } | 812 | } |
814 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | 813 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); |
815 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 814 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
816 | countlist = recList; | 815 | countlist = recList; |
817 | } | 816 | } |
818 | ++ccount; | 817 | ++ccount; |
819 | } | 818 | } |
820 | } | 819 | } |
821 | break; | 820 | break; |
822 | default: | 821 | default: |
823 | break; | 822 | break; |
824 | } | 823 | } |
825 | } | 824 | } |
826 | 825 | ||
827 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) | 826 | void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) |
828 | { | 827 | { |
829 | if (!Description) { | 828 | if (!Description) { |
830 | return; | 829 | return; |
831 | } | 830 | } |
832 | switch (Description->bd_type) { | 831 | switch (Description->bd_type) { |
833 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 832 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
834 | target_part->setType("text"); | 833 | target_part->setType("text"); |
835 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 834 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
836 | break; | 835 | break; |
837 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 836 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
838 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 837 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
839 | break; | 838 | break; |
840 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 839 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
841 | target_part->setType("message"); | 840 | target_part->setType("message"); |
842 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | 841 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); |
843 | break; | 842 | break; |
844 | default: | 843 | default: |
845 | break; | 844 | break; |
846 | } | 845 | } |
847 | } | 846 | } |
848 | 847 | ||
849 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) | 848 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) |
850 | { | 849 | { |
851 | if (!which) { | 850 | if (!which) { |
852 | return; | 851 | return; |
853 | } | 852 | } |
854 | QString sub; | 853 | QString sub; |
855 | sub = which->bd_media_text; | 854 | sub = which->bd_media_text; |
856 | //odebug << "Type= text/" << which->bd_media_text << "" << oendl; | 855 | //odebug << "Type= text/" << which->bd_media_text << "" << oendl; |
857 | target_part->setSubtype(sub.lower()); | 856 | target_part->setSubtype(sub.lower()); |
858 | target_part->setLines(which->bd_lines); | 857 | target_part->setLines(which->bd_lines); |
859 | fillBodyFields(target_part,which->bd_fields); | 858 | fillBodyFields(target_part,which->bd_fields); |
860 | } | 859 | } |
861 | 860 | ||
862 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) | 861 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) |
863 | { | 862 | { |
864 | if (!which) { | 863 | if (!which) { |
865 | return; | 864 | return; |
866 | } | 865 | } |
867 | target_part->setSubtype("rfc822"); | 866 | target_part->setSubtype("rfc822"); |
868 | //odebug << "Message part" << oendl; | 867 | //odebug << "Message part" << oendl; |
869 | /* we set this type to text/plain */ | 868 | /* we set this type to text/plain */ |
870 | target_part->setLines(which->bd_lines); | 869 | target_part->setLines(which->bd_lines); |
871 | fillBodyFields(target_part,which->bd_fields); | 870 | fillBodyFields(target_part,which->bd_fields); |
872 | } | 871 | } |
873 | 872 | ||
874 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) | 873 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) |
875 | { | 874 | { |
876 | if (!which) return; | 875 | if (!which) return; |
877 | QString sub = which->bd_media_subtype; | 876 | QString sub = which->bd_media_subtype; |
878 | target_part->setSubtype(sub.lower()); | 877 | target_part->setSubtype(sub.lower()); |
879 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | 878 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { |
880 | clistcell*cur = 0; | 879 | clistcell*cur = 0; |
881 | mailimap_single_body_fld_param*param=0; | 880 | mailimap_single_body_fld_param*param=0; |
882 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 881 | for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
883 | param = (mailimap_single_body_fld_param*)cur->data; | 882 | param = (mailimap_single_body_fld_param*)cur->data; |
884 | if (param) { | 883 | if (param) { |
885 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 884 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
886 | } | 885 | } |
887 | } | 886 | } |
888 | } | 887 | } |
889 | } | 888 | } |
890 | 889 | ||
891 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) | 890 | void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_basic*which) |
892 | { | 891 | { |
893 | if (!which) { | 892 | if (!which) { |
894 | return; | 893 | return; |
895 | } | 894 | } |
896 | QString type,sub; | 895 | QString type,sub; |
897 | switch (which->bd_media_basic->med_type) { | 896 | switch (which->bd_media_basic->med_type) { |
898 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | 897 | case MAILIMAP_MEDIA_BASIC_APPLICATION: |
899 | type = "application"; | 898 | type = "application"; |
900 | break; | 899 | break; |
901 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 900 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
902 | type = "audio"; | 901 | type = "audio"; |
903 | break; | 902 | break; |
904 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 903 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
905 | type = "image"; | 904 | type = "image"; |
906 | break; | 905 | break; |
907 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 906 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
908 | type = "message"; | 907 | type = "message"; |
909 | break; | 908 | break; |
910 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 909 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
911 | type = "video"; | 910 | type = "video"; |
912 | break; | 911 | break; |
913 | case MAILIMAP_MEDIA_BASIC_OTHER: | 912 | case MAILIMAP_MEDIA_BASIC_OTHER: |
914 | default: | 913 | default: |
915 | if (which->bd_media_basic->med_basic_type) { | 914 | if (which->bd_media_basic->med_basic_type) { |
916 | type = which->bd_media_basic->med_basic_type; | 915 | type = which->bd_media_basic->med_basic_type; |
917 | } else { | 916 | } else { |
918 | type = ""; | 917 | type = ""; |
919 | } | 918 | } |
920 | break; | 919 | break; |
921 | } | 920 | } |
922 | if (which->bd_media_basic->med_subtype) { | 921 | if (which->bd_media_basic->med_subtype) { |
923 | sub = which->bd_media_basic->med_subtype; | 922 | sub = which->bd_media_basic->med_subtype; |
924 | } else { | 923 | } else { |
925 | sub = ""; | 924 | sub = ""; |
926 | } | 925 | } |
927 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; | 926 | // odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; |
928 | target_part->setType(type.lower()); | 927 | target_part->setType(type.lower()); |
929 | target_part->setSubtype(sub.lower()); | 928 | target_part->setSubtype(sub.lower()); |
930 | fillBodyFields(target_part,which->bd_fields); | 929 | fillBodyFields(target_part,which->bd_fields); |
931 | } | 930 | } |
932 | 931 | ||
933 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) | 932 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) |
934 | { | 933 | { |
935 | if (!which) return; | 934 | if (!which) return; |
936 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { | 935 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { |
937 | clistcell*cur; | 936 | clistcell*cur; |
938 | mailimap_single_body_fld_param*param=0; | 937 | mailimap_single_body_fld_param*param=0; |
939 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 938 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
940 | param = (mailimap_single_body_fld_param*)cur->data; | 939 | param = (mailimap_single_body_fld_param*)cur->data; |
941 | if (param) { | 940 | if (param) { |
942 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | 941 | target_part->addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); |
943 | } | 942 | } |
944 | } | 943 | } |
945 | } | 944 | } |
946 | mailimap_body_fld_enc*enc = which->bd_encoding; | 945 | mailimap_body_fld_enc*enc = which->bd_encoding; |
947 | QString encoding(""); | 946 | QString encoding(""); |
948 | switch (enc->enc_type) { | 947 | switch (enc->enc_type) { |
949 | case MAILIMAP_BODY_FLD_ENC_7BIT: | 948 | case MAILIMAP_BODY_FLD_ENC_7BIT: |
950 | encoding = "7bit"; | 949 | encoding = "7bit"; |
951 | break; | 950 | break; |
952 | case MAILIMAP_BODY_FLD_ENC_8BIT: | 951 | case MAILIMAP_BODY_FLD_ENC_8BIT: |
953 | encoding = "8bit"; | 952 | encoding = "8bit"; |
954 | break; | 953 | break; |
955 | case MAILIMAP_BODY_FLD_ENC_BINARY: | 954 | case MAILIMAP_BODY_FLD_ENC_BINARY: |
956 | encoding="binary"; | 955 | encoding="binary"; |
957 | break; | 956 | break; |
958 | case MAILIMAP_BODY_FLD_ENC_BASE64: | 957 | case MAILIMAP_BODY_FLD_ENC_BASE64: |
959 | encoding="base64"; | 958 | encoding="base64"; |
960 | break; | 959 | break; |
961 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | 960 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: |
962 | encoding="quoted-printable"; | 961 | encoding="quoted-printable"; |
963 | break; | 962 | break; |
964 | case MAILIMAP_BODY_FLD_ENC_OTHER: | 963 | case MAILIMAP_BODY_FLD_ENC_OTHER: |
965 | default: | 964 | default: |
966 | if (enc->enc_value) { | 965 | if (enc->enc_value) { |
967 | char*t=enc->enc_value; | 966 | char*t=enc->enc_value; |
968 | encoding=QString(enc->enc_value); | 967 | encoding=QString(enc->enc_value); |
969 | enc->enc_value=0L; | 968 | enc->enc_value=0L; |
970 | free(t); | 969 | free(t); |
971 | } | 970 | } |
972 | } | 971 | } |
973 | if (which->bd_description) { | 972 | if (which->bd_description) { |
974 | target_part->setDescription(QString(which->bd_description)); | 973 | target_part->setDescription(QString(which->bd_description)); |
975 | } | 974 | } |
976 | target_part->setEncoding(encoding); | 975 | target_part->setEncoding(encoding); |
977 | target_part->setSize(which->bd_size); | 976 | target_part->setSize(which->bd_size); |
978 | } | 977 | } |
979 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) | 978 | void IMAPwrapper::deleteMailList(const QValueList<RecMailP>&target) |
980 | { | 979 | { |
981 | //#if 0 | 980 | //#if 0 |
982 | mailimap_flag_list*flist; | 981 | mailimap_flag_list*flist; |
983 | mailimap_set *set; | 982 | mailimap_set *set; |
984 | mailimap_store_att_flags * store_flags; | 983 | mailimap_store_att_flags * store_flags; |
985 | int err; | 984 | int err; |
986 | login(); | 985 | login(); |
987 | //#endif | 986 | //#endif |
988 | if (!m_imap) { | 987 | if (!m_imap) { |
989 | return; | 988 | return; |
990 | } | 989 | } |
991 | int iii = 0; | 990 | int iii = 0; |
992 | int count = target.count(); | 991 | int count = target.count(); |
993 | // qDebug("imap remove count %d ", count); | 992 | // qDebug("imap remove count %d ", count); |
994 | 993 | ||
995 | 994 | ||
996 | mMax = count; | 995 | mMax = count; |
997 | progress( i18n("Delete")); | 996 | progress( i18n("Delete")); |
998 | 997 | ||
999 | QProgressBar wid ( count ); | 998 | QProgressBar wid ( count ); |
1000 | wid.setCaption( i18n("Deleting ...")); | 999 | wid.setCaption( i18n("Deleting ...")); |
1001 | wid.show(); | 1000 | wid.show(); |
1002 | while (iii < count ) { | 1001 | while (iii < count ) { |
1003 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); | 1002 | Global::statusMessage(i18n("Delete message %1 of %2").arg(iii).arg(count)); |
1004 | wid.setProgress( iii ); | 1003 | wid.setProgress( iii ); |
1005 | wid.raise(); | 1004 | wid.raise(); |
1006 | qApp->processEvents(); | 1005 | qApp->processEvents(); |
1007 | RecMailP mail = (*target.at( iii )); | 1006 | RecMailP mail = (*target.at( iii )); |
1008 | //#if 0 | 1007 | //#if 0 |
1009 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); | 1008 | //qDebug("IMAP remove %d %d ", iii, mail->getNumber() ); |
1010 | err = selectMbox(mail->getMbox()); | 1009 | err = selectMbox(mail->getMbox()); |
1011 | if ( err != MAILIMAP_NO_ERROR ) { | 1010 | if ( err != MAILIMAP_NO_ERROR ) { |
1012 | return; | 1011 | return; |
1013 | } | 1012 | } |
1014 | flist = mailimap_flag_list_new_empty(); | 1013 | flist = mailimap_flag_list_new_empty(); |
1015 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1014 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1016 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1015 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1017 | set = mailimap_set_new_single(mail->getNumber()); | 1016 | set = mailimap_set_new_single(mail->getNumber()); |
1018 | err = mailimap_store(m_imap,set,store_flags); | 1017 | err = mailimap_store(m_imap,set,store_flags); |
1019 | mailimap_set_free( set ); | 1018 | mailimap_set_free( set ); |
1020 | mailimap_store_att_flags_free(store_flags); | 1019 | mailimap_store_att_flags_free(store_flags); |
1021 | 1020 | ||
1022 | if (err != MAILIMAP_NO_ERROR) { | 1021 | if (err != MAILIMAP_NO_ERROR) { |
1023 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 1022 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
1024 | return; | 1023 | return; |
1025 | } | 1024 | } |
1026 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1025 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1027 | /* should we realy do that at this moment? */ | 1026 | /* should we realy do that at this moment? */ |
1028 | 1027 | ||
1029 | // err = mailimap_expunge(m_imap); | 1028 | // err = mailimap_expunge(m_imap); |
1030 | //if (err != MAILIMAP_NO_ERROR) { | 1029 | //if (err != MAILIMAP_NO_ERROR) { |
1031 | // Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); | 1030 | // Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); |
1032 | // } | 1031 | // } |
1033 | //#endif | 1032 | //#endif |
1034 | //deleteMail( mail); | 1033 | //deleteMail( mail); |
1035 | ++iii; | 1034 | ++iii; |
1036 | } | 1035 | } |
1037 | //qDebug("Deleting imap mails... "); | 1036 | //qDebug("Deleting imap mails... "); |
1038 | err = mailimap_expunge(m_imap); | 1037 | err = mailimap_expunge(m_imap); |
1039 | if (err != MAILIMAP_NO_ERROR) { | 1038 | if (err != MAILIMAP_NO_ERROR) { |
1040 | Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); | 1039 | Global::statusMessage(i18n("Error deleting mails: %s").arg(m_imap->imap_response)); |
1041 | } | 1040 | } |
1042 | } | 1041 | } |
1043 | void IMAPwrapper::deleteMail(const RecMailP&mail) | 1042 | void IMAPwrapper::deleteMail(const RecMailP&mail) |
1044 | { | 1043 | { |
1045 | mailimap_flag_list*flist; | 1044 | mailimap_flag_list*flist; |
1046 | mailimap_set *set; | 1045 | mailimap_set *set; |
1047 | mailimap_store_att_flags * store_flags; | 1046 | mailimap_store_att_flags * store_flags; |
1048 | int err; | 1047 | int err; |
1049 | login(); | 1048 | login(); |
1050 | if (!m_imap) { | 1049 | if (!m_imap) { |
1051 | return; | 1050 | return; |
1052 | } | 1051 | } |
1053 | err = selectMbox(mail->getMbox()); | 1052 | err = selectMbox(mail->getMbox()); |
1054 | if ( err != MAILIMAP_NO_ERROR ) { | 1053 | if ( err != MAILIMAP_NO_ERROR ) { |
1055 | return; | 1054 | return; |
1056 | } | 1055 | } |
1057 | flist = mailimap_flag_list_new_empty(); | 1056 | flist = mailimap_flag_list_new_empty(); |
1058 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1057 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1059 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1058 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1060 | set = mailimap_set_new_single(mail->getNumber()); | 1059 | set = mailimap_set_new_single(mail->getNumber()); |
1061 | err = mailimap_store(m_imap,set,store_flags); | 1060 | err = mailimap_store(m_imap,set,store_flags); |
1062 | mailimap_set_free( set ); | 1061 | mailimap_set_free( set ); |
1063 | mailimap_store_att_flags_free(store_flags); | 1062 | mailimap_store_att_flags_free(store_flags); |
1064 | 1063 | ||
1065 | if (err != MAILIMAP_NO_ERROR) { | 1064 | if (err != MAILIMAP_NO_ERROR) { |
1066 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 1065 | // odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
1067 | return; | 1066 | return; |
1068 | } | 1067 | } |
1069 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1068 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1070 | /* should we realy do that at this moment? */ | 1069 | /* should we realy do that at this moment? */ |
1071 | 1070 | ||
1072 | err = mailimap_expunge(m_imap); | 1071 | err = mailimap_expunge(m_imap); |
1073 | if (err != MAILIMAP_NO_ERROR) { | 1072 | if (err != MAILIMAP_NO_ERROR) { |
1074 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); | 1073 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1075 | } | 1074 | } |
1076 | //qDebug("IMAPwrapper::deleteMail 2"); | 1075 | //qDebug("IMAPwrapper::deleteMail 2"); |
1077 | 1076 | ||
1078 | } | 1077 | } |
1079 | 1078 | ||
1080 | void IMAPwrapper::answeredMail(const RecMailP&mail) | 1079 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
1081 | { | 1080 | { |
1082 | mailimap_flag_list*flist; | 1081 | mailimap_flag_list*flist; |
1083 | mailimap_set *set; | 1082 | mailimap_set *set; |
1084 | mailimap_store_att_flags * store_flags; | 1083 | mailimap_store_att_flags * store_flags; |
1085 | int err; | 1084 | int err; |
1086 | login(); | 1085 | login(); |
1087 | if (!m_imap) { | 1086 | if (!m_imap) { |
1088 | return; | 1087 | return; |
1089 | } | 1088 | } |
1090 | err = selectMbox(mail->getMbox()); | 1089 | err = selectMbox(mail->getMbox()); |
1091 | if ( err != MAILIMAP_NO_ERROR ) { | 1090 | if ( err != MAILIMAP_NO_ERROR ) { |
1092 | return; | 1091 | return; |
1093 | } | 1092 | } |
1094 | flist = mailimap_flag_list_new_empty(); | 1093 | flist = mailimap_flag_list_new_empty(); |
1095 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 1094 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
1096 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 1095 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
1097 | set = mailimap_set_new_single(mail->getNumber()); | 1096 | set = mailimap_set_new_single(mail->getNumber()); |
1098 | err = mailimap_store(m_imap,set,store_flags); | 1097 | err = mailimap_store(m_imap,set,store_flags); |
1099 | mailimap_set_free( set ); | 1098 | mailimap_set_free( set ); |
1100 | mailimap_store_att_flags_free(store_flags); | 1099 | mailimap_store_att_flags_free(store_flags); |
1101 | 1100 | ||
1102 | if (err != MAILIMAP_NO_ERROR) { | 1101 | if (err != MAILIMAP_NO_ERROR) { |
1103 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; | 1102 | // odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; |
1104 | return; | 1103 | return; |
1105 | } | 1104 | } |
1106 | } | 1105 | } |
1107 | 1106 | ||
1108 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 1107 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
1109 | { | 1108 | { |
1110 | QString body(""); | 1109 | QString body(""); |
1111 | encodedString*res = fetchRawPart(mail,path,internal_call); | 1110 | encodedString*res = fetchRawPart(mail,path,internal_call); |
1112 | encodedString*r = decode_String(res,enc); | 1111 | encodedString*r = decode_String(res,enc); |
1113 | delete res; | 1112 | delete res; |
1114 | if (r) { | 1113 | if (r) { |
1115 | if (r->Length()>0) { | 1114 | if (r->Length()>0) { |
1116 | body = r->Content(); | 1115 | body = r->Content(); |
1117 | } | 1116 | } |
1118 | delete r; | 1117 | delete r; |
1119 | } | 1118 | } |
1120 | return body; | 1119 | return body; |
1121 | } | 1120 | } |
1122 | 1121 | ||
1123 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) | 1122 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const RecPartP&part) |
1124 | { | 1123 | { |
1125 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); | 1124 | return fetchTextPart(mail,part->Positionlist(),false,part->Encoding()); |
1126 | } | 1125 | } |
1127 | 1126 | ||
1128 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) | 1127 | encodedString* IMAPwrapper::fetchDecodedPart(const RecMailP&mail,const RecPartP&part) |
1129 | { | 1128 | { |
1130 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); | 1129 | encodedString*res = fetchRawPart(mail,part->Positionlist(),false); |
1131 | encodedString*r = decode_String(res,part->Encoding()); | 1130 | encodedString*r = decode_String(res,part->Encoding()); |
1132 | delete res; | 1131 | delete res; |
1133 | return r; | 1132 | return r; |
1134 | } | 1133 | } |
1135 | 1134 | ||
1136 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) | 1135 | encodedString* IMAPwrapper::fetchRawPart(const RecMailP&mail,const RecPartP&part) |
1137 | { | 1136 | { |
1138 | return fetchRawPart(mail,part->Positionlist(),false); | 1137 | return fetchRawPart(mail,part->Positionlist(),false); |
1139 | } | 1138 | } |
1140 | 1139 | ||
1141 | int IMAPwrapper::deleteAllMail(const FolderP&folder) | 1140 | int IMAPwrapper::deleteAllMail(const FolderP&folder) |
1142 | { | 1141 | { |
1143 | login(); | 1142 | login(); |
1144 | if (!m_imap) { | 1143 | if (!m_imap) { |
1145 | return 0; | 1144 | return 0; |
1146 | } | 1145 | } |
1147 | mailimap_flag_list*flist; | 1146 | mailimap_flag_list*flist; |
1148 | mailimap_set *set; | 1147 | mailimap_set *set; |
1149 | mailimap_store_att_flags * store_flags; | 1148 | mailimap_store_att_flags * store_flags; |
1150 | int err = selectMbox(folder->getName()); | 1149 | int err = selectMbox(folder->getName()); |
1151 | if ( err != MAILIMAP_NO_ERROR ) { | 1150 | if ( err != MAILIMAP_NO_ERROR ) { |
1152 | return 0; | 1151 | return 0; |
1153 | } | 1152 | } |
1154 | 1153 | ||
1155 | int last = m_imap->imap_selection_info->sel_exists; | 1154 | int last = m_imap->imap_selection_info->sel_exists; |
1156 | if (last == 0) { | 1155 | if (last == 0) { |
1157 | Global::statusMessage(i18n("Mailbox has no mails!")); | 1156 | Global::statusMessage(i18n("Mailbox has no mails!")); |
1158 | return 0; | 1157 | return 0; |
1159 | } | 1158 | } |
1160 | flist = mailimap_flag_list_new_empty(); | 1159 | flist = mailimap_flag_list_new_empty(); |
1161 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1160 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
1162 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1161 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
1163 | set = mailimap_set_new_interval( 1, last ); | 1162 | set = mailimap_set_new_interval( 1, last ); |
1164 | err = mailimap_store(m_imap,set,store_flags); | 1163 | err = mailimap_store(m_imap,set,store_flags); |
1165 | mailimap_set_free( set ); | 1164 | mailimap_set_free( set ); |
1166 | mailimap_store_att_flags_free(store_flags); | 1165 | mailimap_store_att_flags_free(store_flags); |
1167 | if (err != MAILIMAP_NO_ERROR) { | 1166 | if (err != MAILIMAP_NO_ERROR) { |
1168 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); | 1167 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1169 | return 0; | 1168 | return 0; |
1170 | } | 1169 | } |
1171 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1170 | // odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1172 | /* should we realy do that at this moment? */ | 1171 | /* should we realy do that at this moment? */ |
1173 | err = mailimap_expunge(m_imap); | 1172 | err = mailimap_expunge(m_imap); |
1174 | if (err != MAILIMAP_NO_ERROR) { | 1173 | if (err != MAILIMAP_NO_ERROR) { |
1175 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); | 1174 | Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); |
1176 | return 0; | 1175 | return 0; |
1177 | } | 1176 | } |
1178 | // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; | 1177 | // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; |
1179 | return 1; | 1178 | return 1; |
1180 | } | 1179 | } |
1181 | 1180 | ||
1182 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) | 1181 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) |
1183 | { | 1182 | { |
1184 | if (folder.length()==0) return 0; | 1183 | if (folder.length()==0) return 0; |
1185 | login(); | 1184 | login(); |
1186 | if (!m_imap) {return 0;} | 1185 | if (!m_imap) {return 0;} |
1187 | QString pre = account->getPrefix(); | 1186 | QString pre = account->getPrefix(); |
1188 | if (delemiter.length()>0 && pre.findRev(delemiter)!=((int)pre.length())-1) { | 1187 | if (delemiter.length()>0 && pre.findRev(delemiter)!=((int)pre.length())-1) { |
1189 | pre+=delemiter; | 1188 | pre+=delemiter; |
1190 | } | 1189 | } |
1191 | if (parentfolder) { | 1190 | if (parentfolder) { |
1192 | pre += parentfolder->getDisplayName()+delemiter; | 1191 | pre += parentfolder->getDisplayName()+delemiter; |
1193 | } | 1192 | } |
1194 | pre+=folder; | 1193 | pre+=folder; |
1195 | if (getsubfolder) { | 1194 | if (getsubfolder) { |
1196 | if (delemiter.length()>0) { | 1195 | if (delemiter.length()>0) { |
1197 | pre+=delemiter; | 1196 | pre+=delemiter; |
1198 | } else { | 1197 | } else { |
1199 | Global::statusMessage(i18n("Cannot create folder %1 for holding subfolders").arg(pre)); | 1198 | Global::statusMessage(i18n("Cannot create folder %1 for holding subfolders").arg(pre)); |
1200 | return 0; | 1199 | return 0; |
1201 | } | 1200 | } |
1202 | } | 1201 | } |
1203 | // odebug << "Creating " << pre.latin1() << "" << oendl; | 1202 | // odebug << "Creating " << pre.latin1() << "" << oendl; |
1204 | int res = mailimap_create(m_imap,pre.latin1()); | 1203 | int res = mailimap_create(m_imap,pre.latin1()); |
1205 | if (res != MAILIMAP_NO_ERROR) { | 1204 | if (res != MAILIMAP_NO_ERROR) { |
1206 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); | 1205 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); |
1207 | return 0; | 1206 | return 0; |
1208 | } | 1207 | } |
1209 | return 1; | 1208 | return 1; |
1210 | } | 1209 | } |
1211 | 1210 | ||
1212 | int IMAPwrapper::deleteMbox(const FolderP&folder) | 1211 | int IMAPwrapper::deleteMbox(const FolderP&folder) |
1213 | { | 1212 | { |
1214 | if (!folder) return 0; | 1213 | if (!folder) return 0; |
1215 | login(); | 1214 | login(); |
1216 | if (!m_imap) {return 0;} | 1215 | if (!m_imap) {return 0;} |
1217 | int res = mailimap_delete(m_imap,folder->getName()); | 1216 | int res = mailimap_delete(m_imap,folder->getName()); |
1218 | if (res != MAILIMAP_NO_ERROR) { | 1217 | if (res != MAILIMAP_NO_ERROR) { |
1219 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); | 1218 | Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); |
1220 | return 0; | 1219 | return 0; |
1221 | } | 1220 | } |
1222 | return 1; | 1221 | return 1; |
1223 | } | 1222 | } |
1224 | 1223 | ||
1225 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | 1224 | void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) |
1226 | { | 1225 | { |
1227 | mailimap_status_att_list * att_list =0; | 1226 | mailimap_status_att_list * att_list =0; |
1228 | mailimap_mailbox_data_status * status=0; | 1227 | mailimap_mailbox_data_status * status=0; |
1229 | clistiter * cur = 0; | 1228 | clistiter * cur = 0; |
1230 | int r = 0; | 1229 | int r = 0; |
1231 | target_stat.message_count = 0; | 1230 | target_stat.message_count = 0; |
1232 | target_stat.message_unseen = 0; | 1231 | target_stat.message_unseen = 0; |
1233 | target_stat.message_recent = 0; | 1232 | target_stat.message_recent = 0; |
1234 | login(); | 1233 | login(); |
1235 | if (!m_imap) { | 1234 | if (!m_imap) { |
1236 | return; | 1235 | return; |
1237 | } | 1236 | } |
1238 | att_list = mailimap_status_att_list_new_empty(); | 1237 | att_list = mailimap_status_att_list_new_empty(); |
1239 | if (!att_list) return; | 1238 | if (!att_list) return; |
1240 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); | 1239 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_MESSAGES); |
1241 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); | 1240 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_RECENT); |
1242 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); | 1241 | r = mailimap_status_att_list_add(att_list, MAILIMAP_STATUS_ATT_UNSEEN); |
1243 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); | 1242 | r = mailimap_status(m_imap, mailbox.latin1(), att_list, &status); |
1244 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { | 1243 | if (r==MAILIMAP_NO_ERROR&&status->st_info_list!=0) { |
1245 | for (cur = clist_begin(status->st_info_list); | 1244 | for (cur = clist_begin(status->st_info_list); |
1246 | cur != NULL ; cur = clist_next(cur)) { | 1245 | cur != NULL ; cur = clist_next(cur)) { |
1247 | mailimap_status_info * status_info; | 1246 | mailimap_status_info * status_info; |
1248 | status_info = (mailimap_status_info *)clist_content(cur); | 1247 | status_info = (mailimap_status_info *)clist_content(cur); |
1249 | switch (status_info->st_att) { | 1248 | switch (status_info->st_att) { |
1250 | case MAILIMAP_STATUS_ATT_MESSAGES: | 1249 | case MAILIMAP_STATUS_ATT_MESSAGES: |
1251 | target_stat.message_count = status_info->st_value; | 1250 | target_stat.message_count = status_info->st_value; |
1252 | break; | 1251 | break; |
1253 | case MAILIMAP_STATUS_ATT_RECENT: | 1252 | case MAILIMAP_STATUS_ATT_RECENT: |
1254 | target_stat.message_recent = status_info->st_value; | 1253 | target_stat.message_recent = status_info->st_value; |
1255 | break; | 1254 | break; |
1256 | case MAILIMAP_STATUS_ATT_UNSEEN: | 1255 | case MAILIMAP_STATUS_ATT_UNSEEN: |
1257 | target_stat.message_unseen = status_info->st_value; | 1256 | target_stat.message_unseen = status_info->st_value; |
1258 | break; | 1257 | break; |
1259 | } | 1258 | } |
1260 | } | 1259 | } |
1261 | } else { | 1260 | } else { |
1262 | // odebug << "Error retrieving status" << oendl; | 1261 | // odebug << "Error retrieving status" << oendl; |
1263 | } | 1262 | } |
1264 | if (status) mailimap_mailbox_data_status_free(status); | 1263 | if (status) mailimap_mailbox_data_status_free(status); |
1265 | if (att_list) mailimap_status_att_list_free(att_list); | 1264 | if (att_list) mailimap_status_att_list_free(att_list); |
1266 | } | 1265 | } |
1267 | 1266 | ||
1268 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 1267 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
1269 | { | 1268 | { |
1270 | login(); | 1269 | login(); |
1271 | if (!m_imap) return; | 1270 | if (!m_imap) return; |
1272 | if (!msg) return; | 1271 | if (!msg) return; |
1273 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 1272 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
1274 | if (r != MAILIMAP_NO_ERROR) { | 1273 | if (r != MAILIMAP_NO_ERROR) { |
1275 | Global::statusMessage("Error storing mail!"); | 1274 | Global::statusMessage("Error storing mail!"); |
1276 | } | 1275 | } |
1277 | } | 1276 | } |
1278 | 1277 | ||
1279 | MAILLIB::ATYPE IMAPwrapper::getType()const | 1278 | MAILLIB::ATYPE IMAPwrapper::getType()const |
1280 | { | 1279 | { |
1281 | return account->getType(); | 1280 | return account->getType(); |
1282 | } | 1281 | } |
1283 | 1282 | ||
1284 | const QString&IMAPwrapper::getName()const | 1283 | const QString&IMAPwrapper::getName()const |
1285 | { | 1284 | { |
1286 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; | 1285 | // odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; |
1287 | return account->getAccountName(); | 1286 | return account->getAccountName(); |
1288 | } | 1287 | } |
1289 | 1288 | ||
1290 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) | 1289 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1291 | { | 1290 | { |
1292 | // dummy | 1291 | // dummy |
1293 | QValueList<int> path; | 1292 | QValueList<int> path; |
1294 | return fetchRawPart(mail,path,false); | 1293 | return fetchRawPart(mail,path,false); |
1295 | } | 1294 | } |
1296 | 1295 | ||
1297 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | 1296 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1298 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) | 1297 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit, int maxSizeInKb) |
1299 | { | 1298 | { |
1300 | if (targetWrapper != this || maxSizeInKb > 0 ) { | 1299 | if (targetWrapper != this || maxSizeInKb > 0 ) { |
1301 | mMax = 0; | 1300 | mMax = 0; |
1302 | progress( i18n("Copy")); | 1301 | progress( i18n("Copy")); |
1303 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); | 1302 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit, maxSizeInKb); |
1304 | //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); | 1303 | //qDebug("IMAPwrapper::mvcpAllMails::Using generic"); |
1305 | // odebug << "Using generic" << oendl; | 1304 | // odebug << "Using generic" << oendl; |
1306 | return; | 1305 | return; |
1307 | } | 1306 | } |
1308 | mailimap_set *set = 0; | 1307 | mailimap_set *set = 0; |
1309 | login(); | 1308 | login(); |
1310 | if (!m_imap) { | 1309 | if (!m_imap) { |
1311 | return; | 1310 | return; |
1312 | } | 1311 | } |
1313 | int err = selectMbox(fromFolder->getName()); | 1312 | int err = selectMbox(fromFolder->getName()); |
1314 | if ( err != MAILIMAP_NO_ERROR ) { | 1313 | if ( err != MAILIMAP_NO_ERROR ) { |
1315 | return; | 1314 | return; |
1316 | } | 1315 | } |
1317 | Global::statusMessage( i18n("Copying mails on server...") ); | 1316 | Global::statusMessage( i18n("Copying mails on server...") ); |
1318 | int last = m_imap->imap_selection_info->sel_exists; | 1317 | int last = m_imap->imap_selection_info->sel_exists; |
1319 | set = mailimap_set_new_interval( 1, last ); | 1318 | set = mailimap_set_new_interval( 1, last ); |
1320 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1319 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1321 | mailimap_set_free( set ); | 1320 | mailimap_set_free( set ); |
1322 | if ( err != MAILIMAP_NO_ERROR ) { | 1321 | if ( err != MAILIMAP_NO_ERROR ) { |
1323 | QString error_msg = i18n("Error copy mails: %1").arg(m_imap->imap_response); | 1322 | QString error_msg = i18n("Error copy mails: %1").arg(m_imap->imap_response); |
1324 | Global::statusMessage(error_msg); | 1323 | Global::statusMessage(error_msg); |
1325 | // odebug << error_msg << oendl; | 1324 | // odebug << error_msg << oendl; |
1326 | return; | 1325 | return; |
1327 | } | 1326 | } |
1328 | if (moveit) { | 1327 | if (moveit) { |
1329 | deleteAllMail(fromFolder); | 1328 | deleteAllMail(fromFolder); |
1330 | } | 1329 | } |
1331 | } | 1330 | } |
1332 | 1331 | ||
1333 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1332 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1334 | { | 1333 | { |
1335 | if (targetWrapper != this) { | 1334 | if (targetWrapper != this) { |
1336 | // odebug << "Using generic" << oendl; | 1335 | // odebug << "Using generic" << oendl; |
1337 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1336 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1338 | return; | 1337 | return; |
1339 | } | 1338 | } |
1340 | mailimap_set *set = 0; | 1339 | mailimap_set *set = 0; |
1341 | login(); | 1340 | login(); |
1342 | if (!m_imap) { | 1341 | if (!m_imap) { |
1343 | return; | 1342 | return; |
1344 | } | 1343 | } |
1345 | int err = selectMbox(mail->getMbox()); | 1344 | int err = selectMbox(mail->getMbox()); |
1346 | if ( err != MAILIMAP_NO_ERROR ) { | 1345 | if ( err != MAILIMAP_NO_ERROR ) { |
1347 | return; | 1346 | return; |
1348 | } | 1347 | } |
1349 | set = mailimap_set_new_single(mail->getNumber()); | 1348 | set = mailimap_set_new_single(mail->getNumber()); |
1350 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1349 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1351 | mailimap_set_free( set ); | 1350 | mailimap_set_free( set ); |
1352 | if ( err != MAILIMAP_NO_ERROR ) { | 1351 | if ( err != MAILIMAP_NO_ERROR ) { |
1353 | QString error_msg = i18n("error copy mail: %1").arg(m_imap->imap_response); | 1352 | QString error_msg = i18n("error copy mail: %1").arg(m_imap->imap_response); |
1354 | Global::statusMessage(error_msg); | 1353 | Global::statusMessage(error_msg); |
1355 | // odebug << error_msg << oendl; | 1354 | // odebug << error_msg << oendl; |
1356 | return; | 1355 | return; |
1357 | } | 1356 | } |
1358 | if (moveit) { | 1357 | if (moveit) { |
1359 | deleteMail(mail); | 1358 | deleteMail(mail); |
1360 | } | 1359 | } |
1361 | } | 1360 | } |
diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp index 0e4a64f..1dc374b 100644 --- a/kmicromail/mainwindow.cpp +++ b/kmicromail/mainwindow.cpp | |||
@@ -1,355 +1,355 @@ | |||
1 | 1 | ||
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qvbox.h> | 4 | #include <qvbox.h> |
5 | #include <qheader.h> | 5 | #include <qheader.h> |
6 | #include <qtimer.h> | 6 | #include <qtimer.h> |
7 | #include <qlayout.h> | 7 | #include <qlayout.h> |
8 | //#include <kdialog.h> | 8 | //#include <kdialog.h> |
9 | #include <kiconloader.h> | 9 | #include <kiconloader.h> |
10 | #include <kapplication.h> | 10 | #include <kapplication.h> |
11 | 11 | ||
12 | #ifdef DESKTOP_VERSION | 12 | #ifdef DESKTOP_VERSION |
13 | #include <qapplication.h> | 13 | #include <qapplication.h> |
14 | #include <qstatusbar.h> | 14 | #include <qstatusbar.h> |
15 | #include <kabc/stdaddressbook.h> | 15 | #include <kabc/stdaddressbook.h> |
16 | extern QStatusBar* globalSstatusBarMainWindow; | 16 | extern QStatusBar* globalSstatusBarMainWindow; |
17 | #else | 17 | #else |
18 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
19 | #include <klocale.h> | 19 | #include <klocale.h> |
20 | #endif | 20 | #endif |
21 | #include "defines.h" | 21 | #include "defines.h" |
22 | #include "mainwindow.h" | 22 | #include "mainwindow.h" |
23 | #include <KDGanttMinimizeSplitter.h> | 23 | #include <KDGanttMinimizeSplitter.h> |
24 | 24 | ||
25 | #include "koprefs.h" | 25 | #include "koprefs.h" |
26 | 26 | ||
27 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 27 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
28 | : QMainWindow( parent, name ) //, flags ) | 28 | : QMainWindow( parent, name ) //, flags ) |
29 | { | 29 | { |
30 | #ifdef DESKTOP_VERSION | 30 | #ifdef DESKTOP_VERSION |
31 | globalSstatusBarMainWindow = statusBar(); | 31 | globalSstatusBarMainWindow = statusBar(); |
32 | #endif | 32 | #endif |
33 | setCaption( i18n( "KOpieMail/Pi" ) ); | 33 | setCaption( i18n( "KOpieMail/Pi" ) ); |
34 | setToolBarsMovable( false ); | 34 | setToolBarsMovable( false ); |
35 | //KABC::StdAddressBook::self(); | 35 | //KABC::StdAddressBook::self(); |
36 | toolBar = new QToolBar( this ); | 36 | toolBar = new QToolBar( this ); |
37 | menuBar = new QPEMenuBar( toolBar ); | 37 | menuBar = new QPEMenuBar( toolBar ); |
38 | mailMenu = new QPopupMenu( menuBar ); | 38 | mailMenu = new QPopupMenu( menuBar ); |
39 | menuBar->insertItem( i18n( "Mail" ), mailMenu ); | 39 | menuBar->insertItem( i18n( "Mail" ), mailMenu ); |
40 | settingsMenu = new QPopupMenu( menuBar ); | 40 | settingsMenu = new QPopupMenu( menuBar ); |
41 | menuBar->insertItem( i18n( "Settings" ), settingsMenu ); | 41 | menuBar->insertItem( i18n( "Settings" ), settingsMenu ); |
42 | 42 | ||
43 | addToolBar( toolBar ); | 43 | addToolBar( toolBar ); |
44 | toolBar->setHorizontalStretchable( true ); | 44 | toolBar->setHorizontalStretchable( true ); |
45 | QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"), | 45 | QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"), |
46 | 0, 0, this ); | 46 | 0, 0, this ); |
47 | connect(getMail, SIGNAL( activated() ), | 47 | connect(getMail, SIGNAL( activated() ), |
48 | SLOT( slotGetAllMail() ) ); | 48 | SLOT( slotGetAllMail() ) ); |
49 | getMail->addTo( mailMenu ); | 49 | getMail->addTo( mailMenu ); |
50 | 50 | ||
51 | getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"), | 51 | getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"), |
52 | 0, 0, this ); | 52 | 0, 0, this ); |
53 | getMail->addTo( toolBar ); | 53 | getMail->addTo( toolBar ); |
54 | getMail->addTo( mailMenu ); | 54 | getMail->addTo( mailMenu ); |
55 | connect(getMail, SIGNAL( activated() ), | 55 | connect(getMail, SIGNAL( activated() ), |
56 | SLOT( slotGetMail() ) ); | 56 | SLOT( slotGetMail() ) ); |
57 | 57 | ||
58 | composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"), | 58 | composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"), |
59 | 0, 0, this ); | 59 | 0, 0, this ); |
60 | composeMail->addTo( toolBar ); | 60 | composeMail->addTo( toolBar ); |
61 | composeMail->addTo( mailMenu ); | 61 | composeMail->addTo( mailMenu ); |
62 | 62 | ||
63 | sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") , | 63 | sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") , |
64 | 0, 0, this ); | 64 | 0, 0, this ); |
65 | sendQueued->addTo( toolBar ); | 65 | sendQueued->addTo( toolBar ); |
66 | sendQueued->addTo( mailMenu ); | 66 | sendQueued->addTo( mailMenu ); |
67 | 67 | ||
68 | /* | 68 | /* |
69 | syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC, | 69 | syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC, |
70 | 0, 0, this ); | 70 | 0, 0, this ); |
71 | syncFolders->addTo( toolBar ); | 71 | syncFolders->addTo( toolBar ); |
72 | syncFolders->addTo( mailMenu ); | 72 | syncFolders->addTo( mailMenu ); |
73 | */ | 73 | */ |
74 | 74 | ||
75 | showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") , | 75 | showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") , |
76 | 0, 0, this, 0, true ); | 76 | 0, 0, this, 0, true ); |
77 | showFolders->addTo( toolBar ); | 77 | showFolders->addTo( toolBar ); |
78 | showFolders->addTo( mailMenu ); | 78 | showFolders->addTo( mailMenu ); |
79 | showFolders->setOn( true ); | 79 | showFolders->setOn( true ); |
80 | connect(showFolders, SIGNAL( toggled(bool) ), | 80 | connect(showFolders, SIGNAL( toggled(bool) ), |
81 | SLOT( slotShowFolders(bool) ) ); | 81 | SLOT( slotShowFolders(bool) ) ); |
82 | 82 | ||
83 | /* | 83 | /* |
84 | searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ), | 84 | searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ), |
85 | 0, 0, this ); | 85 | 0, 0, this ); |
86 | searchMails->addTo( toolBar ); | 86 | searchMails->addTo( toolBar ); |
87 | searchMails->addTo( mailMenu ); | 87 | searchMails->addTo( mailMenu ); |
88 | */ | 88 | */ |
89 | 89 | ||
90 | deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this); | 90 | deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this); |
91 | deleteMails->addTo( toolBar ); | 91 | deleteMails->addTo( toolBar ); |
92 | deleteMails->addTo( mailMenu ); | 92 | deleteMails->addTo( mailMenu ); |
93 | connect( deleteMails, SIGNAL( activated() ), | 93 | connect( deleteMails, SIGNAL( activated() ), |
94 | SLOT( slotDeleteMail() ) ); | 94 | SLOT( slotDeleteAllMail() ) ); |
95 | 95 | ||
96 | editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") , | 96 | editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") , |
97 | 0, 0, this ); | 97 | 0, 0, this ); |
98 | editSettings->addTo( settingsMenu ); | 98 | editSettings->addTo( settingsMenu ); |
99 | connect( editSettings, SIGNAL( activated() ), | 99 | connect( editSettings, SIGNAL( activated() ), |
100 | SLOT( slotEditSettings() ) ); | 100 | SLOT( slotEditSettings() ) ); |
101 | editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") , | 101 | editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") , |
102 | 0, 0, this ); | 102 | 0, 0, this ); |
103 | editAccounts->addTo( settingsMenu ); | 103 | editAccounts->addTo( settingsMenu ); |
104 | codecMenu = new QPopupMenu( menuBar ); | 104 | codecMenu = new QPopupMenu( menuBar ); |
105 | codecMenu->insertItem( "Western (iso-8859-1)",0,0); | 105 | codecMenu->insertItem( "Western (iso-8859-1)",0,0); |
106 | codecMenu->insertItem( "Cyrillic (iso-8859-5)",1,1); | 106 | codecMenu->insertItem( "Cyrillic (iso-8859-5)",1,1); |
107 | codecMenu->insertItem( "Western (iso-8859-15)",2,2); | 107 | codecMenu->insertItem( "Western (iso-8859-15)",2,2); |
108 | codecMenu->insertItem( "Chinese (big-5)",3,3); | 108 | codecMenu->insertItem( "Chinese (big-5)",3,3); |
109 | codecMenu->insertItem( "Unicode (utf-8)",4,4); | 109 | codecMenu->insertItem( "Unicode (utf-8)",4,4); |
110 | codecMenu->insertItem( "Userdefined ("+KOPrefs::instance()->mSendCodec+")",5,5); | 110 | codecMenu->insertItem( "Userdefined ("+KOPrefs::instance()->mSendCodec+")",5,5); |
111 | //disabled | 111 | //disabled |
112 | //settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu); | 112 | //settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu); |
113 | //setCentralWidget( view ); | 113 | //setCentralWidget( view ); |
114 | 114 | ||
115 | QVBox* wrapperBox = new QVBox( this ); | 115 | QVBox* wrapperBox = new QVBox( this ); |
116 | setCentralWidget( wrapperBox ); | 116 | setCentralWidget( wrapperBox ); |
117 | 117 | ||
118 | // QWidget *view = new QWidget( wrapperBox ); | 118 | // QWidget *view = new QWidget( wrapperBox ); |
119 | KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); | 119 | KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); |
120 | split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); | 120 | split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); |
121 | //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); | 121 | //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); |
122 | 122 | ||
123 | folderView = new AccountView( split ); | 123 | folderView = new AccountView( split ); |
124 | folderView->header()->hide(); | 124 | folderView->header()->hide(); |
125 | folderView->setRootIsDecorated( false ); | 125 | folderView->setRootIsDecorated( false ); |
126 | folderView->addColumn( i18n( "Mailbox" ) ); | 126 | folderView->addColumn( i18n( "Mailbox" ) ); |
127 | 127 | ||
128 | //layout->addWidget( folderView ); | 128 | //layout->addWidget( folderView ); |
129 | 129 | ||
130 | mailView = new QListView( split ); | 130 | mailView = new QListView( split ); |
131 | mailView->addColumn( i18n( " " ) ); | 131 | mailView->addColumn( i18n( " " ) ); |
132 | mailView->addColumn( i18n( "Subject" ),QListView::Manual ); | 132 | mailView->addColumn( i18n( "Subject" ),QListView::Manual ); |
133 | mailView->addColumn( i18n( "Sender" ),QListView::Manual ); | 133 | mailView->addColumn( i18n( "Sender" ),QListView::Manual ); |
134 | mailView->addColumn( i18n( "Size" ),QListView::Manual); | 134 | mailView->addColumn( i18n( "Size" ),QListView::Manual); |
135 | mailView->addColumn( i18n( "Date" ),QListView::Manual); | 135 | mailView->addColumn( i18n( "Date" ),QListView::Manual); |
136 | mailView->setAllColumnsShowFocus(true); | 136 | mailView->setAllColumnsShowFocus(true); |
137 | //mailView->setSorting(-1); | 137 | //mailView->setSorting(-1); |
138 | mailView->setRootIsDecorated( false ); | 138 | mailView->setRootIsDecorated( false ); |
139 | statusWidget = new StatusWidget( wrapperBox ); | 139 | statusWidget = new StatusWidget( wrapperBox ); |
140 | statusWidget->hide(); | 140 | statusWidget->hide(); |
141 | 141 | ||
142 | //layout->addWidget( mailView ); | 142 | //layout->addWidget( mailView ); |
143 | //layout->setStretchFactor( folderView, 1 ); | 143 | //layout->setStretchFactor( folderView, 1 ); |
144 | //layout->setStretchFactor( mailView, 2 ); | 144 | //layout->setStretchFactor( mailView, 2 ); |
145 | 145 | ||
146 | slotAdjustLayout(); | 146 | slotAdjustLayout(); |
147 | #ifndef DESKTOP_VERSION | 147 | #ifndef DESKTOP_VERSION |
148 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); | 148 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); |
149 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); | 149 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); |
150 | #endif | 150 | #endif |
151 | connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, | 151 | connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, |
152 | SLOT( mailLeftClicked(QListViewItem*) ) ); | 152 | SLOT( mailLeftClicked(QListViewItem*) ) ); |
153 | connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, | 153 | connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, |
154 | SLOT( mailLeftClicked(QListViewItem*) ) ); | 154 | SLOT( mailLeftClicked(QListViewItem*) ) ); |
155 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 155 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
156 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); | 156 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); |
157 | connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), | 157 | connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), |
158 | this,SLOT(refreshMailView(const QValueList<RecMailP>&))); | 158 | this,SLOT(refreshMailView(const QValueList<RecMailP>&))); |
159 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); | 159 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); |
160 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); | 160 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); |
161 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); | 161 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); |
162 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); | 162 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); |
163 | //mailView->setMultiSelection ( true ); | 163 | //mailView->setMultiSelection ( true ); |
164 | mailView->setSelectionMode( QListView::Extended ); | 164 | mailView->setSelectionMode( QListView::Extended ); |
165 | QValueList<int> list; | 165 | QValueList<int> list; |
166 | int fw = 100; | 166 | int fw = 100; |
167 | if ( QApplication::desktop()->width() > 320 ) | 167 | if ( QApplication::desktop()->width() > 320 ) |
168 | fw = 50; | 168 | fw = 50; |
169 | list.append( fw ); | 169 | list.append( fw ); |
170 | list.append( 100 ); | 170 | list.append( 100 ); |
171 | split->setSizes( list ); | 171 | split->setSizes( list ); |
172 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 172 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
173 | mailView->setShowSortIndicator ( true ); | 173 | mailView->setShowSortIndicator ( true ); |
174 | QLabel *spacer = new QLabel( toolBar ); | 174 | QLabel *spacer = new QLabel( toolBar ); |
175 | spacer->setBackgroundMode( QWidget::PaletteButton ); | 175 | spacer->setBackgroundMode( QWidget::PaletteButton ); |
176 | toolBar->setStretchableWidget( spacer ); | 176 | toolBar->setStretchableWidget( spacer ); |
177 | 177 | ||
178 | QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); | 178 | QAction* closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); |
179 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); | 179 | connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); |
180 | if ( QApplication::desktop()->width() > 320 ) | 180 | if ( QApplication::desktop()->width() > 320 ) |
181 | closeMail->addTo(toolBar); | 181 | closeMail->addTo(toolBar); |
182 | closeMail->addTo(mailMenu); | 182 | closeMail->addTo(mailMenu); |
183 | 183 | ||
184 | 184 | ||
185 | QPopupMenu* helpMenu = new QPopupMenu( menuBar ); | 185 | QPopupMenu* helpMenu = new QPopupMenu( menuBar ); |
186 | menuBar->insertItem( i18n( "Help" ), helpMenu ); | 186 | menuBar->insertItem( i18n( "Help" ), helpMenu ); |
187 | QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this); | 187 | QAction* li = new QAction(i18n("About"), QPixmap(), 0, 0, this); |
188 | connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); | 188 | connect( li, SIGNAL( activated() ), SLOT( showAbout()) ); |
189 | li->addTo(helpMenu); | 189 | li->addTo(helpMenu); |
190 | li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this); | 190 | li = new QAction(i18n("Licence"),QPixmap(), 0, 0, this); |
191 | connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); | 191 | connect( li, SIGNAL( activated() ), SLOT( showLicence()) ); |
192 | li->addTo(helpMenu); | 192 | li->addTo(helpMenu); |
193 | li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this); | 193 | li = new QAction(i18n("LibEtPan Licence"), QPixmap(), 0, 0, this); |
194 | connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); | 194 | connect( li, SIGNAL( activated() ), SLOT( showEtpanLicence()) ); |
195 | li->addTo(helpMenu); | 195 | li->addTo(helpMenu); |
196 | connect( codecMenu, SIGNAL( activated(int) ), this, SLOT( slotSetCodec( int )) ); | 196 | connect( codecMenu, SIGNAL( activated(int) ), this, SLOT( slotSetCodec( int )) ); |
197 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | 197 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); |
198 | #ifdef DESKTOP_VERSION | 198 | #ifdef DESKTOP_VERSION |
199 | resize ( 640, 480 ); | 199 | resize ( 640, 480 ); |
200 | #endif | 200 | #endif |
201 | } | 201 | } |
202 | 202 | ||
203 | MainWindow::~MainWindow() | 203 | MainWindow::~MainWindow() |
204 | { | 204 | { |
205 | } | 205 | } |
206 | 206 | ||
207 | void MainWindow::slotSetCodec( int codec ) | 207 | void MainWindow::slotSetCodec( int codec ) |
208 | { | 208 | { |
209 | codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, false ); | 209 | codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, false ); |
210 | //qDebug("codec %d ", codec); | 210 | //qDebug("codec %d ", codec); |
211 | KOPrefs::instance()->mCurrentCodec = codec; | 211 | KOPrefs::instance()->mCurrentCodec = codec; |
212 | KOPrefs::instance()->isDirty = true; | 212 | KOPrefs::instance()->isDirty = true; |
213 | QString name; | 213 | QString name; |
214 | switch ( codec ) { | 214 | switch ( codec ) { |
215 | case 0: | 215 | case 0: |
216 | name = "iso-8859-1"; | 216 | name = "iso-8859-1"; |
217 | break; | 217 | break; |
218 | case 1: | 218 | case 1: |
219 | name = "iso-8859-5"; | 219 | name = "iso-8859-5"; |
220 | break; | 220 | break; |
221 | case 2: | 221 | case 2: |
222 | name = "iso-8859-15"; | 222 | name = "iso-8859-15"; |
223 | break; | 223 | break; |
224 | case 3: | 224 | case 3: |
225 | name = "big-5"; | 225 | name = "big-5"; |
226 | break; | 226 | break; |
227 | case 4: | 227 | case 4: |
228 | name = "utf-8"; | 228 | name = "utf-8"; |
229 | break; | 229 | break; |
230 | case 5: | 230 | case 5: |
231 | name = KOPrefs::instance()->mSendCodec.lower(); | 231 | name = KOPrefs::instance()->mSendCodec.lower(); |
232 | break; | 232 | break; |
233 | } | 233 | } |
234 | KOPrefs::instance()->mCurrentCodeName = name ; | 234 | KOPrefs::instance()->mCurrentCodeName = name ; |
235 | codecMenu->changeItem ( 5, "Userdefined ("+KOPrefs::instance()->mSendCodec+")"); | 235 | codecMenu->changeItem ( 5, "Userdefined ("+KOPrefs::instance()->mSendCodec+")"); |
236 | codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, true ); | 236 | codecMenu->setItemChecked(KOPrefs::instance()->mCurrentCodec, true ); |
237 | } | 237 | } |
238 | void MainWindow::showLicence() | 238 | void MainWindow::showLicence() |
239 | { | 239 | { |
240 | KApplication::showLicence(); | 240 | KApplication::showLicence(); |
241 | } | 241 | } |
242 | void MainWindow::showAbout() | 242 | void MainWindow::showAbout() |
243 | { | 243 | { |
244 | QString version; | 244 | QString version; |
245 | #include <../version> | 245 | #include <../version> |
246 | 246 | ||
247 | QString cap = "About KOpieMail/Pi"; | 247 | QString cap = "About KOpieMail/Pi"; |
248 | QString text =i18n("KOpieMail/Platform-independent\n") + | 248 | QString text =i18n("KOpieMail/Platform-independent\n") + |
249 | "(OM/Pi) " + version + " - " | 249 | "(OM/Pi) " + version + " - " |
250 | 250 | ||
251 | #ifdef DESKTOP_VERSION | 251 | #ifdef DESKTOP_VERSION |
252 | "Desktop Edition\n" | 252 | "Desktop Edition\n" |
253 | #else | 253 | #else |
254 | "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" | 254 | "PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n" |
255 | #endif | 255 | #endif |
256 | "www.pi-sync.net\n\n" | 256 | "www.pi-sync.net\n\n" |
257 | 257 | ||
258 | 258 | ||
259 | 259 | ||
260 | "Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" | 260 | "Copyright (c) 2004 Lutz Rogowski <lutz@pi-sync.net>\n" |
261 | "KOpieMail/Pi is based on Opie Mail\n" | 261 | "KOpieMail/Pi is based on Opie Mail\n" |
262 | "Copyright (c) Rajko Albrecht and the Opie team\n" | 262 | "Copyright (c) Rajko Albrecht and the Opie team\n" |
263 | "KOpieMail/Pi is licensed under the GPL\n" | 263 | "KOpieMail/Pi is licensed under the GPL\n" |
264 | "\n" | 264 | "\n" |
265 | "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" | 265 | "KOpieMail/Pi uses LibEtPan - a mail stuff library\n" |
266 | "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" | 266 | "Copyright (C) 2001, 2002 - DINH Viet Hoa\n" |
267 | "libEtPan has its own licence - see LibEtPan licence\n"; | 267 | "libEtPan has its own licence - see LibEtPan licence\n"; |
268 | 268 | ||
269 | KApplication::showText( cap, text ); | 269 | KApplication::showText( cap, text ); |
270 | } | 270 | } |
271 | void MainWindow::showEtpanLicence() | 271 | void MainWindow::showEtpanLicence() |
272 | { | 272 | { |
273 | KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" ); | 273 | KApplication::showFile( "LibEtPan licence", "kdepim/kopiemail/COPYRIGHTlibetpan" ); |
274 | 274 | ||
275 | } | 275 | } |
276 | void MainWindow::appMessage(const QCString &, const QByteArray &) | 276 | void MainWindow::appMessage(const QCString &, const QByteArray &) |
277 | { | 277 | { |
278 | qDebug("appMessage implemented by subclass"); | 278 | qDebug("appMessage implemented by subclass"); |
279 | } | 279 | } |
280 | 280 | ||
281 | void MainWindow::slotAdjustLayout() { | 281 | void MainWindow::slotAdjustLayout() { |
282 | 282 | ||
283 | /* | 283 | /* |
284 | QWidget *d = QApplication::desktop(); | 284 | QWidget *d = QApplication::desktop(); |
285 | 285 | ||
286 | if ( d->width() < d->height() ) { | 286 | if ( d->width() < d->height() ) { |
287 | layout->setDirection( QBoxLayout::TopToBottom ); | 287 | layout->setDirection( QBoxLayout::TopToBottom ); |
288 | } else { | 288 | } else { |
289 | layout->setDirection( QBoxLayout::LeftToRight ); | 289 | layout->setDirection( QBoxLayout::LeftToRight ); |
290 | } | 290 | } |
291 | */ | 291 | */ |
292 | } | 292 | } |
293 | 293 | ||
294 | void MainWindow::slotAdjustColumns() | 294 | void MainWindow::slotAdjustColumns() |
295 | { | 295 | { |
296 | bool hidden = folderView->isHidden(); | 296 | bool hidden = folderView->isHidden(); |
297 | if ( hidden ) folderView->show(); | 297 | if ( hidden ) folderView->show(); |
298 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 298 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
299 | if ( hidden ) folderView->hide(); | 299 | if ( hidden ) folderView->hide(); |
300 | 300 | ||
301 | mailView->setColumnWidth( 0, 10 ); | 301 | mailView->setColumnWidth( 0, 10 ); |
302 | mailView->setColumnWidth( 1, 100 ); | 302 | mailView->setColumnWidth( 1, 100 ); |
303 | mailView->setColumnWidth( 2, 100 ); | 303 | mailView->setColumnWidth( 2, 100 ); |
304 | mailView->setColumnWidth( 3, 50 ); | 304 | mailView->setColumnWidth( 3, 50 ); |
305 | mailView->setColumnWidth( 4, 120 ); | 305 | mailView->setColumnWidth( 4, 120 ); |
306 | } | 306 | } |
307 | 307 | ||
308 | void MainWindow::slotEditSettings() | 308 | void MainWindow::slotEditSettings() |
309 | { | 309 | { |
310 | } | 310 | } |
311 | 311 | ||
312 | void MainWindow::slotShowFolders( bool ) | 312 | void MainWindow::slotShowFolders( bool ) |
313 | { | 313 | { |
314 | qDebug("not implemented: "); | 314 | qDebug("not implemented: "); |
315 | } | 315 | } |
316 | 316 | ||
317 | void MainWindow::refreshMailView(const QValueList<RecMailP>&) | 317 | void MainWindow::refreshMailView(const QValueList<RecMailP>&) |
318 | { | 318 | { |
319 | qDebug("not implemented: "); | 319 | qDebug("not implemented: "); |
320 | } | 320 | } |
321 | 321 | ||
322 | void MainWindow::mailLeftClicked(QListViewItem * ) | 322 | void MainWindow::mailLeftClicked(QListViewItem * ) |
323 | { | 323 | { |
324 | qDebug("not implemented: "); | 324 | qDebug("not implemented: "); |
325 | } | 325 | } |
326 | 326 | ||
327 | void MainWindow::displayMail() | 327 | void MainWindow::displayMail() |
328 | { | 328 | { |
329 | qDebug("not implemented: "); | 329 | qDebug("not implemented: "); |
330 | } | 330 | } |
331 | 331 | ||
332 | void MainWindow::slotDeleteMail() | 332 | void MainWindow::slotDeleteMail() |
333 | { | 333 | { |
334 | qDebug("not implemented: "); | 334 | qDebug("not implemented: "); |
335 | } | 335 | } |
336 | 336 | ||
337 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) | 337 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) |
338 | { | 338 | { |
339 | qDebug("not implemented: "); | 339 | qDebug("not implemented: "); |
340 | } | 340 | } |
341 | 341 | ||
342 | void MainWindow::slotSendQueued() | 342 | void MainWindow::slotSendQueued() |
343 | { | 343 | { |
344 | qDebug("not implemented: "); | 344 | qDebug("not implemented: "); |
345 | } | 345 | } |
346 | 346 | ||
347 | void MainWindow::slotEditAccounts() | 347 | void MainWindow::slotEditAccounts() |
348 | { | 348 | { |
349 | qDebug("not implemented: "); | 349 | qDebug("not implemented: "); |
350 | } | 350 | } |
351 | 351 | ||
352 | void MainWindow::slotComposeMail() | 352 | void MainWindow::slotComposeMail() |
353 | { | 353 | { |
354 | qDebug("not implemented: "); | 354 | qDebug("not implemented: "); |
355 | } | 355 | } |
diff --git a/kmicromail/mainwindow.h b/kmicromail/mainwindow.h index d0a5caf..016e44c 100644 --- a/kmicromail/mainwindow.h +++ b/kmicromail/mainwindow.h | |||
@@ -1,69 +1,70 @@ | |||
1 | 1 | ||
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | #ifndef MAINWINDOW_H | 3 | #ifndef MAINWINDOW_H |
4 | #define MAINWINDOW_H | 4 | #define MAINWINDOW_H |
5 | 5 | ||
6 | #include <qmainwindow.h> | 6 | #include <qmainwindow.h> |
7 | #include <qlistview.h> | 7 | #include <qlistview.h> |
8 | #include <qaction.h> | 8 | #include <qaction.h> |
9 | 9 | ||
10 | #include <qtoolbar.h> | 10 | #include <qtoolbar.h> |
11 | #ifdef DESKTOP_VERSION | 11 | #ifdef DESKTOP_VERSION |
12 | #include <qmenubar.h> | 12 | #include <qmenubar.h> |
13 | #define QPEMenuBar QMenuBar | 13 | #define QPEMenuBar QMenuBar |
14 | #else | 14 | #else |
15 | #include <qpe/qpemenubar.h> | 15 | #include <qpe/qpemenubar.h> |
16 | #endif | 16 | #endif |
17 | 17 | ||
18 | #include "accountview.h" | 18 | #include "accountview.h" |
19 | #include "statuswidget.h" | 19 | #include "statuswidget.h" |
20 | 20 | ||
21 | #include <libmailwrapper/mailtypes.h> | 21 | #include <libmailwrapper/mailtypes.h> |
22 | #include <opie2/osmartpointer.h> | 22 | #include <opie2/osmartpointer.h> |
23 | 23 | ||
24 | class RecMail; | 24 | class RecMail; |
25 | 25 | ||
26 | class MainWindow : public QMainWindow | 26 | class MainWindow : public QMainWindow |
27 | { | 27 | { |
28 | Q_OBJECT | 28 | Q_OBJECT |
29 | 29 | ||
30 | public: | 30 | public: |
31 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); | 31 | MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); |
32 | virtual ~MainWindow(); | 32 | virtual ~MainWindow(); |
33 | 33 | ||
34 | public slots: | 34 | public slots: |
35 | virtual void slotAdjustColumns(); | 35 | virtual void slotAdjustColumns(); |
36 | virtual void appMessage(const QCString &msg, const QByteArray &data); | 36 | virtual void appMessage(const QCString &msg, const QByteArray &data); |
37 | virtual void slotComposeMail(); | 37 | virtual void slotComposeMail(); |
38 | 38 | ||
39 | protected slots: | 39 | protected slots: |
40 | virtual void slotSendQueued(); | 40 | virtual void slotSendQueued(); |
41 | virtual void slotEditAccounts(); | 41 | virtual void slotEditAccounts(); |
42 | virtual void slotShowFolders( bool show ); | 42 | virtual void slotShowFolders( bool show ); |
43 | virtual void refreshMailView(const QValueList<RecMailP>&); | 43 | virtual void refreshMailView(const QValueList<RecMailP>&); |
44 | virtual void displayMail(); | 44 | virtual void displayMail(); |
45 | virtual void slotGetMail() = 0; | 45 | virtual void slotGetMail() = 0; |
46 | virtual void slotGetAllMail() = 0; | 46 | virtual void slotGetAllMail() = 0; |
47 | virtual void slotDeleteMail(); | 47 | virtual void slotDeleteMail(); |
48 | virtual void slotDeleteAllMail() = 0; | ||
48 | virtual void slotSetCodec(int); | 49 | virtual void slotSetCodec(int); |
49 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); | 50 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); |
50 | virtual void slotAdjustLayout(); | 51 | virtual void slotAdjustLayout(); |
51 | virtual void slotEditSettings(); | 52 | virtual void slotEditSettings(); |
52 | virtual void mailLeftClicked( QListViewItem * ); | 53 | virtual void mailLeftClicked( QListViewItem * ); |
53 | void showLicence(); | 54 | void showLicence(); |
54 | void showAbout(); | 55 | void showAbout(); |
55 | void showEtpanLicence(); | 56 | void showEtpanLicence(); |
56 | 57 | ||
57 | protected: | 58 | protected: |
58 | QToolBar *toolBar; | 59 | QToolBar *toolBar; |
59 | StatusWidget *statusWidget; | 60 | StatusWidget *statusWidget; |
60 | QPEMenuBar *menuBar; | 61 | QPEMenuBar *menuBar; |
61 | QPopupMenu *mailMenu, *settingsMenu, *codecMenu; | 62 | QPopupMenu *mailMenu, *settingsMenu, *codecMenu; |
62 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, | 63 | QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, |
63 | *editSettings, *editAccounts, *syncFolders; | 64 | *editSettings, *editAccounts, *syncFolders; |
64 | AccountView *folderView; | 65 | AccountView *folderView; |
65 | QListView *mailView; | 66 | QListView *mailView; |
66 | //QBoxLayout *layout; | 67 | //QBoxLayout *layout; |
67 | }; | 68 | }; |
68 | 69 | ||
69 | #endif | 70 | #endif |