Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/genericwrapper.cpp | 13 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 86 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mhwrapper.cpp | 60 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 21 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.h | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.cpp | 47 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/settings.h | 7 |
7 files changed, 144 insertions, 92 deletions
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp index 1caa375..5ec9415 100644 --- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp | |||
@@ -1,17 +1,19 @@ | |||
1 | #include "genericwrapper.h" | 1 | #include "genericwrapper.h" |
2 | #include <libetpan/libetpan.h> | 2 | #include <libetpan/libetpan.h> |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | 4 | ||
5 | #include <opie2/odebug.h> | 5 | #include <opie2/odebug.h> |
6 | #include <qpe/timestring.h> | ||
7 | #include <qdatetime.h> | ||
6 | 8 | ||
7 | using namespace Opie::Core; | 9 | using namespace Opie::Core; |
8 | Genericwrapper::Genericwrapper() | 10 | Genericwrapper::Genericwrapper() |
9 | : AbstractMail() | 11 | : AbstractMail() |
10 | { | 12 | { |
11 | bodyCache.clear(); | 13 | bodyCache.clear(); |
12 | m_storage = 0; | 14 | m_storage = 0; |
13 | m_folder = 0; | 15 | m_folder = 0; |
14 | } | 16 | } |
15 | 17 | ||
16 | Genericwrapper::~Genericwrapper() | 18 | Genericwrapper::~Genericwrapper() |
17 | { | 19 | { |
@@ -234,30 +236,29 @@ RecBodyP Genericwrapper::parseMail( mailmessage * msg ) | |||
234 | /* is bound to msg and will be freed there */ | 236 | /* is bound to msg and will be freed there */ |
235 | mailmime * mime=0; | 237 | mailmime * mime=0; |
236 | RecBodyP body = new RecBody(); | 238 | RecBodyP body = new RecBody(); |
237 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 239 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
238 | err = mailmessage_get_bodystructure(msg,&mime); | 240 | err = mailmessage_get_bodystructure(msg,&mime); |
239 | QValueList<int>recList; | 241 | QValueList<int>recList; |
240 | traverseBody(body,msg,mime,recList); | 242 | traverseBody(body,msg,mime,recList); |
241 | return body; | 243 | return body; |
242 | } | 244 | } |
243 | 245 | ||
244 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) | 246 | QString Genericwrapper::parseDateTime( mailimf_date_time *date ) |
245 | { | 247 | { |
246 | char tmp[23]; | 248 | QDateTime da(QDate(date->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec)); |
247 | 249 | QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" "; | |
248 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 250 | timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" "; |
249 | date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 251 | timestring.sprintf(timestring+" %+05i",date->dt_zone); |
250 | 252 | return timestring; | |
251 | return QString( tmp ); | ||
252 | } | 253 | } |
253 | 254 | ||
254 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) | 255 | QString Genericwrapper::parseAddressList( mailimf_address_list *list ) |
255 | { | 256 | { |
256 | QString result( "" ); | 257 | QString result( "" ); |
257 | 258 | ||
258 | bool first = true; | 259 | bool first = true; |
259 | if (list == 0) return result; | 260 | if (list == 0) return result; |
260 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 261 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
261 | mailimf_address *addr = (mailimf_address *) current->data; | 262 | mailimf_address *addr = (mailimf_address *) current->data; |
262 | 263 | ||
263 | if ( !first ) { | 264 | if ( !first ) { |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 9b7c0e0..fe75a15 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -22,69 +22,69 @@ IMAPwrapper::~IMAPwrapper() | |||
22 | logout(); | 22 | logout(); |
23 | } | 23 | } |
24 | 24 | ||
25 | /* to avoid to often select statements in loops etc. | 25 | /* to avoid to often select statements in loops etc. |
26 | we trust that we are logged in and connection is established!*/ | 26 | we trust that we are logged in and connection is established!*/ |
27 | int IMAPwrapper::selectMbox(const QString&mbox) | 27 | int IMAPwrapper::selectMbox(const QString&mbox) |
28 | { | 28 | { |
29 | if (mbox == m_Lastmbox) { | 29 | if (mbox == m_Lastmbox) { |
30 | return MAILIMAP_NO_ERROR; | 30 | return MAILIMAP_NO_ERROR; |
31 | } | 31 | } |
32 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 32 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
33 | if ( err != MAILIMAP_NO_ERROR ) { | 33 | if ( err != MAILIMAP_NO_ERROR ) { |
34 | odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl; | 34 | odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl; |
35 | m_Lastmbox = ""; | 35 | m_Lastmbox = ""; |
36 | return err; | 36 | return err; |
37 | } | 37 | } |
38 | m_Lastmbox = mbox; | 38 | m_Lastmbox = mbox; |
39 | return err; | 39 | return err; |
40 | } | 40 | } |
41 | 41 | ||
42 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 42 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
43 | { | 43 | { |
44 | qApp->processEvents(); | 44 | qApp->processEvents(); |
45 | odebug << "IMAP: " << current << " of " << maximum << "" << oendl; | 45 | odebug << "IMAP: " << current << " of " << maximum << "" << oendl; |
46 | } | 46 | } |
47 | 47 | ||
48 | bool IMAPwrapper::start_tls(bool force_tls) | 48 | bool IMAPwrapper::start_tls(bool force_tls) |
49 | { | 49 | { |
50 | int err; | 50 | int err; |
51 | bool try_tls; | 51 | bool try_tls; |
52 | mailimap_capability_data * cap_data = 0; | 52 | mailimap_capability_data * cap_data = 0; |
53 | 53 | ||
54 | err = mailimap_capability(m_imap,&cap_data); | 54 | err = mailimap_capability(m_imap,&cap_data); |
55 | if (err != MAILIMAP_NO_ERROR) { | 55 | if (err != MAILIMAP_NO_ERROR) { |
56 | Global::statusMessage("error getting capabilities!"); | 56 | Global::statusMessage("error getting capabilities!"); |
57 | odebug << "error getting capabilities!" << oendl; | 57 | odebug << "error getting capabilities!" << oendl; |
58 | return false; | 58 | return false; |
59 | } | 59 | } |
60 | clistiter * cur; | 60 | clistiter * cur; |
61 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 61 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
62 | struct mailimap_capability * cap; | 62 | struct mailimap_capability * cap; |
63 | cap = (struct mailimap_capability *)clist_content(cur); | 63 | cap = (struct mailimap_capability *)clist_content(cur); |
64 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 64 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
65 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 65 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
66 | try_tls = true; | 66 | try_tls = true; |
67 | break; | 67 | break; |
68 | } | 68 | } |
69 | } | 69 | } |
70 | } | 70 | } |
71 | if (cap_data) { | 71 | if (cap_data) { |
72 | mailimap_capability_data_free(cap_data); | 72 | mailimap_capability_data_free(cap_data); |
73 | } | 73 | } |
74 | if (try_tls) { | 74 | if (try_tls) { |
75 | err = mailimap_starttls(m_imap); | 75 | err = mailimap_starttls(m_imap); |
76 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 76 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
77 | Global::statusMessage(tr("Server has no TLS support!")); | 77 | Global::statusMessage(tr("Server has no TLS support!")); |
78 | odebug << "Server has no TLS support!" << oendl; | 78 | odebug << "Server has no TLS support!" << oendl; |
79 | try_tls = false; | 79 | try_tls = false; |
80 | } else { | 80 | } else { |
81 | mailstream_low * low; | 81 | mailstream_low * low; |
82 | mailstream_low * new_low; | 82 | mailstream_low * new_low; |
83 | low = mailstream_get_low(m_imap->imap_stream); | 83 | low = mailstream_get_low(m_imap->imap_stream); |
84 | if (!low) { | 84 | if (!low) { |
85 | try_tls = false; | 85 | try_tls = false; |
86 | } else { | 86 | } else { |
87 | int fd = mailstream_low_get_fd(low); | 87 | int fd = mailstream_low_get_fd(low); |
88 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 88 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
89 | mailstream_low_free(low); | 89 | mailstream_low_free(low); |
90 | mailstream_set_low(m_imap->imap_stream, new_low); | 90 | mailstream_set_low(m_imap->imap_stream, new_low); |
@@ -117,48 +117,48 @@ void IMAPwrapper::login() | |||
117 | } | 117 | } |
118 | server = account->getServer().latin1(); | 118 | server = account->getServer().latin1(); |
119 | port = account->getPort().toUInt(); | 119 | port = account->getPort().toUInt(); |
120 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 120 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
121 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 121 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
122 | login.show(); | 122 | login.show(); |
123 | if ( QDialog::Accepted == login.exec() ) { | 123 | if ( QDialog::Accepted == login.exec() ) { |
124 | // ok | 124 | // ok |
125 | user = login.getUser().latin1(); | 125 | user = login.getUser().latin1(); |
126 | pass = login.getPassword().latin1(); | 126 | pass = login.getPassword().latin1(); |
127 | } else { | 127 | } else { |
128 | // cancel | 128 | // cancel |
129 | odebug << "IMAP: Login canceled" << oendl; | 129 | odebug << "IMAP: Login canceled" << oendl; |
130 | return; | 130 | return; |
131 | } | 131 | } |
132 | } else { | 132 | } else { |
133 | user = account->getUser().latin1(); | 133 | user = account->getUser().latin1(); |
134 | pass = account->getPassword().latin1(); | 134 | pass = account->getPassword().latin1(); |
135 | } | 135 | } |
136 | 136 | ||
137 | m_imap = mailimap_new( 20, &imap_progress ); | 137 | m_imap = mailimap_new( 20, &imap_progress ); |
138 | 138 | ||
139 | /* connect */ | 139 | /* connect */ |
140 | bool ssl = false; | 140 | bool ssl = false; |
141 | bool try_tls = false; | 141 | bool try_tls = false; |
142 | bool force_tls = false; | 142 | bool force_tls = false; |
143 | 143 | ||
144 | if ( account->ConnectionType() == 2 ) { | 144 | if ( account->ConnectionType() == 2 ) { |
145 | ssl = true; | 145 | ssl = true; |
146 | } | 146 | } |
147 | if (account->ConnectionType()==1) { | 147 | if (account->ConnectionType()==1) { |
148 | force_tls = true; | 148 | force_tls = true; |
149 | } | 149 | } |
150 | 150 | ||
151 | if ( ssl ) { | 151 | if ( ssl ) { |
152 | odebug << "using ssl" << oendl; | 152 | odebug << "using ssl" << oendl; |
153 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); | 153 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); |
154 | } else { | 154 | } else { |
155 | err = mailimap_socket_connect( m_imap, (char*)server, port ); | 155 | err = mailimap_socket_connect( m_imap, (char*)server, port ); |
156 | } | 156 | } |
157 | 157 | ||
158 | if ( err != MAILIMAP_NO_ERROR && | 158 | if ( err != MAILIMAP_NO_ERROR && |
159 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 159 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
160 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 160 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
161 | QString failure = ""; | 161 | QString failure = ""; |
162 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 162 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
163 | failure="Connection refused"; | 163 | failure="Connection refused"; |
164 | } else { | 164 | } else { |
@@ -168,25 +168,25 @@ void IMAPwrapper::login() | |||
168 | mailimap_free( m_imap ); | 168 | mailimap_free( m_imap ); |
169 | m_imap = 0; | 169 | m_imap = 0; |
170 | return; | 170 | return; |
171 | } | 171 | } |
172 | 172 | ||
173 | if (!ssl) { | 173 | if (!ssl) { |
174 | try_tls = start_tls(force_tls); | 174 | try_tls = start_tls(force_tls); |
175 | } | 175 | } |
176 | 176 | ||
177 | bool ok = true; | 177 | bool ok = true; |
178 | if (force_tls && !try_tls) { | 178 | if (force_tls && !try_tls) { |
179 | Global::statusMessage(tr("Server has no TLS support!")); | 179 | Global::statusMessage(tr("Server has no TLS support!")); |
180 | odebug << "Server has no TLS support!" << oendl; | 180 | odebug << "Server has no TLS support!" << oendl; |
181 | ok = false; | 181 | ok = false; |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | /* login */ | 185 | /* login */ |
186 | 186 | ||
187 | if (ok) { | 187 | if (ok) { |
188 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 188 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
189 | if ( err != MAILIMAP_NO_ERROR ) { | 189 | if ( err != MAILIMAP_NO_ERROR ) { |
190 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); | 190 | Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); |
191 | ok = false; | 191 | ok = false; |
192 | } | 192 | } |
@@ -228,30 +228,34 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma | |||
228 | } | 228 | } |
229 | 229 | ||
230 | int last = m_imap->imap_selection_info->sel_exists; | 230 | int last = m_imap->imap_selection_info->sel_exists; |
231 | 231 | ||
232 | if (last == 0) { | 232 | if (last == 0) { |
233 | Global::statusMessage(tr("Mailbox has no mails")); | 233 | Global::statusMessage(tr("Mailbox has no mails")); |
234 | return; | 234 | return; |
235 | } else { | 235 | } else { |
236 | } | 236 | } |
237 | 237 | ||
238 | /* the range has to start at 1!!! not with 0!!!! */ | 238 | /* the range has to start at 1!!! not with 0!!!! */ |
239 | set = mailimap_set_new_interval( 1, last ); | 239 | set = mailimap_set_new_interval( 1, last ); |
240 | |||
241 | |||
242 | fetchType = mailimap_fetch_type_new_all(); | ||
243 | /* | ||
240 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 244 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
241 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 245 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
242 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 246 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
243 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 247 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
244 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 248 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
245 | 249 | */ | |
246 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 250 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
247 | mailimap_set_free( set ); | 251 | mailimap_set_free( set ); |
248 | mailimap_fetch_type_free( fetchType ); | 252 | mailimap_fetch_type_free( fetchType ); |
249 | 253 | ||
250 | QString date,subject,from; | 254 | QString date,subject,from; |
251 | 255 | ||
252 | if ( err == MAILIMAP_NO_ERROR ) { | 256 | if ( err == MAILIMAP_NO_ERROR ) { |
253 | mailimap_msg_att * msg_att; | 257 | mailimap_msg_att * msg_att; |
254 | int i = 0; | 258 | int i = 0; |
255 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 259 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
256 | ++i; | 260 | ++i; |
257 | msg_att = (mailimap_msg_att*)current->data; | 261 | msg_att = (mailimap_msg_att*)current->data; |
@@ -309,35 +313,35 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | |||
309 | if ( (bflags = list->mb_flag) ) { | 313 | if ( (bflags = list->mb_flag) ) { |
310 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 314 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
311 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 315 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
312 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 316 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
313 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 317 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
314 | no_inferiors = true; | 318 | no_inferiors = true; |
315 | } | 319 | } |
316 | } | 320 | } |
317 | } | 321 | } |
318 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 322 | folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
319 | } | 323 | } |
320 | } else { | 324 | } else { |
321 | odebug << "error fetching folders: " << m_imap->imap_response << "" << oendl; | 325 | odebug << "error fetching folders: " << m_imap->imap_response << "" << oendl; |
322 | } | 326 | } |
323 | mailimap_list_result_free( result ); | 327 | mailimap_list_result_free( result ); |
324 | 328 | ||
325 | /* | 329 | /* |
326 | * second stage - get the other then inbox folders | 330 | * second stage - get the other then inbox folders |
327 | */ | 331 | */ |
328 | mask = "*" ; | 332 | mask = "*" ; |
329 | path = account->getPrefix().latin1(); | 333 | path = account->getPrefix().latin1(); |
330 | if (!path) path = ""; | 334 | if (!path) path = ""; |
331 | odebug << path << oendl; | 335 | odebug << path << oendl; |
332 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 336 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
333 | if ( err == MAILIMAP_NO_ERROR ) { | 337 | if ( err == MAILIMAP_NO_ERROR ) { |
334 | current = result->first; | 338 | current = result->first; |
335 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { | 339 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
336 | no_inferiors = false; | 340 | no_inferiors = false; |
337 | list = (mailimap_mailbox_list *) current->data; | 341 | list = (mailimap_mailbox_list *) current->data; |
338 | // it is better use the deep copy mechanism of qt itself | 342 | // it is better use the deep copy mechanism of qt itself |
339 | // instead of using strdup! | 343 | // instead of using strdup! |
340 | temp = list->mb_name; | 344 | temp = list->mb_name; |
341 | if (temp.lower()=="inbox") | 345 | if (temp.lower()=="inbox") |
342 | continue; | 346 | continue; |
343 | if (temp.lower()==account->getPrefix().lower()) | 347 | if (temp.lower()==account->getPrefix().lower()) |
@@ -346,48 +350,48 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() | |||
346 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | 350 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& |
347 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | 351 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); |
348 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { | 352 | for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { |
349 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { | 353 | if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { |
350 | no_inferiors = true; | 354 | no_inferiors = true; |
351 | } | 355 | } |
352 | } | 356 | } |
353 | } | 357 | } |
354 | del = list->mb_delimiter; | 358 | del = list->mb_delimiter; |
355 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); | 359 | folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); |
356 | } | 360 | } |
357 | } else { | 361 | } else { |
358 | odebug << "error fetching folders " << m_imap->imap_response << "" << oendl; | 362 | odebug << "error fetching folders " << m_imap->imap_response << "" << oendl; |
359 | } | 363 | } |
360 | if (result) mailimap_list_result_free( result ); | 364 | if (result) mailimap_list_result_free( result ); |
361 | return folders; | 365 | return folders; |
362 | } | 366 | } |
363 | 367 | ||
364 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 368 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
365 | { | 369 | { |
366 | RecMail * m = 0; | 370 | RecMail * m = 0; |
367 | mailimap_msg_att_item *item=0; | 371 | mailimap_msg_att_item *item=0; |
368 | clistcell *current,*c,*cf; | 372 | clistcell *current,*c,*cf; |
369 | mailimap_msg_att_dynamic*flist; | 373 | mailimap_msg_att_dynamic*flist; |
370 | mailimap_flag_fetch*cflag; | 374 | mailimap_flag_fetch*cflag; |
371 | int size; | 375 | int size; |
372 | QBitArray mFlags(7); | 376 | QBitArray mFlags(7); |
373 | QStringList addresslist; | 377 | QStringList addresslist; |
374 | 378 | ||
375 | if (!m_att) { | 379 | if (!m_att) { |
376 | return m; | 380 | return m; |
377 | } | 381 | } |
382 | size = 0; | ||
378 | m = new RecMail(); | 383 | m = new RecMail(); |
379 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 384 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
380 | current = c; | 385 | current = c; |
381 | size = 0; | ||
382 | item = (mailimap_msg_att_item*)current->data; | 386 | item = (mailimap_msg_att_item*)current->data; |
383 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 387 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
384 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 388 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
385 | if (!flist->att_list) { | 389 | if (!flist->att_list) { |
386 | continue; | 390 | continue; |
387 | } | 391 | } |
388 | cf = flist->att_list->first; | 392 | cf = flist->att_list->first; |
389 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 393 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
390 | cflag = (mailimap_flag_fetch*)cf->data; | 394 | cflag = (mailimap_flag_fetch*)cf->data; |
391 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 395 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
392 | switch (cflag->fl_flag->fl_type) { | 396 | switch (cflag->fl_flag->fl_type) { |
393 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 397 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
@@ -456,41 +460,47 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
456 | while (h.length()>0 && h[h.length()-1]=='>') { | 460 | while (h.length()>0 && h[h.length()-1]=='>') { |
457 | h.remove(h.length()-1,1); | 461 | h.remove(h.length()-1,1); |
458 | } | 462 | } |
459 | if (h.length()>0) { | 463 | if (h.length()>0) { |
460 | m->setInreply(QStringList(h)); | 464 | m->setInreply(QStringList(h)); |
461 | } | 465 | } |
462 | } | 466 | } |
463 | if (head->env_message_id) { | 467 | if (head->env_message_id) { |
464 | m->setMsgid(QString(head->env_message_id)); | 468 | m->setMsgid(QString(head->env_message_id)); |
465 | } | 469 | } |
466 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 470 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
467 | #if 0 | 471 | #if 0 |
468 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 472 | mailimap_date_time*date = item->att_data.att_static->att_data.att_internal_date; |
473 | if (date->dt_sec>60 || date->dt_sec<0) date->dt_sec=0; | ||
474 | //QDateTime da(QDate(d->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec)); | ||
475 | QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" "; | ||
476 | timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" "; | ||
477 | timestring.sprintf(timestring+" %+05i",date->dt_zone); | ||
478 | m->setDate(timestring); | ||
469 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 479 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
470 | odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl; | 480 | odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl; |
471 | odebug << da.toString() << oendl; | 481 | odebug << da.toString() << oendl; |
472 | #endif | 482 | #endif |
473 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 483 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
474 | size = item->att_data.att_static->att_data.att_rfc822_size; | 484 | //size = item->att_data.att_static->att_data.att_rfc822_size; |
485 | m->setMsgsize(item->att_data.att_static->att_data.att_rfc822_size); | ||
475 | } | 486 | } |
476 | } | 487 | } |
477 | /* msg is already deleted */ | 488 | /* msg is already deleted */ |
478 | if (mFlags.testBit(FLAG_DELETED) && m) { | 489 | if (mFlags.testBit(FLAG_DELETED) && m) { |
479 | delete m; | 490 | delete m; |
480 | m = 0; | 491 | m = 0; |
481 | } | 492 | } |
482 | if (m) { | 493 | if (m) { |
483 | m->setFlags(mFlags); | 494 | m->setFlags(mFlags); |
484 | m->setMsgsize(size); | ||
485 | } | 495 | } |
486 | return m; | 496 | return m; |
487 | } | 497 | } |
488 | 498 | ||
489 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | 499 | RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) |
490 | { | 500 | { |
491 | RecBodyP body = new RecBody(); | 501 | RecBodyP body = new RecBody(); |
492 | const char *mb; | 502 | const char *mb; |
493 | int err = MAILIMAP_NO_ERROR; | 503 | int err = MAILIMAP_NO_ERROR; |
494 | clist *result = 0; | 504 | clist *result = 0; |
495 | clistcell *current; | 505 | clistcell *current; |
496 | mailimap_fetch_att *fetchAtt = 0; | 506 | mailimap_fetch_att *fetchAtt = 0; |
@@ -516,25 +526,25 @@ RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) | |||
516 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 526 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
517 | mailimap_set_free( set ); | 527 | mailimap_set_free( set ); |
518 | mailimap_fetch_type_free( fetchType ); | 528 | mailimap_fetch_type_free( fetchType ); |
519 | 529 | ||
520 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 530 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
521 | mailimap_msg_att * msg_att; | 531 | mailimap_msg_att * msg_att; |
522 | msg_att = (mailimap_msg_att*)current->data; | 532 | msg_att = (mailimap_msg_att*)current->data; |
523 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 533 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
524 | QValueList<int> path; | 534 | QValueList<int> path; |
525 | body_desc = item->att_data.att_static->att_data.att_body; | 535 | body_desc = item->att_data.att_static->att_data.att_body; |
526 | traverseBody(mail,body_desc,body,0,path); | 536 | traverseBody(mail,body_desc,body,0,path); |
527 | } else { | 537 | } else { |
528 | odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; | 538 | odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; |
529 | } | 539 | } |
530 | if (result) mailimap_fetch_list_free(result); | 540 | if (result) mailimap_fetch_list_free(result); |
531 | return body; | 541 | return body; |
532 | } | 542 | } |
533 | 543 | ||
534 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 544 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
535 | { | 545 | { |
536 | QStringList l; | 546 | QStringList l; |
537 | QString from; | 547 | QString from; |
538 | bool named_from; | 548 | bool named_from; |
539 | clistcell *current = NULL; | 549 | clistcell *current = NULL; |
540 | mailimap_address * current_address=NULL; | 550 | mailimap_address * current_address=NULL; |
@@ -628,25 +638,25 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int | |||
628 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 638 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
629 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 639 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
630 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 640 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
631 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 641 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
632 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 642 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
633 | /* detach - we take over the content */ | 643 | /* detach - we take over the content */ |
634 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 644 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
635 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); | 645 | res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); |
636 | } | 646 | } |
637 | } | 647 | } |
638 | } | 648 | } |
639 | } else { | 649 | } else { |
640 | odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; | 650 | odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; |
641 | } | 651 | } |
642 | if (result) mailimap_fetch_list_free(result); | 652 | if (result) mailimap_fetch_list_free(result); |
643 | return res; | 653 | return res; |
644 | } | 654 | } |
645 | 655 | ||
646 | /* current_recursion is for recursive calls. | 656 | /* current_recursion is for recursive calls. |
647 | current_count means the position inside the internal loop! */ | 657 | current_count means the position inside the internal loop! */ |
648 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, | 658 | void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, |
649 | int current_recursion,QValueList<int>recList,int current_count) | 659 | int current_recursion,QValueList<int>recList,int current_count) |
650 | { | 660 | { |
651 | if (!body || current_recursion>=10) { | 661 | if (!body || current_recursion>=10) { |
652 | return; | 662 | return; |
@@ -655,25 +665,25 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t | |||
655 | case MAILIMAP_BODY_1PART: | 665 | case MAILIMAP_BODY_1PART: |
656 | { | 666 | { |
657 | QValueList<int>countlist = recList; | 667 | QValueList<int>countlist = recList; |
658 | countlist.append(current_count); | 668 | countlist.append(current_count); |
659 | RecPartP currentPart = new RecPart(); | 669 | RecPartP currentPart = new RecPart(); |
660 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; | 670 | mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; |
661 | QString id(""); | 671 | QString id(""); |
662 | currentPart->setPositionlist(countlist); | 672 | currentPart->setPositionlist(countlist); |
663 | for (unsigned int j = 0; j < countlist.count();++j) { | 673 | for (unsigned int j = 0; j < countlist.count();++j) { |
664 | id+=(j>0?" ":""); | 674 | id+=(j>0?" ":""); |
665 | id+=QString("%1").arg(countlist[j]); | 675 | id+=QString("%1").arg(countlist[j]); |
666 | } | 676 | } |
667 | odebug << "ID = " << id.latin1() << "" << oendl; | 677 | odebug << "ID = " << id.latin1() << "" << oendl; |
668 | currentPart->setIdentifier(id); | 678 | currentPart->setIdentifier(id); |
669 | fillSinglePart(currentPart,part1); | 679 | fillSinglePart(currentPart,part1); |
670 | /* important: Check for is NULL 'cause a body can be empty! | 680 | /* important: Check for is NULL 'cause a body can be empty! |
671 | And we put it only into the mail if it is the FIRST part */ | 681 | And we put it only into the mail if it is the FIRST part */ |
672 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { | 682 | if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { |
673 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); | 683 | QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); |
674 | target_body->setDescription(currentPart); | 684 | target_body->setDescription(currentPart); |
675 | target_body->setBodytext(body_text); | 685 | target_body->setBodytext(body_text); |
676 | if (countlist.count()>1) { | 686 | if (countlist.count()>1) { |
677 | target_body->addPart(currentPart); | 687 | target_body->addPart(currentPart); |
678 | } | 688 | } |
679 | } else { | 689 | } else { |
@@ -696,25 +706,25 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t | |||
696 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 706 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
697 | RecPartP targetPart = new RecPart(); | 707 | RecPartP targetPart = new RecPart(); |
698 | targetPart->setType("multipart"); | 708 | targetPart->setType("multipart"); |
699 | fillMultiPart(targetPart,mailDescription); | 709 | fillMultiPart(targetPart,mailDescription); |
700 | countlist.append(current_count); | 710 | countlist.append(current_count); |
701 | targetPart->setPositionlist(countlist); | 711 | targetPart->setPositionlist(countlist); |
702 | target_body->addPart(targetPart); | 712 | target_body->addPart(targetPart); |
703 | QString id(""); | 713 | QString id(""); |
704 | for (unsigned int j = 0; j < countlist.count();++j) { | 714 | for (unsigned int j = 0; j < countlist.count();++j) { |
705 | id+=(j>0?" ":""); | 715 | id+=(j>0?" ":""); |
706 | id+=QString("%1").arg(countlist[j]); | 716 | id+=QString("%1").arg(countlist[j]); |
707 | } | 717 | } |
708 | odebug << "ID(mpart) = " << id.latin1() << "" << oendl; | 718 | odebug << "ID(mpart) = " << id.latin1() << "" << oendl; |
709 | } | 719 | } |
710 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); | 720 | traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); |
711 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 721 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
712 | countlist = recList; | 722 | countlist = recList; |
713 | } | 723 | } |
714 | ++ccount; | 724 | ++ccount; |
715 | } | 725 | } |
716 | } | 726 | } |
717 | break; | 727 | break; |
718 | default: | 728 | default: |
719 | break; | 729 | break; |
720 | } | 730 | } |
@@ -740,37 +750,37 @@ void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*D | |||
740 | default: | 750 | default: |
741 | break; | 751 | break; |
742 | } | 752 | } |
743 | } | 753 | } |
744 | 754 | ||
745 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) | 755 | void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_text*which) |
746 | { | 756 | { |
747 | if (!which) { | 757 | if (!which) { |
748 | return; | 758 | return; |
749 | } | 759 | } |
750 | QString sub; | 760 | QString sub; |
751 | sub = which->bd_media_text; | 761 | sub = which->bd_media_text; |
752 | odebug << "Type= text/" << which->bd_media_text << "" << oendl; | 762 | odebug << "Type= text/" << which->bd_media_text << "" << oendl; |
753 | target_part->setSubtype(sub.lower()); | 763 | target_part->setSubtype(sub.lower()); |
754 | target_part->setLines(which->bd_lines); | 764 | target_part->setLines(which->bd_lines); |
755 | fillBodyFields(target_part,which->bd_fields); | 765 | fillBodyFields(target_part,which->bd_fields); |
756 | } | 766 | } |
757 | 767 | ||
758 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) | 768 | void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*which) |
759 | { | 769 | { |
760 | if (!which) { | 770 | if (!which) { |
761 | return; | 771 | return; |
762 | } | 772 | } |
763 | target_part->setSubtype("rfc822"); | 773 | target_part->setSubtype("rfc822"); |
764 | odebug << "Message part" << oendl; | 774 | odebug << "Message part" << oendl; |
765 | /* we set this type to text/plain */ | 775 | /* we set this type to text/plain */ |
766 | target_part->setLines(which->bd_lines); | 776 | target_part->setLines(which->bd_lines); |
767 | fillBodyFields(target_part,which->bd_fields); | 777 | fillBodyFields(target_part,which->bd_fields); |
768 | } | 778 | } |
769 | 779 | ||
770 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) | 780 | void IMAPwrapper::fillMultiPart(RecPartP&target_part,mailimap_body_type_mpart*which) |
771 | { | 781 | { |
772 | if (!which) return; | 782 | if (!which) return; |
773 | QString sub = which->bd_media_subtype; | 783 | QString sub = which->bd_media_subtype; |
774 | target_part->setSubtype(sub.lower()); | 784 | target_part->setSubtype(sub.lower()); |
775 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { | 785 | if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) { |
776 | clistcell*cur = 0; | 786 | clistcell*cur = 0; |
@@ -811,25 +821,25 @@ void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_ba | |||
811 | if (which->bd_media_basic->med_basic_type) { | 821 | if (which->bd_media_basic->med_basic_type) { |
812 | type = which->bd_media_basic->med_basic_type; | 822 | type = which->bd_media_basic->med_basic_type; |
813 | } else { | 823 | } else { |
814 | type = ""; | 824 | type = ""; |
815 | } | 825 | } |
816 | break; | 826 | break; |
817 | } | 827 | } |
818 | if (which->bd_media_basic->med_subtype) { | 828 | if (which->bd_media_basic->med_subtype) { |
819 | sub = which->bd_media_basic->med_subtype; | 829 | sub = which->bd_media_basic->med_subtype; |
820 | } else { | 830 | } else { |
821 | sub = ""; | 831 | sub = ""; |
822 | } | 832 | } |
823 | odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; | 833 | odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl; |
824 | target_part->setType(type.lower()); | 834 | target_part->setType(type.lower()); |
825 | target_part->setSubtype(sub.lower()); | 835 | target_part->setSubtype(sub.lower()); |
826 | fillBodyFields(target_part,which->bd_fields); | 836 | fillBodyFields(target_part,which->bd_fields); |
827 | } | 837 | } |
828 | 838 | ||
829 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) | 839 | void IMAPwrapper::fillBodyFields(RecPartP&target_part,mailimap_body_fields*which) |
830 | { | 840 | { |
831 | if (!which) return; | 841 | if (!which) return; |
832 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { | 842 | if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { |
833 | clistcell*cur; | 843 | clistcell*cur; |
834 | mailimap_single_body_fld_param*param=0; | 844 | mailimap_single_body_fld_param*param=0; |
835 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 845 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
@@ -887,34 +897,34 @@ void IMAPwrapper::deleteMail(const RecMailP&mail) | |||
887 | if ( err != MAILIMAP_NO_ERROR ) { | 897 | if ( err != MAILIMAP_NO_ERROR ) { |
888 | return; | 898 | return; |
889 | } | 899 | } |
890 | flist = mailimap_flag_list_new_empty(); | 900 | flist = mailimap_flag_list_new_empty(); |
891 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 901 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
892 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 902 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
893 | set = mailimap_set_new_single(mail->getNumber()); | 903 | set = mailimap_set_new_single(mail->getNumber()); |
894 | err = mailimap_store(m_imap,set,store_flags); | 904 | err = mailimap_store(m_imap,set,store_flags); |
895 | mailimap_set_free( set ); | 905 | mailimap_set_free( set ); |
896 | mailimap_store_att_flags_free(store_flags); | 906 | mailimap_store_att_flags_free(store_flags); |
897 | 907 | ||
898 | if (err != MAILIMAP_NO_ERROR) { | 908 | if (err != MAILIMAP_NO_ERROR) { |
899 | odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 909 | odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
900 | return; | 910 | return; |
901 | } | 911 | } |
902 | odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 912 | odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
903 | /* should we realy do that at this moment? */ | 913 | /* should we realy do that at this moment? */ |
904 | err = mailimap_expunge(m_imap); | 914 | err = mailimap_expunge(m_imap); |
905 | if (err != MAILIMAP_NO_ERROR) { | 915 | if (err != MAILIMAP_NO_ERROR) { |
906 | odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; | 916 | odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl; |
907 | } | 917 | } |
908 | odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; | 918 | odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; |
909 | } | 919 | } |
910 | 920 | ||
911 | void IMAPwrapper::answeredMail(const RecMailP&mail) | 921 | void IMAPwrapper::answeredMail(const RecMailP&mail) |
912 | { | 922 | { |
913 | mailimap_flag_list*flist; | 923 | mailimap_flag_list*flist; |
914 | mailimap_set *set; | 924 | mailimap_set *set; |
915 | mailimap_store_att_flags * store_flags; | 925 | mailimap_store_att_flags * store_flags; |
916 | int err; | 926 | int err; |
917 | login(); | 927 | login(); |
918 | if (!m_imap) { | 928 | if (!m_imap) { |
919 | return; | 929 | return; |
920 | } | 930 | } |
@@ -922,25 +932,25 @@ void IMAPwrapper::answeredMail(const RecMailP&mail) | |||
922 | if ( err != MAILIMAP_NO_ERROR ) { | 932 | if ( err != MAILIMAP_NO_ERROR ) { |
923 | return; | 933 | return; |
924 | } | 934 | } |
925 | flist = mailimap_flag_list_new_empty(); | 935 | flist = mailimap_flag_list_new_empty(); |
926 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); | 936 | mailimap_flag_list_add(flist,mailimap_flag_new_answered()); |
927 | store_flags = mailimap_store_att_flags_new_add_flags(flist); | 937 | store_flags = mailimap_store_att_flags_new_add_flags(flist); |
928 | set = mailimap_set_new_single(mail->getNumber()); | 938 | set = mailimap_set_new_single(mail->getNumber()); |
929 | err = mailimap_store(m_imap,set,store_flags); | 939 | err = mailimap_store(m_imap,set,store_flags); |
930 | mailimap_set_free( set ); | 940 | mailimap_set_free( set ); |
931 | mailimap_store_att_flags_free(store_flags); | 941 | mailimap_store_att_flags_free(store_flags); |
932 | 942 | ||
933 | if (err != MAILIMAP_NO_ERROR) { | 943 | if (err != MAILIMAP_NO_ERROR) { |
934 | odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; | 944 | odebug << "error marking mail: " << m_imap->imap_response << "" << oendl; |
935 | return; | 945 | return; |
936 | } | 946 | } |
937 | } | 947 | } |
938 | 948 | ||
939 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) | 949 | QString IMAPwrapper::fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call,const QString&enc) |
940 | { | 950 | { |
941 | QString body(""); | 951 | QString body(""); |
942 | encodedString*res = fetchRawPart(mail,path,internal_call); | 952 | encodedString*res = fetchRawPart(mail,path,internal_call); |
943 | encodedString*r = decode_String(res,enc); | 953 | encodedString*r = decode_String(res,enc); |
944 | delete res; | 954 | delete res; |
945 | if (r) { | 955 | if (r) { |
946 | if (r->Length()>0) { | 956 | if (r->Length()>0) { |
@@ -990,57 +1000,57 @@ int IMAPwrapper::deleteAllMail(const FolderP&folder) | |||
990 | } | 1000 | } |
991 | flist = mailimap_flag_list_new_empty(); | 1001 | flist = mailimap_flag_list_new_empty(); |
992 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); | 1002 | mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); |
993 | store_flags = mailimap_store_att_flags_new_set_flags(flist); | 1003 | store_flags = mailimap_store_att_flags_new_set_flags(flist); |
994 | set = mailimap_set_new_interval( 1, last ); | 1004 | set = mailimap_set_new_interval( 1, last ); |
995 | err = mailimap_store(m_imap,set,store_flags); | 1005 | err = mailimap_store(m_imap,set,store_flags); |
996 | mailimap_set_free( set ); | 1006 | mailimap_set_free( set ); |
997 | mailimap_store_att_flags_free(store_flags); | 1007 | mailimap_store_att_flags_free(store_flags); |
998 | if (err != MAILIMAP_NO_ERROR) { | 1008 | if (err != MAILIMAP_NO_ERROR) { |
999 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 1009 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
1000 | return 0; | 1010 | return 0; |
1001 | } | 1011 | } |
1002 | odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; | 1012 | odebug << "deleting mail: " << m_imap->imap_response << "" << oendl; |
1003 | /* should we realy do that at this moment? */ | 1013 | /* should we realy do that at this moment? */ |
1004 | err = mailimap_expunge(m_imap); | 1014 | err = mailimap_expunge(m_imap); |
1005 | if (err != MAILIMAP_NO_ERROR) { | 1015 | if (err != MAILIMAP_NO_ERROR) { |
1006 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); | 1016 | Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response)); |
1007 | return 0; | 1017 | return 0; |
1008 | } | 1018 | } |
1009 | odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; | 1019 | odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; |
1010 | return 1; | 1020 | return 1; |
1011 | } | 1021 | } |
1012 | 1022 | ||
1013 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) | 1023 | int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) |
1014 | { | 1024 | { |
1015 | if (folder.length()==0) return 0; | 1025 | if (folder.length()==0) return 0; |
1016 | login(); | 1026 | login(); |
1017 | if (!m_imap) {return 0;} | 1027 | if (!m_imap) {return 0;} |
1018 | QString pre = account->getPrefix(); | 1028 | QString pre = account->getPrefix(); |
1019 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { | 1029 | if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { |
1020 | pre+=delemiter; | 1030 | pre+=delemiter; |
1021 | } | 1031 | } |
1022 | if (parentfolder) { | 1032 | if (parentfolder) { |
1023 | pre += parentfolder->getDisplayName()+delemiter; | 1033 | pre += parentfolder->getDisplayName()+delemiter; |
1024 | } | 1034 | } |
1025 | pre+=folder; | 1035 | pre+=folder; |
1026 | if (getsubfolder) { | 1036 | if (getsubfolder) { |
1027 | if (delemiter.length()>0) { | 1037 | if (delemiter.length()>0) { |
1028 | pre+=delemiter; | 1038 | pre+=delemiter; |
1029 | } else { | 1039 | } else { |
1030 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); | 1040 | Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre)); |
1031 | return 0; | 1041 | return 0; |
1032 | } | 1042 | } |
1033 | } | 1043 | } |
1034 | odebug << "Creating " << pre.latin1() << "" << oendl; | 1044 | odebug << "Creating " << pre.latin1() << "" << oendl; |
1035 | int res = mailimap_create(m_imap,pre.latin1()); | 1045 | int res = mailimap_create(m_imap,pre.latin1()); |
1036 | if (res != MAILIMAP_NO_ERROR) { | 1046 | if (res != MAILIMAP_NO_ERROR) { |
1037 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); | 1047 | Global::statusMessage(tr("%1").arg(m_imap->imap_response)); |
1038 | return 0; | 1048 | return 0; |
1039 | } | 1049 | } |
1040 | return 1; | 1050 | return 1; |
1041 | } | 1051 | } |
1042 | 1052 | ||
1043 | int IMAPwrapper::deleteMbox(const FolderP&folder) | 1053 | int IMAPwrapper::deleteMbox(const FolderP&folder) |
1044 | { | 1054 | { |
1045 | if (!folder) return 0; | 1055 | if (!folder) return 0; |
1046 | login(); | 1056 | login(); |
@@ -1081,108 +1091,108 @@ void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) | |||
1081 | case MAILIMAP_STATUS_ATT_MESSAGES: | 1091 | case MAILIMAP_STATUS_ATT_MESSAGES: |
1082 | target_stat.message_count = status_info->st_value; | 1092 | target_stat.message_count = status_info->st_value; |
1083 | break; | 1093 | break; |
1084 | case MAILIMAP_STATUS_ATT_RECENT: | 1094 | case MAILIMAP_STATUS_ATT_RECENT: |
1085 | target_stat.message_recent = status_info->st_value; | 1095 | target_stat.message_recent = status_info->st_value; |
1086 | break; | 1096 | break; |
1087 | case MAILIMAP_STATUS_ATT_UNSEEN: | 1097 | case MAILIMAP_STATUS_ATT_UNSEEN: |
1088 | target_stat.message_unseen = status_info->st_value; | 1098 | target_stat.message_unseen = status_info->st_value; |
1089 | break; | 1099 | break; |
1090 | } | 1100 | } |
1091 | } | 1101 | } |
1092 | } else { | 1102 | } else { |
1093 | odebug << "Error retrieving status" << oendl; | 1103 | odebug << "Error retrieving status" << oendl; |
1094 | } | 1104 | } |
1095 | if (status) mailimap_mailbox_data_status_free(status); | 1105 | if (status) mailimap_mailbox_data_status_free(status); |
1096 | if (att_list) mailimap_status_att_list_free(att_list); | 1106 | if (att_list) mailimap_status_att_list_free(att_list); |
1097 | } | 1107 | } |
1098 | 1108 | ||
1099 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) | 1109 | void IMAPwrapper::storeMessage(const char*msg,size_t length, const QString&folder) |
1100 | { | 1110 | { |
1101 | login(); | 1111 | login(); |
1102 | if (!m_imap) return; | 1112 | if (!m_imap) return; |
1103 | if (!msg) return; | 1113 | if (!msg) return; |
1104 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); | 1114 | int r = mailimap_append(m_imap,(char*)folder.latin1(),0,0,msg,length); |
1105 | if (r != MAILIMAP_NO_ERROR) { | 1115 | if (r != MAILIMAP_NO_ERROR) { |
1106 | Global::statusMessage("Error storing mail!"); | 1116 | Global::statusMessage("Error storing mail!"); |
1107 | } | 1117 | } |
1108 | } | 1118 | } |
1109 | 1119 | ||
1110 | MAILLIB::ATYPE IMAPwrapper::getType()const | 1120 | MAILLIB::ATYPE IMAPwrapper::getType()const |
1111 | { | 1121 | { |
1112 | return account->getType(); | 1122 | return account->getType(); |
1113 | } | 1123 | } |
1114 | 1124 | ||
1115 | const QString&IMAPwrapper::getName()const | 1125 | const QString&IMAPwrapper::getName()const |
1116 | { | 1126 | { |
1117 | odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; | 1127 | odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl; |
1118 | return account->getAccountName(); | 1128 | return account->getAccountName(); |
1119 | } | 1129 | } |
1120 | 1130 | ||
1121 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) | 1131 | encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail) |
1122 | { | 1132 | { |
1123 | // dummy | 1133 | // dummy |
1124 | QValueList<int> path; | 1134 | QValueList<int> path; |
1125 | return fetchRawPart(mail,path,false); | 1135 | return fetchRawPart(mail,path,false); |
1126 | } | 1136 | } |
1127 | 1137 | ||
1128 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, | 1138 | void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder, |
1129 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1139 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1130 | { | 1140 | { |
1131 | if (targetWrapper != this) { | 1141 | if (targetWrapper != this) { |
1132 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 1142 | AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
1133 | odebug << "Using generic" << oendl; | 1143 | odebug << "Using generic" << oendl; |
1134 | return; | 1144 | return; |
1135 | } | 1145 | } |
1136 | mailimap_set *set = 0; | 1146 | mailimap_set *set = 0; |
1137 | login(); | 1147 | login(); |
1138 | if (!m_imap) { | 1148 | if (!m_imap) { |
1139 | return; | 1149 | return; |
1140 | } | 1150 | } |
1141 | int err = selectMbox(fromFolder->getName()); | 1151 | int err = selectMbox(fromFolder->getName()); |
1142 | if ( err != MAILIMAP_NO_ERROR ) { | 1152 | if ( err != MAILIMAP_NO_ERROR ) { |
1143 | return; | 1153 | return; |
1144 | } | 1154 | } |
1145 | int last = m_imap->imap_selection_info->sel_exists; | 1155 | int last = m_imap->imap_selection_info->sel_exists; |
1146 | set = mailimap_set_new_interval( 1, last ); | 1156 | set = mailimap_set_new_interval( 1, last ); |
1147 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1157 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1148 | mailimap_set_free( set ); | 1158 | mailimap_set_free( set ); |
1149 | if ( err != MAILIMAP_NO_ERROR ) { | 1159 | if ( err != MAILIMAP_NO_ERROR ) { |
1150 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); | 1160 | QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response); |
1151 | Global::statusMessage(error_msg); | 1161 | Global::statusMessage(error_msg); |
1152 | odebug << error_msg << oendl; | 1162 | odebug << error_msg << oendl; |
1153 | return; | 1163 | return; |
1154 | } | 1164 | } |
1155 | if (moveit) { | 1165 | if (moveit) { |
1156 | deleteAllMail(fromFolder); | 1166 | deleteAllMail(fromFolder); |
1157 | } | 1167 | } |
1158 | } | 1168 | } |
1159 | 1169 | ||
1160 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 1170 | void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
1161 | { | 1171 | { |
1162 | if (targetWrapper != this) { | 1172 | if (targetWrapper != this) { |
1163 | odebug << "Using generic" << oendl; | 1173 | odebug << "Using generic" << oendl; |
1164 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 1174 | AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
1165 | return; | 1175 | return; |
1166 | } | 1176 | } |
1167 | mailimap_set *set = 0; | 1177 | mailimap_set *set = 0; |
1168 | login(); | 1178 | login(); |
1169 | if (!m_imap) { | 1179 | if (!m_imap) { |
1170 | return; | 1180 | return; |
1171 | } | 1181 | } |
1172 | int err = selectMbox(mail->getMbox()); | 1182 | int err = selectMbox(mail->getMbox()); |
1173 | if ( err != MAILIMAP_NO_ERROR ) { | 1183 | if ( err != MAILIMAP_NO_ERROR ) { |
1174 | return; | 1184 | return; |
1175 | } | 1185 | } |
1176 | set = mailimap_set_new_single(mail->getNumber()); | 1186 | set = mailimap_set_new_single(mail->getNumber()); |
1177 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); | 1187 | err = mailimap_copy(m_imap,set,targetFolder.latin1()); |
1178 | mailimap_set_free( set ); | 1188 | mailimap_set_free( set ); |
1179 | if ( err != MAILIMAP_NO_ERROR ) { | 1189 | if ( err != MAILIMAP_NO_ERROR ) { |
1180 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); | 1190 | QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response); |
1181 | Global::statusMessage(error_msg); | 1191 | Global::statusMessage(error_msg); |
1182 | odebug << error_msg << oendl; | 1192 | odebug << error_msg << oendl; |
1183 | return; | 1193 | return; |
1184 | } | 1194 | } |
1185 | if (moveit) { | 1195 | if (moveit) { |
1186 | deleteMail(mail); | 1196 | deleteMail(mail); |
1187 | } | 1197 | } |
1188 | } | 1198 | } |
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index 403afcf..765a21c 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp | |||
@@ -8,50 +8,50 @@ | |||
8 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | #include <opie2/oprocess.h> | 9 | #include <opie2/oprocess.h> |
10 | #include <opie2/odebug.h> | 10 | #include <opie2/odebug.h> |
11 | 11 | ||
12 | using namespace Opie::Core; | 12 | using namespace Opie::Core; |
13 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) | 13 | MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) |
14 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) | 14 | : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) |
15 | { | 15 | { |
16 | if (MHPath.length()>0) { | 16 | if (MHPath.length()>0) { |
17 | if (MHPath[MHPath.length()-1]=='/') { | 17 | if (MHPath[MHPath.length()-1]=='/') { |
18 | MHPath=MHPath.left(MHPath.length()-1); | 18 | MHPath=MHPath.left(MHPath.length()-1); |
19 | } | 19 | } |
20 | odebug << MHPath << oendl; | 20 | odebug << MHPath << oendl; |
21 | QDir dir(MHPath); | 21 | QDir dir(MHPath); |
22 | if (!dir.exists()) { | 22 | if (!dir.exists()) { |
23 | dir.mkdir(MHPath); | 23 | dir.mkdir(MHPath); |
24 | } | 24 | } |
25 | init_storage(); | 25 | init_storage(); |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | void MHwrapper::init_storage() | 29 | void MHwrapper::init_storage() |
30 | { | 30 | { |
31 | int r; | 31 | int r; |
32 | QString pre = MHPath; | 32 | QString pre = MHPath; |
33 | if (!m_storage) { | 33 | if (!m_storage) { |
34 | m_storage = mailstorage_new(NULL); | 34 | m_storage = mailstorage_new(NULL); |
35 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); | 35 | r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); |
36 | if (r != MAIL_NO_ERROR) { | 36 | if (r != MAIL_NO_ERROR) { |
37 | odebug << "error initializing storage" << oendl; | 37 | odebug << "error initializing storage" << oendl; |
38 | mailstorage_free(m_storage); | 38 | mailstorage_free(m_storage); |
39 | m_storage = 0; | 39 | m_storage = 0; |
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | } | 42 | } |
43 | r = mailstorage_connect(m_storage); | 43 | r = mailstorage_connect(m_storage); |
44 | if (r!=MAIL_NO_ERROR) { | 44 | if (r!=MAIL_NO_ERROR) { |
45 | odebug << "error connecting storage" << oendl; | 45 | odebug << "error connecting storage" << oendl; |
46 | mailstorage_free(m_storage); | 46 | mailstorage_free(m_storage); |
47 | m_storage = 0; | 47 | m_storage = 0; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | void MHwrapper::clean_storage() | 51 | void MHwrapper::clean_storage() |
52 | { | 52 | { |
53 | if (m_storage) { | 53 | if (m_storage) { |
54 | mailstorage_disconnect(m_storage); | 54 | mailstorage_disconnect(m_storage); |
55 | mailstorage_free(m_storage); | 55 | mailstorage_free(m_storage); |
56 | m_storage = 0; | 56 | m_storage = 0; |
57 | } | 57 | } |
@@ -62,105 +62,105 @@ MHwrapper::~MHwrapper() | |||
62 | clean_storage(); | 62 | clean_storage(); |
63 | } | 63 | } |
64 | 64 | ||
65 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) | 65 | void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
66 | { | 66 | { |
67 | init_storage(); | 67 | init_storage(); |
68 | if (!m_storage) { | 68 | if (!m_storage) { |
69 | return; | 69 | return; |
70 | } | 70 | } |
71 | QString f = buildPath(mailbox); | 71 | QString f = buildPath(mailbox); |
72 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 72 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
73 | if (r!=MAIL_NO_ERROR) { | 73 | if (r!=MAIL_NO_ERROR) { |
74 | odebug << "listMessages: error selecting folder!" << oendl; | 74 | odebug << "listMessages: error selecting folder!" << oendl; |
75 | return; | 75 | return; |
76 | } | 76 | } |
77 | parseList(target,m_storage->sto_session,f); | 77 | parseList(target,m_storage->sto_session,f); |
78 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); | 78 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
79 | } | 79 | } |
80 | 80 | ||
81 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() | 81 | QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() |
82 | { | 82 | { |
83 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 83 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
84 | /* this is needed! */ | 84 | /* this is needed! */ |
85 | if (m_storage) mailstorage_disconnect(m_storage); | 85 | if (m_storage) mailstorage_disconnect(m_storage); |
86 | init_storage(); | 86 | init_storage(); |
87 | if (!m_storage) { | 87 | if (!m_storage) { |
88 | return folders; | 88 | return folders; |
89 | } | 89 | } |
90 | mail_list*flist = 0; | 90 | mail_list*flist = 0; |
91 | clistcell*current=0; | 91 | clistcell*current=0; |
92 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); | 92 | int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); |
93 | if (r != MAIL_NO_ERROR || !flist) { | 93 | if (r != MAIL_NO_ERROR || !flist) { |
94 | odebug << "error getting folder list" << oendl; | 94 | odebug << "error getting folder list" << oendl; |
95 | return folders; | 95 | return folders; |
96 | } | 96 | } |
97 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { | 97 | for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { |
98 | QString t = (char*)current->data; | 98 | QString t = (char*)current->data; |
99 | t.replace(0,MHPath.length(),""); | 99 | t.replace(0,MHPath.length(),""); |
100 | folders->append(new MHFolder(t,MHPath)); | 100 | folders->append(new MHFolder(t,MHPath)); |
101 | } | 101 | } |
102 | mail_list_free(flist); | 102 | mail_list_free(flist); |
103 | return folders; | 103 | return folders; |
104 | } | 104 | } |
105 | 105 | ||
106 | void MHwrapper::deleteMail(const RecMailP&mail) | 106 | void MHwrapper::deleteMail(const RecMailP&mail) |
107 | { | 107 | { |
108 | init_storage(); | 108 | init_storage(); |
109 | if (!m_storage) { | 109 | if (!m_storage) { |
110 | return; | 110 | return; |
111 | } | 111 | } |
112 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 112 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
113 | if (r!=MAIL_NO_ERROR) { | 113 | if (r!=MAIL_NO_ERROR) { |
114 | odebug << "error selecting folder!" << oendl; | 114 | odebug << "error selecting folder!" << oendl; |
115 | return; | 115 | return; |
116 | } | 116 | } |
117 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); | 117 | r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); |
118 | if (r != MAIL_NO_ERROR) { | 118 | if (r != MAIL_NO_ERROR) { |
119 | odebug << "error deleting mail" << oendl; | 119 | odebug << "error deleting mail" << oendl; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | void MHwrapper::answeredMail(const RecMailP&) | 123 | void MHwrapper::answeredMail(const RecMailP&) |
124 | { | 124 | { |
125 | } | 125 | } |
126 | 126 | ||
127 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) | 127 | RecBodyP MHwrapper::fetchBody( const RecMailP &mail ) |
128 | { | 128 | { |
129 | RecBodyP body = new RecBody(); | 129 | RecBodyP body = new RecBody(); |
130 | init_storage(); | 130 | init_storage(); |
131 | if (!m_storage) { | 131 | if (!m_storage) { |
132 | return body; | 132 | return body; |
133 | } | 133 | } |
134 | mailmessage * msg; | 134 | mailmessage * msg; |
135 | char*data=0; | 135 | char*data=0; |
136 | 136 | ||
137 | /* mail should hold the complete path! */ | 137 | /* mail should hold the complete path! */ |
138 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 138 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
139 | if (r != MAIL_NO_ERROR) { | 139 | if (r != MAIL_NO_ERROR) { |
140 | return body; | 140 | return body; |
141 | } | 141 | } |
142 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 142 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
143 | if (r != MAIL_NO_ERROR) { | 143 | if (r != MAIL_NO_ERROR) { |
144 | odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; | 144 | odebug << "Error fetching mail " << mail->getNumber() << "" << oendl; |
145 | return body; | 145 | return body; |
146 | } | 146 | } |
147 | body = parseMail(msg); | 147 | body = parseMail(msg); |
148 | mailmessage_fetch_result_free(msg,data); | 148 | mailmessage_fetch_result_free(msg,data); |
149 | return body; | 149 | return body; |
150 | } | 150 | } |
151 | 151 | ||
152 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) | 152 | void MHwrapper::mbox_progress( size_t current, size_t maximum ) |
153 | { | 153 | { |
154 | odebug << "MH " << current << " von " << maximum << "" << oendl; | 154 | odebug << "MH " << current << " von " << maximum << "" << oendl; |
155 | } | 155 | } |
156 | 156 | ||
157 | QString MHwrapper::buildPath(const QString&p) | 157 | QString MHwrapper::buildPath(const QString&p) |
158 | { | 158 | { |
159 | QString f=""; | 159 | QString f=""; |
160 | if (p.length()==0||p=="/") | 160 | if (p.length()==0||p=="/") |
161 | return MHPath; | 161 | return MHPath; |
162 | if (!p.startsWith(MHPath)) { | 162 | if (!p.startsWith(MHPath)) { |
163 | f+=MHPath; | 163 | f+=MHPath; |
164 | } | 164 | } |
165 | if (!p.startsWith("/")) { | 165 | if (!p.startsWith("/")) { |
166 | f+="/"; | 166 | f+="/"; |
@@ -175,119 +175,119 @@ int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QStri | |||
175 | if (!m_storage) { | 175 | if (!m_storage) { |
176 | return 0; | 176 | return 0; |
177 | } | 177 | } |
178 | QString f; | 178 | QString f; |
179 | if (!pfolder) { | 179 | if (!pfolder) { |
180 | // toplevel folder | 180 | // toplevel folder |
181 | f = buildPath(folder); | 181 | f = buildPath(folder); |
182 | } else { | 182 | } else { |
183 | f = pfolder->getName(); | 183 | f = pfolder->getName(); |
184 | f+="/"; | 184 | f+="/"; |
185 | f+=folder; | 185 | f+=folder; |
186 | } | 186 | } |
187 | odebug << f << oendl; | 187 | odebug << f << oendl; |
188 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); | 188 | int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); |
189 | if (r != MAIL_NO_ERROR) { | 189 | if (r != MAIL_NO_ERROR) { |
190 | odebug << "error creating folder " << r << "" << oendl; | 190 | odebug << "error creating folder " << r << "" << oendl; |
191 | return 0; | 191 | return 0; |
192 | } | 192 | } |
193 | odebug << "Folder created" << oendl; | 193 | odebug << "Folder created" << oendl; |
194 | return 1; | 194 | return 1; |
195 | } | 195 | } |
196 | 196 | ||
197 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) | 197 | void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) |
198 | { | 198 | { |
199 | init_storage(); | 199 | init_storage(); |
200 | if (!m_storage) { | 200 | if (!m_storage) { |
201 | return; | 201 | return; |
202 | } | 202 | } |
203 | QString f = buildPath(Folder); | 203 | QString f = buildPath(Folder); |
204 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 204 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
205 | if (r!=MAIL_NO_ERROR) { | 205 | if (r!=MAIL_NO_ERROR) { |
206 | odebug << "error selecting folder!" << oendl; | 206 | odebug << "error selecting folder!" << oendl; |
207 | return; | 207 | return; |
208 | } | 208 | } |
209 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); | 209 | r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); |
210 | if (r!=MAIL_NO_ERROR) { | 210 | if (r!=MAIL_NO_ERROR) { |
211 | odebug << "error storing mail" << oendl; | 211 | odebug << "error storing mail" << oendl; |
212 | } | 212 | } |
213 | return; | 213 | return; |
214 | } | 214 | } |
215 | 215 | ||
216 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) | 216 | encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) |
217 | { | 217 | { |
218 | encodedString*result = 0; | 218 | encodedString*result = 0; |
219 | init_storage(); | 219 | init_storage(); |
220 | if (!m_storage) { | 220 | if (!m_storage) { |
221 | return result; | 221 | return result; |
222 | } | 222 | } |
223 | mailmessage * msg = 0; | 223 | mailmessage * msg = 0; |
224 | char*data=0; | 224 | char*data=0; |
225 | size_t size; | 225 | size_t size; |
226 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 226 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
227 | if (r!=MAIL_NO_ERROR) { | 227 | if (r!=MAIL_NO_ERROR) { |
228 | odebug << "error selecting folder!" << oendl; | 228 | odebug << "error selecting folder!" << oendl; |
229 | return result; | 229 | return result; |
230 | } | 230 | } |
231 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); | 231 | r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); |
232 | if (r != MAIL_NO_ERROR) { | 232 | if (r != MAIL_NO_ERROR) { |
233 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); | 233 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
234 | return 0; | 234 | return 0; |
235 | } | 235 | } |
236 | r = mailmessage_fetch(msg,&data,&size); | 236 | r = mailmessage_fetch(msg,&data,&size); |
237 | if (r != MAIL_NO_ERROR) { | 237 | if (r != MAIL_NO_ERROR) { |
238 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); | 238 | Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); |
239 | if (msg) mailmessage_free(msg); | 239 | if (msg) mailmessage_free(msg); |
240 | return 0; | 240 | return 0; |
241 | } | 241 | } |
242 | result = new encodedString(data,size); | 242 | result = new encodedString(data,size); |
243 | if (msg) mailmessage_free(msg); | 243 | if (msg) mailmessage_free(msg); |
244 | return result; | 244 | return result; |
245 | } | 245 | } |
246 | 246 | ||
247 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) | 247 | void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) |
248 | { | 248 | { |
249 | QString f = buildPath(mailbox); | 249 | QString f = buildPath(mailbox); |
250 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); | 250 | int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); |
251 | if (r!=MAIL_NO_ERROR) { | 251 | if (r!=MAIL_NO_ERROR) { |
252 | odebug << "deleteMails: error selecting folder!" << oendl; | 252 | odebug << "deleteMails: error selecting folder!" << oendl; |
253 | return; | 253 | return; |
254 | } | 254 | } |
255 | QValueList<RecMailP>::ConstIterator it; | 255 | QValueList<RecMailP>::ConstIterator it; |
256 | for (it=target.begin(); it!=target.end();++it) { | 256 | for (it=target.begin(); it!=target.end();++it) { |
257 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); | 257 | r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); |
258 | if (r != MAIL_NO_ERROR) { | 258 | if (r != MAIL_NO_ERROR) { |
259 | odebug << "error deleting mail" << oendl; | 259 | odebug << "error deleting mail" << oendl; |
260 | break; | 260 | break; |
261 | } | 261 | } |
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
265 | int MHwrapper::deleteAllMail(const FolderP&tfolder) | 265 | int MHwrapper::deleteAllMail(const FolderP&tfolder) |
266 | { | 266 | { |
267 | init_storage(); | 267 | init_storage(); |
268 | if (!m_storage) { | 268 | if (!m_storage) { |
269 | return 0; | 269 | return 0; |
270 | } | 270 | } |
271 | int res = 1; | 271 | int res = 1; |
272 | if (!tfolder) return 0; | 272 | if (!tfolder) return 0; |
273 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 273 | int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
274 | if (r!=MAIL_NO_ERROR) { | 274 | if (r!=MAIL_NO_ERROR) { |
275 | odebug << "error selecting folder!" << oendl; | 275 | odebug << "error selecting folder!" << oendl; |
276 | return 0; | 276 | return 0; |
277 | } | 277 | } |
278 | mailmessage_list*l=0; | 278 | mailmessage_list*l=0; |
279 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 279 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
280 | if (r != MAIL_NO_ERROR) { | 280 | if (r != MAIL_NO_ERROR) { |
281 | odebug << "Error message list" << oendl; | 281 | odebug << "Error message list" << oendl; |
282 | res = 0; | 282 | res = 0; |
283 | } | 283 | } |
284 | unsigned j = 0; | 284 | unsigned j = 0; |
285 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { | 285 | for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { |
286 | mailmessage * msg; | 286 | mailmessage * msg; |
287 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 287 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
288 | j = msg->msg_index; | 288 | j = msg->msg_index; |
289 | r = mailsession_remove_message(m_storage->sto_session,j); | 289 | r = mailsession_remove_message(m_storage->sto_session,j); |
290 | if (r != MAIL_NO_ERROR) { | 290 | if (r != MAIL_NO_ERROR) { |
291 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 291 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
292 | res = 0; | 292 | res = 0; |
293 | break; | 293 | break; |
@@ -300,46 +300,46 @@ int MHwrapper::deleteAllMail(const FolderP&tfolder) | |||
300 | int MHwrapper::deleteMbox(const FolderP&tfolder) | 300 | int MHwrapper::deleteMbox(const FolderP&tfolder) |
301 | { | 301 | { |
302 | init_storage(); | 302 | init_storage(); |
303 | if (!m_storage) { | 303 | if (!m_storage) { |
304 | return 0; | 304 | return 0; |
305 | } | 305 | } |
306 | if (!tfolder) return 0; | 306 | if (!tfolder) return 0; |
307 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; | 307 | if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; |
308 | 308 | ||
309 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); | 309 | int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); |
310 | 310 | ||
311 | if (r != MAIL_NO_ERROR) { | 311 | if (r != MAIL_NO_ERROR) { |
312 | odebug << "error deleting mail box" << oendl; | 312 | odebug << "error deleting mail box" << oendl; |
313 | return 0; | 313 | return 0; |
314 | } | 314 | } |
315 | QString cmd = "rm -rf "+tfolder->getName(); | 315 | QString cmd = "rm -rf "+tfolder->getName(); |
316 | QStringList command; | 316 | QStringList command; |
317 | command << "/bin/sh"; | 317 | command << "/bin/sh"; |
318 | command << "-c"; | 318 | command << "-c"; |
319 | command << cmd.latin1(); | 319 | command << cmd.latin1(); |
320 | OProcess *process = new OProcess(); | 320 | OProcess *process = new OProcess(); |
321 | 321 | ||
322 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), | 322 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), |
323 | this, SLOT( processEnded(Opie::Core::OProcess*))); | 323 | this, SLOT( processEnded(Opie::Core::OProcess*))); |
324 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), | 324 | connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), |
325 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); | 325 | this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); |
326 | 326 | ||
327 | *process << command; | 327 | *process << command; |
328 | removeMboxfailed = false; | 328 | removeMboxfailed = false; |
329 | if(!process->start(OProcess::Block, OProcess::All) ) { | 329 | if(!process->start(OProcess::Block, OProcess::All) ) { |
330 | odebug << "could not start process" << oendl; | 330 | odebug << "could not start process" << oendl; |
331 | return 0; | 331 | return 0; |
332 | } | 332 | } |
333 | odebug << "mail box deleted" << oendl; | 333 | odebug << "mail box deleted" << oendl; |
334 | return 1; | 334 | return 1; |
335 | } | 335 | } |
336 | 336 | ||
337 | void MHwrapper::processEnded(OProcess *p) | 337 | void MHwrapper::processEnded(OProcess *p) |
338 | { | 338 | { |
339 | if (p) delete p; | 339 | if (p) delete p; |
340 | } | 340 | } |
341 | 341 | ||
342 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) | 342 | void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) |
343 | { | 343 | { |
344 | QString lineStr = buffer; | 344 | QString lineStr = buffer; |
345 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); | 345 | QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); |
@@ -370,74 +370,74 @@ MAILLIB::ATYPE MHwrapper::getType()const | |||
370 | 370 | ||
371 | const QString&MHwrapper::getName()const | 371 | const QString&MHwrapper::getName()const |
372 | { | 372 | { |
373 | return MHName; | 373 | return MHName; |
374 | } | 374 | } |
375 | void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 375 | void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
376 | { | 376 | { |
377 | init_storage(); | 377 | init_storage(); |
378 | if (!m_storage) { | 378 | if (!m_storage) { |
379 | return; | 379 | return; |
380 | } | 380 | } |
381 | if (targetWrapper != this) { | 381 | if (targetWrapper != this) { |
382 | odebug << "Using generic" << oendl; | 382 | odebug << "Using generic" << oendl; |
383 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); | 383 | Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); |
384 | return; | 384 | return; |
385 | } | 385 | } |
386 | odebug << "Using internal routines for move/copy" << oendl; | 386 | odebug << "Using internal routines for move/copy" << oendl; |
387 | QString tf = buildPath(targetFolder); | 387 | QString tf = buildPath(targetFolder); |
388 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); | 388 | int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); |
389 | if (r != MAIL_NO_ERROR) { | 389 | if (r != MAIL_NO_ERROR) { |
390 | odebug << "Error selecting source mailbox" << oendl; | 390 | odebug << "Error selecting source mailbox" << oendl; |
391 | return; | 391 | return; |
392 | } | 392 | } |
393 | if (moveit) { | 393 | if (moveit) { |
394 | r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); | 394 | r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); |
395 | } else { | 395 | } else { |
396 | r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); | 396 | r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); |
397 | } | 397 | } |
398 | if (r != MAIL_NO_ERROR) { | 398 | if (r != MAIL_NO_ERROR) { |
399 | odebug << "Error copy/moving mail internal (" << r << ")" << oendl; | 399 | odebug << "Error copy/moving mail internal (" << r << ")" << oendl; |
400 | } | 400 | } |
401 | } | 401 | } |
402 | 402 | ||
403 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, | 403 | void MHwrapper::mvcpAllMails(const FolderP&fromFolder, |
404 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 404 | const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
405 | { | 405 | { |
406 | init_storage(); | 406 | init_storage(); |
407 | if (!m_storage) { | 407 | if (!m_storage) { |
408 | return; | 408 | return; |
409 | } | 409 | } |
410 | if (targetWrapper != this) { | 410 | if (targetWrapper != this) { |
411 | odebug << "Using generic" << oendl; | 411 | odebug << "Using generic" << oendl; |
412 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); | 412 | Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); |
413 | return; | 413 | return; |
414 | } | 414 | } |
415 | if (!fromFolder) return; | 415 | if (!fromFolder) return; |
416 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); | 416 | int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); |
417 | if (r!=MAIL_NO_ERROR) { | 417 | if (r!=MAIL_NO_ERROR) { |
418 | odebug << "error selecting source folder!" << oendl; | 418 | odebug << "error selecting source folder!" << oendl; |
419 | return; | 419 | return; |
420 | } | 420 | } |
421 | QString tf = buildPath(targetFolder); | 421 | QString tf = buildPath(targetFolder); |
422 | mailmessage_list*l=0; | 422 | mailmessage_list*l=0; |
423 | r = mailsession_get_messages_list(m_storage->sto_session,&l); | 423 | r = mailsession_get_messages_list(m_storage->sto_session,&l); |
424 | if (r != MAIL_NO_ERROR) { | 424 | if (r != MAIL_NO_ERROR) { |
425 | odebug << "Error message list" << oendl; | 425 | odebug << "Error message list" << oendl; |
426 | } | 426 | } |
427 | unsigned j = 0; | 427 | unsigned j = 0; |
428 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { | 428 | for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { |
429 | mailmessage * msg; | 429 | mailmessage * msg; |
430 | msg = (mailmessage*)carray_get(l->msg_tab, i); | 430 | msg = (mailmessage*)carray_get(l->msg_tab, i); |
431 | j = msg->msg_index; | 431 | j = msg->msg_index; |
432 | if (moveit) { | 432 | if (moveit) { |
433 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); | 433 | r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); |
434 | } else { | 434 | } else { |
435 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); | 435 | r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); |
436 | } | 436 | } |
437 | if (r != MAIL_NO_ERROR) { | 437 | if (r != MAIL_NO_ERROR) { |
438 | odebug << "Error copy/moving mail internal (" << r << ")" << oendl; | 438 | odebug << "Error copy/moving mail internal (" << r << ")" << oendl; |
439 | break; | 439 | break; |
440 | } | 440 | } |
441 | } | 441 | } |
442 | if (l) mailmessage_list_free(l); | 442 | if (l) mailmessage_list_free(l); |
443 | } | 443 | } |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 3cfd1ee..2d66fc9 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -1,62 +1,69 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include "pop3wrapper.h" | 2 | #include "pop3wrapper.h" |
3 | #include "mailtypes.h" | 3 | #include "mailtypes.h" |
4 | #include "logindialog.h" | 4 | #include "logindialog.h" |
5 | #include <libetpan/libetpan.h> | 5 | #include <libetpan/libetpan.h> |
6 | 6 | ||
7 | #include <opie2/odebug.h> | 7 | #include <opie2/odebug.h> |
8 | #include <qpe/global.h> | 8 | #include <qpe/global.h> |
9 | #include <qfile.h> | 9 | #include <qfile.h> |
10 | #include <qmessagebox.h> | ||
10 | 11 | ||
11 | /* we don't fetch messages larger than 5 MB */ | 12 | /* we don't fetch messages larger than 5 MB */ |
12 | #define HARD_MSG_SIZE_LIMIT 5242880 | 13 | #define HARD_MSG_SIZE_LIMIT 5242880 |
13 | 14 | ||
14 | using namespace Opie::Core; | 15 | using namespace Opie::Core; |
15 | POP3wrapper::POP3wrapper( POP3account *a ) | 16 | POP3wrapper::POP3wrapper( POP3account *a ) |
16 | : Genericwrapper() { | 17 | : Genericwrapper() { |
17 | account = a; | 18 | account = a; |
18 | m_pop3 = NULL; | 19 | m_pop3 = NULL; |
19 | msgTempName = a->getFileName()+"_msg_cache"; | 20 | msgTempName = a->getFileName()+"_msg_cache"; |
20 | last_msg_id = 0; | 21 | last_msg_id = 0; |
22 | m_maxsize = account->getMaxSize(); | ||
23 | m_checksize = account->getCheckMaxSize(); | ||
21 | } | 24 | } |
22 | 25 | ||
23 | POP3wrapper::~POP3wrapper() { | 26 | POP3wrapper::~POP3wrapper() { |
24 | logout(); | 27 | logout(); |
25 | QFile msg_cache(msgTempName); | 28 | QFile msg_cache(msgTempName); |
26 | if (msg_cache.exists()) { | 29 | if (msg_cache.exists()) { |
27 | msg_cache.remove(); | 30 | msg_cache.remove(); |
28 | } | 31 | } |
29 | } | 32 | } |
30 | 33 | ||
31 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { | 34 | void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { |
32 | odebug << "POP3: " << current << " of " << maximum << "" << oendl; | 35 | odebug << "POP3: " << current << " of " << maximum << "" << oendl; |
33 | } | 36 | } |
34 | 37 | ||
35 | RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { | 38 | RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { |
36 | int err = MAILPOP3_NO_ERROR; | 39 | int err = MAILPOP3_NO_ERROR; |
37 | char *message = 0; | 40 | char *message = 0; |
38 | size_t length = 0; | 41 | size_t length = 0; |
39 | 42 | ||
40 | RecBodyP body = new RecBody(); | 43 | RecBodyP body = new RecBody(); |
41 | 44 | ||
42 | login(); | 45 | login(); |
43 | if ( !m_pop3 ) { | 46 | if ( !m_pop3 ) { |
44 | return body; | 47 | return body; |
45 | } | 48 | } |
46 | 49 | ||
47 | mailmessage * mailmsg; | 50 | mailmessage * mailmsg; |
48 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { | 51 | if (mail->Msgsize()/1024>m_maxsize && m_checksize && mail->getNumber()!=last_msg_id) { |
49 | odebug << "Message to large: " << mail->Msgsize() << "" << oendl; | 52 | QString quest = QString(tr("Download mail?\nIt is %1 kByte but your limit is %2 kByte")).arg(mail->Msgsize()/1024).arg(m_maxsize); |
50 | return body; | 53 | int yesno = QMessageBox::warning(0,tr("Download message"), |
54 | quest,tr("Yes"),tr("No"),QString::null,0,1); | ||
55 | odebug << "Message to large: " << mail->Msgsize() << "" << oendl; | ||
56 | if (yesno==1) | ||
57 | return body; | ||
51 | } | 58 | } |
52 | 59 | ||
53 | QFile msg_cache(msgTempName); | 60 | QFile msg_cache(msgTempName); |
54 | 61 | ||
55 | cleanMimeCache(); | 62 | cleanMimeCache(); |
56 | 63 | ||
57 | if (mail->getNumber()!=last_msg_id) { | 64 | if (mail->getNumber()!=last_msg_id) { |
58 | if (msg_cache.exists()) { | 65 | if (msg_cache.exists()) { |
59 | msg_cache.remove(); | 66 | msg_cache.remove(); |
60 | } | 67 | } |
61 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 68 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
62 | last_msg_id = mail->getNumber(); | 69 | last_msg_id = mail->getNumber(); |
@@ -122,25 +129,25 @@ void POP3wrapper::login() | |||
122 | server = account->getServer().latin1(); | 129 | server = account->getServer().latin1(); |
123 | port = account->getPort().toUInt(); | 130 | port = account->getPort().toUInt(); |
124 | 131 | ||
125 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 132 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
126 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 133 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
127 | login.show(); | 134 | login.show(); |
128 | if ( QDialog::Accepted == login.exec() ) { | 135 | if ( QDialog::Accepted == login.exec() ) { |
129 | // ok | 136 | // ok |
130 | user = login.getUser().latin1(); | 137 | user = login.getUser().latin1(); |
131 | pass = login.getPassword().latin1(); | 138 | pass = login.getPassword().latin1(); |
132 | } else { | 139 | } else { |
133 | // cancel | 140 | // cancel |
134 | odebug << "POP3: Login canceled" << oendl; | 141 | odebug << "POP3: Login canceled" << oendl; |
135 | return; | 142 | return; |
136 | } | 143 | } |
137 | } else { | 144 | } else { |
138 | user = account->getUser().latin1(); | 145 | user = account->getUser().latin1(); |
139 | pass = account->getPassword().latin1(); | 146 | pass = account->getPassword().latin1(); |
140 | } | 147 | } |
141 | 148 | ||
142 | // bool ssl = account->getSSL(); | 149 | // bool ssl = account->getSSL(); |
143 | 150 | ||
144 | m_pop3=mailstorage_new(NULL); | 151 | m_pop3=mailstorage_new(NULL); |
145 | 152 | ||
146 | int conntypeset = account->ConnectionType(); | 153 | int conntypeset = account->ConnectionType(); |
@@ -154,25 +161,25 @@ void POP3wrapper::login() | |||
154 | } else if ( conntypeset == 0 ) { | 161 | } else if ( conntypeset == 0 ) { |
155 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 162 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
156 | } | 163 | } |
157 | 164 | ||
158 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); | 165 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); |
159 | 166 | ||
160 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, | 167 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, |
161 | (char*)user,(char*)pass,0,0,0); | 168 | (char*)user,(char*)pass,0,0,0); |
162 | 169 | ||
163 | 170 | ||
164 | err = mailstorage_connect(m_pop3); | 171 | err = mailstorage_connect(m_pop3); |
165 | if (err != MAIL_NO_ERROR) { | 172 | if (err != MAIL_NO_ERROR) { |
166 | odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; | 173 | odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; |
167 | Global::statusMessage(tr("Error initializing folder")); | 174 | Global::statusMessage(tr("Error initializing folder")); |
168 | mailstorage_free(m_pop3); | 175 | mailstorage_free(m_pop3); |
169 | m_pop3 = 0; | 176 | m_pop3 = 0; |
170 | } else { | 177 | } else { |
171 | mailsession * session = m_pop3->sto_session; | 178 | mailsession * session = m_pop3->sto_session; |
172 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; | 179 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; |
173 | if (mail) { | 180 | if (mail) { |
174 | mail->pop3_progr_fun = &pop3_progress; | 181 | mail->pop3_progr_fun = &pop3_progress; |
175 | } | 182 | } |
176 | } | 183 | } |
177 | } | 184 | } |
178 | 185 | ||
@@ -228,25 +235,25 @@ int POP3wrapper::deleteAllMail(const FolderP&) { | |||
228 | } | 235 | } |
229 | 236 | ||
230 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { | 237 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { |
231 | login(); | 238 | login(); |
232 | target_stat.message_count = 0; | 239 | target_stat.message_count = 0; |
233 | target_stat.message_unseen = 0; | 240 | target_stat.message_unseen = 0; |
234 | target_stat.message_recent = 0; | 241 | target_stat.message_recent = 0; |
235 | if (!m_pop3) | 242 | if (!m_pop3) |
236 | return; | 243 | return; |
237 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, | 244 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, |
238 | &target_stat.message_recent,&target_stat.message_unseen); | 245 | &target_stat.message_recent,&target_stat.message_unseen); |
239 | if (r != MAIL_NO_ERROR) { | 246 | if (r != MAIL_NO_ERROR) { |
240 | odebug << "error getting folter status." << oendl; | 247 | odebug << "error getting folter status." << oendl; |
241 | } | 248 | } |
242 | } | 249 | } |
243 | 250 | ||
244 | encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { | 251 | encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { |
245 | char*target=0; | 252 | char*target=0; |
246 | size_t length=0; | 253 | size_t length=0; |
247 | encodedString*res = 0; | 254 | encodedString*res = 0; |
248 | mailmessage * mailmsg = 0; | 255 | mailmessage * mailmsg = 0; |
249 | int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); | 256 | int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); |
250 | err = mailmessage_fetch(mailmsg,&target,&length); | 257 | err = mailmessage_fetch(mailmsg,&target,&length); |
251 | if (mailmsg) | 258 | if (mailmsg) |
252 | mailmessage_free(mailmsg); | 259 | mailmessage_free(mailmsg); |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h index 5101fa5..8c36cf9 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.h +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h | |||
@@ -28,15 +28,17 @@ public: | |||
28 | 28 | ||
29 | virtual RecBodyP fetchBody( const RecMailP &mail ); | 29 | virtual RecBodyP fetchBody( const RecMailP &mail ); |
30 | virtual encodedString* fetchRawBody(const RecMailP&mail); | 30 | virtual encodedString* fetchRawBody(const RecMailP&mail); |
31 | virtual void logout(); | 31 | virtual void logout(); |
32 | virtual MAILLIB::ATYPE getType()const; | 32 | virtual MAILLIB::ATYPE getType()const; |
33 | virtual const QString&getName()const; | 33 | virtual const QString&getName()const; |
34 | static void pop3_progress( size_t current, size_t maximum ); | 34 | static void pop3_progress( size_t current, size_t maximum ); |
35 | 35 | ||
36 | protected: | 36 | protected: |
37 | void login(); | 37 | void login(); |
38 | POP3account *account; | 38 | POP3account *account; |
39 | mailstorage*m_pop3; | 39 | mailstorage*m_pop3; |
40 | int m_maxsize; | ||
41 | bool m_checksize; | ||
40 | }; | 42 | }; |
41 | 43 | ||
42 | #endif | 44 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp index 3c9b25c..09be91b 100644 --- a/noncore/net/mail/libmailwrapper/settings.cpp +++ b/noncore/net/mail/libmailwrapper/settings.cpp | |||
@@ -7,36 +7,35 @@ | |||
7 | #include "settings.h" | 7 | #include "settings.h" |
8 | //#include "defines.h" | 8 | //#include "defines.h" |
9 | 9 | ||
10 | #define IMAP_PORT "143" | 10 | #define IMAP_PORT "143" |
11 | #define IMAP_SSL_PORT "993" | 11 | #define IMAP_SSL_PORT "993" |
12 | #define SMTP_PORT "25" | 12 | #define SMTP_PORT "25" |
13 | #define SMTP_SSL_PORT "465" | 13 | #define SMTP_SSL_PORT "465" |
14 | #define POP3_PORT "110" | 14 | #define POP3_PORT "110" |
15 | #define POP3_SSL_PORT "995" | 15 | #define POP3_SSL_PORT "995" |
16 | #define NNTP_PORT "119" | 16 | #define NNTP_PORT "119" |
17 | #define NNTP_SSL_PORT "563" | 17 | #define NNTP_SSL_PORT "563" |
18 | 18 | ||
19 | |||
20 | Settings::Settings() | 19 | Settings::Settings() |
21 | : QObject() | 20 | : QObject() |
22 | { | 21 | { |
23 | updateAccounts(); | 22 | updateAccounts(); |
24 | } | 23 | } |
25 | 24 | ||
26 | void Settings::checkDirectory() | 25 | void Settings::checkDirectory() |
27 | { | 26 | { |
28 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { | 27 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { |
29 | system( "mkdir -p $HOME/Applications/opiemail" ); | 28 | system( "mkdir -p $HOME/Applications/opiemail" ); |
30 | odebug << "$HOME/Applications/opiemail created" << oendl; | 29 | odebug << "$HOME/Applications/opiemail created" << oendl; |
31 | } | 30 | } |
32 | } | 31 | } |
33 | 32 | ||
34 | QList<Account> Settings::getAccounts() | 33 | QList<Account> Settings::getAccounts() |
35 | { | 34 | { |
36 | return accounts; | 35 | return accounts; |
37 | } | 36 | } |
38 | 37 | ||
39 | void Settings::addAccount( Account *account ) | 38 | void Settings::addAccount( Account *account ) |
40 | { | 39 | { |
41 | accounts.append( account ); | 40 | accounts.append( account ); |
42 | } | 41 | } |
@@ -46,46 +45,46 @@ void Settings::delAccount( Account *account ) | |||
46 | accounts.remove( account ); | 45 | accounts.remove( account ); |
47 | account->remove(); | 46 | account->remove(); |
48 | } | 47 | } |
49 | 48 | ||
50 | void Settings::updateAccounts() | 49 | void Settings::updateAccounts() |
51 | { | 50 | { |
52 | accounts.clear(); | 51 | accounts.clear(); |
53 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 52 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
54 | QStringList::Iterator it; | 53 | QStringList::Iterator it; |
55 | 54 | ||
56 | QStringList imap = dir.entryList( "imap-*" ); | 55 | QStringList imap = dir.entryList( "imap-*" ); |
57 | for ( it = imap.begin(); it != imap.end(); it++ ) { | 56 | for ( it = imap.begin(); it != imap.end(); it++ ) { |
58 | odebug << "Added IMAP account" << oendl; | 57 | odebug << "Added IMAP account" << oendl; |
59 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); | 58 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); |
60 | accounts.append( account ); | 59 | accounts.append( account ); |
61 | } | 60 | } |
62 | 61 | ||
63 | QStringList pop3 = dir.entryList( "pop3-*" ); | 62 | QStringList pop3 = dir.entryList( "pop3-*" ); |
64 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { | 63 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { |
65 | odebug << "Added POP account" << oendl; | 64 | odebug << "Added POP account" << oendl; |
66 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); | 65 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); |
67 | accounts.append( account ); | 66 | accounts.append( account ); |
68 | } | 67 | } |
69 | 68 | ||
70 | QStringList smtp = dir.entryList( "smtp-*" ); | 69 | QStringList smtp = dir.entryList( "smtp-*" ); |
71 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { | 70 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { |
72 | odebug << "Added SMTP account" << oendl; | 71 | odebug << "Added SMTP account" << oendl; |
73 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); | 72 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); |
74 | accounts.append( account ); | 73 | accounts.append( account ); |
75 | } | 74 | } |
76 | 75 | ||
77 | QStringList nntp = dir.entryList( "nntp-*" ); | 76 | QStringList nntp = dir.entryList( "nntp-*" ); |
78 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { | 77 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { |
79 | odebug << "Added NNTP account" << oendl; | 78 | odebug << "Added NNTP account" << oendl; |
80 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); | 79 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); |
81 | accounts.append( account ); | 80 | accounts.append( account ); |
82 | } | 81 | } |
83 | 82 | ||
84 | readAccounts(); | 83 | readAccounts(); |
85 | } | 84 | } |
86 | 85 | ||
87 | void Settings::saveAccounts() | 86 | void Settings::saveAccounts() |
88 | { | 87 | { |
89 | checkDirectory(); | 88 | checkDirectory(); |
90 | Account *it; | 89 | Account *it; |
91 | 90 | ||
@@ -171,25 +170,25 @@ void IMAPaccount::read() | |||
171 | user = conf->readEntry( "User","" ); | 170 | user = conf->readEntry( "User","" ); |
172 | if (user.isNull()) user = ""; | 171 | if (user.isNull()) user = ""; |
173 | password = conf->readEntryCrypt( "Password","" ); | 172 | password = conf->readEntryCrypt( "Password","" ); |
174 | if (password.isNull()) password = ""; | 173 | if (password.isNull()) password = ""; |
175 | prefix = conf->readEntry("MailPrefix",""); | 174 | prefix = conf->readEntry("MailPrefix",""); |
176 | if (prefix.isNull()) prefix = ""; | 175 | if (prefix.isNull()) prefix = ""; |
177 | offline = conf->readBoolEntry("Offline",false); | 176 | offline = conf->readBoolEntry("Offline",false); |
178 | delete conf; | 177 | delete conf; |
179 | } | 178 | } |
180 | 179 | ||
181 | void IMAPaccount::save() | 180 | void IMAPaccount::save() |
182 | { | 181 | { |
183 | odebug << "saving " + getFileName() << oendl; | 182 | odebug << "saving " + getFileName() << oendl; |
184 | Settings::checkDirectory(); | 183 | Settings::checkDirectory(); |
185 | 184 | ||
186 | Config *conf = new Config( getFileName(), Config::File ); | 185 | Config *conf = new Config( getFileName(), Config::File ); |
187 | conf->setGroup( "IMAP Account" ); | 186 | conf->setGroup( "IMAP Account" ); |
188 | conf->writeEntry( "Account", accountName ); | 187 | conf->writeEntry( "Account", accountName ); |
189 | conf->writeEntry( "Server", server ); | 188 | conf->writeEntry( "Server", server ); |
190 | conf->writeEntry( "Port", port ); | 189 | conf->writeEntry( "Port", port ); |
191 | conf->writeEntry( "SSL", ssl ); | 190 | conf->writeEntry( "SSL", ssl ); |
192 | conf->writeEntry( "ConnectionType", connectionType ); | 191 | conf->writeEntry( "ConnectionType", connectionType ); |
193 | conf->writeEntry( "User", user ); | 192 | conf->writeEntry( "User", user ); |
194 | conf->writeEntryCrypt( "Password", password ); | 193 | conf->writeEntryCrypt( "Password", password ); |
195 | conf->writeEntry( "MailPrefix",prefix); | 194 | conf->writeEntry( "MailPrefix",prefix); |
@@ -204,35 +203,39 @@ QString IMAPaccount::getFileName() | |||
204 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; | 203 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; |
205 | } | 204 | } |
206 | 205 | ||
207 | POP3account::POP3account() | 206 | POP3account::POP3account() |
208 | : Account() | 207 | : Account() |
209 | { | 208 | { |
210 | file = POP3account::getUniqueFileName(); | 209 | file = POP3account::getUniqueFileName(); |
211 | accountName = "New POP3 Account"; | 210 | accountName = "New POP3 Account"; |
212 | ssl = false; | 211 | ssl = false; |
213 | connectionType = 1; | 212 | connectionType = 1; |
214 | type = MAILLIB::A_POP3; | 213 | type = MAILLIB::A_POP3; |
215 | port = POP3_PORT; | 214 | port = POP3_PORT; |
215 | m_CheckSize = true; | ||
216 | m_MaxSize = 1024; | ||
216 | } | 217 | } |
217 | 218 | ||
218 | POP3account::POP3account( QString filename ) | 219 | POP3account::POP3account( QString filename ) |
219 | : Account() | 220 | : Account() |
220 | { | 221 | { |
221 | file = filename; | 222 | file = filename; |
222 | accountName = "New POP3 Account"; | 223 | accountName = "New POP3 Account"; |
223 | ssl = false; | 224 | ssl = false; |
224 | connectionType = 1; | 225 | connectionType = 1; |
225 | type = MAILLIB::A_POP3; | 226 | type = MAILLIB::A_POP3; |
226 | port = POP3_PORT; | 227 | port = POP3_PORT; |
228 | m_CheckSize = true; | ||
229 | m_MaxSize = 1024; | ||
227 | } | 230 | } |
228 | 231 | ||
229 | QString POP3account::getUniqueFileName() | 232 | QString POP3account::getUniqueFileName() |
230 | { | 233 | { |
231 | int num = 0; | 234 | int num = 0; |
232 | QString unique; | 235 | QString unique; |
233 | 236 | ||
234 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); | 237 | QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); |
235 | 238 | ||
236 | QStringList imap = dir.entryList( "pop3-*" ); | 239 | QStringList imap = dir.entryList( "pop3-*" ); |
237 | do { | 240 | do { |
238 | unique.setNum( num++ ); | 241 | unique.setNum( num++ ); |
@@ -244,52 +247,76 @@ QString POP3account::getUniqueFileName() | |||
244 | void POP3account::read() | 247 | void POP3account::read() |
245 | { | 248 | { |
246 | Config *conf = new Config( getFileName(), Config::File ); | 249 | Config *conf = new Config( getFileName(), Config::File ); |
247 | conf->setGroup( "POP3 Account" ); | 250 | conf->setGroup( "POP3 Account" ); |
248 | accountName = conf->readEntry( "Account" ); | 251 | accountName = conf->readEntry( "Account" ); |
249 | server = conf->readEntry( "Server" ); | 252 | server = conf->readEntry( "Server" ); |
250 | port = conf->readEntry( "Port" ); | 253 | port = conf->readEntry( "Port" ); |
251 | ssl = conf->readBoolEntry( "SSL" ); | 254 | ssl = conf->readBoolEntry( "SSL" ); |
252 | connectionType = conf->readNumEntry( "ConnectionType" ); | 255 | connectionType = conf->readNumEntry( "ConnectionType" ); |
253 | user = conf->readEntry( "User" ); | 256 | user = conf->readEntry( "User" ); |
254 | password = conf->readEntryCrypt( "Password" ); | 257 | password = conf->readEntryCrypt( "Password" ); |
255 | offline = conf->readBoolEntry("Offline",false); | 258 | offline = conf->readBoolEntry("Offline",false); |
259 | m_CheckSize = conf->readBoolEntry("Checkmaxsize",true); | ||
260 | m_MaxSize = conf->readNumEntry("Maxsize",1024); | ||
256 | delete conf; | 261 | delete conf; |
257 | } | 262 | } |
258 | 263 | ||
259 | void POP3account::save() | 264 | void POP3account::save() |
260 | { | 265 | { |
261 | odebug << "saving " + getFileName() << oendl; | 266 | odebug << "saving " + getFileName() << oendl; |
262 | Settings::checkDirectory(); | 267 | Settings::checkDirectory(); |
263 | 268 | ||
264 | Config *conf = new Config( getFileName(), Config::File ); | 269 | Config *conf = new Config( getFileName(), Config::File ); |
265 | conf->setGroup( "POP3 Account" ); | 270 | conf->setGroup( "POP3 Account" ); |
266 | conf->writeEntry( "Account", accountName ); | 271 | conf->writeEntry( "Account", accountName ); |
267 | conf->writeEntry( "Server", server ); | 272 | conf->writeEntry( "Server", server ); |
268 | conf->writeEntry( "Port", port ); | 273 | conf->writeEntry( "Port", port ); |
269 | conf->writeEntry( "SSL", ssl ); | 274 | conf->writeEntry( "SSL", ssl ); |
270 | conf->writeEntry( "ConnectionType", connectionType ); | 275 | conf->writeEntry( "ConnectionType", connectionType ); |
271 | conf->writeEntry( "User", user ); | 276 | conf->writeEntry( "User", user ); |
272 | conf->writeEntryCrypt( "Password", password ); | 277 | conf->writeEntryCrypt( "Password", password ); |
273 | conf->writeEntry( "Offline",offline); | 278 | conf->writeEntry( "Offline",offline); |
279 | conf->writeEntry("Checkmaxsize",m_CheckSize); | ||
280 | conf->writeEntry("Maxsize",m_MaxSize); | ||
274 | conf->write(); | 281 | conf->write(); |
275 | delete conf; | 282 | delete conf; |
276 | } | 283 | } |
277 | 284 | ||
278 | 285 | ||
279 | QString POP3account::getFileName() | 286 | QString POP3account::getFileName() |
280 | { | 287 | { |
281 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; | 288 | return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; |
282 | } | 289 | } |
283 | 290 | ||
291 | bool POP3account::getCheckMaxSize()const | ||
292 | { | ||
293 | return m_CheckSize; | ||
294 | } | ||
295 | |||
296 | void POP3account::setCheckMaxSize(bool aValue) | ||
297 | { | ||
298 | m_CheckSize = aValue; | ||
299 | } | ||
300 | |||
301 | int POP3account::getMaxSize()const | ||
302 | { | ||
303 | return m_MaxSize; | ||
304 | } | ||
305 | |||
306 | void POP3account::setMaxSize(int aValue) | ||
307 | { | ||
308 | m_MaxSize = aValue; | ||
309 | } | ||
310 | |||
284 | SMTPaccount::SMTPaccount() | 311 | SMTPaccount::SMTPaccount() |
285 | : Account() | 312 | : Account() |
286 | { | 313 | { |
287 | file = SMTPaccount::getUniqueFileName(); | 314 | file = SMTPaccount::getUniqueFileName(); |
288 | accountName = "New SMTP Account"; | 315 | accountName = "New SMTP Account"; |
289 | ssl = false; | 316 | ssl = false; |
290 | connectionType = 1; | 317 | connectionType = 1; |
291 | login = false; | 318 | login = false; |
292 | useCC = false; | 319 | useCC = false; |
293 | useBCC = false; | 320 | useBCC = false; |
294 | useReply = false; | 321 | useReply = false; |
295 | type = MAILLIB::A_SMTP; | 322 | type = MAILLIB::A_SMTP; |
@@ -331,25 +358,25 @@ void SMTPaccount::read() | |||
331 | server = conf->readEntry( "Server" ); | 358 | server = conf->readEntry( "Server" ); |
332 | port = conf->readEntry( "Port" ); | 359 | port = conf->readEntry( "Port" ); |
333 | ssl = conf->readBoolEntry( "SSL" ); | 360 | ssl = conf->readBoolEntry( "SSL" ); |
334 | connectionType = conf->readNumEntry( "ConnectionType" ); | 361 | connectionType = conf->readNumEntry( "ConnectionType" ); |
335 | login = conf->readBoolEntry( "Login" ); | 362 | login = conf->readBoolEntry( "Login" ); |
336 | user = conf->readEntry( "User" ); | 363 | user = conf->readEntry( "User" ); |
337 | password = conf->readEntryCrypt( "Password" ); | 364 | password = conf->readEntryCrypt( "Password" ); |
338 | delete conf; | 365 | delete conf; |
339 | } | 366 | } |
340 | 367 | ||
341 | void SMTPaccount::save() | 368 | void SMTPaccount::save() |
342 | { | 369 | { |
343 | odebug << "saving " + getFileName() << oendl; | 370 | odebug << "saving " + getFileName() << oendl; |
344 | Settings::checkDirectory(); | 371 | Settings::checkDirectory(); |
345 | 372 | ||
346 | Config *conf = new Config( getFileName(), Config::File ); | 373 | Config *conf = new Config( getFileName(), Config::File ); |
347 | conf->setGroup( "SMTP Account" ); | 374 | conf->setGroup( "SMTP Account" ); |
348 | conf->writeEntry( "Account", accountName ); | 375 | conf->writeEntry( "Account", accountName ); |
349 | conf->writeEntry( "Server", server ); | 376 | conf->writeEntry( "Server", server ); |
350 | conf->writeEntry( "Port", port ); | 377 | conf->writeEntry( "Port", port ); |
351 | conf->writeEntry( "SSL", ssl ); | 378 | conf->writeEntry( "SSL", ssl ); |
352 | conf->writeEntry( "ConnectionType", connectionType ); | 379 | conf->writeEntry( "ConnectionType", connectionType ); |
353 | conf->writeEntry( "Login", login ); | 380 | conf->writeEntry( "Login", login ); |
354 | conf->writeEntry( "User", user ); | 381 | conf->writeEntry( "User", user ); |
355 | conf->writeEntryCrypt( "Password", password ); | 382 | conf->writeEntryCrypt( "Password", password ); |
@@ -408,25 +435,25 @@ void NNTPaccount::read() | |||
408 | server = conf->readEntry( "Server" ); | 435 | server = conf->readEntry( "Server" ); |
409 | port = conf->readEntry( "Port" ); | 436 | port = conf->readEntry( "Port" ); |
410 | ssl = conf->readBoolEntry( "SSL" ); | 437 | ssl = conf->readBoolEntry( "SSL" ); |
411 | login = conf->readBoolEntry( "Login" ); | 438 | login = conf->readBoolEntry( "Login" ); |
412 | user = conf->readEntry( "User" ); | 439 | user = conf->readEntry( "User" ); |
413 | password = conf->readEntryCrypt( "Password" ); | 440 | password = conf->readEntryCrypt( "Password" ); |
414 | subscribedGroups = conf->readListEntry( "Subscribed", ',' ); | 441 | subscribedGroups = conf->readListEntry( "Subscribed", ',' ); |
415 | delete conf; | 442 | delete conf; |
416 | } | 443 | } |
417 | 444 | ||
418 | void NNTPaccount::save() | 445 | void NNTPaccount::save() |
419 | { | 446 | { |
420 | odebug << "saving " + getFileName() << oendl; | 447 | odebug << "saving " + getFileName() << oendl; |
421 | Settings::checkDirectory(); | 448 | Settings::checkDirectory(); |
422 | 449 | ||
423 | Config *conf = new Config( getFileName(), Config::File ); | 450 | Config *conf = new Config( getFileName(), Config::File ); |
424 | conf->setGroup( "NNTP Account" ); | 451 | conf->setGroup( "NNTP Account" ); |
425 | conf->writeEntry( "Account", accountName ); | 452 | conf->writeEntry( "Account", accountName ); |
426 | conf->writeEntry( "Server", server ); | 453 | conf->writeEntry( "Server", server ); |
427 | conf->writeEntry( "Port", port ); | 454 | conf->writeEntry( "Port", port ); |
428 | conf->writeEntry( "SSL", ssl ); | 455 | conf->writeEntry( "SSL", ssl ); |
429 | conf->writeEntry( "Login", login ); | 456 | conf->writeEntry( "Login", login ); |
430 | conf->writeEntry( "User", user ); | 457 | conf->writeEntry( "User", user ); |
431 | conf->writeEntryCrypt( "Password", password ); | 458 | conf->writeEntryCrypt( "Password", password ); |
432 | conf->writeEntry( "Subscribed" , subscribedGroups, ',' ); | 459 | conf->writeEntry( "Subscribed" , subscribedGroups, ',' ); |
diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h index bf27b97..8683a05 100644 --- a/noncore/net/mail/libmailwrapper/settings.h +++ b/noncore/net/mail/libmailwrapper/settings.h | |||
@@ -80,28 +80,33 @@ private: | |||
80 | class POP3account : public Account | 80 | class POP3account : public Account |
81 | { | 81 | { |
82 | 82 | ||
83 | public: | 83 | public: |
84 | POP3account(); | 84 | POP3account(); |
85 | POP3account( QString filename ); | 85 | POP3account( QString filename ); |
86 | 86 | ||
87 | static QString getUniqueFileName(); | 87 | static QString getUniqueFileName(); |
88 | 88 | ||
89 | virtual void read(); | 89 | virtual void read(); |
90 | virtual void save(); | 90 | virtual void save(); |
91 | virtual QString getFileName(); | 91 | virtual QString getFileName(); |
92 | virtual bool getCheckMaxSize()const; | ||
93 | virtual void setCheckMaxSize(bool); | ||
94 | virtual int getMaxSize()const; | ||
95 | virtual void setMaxSize(int); | ||
92 | 96 | ||
93 | private: | 97 | private: |
94 | QString file; | 98 | QString file; |
95 | 99 | bool m_CheckSize; | |
100 | int m_MaxSize; | ||
96 | }; | 101 | }; |
97 | 102 | ||
98 | class SMTPaccount : public Account | 103 | class SMTPaccount : public Account |
99 | { | 104 | { |
100 | 105 | ||
101 | public: | 106 | public: |
102 | SMTPaccount(); | 107 | SMTPaccount(); |
103 | SMTPaccount( QString filename ); | 108 | SMTPaccount( QString filename ); |
104 | 109 | ||
105 | static QString getUniqueFileName(); | 110 | static QString getUniqueFileName(); |
106 | 111 | ||
107 | virtual void read(); | 112 | virtual void read(); |