summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-14 22:30:26 (UTC)
committer alwin <alwin>2003-12-14 22:30:26 (UTC)
commitbdc60d27df0fa3a861e9117547fd2bed8a39661e (patch) (unidiff)
tree8dba1e590e60443ec0aff14398da665d351b0aa4
parent172c790df9004205eda2da25832cdc88fc6481ee (diff)
downloadopie-bdc60d27df0fa3a861e9117547fd2bed8a39661e.zip
opie-bdc60d27df0fa3a861e9117547fd2bed8a39661e.tar.gz
opie-bdc60d27df0fa3a861e9117547fd2bed8a39661e.tar.bz2
-answered mails get another pic (checked in in pics/opiemail)
-if a description for an attachment exists it will displayed -if mailbody is selected from list of attachments it will displayd without menu
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/imapwrapper.cpp5
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp5
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp12
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h4
-rw-r--r--noncore/net/mail/mailtypes.cpp12
-rw-r--r--noncore/net/mail/mailtypes.h4
-rw-r--r--noncore/net/mail/mainwindow.cpp4
-rw-r--r--noncore/net/mail/viewmail.cpp32
-rw-r--r--noncore/net/mail/viewmail.h3
-rw-r--r--noncore/net/mail/viewmailbase.cpp5
10 files changed, 64 insertions, 22 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp
index 0ce2c6c..ad95384 100644
--- a/noncore/net/mail/imapwrapper.cpp
+++ b/noncore/net/mail/imapwrapper.cpp
@@ -1,773 +1,776 @@
1 1
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include "imapwrapper.h" 4#include "imapwrapper.h"
5#include "mailtypes.h" 5#include "mailtypes.h"
6#include <libetpan/mailimap.h> 6#include <libetpan/mailimap.h>
7 7
8IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 8IMAPwrapper::IMAPwrapper( IMAPaccount *a )
9 : AbstractMail() 9 : AbstractMail()
10{ 10{
11 account = a; 11 account = a;
12 m_imap = 0; 12 m_imap = 0;
13} 13}
14 14
15IMAPwrapper::~IMAPwrapper() 15IMAPwrapper::~IMAPwrapper()
16{ 16{
17 logout(); 17 logout();
18} 18}
19 19
20void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 20void IMAPwrapper::imap_progress( size_t current, size_t maximum )
21{ 21{
22 qDebug( "IMAP: %i of %i", current, maximum ); 22 qDebug( "IMAP: %i of %i", current, maximum );
23} 23}
24 24
25void IMAPwrapper::login() 25void IMAPwrapper::login()
26{ 26{
27 const char *server, *user, *pass; 27 const char *server, *user, *pass;
28 uint16_t port; 28 uint16_t port;
29 int err = MAILIMAP_NO_ERROR; 29 int err = MAILIMAP_NO_ERROR;
30 30
31 /* we are connected this moment */ 31 /* we are connected this moment */
32 /* TODO: setup a timer holding the line or if connection closed - delete the value */ 32 /* TODO: setup a timer holding the line or if connection closed - delete the value */
33 if (m_imap) { 33 if (m_imap) {
34 mailstream_flush(m_imap->imap_stream); 34 mailstream_flush(m_imap->imap_stream);
35 return; 35 return;
36 } 36 }
37 server = account->getServer().latin1(); 37 server = account->getServer().latin1();
38 port = account->getPort().toUInt(); 38 port = account->getPort().toUInt();
39 user = account->getUser().latin1(); 39 user = account->getUser().latin1();
40 pass = account->getPassword().latin1(); 40 pass = account->getPassword().latin1();
41 41
42 m_imap = mailimap_new( 20, &imap_progress ); 42 m_imap = mailimap_new( 20, &imap_progress );
43 /* connect */ 43 /* connect */
44 if (account->getSSL()) { 44 if (account->getSSL()) {
45 err = mailimap_ssl_connect( m_imap, (char*)server, port ); 45 err = mailimap_ssl_connect( m_imap, (char*)server, port );
46 } else { 46 } else {
47 err = mailimap_socket_connect( m_imap, (char*)server, port ); 47 err = mailimap_socket_connect( m_imap, (char*)server, port );
48 } 48 }
49 49
50 if ( err != MAILIMAP_NO_ERROR && 50 if ( err != MAILIMAP_NO_ERROR &&
51 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 51 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
52 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 52 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
53 qDebug("error connecting server: %s",m_imap->imap_response); 53 qDebug("error connecting server: %s",m_imap->imap_response);
54 mailimap_free( m_imap ); 54 mailimap_free( m_imap );
55 m_imap = 0; 55 m_imap = 0;
56 return; 56 return;
57 } 57 }
58 58
59 /* login */ 59 /* login */
60 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); 60 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
61 if ( err != MAILIMAP_NO_ERROR ) { 61 if ( err != MAILIMAP_NO_ERROR ) {
62 qDebug("error logging in imap: %s",m_imap->imap_response); 62 qDebug("error logging in imap: %s",m_imap->imap_response);
63 err = mailimap_close( m_imap ); 63 err = mailimap_close( m_imap );
64 mailimap_free( m_imap ); 64 mailimap_free( m_imap );
65 m_imap = 0; 65 m_imap = 0;
66 } 66 }
67} 67}
68 68
69void IMAPwrapper::logout() 69void IMAPwrapper::logout()
70{ 70{
71 int err = MAILIMAP_NO_ERROR; 71 int err = MAILIMAP_NO_ERROR;
72 if (!m_imap) return; 72 if (!m_imap) return;
73 err = mailimap_logout( m_imap ); 73 err = mailimap_logout( m_imap );
74 err = mailimap_close( m_imap ); 74 err = mailimap_close( m_imap );
75 mailimap_free( m_imap ); 75 mailimap_free( m_imap );
76 m_imap = 0; 76 m_imap = 0;
77} 77}
78 78
79void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) 79void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
80{ 80{
81 const char *mb; 81 const char *mb;
82 int err = MAILIMAP_NO_ERROR; 82 int err = MAILIMAP_NO_ERROR;
83 clist *result; 83 clist *result;
84 clistcell *current; 84 clistcell *current;
85// mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; 85// mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize;
86 mailimap_fetch_type *fetchType; 86 mailimap_fetch_type *fetchType;
87 mailimap_set *set; 87 mailimap_set *set;
88 88
89 mb = mailbox.latin1(); 89 mb = mailbox.latin1();
90 login(); 90 login();
91 if (!m_imap) { 91 if (!m_imap) {
92 return; 92 return;
93 } 93 }
94 /* select mailbox READONLY for operations */ 94 /* select mailbox READONLY for operations */
95 err = mailimap_examine( m_imap, (char*)mb); 95 err = mailimap_examine( m_imap, (char*)mb);
96 if ( err != MAILIMAP_NO_ERROR ) { 96 if ( err != MAILIMAP_NO_ERROR ) {
97 qDebug("error selecting mailbox: %s",m_imap->imap_response); 97 qDebug("error selecting mailbox: %s",m_imap->imap_response);
98 return; 98 return;
99 } 99 }
100 100
101 int last = m_imap->imap_selection_info->sel_exists; 101 int last = m_imap->imap_selection_info->sel_exists;
102 102
103 if (last == 0) { 103 if (last == 0) {
104 qDebug("mailbox has no mails"); 104 qDebug("mailbox has no mails");
105 return; 105 return;
106 } 106 }
107 107
108 result = clist_new(); 108 result = clist_new();
109 /* the range has to start at 1!!! not with 0!!!! */ 109 /* the range has to start at 1!!! not with 0!!!! */
110 set = mailimap_set_new_interval( 1, last ); 110 set = mailimap_set_new_interval( 1, last );
111 fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); 111 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
112 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); 112 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
113 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); 113 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
114 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); 114 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
115 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); 115 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
116 116
117 err = mailimap_fetch( m_imap, set, fetchType, &result ); 117 err = mailimap_fetch( m_imap, set, fetchType, &result );
118 mailimap_set_free( set ); 118 mailimap_set_free( set );
119 mailimap_fetch_type_free( fetchType ); 119 mailimap_fetch_type_free( fetchType );
120 120
121 QString date,subject,from; 121 QString date,subject,from;
122 122
123 if ( err == MAILIMAP_NO_ERROR ) { 123 if ( err == MAILIMAP_NO_ERROR ) {
124 124
125 mailimap_msg_att * msg_att; 125 mailimap_msg_att * msg_att;
126 int i = 0; 126 int i = 0;
127 for (current = clist_begin(result); current != 0; current=clist_next(current)) { 127 for (current = clist_begin(result); current != 0; current=clist_next(current)) {
128 ++i; 128 ++i;
129 msg_att = (mailimap_msg_att*)current->data; 129 msg_att = (mailimap_msg_att*)current->data;
130 RecMail*m = parse_list_result(msg_att); 130 RecMail*m = parse_list_result(msg_att);
131 if (m) { 131 if (m) {
132 m->setNumber(i); 132 m->setNumber(i);
133 m->setMbox(mailbox); 133 m->setMbox(mailbox);
134 m->setWrapper(this); 134 m->setWrapper(this);
135 target.append(m); 135 target.append(m);
136 } 136 }
137 } 137 }
138 } else { 138 } else {
139 qDebug("Error fetching headers: %s",m_imap->imap_response); 139 qDebug("Error fetching headers: %s",m_imap->imap_response);
140 } 140 }
141 mailimap_fetch_list_free(result); 141 mailimap_fetch_list_free(result);
142} 142}
143 143
144QList<Folder>* IMAPwrapper::listFolders() 144QList<Folder>* IMAPwrapper::listFolders()
145{ 145{
146 const char *path, *mask; 146 const char *path, *mask;
147 int err = MAILIMAP_NO_ERROR; 147 int err = MAILIMAP_NO_ERROR;
148 clist *result; 148 clist *result;
149 clistcell *current; 149 clistcell *current;
150 150
151 QList<Folder> * folders = new QList<Folder>(); 151 QList<Folder> * folders = new QList<Folder>();
152 folders->setAutoDelete( false ); 152 folders->setAutoDelete( false );
153 login(); 153 login();
154 if (!m_imap) { 154 if (!m_imap) {
155 return folders; 155 return folders;
156 } 156 }
157 157
158/* 158/*
159 * First we have to check for INBOX 'cause it sometimes it's not inside the path. 159 * First we have to check for INBOX 'cause it sometimes it's not inside the path.
160 * We must not forget to filter them out in next loop! 160 * We must not forget to filter them out in next loop!
161 * it seems like ugly code. and yes - it is ugly code. but the best way. 161 * it seems like ugly code. and yes - it is ugly code. but the best way.
162 */ 162 */
163 QString temp; 163 QString temp;
164 mask = "INBOX" ; 164 mask = "INBOX" ;
165 result = clist_new(); 165 result = clist_new();
166 mailimap_mailbox_list *list; 166 mailimap_mailbox_list *list;
167 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); 167 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result );
168 if ( err == MAILIMAP_NO_ERROR ) { 168 if ( err == MAILIMAP_NO_ERROR ) {
169 current = result->first; 169 current = result->first;
170 for ( int i = result->count; i > 0; i-- ) { 170 for ( int i = result->count; i > 0; i-- ) {
171 list = (mailimap_mailbox_list *) current->data; 171 list = (mailimap_mailbox_list *) current->data;
172 // it is better use the deep copy mechanism of qt itself 172 // it is better use the deep copy mechanism of qt itself
173 // instead of using strdup! 173 // instead of using strdup!
174 temp = list->mb_name; 174 temp = list->mb_name;
175 folders->append( new IMAPFolder(temp)); 175 folders->append( new IMAPFolder(temp));
176 current = current->next; 176 current = current->next;
177 } 177 }
178 } else { 178 } else {
179 qDebug("error fetching folders: %s",m_imap->imap_response); 179 qDebug("error fetching folders: %s",m_imap->imap_response);
180 } 180 }
181 mailimap_list_result_free( result ); 181 mailimap_list_result_free( result );
182 182
183/* 183/*
184 * second stage - get the other then inbox folders 184 * second stage - get the other then inbox folders
185 */ 185 */
186 mask = "*" ; 186 mask = "*" ;
187 path = account->getPrefix().latin1(); 187 path = account->getPrefix().latin1();
188 if (!path) path = ""; 188 if (!path) path = "";
189 result = clist_new(); 189 result = clist_new();
190 qDebug(path); 190 qDebug(path);
191 bool selectable = true; 191 bool selectable = true;
192 mailimap_mbx_list_flags*bflags; 192 mailimap_mbx_list_flags*bflags;
193 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); 193 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
194 if ( err == MAILIMAP_NO_ERROR ) { 194 if ( err == MAILIMAP_NO_ERROR ) {
195 current = result->first; 195 current = result->first;
196 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { 196 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) {
197 list = (mailimap_mailbox_list *) current->data; 197 list = (mailimap_mailbox_list *) current->data;
198 // it is better use the deep copy mechanism of qt itself 198 // it is better use the deep copy mechanism of qt itself
199 // instead of using strdup! 199 // instead of using strdup!
200 temp = list->mb_name; 200 temp = list->mb_name;
201 if (temp.lower()=="inbox") 201 if (temp.lower()=="inbox")
202 continue; 202 continue;
203 if (temp.lower()==account->getPrefix().lower()) 203 if (temp.lower()==account->getPrefix().lower())
204 continue; 204 continue;
205 if ( (bflags = list->mb_flag) ) { 205 if ( (bflags = list->mb_flag) ) {
206 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 206 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
207 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 207 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
208 } 208 }
209 folders->append(new IMAPFolder(temp,selectable,account->getPrefix())); 209 folders->append(new IMAPFolder(temp,selectable,account->getPrefix()));
210 } 210 }
211 } else { 211 } else {
212 qDebug("error fetching folders %s",m_imap->imap_response); 212 qDebug("error fetching folders %s",m_imap->imap_response);
213 } 213 }
214 mailimap_list_result_free( result ); 214 mailimap_list_result_free( result );
215 return folders; 215 return folders;
216} 216}
217 217
218RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) 218RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
219{ 219{
220 RecMail * m = 0; 220 RecMail * m = 0;
221 mailimap_msg_att_item *item=0; 221 mailimap_msg_att_item *item=0;
222 clistcell *current,*c,*cf; 222 clistcell *current,*c,*cf;
223 mailimap_msg_att_dynamic*flist; 223 mailimap_msg_att_dynamic*flist;
224 mailimap_flag_fetch*cflag; 224 mailimap_flag_fetch*cflag;
225 int size; 225 int size;
226 QBitArray mFlags(7); 226 QBitArray mFlags(7);
227 QStringList addresslist; 227 QStringList addresslist;
228 228
229 if (!m_att) { 229 if (!m_att) {
230 return m; 230 return m;
231 } 231 }
232 m = new RecMail(); 232 m = new RecMail();
233 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { 233 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
234 current = c; 234 current = c;
235 size = 0; 235 size = 0;
236 item = (mailimap_msg_att_item*)current->data; 236 item = (mailimap_msg_att_item*)current->data;
237 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { 237 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
238 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; 238 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
239 if (!flist->att_list) { 239 if (!flist->att_list) {
240 continue; 240 continue;
241 } 241 }
242 cf = flist->att_list->first; 242 cf = flist->att_list->first;
243 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { 243 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
244 cflag = (mailimap_flag_fetch*)cf->data; 244 cflag = (mailimap_flag_fetch*)cf->data;
245 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { 245 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
246 switch (cflag->fl_flag->fl_type) { 246 switch (cflag->fl_flag->fl_type) {
247 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ 247 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
248 mFlags.setBit(FLAG_ANSWERED); 248 mFlags.setBit(FLAG_ANSWERED);
249 break; 249 break;
250 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ 250 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */
251 mFlags.setBit(FLAG_FLAGGED); 251 mFlags.setBit(FLAG_FLAGGED);
252 break; 252 break;
253 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ 253 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */
254 mFlags.setBit(FLAG_DELETED); 254 mFlags.setBit(FLAG_DELETED);
255 break; 255 break;
256 case MAILIMAP_FLAG_SEEN: /* \Seen flag */ 256 case MAILIMAP_FLAG_SEEN: /* \Seen flag */
257 mFlags.setBit(FLAG_SEEN); 257 mFlags.setBit(FLAG_SEEN);
258 break; 258 break;
259 case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ 259 case MAILIMAP_FLAG_DRAFT: /* \Draft flag */
260 mFlags.setBit(FLAG_DRAFT); 260 mFlags.setBit(FLAG_DRAFT);
261 break; 261 break;
262 case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ 262 case MAILIMAP_FLAG_KEYWORD: /* keyword flag */
263 break; 263 break;
264 case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ 264 case MAILIMAP_FLAG_EXTENSION: /* \extension flag */
265 break; 265 break;
266 default: 266 default:
267 break; 267 break;
268 } 268 }
269 } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { 269 } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
270 mFlags.setBit(FLAG_RECENT); 270 mFlags.setBit(FLAG_RECENT);
271 } 271 }
272 } 272 }
273 continue; 273 continue;
274 } 274 }
275 if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { 275 if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) {
276 mailimap_envelope * head = item->att_data.att_static->att_data.att_env; 276 mailimap_envelope * head = item->att_data.att_static->att_data.att_env;
277 m->setDate(head->env_date); 277 m->setDate(head->env_date);
278 m->setSubject(head->env_subject); 278 m->setSubject(head->env_subject);
279 if (head->env_from!=NULL) { 279 if (head->env_from!=NULL) {
280 addresslist = address_list_to_stringlist(head->env_from->frm_list); 280 addresslist = address_list_to_stringlist(head->env_from->frm_list);
281 if (addresslist.count()) { 281 if (addresslist.count()) {
282 m->setFrom(addresslist.first()); 282 m->setFrom(addresslist.first());
283 } 283 }
284 } 284 }
285 if (head->env_to!=NULL) { 285 if (head->env_to!=NULL) {
286 addresslist = address_list_to_stringlist(head->env_to->to_list); 286 addresslist = address_list_to_stringlist(head->env_to->to_list);
287 m->setTo(addresslist); 287 m->setTo(addresslist);
288 } 288 }
289 if (head->env_cc!=NULL) { 289 if (head->env_cc!=NULL) {
290 addresslist = address_list_to_stringlist(head->env_cc->cc_list); 290 addresslist = address_list_to_stringlist(head->env_cc->cc_list);
291 m->setCC(addresslist); 291 m->setCC(addresslist);
292 } 292 }
293 if (head->env_bcc!=NULL) { 293 if (head->env_bcc!=NULL) {
294 addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); 294 addresslist = address_list_to_stringlist(head->env_bcc->bcc_list);
295 m->setBcc(addresslist); 295 m->setBcc(addresslist);
296 } 296 }
297 if (head->env_reply_to!=NULL) { 297 if (head->env_reply_to!=NULL) {
298 addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); 298 addresslist = address_list_to_stringlist(head->env_reply_to->rt_list);
299 if (addresslist.count()) { 299 if (addresslist.count()) {
300 m->setReplyto(addresslist.first()); 300 m->setReplyto(addresslist.first());
301 } 301 }
302 } 302 }
303 m->setMsgid(QString(head->env_message_id)); 303 m->setMsgid(QString(head->env_message_id));
304 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { 304 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
305 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; 305 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
306#if 0 306#if 0
307 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); 307 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
308 qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); 308 qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec);
309 qDebug(da.toString()); 309 qDebug(da.toString());
310#endif 310#endif
311 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { 311 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
312 size = item->att_data.att_static->att_data.att_rfc822_size; 312 size = item->att_data.att_static->att_data.att_rfc822_size;
313 } 313 }
314 } 314 }
315 /* msg is already deleted */ 315 /* msg is already deleted */
316 if (mFlags.testBit(FLAG_DELETED) && m) { 316 if (mFlags.testBit(FLAG_DELETED) && m) {
317 delete m; 317 delete m;
318 m = 0; 318 m = 0;
319 } 319 }
320 if (m) { 320 if (m) {
321 m->setFlags(mFlags); 321 m->setFlags(mFlags);
322 m->setMsgsize(size); 322 m->setMsgsize(size);
323 } 323 }
324 return m; 324 return m;
325} 325}
326 326
327RecBody IMAPwrapper::fetchBody(const RecMail&mail) 327RecBody IMAPwrapper::fetchBody(const RecMail&mail)
328{ 328{
329 RecBody body; 329 RecBody body;
330 const char *mb; 330 const char *mb;
331 int err = MAILIMAP_NO_ERROR; 331 int err = MAILIMAP_NO_ERROR;
332 clist *result; 332 clist *result;
333 clistcell *current; 333 clistcell *current;
334 mailimap_fetch_att *fetchAtt; 334 mailimap_fetch_att *fetchAtt;
335 mailimap_fetch_type *fetchType; 335 mailimap_fetch_type *fetchType;
336 mailimap_set *set; 336 mailimap_set *set;
337 mailimap_body*body_desc; 337 mailimap_body*body_desc;
338 338
339 mb = mail.getMbox().latin1(); 339 mb = mail.getMbox().latin1();
340 340
341 login(); 341 login();
342 if (!m_imap) { 342 if (!m_imap) {
343 return body; 343 return body;
344 } 344 }
345 345
346 err = mailimap_select( m_imap, (char*)mb); 346 err = mailimap_select( m_imap, (char*)mb);
347 if ( err != MAILIMAP_NO_ERROR ) { 347 if ( err != MAILIMAP_NO_ERROR ) {
348 qDebug("error selecting mailbox: %s",m_imap->imap_response); 348 qDebug("error selecting mailbox: %s",m_imap->imap_response);
349 return body; 349 return body;
350 } 350 }
351 351
352 result = clist_new(); 352 result = clist_new();
353 /* the range has to start at 1!!! not with 0!!!! */ 353 /* the range has to start at 1!!! not with 0!!!! */
354 set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); 354 set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
355 fetchAtt = mailimap_fetch_att_new_bodystructure(); 355 fetchAtt = mailimap_fetch_att_new_bodystructure();
356 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); 356 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
357 err = mailimap_fetch( m_imap, set, fetchType, &result ); 357 err = mailimap_fetch( m_imap, set, fetchType, &result );
358 mailimap_set_free( set ); 358 mailimap_set_free( set );
359 mailimap_fetch_type_free( fetchType ); 359 mailimap_fetch_type_free( fetchType );
360 360
361 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 361 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
362 mailimap_msg_att * msg_att; 362 mailimap_msg_att * msg_att;
363 msg_att = (mailimap_msg_att*)current->data; 363 msg_att = (mailimap_msg_att*)current->data;
364 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; 364 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data;
365 body_desc = item->att_data.att_static->att_data.att_body; 365 body_desc = item->att_data.att_static->att_data.att_body;
366 if (body_desc->bd_type==MAILIMAP_BODY_1PART) { 366 if (body_desc->bd_type==MAILIMAP_BODY_1PART) {
367 searchBodyText(mail,body_desc->bd_data.bd_body_1part,body); 367 searchBodyText(mail,body_desc->bd_data.bd_body_1part,body);
368 } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) { 368 } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) {
369 qDebug("Mulitpart mail"); 369 qDebug("Mulitpart mail");
370 searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); 370 searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body);
371 } 371 }
372 } else { 372 } else {
373 qDebug("error fetching body: %s",m_imap->imap_response); 373 qDebug("error fetching body: %s",m_imap->imap_response);
374 } 374 }
375 mailimap_fetch_list_free(result); 375 mailimap_fetch_list_free(result);
376 return body; 376 return body;
377} 377}
378 378
379/* this routine is just called when the mail has only ONE part. 379/* this routine is just called when the mail has only ONE part.
380 for filling the parts of a multi-part-message there are other 380 for filling the parts of a multi-part-message there are other
381 routines 'cause we can not simply fetch the whole body. */ 381 routines 'cause we can not simply fetch the whole body. */
382void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) 382void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body)
383{ 383{
384 if (!mailDescription) { 384 if (!mailDescription) {
385 return; 385 return;
386 } 386 }
387 QString sub,body_text; 387 QString sub,body_text;
388 RecPart singlePart; 388 RecPart singlePart;
389 QValueList<int> path; 389 QValueList<int> path;
390 fillSinglePart(singlePart,mailDescription); 390 fillSinglePart(singlePart,mailDescription);
391 switch (mailDescription->bd_type) { 391 switch (mailDescription->bd_type) {
392 case MAILIMAP_BODY_TYPE_1PART_MSG: 392 case MAILIMAP_BODY_TYPE_1PART_MSG:
393 path.append(1); 393 path.append(1);
394 body_text = fetchPart(mail,path,true); 394 body_text = fetchPart(mail,path,true);
395 target_body.setBodytext(body_text); 395 target_body.setBodytext(body_text);
396 target_body.setDescription(singlePart); 396 target_body.setDescription(singlePart);
397 break; 397 break;
398 case MAILIMAP_BODY_TYPE_1PART_TEXT: 398 case MAILIMAP_BODY_TYPE_1PART_TEXT:
399 qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); 399 qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text);
400 path.append(1); 400 path.append(1);
401 body_text = fetchPart(mail,path,true); 401 body_text = fetchPart(mail,path,true);
402 target_body.setBodytext(body_text); 402 target_body.setBodytext(body_text);
403 target_body.setDescription(singlePart); 403 target_body.setDescription(singlePart);
404 break; 404 break;
405 case MAILIMAP_BODY_TYPE_1PART_BASIC: 405 case MAILIMAP_BODY_TYPE_1PART_BASIC:
406 qDebug("Single attachment"); 406 qDebug("Single attachment");
407 target_body.setBodytext(""); 407 target_body.setBodytext("");
408 target_body.addPart(singlePart); 408 target_body.addPart(singlePart);
409 break; 409 break;
410 default: 410 default:
411 break; 411 break;
412 } 412 }
413 413
414 return; 414 return;
415} 415}
416 416
417QStringList IMAPwrapper::address_list_to_stringlist(clist*list) 417QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
418{ 418{
419 QStringList l; 419 QStringList l;
420 QString from; 420 QString from;
421 bool named_from; 421 bool named_from;
422 clistcell *current = NULL; 422 clistcell *current = NULL;
423 mailimap_address * current_address=NULL; 423 mailimap_address * current_address=NULL;
424 if (!list) { 424 if (!list) {
425 return l; 425 return l;
426 } 426 }
427 unsigned int count = 0; 427 unsigned int count = 0;
428 for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { 428 for (current=clist_begin(list);current!= NULL;current=clist_next(current)) {
429 from = ""; 429 from = "";
430 named_from = false; 430 named_from = false;
431 current_address=(mailimap_address*)current->data; 431 current_address=(mailimap_address*)current->data;
432 if (current_address->ad_personal_name){ 432 if (current_address->ad_personal_name){
433 from+=QString(current_address->ad_personal_name); 433 from+=QString(current_address->ad_personal_name);
434 from+=" "; 434 from+=" ";
435 named_from = true; 435 named_from = true;
436 } 436 }
437 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { 437 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
438 from+="<"; 438 from+="<";
439 } 439 }
440 if (current_address->ad_mailbox_name) { 440 if (current_address->ad_mailbox_name) {
441 from+=QString(current_address->ad_mailbox_name); 441 from+=QString(current_address->ad_mailbox_name);
442 from+="@"; 442 from+="@";
443 } 443 }
444 if (current_address->ad_host_name) { 444 if (current_address->ad_host_name) {
445 from+=QString(current_address->ad_host_name); 445 from+=QString(current_address->ad_host_name);
446 } 446 }
447 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { 447 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
448 from+=">"; 448 from+=">";
449 } 449 }
450 l.append(QString(from)); 450 l.append(QString(from));
451 if (++count > 99) { 451 if (++count > 99) {
452 break; 452 break;
453 } 453 }
454 } 454 }
455 return l; 455 return l;
456} 456}
457 457
458QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) 458QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call)
459{ 459{
460 QString body(""); 460 QString body("");
461 const char*mb; 461 const char*mb;
462 int err; 462 int err;
463 mailimap_fetch_type *fetchType; 463 mailimap_fetch_type *fetchType;
464 mailimap_set *set; 464 mailimap_set *set;
465 clistcell*current,*cur; 465 clistcell*current,*cur;
466 466
467 login(); 467 login();
468 if (!m_imap) { 468 if (!m_imap) {
469 return body; 469 return body;
470 } 470 }
471 if (!internal_call) { 471 if (!internal_call) {
472 mb = mail.getMbox().latin1(); 472 mb = mail.getMbox().latin1();
473 err = mailimap_select( m_imap, (char*)mb); 473 err = mailimap_select( m_imap, (char*)mb);
474 if ( err != MAILIMAP_NO_ERROR ) { 474 if ( err != MAILIMAP_NO_ERROR ) {
475 qDebug("error selecting mailbox: %s",m_imap->imap_response); 475 qDebug("error selecting mailbox: %s",m_imap->imap_response);
476 return body; 476 return body;
477 } 477 }
478 } 478 }
479 set = mailimap_set_new_single(mail.getNumber()); 479 set = mailimap_set_new_single(mail.getNumber());
480 clist*id_list=clist_new(); 480 clist*id_list=clist_new();
481 for (unsigned j=0; j < path.count();++j) { 481 for (unsigned j=0; j < path.count();++j) {
482 uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); 482 uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id));
483 *p_id = path[j]; 483 *p_id = path[j];
484 clist_append(id_list,p_id); 484 clist_append(id_list,p_id);
485 } 485 }
486 mailimap_section_part * section_part = mailimap_section_part_new(id_list); 486 mailimap_section_part * section_part = mailimap_section_part_new(id_list);
487 mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); 487 mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL);
488 mailimap_section * section = mailimap_section_new(section_spec); 488 mailimap_section * section = mailimap_section_new(section_spec);
489 mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); 489 mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section);
490 490
491 fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); 491 fetchType = mailimap_fetch_type_new_fetch_att(fetch_att);
492 492
493 clist*result = clist_new(); 493 clist*result = clist_new();
494 494
495 err = mailimap_fetch( m_imap, set, fetchType, &result ); 495 err = mailimap_fetch( m_imap, set, fetchType, &result );
496 mailimap_set_free( set ); 496 mailimap_set_free( set );
497 mailimap_fetch_type_free( fetchType ); 497 mailimap_fetch_type_free( fetchType );
498 498
499 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 499 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
500 mailimap_msg_att * msg_att; 500 mailimap_msg_att * msg_att;
501 msg_att = (mailimap_msg_att*)current->data; 501 msg_att = (mailimap_msg_att*)current->data;
502 mailimap_msg_att_item*msg_att_item; 502 mailimap_msg_att_item*msg_att_item;
503 for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { 503 for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) {
504 msg_att_item = (mailimap_msg_att_item*)clist_content(cur); 504 msg_att_item = (mailimap_msg_att_item*)clist_content(cur);
505 if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { 505 if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) {
506 if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { 506 if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) {
507 char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; 507 char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part;
508 msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; 508 msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
509 if (text) { 509 if (text) {
510 body = QString(text); 510 body = QString(text);
511 free(text); 511 free(text);
512 } else { 512 } else {
513 body = ""; 513 body = "";
514 } 514 }
515 } 515 }
516 } 516 }
517 } 517 }
518 518
519 } else { 519 } else {
520 qDebug("error fetching text: %s",m_imap->imap_response); 520 qDebug("error fetching text: %s",m_imap->imap_response);
521 } 521 }
522 mailimap_fetch_list_free(result); 522 mailimap_fetch_list_free(result);
523 return body; 523 return body;
524} 524}
525 525
526void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList) 526void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList)
527{ 527{
528 /* current_recursion is for avoiding ugly mails which has a to deep body-structure */ 528 /* current_recursion is for avoiding ugly mails which has a to deep body-structure */
529 if (!mailDescription||current_recursion==10) { 529 if (!mailDescription||current_recursion==10) {
530 return; 530 return;
531 } 531 }
532 clistcell*current; 532 clistcell*current;
533 mailimap_body*current_body; 533 mailimap_body*current_body;
534 unsigned int count = 0; 534 unsigned int count = 0;
535 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { 535 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
536 /* the point in the message */ 536 /* the point in the message */
537 ++count; 537 ++count;
538 current_body = (mailimap_body*)current->data; 538 current_body = (mailimap_body*)current->data;
539 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 539 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
540 QValueList<int>clist = recList; 540 QValueList<int>clist = recList;
541 clist.append(count); 541 clist.append(count);
542 searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,clist); 542 searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,clist);
543 } else if (current_body->bd_type==MAILIMAP_BODY_1PART){ 543 } else if (current_body->bd_type==MAILIMAP_BODY_1PART){
544 RecPart currentPart; 544 RecPart currentPart;
545 fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); 545 fillSinglePart(currentPart,current_body->bd_data.bd_body_1part);
546 QValueList<int>clist = recList; 546 QValueList<int>clist = recList;
547 clist.append(count); 547 clist.append(count);
548 /* important: Check for is NULL 'cause a body can be empty! */ 548 /* important: Check for is NULL 'cause a body can be empty! */
549 if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { 549 if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) {
550 QString body_text = fetchPart(mail,clist,true); 550 QString body_text = fetchPart(mail,clist,true);
551 target_body.setDescription(currentPart); 551 target_body.setDescription(currentPart);
552 target_body.setBodytext(body_text); 552 target_body.setBodytext(body_text);
553 } else { 553 } else {
554 QString id(""); 554 QString id("");
555 for (unsigned int j = 0; j < clist.count();++j) { 555 for (unsigned int j = 0; j < clist.count();++j) {
556 id+=(j>0?" ":""); 556 id+=(j>0?" ":"");
557 id+=QString("%1").arg(clist[j]); 557 id+=QString("%1").arg(clist[j]);
558 } 558 }
559 qDebug("ID= %s",id.latin1()); 559 qDebug("ID= %s",id.latin1());
560 currentPart.setIdentifier(id); 560 currentPart.setIdentifier(id);
561 currentPart.setPositionlist(clist); 561 currentPart.setPositionlist(clist);
562 target_body.addPart(currentPart); 562 target_body.addPart(currentPart);
563 } 563 }
564 } 564 }
565 } 565 }
566} 566}
567 567
568void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) 568void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description)
569{ 569{
570 if (!Description) { 570 if (!Description) {
571 return; 571 return;
572 } 572 }
573 switch (Description->bd_type) { 573 switch (Description->bd_type) {
574 case MAILIMAP_BODY_TYPE_1PART_TEXT: 574 case MAILIMAP_BODY_TYPE_1PART_TEXT:
575 target_part.setType("text"); 575 target_part.setType("text");
576 fillSingleTextPart(target_part,Description->bd_data.bd_type_text); 576 fillSingleTextPart(target_part,Description->bd_data.bd_type_text);
577 break; 577 break;
578 case MAILIMAP_BODY_TYPE_1PART_BASIC: 578 case MAILIMAP_BODY_TYPE_1PART_BASIC:
579 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); 579 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
580 break; 580 break;
581 case MAILIMAP_BODY_TYPE_1PART_MSG: 581 case MAILIMAP_BODY_TYPE_1PART_MSG:
582 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); 582 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg);
583 break; 583 break;
584 default: 584 default:
585 break; 585 break;
586 } 586 }
587} 587}
588 588
589void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) 589void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which)
590{ 590{
591 if (!which) { 591 if (!which) {
592 return; 592 return;
593 } 593 }
594 QString sub; 594 QString sub;
595 sub = which->bd_media_text; 595 sub = which->bd_media_text;
596 target_part.setSubtype(sub.lower()); 596 target_part.setSubtype(sub.lower());
597 target_part.setLines(which->bd_lines); 597 target_part.setLines(which->bd_lines);
598 fillBodyFields(target_part,which->bd_fields); 598 fillBodyFields(target_part,which->bd_fields);
599} 599}
600 600
601void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) 601void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which)
602{ 602{
603 if (!which) { 603 if (!which) {
604 return; 604 return;
605 } 605 }
606// QString sub; 606// QString sub;
607// sub = which->bd_media_text; 607// sub = which->bd_media_text;
608// target_part.setSubtype(sub.lower()); 608// target_part.setSubtype(sub.lower());
609 qDebug("Message part"); 609 qDebug("Message part");
610 /* we set this type to text/plain */ 610 /* we set this type to text/plain */
611 target_part.setType("text"); 611 target_part.setType("text");
612 target_part.setSubtype("plain"); 612 target_part.setSubtype("plain");
613 target_part.setLines(which->bd_lines); 613 target_part.setLines(which->bd_lines);
614 fillBodyFields(target_part,which->bd_fields); 614 fillBodyFields(target_part,which->bd_fields);
615} 615}
616 616
617void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) 617void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which)
618{ 618{
619 if (!which) { 619 if (!which) {
620 return; 620 return;
621 } 621 }
622 QString type,sub; 622 QString type,sub;
623 switch (which->bd_media_basic->med_type) { 623 switch (which->bd_media_basic->med_type) {
624 case MAILIMAP_MEDIA_BASIC_APPLICATION: 624 case MAILIMAP_MEDIA_BASIC_APPLICATION:
625 type = "application"; 625 type = "application";
626 break; 626 break;
627 case MAILIMAP_MEDIA_BASIC_AUDIO: 627 case MAILIMAP_MEDIA_BASIC_AUDIO:
628 type = "audio"; 628 type = "audio";
629 break; 629 break;
630 case MAILIMAP_MEDIA_BASIC_IMAGE: 630 case MAILIMAP_MEDIA_BASIC_IMAGE:
631 type = "image"; 631 type = "image";
632 break; 632 break;
633 case MAILIMAP_MEDIA_BASIC_MESSAGE: 633 case MAILIMAP_MEDIA_BASIC_MESSAGE:
634 type = "message"; 634 type = "message";
635 break; 635 break;
636 case MAILIMAP_MEDIA_BASIC_VIDEO: 636 case MAILIMAP_MEDIA_BASIC_VIDEO:
637 type = "video"; 637 type = "video";
638 break; 638 break;
639 case MAILIMAP_MEDIA_BASIC_OTHER: 639 case MAILIMAP_MEDIA_BASIC_OTHER:
640 default: 640 default:
641 if (which->bd_media_basic->med_basic_type) { 641 if (which->bd_media_basic->med_basic_type) {
642 type = which->bd_media_basic->med_basic_type; 642 type = which->bd_media_basic->med_basic_type;
643 } else { 643 } else {
644 type = ""; 644 type = "";
645 } 645 }
646 break; 646 break;
647 } 647 }
648 if (which->bd_media_basic->med_subtype) { 648 if (which->bd_media_basic->med_subtype) {
649 sub = which->bd_media_basic->med_subtype; 649 sub = which->bd_media_basic->med_subtype;
650 } else { 650 } else {
651 sub = ""; 651 sub = "";
652 } 652 }
653 qDebug("Type = %s/%s",type.latin1(),sub.latin1()); 653 qDebug("Type = %s/%s",type.latin1(),sub.latin1());
654 target_part.setType(type.lower()); 654 target_part.setType(type.lower());
655 target_part.setSubtype(sub.lower()); 655 target_part.setSubtype(sub.lower());
656 fillBodyFields(target_part,which->bd_fields); 656 fillBodyFields(target_part,which->bd_fields);
657} 657}
658 658
659void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) 659void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
660{ 660{
661 if (!which) return; 661 if (!which) return;
662 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { 662 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) {
663 clistcell*cur; 663 clistcell*cur;
664 mailimap_single_body_fld_param*param=0; 664 mailimap_single_body_fld_param*param=0;
665 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 665 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
666 param = (mailimap_single_body_fld_param*)cur->data; 666 param = (mailimap_single_body_fld_param*)cur->data;
667 if (param) { 667 if (param) {
668 target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 668 target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
669 } 669 }
670 } 670 }
671 } 671 }
672 mailimap_body_fld_enc*enc = which->bd_encoding; 672 mailimap_body_fld_enc*enc = which->bd_encoding;
673 QString encoding(""); 673 QString encoding("");
674 switch (enc->enc_type) { 674 switch (enc->enc_type) {
675 case MAILIMAP_BODY_FLD_ENC_7BIT: 675 case MAILIMAP_BODY_FLD_ENC_7BIT:
676 encoding = "7bit"; 676 encoding = "7bit";
677 break; 677 break;
678 case MAILIMAP_BODY_FLD_ENC_8BIT: 678 case MAILIMAP_BODY_FLD_ENC_8BIT:
679 encoding = "8bit"; 679 encoding = "8bit";
680 break; 680 break;
681 case MAILIMAP_BODY_FLD_ENC_BINARY: 681 case MAILIMAP_BODY_FLD_ENC_BINARY:
682 encoding="binary"; 682 encoding="binary";
683 break; 683 break;
684 case MAILIMAP_BODY_FLD_ENC_BASE64: 684 case MAILIMAP_BODY_FLD_ENC_BASE64:
685 encoding="base64"; 685 encoding="base64";
686 break; 686 break;
687 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: 687 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE:
688 encoding="quoted-printable"; 688 encoding="quoted-printable";
689 break; 689 break;
690 case MAILIMAP_BODY_FLD_ENC_OTHER: 690 case MAILIMAP_BODY_FLD_ENC_OTHER:
691 default: 691 default:
692 if (enc->enc_value) { 692 if (enc->enc_value) {
693 char*t=enc->enc_value; 693 char*t=enc->enc_value;
694 encoding=QString(enc->enc_value); 694 encoding=QString(enc->enc_value);
695 enc->enc_value=0L; 695 enc->enc_value=0L;
696 free(t); 696 free(t);
697 } 697 }
698 } 698 }
699 if (which->bd_description) {
700 target_part.setDescription(QString(which->bd_description));
701 }
699 target_part.setEncoding(encoding); 702 target_part.setEncoding(encoding);
700 target_part.setSize(which->bd_size); 703 target_part.setSize(which->bd_size);
701} 704}
702 705
703QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) 706QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part)
704{ 707{
705 return fetchPart(mail,part.Positionlist(),false); 708 return fetchPart(mail,part.Positionlist(),false);
706} 709}
707 710
708void IMAPwrapper::deleteMail(const RecMail&mail) 711void IMAPwrapper::deleteMail(const RecMail&mail)
709{ 712{
710 mailimap_flag_list*flist; 713 mailimap_flag_list*flist;
711 mailimap_set *set; 714 mailimap_set *set;
712 mailimap_store_att_flags * store_flags; 715 mailimap_store_att_flags * store_flags;
713 int err; 716 int err;
714 login(); 717 login();
715 if (!m_imap) { 718 if (!m_imap) {
716 return; 719 return;
717 } 720 }
718 const char *mb = mail.getMbox().latin1(); 721 const char *mb = mail.getMbox().latin1();
719 err = mailimap_select( m_imap, (char*)mb); 722 err = mailimap_select( m_imap, (char*)mb);
720 if ( err != MAILIMAP_NO_ERROR ) { 723 if ( err != MAILIMAP_NO_ERROR ) {
721 qDebug("error selecting mailbox for delete: %s",m_imap->imap_response); 724 qDebug("error selecting mailbox for delete: %s",m_imap->imap_response);
722 return; 725 return;
723 } 726 }
724 flist = mailimap_flag_list_new_empty(); 727 flist = mailimap_flag_list_new_empty();
725 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 728 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
726 store_flags = mailimap_store_att_flags_new_set_flags(flist); 729 store_flags = mailimap_store_att_flags_new_set_flags(flist);
727 set = mailimap_set_new_single(mail.getNumber()); 730 set = mailimap_set_new_single(mail.getNumber());
728 err = mailimap_store(m_imap,set,store_flags); 731 err = mailimap_store(m_imap,set,store_flags);
729 mailimap_set_free( set ); 732 mailimap_set_free( set );
730 mailimap_store_att_flags_free(store_flags); 733 mailimap_store_att_flags_free(store_flags);
731 734
732 if (err != MAILIMAP_NO_ERROR) { 735 if (err != MAILIMAP_NO_ERROR) {
733 qDebug("error deleting mail: %s",m_imap->imap_response); 736 qDebug("error deleting mail: %s",m_imap->imap_response);
734 return; 737 return;
735 } 738 }
736 qDebug("deleting mail: %s",m_imap->imap_response); 739 qDebug("deleting mail: %s",m_imap->imap_response);
737 /* should we realy do that at this moment? */ 740 /* should we realy do that at this moment? */
738 err = mailimap_expunge(m_imap); 741 err = mailimap_expunge(m_imap);
739 if (err != MAILIMAP_NO_ERROR) { 742 if (err != MAILIMAP_NO_ERROR) {
740 qDebug("error deleting mail: %s",m_imap->imap_response); 743 qDebug("error deleting mail: %s",m_imap->imap_response);
741 } 744 }
742 qDebug("Delete successfull %s",m_imap->imap_response); 745 qDebug("Delete successfull %s",m_imap->imap_response);
743} 746}
744 747
745void IMAPwrapper::answeredMail(const RecMail&mail) 748void IMAPwrapper::answeredMail(const RecMail&mail)
746{ 749{
747 mailimap_flag_list*flist; 750 mailimap_flag_list*flist;
748 mailimap_set *set; 751 mailimap_set *set;
749 mailimap_store_att_flags * store_flags; 752 mailimap_store_att_flags * store_flags;
750 int err; 753 int err;
751 login(); 754 login();
752 if (!m_imap) { 755 if (!m_imap) {
753 return; 756 return;
754 } 757 }
755 const char *mb = mail.getMbox().latin1(); 758 const char *mb = mail.getMbox().latin1();
756 err = mailimap_select( m_imap, (char*)mb); 759 err = mailimap_select( m_imap, (char*)mb);
757 if ( err != MAILIMAP_NO_ERROR ) { 760 if ( err != MAILIMAP_NO_ERROR ) {
758 qDebug("error selecting mailbox for mark: %s",m_imap->imap_response); 761 qDebug("error selecting mailbox for mark: %s",m_imap->imap_response);
759 return; 762 return;
760 } 763 }
761 flist = mailimap_flag_list_new_empty(); 764 flist = mailimap_flag_list_new_empty();
762 mailimap_flag_list_add(flist,mailimap_flag_new_answered()); 765 mailimap_flag_list_add(flist,mailimap_flag_new_answered());
763 store_flags = mailimap_store_att_flags_new_set_flags(flist); 766 store_flags = mailimap_store_att_flags_new_add_flags(flist);
764 set = mailimap_set_new_single(mail.getNumber()); 767 set = mailimap_set_new_single(mail.getNumber());
765 err = mailimap_store(m_imap,set,store_flags); 768 err = mailimap_store(m_imap,set,store_flags);
766 mailimap_set_free( set ); 769 mailimap_set_free( set );
767 mailimap_store_att_flags_free(store_flags); 770 mailimap_store_att_flags_free(store_flags);
768 771
769 if (err != MAILIMAP_NO_ERROR) { 772 if (err != MAILIMAP_NO_ERROR) {
770 qDebug("error marking mail: %s",m_imap->imap_response); 773 qDebug("error marking mail: %s",m_imap->imap_response);
771 return; 774 return;
772 } 775 }
773} 776}
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 0ce2c6c..ad95384 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -1,773 +1,776 @@
1 1
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include "imapwrapper.h" 4#include "imapwrapper.h"
5#include "mailtypes.h" 5#include "mailtypes.h"
6#include <libetpan/mailimap.h> 6#include <libetpan/mailimap.h>
7 7
8IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 8IMAPwrapper::IMAPwrapper( IMAPaccount *a )
9 : AbstractMail() 9 : AbstractMail()
10{ 10{
11 account = a; 11 account = a;
12 m_imap = 0; 12 m_imap = 0;
13} 13}
14 14
15IMAPwrapper::~IMAPwrapper() 15IMAPwrapper::~IMAPwrapper()
16{ 16{
17 logout(); 17 logout();
18} 18}
19 19
20void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 20void IMAPwrapper::imap_progress( size_t current, size_t maximum )
21{ 21{
22 qDebug( "IMAP: %i of %i", current, maximum ); 22 qDebug( "IMAP: %i of %i", current, maximum );
23} 23}
24 24
25void IMAPwrapper::login() 25void IMAPwrapper::login()
26{ 26{
27 const char *server, *user, *pass; 27 const char *server, *user, *pass;
28 uint16_t port; 28 uint16_t port;
29 int err = MAILIMAP_NO_ERROR; 29 int err = MAILIMAP_NO_ERROR;
30 30
31 /* we are connected this moment */ 31 /* we are connected this moment */
32 /* TODO: setup a timer holding the line or if connection closed - delete the value */ 32 /* TODO: setup a timer holding the line or if connection closed - delete the value */
33 if (m_imap) { 33 if (m_imap) {
34 mailstream_flush(m_imap->imap_stream); 34 mailstream_flush(m_imap->imap_stream);
35 return; 35 return;
36 } 36 }
37 server = account->getServer().latin1(); 37 server = account->getServer().latin1();
38 port = account->getPort().toUInt(); 38 port = account->getPort().toUInt();
39 user = account->getUser().latin1(); 39 user = account->getUser().latin1();
40 pass = account->getPassword().latin1(); 40 pass = account->getPassword().latin1();
41 41
42 m_imap = mailimap_new( 20, &imap_progress ); 42 m_imap = mailimap_new( 20, &imap_progress );
43 /* connect */ 43 /* connect */
44 if (account->getSSL()) { 44 if (account->getSSL()) {
45 err = mailimap_ssl_connect( m_imap, (char*)server, port ); 45 err = mailimap_ssl_connect( m_imap, (char*)server, port );
46 } else { 46 } else {
47 err = mailimap_socket_connect( m_imap, (char*)server, port ); 47 err = mailimap_socket_connect( m_imap, (char*)server, port );
48 } 48 }
49 49
50 if ( err != MAILIMAP_NO_ERROR && 50 if ( err != MAILIMAP_NO_ERROR &&
51 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 51 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
52 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 52 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
53 qDebug("error connecting server: %s",m_imap->imap_response); 53 qDebug("error connecting server: %s",m_imap->imap_response);
54 mailimap_free( m_imap ); 54 mailimap_free( m_imap );
55 m_imap = 0; 55 m_imap = 0;
56 return; 56 return;
57 } 57 }
58 58
59 /* login */ 59 /* login */
60 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); 60 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
61 if ( err != MAILIMAP_NO_ERROR ) { 61 if ( err != MAILIMAP_NO_ERROR ) {
62 qDebug("error logging in imap: %s",m_imap->imap_response); 62 qDebug("error logging in imap: %s",m_imap->imap_response);
63 err = mailimap_close( m_imap ); 63 err = mailimap_close( m_imap );
64 mailimap_free( m_imap ); 64 mailimap_free( m_imap );
65 m_imap = 0; 65 m_imap = 0;
66 } 66 }
67} 67}
68 68
69void IMAPwrapper::logout() 69void IMAPwrapper::logout()
70{ 70{
71 int err = MAILIMAP_NO_ERROR; 71 int err = MAILIMAP_NO_ERROR;
72 if (!m_imap) return; 72 if (!m_imap) return;
73 err = mailimap_logout( m_imap ); 73 err = mailimap_logout( m_imap );
74 err = mailimap_close( m_imap ); 74 err = mailimap_close( m_imap );
75 mailimap_free( m_imap ); 75 mailimap_free( m_imap );
76 m_imap = 0; 76 m_imap = 0;
77} 77}
78 78
79void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) 79void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
80{ 80{
81 const char *mb; 81 const char *mb;
82 int err = MAILIMAP_NO_ERROR; 82 int err = MAILIMAP_NO_ERROR;
83 clist *result; 83 clist *result;
84 clistcell *current; 84 clistcell *current;
85// mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; 85// mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize;
86 mailimap_fetch_type *fetchType; 86 mailimap_fetch_type *fetchType;
87 mailimap_set *set; 87 mailimap_set *set;
88 88
89 mb = mailbox.latin1(); 89 mb = mailbox.latin1();
90 login(); 90 login();
91 if (!m_imap) { 91 if (!m_imap) {
92 return; 92 return;
93 } 93 }
94 /* select mailbox READONLY for operations */ 94 /* select mailbox READONLY for operations */
95 err = mailimap_examine( m_imap, (char*)mb); 95 err = mailimap_examine( m_imap, (char*)mb);
96 if ( err != MAILIMAP_NO_ERROR ) { 96 if ( err != MAILIMAP_NO_ERROR ) {
97 qDebug("error selecting mailbox: %s",m_imap->imap_response); 97 qDebug("error selecting mailbox: %s",m_imap->imap_response);
98 return; 98 return;
99 } 99 }
100 100
101 int last = m_imap->imap_selection_info->sel_exists; 101 int last = m_imap->imap_selection_info->sel_exists;
102 102
103 if (last == 0) { 103 if (last == 0) {
104 qDebug("mailbox has no mails"); 104 qDebug("mailbox has no mails");
105 return; 105 return;
106 } 106 }
107 107
108 result = clist_new(); 108 result = clist_new();
109 /* the range has to start at 1!!! not with 0!!!! */ 109 /* the range has to start at 1!!! not with 0!!!! */
110 set = mailimap_set_new_interval( 1, last ); 110 set = mailimap_set_new_interval( 1, last );
111 fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); 111 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
112 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); 112 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
113 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); 113 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
114 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); 114 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
115 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); 115 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
116 116
117 err = mailimap_fetch( m_imap, set, fetchType, &result ); 117 err = mailimap_fetch( m_imap, set, fetchType, &result );
118 mailimap_set_free( set ); 118 mailimap_set_free( set );
119 mailimap_fetch_type_free( fetchType ); 119 mailimap_fetch_type_free( fetchType );
120 120
121 QString date,subject,from; 121 QString date,subject,from;
122 122
123 if ( err == MAILIMAP_NO_ERROR ) { 123 if ( err == MAILIMAP_NO_ERROR ) {
124 124
125 mailimap_msg_att * msg_att; 125 mailimap_msg_att * msg_att;
126 int i = 0; 126 int i = 0;
127 for (current = clist_begin(result); current != 0; current=clist_next(current)) { 127 for (current = clist_begin(result); current != 0; current=clist_next(current)) {
128 ++i; 128 ++i;
129 msg_att = (mailimap_msg_att*)current->data; 129 msg_att = (mailimap_msg_att*)current->data;
130 RecMail*m = parse_list_result(msg_att); 130 RecMail*m = parse_list_result(msg_att);
131 if (m) { 131 if (m) {
132 m->setNumber(i); 132 m->setNumber(i);
133 m->setMbox(mailbox); 133 m->setMbox(mailbox);
134 m->setWrapper(this); 134 m->setWrapper(this);
135 target.append(m); 135 target.append(m);
136 } 136 }
137 } 137 }
138 } else { 138 } else {
139 qDebug("Error fetching headers: %s",m_imap->imap_response); 139 qDebug("Error fetching headers: %s",m_imap->imap_response);
140 } 140 }
141 mailimap_fetch_list_free(result); 141 mailimap_fetch_list_free(result);
142} 142}
143 143
144QList<Folder>* IMAPwrapper::listFolders() 144QList<Folder>* IMAPwrapper::listFolders()
145{ 145{
146 const char *path, *mask; 146 const char *path, *mask;
147 int err = MAILIMAP_NO_ERROR; 147 int err = MAILIMAP_NO_ERROR;
148 clist *result; 148 clist *result;
149 clistcell *current; 149 clistcell *current;
150 150
151 QList<Folder> * folders = new QList<Folder>(); 151 QList<Folder> * folders = new QList<Folder>();
152 folders->setAutoDelete( false ); 152 folders->setAutoDelete( false );
153 login(); 153 login();
154 if (!m_imap) { 154 if (!m_imap) {
155 return folders; 155 return folders;
156 } 156 }
157 157
158/* 158/*
159 * First we have to check for INBOX 'cause it sometimes it's not inside the path. 159 * First we have to check for INBOX 'cause it sometimes it's not inside the path.
160 * We must not forget to filter them out in next loop! 160 * We must not forget to filter them out in next loop!
161 * it seems like ugly code. and yes - it is ugly code. but the best way. 161 * it seems like ugly code. and yes - it is ugly code. but the best way.
162 */ 162 */
163 QString temp; 163 QString temp;
164 mask = "INBOX" ; 164 mask = "INBOX" ;
165 result = clist_new(); 165 result = clist_new();
166 mailimap_mailbox_list *list; 166 mailimap_mailbox_list *list;
167 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); 167 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result );
168 if ( err == MAILIMAP_NO_ERROR ) { 168 if ( err == MAILIMAP_NO_ERROR ) {
169 current = result->first; 169 current = result->first;
170 for ( int i = result->count; i > 0; i-- ) { 170 for ( int i = result->count; i > 0; i-- ) {
171 list = (mailimap_mailbox_list *) current->data; 171 list = (mailimap_mailbox_list *) current->data;
172 // it is better use the deep copy mechanism of qt itself 172 // it is better use the deep copy mechanism of qt itself
173 // instead of using strdup! 173 // instead of using strdup!
174 temp = list->mb_name; 174 temp = list->mb_name;
175 folders->append( new IMAPFolder(temp)); 175 folders->append( new IMAPFolder(temp));
176 current = current->next; 176 current = current->next;
177 } 177 }
178 } else { 178 } else {
179 qDebug("error fetching folders: %s",m_imap->imap_response); 179 qDebug("error fetching folders: %s",m_imap->imap_response);
180 } 180 }
181 mailimap_list_result_free( result ); 181 mailimap_list_result_free( result );
182 182
183/* 183/*
184 * second stage - get the other then inbox folders 184 * second stage - get the other then inbox folders
185 */ 185 */
186 mask = "*" ; 186 mask = "*" ;
187 path = account->getPrefix().latin1(); 187 path = account->getPrefix().latin1();
188 if (!path) path = ""; 188 if (!path) path = "";
189 result = clist_new(); 189 result = clist_new();
190 qDebug(path); 190 qDebug(path);
191 bool selectable = true; 191 bool selectable = true;
192 mailimap_mbx_list_flags*bflags; 192 mailimap_mbx_list_flags*bflags;
193 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); 193 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
194 if ( err == MAILIMAP_NO_ERROR ) { 194 if ( err == MAILIMAP_NO_ERROR ) {
195 current = result->first; 195 current = result->first;
196 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { 196 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) {
197 list = (mailimap_mailbox_list *) current->data; 197 list = (mailimap_mailbox_list *) current->data;
198 // it is better use the deep copy mechanism of qt itself 198 // it is better use the deep copy mechanism of qt itself
199 // instead of using strdup! 199 // instead of using strdup!
200 temp = list->mb_name; 200 temp = list->mb_name;
201 if (temp.lower()=="inbox") 201 if (temp.lower()=="inbox")
202 continue; 202 continue;
203 if (temp.lower()==account->getPrefix().lower()) 203 if (temp.lower()==account->getPrefix().lower())
204 continue; 204 continue;
205 if ( (bflags = list->mb_flag) ) { 205 if ( (bflags = list->mb_flag) ) {
206 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 206 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
207 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 207 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
208 } 208 }
209 folders->append(new IMAPFolder(temp,selectable,account->getPrefix())); 209 folders->append(new IMAPFolder(temp,selectable,account->getPrefix()));
210 } 210 }
211 } else { 211 } else {
212 qDebug("error fetching folders %s",m_imap->imap_response); 212 qDebug("error fetching folders %s",m_imap->imap_response);
213 } 213 }
214 mailimap_list_result_free( result ); 214 mailimap_list_result_free( result );
215 return folders; 215 return folders;
216} 216}
217 217
218RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) 218RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
219{ 219{
220 RecMail * m = 0; 220 RecMail * m = 0;
221 mailimap_msg_att_item *item=0; 221 mailimap_msg_att_item *item=0;
222 clistcell *current,*c,*cf; 222 clistcell *current,*c,*cf;
223 mailimap_msg_att_dynamic*flist; 223 mailimap_msg_att_dynamic*flist;
224 mailimap_flag_fetch*cflag; 224 mailimap_flag_fetch*cflag;
225 int size; 225 int size;
226 QBitArray mFlags(7); 226 QBitArray mFlags(7);
227 QStringList addresslist; 227 QStringList addresslist;
228 228
229 if (!m_att) { 229 if (!m_att) {
230 return m; 230 return m;
231 } 231 }
232 m = new RecMail(); 232 m = new RecMail();
233 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { 233 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
234 current = c; 234 current = c;
235 size = 0; 235 size = 0;
236 item = (mailimap_msg_att_item*)current->data; 236 item = (mailimap_msg_att_item*)current->data;
237 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { 237 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
238 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; 238 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
239 if (!flist->att_list) { 239 if (!flist->att_list) {
240 continue; 240 continue;
241 } 241 }
242 cf = flist->att_list->first; 242 cf = flist->att_list->first;
243 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { 243 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
244 cflag = (mailimap_flag_fetch*)cf->data; 244 cflag = (mailimap_flag_fetch*)cf->data;
245 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { 245 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
246 switch (cflag->fl_flag->fl_type) { 246 switch (cflag->fl_flag->fl_type) {
247 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ 247 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
248 mFlags.setBit(FLAG_ANSWERED); 248 mFlags.setBit(FLAG_ANSWERED);
249 break; 249 break;
250 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ 250 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */
251 mFlags.setBit(FLAG_FLAGGED); 251 mFlags.setBit(FLAG_FLAGGED);
252 break; 252 break;
253 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ 253 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */
254 mFlags.setBit(FLAG_DELETED); 254 mFlags.setBit(FLAG_DELETED);
255 break; 255 break;
256 case MAILIMAP_FLAG_SEEN: /* \Seen flag */ 256 case MAILIMAP_FLAG_SEEN: /* \Seen flag */
257 mFlags.setBit(FLAG_SEEN); 257 mFlags.setBit(FLAG_SEEN);
258 break; 258 break;
259 case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ 259 case MAILIMAP_FLAG_DRAFT: /* \Draft flag */
260 mFlags.setBit(FLAG_DRAFT); 260 mFlags.setBit(FLAG_DRAFT);
261 break; 261 break;
262 case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ 262 case MAILIMAP_FLAG_KEYWORD: /* keyword flag */
263 break; 263 break;
264 case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ 264 case MAILIMAP_FLAG_EXTENSION: /* \extension flag */
265 break; 265 break;
266 default: 266 default:
267 break; 267 break;
268 } 268 }
269 } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { 269 } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
270 mFlags.setBit(FLAG_RECENT); 270 mFlags.setBit(FLAG_RECENT);
271 } 271 }
272 } 272 }
273 continue; 273 continue;
274 } 274 }
275 if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { 275 if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) {
276 mailimap_envelope * head = item->att_data.att_static->att_data.att_env; 276 mailimap_envelope * head = item->att_data.att_static->att_data.att_env;
277 m->setDate(head->env_date); 277 m->setDate(head->env_date);
278 m->setSubject(head->env_subject); 278 m->setSubject(head->env_subject);
279 if (head->env_from!=NULL) { 279 if (head->env_from!=NULL) {
280 addresslist = address_list_to_stringlist(head->env_from->frm_list); 280 addresslist = address_list_to_stringlist(head->env_from->frm_list);
281 if (addresslist.count()) { 281 if (addresslist.count()) {
282 m->setFrom(addresslist.first()); 282 m->setFrom(addresslist.first());
283 } 283 }
284 } 284 }
285 if (head->env_to!=NULL) { 285 if (head->env_to!=NULL) {
286 addresslist = address_list_to_stringlist(head->env_to->to_list); 286 addresslist = address_list_to_stringlist(head->env_to->to_list);
287 m->setTo(addresslist); 287 m->setTo(addresslist);
288 } 288 }
289 if (head->env_cc!=NULL) { 289 if (head->env_cc!=NULL) {
290 addresslist = address_list_to_stringlist(head->env_cc->cc_list); 290 addresslist = address_list_to_stringlist(head->env_cc->cc_list);
291 m->setCC(addresslist); 291 m->setCC(addresslist);
292 } 292 }
293 if (head->env_bcc!=NULL) { 293 if (head->env_bcc!=NULL) {
294 addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); 294 addresslist = address_list_to_stringlist(head->env_bcc->bcc_list);
295 m->setBcc(addresslist); 295 m->setBcc(addresslist);
296 } 296 }
297 if (head->env_reply_to!=NULL) { 297 if (head->env_reply_to!=NULL) {
298 addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); 298 addresslist = address_list_to_stringlist(head->env_reply_to->rt_list);
299 if (addresslist.count()) { 299 if (addresslist.count()) {
300 m->setReplyto(addresslist.first()); 300 m->setReplyto(addresslist.first());
301 } 301 }
302 } 302 }
303 m->setMsgid(QString(head->env_message_id)); 303 m->setMsgid(QString(head->env_message_id));
304 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { 304 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
305 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; 305 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
306#if 0 306#if 0
307 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); 307 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
308 qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); 308 qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec);
309 qDebug(da.toString()); 309 qDebug(da.toString());
310#endif 310#endif
311 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { 311 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
312 size = item->att_data.att_static->att_data.att_rfc822_size; 312 size = item->att_data.att_static->att_data.att_rfc822_size;
313 } 313 }
314 } 314 }
315 /* msg is already deleted */ 315 /* msg is already deleted */
316 if (mFlags.testBit(FLAG_DELETED) && m) { 316 if (mFlags.testBit(FLAG_DELETED) && m) {
317 delete m; 317 delete m;
318 m = 0; 318 m = 0;
319 } 319 }
320 if (m) { 320 if (m) {
321 m->setFlags(mFlags); 321 m->setFlags(mFlags);
322 m->setMsgsize(size); 322 m->setMsgsize(size);
323 } 323 }
324 return m; 324 return m;
325} 325}
326 326
327RecBody IMAPwrapper::fetchBody(const RecMail&mail) 327RecBody IMAPwrapper::fetchBody(const RecMail&mail)
328{ 328{
329 RecBody body; 329 RecBody body;
330 const char *mb; 330 const char *mb;
331 int err = MAILIMAP_NO_ERROR; 331 int err = MAILIMAP_NO_ERROR;
332 clist *result; 332 clist *result;
333 clistcell *current; 333 clistcell *current;
334 mailimap_fetch_att *fetchAtt; 334 mailimap_fetch_att *fetchAtt;
335 mailimap_fetch_type *fetchType; 335 mailimap_fetch_type *fetchType;
336 mailimap_set *set; 336 mailimap_set *set;
337 mailimap_body*body_desc; 337 mailimap_body*body_desc;
338 338
339 mb = mail.getMbox().latin1(); 339 mb = mail.getMbox().latin1();
340 340
341 login(); 341 login();
342 if (!m_imap) { 342 if (!m_imap) {
343 return body; 343 return body;
344 } 344 }
345 345
346 err = mailimap_select( m_imap, (char*)mb); 346 err = mailimap_select( m_imap, (char*)mb);
347 if ( err != MAILIMAP_NO_ERROR ) { 347 if ( err != MAILIMAP_NO_ERROR ) {
348 qDebug("error selecting mailbox: %s",m_imap->imap_response); 348 qDebug("error selecting mailbox: %s",m_imap->imap_response);
349 return body; 349 return body;
350 } 350 }
351 351
352 result = clist_new(); 352 result = clist_new();
353 /* the range has to start at 1!!! not with 0!!!! */ 353 /* the range has to start at 1!!! not with 0!!!! */
354 set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); 354 set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
355 fetchAtt = mailimap_fetch_att_new_bodystructure(); 355 fetchAtt = mailimap_fetch_att_new_bodystructure();
356 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); 356 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
357 err = mailimap_fetch( m_imap, set, fetchType, &result ); 357 err = mailimap_fetch( m_imap, set, fetchType, &result );
358 mailimap_set_free( set ); 358 mailimap_set_free( set );
359 mailimap_fetch_type_free( fetchType ); 359 mailimap_fetch_type_free( fetchType );
360 360
361 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 361 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
362 mailimap_msg_att * msg_att; 362 mailimap_msg_att * msg_att;
363 msg_att = (mailimap_msg_att*)current->data; 363 msg_att = (mailimap_msg_att*)current->data;
364 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; 364 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data;
365 body_desc = item->att_data.att_static->att_data.att_body; 365 body_desc = item->att_data.att_static->att_data.att_body;
366 if (body_desc->bd_type==MAILIMAP_BODY_1PART) { 366 if (body_desc->bd_type==MAILIMAP_BODY_1PART) {
367 searchBodyText(mail,body_desc->bd_data.bd_body_1part,body); 367 searchBodyText(mail,body_desc->bd_data.bd_body_1part,body);
368 } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) { 368 } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) {
369 qDebug("Mulitpart mail"); 369 qDebug("Mulitpart mail");
370 searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); 370 searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body);
371 } 371 }
372 } else { 372 } else {
373 qDebug("error fetching body: %s",m_imap->imap_response); 373 qDebug("error fetching body: %s",m_imap->imap_response);
374 } 374 }
375 mailimap_fetch_list_free(result); 375 mailimap_fetch_list_free(result);
376 return body; 376 return body;
377} 377}
378 378
379/* this routine is just called when the mail has only ONE part. 379/* this routine is just called when the mail has only ONE part.
380 for filling the parts of a multi-part-message there are other 380 for filling the parts of a multi-part-message there are other
381 routines 'cause we can not simply fetch the whole body. */ 381 routines 'cause we can not simply fetch the whole body. */
382void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) 382void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body)
383{ 383{
384 if (!mailDescription) { 384 if (!mailDescription) {
385 return; 385 return;
386 } 386 }
387 QString sub,body_text; 387 QString sub,body_text;
388 RecPart singlePart; 388 RecPart singlePart;
389 QValueList<int> path; 389 QValueList<int> path;
390 fillSinglePart(singlePart,mailDescription); 390 fillSinglePart(singlePart,mailDescription);
391 switch (mailDescription->bd_type) { 391 switch (mailDescription->bd_type) {
392 case MAILIMAP_BODY_TYPE_1PART_MSG: 392 case MAILIMAP_BODY_TYPE_1PART_MSG:
393 path.append(1); 393 path.append(1);
394 body_text = fetchPart(mail,path,true); 394 body_text = fetchPart(mail,path,true);
395 target_body.setBodytext(body_text); 395 target_body.setBodytext(body_text);
396 target_body.setDescription(singlePart); 396 target_body.setDescription(singlePart);
397 break; 397 break;
398 case MAILIMAP_BODY_TYPE_1PART_TEXT: 398 case MAILIMAP_BODY_TYPE_1PART_TEXT:
399 qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); 399 qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text);
400 path.append(1); 400 path.append(1);
401 body_text = fetchPart(mail,path,true); 401 body_text = fetchPart(mail,path,true);
402 target_body.setBodytext(body_text); 402 target_body.setBodytext(body_text);
403 target_body.setDescription(singlePart); 403 target_body.setDescription(singlePart);
404 break; 404 break;
405 case MAILIMAP_BODY_TYPE_1PART_BASIC: 405 case MAILIMAP_BODY_TYPE_1PART_BASIC:
406 qDebug("Single attachment"); 406 qDebug("Single attachment");
407 target_body.setBodytext(""); 407 target_body.setBodytext("");
408 target_body.addPart(singlePart); 408 target_body.addPart(singlePart);
409 break; 409 break;
410 default: 410 default:
411 break; 411 break;
412 } 412 }
413 413
414 return; 414 return;
415} 415}
416 416
417QStringList IMAPwrapper::address_list_to_stringlist(clist*list) 417QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
418{ 418{
419 QStringList l; 419 QStringList l;
420 QString from; 420 QString from;
421 bool named_from; 421 bool named_from;
422 clistcell *current = NULL; 422 clistcell *current = NULL;
423 mailimap_address * current_address=NULL; 423 mailimap_address * current_address=NULL;
424 if (!list) { 424 if (!list) {
425 return l; 425 return l;
426 } 426 }
427 unsigned int count = 0; 427 unsigned int count = 0;
428 for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { 428 for (current=clist_begin(list);current!= NULL;current=clist_next(current)) {
429 from = ""; 429 from = "";
430 named_from = false; 430 named_from = false;
431 current_address=(mailimap_address*)current->data; 431 current_address=(mailimap_address*)current->data;
432 if (current_address->ad_personal_name){ 432 if (current_address->ad_personal_name){
433 from+=QString(current_address->ad_personal_name); 433 from+=QString(current_address->ad_personal_name);
434 from+=" "; 434 from+=" ";
435 named_from = true; 435 named_from = true;
436 } 436 }
437 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { 437 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
438 from+="<"; 438 from+="<";
439 } 439 }
440 if (current_address->ad_mailbox_name) { 440 if (current_address->ad_mailbox_name) {
441 from+=QString(current_address->ad_mailbox_name); 441 from+=QString(current_address->ad_mailbox_name);
442 from+="@"; 442 from+="@";
443 } 443 }
444 if (current_address->ad_host_name) { 444 if (current_address->ad_host_name) {
445 from+=QString(current_address->ad_host_name); 445 from+=QString(current_address->ad_host_name);
446 } 446 }
447 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { 447 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
448 from+=">"; 448 from+=">";
449 } 449 }
450 l.append(QString(from)); 450 l.append(QString(from));
451 if (++count > 99) { 451 if (++count > 99) {
452 break; 452 break;
453 } 453 }
454 } 454 }
455 return l; 455 return l;
456} 456}
457 457
458QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) 458QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call)
459{ 459{
460 QString body(""); 460 QString body("");
461 const char*mb; 461 const char*mb;
462 int err; 462 int err;
463 mailimap_fetch_type *fetchType; 463 mailimap_fetch_type *fetchType;
464 mailimap_set *set; 464 mailimap_set *set;
465 clistcell*current,*cur; 465 clistcell*current,*cur;
466 466
467 login(); 467 login();
468 if (!m_imap) { 468 if (!m_imap) {
469 return body; 469 return body;
470 } 470 }
471 if (!internal_call) { 471 if (!internal_call) {
472 mb = mail.getMbox().latin1(); 472 mb = mail.getMbox().latin1();
473 err = mailimap_select( m_imap, (char*)mb); 473 err = mailimap_select( m_imap, (char*)mb);
474 if ( err != MAILIMAP_NO_ERROR ) { 474 if ( err != MAILIMAP_NO_ERROR ) {
475 qDebug("error selecting mailbox: %s",m_imap->imap_response); 475 qDebug("error selecting mailbox: %s",m_imap->imap_response);
476 return body; 476 return body;
477 } 477 }
478 } 478 }
479 set = mailimap_set_new_single(mail.getNumber()); 479 set = mailimap_set_new_single(mail.getNumber());
480 clist*id_list=clist_new(); 480 clist*id_list=clist_new();
481 for (unsigned j=0; j < path.count();++j) { 481 for (unsigned j=0; j < path.count();++j) {
482 uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); 482 uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id));
483 *p_id = path[j]; 483 *p_id = path[j];
484 clist_append(id_list,p_id); 484 clist_append(id_list,p_id);
485 } 485 }
486 mailimap_section_part * section_part = mailimap_section_part_new(id_list); 486 mailimap_section_part * section_part = mailimap_section_part_new(id_list);
487 mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); 487 mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL);
488 mailimap_section * section = mailimap_section_new(section_spec); 488 mailimap_section * section = mailimap_section_new(section_spec);
489 mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); 489 mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section);
490 490
491 fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); 491 fetchType = mailimap_fetch_type_new_fetch_att(fetch_att);
492 492
493 clist*result = clist_new(); 493 clist*result = clist_new();
494 494
495 err = mailimap_fetch( m_imap, set, fetchType, &result ); 495 err = mailimap_fetch( m_imap, set, fetchType, &result );
496 mailimap_set_free( set ); 496 mailimap_set_free( set );
497 mailimap_fetch_type_free( fetchType ); 497 mailimap_fetch_type_free( fetchType );
498 498
499 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 499 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
500 mailimap_msg_att * msg_att; 500 mailimap_msg_att * msg_att;
501 msg_att = (mailimap_msg_att*)current->data; 501 msg_att = (mailimap_msg_att*)current->data;
502 mailimap_msg_att_item*msg_att_item; 502 mailimap_msg_att_item*msg_att_item;
503 for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { 503 for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) {
504 msg_att_item = (mailimap_msg_att_item*)clist_content(cur); 504 msg_att_item = (mailimap_msg_att_item*)clist_content(cur);
505 if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { 505 if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) {
506 if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { 506 if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) {
507 char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; 507 char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part;
508 msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; 508 msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
509 if (text) { 509 if (text) {
510 body = QString(text); 510 body = QString(text);
511 free(text); 511 free(text);
512 } else { 512 } else {
513 body = ""; 513 body = "";
514 } 514 }
515 } 515 }
516 } 516 }
517 } 517 }
518 518
519 } else { 519 } else {
520 qDebug("error fetching text: %s",m_imap->imap_response); 520 qDebug("error fetching text: %s",m_imap->imap_response);
521 } 521 }
522 mailimap_fetch_list_free(result); 522 mailimap_fetch_list_free(result);
523 return body; 523 return body;
524} 524}
525 525
526void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList) 526void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList)
527{ 527{
528 /* current_recursion is for avoiding ugly mails which has a to deep body-structure */ 528 /* current_recursion is for avoiding ugly mails which has a to deep body-structure */
529 if (!mailDescription||current_recursion==10) { 529 if (!mailDescription||current_recursion==10) {
530 return; 530 return;
531 } 531 }
532 clistcell*current; 532 clistcell*current;
533 mailimap_body*current_body; 533 mailimap_body*current_body;
534 unsigned int count = 0; 534 unsigned int count = 0;
535 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { 535 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
536 /* the point in the message */ 536 /* the point in the message */
537 ++count; 537 ++count;
538 current_body = (mailimap_body*)current->data; 538 current_body = (mailimap_body*)current->data;
539 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 539 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
540 QValueList<int>clist = recList; 540 QValueList<int>clist = recList;
541 clist.append(count); 541 clist.append(count);
542 searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,clist); 542 searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,clist);
543 } else if (current_body->bd_type==MAILIMAP_BODY_1PART){ 543 } else if (current_body->bd_type==MAILIMAP_BODY_1PART){
544 RecPart currentPart; 544 RecPart currentPart;
545 fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); 545 fillSinglePart(currentPart,current_body->bd_data.bd_body_1part);
546 QValueList<int>clist = recList; 546 QValueList<int>clist = recList;
547 clist.append(count); 547 clist.append(count);
548 /* important: Check for is NULL 'cause a body can be empty! */ 548 /* important: Check for is NULL 'cause a body can be empty! */
549 if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { 549 if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) {
550 QString body_text = fetchPart(mail,clist,true); 550 QString body_text = fetchPart(mail,clist,true);
551 target_body.setDescription(currentPart); 551 target_body.setDescription(currentPart);
552 target_body.setBodytext(body_text); 552 target_body.setBodytext(body_text);
553 } else { 553 } else {
554 QString id(""); 554 QString id("");
555 for (unsigned int j = 0; j < clist.count();++j) { 555 for (unsigned int j = 0; j < clist.count();++j) {
556 id+=(j>0?" ":""); 556 id+=(j>0?" ":"");
557 id+=QString("%1").arg(clist[j]); 557 id+=QString("%1").arg(clist[j]);
558 } 558 }
559 qDebug("ID= %s",id.latin1()); 559 qDebug("ID= %s",id.latin1());
560 currentPart.setIdentifier(id); 560 currentPart.setIdentifier(id);
561 currentPart.setPositionlist(clist); 561 currentPart.setPositionlist(clist);
562 target_body.addPart(currentPart); 562 target_body.addPart(currentPart);
563 } 563 }
564 } 564 }
565 } 565 }
566} 566}
567 567
568void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) 568void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description)
569{ 569{
570 if (!Description) { 570 if (!Description) {
571 return; 571 return;
572 } 572 }
573 switch (Description->bd_type) { 573 switch (Description->bd_type) {
574 case MAILIMAP_BODY_TYPE_1PART_TEXT: 574 case MAILIMAP_BODY_TYPE_1PART_TEXT:
575 target_part.setType("text"); 575 target_part.setType("text");
576 fillSingleTextPart(target_part,Description->bd_data.bd_type_text); 576 fillSingleTextPart(target_part,Description->bd_data.bd_type_text);
577 break; 577 break;
578 case MAILIMAP_BODY_TYPE_1PART_BASIC: 578 case MAILIMAP_BODY_TYPE_1PART_BASIC:
579 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); 579 fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic);
580 break; 580 break;
581 case MAILIMAP_BODY_TYPE_1PART_MSG: 581 case MAILIMAP_BODY_TYPE_1PART_MSG:
582 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); 582 fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg);
583 break; 583 break;
584 default: 584 default:
585 break; 585 break;
586 } 586 }
587} 587}
588 588
589void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) 589void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which)
590{ 590{
591 if (!which) { 591 if (!which) {
592 return; 592 return;
593 } 593 }
594 QString sub; 594 QString sub;
595 sub = which->bd_media_text; 595 sub = which->bd_media_text;
596 target_part.setSubtype(sub.lower()); 596 target_part.setSubtype(sub.lower());
597 target_part.setLines(which->bd_lines); 597 target_part.setLines(which->bd_lines);
598 fillBodyFields(target_part,which->bd_fields); 598 fillBodyFields(target_part,which->bd_fields);
599} 599}
600 600
601void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) 601void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which)
602{ 602{
603 if (!which) { 603 if (!which) {
604 return; 604 return;
605 } 605 }
606// QString sub; 606// QString sub;
607// sub = which->bd_media_text; 607// sub = which->bd_media_text;
608// target_part.setSubtype(sub.lower()); 608// target_part.setSubtype(sub.lower());
609 qDebug("Message part"); 609 qDebug("Message part");
610 /* we set this type to text/plain */ 610 /* we set this type to text/plain */
611 target_part.setType("text"); 611 target_part.setType("text");
612 target_part.setSubtype("plain"); 612 target_part.setSubtype("plain");
613 target_part.setLines(which->bd_lines); 613 target_part.setLines(which->bd_lines);
614 fillBodyFields(target_part,which->bd_fields); 614 fillBodyFields(target_part,which->bd_fields);
615} 615}
616 616
617void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) 617void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which)
618{ 618{
619 if (!which) { 619 if (!which) {
620 return; 620 return;
621 } 621 }
622 QString type,sub; 622 QString type,sub;
623 switch (which->bd_media_basic->med_type) { 623 switch (which->bd_media_basic->med_type) {
624 case MAILIMAP_MEDIA_BASIC_APPLICATION: 624 case MAILIMAP_MEDIA_BASIC_APPLICATION:
625 type = "application"; 625 type = "application";
626 break; 626 break;
627 case MAILIMAP_MEDIA_BASIC_AUDIO: 627 case MAILIMAP_MEDIA_BASIC_AUDIO:
628 type = "audio"; 628 type = "audio";
629 break; 629 break;
630 case MAILIMAP_MEDIA_BASIC_IMAGE: 630 case MAILIMAP_MEDIA_BASIC_IMAGE:
631 type = "image"; 631 type = "image";
632 break; 632 break;
633 case MAILIMAP_MEDIA_BASIC_MESSAGE: 633 case MAILIMAP_MEDIA_BASIC_MESSAGE:
634 type = "message"; 634 type = "message";
635 break; 635 break;
636 case MAILIMAP_MEDIA_BASIC_VIDEO: 636 case MAILIMAP_MEDIA_BASIC_VIDEO:
637 type = "video"; 637 type = "video";
638 break; 638 break;
639 case MAILIMAP_MEDIA_BASIC_OTHER: 639 case MAILIMAP_MEDIA_BASIC_OTHER:
640 default: 640 default:
641 if (which->bd_media_basic->med_basic_type) { 641 if (which->bd_media_basic->med_basic_type) {
642 type = which->bd_media_basic->med_basic_type; 642 type = which->bd_media_basic->med_basic_type;
643 } else { 643 } else {
644 type = ""; 644 type = "";
645 } 645 }
646 break; 646 break;
647 } 647 }
648 if (which->bd_media_basic->med_subtype) { 648 if (which->bd_media_basic->med_subtype) {
649 sub = which->bd_media_basic->med_subtype; 649 sub = which->bd_media_basic->med_subtype;
650 } else { 650 } else {
651 sub = ""; 651 sub = "";
652 } 652 }
653 qDebug("Type = %s/%s",type.latin1(),sub.latin1()); 653 qDebug("Type = %s/%s",type.latin1(),sub.latin1());
654 target_part.setType(type.lower()); 654 target_part.setType(type.lower());
655 target_part.setSubtype(sub.lower()); 655 target_part.setSubtype(sub.lower());
656 fillBodyFields(target_part,which->bd_fields); 656 fillBodyFields(target_part,which->bd_fields);
657} 657}
658 658
659void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) 659void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which)
660{ 660{
661 if (!which) return; 661 if (!which) return;
662 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) { 662 if (which->bd_parameter && which->bd_parameter->pa_list && which->bd_parameter->pa_list->count>0) {
663 clistcell*cur; 663 clistcell*cur;
664 mailimap_single_body_fld_param*param=0; 664 mailimap_single_body_fld_param*param=0;
665 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { 665 for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
666 param = (mailimap_single_body_fld_param*)cur->data; 666 param = (mailimap_single_body_fld_param*)cur->data;
667 if (param) { 667 if (param) {
668 target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 668 target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
669 } 669 }
670 } 670 }
671 } 671 }
672 mailimap_body_fld_enc*enc = which->bd_encoding; 672 mailimap_body_fld_enc*enc = which->bd_encoding;
673 QString encoding(""); 673 QString encoding("");
674 switch (enc->enc_type) { 674 switch (enc->enc_type) {
675 case MAILIMAP_BODY_FLD_ENC_7BIT: 675 case MAILIMAP_BODY_FLD_ENC_7BIT:
676 encoding = "7bit"; 676 encoding = "7bit";
677 break; 677 break;
678 case MAILIMAP_BODY_FLD_ENC_8BIT: 678 case MAILIMAP_BODY_FLD_ENC_8BIT:
679 encoding = "8bit"; 679 encoding = "8bit";
680 break; 680 break;
681 case MAILIMAP_BODY_FLD_ENC_BINARY: 681 case MAILIMAP_BODY_FLD_ENC_BINARY:
682 encoding="binary"; 682 encoding="binary";
683 break; 683 break;
684 case MAILIMAP_BODY_FLD_ENC_BASE64: 684 case MAILIMAP_BODY_FLD_ENC_BASE64:
685 encoding="base64"; 685 encoding="base64";
686 break; 686 break;
687 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: 687 case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE:
688 encoding="quoted-printable"; 688 encoding="quoted-printable";
689 break; 689 break;
690 case MAILIMAP_BODY_FLD_ENC_OTHER: 690 case MAILIMAP_BODY_FLD_ENC_OTHER:
691 default: 691 default:
692 if (enc->enc_value) { 692 if (enc->enc_value) {
693 char*t=enc->enc_value; 693 char*t=enc->enc_value;
694 encoding=QString(enc->enc_value); 694 encoding=QString(enc->enc_value);
695 enc->enc_value=0L; 695 enc->enc_value=0L;
696 free(t); 696 free(t);
697 } 697 }
698 } 698 }
699 if (which->bd_description) {
700 target_part.setDescription(QString(which->bd_description));
701 }
699 target_part.setEncoding(encoding); 702 target_part.setEncoding(encoding);
700 target_part.setSize(which->bd_size); 703 target_part.setSize(which->bd_size);
701} 704}
702 705
703QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) 706QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part)
704{ 707{
705 return fetchPart(mail,part.Positionlist(),false); 708 return fetchPart(mail,part.Positionlist(),false);
706} 709}
707 710
708void IMAPwrapper::deleteMail(const RecMail&mail) 711void IMAPwrapper::deleteMail(const RecMail&mail)
709{ 712{
710 mailimap_flag_list*flist; 713 mailimap_flag_list*flist;
711 mailimap_set *set; 714 mailimap_set *set;
712 mailimap_store_att_flags * store_flags; 715 mailimap_store_att_flags * store_flags;
713 int err; 716 int err;
714 login(); 717 login();
715 if (!m_imap) { 718 if (!m_imap) {
716 return; 719 return;
717 } 720 }
718 const char *mb = mail.getMbox().latin1(); 721 const char *mb = mail.getMbox().latin1();
719 err = mailimap_select( m_imap, (char*)mb); 722 err = mailimap_select( m_imap, (char*)mb);
720 if ( err != MAILIMAP_NO_ERROR ) { 723 if ( err != MAILIMAP_NO_ERROR ) {
721 qDebug("error selecting mailbox for delete: %s",m_imap->imap_response); 724 qDebug("error selecting mailbox for delete: %s",m_imap->imap_response);
722 return; 725 return;
723 } 726 }
724 flist = mailimap_flag_list_new_empty(); 727 flist = mailimap_flag_list_new_empty();
725 mailimap_flag_list_add(flist,mailimap_flag_new_deleted()); 728 mailimap_flag_list_add(flist,mailimap_flag_new_deleted());
726 store_flags = mailimap_store_att_flags_new_set_flags(flist); 729 store_flags = mailimap_store_att_flags_new_set_flags(flist);
727 set = mailimap_set_new_single(mail.getNumber()); 730 set = mailimap_set_new_single(mail.getNumber());
728 err = mailimap_store(m_imap,set,store_flags); 731 err = mailimap_store(m_imap,set,store_flags);
729 mailimap_set_free( set ); 732 mailimap_set_free( set );
730 mailimap_store_att_flags_free(store_flags); 733 mailimap_store_att_flags_free(store_flags);
731 734
732 if (err != MAILIMAP_NO_ERROR) { 735 if (err != MAILIMAP_NO_ERROR) {
733 qDebug("error deleting mail: %s",m_imap->imap_response); 736 qDebug("error deleting mail: %s",m_imap->imap_response);
734 return; 737 return;
735 } 738 }
736 qDebug("deleting mail: %s",m_imap->imap_response); 739 qDebug("deleting mail: %s",m_imap->imap_response);
737 /* should we realy do that at this moment? */ 740 /* should we realy do that at this moment? */
738 err = mailimap_expunge(m_imap); 741 err = mailimap_expunge(m_imap);
739 if (err != MAILIMAP_NO_ERROR) { 742 if (err != MAILIMAP_NO_ERROR) {
740 qDebug("error deleting mail: %s",m_imap->imap_response); 743 qDebug("error deleting mail: %s",m_imap->imap_response);
741 } 744 }
742 qDebug("Delete successfull %s",m_imap->imap_response); 745 qDebug("Delete successfull %s",m_imap->imap_response);
743} 746}
744 747
745void IMAPwrapper::answeredMail(const RecMail&mail) 748void IMAPwrapper::answeredMail(const RecMail&mail)
746{ 749{
747 mailimap_flag_list*flist; 750 mailimap_flag_list*flist;
748 mailimap_set *set; 751 mailimap_set *set;
749 mailimap_store_att_flags * store_flags; 752 mailimap_store_att_flags * store_flags;
750 int err; 753 int err;
751 login(); 754 login();
752 if (!m_imap) { 755 if (!m_imap) {
753 return; 756 return;
754 } 757 }
755 const char *mb = mail.getMbox().latin1(); 758 const char *mb = mail.getMbox().latin1();
756 err = mailimap_select( m_imap, (char*)mb); 759 err = mailimap_select( m_imap, (char*)mb);
757 if ( err != MAILIMAP_NO_ERROR ) { 760 if ( err != MAILIMAP_NO_ERROR ) {
758 qDebug("error selecting mailbox for mark: %s",m_imap->imap_response); 761 qDebug("error selecting mailbox for mark: %s",m_imap->imap_response);
759 return; 762 return;
760 } 763 }
761 flist = mailimap_flag_list_new_empty(); 764 flist = mailimap_flag_list_new_empty();
762 mailimap_flag_list_add(flist,mailimap_flag_new_answered()); 765 mailimap_flag_list_add(flist,mailimap_flag_new_answered());
763 store_flags = mailimap_store_att_flags_new_set_flags(flist); 766 store_flags = mailimap_store_att_flags_new_add_flags(flist);
764 set = mailimap_set_new_single(mail.getNumber()); 767 set = mailimap_set_new_single(mail.getNumber());
765 err = mailimap_store(m_imap,set,store_flags); 768 err = mailimap_store(m_imap,set,store_flags);
766 mailimap_set_free( set ); 769 mailimap_set_free( set );
767 mailimap_store_att_flags_free(store_flags); 770 mailimap_store_att_flags_free(store_flags);
768 771
769 if (err != MAILIMAP_NO_ERROR) { 772 if (err != MAILIMAP_NO_ERROR) {
770 qDebug("error marking mail: %s",m_imap->imap_response); 773 qDebug("error marking mail: %s",m_imap->imap_response);
771 return; 774 return;
772 } 775 }
773} 776}
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp
index 94f5d6f..8d9b247 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.cpp
+++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp
@@ -1,237 +1,247 @@
1#include "mailtypes.h" 1#include "mailtypes.h"
2 2
3 3
4RecMail::RecMail() 4RecMail::RecMail()
5 :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) 5 :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7)
6{ 6{
7 init(); 7 init();
8} 8}
9 9
10RecMail::RecMail(const RecMail&old) 10RecMail::RecMail(const RecMail&old)
11 :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) 11 :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
12{ 12{
13 init(); 13 init();
14 copy_old(old); 14 copy_old(old);
15 qDebug("Copy constructor RecMail"); 15 qDebug("Copy constructor RecMail");
16} 16}
17 17
18RecMail::~RecMail() 18RecMail::~RecMail()
19{ 19{
20 wrapper = 0; 20 wrapper = 0;
21} 21}
22 22
23void RecMail::copy_old(const RecMail&old) 23void RecMail::copy_old(const RecMail&old)
24{ 24{
25 subject = old.subject; 25 subject = old.subject;
26 date = old.date; 26 date = old.date;
27 mbox = old.mbox; 27 mbox = old.mbox;
28 msg_id = old.msg_id; 28 msg_id = old.msg_id;
29 msg_size = old.msg_size; 29 msg_size = old.msg_size;
30 msg_number = old.msg_number; 30 msg_number = old.msg_number;
31 from = old.from; 31 from = old.from;
32 msg_flags = old.msg_flags; 32 msg_flags = old.msg_flags;
33 to = old.to; 33 to = old.to;
34 cc = old.cc; 34 cc = old.cc;
35 bcc = old.bcc; 35 bcc = old.bcc;
36 wrapper = old.wrapper; 36 wrapper = old.wrapper;
37} 37}
38 38
39void RecMail::init() 39void RecMail::init()
40{ 40{
41 to.clear(); 41 to.clear();
42 cc.clear(); 42 cc.clear();
43 bcc.clear(); 43 bcc.clear();
44 wrapper = 0; 44 wrapper = 0;
45} 45}
46 46
47void RecMail::setWrapper(AbstractMail*awrapper) 47void RecMail::setWrapper(AbstractMail*awrapper)
48{ 48{
49 wrapper = awrapper; 49 wrapper = awrapper;
50} 50}
51 51
52AbstractMail* RecMail::Wrapper() 52AbstractMail* RecMail::Wrapper()
53{ 53{
54 return wrapper; 54 return wrapper;
55} 55}
56 56
57void RecMail::setTo(const QStringList&list) 57void RecMail::setTo(const QStringList&list)
58{ 58{
59 to = list; 59 to = list;
60} 60}
61 61
62const QStringList&RecMail::To()const 62const QStringList&RecMail::To()const
63{ 63{
64 return to; 64 return to;
65} 65}
66 66
67void RecMail::setCC(const QStringList&list) 67void RecMail::setCC(const QStringList&list)
68{ 68{
69 cc = list; 69 cc = list;
70} 70}
71 71
72const QStringList&RecMail::CC()const 72const QStringList&RecMail::CC()const
73{ 73{
74 return cc; 74 return cc;
75} 75}
76 76
77void RecMail::setBcc(const QStringList&list) 77void RecMail::setBcc(const QStringList&list)
78{ 78{
79 bcc = list; 79 bcc = list;
80} 80}
81 81
82const QStringList& RecMail::Bcc()const 82const QStringList& RecMail::Bcc()const
83{ 83{
84 return bcc; 84 return bcc;
85} 85}
86 86
87RecPart::RecPart() 87RecPart::RecPart()
88 : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0),m_size(0) 88 : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0)
89{ 89{
90 m_Parameters.clear(); 90 m_Parameters.clear();
91 m_poslist.clear(); 91 m_poslist.clear();
92} 92}
93 93
94RecPart::~RecPart() 94RecPart::~RecPart()
95{ 95{
96} 96}
97 97
98void RecPart::setSize(unsigned int size) 98void RecPart::setSize(unsigned int size)
99{ 99{
100 m_size = size; 100 m_size = size;
101} 101}
102 102
103const unsigned int RecPart::Size()const 103const unsigned int RecPart::Size()const
104{ 104{
105 return m_size; 105 return m_size;
106} 106}
107 107
108void RecPart::setLines(unsigned int lines) 108void RecPart::setLines(unsigned int lines)
109{ 109{
110 m_lines = lines; 110 m_lines = lines;
111} 111}
112 112
113const unsigned int RecPart::Lines()const 113const unsigned int RecPart::Lines()const
114{ 114{
115 return m_lines; 115 return m_lines;
116} 116}
117 117
118const QString& RecPart::Type()const 118const QString& RecPart::Type()const
119{ 119{
120 return m_type; 120 return m_type;
121} 121}
122 122
123void RecPart::setType(const QString&type) 123void RecPart::setType(const QString&type)
124{ 124{
125 m_type = type; 125 m_type = type;
126} 126}
127 127
128const QString& RecPart::Subtype()const 128const QString& RecPart::Subtype()const
129{ 129{
130 return m_subtype; 130 return m_subtype;
131} 131}
132 132
133void RecPart::setSubtype(const QString&subtype) 133void RecPart::setSubtype(const QString&subtype)
134{ 134{
135 m_subtype = subtype; 135 m_subtype = subtype;
136} 136}
137 137
138const QString& RecPart::Identifier()const 138const QString& RecPart::Identifier()const
139{ 139{
140 return m_identifier; 140 return m_identifier;
141} 141}
142 142
143void RecPart::setIdentifier(const QString&identifier) 143void RecPart::setIdentifier(const QString&identifier)
144{ 144{
145 m_identifier = identifier; 145 m_identifier = identifier;
146} 146}
147 147
148const QString& RecPart::Encoding()const 148const QString& RecPart::Encoding()const
149{ 149{
150 return m_encoding; 150 return m_encoding;
151} 151}
152 152
153void RecPart::setEncoding(const QString&encoding) 153void RecPart::setEncoding(const QString&encoding)
154{ 154{
155 m_encoding = encoding; 155 m_encoding = encoding;
156} 156}
157 157
158const QString& RecPart::Description()const
159{
160 return m_description;
161}
162
163void RecPart::setDescription(const QString&desc)
164{
165 m_description = desc;
166}
167
158void RecPart::setParameters(const part_plist_t&list) 168void RecPart::setParameters(const part_plist_t&list)
159{ 169{
160 m_Parameters = list; 170 m_Parameters = list;
161} 171}
162 172
163const part_plist_t& RecPart::Parameters()const 173const part_plist_t& RecPart::Parameters()const
164{ 174{
165 return m_Parameters; 175 return m_Parameters;
166} 176}
167 177
168void RecPart::addParameter(const QString&key,const QString&value) 178void RecPart::addParameter(const QString&key,const QString&value)
169{ 179{
170 m_Parameters[key]=value; 180 m_Parameters[key]=value;
171} 181}
172 182
173const QString RecPart::searchParamter(const QString&key)const 183const QString RecPart::searchParamter(const QString&key)const
174{ 184{
175 QString value(""); 185 QString value("");
176 part_plist_t::ConstIterator it = m_Parameters.find(key); 186 part_plist_t::ConstIterator it = m_Parameters.find(key);
177 if (it != m_Parameters.end()) { 187 if (it != m_Parameters.end()) {
178 value = it.data(); 188 value = it.data();
179 } 189 }
180 return value; 190 return value;
181} 191}
182 192
183void RecPart::setPositionlist(const QValueList<int>&poslist) 193void RecPart::setPositionlist(const QValueList<int>&poslist)
184{ 194{
185 m_poslist = poslist; 195 m_poslist = poslist;
186} 196}
187 197
188const QValueList<int>& RecPart::Positionlist()const 198const QValueList<int>& RecPart::Positionlist()const
189{ 199{
190 return m_poslist; 200 return m_poslist;
191} 201}
192 202
193RecBody::RecBody() 203RecBody::RecBody()
194 : m_BodyText(),m_PartsList(),m_description() 204 : m_BodyText(),m_PartsList(),m_description()
195{ 205{
196 m_PartsList.clear(); 206 m_PartsList.clear();
197} 207}
198 208
199RecBody::~RecBody() 209RecBody::~RecBody()
200{ 210{
201} 211}
202 212
203void RecBody::setBodytext(const QString&bodyText) 213void RecBody::setBodytext(const QString&bodyText)
204{ 214{
205 m_BodyText = bodyText; 215 m_BodyText = bodyText;
206} 216}
207 217
208const QString& RecBody::Bodytext()const 218const QString& RecBody::Bodytext()const
209{ 219{
210 return m_BodyText; 220 return m_BodyText;
211} 221}
212 222
213void RecBody::setParts(const QValueList<RecPart>&parts) 223void RecBody::setParts(const QValueList<RecPart>&parts)
214{ 224{
215 m_PartsList.clear(); 225 m_PartsList.clear();
216 m_PartsList = parts; 226 m_PartsList = parts;
217} 227}
218 228
219const QValueList<RecPart>& RecBody::Parts()const 229const QValueList<RecPart>& RecBody::Parts()const
220{ 230{
221 return m_PartsList; 231 return m_PartsList;
222} 232}
223 233
224void RecBody::addPart(const RecPart& part) 234void RecBody::addPart(const RecPart& part)
225{ 235{
226 m_PartsList.append(part); 236 m_PartsList.append(part);
227} 237}
228 238
229void RecBody::setDescription(const RecPart&des) 239void RecBody::setDescription(const RecPart&des)
230{ 240{
231 m_description = des; 241 m_description = des;
232} 242}
233 243
234const RecPart& RecBody::Description()const 244const RecPart& RecBody::Description()const
235{ 245{
236 return m_description; 246 return m_description;
237} 247}
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h
index 9ef762d..7d7bebc 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.h
+++ b/noncore/net/mail/libmailwrapper/mailtypes.h
@@ -1,136 +1,138 @@
1#ifndef __MAIL_TYPES_H 1#ifndef __MAIL_TYPES_H
2#define __MAIL_TYPES_H 2#define __MAIL_TYPES_H
3 3
4#define FLAG_ANSWERED 0 4#define FLAG_ANSWERED 0
5#define FLAG_FLAGGED 1 5#define FLAG_FLAGGED 1
6#define FLAG_DELETED 2 6#define FLAG_DELETED 2
7#define FLAG_SEEN 3 7#define FLAG_SEEN 3
8#define FLAG_DRAFT 4 8#define FLAG_DRAFT 4
9#define FLAG_RECENT 5 9#define FLAG_RECENT 5
10 10
11#include <qlist.h> 11#include <qlist.h>
12#include <qbitarray.h> 12#include <qbitarray.h>
13#include <qstring.h> 13#include <qstring.h>
14#include <qstringlist.h> 14#include <qstringlist.h>
15#include <qmap.h> 15#include <qmap.h>
16#include <qvaluelist.h> 16#include <qvaluelist.h>
17 17
18class AbstractMail; 18class AbstractMail;
19/* a class to describe mails in a mailbox */ 19/* a class to describe mails in a mailbox */
20/* Attention! 20/* Attention!
21 From programmers point of view it would make sense to 21 From programmers point of view it would make sense to
22 store the mail body into this class, too. 22 store the mail body into this class, too.
23 But: not from the point of view of the device. 23 But: not from the point of view of the device.
24 Mailbodies can be real large. So we request them when 24 Mailbodies can be real large. So we request them when
25 needed from the mail-wrapper class direct from the server itself 25 needed from the mail-wrapper class direct from the server itself
26 (imap) or from a file-based cache (pop3?) 26 (imap) or from a file-based cache (pop3?)
27 So there is no interface "const QString&body()" but you should 27 So there is no interface "const QString&body()" but you should
28 make a request to the mailwrapper with this class as parameter to 28 make a request to the mailwrapper with this class as parameter to
29 get the body. Same words for the attachments. 29 get the body. Same words for the attachments.
30*/ 30*/
31class RecMail 31class RecMail
32{ 32{
33public: 33public:
34 RecMail(); 34 RecMail();
35 RecMail(const RecMail&old); 35 RecMail(const RecMail&old);
36 virtual ~RecMail(); 36 virtual ~RecMail();
37 37
38 const int getNumber()const{return msg_number;} 38 const int getNumber()const{return msg_number;}
39 void setNumber(int number){msg_number=number;} 39 void setNumber(int number){msg_number=number;}
40 const QString&getDate()const{ return date; } 40 const QString&getDate()const{ return date; }
41 void setDate( const QString&a ) { date = a; } 41 void setDate( const QString&a ) { date = a; }
42 const QString&getFrom()const{ return from; } 42 const QString&getFrom()const{ return from; }
43 void setFrom( const QString&a ) { from = a; } 43 void setFrom( const QString&a ) { from = a; }
44 const QString&getSubject()const { return subject; } 44 const QString&getSubject()const { return subject; }
45 void setSubject( const QString&s ) { subject = s; } 45 void setSubject( const QString&s ) { subject = s; }
46 const QString&getMbox()const{return mbox;} 46 const QString&getMbox()const{return mbox;}
47 void setMbox(const QString&box){mbox = box;} 47 void setMbox(const QString&box){mbox = box;}
48 void setMsgid(const QString&id){msg_id=id;} 48 void setMsgid(const QString&id){msg_id=id;}
49 const QString&Msgid()const{return msg_id;} 49 const QString&Msgid()const{return msg_id;}
50 void setReplyto(const QString&reply){replyto=reply;} 50 void setReplyto(const QString&reply){replyto=reply;}
51 const QString&Replyto()const{return replyto;} 51 const QString&Replyto()const{return replyto;}
52 void setMsgsize(int size){msg_size = size;} 52 void setMsgsize(int size){msg_size = size;}
53 const int Msgsize()const{return msg_size;} 53 const int Msgsize()const{return msg_size;}
54 54
55 55
56 void setTo(const QStringList&list); 56 void setTo(const QStringList&list);
57 const QStringList&To()const; 57 const QStringList&To()const;
58 void setCC(const QStringList&list); 58 void setCC(const QStringList&list);
59 const QStringList&CC()const; 59 const QStringList&CC()const;
60 void setBcc(const QStringList&list); 60 void setBcc(const QStringList&list);
61 const QStringList&Bcc()const; 61 const QStringList&Bcc()const;
62 const QBitArray&getFlags()const{return msg_flags;} 62 const QBitArray&getFlags()const{return msg_flags;}
63 void setFlags(const QBitArray&flags){msg_flags = flags;} 63 void setFlags(const QBitArray&flags){msg_flags = flags;}
64 64
65 void setWrapper(AbstractMail*wrapper); 65 void setWrapper(AbstractMail*wrapper);
66 AbstractMail* Wrapper(); 66 AbstractMail* Wrapper();
67 67
68protected: 68protected:
69 QString subject,date,from,mbox,msg_id,replyto; 69 QString subject,date,from,mbox,msg_id,replyto;
70 int msg_number,msg_size; 70 int msg_number,msg_size;
71 QBitArray msg_flags; 71 QBitArray msg_flags;
72 QStringList to,cc,bcc; 72 QStringList to,cc,bcc;
73 AbstractMail*wrapper; 73 AbstractMail*wrapper;
74 void init(); 74 void init();
75 void copy_old(const RecMail&old); 75 void copy_old(const RecMail&old);
76}; 76};
77 77
78typedef QMap<QString,QString> part_plist_t; 78typedef QMap<QString,QString> part_plist_t;
79 79
80class RecPart 80class RecPart
81{ 81{
82protected: 82protected:
83 QString m_type,m_subtype,m_identifier,m_encoding; 83 QString m_type,m_subtype,m_identifier,m_encoding,m_description;
84 unsigned int m_lines,m_size; 84 unsigned int m_lines,m_size;
85 part_plist_t m_Parameters; 85 part_plist_t m_Parameters;
86 /* describes the position in the mail */ 86 /* describes the position in the mail */
87 QValueList<int> m_poslist; 87 QValueList<int> m_poslist;
88 88
89public: 89public:
90 RecPart(); 90 RecPart();
91 virtual ~RecPart(); 91 virtual ~RecPart();
92 92
93 const QString&Type()const; 93 const QString&Type()const;
94 void setType(const QString&type); 94 void setType(const QString&type);
95 const QString&Subtype()const; 95 const QString&Subtype()const;
96 void setSubtype(const QString&subtype); 96 void setSubtype(const QString&subtype);
97 const QString&Identifier()const; 97 const QString&Identifier()const;
98 void setIdentifier(const QString&identifier); 98 void setIdentifier(const QString&identifier);
99 const QString&Encoding()const; 99 const QString&Encoding()const;
100 void setEncoding(const QString&encoding); 100 void setEncoding(const QString&encoding);
101 const QString&Description()const;
102 void setDescription(const QString&desc);
101 void setLines(unsigned int lines); 103 void setLines(unsigned int lines);
102 const unsigned int Lines()const; 104 const unsigned int Lines()const;
103 void setSize(unsigned int size); 105 void setSize(unsigned int size);
104 const unsigned int Size()const; 106 const unsigned int Size()const;
105 107
106 108
107 void setParameters(const part_plist_t&list); 109 void setParameters(const part_plist_t&list);
108 const part_plist_t&Parameters()const; 110 const part_plist_t&Parameters()const;
109 void addParameter(const QString&key,const QString&value); 111 void addParameter(const QString&key,const QString&value);
110 const QString searchParamter(const QString&key)const; 112 const QString searchParamter(const QString&key)const;
111 void setPositionlist(const QValueList<int>&poslist); 113 void setPositionlist(const QValueList<int>&poslist);
112 const QValueList<int>& Positionlist()const; 114 const QValueList<int>& Positionlist()const;
113}; 115};
114 116
115class RecBody 117class RecBody
116{ 118{
117protected: 119protected:
118 QString m_BodyText; 120 QString m_BodyText;
119 QValueList<RecPart> m_PartsList; 121 QValueList<RecPart> m_PartsList;
120 RecPart m_description; 122 RecPart m_description;
121 123
122public: 124public:
123 RecBody(); 125 RecBody();
124 virtual ~RecBody(); 126 virtual ~RecBody();
125 void setBodytext(const QString&); 127 void setBodytext(const QString&);
126 const QString& Bodytext()const; 128 const QString& Bodytext()const;
127 129
128 void setDescription(const RecPart&des); 130 void setDescription(const RecPart&des);
129 const RecPart& Description()const; 131 const RecPart& Description()const;
130 132
131 void setParts(const QValueList<RecPart>&parts); 133 void setParts(const QValueList<RecPart>&parts);
132 const QValueList<RecPart>& Parts()const; 134 const QValueList<RecPart>& Parts()const;
133 void addPart(const RecPart&part); 135 void addPart(const RecPart&part);
134}; 136};
135 137
136#endif 138#endif
diff --git a/noncore/net/mail/mailtypes.cpp b/noncore/net/mail/mailtypes.cpp
index 94f5d6f..8d9b247 100644
--- a/noncore/net/mail/mailtypes.cpp
+++ b/noncore/net/mail/mailtypes.cpp
@@ -1,237 +1,247 @@
1#include "mailtypes.h" 1#include "mailtypes.h"
2 2
3 3
4RecMail::RecMail() 4RecMail::RecMail()
5 :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) 5 :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7)
6{ 6{
7 init(); 7 init();
8} 8}
9 9
10RecMail::RecMail(const RecMail&old) 10RecMail::RecMail(const RecMail&old)
11 :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) 11 :subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
12{ 12{
13 init(); 13 init();
14 copy_old(old); 14 copy_old(old);
15 qDebug("Copy constructor RecMail"); 15 qDebug("Copy constructor RecMail");
16} 16}
17 17
18RecMail::~RecMail() 18RecMail::~RecMail()
19{ 19{
20 wrapper = 0; 20 wrapper = 0;
21} 21}
22 22
23void RecMail::copy_old(const RecMail&old) 23void RecMail::copy_old(const RecMail&old)
24{ 24{
25 subject = old.subject; 25 subject = old.subject;
26 date = old.date; 26 date = old.date;
27 mbox = old.mbox; 27 mbox = old.mbox;
28 msg_id = old.msg_id; 28 msg_id = old.msg_id;
29 msg_size = old.msg_size; 29 msg_size = old.msg_size;
30 msg_number = old.msg_number; 30 msg_number = old.msg_number;
31 from = old.from; 31 from = old.from;
32 msg_flags = old.msg_flags; 32 msg_flags = old.msg_flags;
33 to = old.to; 33 to = old.to;
34 cc = old.cc; 34 cc = old.cc;
35 bcc = old.bcc; 35 bcc = old.bcc;
36 wrapper = old.wrapper; 36 wrapper = old.wrapper;
37} 37}
38 38
39void RecMail::init() 39void RecMail::init()
40{ 40{
41 to.clear(); 41 to.clear();
42 cc.clear(); 42 cc.clear();
43 bcc.clear(); 43 bcc.clear();
44 wrapper = 0; 44 wrapper = 0;
45} 45}
46 46
47void RecMail::setWrapper(AbstractMail*awrapper) 47void RecMail::setWrapper(AbstractMail*awrapper)
48{ 48{
49 wrapper = awrapper; 49 wrapper = awrapper;
50} 50}
51 51
52AbstractMail* RecMail::Wrapper() 52AbstractMail* RecMail::Wrapper()
53{ 53{
54 return wrapper; 54 return wrapper;
55} 55}
56 56
57void RecMail::setTo(const QStringList&list) 57void RecMail::setTo(const QStringList&list)
58{ 58{
59 to = list; 59 to = list;
60} 60}
61 61
62const QStringList&RecMail::To()const 62const QStringList&RecMail::To()const
63{ 63{
64 return to; 64 return to;
65} 65}
66 66
67void RecMail::setCC(const QStringList&list) 67void RecMail::setCC(const QStringList&list)
68{ 68{
69 cc = list; 69 cc = list;
70} 70}
71 71
72const QStringList&RecMail::CC()const 72const QStringList&RecMail::CC()const
73{ 73{
74 return cc; 74 return cc;
75} 75}
76 76
77void RecMail::setBcc(const QStringList&list) 77void RecMail::setBcc(const QStringList&list)
78{ 78{
79 bcc = list; 79 bcc = list;
80} 80}
81 81
82const QStringList& RecMail::Bcc()const 82const QStringList& RecMail::Bcc()const
83{ 83{
84 return bcc; 84 return bcc;
85} 85}
86 86
87RecPart::RecPart() 87RecPart::RecPart()
88 : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0),m_size(0) 88 : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0)
89{ 89{
90 m_Parameters.clear(); 90 m_Parameters.clear();
91 m_poslist.clear(); 91 m_poslist.clear();
92} 92}
93 93
94RecPart::~RecPart() 94RecPart::~RecPart()
95{ 95{
96} 96}
97 97
98void RecPart::setSize(unsigned int size) 98void RecPart::setSize(unsigned int size)
99{ 99{
100 m_size = size; 100 m_size = size;
101} 101}
102 102
103const unsigned int RecPart::Size()const 103const unsigned int RecPart::Size()const
104{ 104{
105 return m_size; 105 return m_size;
106} 106}
107 107
108void RecPart::setLines(unsigned int lines) 108void RecPart::setLines(unsigned int lines)
109{ 109{
110 m_lines = lines; 110 m_lines = lines;
111} 111}
112 112
113const unsigned int RecPart::Lines()const 113const unsigned int RecPart::Lines()const
114{ 114{
115 return m_lines; 115 return m_lines;
116} 116}
117 117
118const QString& RecPart::Type()const 118const QString& RecPart::Type()const
119{ 119{
120 return m_type; 120 return m_type;
121} 121}
122 122
123void RecPart::setType(const QString&type) 123void RecPart::setType(const QString&type)
124{ 124{
125 m_type = type; 125 m_type = type;
126} 126}
127 127
128const QString& RecPart::Subtype()const 128const QString& RecPart::Subtype()const
129{ 129{
130 return m_subtype; 130 return m_subtype;
131} 131}
132 132
133void RecPart::setSubtype(const QString&subtype) 133void RecPart::setSubtype(const QString&subtype)
134{ 134{
135 m_subtype = subtype; 135 m_subtype = subtype;
136} 136}
137 137
138const QString& RecPart::Identifier()const 138const QString& RecPart::Identifier()const
139{ 139{
140 return m_identifier; 140 return m_identifier;
141} 141}
142 142
143void RecPart::setIdentifier(const QString&identifier) 143void RecPart::setIdentifier(const QString&identifier)
144{ 144{
145 m_identifier = identifier; 145 m_identifier = identifier;
146} 146}
147 147
148const QString& RecPart::Encoding()const 148const QString& RecPart::Encoding()const
149{ 149{
150 return m_encoding; 150 return m_encoding;
151} 151}
152 152
153void RecPart::setEncoding(const QString&encoding) 153void RecPart::setEncoding(const QString&encoding)
154{ 154{
155 m_encoding = encoding; 155 m_encoding = encoding;
156} 156}
157 157
158const QString& RecPart::Description()const
159{
160 return m_description;
161}
162
163void RecPart::setDescription(const QString&desc)
164{
165 m_description = desc;
166}
167
158void RecPart::setParameters(const part_plist_t&list) 168void RecPart::setParameters(const part_plist_t&list)
159{ 169{
160 m_Parameters = list; 170 m_Parameters = list;
161} 171}
162 172
163const part_plist_t& RecPart::Parameters()const 173const part_plist_t& RecPart::Parameters()const
164{ 174{
165 return m_Parameters; 175 return m_Parameters;
166} 176}
167 177
168void RecPart::addParameter(const QString&key,const QString&value) 178void RecPart::addParameter(const QString&key,const QString&value)
169{ 179{
170 m_Parameters[key]=value; 180 m_Parameters[key]=value;
171} 181}
172 182
173const QString RecPart::searchParamter(const QString&key)const 183const QString RecPart::searchParamter(const QString&key)const
174{ 184{
175 QString value(""); 185 QString value("");
176 part_plist_t::ConstIterator it = m_Parameters.find(key); 186 part_plist_t::ConstIterator it = m_Parameters.find(key);
177 if (it != m_Parameters.end()) { 187 if (it != m_Parameters.end()) {
178 value = it.data(); 188 value = it.data();
179 } 189 }
180 return value; 190 return value;
181} 191}
182 192
183void RecPart::setPositionlist(const QValueList<int>&poslist) 193void RecPart::setPositionlist(const QValueList<int>&poslist)
184{ 194{
185 m_poslist = poslist; 195 m_poslist = poslist;
186} 196}
187 197
188const QValueList<int>& RecPart::Positionlist()const 198const QValueList<int>& RecPart::Positionlist()const
189{ 199{
190 return m_poslist; 200 return m_poslist;
191} 201}
192 202
193RecBody::RecBody() 203RecBody::RecBody()
194 : m_BodyText(),m_PartsList(),m_description() 204 : m_BodyText(),m_PartsList(),m_description()
195{ 205{
196 m_PartsList.clear(); 206 m_PartsList.clear();
197} 207}
198 208
199RecBody::~RecBody() 209RecBody::~RecBody()
200{ 210{
201} 211}
202 212
203void RecBody::setBodytext(const QString&bodyText) 213void RecBody::setBodytext(const QString&bodyText)
204{ 214{
205 m_BodyText = bodyText; 215 m_BodyText = bodyText;
206} 216}
207 217
208const QString& RecBody::Bodytext()const 218const QString& RecBody::Bodytext()const
209{ 219{
210 return m_BodyText; 220 return m_BodyText;
211} 221}
212 222
213void RecBody::setParts(const QValueList<RecPart>&parts) 223void RecBody::setParts(const QValueList<RecPart>&parts)
214{ 224{
215 m_PartsList.clear(); 225 m_PartsList.clear();
216 m_PartsList = parts; 226 m_PartsList = parts;
217} 227}
218 228
219const QValueList<RecPart>& RecBody::Parts()const 229const QValueList<RecPart>& RecBody::Parts()const
220{ 230{
221 return m_PartsList; 231 return m_PartsList;
222} 232}
223 233
224void RecBody::addPart(const RecPart& part) 234void RecBody::addPart(const RecPart& part)
225{ 235{
226 m_PartsList.append(part); 236 m_PartsList.append(part);
227} 237}
228 238
229void RecBody::setDescription(const RecPart&des) 239void RecBody::setDescription(const RecPart&des)
230{ 240{
231 m_description = des; 241 m_description = des;
232} 242}
233 243
234const RecPart& RecBody::Description()const 244const RecPart& RecBody::Description()const
235{ 245{
236 return m_description; 246 return m_description;
237} 247}
diff --git a/noncore/net/mail/mailtypes.h b/noncore/net/mail/mailtypes.h
index 9ef762d..7d7bebc 100644
--- a/noncore/net/mail/mailtypes.h
+++ b/noncore/net/mail/mailtypes.h
@@ -1,136 +1,138 @@
1#ifndef __MAIL_TYPES_H 1#ifndef __MAIL_TYPES_H
2#define __MAIL_TYPES_H 2#define __MAIL_TYPES_H
3 3
4#define FLAG_ANSWERED 0 4#define FLAG_ANSWERED 0
5#define FLAG_FLAGGED 1 5#define FLAG_FLAGGED 1
6#define FLAG_DELETED 2 6#define FLAG_DELETED 2
7#define FLAG_SEEN 3 7#define FLAG_SEEN 3
8#define FLAG_DRAFT 4 8#define FLAG_DRAFT 4
9#define FLAG_RECENT 5 9#define FLAG_RECENT 5
10 10
11#include <qlist.h> 11#include <qlist.h>
12#include <qbitarray.h> 12#include <qbitarray.h>
13#include <qstring.h> 13#include <qstring.h>
14#include <qstringlist.h> 14#include <qstringlist.h>
15#include <qmap.h> 15#include <qmap.h>
16#include <qvaluelist.h> 16#include <qvaluelist.h>
17 17
18class AbstractMail; 18class AbstractMail;
19/* a class to describe mails in a mailbox */ 19/* a class to describe mails in a mailbox */
20/* Attention! 20/* Attention!
21 From programmers point of view it would make sense to 21 From programmers point of view it would make sense to
22 store the mail body into this class, too. 22 store the mail body into this class, too.
23 But: not from the point of view of the device. 23 But: not from the point of view of the device.
24 Mailbodies can be real large. So we request them when 24 Mailbodies can be real large. So we request them when
25 needed from the mail-wrapper class direct from the server itself 25 needed from the mail-wrapper class direct from the server itself
26 (imap) or from a file-based cache (pop3?) 26 (imap) or from a file-based cache (pop3?)
27 So there is no interface "const QString&body()" but you should 27 So there is no interface "const QString&body()" but you should
28 make a request to the mailwrapper with this class as parameter to 28 make a request to the mailwrapper with this class as parameter to
29 get the body. Same words for the attachments. 29 get the body. Same words for the attachments.
30*/ 30*/
31class RecMail 31class RecMail
32{ 32{
33public: 33public:
34 RecMail(); 34 RecMail();
35 RecMail(const RecMail&old); 35 RecMail(const RecMail&old);
36 virtual ~RecMail(); 36 virtual ~RecMail();
37 37
38 const int getNumber()const{return msg_number;} 38 const int getNumber()const{return msg_number;}
39 void setNumber(int number){msg_number=number;} 39 void setNumber(int number){msg_number=number;}
40 const QString&getDate()const{ return date; } 40 const QString&getDate()const{ return date; }
41 void setDate( const QString&a ) { date = a; } 41 void setDate( const QString&a ) { date = a; }
42 const QString&getFrom()const{ return from; } 42 const QString&getFrom()const{ return from; }
43 void setFrom( const QString&a ) { from = a; } 43 void setFrom( const QString&a ) { from = a; }
44 const QString&getSubject()const { return subject; } 44 const QString&getSubject()const { return subject; }
45 void setSubject( const QString&s ) { subject = s; } 45 void setSubject( const QString&s ) { subject = s; }
46 const QString&getMbox()const{return mbox;} 46 const QString&getMbox()const{return mbox;}
47 void setMbox(const QString&box){mbox = box;} 47 void setMbox(const QString&box){mbox = box;}
48 void setMsgid(const QString&id){msg_id=id;} 48 void setMsgid(const QString&id){msg_id=id;}
49 const QString&Msgid()const{return msg_id;} 49 const QString&Msgid()const{return msg_id;}
50 void setReplyto(const QString&reply){replyto=reply;} 50 void setReplyto(const QString&reply){replyto=reply;}
51 const QString&Replyto()const{return replyto;} 51 const QString&Replyto()const{return replyto;}
52 void setMsgsize(int size){msg_size = size;} 52 void setMsgsize(int size){msg_size = size;}
53 const int Msgsize()const{return msg_size;} 53 const int Msgsize()const{return msg_size;}
54 54
55 55
56 void setTo(const QStringList&list); 56 void setTo(const QStringList&list);
57 const QStringList&To()const; 57 const QStringList&To()const;
58 void setCC(const QStringList&list); 58 void setCC(const QStringList&list);
59 const QStringList&CC()const; 59 const QStringList&CC()const;
60 void setBcc(const QStringList&list); 60 void setBcc(const QStringList&list);
61 const QStringList&Bcc()const; 61 const QStringList&Bcc()const;
62 const QBitArray&getFlags()const{return msg_flags;} 62 const QBitArray&getFlags()const{return msg_flags;}
63 void setFlags(const QBitArray&flags){msg_flags = flags;} 63 void setFlags(const QBitArray&flags){msg_flags = flags;}
64 64
65 void setWrapper(AbstractMail*wrapper); 65 void setWrapper(AbstractMail*wrapper);
66 AbstractMail* Wrapper(); 66 AbstractMail* Wrapper();
67 67
68protected: 68protected:
69 QString subject,date,from,mbox,msg_id,replyto; 69 QString subject,date,from,mbox,msg_id,replyto;
70 int msg_number,msg_size; 70 int msg_number,msg_size;
71 QBitArray msg_flags; 71 QBitArray msg_flags;
72 QStringList to,cc,bcc; 72 QStringList to,cc,bcc;
73 AbstractMail*wrapper; 73 AbstractMail*wrapper;
74 void init(); 74 void init();
75 void copy_old(const RecMail&old); 75 void copy_old(const RecMail&old);
76}; 76};
77 77
78typedef QMap<QString,QString> part_plist_t; 78typedef QMap<QString,QString> part_plist_t;
79 79
80class RecPart 80class RecPart
81{ 81{
82protected: 82protected:
83 QString m_type,m_subtype,m_identifier,m_encoding; 83 QString m_type,m_subtype,m_identifier,m_encoding,m_description;
84 unsigned int m_lines,m_size; 84 unsigned int m_lines,m_size;
85 part_plist_t m_Parameters; 85 part_plist_t m_Parameters;
86 /* describes the position in the mail */ 86 /* describes the position in the mail */
87 QValueList<int> m_poslist; 87 QValueList<int> m_poslist;
88 88
89public: 89public:
90 RecPart(); 90 RecPart();
91 virtual ~RecPart(); 91 virtual ~RecPart();
92 92
93 const QString&Type()const; 93 const QString&Type()const;
94 void setType(const QString&type); 94 void setType(const QString&type);
95 const QString&Subtype()const; 95 const QString&Subtype()const;
96 void setSubtype(const QString&subtype); 96 void setSubtype(const QString&subtype);
97 const QString&Identifier()const; 97 const QString&Identifier()const;
98 void setIdentifier(const QString&identifier); 98 void setIdentifier(const QString&identifier);
99 const QString&Encoding()const; 99 const QString&Encoding()const;
100 void setEncoding(const QString&encoding); 100 void setEncoding(const QString&encoding);
101 const QString&Description()const;
102 void setDescription(const QString&desc);
101 void setLines(unsigned int lines); 103 void setLines(unsigned int lines);
102 const unsigned int Lines()const; 104 const unsigned int Lines()const;
103 void setSize(unsigned int size); 105 void setSize(unsigned int size);
104 const unsigned int Size()const; 106 const unsigned int Size()const;
105 107
106 108
107 void setParameters(const part_plist_t&list); 109 void setParameters(const part_plist_t&list);
108 const part_plist_t&Parameters()const; 110 const part_plist_t&Parameters()const;
109 void addParameter(const QString&key,const QString&value); 111 void addParameter(const QString&key,const QString&value);
110 const QString searchParamter(const QString&key)const; 112 const QString searchParamter(const QString&key)const;
111 void setPositionlist(const QValueList<int>&poslist); 113 void setPositionlist(const QValueList<int>&poslist);
112 const QValueList<int>& Positionlist()const; 114 const QValueList<int>& Positionlist()const;
113}; 115};
114 116
115class RecBody 117class RecBody
116{ 118{
117protected: 119protected:
118 QString m_BodyText; 120 QString m_BodyText;
119 QValueList<RecPart> m_PartsList; 121 QValueList<RecPart> m_PartsList;
120 RecPart m_description; 122 RecPart m_description;
121 123
122public: 124public:
123 RecBody(); 125 RecBody();
124 virtual ~RecBody(); 126 virtual ~RecBody();
125 void setBodytext(const QString&); 127 void setBodytext(const QString&);
126 const QString& Bodytext()const; 128 const QString& Bodytext()const;
127 129
128 void setDescription(const RecPart&des); 130 void setDescription(const RecPart&des);
129 const RecPart& Description()const; 131 const RecPart& Description()const;
130 132
131 void setParts(const QValueList<RecPart>&parts); 133 void setParts(const QValueList<RecPart>&parts);
132 const QValueList<RecPart>& Parts()const; 134 const QValueList<RecPart>& Parts()const;
133 void addPart(const RecPart&part); 135 void addPart(const RecPart&part);
134}; 136};
135 137
136#endif 138#endif
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp
index fae3e97..8e2132e 100644
--- a/noncore/net/mail/mainwindow.cpp
+++ b/noncore/net/mail/mainwindow.cpp
@@ -1,222 +1,224 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qvbox.h> 2#include <qvbox.h>
3#include <qheader.h> 3#include <qheader.h>
4#include <qtimer.h> 4#include <qtimer.h>
5#include <qlayout.h> 5#include <qlayout.h>
6#include <qmessagebox.h> 6#include <qmessagebox.h>
7 7
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpe/resource.h> 9#include <qpe/resource.h>
10 10
11#include "defines.h" 11#include "defines.h"
12#include "mainwindow.h" 12#include "mainwindow.h"
13#include "viewmail.h" 13#include "viewmail.h"
14#include "mailtypes.h" 14#include "mailtypes.h"
15#include "mailistviewitem.h" 15#include "mailistviewitem.h"
16 16
17MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) 17MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
18 : QMainWindow( parent, name, flags ) 18 : QMainWindow( parent, name, flags )
19{ 19{
20 setCaption( tr( "Mail" ) ); 20 setCaption( tr( "Mail" ) );
21 setToolBarsMovable( false ); 21 setToolBarsMovable( false );
22 22
23 toolBar = new QToolBar( this ); 23 toolBar = new QToolBar( this );
24 menuBar = new QMenuBar( toolBar ); 24 menuBar = new QMenuBar( toolBar );
25 mailMenu = new QPopupMenu( menuBar ); 25 mailMenu = new QPopupMenu( menuBar );
26 menuBar->insertItem( tr( "Mail" ), mailMenu ); 26 menuBar->insertItem( tr( "Mail" ), mailMenu );
27 settingsMenu = new QPopupMenu( menuBar ); 27 settingsMenu = new QPopupMenu( menuBar );
28 menuBar->insertItem( tr( "Settings" ), settingsMenu ); 28 menuBar->insertItem( tr( "Settings" ), settingsMenu );
29 29
30 addToolBar( toolBar ); 30 addToolBar( toolBar );
31 toolBar->setHorizontalStretchable( true ); 31 toolBar->setHorizontalStretchable( true );
32 32
33 QLabel *spacer = new QLabel( toolBar ); 33 QLabel *spacer = new QLabel( toolBar );
34 spacer->setBackgroundMode( QWidget::PaletteButton ); 34 spacer->setBackgroundMode( QWidget::PaletteButton );
35 toolBar->setStretchableWidget( spacer ); 35 toolBar->setStretchableWidget( spacer );
36 36
37 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, 37 composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL,
38 0, 0, this ); 38 0, 0, this );
39 composeMail->addTo( toolBar ); 39 composeMail->addTo( toolBar );
40 composeMail->addTo( mailMenu ); 40 composeMail->addTo( mailMenu );
41 41
42 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, 42 sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED,
43 0, 0, this ); 43 0, 0, this );
44 sendQueued->addTo( toolBar ); 44 sendQueued->addTo( toolBar );
45 sendQueued->addTo( mailMenu ); 45 sendQueued->addTo( mailMenu );
46 46
47 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 47 syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC,
48 0, 0, this ); 48 0, 0, this );
49 syncFolders->addTo( toolBar ); 49 syncFolders->addTo( toolBar );
50 syncFolders->addTo( mailMenu ); 50 syncFolders->addTo( mailMenu );
51 51
52 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, 52 showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS,
53 0, 0, this, 0, true ); 53 0, 0, this, 0, true );
54 showFolders->addTo( toolBar ); 54 showFolders->addTo( toolBar );
55 showFolders->addTo( mailMenu ); 55 showFolders->addTo( mailMenu );
56 showFolders->setOn( true ); 56 showFolders->setOn( true );
57 connect(showFolders, SIGNAL( toggled( bool ) ), 57 connect(showFolders, SIGNAL( toggled( bool ) ),
58 SLOT( slotShowFolders( bool ) ) ); 58 SLOT( slotShowFolders( bool ) ) );
59 59
60 searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, 60 searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS,
61 0, 0, this ); 61 0, 0, this );
62 searchMails->addTo( toolBar ); 62 searchMails->addTo( toolBar );
63 searchMails->addTo( mailMenu ); 63 searchMails->addTo( mailMenu );
64 64
65 deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); 65 deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this);
66 deleteMails->addTo( toolBar ); 66 deleteMails->addTo( toolBar );
67 deleteMails->addTo( mailMenu ); 67 deleteMails->addTo( mailMenu );
68 connect( deleteMails, SIGNAL( activated() ), 68 connect( deleteMails, SIGNAL( activated() ),
69 SLOT( slotDeleteMail() ) ); 69 SLOT( slotDeleteMail() ) );
70 70
71 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, 71 editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS,
72 0, 0, this ); 72 0, 0, this );
73 editSettings->addTo( settingsMenu ); 73 editSettings->addTo( settingsMenu );
74 74
75 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, 75 editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS,
76 0, 0, this ); 76 0, 0, this );
77 editAccounts->addTo( settingsMenu ); 77 editAccounts->addTo( settingsMenu );
78 78
79 QWidget *view = new QWidget( this ); 79 QWidget *view = new QWidget( this );
80 setCentralWidget( view ); 80 setCentralWidget( view );
81 81
82 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); 82 layout = new QBoxLayout ( view, QBoxLayout::LeftToRight );
83 83
84 folderView = new AccountView( view ); 84 folderView = new AccountView( view );
85 folderView->header()->hide(); 85 folderView->header()->hide();
86 folderView->setRootIsDecorated( true ); 86 folderView->setRootIsDecorated( true );
87 folderView->addColumn( tr( "Mailbox" ) ); 87 folderView->addColumn( tr( "Mailbox" ) );
88 //folderView->hide(); 88 //folderView->hide();
89 89
90 layout->addWidget( folderView ); 90 layout->addWidget( folderView );
91 91
92 mailView = new QListView( view ); 92 mailView = new QListView( view );
93 mailView->addColumn( tr( "" ) ); 93 mailView->addColumn( tr( "" ) );
94 mailView->addColumn( tr( "Subject" ),QListView::Manual ); 94 mailView->addColumn( tr( "Subject" ),QListView::Manual );
95 mailView->addColumn( tr( "Sender" ),QListView::Manual ); 95 mailView->addColumn( tr( "Sender" ),QListView::Manual );
96 mailView->addColumn( tr( "Date" )); 96 mailView->addColumn( tr( "Date" ));
97 mailView->setAllColumnsShowFocus(true); 97 mailView->setAllColumnsShowFocus(true);
98 mailView->setSorting(-1); 98 mailView->setSorting(-1);
99 99
100 layout->addWidget( mailView ); 100 layout->addWidget( mailView );
101 layout->setStretchFactor( folderView, 1 ); 101 layout->setStretchFactor( folderView, 1 );
102 layout->setStretchFactor( mailView, 2 ); 102 layout->setStretchFactor( mailView, 2 );
103 103
104 slotAdjustLayout(); 104 slotAdjustLayout();
105 105
106 connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, 106 connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this,
107 SLOT( displayMail( QListViewItem * ) ) ); 107 SLOT( displayMail( QListViewItem * ) ) );
108 108
109 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); 109 connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*)));
110 110
111 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); 111 QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) );
112 112
113} 113}
114 114
115 115
116void MainWindow::slotAdjustLayout() { 116void MainWindow::slotAdjustLayout() {
117 117
118 QWidget *d = QApplication::desktop(); 118 QWidget *d = QApplication::desktop();
119 119
120 if ( d->width() < d->height() ) { 120 if ( d->width() < d->height() ) {
121 layout->setDirection( QBoxLayout::TopToBottom ); 121 layout->setDirection( QBoxLayout::TopToBottom );
122 } else { 122 } else {
123 layout->setDirection( QBoxLayout::LeftToRight ); 123 layout->setDirection( QBoxLayout::LeftToRight );
124 } 124 }
125 delete d; 125 delete d;
126} 126}
127 127
128void MainWindow::slotAdjustColumns() 128void MainWindow::slotAdjustColumns()
129{ 129{
130 bool hidden = folderView->isHidden(); 130 bool hidden = folderView->isHidden();
131 if ( hidden ) folderView->show(); 131 if ( hidden ) folderView->show();
132 folderView->setColumnWidth( 0, folderView->visibleWidth() ); 132 folderView->setColumnWidth( 0, folderView->visibleWidth() );
133 if ( hidden ) folderView->hide(); 133 if ( hidden ) folderView->hide();
134 134
135 mailView->setColumnWidth( 0, 10 ); 135 mailView->setColumnWidth( 0, 10 );
136 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); 136 mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 );
137 mailView->setColumnWidth( 2, 80 ); 137 mailView->setColumnWidth( 2, 80 );
138 mailView->setColumnWidth( 3, 50 ); 138 mailView->setColumnWidth( 3, 50 );
139} 139}
140 140
141void MainWindow::slotShowFolders( bool show ) 141void MainWindow::slotShowFolders( bool show )
142{ 142{
143 qDebug( "Show Folders" ); 143 qDebug( "Show Folders" );
144 if ( show && folderView->isHidden() ) { 144 if ( show && folderView->isHidden() ) {
145 qDebug( "-> showing" ); 145 qDebug( "-> showing" );
146 folderView->show(); 146 folderView->show();
147 } else if ( !show && !folderView->isHidden() ) { 147 } else if ( !show && !folderView->isHidden() ) {
148 qDebug( "-> hiding" ); 148 qDebug( "-> hiding" );
149 folderView->hide(); 149 folderView->hide();
150 } 150 }
151} 151}
152 152
153void MainWindow::refreshMailView(QList<RecMail>*list) 153void MainWindow::refreshMailView(QList<RecMail>*list)
154{ 154{
155 MailListViewItem*item = 0; 155 MailListViewItem*item = 0;
156 mailView->clear(); 156 mailView->clear();
157 for (unsigned int i = 0; i < list->count();++i) { 157 for (unsigned int i = 0; i < list->count();++i) {
158 item = new MailListViewItem(mailView,item); 158 item = new MailListViewItem(mailView,item);
159 item->storeData(*(list->at(i))); 159 item->storeData(*(list->at(i)));
160 item->showEntry(); 160 item->showEntry();
161 } 161 }
162} 162}
163void MainWindow::displayMail(QListViewItem*item) 163void MainWindow::displayMail(QListViewItem*item)
164{ 164{
165 165
166 if (!item) return; 166 if (!item) return;
167 RecMail mail = ((MailListViewItem*)item)->data(); 167 RecMail mail = ((MailListViewItem*)item)->data();
168 RecBody body = folderView->fetchBody(mail); 168 RecBody body = folderView->fetchBody(mail);
169 169
170 ViewMail readMail( this ); 170 ViewMail readMail( this );
171 readMail.setBody( body ); 171 readMail.setBody( body );
172 readMail.setMail( mail ); 172 readMail.setMail( mail );
173 readMail.showMaximized(); 173 readMail.showMaximized();
174 readMail.exec(); 174 readMail.exec();
175 175
176 if ( readMail.deleted ) { 176 if ( readMail.deleted ) {
177 folderView->refreshCurrent(); 177 folderView->refreshCurrent();
178 } else { 178 } else {
179 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); 179 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") );
180 } 180 }
181} 181}
182 182
183void MainWindow::slotDeleteMail() 183void MainWindow::slotDeleteMail()
184{ 184{
185 if (!mailView->currentItem()) return; 185 if (!mailView->currentItem()) return;
186 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 186 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
187 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { 187 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
188 mail.Wrapper()->deleteMail( mail ); 188 mail.Wrapper()->deleteMail( mail );
189 folderView->refreshCurrent(); 189 folderView->refreshCurrent();
190 } 190 }
191} 191}
192 192
193 193
194 194
195MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) 195MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item )
196 :QListViewItem(parent,item),mail_data() 196 :QListViewItem(parent,item),mail_data()
197{ 197{
198} 198}
199 199
200void MailListViewItem::showEntry() 200void MailListViewItem::showEntry()
201{ 201{
202 if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { 202 if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) {
203 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgreplied") );
204 } else if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) {
203 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); 205 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") );
204 } else { 206 } else {
205 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") ); 207 setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") );
206 } 208 }
207 setText(1,mail_data.getSubject()); 209 setText(1,mail_data.getSubject());
208 setText(2,mail_data.getFrom()); 210 setText(2,mail_data.getFrom());
209 setText(3,mail_data.getDate()); 211 setText(3,mail_data.getDate());
210} 212}
211 213
212void MailListViewItem::storeData(const RecMail&data) 214void MailListViewItem::storeData(const RecMail&data)
213{ 215{
214 mail_data = data; 216 mail_data = data;
215} 217}
216 218
217const RecMail& MailListViewItem::data()const 219const RecMail& MailListViewItem::data()const
218{ 220{
219 return mail_data; 221 return mail_data;
220} 222}
221 223
222 224
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index 68d3c51..48b71eb 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -1,330 +1,338 @@
1#include <qtextbrowser.h> 1#include <qtextbrowser.h>
2#include <qmessagebox.h> 2#include <qmessagebox.h>
3#include <qtextstream.h> 3#include <qtextstream.h>
4#include <qaction.h> 4#include <qaction.h>
5#include <qpopupmenu.h> 5#include <qpopupmenu.h>
6#include <qapplication.h> 6#include <qapplication.h>
7 7
8#include <opie/ofiledialog.h> 8#include <opie/ofiledialog.h>
9 9
10#include "settings.h" 10#include "settings.h"
11#include "composemail.h" 11#include "composemail.h"
12#include "viewmail.h" 12#include "viewmail.h"
13#include "abstractmail.h" 13#include "abstractmail.h"
14#include "accountview.h" 14#include "accountview.h"
15 15
16AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num) 16AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
17 const QString&fsize,int num)
17 : QListViewItem(parent,after),_partNum(num) 18 : QListViewItem(parent,after),_partNum(num)
18{ 19{
19 setText(0, mime); 20 setText(0, mime);
20 setText(1, file); 21 setText(1, desc);
21 setText(2, desc); 22 setText(2, file);
23 setText(3, fsize);
22} 24}
23 25
24void ViewMail::setBody( RecBody body ) { 26void ViewMail::setBody( RecBody body ) {
25 27
26m_body = body; 28m_body = body;
27m_mail[2] = body.Bodytext(); 29m_mail[2] = body.Bodytext();
28attachbutton->setEnabled(body.Parts().count()>0); 30attachbutton->setEnabled(body.Parts().count()>0);
29attachments->setEnabled(body.Parts().count()>0); 31attachments->setEnabled(body.Parts().count()>0);
30if (body.Parts().count()==0) { 32if (body.Parts().count()==0) {
31 return; 33 return;
32} 34}
33AttachItem * curItem=0; 35AttachItem * curItem=0;
34QString type=body.Description().Type()+"/"+body.Description().Subtype(); 36QString type=body.Description().Type()+"/"+body.Description().Subtype();
35QString desc; 37QString desc,fsize;
36double s = body.Description().Size(); 38double s = body.Description().Size();
37int w; 39int w;
38w=0; 40w=0;
39 41
40while (s>1024) { 42while (s>1024) {
41 s/=1024; 43 s/=1024;
42 ++w; 44 ++w;
43 if (w>=2) break; 45 if (w>=2) break;
44} 46}
45 47
46QString q=""; 48QString q="";
47switch(w) { 49switch(w) {
48case 1: 50case 1:
49 q="k"; 51 q="k";
50 break; 52 break;
51case 2: 53case 2:
52 q="M"; 54 q="M";
53 break; 55 break;
54default: 56default:
55 break; 57 break;
56} 58}
57 59
58{ 60{
59 /* I did not found a method to make a CONTENT reset on a QTextStream 61 /* I did not found a method to make a CONTENT reset on a QTextStream
60 so I use this construct that the stream will re-constructed in each 62 so I use this construct that the stream will re-constructed in each
61 loop. To let it work, the textstream is packed into a own area of 63 loop. To let it work, the textstream is packed into a own area of
62 code is it will be destructed after finishing its small job. 64 code is it will be destructed after finishing its small job.
63 */ 65 */
64 QTextOStream o(&desc); 66 QTextOStream o(&fsize);
65 if (w>0) o.precision(2); else o.precision(0); 67 if (w>0) o.precision(2); else o.precision(0);
66 o.setf(QTextStream::fixed); 68 o.setf(QTextStream::fixed);
67 o << s << " " << q << "Byte"; 69 o << s << " " << q << "Byte";
68} 70}
69 71
70curItem=new AttachItem(attachments,curItem,type,"Mailbody",desc,-1); 72curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1);
71QString filename = ""; 73QString filename = "";
72for (unsigned int i = 0; i < body.Parts().count();++i) { 74for (unsigned int i = 0; i < body.Parts().count();++i) {
73 type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); 75 type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype();
74 part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); 76 part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin();
75 for (;it!=body.Parts()[i].Parameters().end();++it) { 77 for (;it!=body.Parts()[i].Parameters().end();++it) {
78 qDebug(it.key());
76 if (it.key().lower()=="name") { 79 if (it.key().lower()=="name") {
77 filename=it.data(); 80 filename=it.data();
78 } 81 }
79 } 82 }
80 s = body.Parts()[i].Size(); 83 s = body.Parts()[i].Size();
81 w = 0; 84 w = 0;
82 while (s>1024) { 85 while (s>1024) {
83 s/=1024; 86 s/=1024;
84 ++w; 87 ++w;
85 if (w>=2) break; 88 if (w>=2) break;
86 } 89 }
87 switch(w) { 90 switch(w) {
88 case 1: 91 case 1:
89 q="k"; 92 q="k";
90 break; 93 break;
91 case 2: 94 case 2:
92 q="M"; 95 q="M";
93 break; 96 break;
94 default: 97 default:
95 q=""; 98 q="";
96 break; 99 break;
97 } 100 }
98 QTextOStream o(&desc); 101 QTextOStream o(&fsize);
99 if (w>0) o.precision(2); else o.precision(0); 102 if (w>0) o.precision(2); else o.precision(0);
100 o.setf(QTextStream::fixed); 103 o.setf(QTextStream::fixed);
101 o << s << " " << q << "Byte"; 104 o << s << " " << q << "Byte";
102 curItem=new AttachItem(attachments,curItem,type,filename,desc,i); 105 desc = body.Parts()[i].Description();
106 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i);
103} 107}
104} 108}
105 109
106void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int c ) { 110void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) {
107 if (!item ) 111 if (!item )
108 return; 112 return;
109 113
110 QPopupMenu *menu = new QPopupMenu(); 114 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) {
115 setText();
116 return;
117 }
118 QPopupMenu *menu = new QPopupMenu();
111 int ret=0; 119 int ret=0;
112 120
113 if ( item->text( 0 ).left( 4 ) == "text" ) { 121 if ( item->text( 0 ).left( 5 ) == "text/" ) {
114 menu->insertItem( tr( "Show Text" ), 1 ); 122 menu->insertItem( tr( "Show Text" ), 1 );
115 } 123 }
116 menu->insertItem( tr( "Save Attachment" ), 0 ); 124 menu->insertItem( tr( "Save Attachment" ), 0 );
117 menu->insertSeparator(1); 125 menu->insertSeparator(1);
118 126
119 ret = menu->exec( point, 0 ); 127 ret = menu->exec( point, 0 );
120 128
121 switch(ret) { 129 switch(ret) {
122 case 0: 130 case 0:
123 { MimeTypes types; 131 { MimeTypes types;
124 types.insert( "all", "*" ); 132 types.insert( "all", "*" );
125 QString str = OFileDialog::getSaveFileName( 1, 133 QString str = OFileDialog::getSaveFileName( 1,
126 "/", item->text( 1 ) , types, 0 ); 134 "/", item->text( 2 ) , types, 0 );
127 135
128 if( !str.isEmpty() ) { 136 if( !str.isEmpty() ) {
129 qDebug( "first we will need a MIME wrapper" ); 137 qDebug( "first we will need a MIME wrapper" );
130 } 138 }
131 } 139 }
132 break ; 140 break ;
133 141
134 case 1: 142 case 1:
135 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { 143 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) {
136 setText(); 144 setText();
137 } else { 145 } else {
138 if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions 146 if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions
139 browser->setText( m_recMail.Wrapper()->fetchPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 147 browser->setText( m_recMail.Wrapper()->fetchPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
140 } 148 }
141 } 149 }
142 break; 150 break;
143 } 151 }
144 delete menu; 152 delete menu;
145} 153}
146 154
147 155
148void ViewMail::setMail( RecMail mail ) { 156void ViewMail::setMail( RecMail mail ) {
149 157
150m_recMail = mail; 158m_recMail = mail;
151 159
152m_mail[0] = mail.getFrom(); 160m_mail[0] = mail.getFrom();
153m_mail[1] = mail.getSubject(); 161m_mail[1] = mail.getSubject();
154m_mail[3] = mail.getDate(); 162m_mail[3] = mail.getDate();
155m_mail[4] = mail.Msgid(); 163m_mail[4] = mail.Msgid();
156 164
157m_mail2[0] = mail.To(); 165m_mail2[0] = mail.To();
158m_mail2[1] = mail.CC(); 166m_mail2[1] = mail.CC();
159m_mail2[2] = mail.Bcc(); 167m_mail2[2] = mail.Bcc();
160 168
161setText(); 169setText();
162} 170}
163 171
164 172
165 173
166ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 174ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
167 : ViewMailBase(parent, name, fl), _inLoop(false) 175 : ViewMailBase(parent, name, fl), _inLoop(false)
168{ 176{
169 m_gotBody = false; 177 m_gotBody = false;
170 178
171 connect(reply, SIGNAL(activated()), SLOT(slotReply())); 179 connect(reply, SIGNAL(activated()), SLOT(slotReply()));
172 connect(forward, SIGNAL(activated()), SLOT(slotForward())); 180 connect(forward, SIGNAL(activated()), SLOT(slotForward()));
173 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); 181 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) );
174 182
175 attachments->setEnabled(m_gotBody); 183 attachments->setEnabled(m_gotBody);
176 connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); 184 connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) );
177 185
178} 186}
179 187
180void ViewMail::setText() 188void ViewMail::setText()
181{ 189{
182 190
183 QString toString; 191 QString toString;
184 QString ccString; 192 QString ccString;
185 QString bccString; 193 QString bccString;
186 194
187 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { 195 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) {
188 toString += (*it); 196 toString += (*it);
189 } 197 }
190 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { 198 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) {
191 ccString += (*it); 199 ccString += (*it);
192 } 200 }
193 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { 201 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) {
194 bccString += (*it); 202 bccString += (*it);
195 } 203 }
196 204
197 setCaption( caption().arg( m_mail[0] ) ); 205 setCaption( caption().arg( m_mail[0] ) );
198 206
199 m_mailHtml = "<html><body>" 207 m_mailHtml = "<html><body>"
200 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 208 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
201 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 209 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>"
202 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 210 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
203 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 211 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
204 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 212 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
205 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 213 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
206 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + 214 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] +
207 "</td></tr></table><font face=fixed>"; 215 "</td></tr></table><font face=fixed>";
208 216
209 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 217 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
210 // remove later in favor of a real handling 218 // remove later in favor of a real handling
211 m_gotBody = true; 219 m_gotBody = true;
212} 220}
213 221
214 222
215ViewMail::~ViewMail() 223ViewMail::~ViewMail()
216{ 224{
217 hide(); 225 hide();
218} 226}
219 227
220void ViewMail::hide() 228void ViewMail::hide()
221{ 229{
222 QWidget::hide(); 230 QWidget::hide();
223 231
224 if (_inLoop) { 232 if (_inLoop) {
225 _inLoop = false; 233 _inLoop = false;
226 qApp->exit_loop(); 234 qApp->exit_loop();
227 235
228 } 236 }
229 237
230} 238}
231 239
232void ViewMail::exec() 240void ViewMail::exec()
233{ 241{
234 show(); 242 show();
235 243
236 if (!_inLoop) { 244 if (!_inLoop) {
237 _inLoop = true; 245 _inLoop = true;
238 qApp->enter_loop(); 246 qApp->enter_loop();
239 } 247 }
240 248
241} 249}
242 250
243QString ViewMail::deHtml(const QString &string) 251QString ViewMail::deHtml(const QString &string)
244{ 252{
245 QString string_ = string; 253 QString string_ = string;
246 string_.replace(QRegExp("&"), "&amp;"); 254 string_.replace(QRegExp("&"), "&amp;");
247 string_.replace(QRegExp("<"), "&lt;"); 255 string_.replace(QRegExp("<"), "&lt;");
248 string_.replace(QRegExp(">"), "&gt;"); 256 string_.replace(QRegExp(">"), "&gt;");
249 string_.replace(QRegExp("\\n"), "<br>"); 257 string_.replace(QRegExp("\\n"), "<br>");
250 return string_; 258 return string_;
251} 259}
252 260
253void ViewMail::slotReply() 261void ViewMail::slotReply()
254{ 262{
255 if (!m_gotBody) { 263 if (!m_gotBody) {
256 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); 264 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
257 return; 265 return;
258 } 266 }
259 267
260 QString rtext; 268 QString rtext;
261 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 269 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
262 .arg( m_mail[0] ) 270 .arg( m_mail[0] )
263 .arg( m_mail[3] ); 271 .arg( m_mail[3] );
264 272
265 QString text = m_mail[2]; 273 QString text = m_mail[2];
266 QStringList lines = QStringList::split(QRegExp("\\n"), text); 274 QStringList lines = QStringList::split(QRegExp("\\n"), text);
267 QStringList::Iterator it; 275 QStringList::Iterator it;
268 for (it = lines.begin(); it != lines.end(); it++) { 276 for (it = lines.begin(); it != lines.end(); it++) {
269 rtext += "> " + *it + "\n"; 277 rtext += "> " + *it + "\n";
270 } 278 }
271 rtext += "\n"; 279 rtext += "\n";
272 280
273 QString prefix; 281 QString prefix;
274 if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; 282 if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = "";
275 else prefix = "Re: "; // no i18n on purpose 283 else prefix = "Re: "; // no i18n on purpose
276 284
277 Settings *settings = new Settings(); 285 Settings *settings = new Settings();
278 ComposeMail composer( settings ,this, 0, true); 286 ComposeMail composer( settings ,this, 0, true);
279 composer.setTo( m_mail[0] ); 287 composer.setTo( m_mail[0] );
280 composer.setSubject( "Re: " + m_mail[1] ); 288 composer.setSubject( "Re: " + m_mail[1] );
281 composer.setMessage( rtext ); 289 composer.setMessage( rtext );
282 composer.showMaximized(); 290 composer.showMaximized();
283 if ( QDialog::Accepted==composer.exec()) { 291 if ( QDialog::Accepted==composer.exec()) {
284 m_recMail.Wrapper()->answeredMail(m_recMail); 292 m_recMail.Wrapper()->answeredMail(m_recMail);
285 } 293 }
286} 294}
287 295
288void ViewMail::slotForward() 296void ViewMail::slotForward()
289{ 297{
290 if (!m_gotBody) { 298 if (!m_gotBody) {
291 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); 299 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
292 return; 300 return;
293 } 301 }
294 302
295 QString ftext; 303 QString ftext;
296 ftext += QString("\n----- Forwarded message from %1 -----\n\n") 304 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
297 .arg( m_mail[0] ); 305 .arg( m_mail[0] );
298 if (!m_mail[3].isNull()) 306 if (!m_mail[3].isNull())
299 ftext += QString("Date: %1\n") 307 ftext += QString("Date: %1\n")
300 .arg( m_mail[3] ); 308 .arg( m_mail[3] );
301 if (!m_mail[0].isNull()) 309 if (!m_mail[0].isNull())
302 ftext += QString("From: %1\n") 310 ftext += QString("From: %1\n")
303 .arg( m_mail[0] ); 311 .arg( m_mail[0] );
304 if (!m_mail[1].isNull()) 312 if (!m_mail[1].isNull())
305 ftext += QString("Subject: %1\n") 313 ftext += QString("Subject: %1\n")
306 .arg( m_mail[1] ); 314 .arg( m_mail[1] );
307 315
308 ftext += QString("\n%1\n") 316 ftext += QString("\n%1\n")
309 .arg( m_mail[2]); 317 .arg( m_mail[2]);
310 318
311 ftext += QString("----- End forwarded message -----\n"); 319 ftext += QString("----- End forwarded message -----\n");
312 320
313 Settings *settings = new Settings(); 321 Settings *settings = new Settings();
314 ComposeMail composer( settings ,this, 0, true); 322 ComposeMail composer( settings ,this, 0, true);
315 composer.setSubject( "Fwd: " + m_mail[1] ); 323 composer.setSubject( "Fwd: " + m_mail[1] );
316 composer.setMessage( ftext ); 324 composer.setMessage( ftext );
317 composer.showMaximized(); 325 composer.showMaximized();
318 if ( QDialog::Accepted==composer.exec()) { 326 if ( QDialog::Accepted==composer.exec()) {
319 327
320 } 328 }
321} 329}
322 330
323void ViewMail::slotDeleteMail( ) 331void ViewMail::slotDeleteMail( )
324{ 332{
325 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { 333 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
326 m_recMail.Wrapper()->deleteMail( m_recMail ); 334 m_recMail.Wrapper()->deleteMail( m_recMail );
327 hide(); 335 hide();
328 deleted = true; 336 deleted = true;
329 } 337 }
330} 338}
diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h
index 765464c..dd7f854 100644
--- a/noncore/net/mail/viewmail.h
+++ b/noncore/net/mail/viewmail.h
@@ -1,60 +1,61 @@
1#ifndef VIEWMAIL_H 1#ifndef VIEWMAIL_H
2#define VIEWMAIL_H 2#define VIEWMAIL_H
3 3
4#include <qlistview.h> 4#include <qlistview.h>
5#include <qmap.h> 5#include <qmap.h>
6#include <qstringlist.h> 6#include <qstringlist.h>
7 7
8#include "viewmailbase.h" 8#include "viewmailbase.h"
9#include "mailtypes.h" 9#include "mailtypes.h"
10 10
11class AttachItem : public QListViewItem 11class AttachItem : public QListViewItem
12{ 12{
13public: 13public:
14 AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num); 14 AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
15 const QString&fsize,int num);
15 int Partnumber() { return _partNum; } 16 int Partnumber() { return _partNum; }
16 17
17private: 18private:
18 int _partNum; 19 int _partNum;
19}; 20};
20 21
21class ViewMail : public ViewMailBase 22class ViewMail : public ViewMailBase
22{ 23{
23 Q_OBJECT 24 Q_OBJECT
24 25
25public: 26public:
26 ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); 27 ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal);
27 ~ViewMail(); 28 ~ViewMail();
28 29
29 void hide(); 30 void hide();
30 void exec(); 31 void exec();
31 void setMail( RecMail mail ); 32 void setMail( RecMail mail );
32 void setBody( RecBody body ); 33 void setBody( RecBody body );
33 bool deleted; 34 bool deleted;
34 35
35protected: 36protected:
36 QString deHtml(const QString &string); 37 QString deHtml(const QString &string);
37 38
38protected slots: 39protected slots:
39 void slotReply(); 40 void slotReply();
40 void slotForward(); 41 void slotForward();
41 void setText(); 42 void setText();
42 void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); 43 void slotItemClicked( QListViewItem * item , const QPoint & point, int c );
43 void slotDeleteMail( ); 44 void slotDeleteMail( );
44 45
45 46
46private: 47private:
47 bool _inLoop; 48 bool _inLoop;
48 QString m_mailHtml; 49 QString m_mailHtml;
49 bool m_gotBody; 50 bool m_gotBody;
50 RecBody m_body; 51 RecBody m_body;
51 RecMail m_recMail; 52 RecMail m_recMail;
52 53
53 // 0 from 1 subject 2 bodytext 3 date 54 // 0 from 1 subject 2 bodytext 3 date
54 QMap <int,QString> m_mail; 55 QMap <int,QString> m_mail;
55 // 0 to 1 cc 2 bcc 56 // 0 to 1 cc 2 bcc
56 QMap <int,QStringList> m_mail2; 57 QMap <int,QStringList> m_mail2;
57 58
58}; 59};
59 60
60#endif 61#endif
diff --git a/noncore/net/mail/viewmailbase.cpp b/noncore/net/mail/viewmailbase.cpp
index 38f92b4..0c7f671 100644
--- a/noncore/net/mail/viewmailbase.cpp
+++ b/noncore/net/mail/viewmailbase.cpp
@@ -1,76 +1,77 @@
1#include <qtextbrowser.h> 1#include <qtextbrowser.h>
2#include <qlistview.h> 2#include <qlistview.h>
3#include <qaction.h> 3#include <qaction.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qvbox.h> 5#include <qvbox.h>
6#include <qpopupmenu.h> 6#include <qpopupmenu.h>
7 7
8#include <qpe/qpetoolbar.h> 8#include <qpe/qpetoolbar.h>
9#include <qmenubar.h> 9#include <qmenubar.h>
10#include <qpe/resource.h> 10#include <qpe/resource.h>
11 11
12#include "viewmailbase.h" 12#include "viewmailbase.h"
13//#include "opendiag.h" 13//#include "opendiag.h"
14 14
15ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) 15ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl)
16 : QMainWindow(parent, name, fl) 16 : QMainWindow(parent, name, fl)
17{ 17{
18 setCaption(tr("E-Mail by %1")); 18 setCaption(tr("E-Mail by %1"));
19 setToolBarsMovable(false); 19 setToolBarsMovable(false);
20 20
21 toolbar = new QToolBar(this); 21 toolbar = new QToolBar(this);
22 menubar = new QMenuBar( toolbar ); 22 menubar = new QMenuBar( toolbar );
23 mailmenu = new QPopupMenu( menubar ); 23 mailmenu = new QPopupMenu( menubar );
24 menubar->insertItem( tr( "Mail" ), mailmenu ); 24 menubar->insertItem( tr( "Mail" ), mailmenu );
25 25
26 toolbar->setHorizontalStretchable(true); 26 toolbar->setHorizontalStretchable(true);
27 addToolBar(toolbar); 27 addToolBar(toolbar);
28 28
29 QLabel *spacer = new QLabel(toolbar); 29 QLabel *spacer = new QLabel(toolbar);
30 spacer->setBackgroundMode(QWidget::PaletteButton); 30 spacer->setBackgroundMode(QWidget::PaletteButton);
31 toolbar->setStretchableWidget(spacer); 31 toolbar->setStretchableWidget(spacer);
32 32
33 reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this); 33 reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this);
34 reply->addTo(toolbar); 34 reply->addTo(toolbar);
35 reply->addTo(mailmenu); 35 reply->addTo(mailmenu);
36 36
37 forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this); 37 forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this);
38 forward->addTo(toolbar); 38 forward->addTo(toolbar);
39 forward->addTo(mailmenu); 39 forward->addTo(mailmenu);
40 40
41 attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); 41 attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true);
42 attachbutton->addTo(toolbar); 42 attachbutton->addTo(toolbar);
43 attachbutton->addTo(mailmenu); 43 attachbutton->addTo(mailmenu);
44 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); 44 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool)));
45 45
46 deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); 46 deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this);
47 deleteMail->addTo(toolbar); 47 deleteMail->addTo(toolbar);
48 deleteMail->addTo(mailmenu); 48 deleteMail->addTo(mailmenu);
49 49
50 QVBox *view = new QVBox(this); 50 QVBox *view = new QVBox(this);
51 setCentralWidget(view); 51 setCentralWidget(view);
52 52
53 attachments = new QListView(view); 53 attachments = new QListView(view);
54 attachments->setMinimumHeight(90); 54 attachments->setMinimumHeight(90);
55 attachments->setMaximumHeight(90); 55 attachments->setMaximumHeight(90);
56 attachments->setAllColumnsShowFocus(true); 56 attachments->setAllColumnsShowFocus(true);
57 attachments->addColumn("Mime Type", 60); 57 attachments->addColumn("Mime Type", 60);
58 attachments->addColumn(tr("Filename"), 100); 58 attachments->addColumn(tr("Description"), 100);
59 attachments->addColumn(tr("Size"), 80); 59 attachments->addColumn(tr("Filename"), 80);
60 attachments->addColumn(tr("Size"), 80);
60 attachments->setSorting(-1); 61 attachments->setSorting(-1);
61 attachments->hide(); 62 attachments->hide();
62 63
63 browser = new QTextBrowser(view); 64 browser = new QTextBrowser(view);
64 65
65 //openDiag = new OpenDiag(view); 66 //openDiag = new OpenDiag(view);
66 //openDiag->hide(); 67 //openDiag->hide();
67 68
68} 69}
69 70
70void ViewMailBase::slotChangeAttachview(bool state) 71void ViewMailBase::slotChangeAttachview(bool state)
71{ 72{
72 if (state) attachments->show(); 73 if (state) attachments->show();
73 else attachments->hide(); 74 else attachments->hide();
74} 75}
75 76
76 77