-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 143 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 143 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.h | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 62 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 25 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.cpp | 62 | ||||
-rw-r--r-- | noncore/net/mail/mailtypes.h | 25 |
8 files changed, 282 insertions, 190 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index fa967da..da5974c 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -1,684 +1,693 @@ | |||
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 | ||
8 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 8 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
9 | { | 9 | { |
10 | account = a; | 10 | account = a; |
11 | m_imap = 0; | 11 | m_imap = 0; |
12 | } | 12 | } |
13 | 13 | ||
14 | IMAPwrapper::~IMAPwrapper() | 14 | IMAPwrapper::~IMAPwrapper() |
15 | { | 15 | { |
16 | logout(); | 16 | logout(); |
17 | } | 17 | } |
18 | 18 | ||
19 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 19 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
20 | { | 20 | { |
21 | qDebug( "IMAP: %i of %i", current, maximum ); | 21 | qDebug( "IMAP: %i of %i", current, maximum ); |
22 | } | 22 | } |
23 | 23 | ||
24 | void IMAPwrapper::login() | 24 | void IMAPwrapper::login() |
25 | { | 25 | { |
26 | const char *server, *user, *pass; | 26 | const char *server, *user, *pass; |
27 | uint16_t port; | 27 | uint16_t port; |
28 | int err = MAILIMAP_NO_ERROR; | 28 | int err = MAILIMAP_NO_ERROR; |
29 | 29 | ||
30 | /* we are connected this moment */ | 30 | /* we are connected this moment */ |
31 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 31 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
32 | if (m_imap) { | 32 | if (m_imap) { |
33 | return; | 33 | return; |
34 | } | 34 | } |
35 | server = account->getServer().latin1(); | 35 | server = account->getServer().latin1(); |
36 | port = account->getPort().toUInt(); | 36 | port = account->getPort().toUInt(); |
37 | user = account->getUser().latin1(); | 37 | user = account->getUser().latin1(); |
38 | pass = account->getPassword().latin1(); | 38 | pass = account->getPassword().latin1(); |
39 | 39 | ||
40 | m_imap = mailimap_new( 20, &imap_progress ); | 40 | m_imap = mailimap_new( 20, &imap_progress ); |
41 | /* connect */ | 41 | /* connect */ |
42 | if (account->getSSL()) { | 42 | if (account->getSSL()) { |
43 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); | 43 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); |
44 | } else { | 44 | } else { |
45 | err = mailimap_socket_connect( m_imap, (char*)server, port ); | 45 | err = mailimap_socket_connect( m_imap, (char*)server, port ); |
46 | } | 46 | } |
47 | 47 | ||
48 | if ( err != MAILIMAP_NO_ERROR && | 48 | if ( err != MAILIMAP_NO_ERROR && |
49 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 49 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
50 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 50 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
51 | qDebug("error connecting server: %s",m_imap->imap_response); | 51 | qDebug("error connecting server: %s",m_imap->imap_response); |
52 | mailimap_free( m_imap ); | 52 | mailimap_free( m_imap ); |
53 | m_imap = 0; | 53 | m_imap = 0; |
54 | return; | 54 | return; |
55 | } | 55 | } |
56 | 56 | ||
57 | /* login */ | 57 | /* login */ |
58 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 58 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
59 | if ( err != MAILIMAP_NO_ERROR ) { | 59 | if ( err != MAILIMAP_NO_ERROR ) { |
60 | qDebug("error logging in imap: %s",m_imap->imap_response); | 60 | qDebug("error logging in imap: %s",m_imap->imap_response); |
61 | err = mailimap_close( m_imap ); | 61 | err = mailimap_close( m_imap ); |
62 | mailimap_free( m_imap ); | 62 | mailimap_free( m_imap ); |
63 | m_imap = 0; | 63 | m_imap = 0; |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | void IMAPwrapper::logout() | 67 | void IMAPwrapper::logout() |
68 | { | 68 | { |
69 | int err = MAILIMAP_NO_ERROR; | 69 | int err = MAILIMAP_NO_ERROR; |
70 | if (!m_imap) return; | 70 | if (!m_imap) return; |
71 | err = mailimap_logout( m_imap ); | 71 | err = mailimap_logout( m_imap ); |
72 | err = mailimap_close( m_imap ); | 72 | err = mailimap_close( m_imap ); |
73 | mailimap_free( m_imap ); | 73 | mailimap_free( m_imap ); |
74 | m_imap = 0; | 74 | m_imap = 0; |
75 | } | 75 | } |
76 | 76 | ||
77 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | 77 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) |
78 | { | 78 | { |
79 | const char *mb; | 79 | const char *mb; |
80 | int err = MAILIMAP_NO_ERROR; | 80 | int err = MAILIMAP_NO_ERROR; |
81 | clist *result; | 81 | clist *result; |
82 | clistcell *current; | 82 | clistcell *current; |
83 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; | 83 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; |
84 | mailimap_fetch_type *fetchType; | 84 | mailimap_fetch_type *fetchType; |
85 | mailimap_set *set; | 85 | mailimap_set *set; |
86 | 86 | ||
87 | mb = mailbox.latin1(); | 87 | mb = mailbox.latin1(); |
88 | login(); | 88 | login(); |
89 | if (!m_imap) { | 89 | if (!m_imap) { |
90 | return; | 90 | return; |
91 | } | 91 | } |
92 | /* select mailbox READONLY for operations */ | 92 | /* select mailbox READONLY for operations */ |
93 | err = mailimap_examine( m_imap, (char*)mb); | 93 | err = mailimap_examine( m_imap, (char*)mb); |
94 | if ( err != MAILIMAP_NO_ERROR ) { | 94 | if ( err != MAILIMAP_NO_ERROR ) { |
95 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 95 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
96 | return; | 96 | return; |
97 | } | 97 | } |
98 | 98 | ||
99 | int last = m_imap->imap_selection_info->sel_exists; | 99 | int last = m_imap->imap_selection_info->sel_exists; |
100 | 100 | ||
101 | if (last == 0) { | 101 | if (last == 0) { |
102 | qDebug("mailbox has no mails"); | 102 | qDebug("mailbox has no mails"); |
103 | return; | 103 | return; |
104 | } | 104 | } |
105 | 105 | ||
106 | result = clist_new(); | 106 | result = clist_new(); |
107 | /* the range has to start at 1!!! not with 0!!!! */ | 107 | /* the range has to start at 1!!! not with 0!!!! */ |
108 | set = mailimap_set_new_interval( 1, last ); | 108 | set = mailimap_set_new_interval( 1, last ); |
109 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 109 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
110 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 110 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
111 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 111 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
112 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 112 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
113 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 113 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
114 | 114 | ||
115 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 115 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
116 | mailimap_set_free( set ); | 116 | mailimap_set_free( set ); |
117 | mailimap_fetch_type_free( fetchType ); | 117 | mailimap_fetch_type_free( fetchType ); |
118 | 118 | ||
119 | QString date,subject,from; | 119 | QString date,subject,from; |
120 | 120 | ||
121 | if ( err == MAILIMAP_NO_ERROR ) { | 121 | if ( err == MAILIMAP_NO_ERROR ) { |
122 | 122 | ||
123 | mailimap_msg_att * msg_att; | 123 | mailimap_msg_att * msg_att; |
124 | int i = 0; | 124 | int i = 0; |
125 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 125 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
126 | ++i; | 126 | ++i; |
127 | msg_att = (mailimap_msg_att*)current->data; | 127 | msg_att = (mailimap_msg_att*)current->data; |
128 | RecMail*m = parse_list_result(msg_att); | 128 | RecMail*m = parse_list_result(msg_att); |
129 | if (m) { | 129 | if (m) { |
130 | m->setNumber(i); | 130 | m->setNumber(i); |
131 | m->setMbox(mailbox); | 131 | m->setMbox(mailbox); |
132 | target.append(m); | 132 | target.append(m); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } else { | 135 | } else { |
136 | qDebug("Error fetching headers: %s",m_imap->imap_response); | 136 | qDebug("Error fetching headers: %s",m_imap->imap_response); |
137 | } | 137 | } |
138 | mailimap_fetch_list_free(result); | 138 | mailimap_fetch_list_free(result); |
139 | } | 139 | } |
140 | 140 | ||
141 | QList<IMAPFolder>* IMAPwrapper::listFolders() | 141 | QList<IMAPFolder>* IMAPwrapper::listFolders() |
142 | { | 142 | { |
143 | const char *path, *mask; | 143 | const char *path, *mask; |
144 | int err = MAILIMAP_NO_ERROR; | 144 | int err = MAILIMAP_NO_ERROR; |
145 | clist *result; | 145 | clist *result; |
146 | clistcell *current; | 146 | clistcell *current; |
147 | 147 | ||
148 | QList<IMAPFolder> * folders = new QList<IMAPFolder>(); | 148 | QList<IMAPFolder> * folders = new QList<IMAPFolder>(); |
149 | folders->setAutoDelete( true ); | 149 | folders->setAutoDelete( true ); |
150 | login(); | 150 | login(); |
151 | if (!m_imap) { | 151 | if (!m_imap) { |
152 | return folders; | 152 | return folders; |
153 | } | 153 | } |
154 | 154 | ||
155 | /* | 155 | /* |
156 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 156 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
157 | * We must not forget to filter them out in next loop! | 157 | * We must not forget to filter them out in next loop! |
158 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 158 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
159 | */ | 159 | */ |
160 | QString temp; | 160 | QString temp; |
161 | mask = "INBOX" ; | 161 | mask = "INBOX" ; |
162 | result = clist_new(); | 162 | result = clist_new(); |
163 | mailimap_mailbox_list *list; | 163 | mailimap_mailbox_list *list; |
164 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 164 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
165 | if ( err == MAILIMAP_NO_ERROR ) { | 165 | if ( err == MAILIMAP_NO_ERROR ) { |
166 | current = result->first; | 166 | current = result->first; |
167 | for ( int i = result->count; i > 0; i-- ) { | 167 | for ( int i = result->count; i > 0; i-- ) { |
168 | list = (mailimap_mailbox_list *) current->data; | 168 | list = (mailimap_mailbox_list *) current->data; |
169 | // it is better use the deep copy mechanism of qt itself | 169 | // it is better use the deep copy mechanism of qt itself |
170 | // instead of using strdup! | 170 | // instead of using strdup! |
171 | temp = list->mb_name; | 171 | temp = list->mb_name; |
172 | folders->append( new IMAPFolder(temp)); | 172 | folders->append( new IMAPFolder(temp)); |
173 | current = current->next; | 173 | current = current->next; |
174 | } | 174 | } |
175 | } else { | 175 | } else { |
176 | qDebug("error fetching folders: %s",m_imap->imap_response); | 176 | qDebug("error fetching folders: %s",m_imap->imap_response); |
177 | } | 177 | } |
178 | mailimap_list_result_free( result ); | 178 | mailimap_list_result_free( result ); |
179 | 179 | ||
180 | /* | 180 | /* |
181 | * second stage - get the other then inbox folders | 181 | * second stage - get the other then inbox folders |
182 | */ | 182 | */ |
183 | mask = "*" ; | 183 | mask = "*" ; |
184 | path = account->getPrefix().latin1(); | 184 | path = account->getPrefix().latin1(); |
185 | if (!path) path = ""; | 185 | if (!path) path = ""; |
186 | result = clist_new(); | 186 | result = clist_new(); |
187 | qDebug(path); | 187 | qDebug(path); |
188 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 188 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
189 | if ( err == MAILIMAP_NO_ERROR ) { | 189 | if ( err == MAILIMAP_NO_ERROR ) { |
190 | current = result->first; | 190 | current = result->first; |
191 | for ( int i = result->count; i > 0; i-- ) { | 191 | for ( int i = result->count; i > 0; i-- ) { |
192 | list = (mailimap_mailbox_list *) current->data; | 192 | list = (mailimap_mailbox_list *) current->data; |
193 | // it is better use the deep copy mechanism of qt itself | 193 | // it is better use the deep copy mechanism of qt itself |
194 | // instead of using strdup! | 194 | // instead of using strdup! |
195 | temp = list->mb_name; | 195 | temp = list->mb_name; |
196 | current = current->next; | 196 | current = current->next; |
197 | if (temp.lower()=="inbox") | 197 | if (temp.lower()=="inbox") |
198 | continue; | 198 | continue; |
199 | folders->append(new IMAPFolder(temp)); | 199 | folders->append(new IMAPFolder(temp)); |
200 | 200 | ||
201 | } | 201 | } |
202 | } else { | 202 | } else { |
203 | qDebug("error fetching folders %s",m_imap->imap_response); | 203 | qDebug("error fetching folders %s",m_imap->imap_response); |
204 | } | 204 | } |
205 | mailimap_list_result_free( result ); | 205 | mailimap_list_result_free( result ); |
206 | return folders; | 206 | return folders; |
207 | } | 207 | } |
208 | 208 | ||
209 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 209 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
210 | { | 210 | { |
211 | RecMail * m = 0; | 211 | RecMail * m = 0; |
212 | mailimap_msg_att_item *item=0; | 212 | mailimap_msg_att_item *item=0; |
213 | clistcell *current,*c,*cf; | 213 | clistcell *current,*c,*cf; |
214 | mailimap_msg_att_dynamic*flist; | 214 | mailimap_msg_att_dynamic*flist; |
215 | mailimap_flag_fetch*cflag; | 215 | mailimap_flag_fetch*cflag; |
216 | int size; | 216 | int size; |
217 | QBitArray mFlags(7); | 217 | QBitArray mFlags(7); |
218 | QStringList addresslist; | 218 | QStringList addresslist; |
219 | 219 | ||
220 | if (!m_att) { | 220 | if (!m_att) { |
221 | return m; | 221 | return m; |
222 | } | 222 | } |
223 | m = new RecMail(); | 223 | m = new RecMail(); |
224 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 224 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
225 | current = c; | 225 | current = c; |
226 | size = 0; | 226 | size = 0; |
227 | item = (mailimap_msg_att_item*)current->data; | 227 | item = (mailimap_msg_att_item*)current->data; |
228 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 228 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
229 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 229 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
230 | if (!flist->att_list) { | 230 | if (!flist->att_list) { |
231 | continue; | 231 | continue; |
232 | } | 232 | } |
233 | cf = flist->att_list->first; | 233 | cf = flist->att_list->first; |
234 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 234 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
235 | cflag = (mailimap_flag_fetch*)cf->data; | 235 | cflag = (mailimap_flag_fetch*)cf->data; |
236 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 236 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
237 | switch (cflag->fl_flag->fl_type) { | 237 | switch (cflag->fl_flag->fl_type) { |
238 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 238 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
239 | mFlags.setBit(FLAG_ANSWERED); | 239 | mFlags.setBit(FLAG_ANSWERED); |
240 | break; | 240 | break; |
241 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 241 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
242 | mFlags.setBit(FLAG_FLAGGED); | 242 | mFlags.setBit(FLAG_FLAGGED); |
243 | break; | 243 | break; |
244 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 244 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
245 | mFlags.setBit(FLAG_DELETED); | 245 | mFlags.setBit(FLAG_DELETED); |
246 | break; | 246 | break; |
247 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 247 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
248 | mFlags.setBit(FLAG_SEEN); | 248 | mFlags.setBit(FLAG_SEEN); |
249 | break; | 249 | break; |
250 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 250 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
251 | mFlags.setBit(FLAG_DRAFT); | 251 | mFlags.setBit(FLAG_DRAFT); |
252 | break; | 252 | break; |
253 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 253 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
254 | break; | 254 | break; |
255 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 255 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
256 | break; | 256 | break; |
257 | default: | 257 | default: |
258 | break; | 258 | break; |
259 | } | 259 | } |
260 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 260 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
261 | mFlags.setBit(FLAG_RECENT); | 261 | mFlags.setBit(FLAG_RECENT); |
262 | } | 262 | } |
263 | } | 263 | } |
264 | continue; | 264 | continue; |
265 | } | 265 | } |
266 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 266 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
267 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 267 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
268 | m->setDate(head->env_date); | 268 | m->setDate(head->env_date); |
269 | m->setSubject(head->env_subject); | 269 | m->setSubject(head->env_subject); |
270 | if (head->env_from!=NULL) { | 270 | if (head->env_from!=NULL) { |
271 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 271 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
272 | if (addresslist.count()) { | 272 | if (addresslist.count()) { |
273 | m->setFrom(addresslist.first()); | 273 | m->setFrom(addresslist.first()); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | if (head->env_to!=NULL) { | 276 | if (head->env_to!=NULL) { |
277 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 277 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
278 | m->setTo(addresslist); | 278 | m->setTo(addresslist); |
279 | } | 279 | } |
280 | if (head->env_cc!=NULL) { | 280 | if (head->env_cc!=NULL) { |
281 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 281 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
282 | m->setCC(addresslist); | 282 | m->setCC(addresslist); |
283 | } | 283 | } |
284 | if (head->env_bcc!=NULL) { | 284 | if (head->env_bcc!=NULL) { |
285 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 285 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
286 | m->setBcc(addresslist); | 286 | m->setBcc(addresslist); |
287 | } | 287 | } |
288 | if (head->env_reply_to!=NULL) { | 288 | if (head->env_reply_to!=NULL) { |
289 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 289 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
290 | if (addresslist.count()) { | 290 | if (addresslist.count()) { |
291 | m->setReplyto(addresslist.first()); | 291 | m->setReplyto(addresslist.first()); |
292 | } | 292 | } |
293 | } | 293 | } |
294 | m->setMsgid(QString(head->env_message_id)); | 294 | m->setMsgid(QString(head->env_message_id)); |
295 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 295 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
296 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 296 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
297 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 297 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
298 | 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); | 298 | 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); |
299 | qDebug(da.toString()); | 299 | qDebug(da.toString()); |
300 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 300 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
301 | size = item->att_data.att_static->att_data.att_rfc822_size; | 301 | size = item->att_data.att_static->att_data.att_rfc822_size; |
302 | } | 302 | } |
303 | } | 303 | } |
304 | /* msg is already deleted */ | 304 | /* msg is already deleted */ |
305 | if (mFlags.testBit(FLAG_DELETED) && m) { | 305 | if (mFlags.testBit(FLAG_DELETED) && m) { |
306 | delete m; | 306 | delete m; |
307 | m = 0; | 307 | m = 0; |
308 | } | 308 | } |
309 | if (m) { | 309 | if (m) { |
310 | m->setFlags(mFlags); | 310 | m->setFlags(mFlags); |
311 | m->setMsgsize(size); | 311 | m->setMsgsize(size); |
312 | } | 312 | } |
313 | return m; | 313 | return m; |
314 | } | 314 | } |
315 | 315 | ||
316 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) | 316 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) |
317 | { | 317 | { |
318 | RecBody body; | 318 | RecBody body; |
319 | const char *mb; | 319 | const char *mb; |
320 | int err = MAILIMAP_NO_ERROR; | 320 | int err = MAILIMAP_NO_ERROR; |
321 | clist *result; | 321 | clist *result; |
322 | clistcell *current; | 322 | clistcell *current; |
323 | mailimap_fetch_att *fetchAtt; | 323 | mailimap_fetch_att *fetchAtt; |
324 | mailimap_fetch_type *fetchType; | 324 | mailimap_fetch_type *fetchType; |
325 | mailimap_set *set; | 325 | mailimap_set *set; |
326 | mailimap_body*body_desc; | 326 | mailimap_body*body_desc; |
327 | 327 | ||
328 | mb = mail.getMbox().latin1(); | 328 | mb = mail.getMbox().latin1(); |
329 | 329 | ||
330 | login(); | 330 | login(); |
331 | if (!m_imap) { | 331 | if (!m_imap) { |
332 | return body; | 332 | return body; |
333 | } | 333 | } |
334 | /* select mailbox READONLY for operations */ | 334 | /* select mailbox READONLY for operations */ |
335 | err = mailimap_examine( m_imap, (char*)mb); | 335 | err = mailimap_examine( m_imap, (char*)mb); |
336 | if ( err != MAILIMAP_NO_ERROR ) { | 336 | if ( err != MAILIMAP_NO_ERROR ) { |
337 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 337 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
338 | return body; | 338 | return body; |
339 | } | 339 | } |
340 | 340 | ||
341 | result = clist_new(); | 341 | result = clist_new(); |
342 | /* the range has to start at 1!!! not with 0!!!! */ | 342 | /* the range has to start at 1!!! not with 0!!!! */ |
343 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | 343 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); |
344 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 344 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
345 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 345 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
346 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 346 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
347 | mailimap_set_free( set ); | 347 | mailimap_set_free( set ); |
348 | mailimap_fetch_type_free( fetchType ); | 348 | mailimap_fetch_type_free( fetchType ); |
349 | 349 | ||
350 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 350 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
351 | mailimap_msg_att * msg_att; | 351 | mailimap_msg_att * msg_att; |
352 | msg_att = (mailimap_msg_att*)current->data; | 352 | msg_att = (mailimap_msg_att*)current->data; |
353 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 353 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
354 | body_desc = item->att_data.att_static->att_data.att_body; | 354 | body_desc = item->att_data.att_static->att_data.att_body; |
355 | if (body_desc->bd_type==MAILIMAP_BODY_1PART) { | 355 | if (body_desc->bd_type==MAILIMAP_BODY_1PART) { |
356 | searchBodyText(mail,body_desc->bd_data.bd_body_1part,body); | 356 | searchBodyText(mail,body_desc->bd_data.bd_body_1part,body); |
357 | } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) { | 357 | } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) { |
358 | qDebug("Mulitpart mail"); | 358 | qDebug("Mulitpart mail"); |
359 | searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); | 359 | searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); |
360 | } | 360 | } |
361 | } else { | 361 | } else { |
362 | qDebug("error fetching body: %s",m_imap->imap_response); | 362 | qDebug("error fetching body: %s",m_imap->imap_response); |
363 | } | 363 | } |
364 | mailimap_fetch_list_free(result); | 364 | mailimap_fetch_list_free(result); |
365 | return body; | 365 | return body; |
366 | } | 366 | } |
367 | 367 | ||
368 | /* this routine is just called when the mail has only ONE part. | 368 | /* this routine is just called when the mail has only ONE part. |
369 | for filling the parts of a multi-part-message there are other | 369 | for filling the parts of a multi-part-message there are other |
370 | routines 'cause we can not simply fetch the whole body. */ | 370 | routines 'cause we can not simply fetch the whole body. */ |
371 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) | 371 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) |
372 | { | 372 | { |
373 | if (!mailDescription) { | 373 | if (!mailDescription) { |
374 | return; | 374 | return; |
375 | } | 375 | } |
376 | QString sub; | 376 | QString sub,body_text; |
377 | RecPart singlePart; | ||
378 | QValueList<int> path; | ||
379 | fillSinglePart(singlePart,mailDescription); | ||
377 | switch (mailDescription->bd_type) { | 380 | switch (mailDescription->bd_type) { |
378 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 381 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
379 | target_body.setType("text"); | 382 | path.append(1); |
380 | sub = mailDescription->bd_data.bd_type_text->bd_media_text; | 383 | body_text = fetchPart(mail,path,true); |
381 | target_body.setSubtype(sub.lower()); | 384 | target_body.setBodytext(body_text); |
382 | fillPlainBody(mail,target_body); | 385 | target_body.setDescription(singlePart); |
383 | break; | 386 | break; |
384 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 387 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
385 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); | 388 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); |
386 | target_body.setType("text"); | 389 | path.append(1); |
387 | sub = mailDescription->bd_data.bd_type_text->bd_media_text; | 390 | body_text = fetchPart(mail,path,true); |
388 | target_body.setSubtype(sub.lower()); | 391 | target_body.setBodytext(body_text); |
389 | fillPlainBody(mail,target_body); | 392 | target_body.setDescription(singlePart); |
393 | break; | ||
394 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | ||
395 | qDebug("Single attachment"); | ||
396 | target_body.setBodytext(""); | ||
397 | target_body.addPart(singlePart); | ||
390 | break; | 398 | break; |
391 | default: | 399 | default: |
392 | break; | 400 | break; |
393 | } | 401 | } |
394 | return; | ||
395 | } | ||
396 | |||
397 | void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body) | ||
398 | { | ||
399 | const char *mb; | ||
400 | QString body=""; | ||
401 | int err = MAILIMAP_NO_ERROR; | ||
402 | clist *result; | ||
403 | clistcell *current,*cur; | ||
404 | mailimap_fetch_att *fetchAtt; | ||
405 | mailimap_fetch_type *fetchType; | ||
406 | mailimap_set *set; | ||
407 | |||
408 | mb = mail.getMbox().latin1(); | ||
409 | |||
410 | if (!m_imap) { | ||
411 | return; | ||
412 | } | ||
413 | |||
414 | result = clist_new(); | ||
415 | set = set = mailimap_set_new_single(mail.getNumber()); | ||
416 | mailimap_section * section = mailimap_section_new_text(); | ||
417 | fetchAtt = mailimap_fetch_att_new_body_peek_section(section); | ||
418 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | ||
419 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | ||
420 | mailimap_set_free( set ); | ||
421 | mailimap_fetch_type_free( fetchType ); | ||
422 | |||
423 | 402 | ||
424 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | ||
425 | mailimap_msg_att * msg_att; | ||
426 | msg_att = (mailimap_msg_att*)current->data; | ||
427 | mailimap_msg_att_item*msg_att_item; | ||
428 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | ||
429 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | ||
430 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | ||
431 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | ||
432 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | ||
433 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | ||
434 | if (text) { | ||
435 | body = QString(text); | ||
436 | free(text); | ||
437 | } else { | ||
438 | body = ""; | ||
439 | } | ||
440 | } | ||
441 | } | ||
442 | } | ||
443 | |||
444 | } else { | ||
445 | qDebug("error fetching text: %s",m_imap->imap_response); | ||
446 | } | ||
447 | mailimap_fetch_list_free(result); | ||
448 | target_body.setBodytext(body); | ||
449 | return; | 403 | return; |
450 | } | 404 | } |
451 | 405 | ||
452 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 406 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
453 | { | 407 | { |
454 | QStringList l; | 408 | QStringList l; |
455 | QString from; | 409 | QString from; |
456 | bool named_from; | 410 | bool named_from; |
457 | clistcell *current = NULL; | 411 | clistcell *current = NULL; |
458 | mailimap_address * current_address=NULL; | 412 | mailimap_address * current_address=NULL; |
459 | if (!list) { | 413 | if (!list) { |
460 | return l; | 414 | return l; |
461 | } | 415 | } |
462 | unsigned int count = 0; | 416 | unsigned int count = 0; |
463 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 417 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
464 | from = ""; | 418 | from = ""; |
465 | named_from = false; | 419 | named_from = false; |
466 | current_address=(mailimap_address*)current->data; | 420 | current_address=(mailimap_address*)current->data; |
467 | if (current_address->ad_personal_name){ | 421 | if (current_address->ad_personal_name){ |
468 | from+=QString(current_address->ad_personal_name); | 422 | from+=QString(current_address->ad_personal_name); |
469 | from+=" "; | 423 | from+=" "; |
470 | named_from = true; | 424 | named_from = true; |
471 | } | 425 | } |
472 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 426 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
473 | from+="<"; | 427 | from+="<"; |
474 | } | 428 | } |
475 | if (current_address->ad_mailbox_name) { | 429 | if (current_address->ad_mailbox_name) { |
476 | from+=QString(current_address->ad_mailbox_name); | 430 | from+=QString(current_address->ad_mailbox_name); |
477 | from+="@"; | 431 | from+="@"; |
478 | } | 432 | } |
479 | if (current_address->ad_host_name) { | 433 | if (current_address->ad_host_name) { |
480 | from+=QString(current_address->ad_host_name); | 434 | from+=QString(current_address->ad_host_name); |
481 | } | 435 | } |
482 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 436 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
483 | from+=">"; | 437 | from+=">"; |
484 | } | 438 | } |
485 | l.append(QString(from)); | 439 | l.append(QString(from)); |
486 | if (++count > 99) { | 440 | if (++count > 99) { |
487 | break; | 441 | break; |
488 | } | 442 | } |
489 | } | 443 | } |
490 | return l; | 444 | return l; |
491 | } | 445 | } |
492 | 446 | ||
493 | QString IMAPwrapper::fetchPart(const RecMail&mail,QValueList<int>&path,bool internal_call) | 447 | QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) |
494 | { | 448 | { |
495 | QString body(""); | 449 | QString body(""); |
496 | const char*mb; | 450 | const char*mb; |
497 | int err; | 451 | int err; |
498 | mailimap_fetch_type *fetchType; | 452 | mailimap_fetch_type *fetchType; |
499 | mailimap_set *set; | 453 | mailimap_set *set; |
500 | clistcell*current,*cur; | 454 | clistcell*current,*cur; |
501 | 455 | ||
502 | login(); | 456 | login(); |
503 | if (!m_imap) { | 457 | if (!m_imap) { |
504 | return body; | 458 | return body; |
505 | } | 459 | } |
506 | if (!internal_call) { | 460 | if (!internal_call) { |
507 | mb = mail.getMbox().latin1(); | 461 | mb = mail.getMbox().latin1(); |
508 | /* select mailbox READONLY for operations */ | 462 | /* select mailbox READONLY for operations */ |
509 | err = mailimap_examine( m_imap, (char*)mb); | 463 | err = mailimap_examine( m_imap, (char*)mb); |
510 | if ( err != MAILIMAP_NO_ERROR ) { | 464 | if ( err != MAILIMAP_NO_ERROR ) { |
511 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 465 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
512 | return body; | 466 | return body; |
513 | } | 467 | } |
514 | } | 468 | } |
515 | set = mailimap_set_new_single(mail.getNumber()); | 469 | set = mailimap_set_new_single(mail.getNumber()); |
516 | clist*id_list=clist_new(); | 470 | clist*id_list=clist_new(); |
517 | for (unsigned j=0; j < path.count();++j) { | 471 | for (unsigned j=0; j < path.count();++j) { |
518 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 472 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
519 | *p_id = path[j]; | 473 | *p_id = path[j]; |
520 | clist_append(id_list,p_id); | 474 | clist_append(id_list,p_id); |
521 | } | 475 | } |
522 | mailimap_section_part * section_part = mailimap_section_part_new(id_list); | 476 | mailimap_section_part * section_part = mailimap_section_part_new(id_list); |
523 | mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 477 | mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
524 | mailimap_section * section = mailimap_section_new(section_spec); | 478 | mailimap_section * section = mailimap_section_new(section_spec); |
525 | mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); | 479 | mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); |
526 | 480 | ||
527 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 481 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
528 | 482 | ||
529 | clist*result = clist_new(); | 483 | clist*result = clist_new(); |
530 | 484 | ||
531 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 485 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
532 | mailimap_set_free( set ); | 486 | mailimap_set_free( set ); |
533 | mailimap_fetch_type_free( fetchType ); | 487 | mailimap_fetch_type_free( fetchType ); |
534 | 488 | ||
535 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 489 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
536 | mailimap_msg_att * msg_att; | 490 | mailimap_msg_att * msg_att; |
537 | msg_att = (mailimap_msg_att*)current->data; | 491 | msg_att = (mailimap_msg_att*)current->data; |
538 | mailimap_msg_att_item*msg_att_item; | 492 | mailimap_msg_att_item*msg_att_item; |
539 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 493 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
540 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 494 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
541 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 495 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
542 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 496 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
543 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 497 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
544 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 498 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
545 | if (text) { | 499 | if (text) { |
546 | body = QString(text); | 500 | body = QString(text); |
547 | free(text); | 501 | free(text); |
548 | } else { | 502 | } else { |
549 | body = ""; | 503 | body = ""; |
550 | } | 504 | } |
551 | } | 505 | } |
552 | } | 506 | } |
553 | } | 507 | } |
554 | 508 | ||
555 | } else { | 509 | } else { |
556 | qDebug("error fetching text: %s",m_imap->imap_response); | 510 | qDebug("error fetching text: %s",m_imap->imap_response); |
557 | } | 511 | } |
558 | mailimap_fetch_list_free(result); | 512 | mailimap_fetch_list_free(result); |
559 | return body; | 513 | return body; |
560 | } | 514 | } |
561 | 515 | ||
562 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList) | 516 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList) |
563 | { | 517 | { |
564 | /* current_recursion is for avoiding ugly mails which has a to deep body-structure */ | 518 | /* current_recursion is for avoiding ugly mails which has a to deep body-structure */ |
565 | if (!mailDescription||current_recursion==10) { | 519 | if (!mailDescription||current_recursion==10) { |
566 | return; | 520 | return; |
567 | } | 521 | } |
568 | clistcell*current; | 522 | clistcell*current; |
569 | mailimap_body*current_body; | 523 | mailimap_body*current_body; |
570 | unsigned int count = 0; | 524 | unsigned int count = 0; |
571 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 525 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
572 | /* the point in the message */ | 526 | /* the point in the message */ |
573 | ++count; | 527 | ++count; |
574 | current_body = (mailimap_body*)current->data; | 528 | current_body = (mailimap_body*)current->data; |
575 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 529 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
576 | QValueList<int>clist = recList; | 530 | QValueList<int>clist = recList; |
577 | clist.append(count); | 531 | clist.append(count); |
578 | searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,clist); | 532 | searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,clist); |
579 | } else if (current_body->bd_type==MAILIMAP_BODY_1PART){ | 533 | } else if (current_body->bd_type==MAILIMAP_BODY_1PART){ |
580 | RecPart currentPart; | 534 | RecPart currentPart; |
581 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); | 535 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); |
582 | QValueList<int>clist = recList; | 536 | QValueList<int>clist = recList; |
583 | clist.append(count); | 537 | clist.append(count); |
584 | /* important: Check for is NULL 'cause a body can be empty! */ | 538 | /* important: Check for is NULL 'cause a body can be empty! */ |
585 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { | 539 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { |
586 | QString body_text = fetchPart(mail,clist,true); | 540 | QString body_text = fetchPart(mail,clist,true); |
541 | target_body.setDescription(currentPart); | ||
587 | target_body.setBodytext(body_text); | 542 | target_body.setBodytext(body_text); |
588 | target_body.setType(currentPart.Type()); | ||
589 | target_body.setSubtype(currentPart.Subtype()); | ||
590 | } else { | 543 | } else { |
591 | QString id(""); | 544 | QString id(""); |
592 | for (unsigned int j = 0; j < clist.count();++j) { | 545 | for (unsigned int j = 0; j < clist.count();++j) { |
593 | id+=(j>0?".":""); | 546 | id+=(j>0?" ":""); |
594 | id+=QString("%1").arg(clist[j]); | 547 | id+=QString("%1").arg(clist[j]); |
595 | } | 548 | } |
596 | qDebug("ID= %s",id.latin1()); | 549 | qDebug("ID= %s",id.latin1()); |
597 | currentPart.setIdentifier(id); | 550 | currentPart.setIdentifier(id); |
551 | currentPart.setPositionlist(clist); | ||
598 | target_body.addPart(currentPart); | 552 | target_body.addPart(currentPart); |
599 | } | 553 | } |
600 | } | 554 | } |
601 | } | 555 | } |
602 | } | 556 | } |
603 | 557 | ||
604 | void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) | 558 | void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) |
605 | { | 559 | { |
606 | if (!Description) { | 560 | if (!Description) { |
607 | return; | 561 | return; |
608 | } | 562 | } |
609 | switch (Description->bd_type) { | 563 | switch (Description->bd_type) { |
610 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 564 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
611 | target_part.setType("text"); | 565 | target_part.setType("text"); |
612 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 566 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
613 | break; | 567 | break; |
614 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 568 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
615 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 569 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
616 | break; | 570 | break; |
571 | case MAILIMAP_BODY_TYPE_1PART_MSG: | ||
572 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | ||
573 | break; | ||
617 | default: | 574 | default: |
618 | break; | 575 | break; |
619 | } | 576 | } |
620 | } | 577 | } |
621 | 578 | ||
622 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) | 579 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) |
623 | { | 580 | { |
624 | if (!which) { | 581 | if (!which) { |
625 | return; | 582 | return; |
626 | } | 583 | } |
627 | QString sub; | 584 | QString sub; |
628 | sub = which->bd_media_text; | 585 | sub = which->bd_media_text; |
629 | target_part.setSubtype(sub.lower()); | 586 | target_part.setSubtype(sub.lower()); |
630 | target_part.setLines(which->bd_lines); | 587 | target_part.setLines(which->bd_lines); |
631 | fillBodyFields(target_part,which->bd_fields); | 588 | fillBodyFields(target_part,which->bd_fields); |
632 | } | 589 | } |
633 | 590 | ||
591 | void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) | ||
592 | { | ||
593 | if (!which) { | ||
594 | return; | ||
595 | } | ||
596 | // QString sub; | ||
597 | // sub = which->bd_media_text; | ||
598 | // target_part.setSubtype(sub.lower()); | ||
599 | qDebug("Message part"); | ||
600 | /* we set this type to text/plain */ | ||
601 | target_part.setType("text"); | ||
602 | target_part.setSubtype("plain"); | ||
603 | target_part.setLines(which->bd_lines); | ||
604 | fillBodyFields(target_part,which->bd_fields); | ||
605 | } | ||
606 | |||
634 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) | 607 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) |
635 | { | 608 | { |
636 | if (!which) { | 609 | if (!which) { |
637 | return; | 610 | return; |
638 | } | 611 | } |
639 | QString type,sub; | 612 | QString type,sub; |
640 | switch (which->bd_media_basic->med_type) { | 613 | switch (which->bd_media_basic->med_type) { |
641 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | 614 | case MAILIMAP_MEDIA_BASIC_APPLICATION: |
642 | type = "application"; | 615 | type = "application"; |
643 | break; | 616 | break; |
644 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 617 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
645 | type = "audio"; | 618 | type = "audio"; |
646 | break; | 619 | break; |
647 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 620 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
648 | type = "image"; | 621 | type = "image"; |
649 | break; | 622 | break; |
650 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 623 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
651 | type = "message"; | 624 | type = "message"; |
652 | break; | 625 | break; |
653 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 626 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
654 | type = "video"; | 627 | type = "video"; |
655 | break; | 628 | break; |
656 | case MAILIMAP_MEDIA_BASIC_OTHER: | 629 | case MAILIMAP_MEDIA_BASIC_OTHER: |
657 | default: | 630 | default: |
658 | if (which->bd_media_basic->med_basic_type) { | 631 | if (which->bd_media_basic->med_basic_type) { |
659 | type = which->bd_media_basic->med_basic_type; | 632 | type = which->bd_media_basic->med_basic_type; |
660 | } else { | 633 | } else { |
661 | type = ""; | 634 | type = ""; |
662 | } | 635 | } |
663 | break; | 636 | break; |
664 | } | 637 | } |
665 | if (which->bd_media_basic->med_subtype) { | 638 | if (which->bd_media_basic->med_subtype) { |
666 | sub = which->bd_media_basic->med_subtype; | 639 | sub = which->bd_media_basic->med_subtype; |
667 | } else { | 640 | } else { |
668 | sub = ""; | 641 | sub = ""; |
669 | } | 642 | } |
670 | qDebug("Type = %s/%s",type.latin1(),sub.latin1()); | 643 | qDebug("Type = %s/%s",type.latin1(),sub.latin1()); |
671 | target_part.setType(type.lower()); | 644 | target_part.setType(type.lower()); |
672 | target_part.setSubtype(sub.lower()); | 645 | target_part.setSubtype(sub.lower()); |
673 | fillBodyFields(target_part,which->bd_fields); | 646 | fillBodyFields(target_part,which->bd_fields); |
674 | } | 647 | } |
675 | 648 | ||
676 | void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | 649 | void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) |
677 | { | 650 | { |
678 | if (!which) return; | 651 | if (!which) return; |
679 | clistcell*cur; | 652 | clistcell*cur; |
680 | mailimap_single_body_fld_param*param; | 653 | mailimap_single_body_fld_param*param; |
681 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 654 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
682 | param = (mailimap_single_body_fld_param*)cur->data; | 655 | param = (mailimap_single_body_fld_param*)cur->data; |
656 | if (param) { | ||
657 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | ||
658 | } | ||
683 | } | 659 | } |
660 | mailimap_body_fld_enc*enc = which->bd_encoding; | ||
661 | QString encoding(""); | ||
662 | switch (enc->enc_type) { | ||
663 | case MAILIMAP_BODY_FLD_ENC_7BIT: | ||
664 | encoding = "7bit"; | ||
665 | break; | ||
666 | case MAILIMAP_BODY_FLD_ENC_8BIT: | ||
667 | encoding = "8bit"; | ||
668 | break; | ||
669 | case MAILIMAP_BODY_FLD_ENC_BINARY: | ||
670 | encoding="binary"; | ||
671 | break; | ||
672 | case MAILIMAP_BODY_FLD_ENC_BASE64: | ||
673 | encoding="base64"; | ||
674 | break; | ||
675 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | ||
676 | encoding="quoted-printable"; | ||
677 | break; | ||
678 | case MAILIMAP_BODY_FLD_ENC_OTHER: | ||
679 | default: | ||
680 | if (enc->enc_value) { | ||
681 | char*t=enc->enc_value; | ||
682 | encoding=QString(enc->enc_value); | ||
683 | enc->enc_value=0L; | ||
684 | free(t); | ||
685 | } | ||
686 | } | ||
687 | target_part.setEncoding(encoding); | ||
688 | } | ||
689 | |||
690 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) | ||
691 | { | ||
692 | return fetchPart(mail,part.Positionlist(),false); | ||
684 | } | 693 | } |
diff --git a/noncore/net/mail/imapwrapper.h b/noncore/net/mail/imapwrapper.h index 5ea45f3..95de215 100644 --- a/noncore/net/mail/imapwrapper.h +++ b/noncore/net/mail/imapwrapper.h | |||
@@ -1,53 +1,55 @@ | |||
1 | #ifndef __IMAPWRAPPER | 1 | #ifndef __IMAPWRAPPER |
2 | #define __IMAPWRAPPER | 2 | #define __IMAPWRAPPER |
3 | 3 | ||
4 | #include <qlist.h> | 4 | #include <qlist.h> |
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | 6 | ||
7 | struct mailimap; | 7 | struct mailimap; |
8 | struct mailimap_body_type_1part; | 8 | struct mailimap_body_type_1part; |
9 | struct mailimap_body_type_text; | 9 | struct mailimap_body_type_text; |
10 | struct mailimap_body_type_basic; | 10 | struct mailimap_body_type_basic; |
11 | struct mailimap_body_type_msg; | ||
11 | struct mailimap_body_type_mpart; | 12 | struct mailimap_body_type_mpart; |
12 | struct mailimap_body_fields; | 13 | struct mailimap_body_fields; |
13 | struct mailimap_msg_att; | 14 | struct mailimap_msg_att; |
14 | class RecMail; | 15 | class RecMail; |
15 | class RecBody; | 16 | class RecBody; |
16 | class RecPart; | 17 | class RecPart; |
17 | 18 | ||
18 | class IMAPwrapper : public QObject | 19 | class IMAPwrapper : public QObject |
19 | { | 20 | { |
20 | Q_OBJECT | 21 | Q_OBJECT |
21 | 22 | ||
22 | public: | 23 | public: |
23 | IMAPwrapper( IMAPaccount *a ); | 24 | IMAPwrapper( IMAPaccount *a ); |
24 | virtual ~IMAPwrapper(); | 25 | virtual ~IMAPwrapper(); |
25 | QList<IMAPFolder>* listFolders(); | 26 | QList<IMAPFolder>* listFolders(); |
26 | void listMessages(const QString & mailbox,QList<RecMail>&target ); | 27 | void listMessages(const QString & mailbox,QList<RecMail>&target ); |
27 | RecBody fetchBody(const RecMail&mail); | 28 | RecBody fetchBody(const RecMail&mail); |
28 | QString fetchPart(const RecMail&mail,QValueList<int>&path,bool internal_call=false); | 29 | QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false); |
30 | QString fetchPart(const RecMail&mail,const RecPart&part); | ||
29 | static void imap_progress( size_t current, size_t maximum ); | 31 | static void imap_progress( size_t current, size_t maximum ); |
30 | 32 | ||
31 | protected: | 33 | protected: |
32 | RecMail*parse_list_result(mailimap_msg_att*); | 34 | RecMail*parse_list_result(mailimap_msg_att*); |
33 | void login(); | 35 | void login(); |
34 | void logout(); | 36 | void logout(); |
35 | 37 | ||
36 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); | 38 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); |
37 | void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); | 39 | void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); |
38 | 40 | ||
39 | void fillPlainBody(const RecMail&mail,RecBody&target_body); | ||
40 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 41 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
41 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 42 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
42 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 43 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
44 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | ||
43 | 45 | ||
44 | /* just helpers */ | 46 | /* just helpers */ |
45 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 47 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
46 | static QStringList address_list_to_stringlist(clist*list); | 48 | static QStringList address_list_to_stringlist(clist*list); |
47 | 49 | ||
48 | private: | 50 | private: |
49 | IMAPaccount *account; | 51 | IMAPaccount *account; |
50 | mailimap *m_imap; | 52 | mailimap *m_imap; |
51 | }; | 53 | }; |
52 | 54 | ||
53 | #endif | 55 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index fa967da..da5974c 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,684 +1,693 @@ | |||
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 | ||
8 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 8 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
9 | { | 9 | { |
10 | account = a; | 10 | account = a; |
11 | m_imap = 0; | 11 | m_imap = 0; |
12 | } | 12 | } |
13 | 13 | ||
14 | IMAPwrapper::~IMAPwrapper() | 14 | IMAPwrapper::~IMAPwrapper() |
15 | { | 15 | { |
16 | logout(); | 16 | logout(); |
17 | } | 17 | } |
18 | 18 | ||
19 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 19 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
20 | { | 20 | { |
21 | qDebug( "IMAP: %i of %i", current, maximum ); | 21 | qDebug( "IMAP: %i of %i", current, maximum ); |
22 | } | 22 | } |
23 | 23 | ||
24 | void IMAPwrapper::login() | 24 | void IMAPwrapper::login() |
25 | { | 25 | { |
26 | const char *server, *user, *pass; | 26 | const char *server, *user, *pass; |
27 | uint16_t port; | 27 | uint16_t port; |
28 | int err = MAILIMAP_NO_ERROR; | 28 | int err = MAILIMAP_NO_ERROR; |
29 | 29 | ||
30 | /* we are connected this moment */ | 30 | /* we are connected this moment */ |
31 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 31 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
32 | if (m_imap) { | 32 | if (m_imap) { |
33 | return; | 33 | return; |
34 | } | 34 | } |
35 | server = account->getServer().latin1(); | 35 | server = account->getServer().latin1(); |
36 | port = account->getPort().toUInt(); | 36 | port = account->getPort().toUInt(); |
37 | user = account->getUser().latin1(); | 37 | user = account->getUser().latin1(); |
38 | pass = account->getPassword().latin1(); | 38 | pass = account->getPassword().latin1(); |
39 | 39 | ||
40 | m_imap = mailimap_new( 20, &imap_progress ); | 40 | m_imap = mailimap_new( 20, &imap_progress ); |
41 | /* connect */ | 41 | /* connect */ |
42 | if (account->getSSL()) { | 42 | if (account->getSSL()) { |
43 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); | 43 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); |
44 | } else { | 44 | } else { |
45 | err = mailimap_socket_connect( m_imap, (char*)server, port ); | 45 | err = mailimap_socket_connect( m_imap, (char*)server, port ); |
46 | } | 46 | } |
47 | 47 | ||
48 | if ( err != MAILIMAP_NO_ERROR && | 48 | if ( err != MAILIMAP_NO_ERROR && |
49 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 49 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
50 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 50 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
51 | qDebug("error connecting server: %s",m_imap->imap_response); | 51 | qDebug("error connecting server: %s",m_imap->imap_response); |
52 | mailimap_free( m_imap ); | 52 | mailimap_free( m_imap ); |
53 | m_imap = 0; | 53 | m_imap = 0; |
54 | return; | 54 | return; |
55 | } | 55 | } |
56 | 56 | ||
57 | /* login */ | 57 | /* login */ |
58 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 58 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
59 | if ( err != MAILIMAP_NO_ERROR ) { | 59 | if ( err != MAILIMAP_NO_ERROR ) { |
60 | qDebug("error logging in imap: %s",m_imap->imap_response); | 60 | qDebug("error logging in imap: %s",m_imap->imap_response); |
61 | err = mailimap_close( m_imap ); | 61 | err = mailimap_close( m_imap ); |
62 | mailimap_free( m_imap ); | 62 | mailimap_free( m_imap ); |
63 | m_imap = 0; | 63 | m_imap = 0; |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | void IMAPwrapper::logout() | 67 | void IMAPwrapper::logout() |
68 | { | 68 | { |
69 | int err = MAILIMAP_NO_ERROR; | 69 | int err = MAILIMAP_NO_ERROR; |
70 | if (!m_imap) return; | 70 | if (!m_imap) return; |
71 | err = mailimap_logout( m_imap ); | 71 | err = mailimap_logout( m_imap ); |
72 | err = mailimap_close( m_imap ); | 72 | err = mailimap_close( m_imap ); |
73 | mailimap_free( m_imap ); | 73 | mailimap_free( m_imap ); |
74 | m_imap = 0; | 74 | m_imap = 0; |
75 | } | 75 | } |
76 | 76 | ||
77 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | 77 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) |
78 | { | 78 | { |
79 | const char *mb; | 79 | const char *mb; |
80 | int err = MAILIMAP_NO_ERROR; | 80 | int err = MAILIMAP_NO_ERROR; |
81 | clist *result; | 81 | clist *result; |
82 | clistcell *current; | 82 | clistcell *current; |
83 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; | 83 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; |
84 | mailimap_fetch_type *fetchType; | 84 | mailimap_fetch_type *fetchType; |
85 | mailimap_set *set; | 85 | mailimap_set *set; |
86 | 86 | ||
87 | mb = mailbox.latin1(); | 87 | mb = mailbox.latin1(); |
88 | login(); | 88 | login(); |
89 | if (!m_imap) { | 89 | if (!m_imap) { |
90 | return; | 90 | return; |
91 | } | 91 | } |
92 | /* select mailbox READONLY for operations */ | 92 | /* select mailbox READONLY for operations */ |
93 | err = mailimap_examine( m_imap, (char*)mb); | 93 | err = mailimap_examine( m_imap, (char*)mb); |
94 | if ( err != MAILIMAP_NO_ERROR ) { | 94 | if ( err != MAILIMAP_NO_ERROR ) { |
95 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 95 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
96 | return; | 96 | return; |
97 | } | 97 | } |
98 | 98 | ||
99 | int last = m_imap->imap_selection_info->sel_exists; | 99 | int last = m_imap->imap_selection_info->sel_exists; |
100 | 100 | ||
101 | if (last == 0) { | 101 | if (last == 0) { |
102 | qDebug("mailbox has no mails"); | 102 | qDebug("mailbox has no mails"); |
103 | return; | 103 | return; |
104 | } | 104 | } |
105 | 105 | ||
106 | result = clist_new(); | 106 | result = clist_new(); |
107 | /* the range has to start at 1!!! not with 0!!!! */ | 107 | /* the range has to start at 1!!! not with 0!!!! */ |
108 | set = mailimap_set_new_interval( 1, last ); | 108 | set = mailimap_set_new_interval( 1, last ); |
109 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 109 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
110 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 110 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
111 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 111 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
112 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 112 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
113 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 113 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
114 | 114 | ||
115 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 115 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
116 | mailimap_set_free( set ); | 116 | mailimap_set_free( set ); |
117 | mailimap_fetch_type_free( fetchType ); | 117 | mailimap_fetch_type_free( fetchType ); |
118 | 118 | ||
119 | QString date,subject,from; | 119 | QString date,subject,from; |
120 | 120 | ||
121 | if ( err == MAILIMAP_NO_ERROR ) { | 121 | if ( err == MAILIMAP_NO_ERROR ) { |
122 | 122 | ||
123 | mailimap_msg_att * msg_att; | 123 | mailimap_msg_att * msg_att; |
124 | int i = 0; | 124 | int i = 0; |
125 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 125 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
126 | ++i; | 126 | ++i; |
127 | msg_att = (mailimap_msg_att*)current->data; | 127 | msg_att = (mailimap_msg_att*)current->data; |
128 | RecMail*m = parse_list_result(msg_att); | 128 | RecMail*m = parse_list_result(msg_att); |
129 | if (m) { | 129 | if (m) { |
130 | m->setNumber(i); | 130 | m->setNumber(i); |
131 | m->setMbox(mailbox); | 131 | m->setMbox(mailbox); |
132 | target.append(m); | 132 | target.append(m); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } else { | 135 | } else { |
136 | qDebug("Error fetching headers: %s",m_imap->imap_response); | 136 | qDebug("Error fetching headers: %s",m_imap->imap_response); |
137 | } | 137 | } |
138 | mailimap_fetch_list_free(result); | 138 | mailimap_fetch_list_free(result); |
139 | } | 139 | } |
140 | 140 | ||
141 | QList<IMAPFolder>* IMAPwrapper::listFolders() | 141 | QList<IMAPFolder>* IMAPwrapper::listFolders() |
142 | { | 142 | { |
143 | const char *path, *mask; | 143 | const char *path, *mask; |
144 | int err = MAILIMAP_NO_ERROR; | 144 | int err = MAILIMAP_NO_ERROR; |
145 | clist *result; | 145 | clist *result; |
146 | clistcell *current; | 146 | clistcell *current; |
147 | 147 | ||
148 | QList<IMAPFolder> * folders = new QList<IMAPFolder>(); | 148 | QList<IMAPFolder> * folders = new QList<IMAPFolder>(); |
149 | folders->setAutoDelete( true ); | 149 | folders->setAutoDelete( true ); |
150 | login(); | 150 | login(); |
151 | if (!m_imap) { | 151 | if (!m_imap) { |
152 | return folders; | 152 | return folders; |
153 | } | 153 | } |
154 | 154 | ||
155 | /* | 155 | /* |
156 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 156 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
157 | * We must not forget to filter them out in next loop! | 157 | * We must not forget to filter them out in next loop! |
158 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 158 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
159 | */ | 159 | */ |
160 | QString temp; | 160 | QString temp; |
161 | mask = "INBOX" ; | 161 | mask = "INBOX" ; |
162 | result = clist_new(); | 162 | result = clist_new(); |
163 | mailimap_mailbox_list *list; | 163 | mailimap_mailbox_list *list; |
164 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 164 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
165 | if ( err == MAILIMAP_NO_ERROR ) { | 165 | if ( err == MAILIMAP_NO_ERROR ) { |
166 | current = result->first; | 166 | current = result->first; |
167 | for ( int i = result->count; i > 0; i-- ) { | 167 | for ( int i = result->count; i > 0; i-- ) { |
168 | list = (mailimap_mailbox_list *) current->data; | 168 | list = (mailimap_mailbox_list *) current->data; |
169 | // it is better use the deep copy mechanism of qt itself | 169 | // it is better use the deep copy mechanism of qt itself |
170 | // instead of using strdup! | 170 | // instead of using strdup! |
171 | temp = list->mb_name; | 171 | temp = list->mb_name; |
172 | folders->append( new IMAPFolder(temp)); | 172 | folders->append( new IMAPFolder(temp)); |
173 | current = current->next; | 173 | current = current->next; |
174 | } | 174 | } |
175 | } else { | 175 | } else { |
176 | qDebug("error fetching folders: %s",m_imap->imap_response); | 176 | qDebug("error fetching folders: %s",m_imap->imap_response); |
177 | } | 177 | } |
178 | mailimap_list_result_free( result ); | 178 | mailimap_list_result_free( result ); |
179 | 179 | ||
180 | /* | 180 | /* |
181 | * second stage - get the other then inbox folders | 181 | * second stage - get the other then inbox folders |
182 | */ | 182 | */ |
183 | mask = "*" ; | 183 | mask = "*" ; |
184 | path = account->getPrefix().latin1(); | 184 | path = account->getPrefix().latin1(); |
185 | if (!path) path = ""; | 185 | if (!path) path = ""; |
186 | result = clist_new(); | 186 | result = clist_new(); |
187 | qDebug(path); | 187 | qDebug(path); |
188 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 188 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
189 | if ( err == MAILIMAP_NO_ERROR ) { | 189 | if ( err == MAILIMAP_NO_ERROR ) { |
190 | current = result->first; | 190 | current = result->first; |
191 | for ( int i = result->count; i > 0; i-- ) { | 191 | for ( int i = result->count; i > 0; i-- ) { |
192 | list = (mailimap_mailbox_list *) current->data; | 192 | list = (mailimap_mailbox_list *) current->data; |
193 | // it is better use the deep copy mechanism of qt itself | 193 | // it is better use the deep copy mechanism of qt itself |
194 | // instead of using strdup! | 194 | // instead of using strdup! |
195 | temp = list->mb_name; | 195 | temp = list->mb_name; |
196 | current = current->next; | 196 | current = current->next; |
197 | if (temp.lower()=="inbox") | 197 | if (temp.lower()=="inbox") |
198 | continue; | 198 | continue; |
199 | folders->append(new IMAPFolder(temp)); | 199 | folders->append(new IMAPFolder(temp)); |
200 | 200 | ||
201 | } | 201 | } |
202 | } else { | 202 | } else { |
203 | qDebug("error fetching folders %s",m_imap->imap_response); | 203 | qDebug("error fetching folders %s",m_imap->imap_response); |
204 | } | 204 | } |
205 | mailimap_list_result_free( result ); | 205 | mailimap_list_result_free( result ); |
206 | return folders; | 206 | return folders; |
207 | } | 207 | } |
208 | 208 | ||
209 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 209 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
210 | { | 210 | { |
211 | RecMail * m = 0; | 211 | RecMail * m = 0; |
212 | mailimap_msg_att_item *item=0; | 212 | mailimap_msg_att_item *item=0; |
213 | clistcell *current,*c,*cf; | 213 | clistcell *current,*c,*cf; |
214 | mailimap_msg_att_dynamic*flist; | 214 | mailimap_msg_att_dynamic*flist; |
215 | mailimap_flag_fetch*cflag; | 215 | mailimap_flag_fetch*cflag; |
216 | int size; | 216 | int size; |
217 | QBitArray mFlags(7); | 217 | QBitArray mFlags(7); |
218 | QStringList addresslist; | 218 | QStringList addresslist; |
219 | 219 | ||
220 | if (!m_att) { | 220 | if (!m_att) { |
221 | return m; | 221 | return m; |
222 | } | 222 | } |
223 | m = new RecMail(); | 223 | m = new RecMail(); |
224 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 224 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
225 | current = c; | 225 | current = c; |
226 | size = 0; | 226 | size = 0; |
227 | item = (mailimap_msg_att_item*)current->data; | 227 | item = (mailimap_msg_att_item*)current->data; |
228 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 228 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
229 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 229 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
230 | if (!flist->att_list) { | 230 | if (!flist->att_list) { |
231 | continue; | 231 | continue; |
232 | } | 232 | } |
233 | cf = flist->att_list->first; | 233 | cf = flist->att_list->first; |
234 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 234 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
235 | cflag = (mailimap_flag_fetch*)cf->data; | 235 | cflag = (mailimap_flag_fetch*)cf->data; |
236 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 236 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
237 | switch (cflag->fl_flag->fl_type) { | 237 | switch (cflag->fl_flag->fl_type) { |
238 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 238 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
239 | mFlags.setBit(FLAG_ANSWERED); | 239 | mFlags.setBit(FLAG_ANSWERED); |
240 | break; | 240 | break; |
241 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 241 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
242 | mFlags.setBit(FLAG_FLAGGED); | 242 | mFlags.setBit(FLAG_FLAGGED); |
243 | break; | 243 | break; |
244 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 244 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
245 | mFlags.setBit(FLAG_DELETED); | 245 | mFlags.setBit(FLAG_DELETED); |
246 | break; | 246 | break; |
247 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 247 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
248 | mFlags.setBit(FLAG_SEEN); | 248 | mFlags.setBit(FLAG_SEEN); |
249 | break; | 249 | break; |
250 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 250 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
251 | mFlags.setBit(FLAG_DRAFT); | 251 | mFlags.setBit(FLAG_DRAFT); |
252 | break; | 252 | break; |
253 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 253 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
254 | break; | 254 | break; |
255 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 255 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
256 | break; | 256 | break; |
257 | default: | 257 | default: |
258 | break; | 258 | break; |
259 | } | 259 | } |
260 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 260 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
261 | mFlags.setBit(FLAG_RECENT); | 261 | mFlags.setBit(FLAG_RECENT); |
262 | } | 262 | } |
263 | } | 263 | } |
264 | continue; | 264 | continue; |
265 | } | 265 | } |
266 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 266 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
267 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 267 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
268 | m->setDate(head->env_date); | 268 | m->setDate(head->env_date); |
269 | m->setSubject(head->env_subject); | 269 | m->setSubject(head->env_subject); |
270 | if (head->env_from!=NULL) { | 270 | if (head->env_from!=NULL) { |
271 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 271 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
272 | if (addresslist.count()) { | 272 | if (addresslist.count()) { |
273 | m->setFrom(addresslist.first()); | 273 | m->setFrom(addresslist.first()); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | if (head->env_to!=NULL) { | 276 | if (head->env_to!=NULL) { |
277 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 277 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
278 | m->setTo(addresslist); | 278 | m->setTo(addresslist); |
279 | } | 279 | } |
280 | if (head->env_cc!=NULL) { | 280 | if (head->env_cc!=NULL) { |
281 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 281 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
282 | m->setCC(addresslist); | 282 | m->setCC(addresslist); |
283 | } | 283 | } |
284 | if (head->env_bcc!=NULL) { | 284 | if (head->env_bcc!=NULL) { |
285 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 285 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
286 | m->setBcc(addresslist); | 286 | m->setBcc(addresslist); |
287 | } | 287 | } |
288 | if (head->env_reply_to!=NULL) { | 288 | if (head->env_reply_to!=NULL) { |
289 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 289 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
290 | if (addresslist.count()) { | 290 | if (addresslist.count()) { |
291 | m->setReplyto(addresslist.first()); | 291 | m->setReplyto(addresslist.first()); |
292 | } | 292 | } |
293 | } | 293 | } |
294 | m->setMsgid(QString(head->env_message_id)); | 294 | m->setMsgid(QString(head->env_message_id)); |
295 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 295 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
296 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 296 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
297 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 297 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
298 | 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); | 298 | 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); |
299 | qDebug(da.toString()); | 299 | qDebug(da.toString()); |
300 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 300 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
301 | size = item->att_data.att_static->att_data.att_rfc822_size; | 301 | size = item->att_data.att_static->att_data.att_rfc822_size; |
302 | } | 302 | } |
303 | } | 303 | } |
304 | /* msg is already deleted */ | 304 | /* msg is already deleted */ |
305 | if (mFlags.testBit(FLAG_DELETED) && m) { | 305 | if (mFlags.testBit(FLAG_DELETED) && m) { |
306 | delete m; | 306 | delete m; |
307 | m = 0; | 307 | m = 0; |
308 | } | 308 | } |
309 | if (m) { | 309 | if (m) { |
310 | m->setFlags(mFlags); | 310 | m->setFlags(mFlags); |
311 | m->setMsgsize(size); | 311 | m->setMsgsize(size); |
312 | } | 312 | } |
313 | return m; | 313 | return m; |
314 | } | 314 | } |
315 | 315 | ||
316 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) | 316 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) |
317 | { | 317 | { |
318 | RecBody body; | 318 | RecBody body; |
319 | const char *mb; | 319 | const char *mb; |
320 | int err = MAILIMAP_NO_ERROR; | 320 | int err = MAILIMAP_NO_ERROR; |
321 | clist *result; | 321 | clist *result; |
322 | clistcell *current; | 322 | clistcell *current; |
323 | mailimap_fetch_att *fetchAtt; | 323 | mailimap_fetch_att *fetchAtt; |
324 | mailimap_fetch_type *fetchType; | 324 | mailimap_fetch_type *fetchType; |
325 | mailimap_set *set; | 325 | mailimap_set *set; |
326 | mailimap_body*body_desc; | 326 | mailimap_body*body_desc; |
327 | 327 | ||
328 | mb = mail.getMbox().latin1(); | 328 | mb = mail.getMbox().latin1(); |
329 | 329 | ||
330 | login(); | 330 | login(); |
331 | if (!m_imap) { | 331 | if (!m_imap) { |
332 | return body; | 332 | return body; |
333 | } | 333 | } |
334 | /* select mailbox READONLY for operations */ | 334 | /* select mailbox READONLY for operations */ |
335 | err = mailimap_examine( m_imap, (char*)mb); | 335 | err = mailimap_examine( m_imap, (char*)mb); |
336 | if ( err != MAILIMAP_NO_ERROR ) { | 336 | if ( err != MAILIMAP_NO_ERROR ) { |
337 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 337 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
338 | return body; | 338 | return body; |
339 | } | 339 | } |
340 | 340 | ||
341 | result = clist_new(); | 341 | result = clist_new(); |
342 | /* the range has to start at 1!!! not with 0!!!! */ | 342 | /* the range has to start at 1!!! not with 0!!!! */ |
343 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | 343 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); |
344 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 344 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
345 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 345 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
346 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 346 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
347 | mailimap_set_free( set ); | 347 | mailimap_set_free( set ); |
348 | mailimap_fetch_type_free( fetchType ); | 348 | mailimap_fetch_type_free( fetchType ); |
349 | 349 | ||
350 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 350 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
351 | mailimap_msg_att * msg_att; | 351 | mailimap_msg_att * msg_att; |
352 | msg_att = (mailimap_msg_att*)current->data; | 352 | msg_att = (mailimap_msg_att*)current->data; |
353 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 353 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
354 | body_desc = item->att_data.att_static->att_data.att_body; | 354 | body_desc = item->att_data.att_static->att_data.att_body; |
355 | if (body_desc->bd_type==MAILIMAP_BODY_1PART) { | 355 | if (body_desc->bd_type==MAILIMAP_BODY_1PART) { |
356 | searchBodyText(mail,body_desc->bd_data.bd_body_1part,body); | 356 | searchBodyText(mail,body_desc->bd_data.bd_body_1part,body); |
357 | } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) { | 357 | } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) { |
358 | qDebug("Mulitpart mail"); | 358 | qDebug("Mulitpart mail"); |
359 | searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); | 359 | searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); |
360 | } | 360 | } |
361 | } else { | 361 | } else { |
362 | qDebug("error fetching body: %s",m_imap->imap_response); | 362 | qDebug("error fetching body: %s",m_imap->imap_response); |
363 | } | 363 | } |
364 | mailimap_fetch_list_free(result); | 364 | mailimap_fetch_list_free(result); |
365 | return body; | 365 | return body; |
366 | } | 366 | } |
367 | 367 | ||
368 | /* this routine is just called when the mail has only ONE part. | 368 | /* this routine is just called when the mail has only ONE part. |
369 | for filling the parts of a multi-part-message there are other | 369 | for filling the parts of a multi-part-message there are other |
370 | routines 'cause we can not simply fetch the whole body. */ | 370 | routines 'cause we can not simply fetch the whole body. */ |
371 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) | 371 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) |
372 | { | 372 | { |
373 | if (!mailDescription) { | 373 | if (!mailDescription) { |
374 | return; | 374 | return; |
375 | } | 375 | } |
376 | QString sub; | 376 | QString sub,body_text; |
377 | RecPart singlePart; | ||
378 | QValueList<int> path; | ||
379 | fillSinglePart(singlePart,mailDescription); | ||
377 | switch (mailDescription->bd_type) { | 380 | switch (mailDescription->bd_type) { |
378 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 381 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
379 | target_body.setType("text"); | 382 | path.append(1); |
380 | sub = mailDescription->bd_data.bd_type_text->bd_media_text; | 383 | body_text = fetchPart(mail,path,true); |
381 | target_body.setSubtype(sub.lower()); | 384 | target_body.setBodytext(body_text); |
382 | fillPlainBody(mail,target_body); | 385 | target_body.setDescription(singlePart); |
383 | break; | 386 | break; |
384 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 387 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
385 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); | 388 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); |
386 | target_body.setType("text"); | 389 | path.append(1); |
387 | sub = mailDescription->bd_data.bd_type_text->bd_media_text; | 390 | body_text = fetchPart(mail,path,true); |
388 | target_body.setSubtype(sub.lower()); | 391 | target_body.setBodytext(body_text); |
389 | fillPlainBody(mail,target_body); | 392 | target_body.setDescription(singlePart); |
393 | break; | ||
394 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | ||
395 | qDebug("Single attachment"); | ||
396 | target_body.setBodytext(""); | ||
397 | target_body.addPart(singlePart); | ||
390 | break; | 398 | break; |
391 | default: | 399 | default: |
392 | break; | 400 | break; |
393 | } | 401 | } |
394 | return; | ||
395 | } | ||
396 | |||
397 | void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body) | ||
398 | { | ||
399 | const char *mb; | ||
400 | QString body=""; | ||
401 | int err = MAILIMAP_NO_ERROR; | ||
402 | clist *result; | ||
403 | clistcell *current,*cur; | ||
404 | mailimap_fetch_att *fetchAtt; | ||
405 | mailimap_fetch_type *fetchType; | ||
406 | mailimap_set *set; | ||
407 | |||
408 | mb = mail.getMbox().latin1(); | ||
409 | |||
410 | if (!m_imap) { | ||
411 | return; | ||
412 | } | ||
413 | |||
414 | result = clist_new(); | ||
415 | set = set = mailimap_set_new_single(mail.getNumber()); | ||
416 | mailimap_section * section = mailimap_section_new_text(); | ||
417 | fetchAtt = mailimap_fetch_att_new_body_peek_section(section); | ||
418 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | ||
419 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | ||
420 | mailimap_set_free( set ); | ||
421 | mailimap_fetch_type_free( fetchType ); | ||
422 | |||
423 | 402 | ||
424 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | ||
425 | mailimap_msg_att * msg_att; | ||
426 | msg_att = (mailimap_msg_att*)current->data; | ||
427 | mailimap_msg_att_item*msg_att_item; | ||
428 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | ||
429 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | ||
430 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | ||
431 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | ||
432 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | ||
433 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | ||
434 | if (text) { | ||
435 | body = QString(text); | ||
436 | free(text); | ||
437 | } else { | ||
438 | body = ""; | ||
439 | } | ||
440 | } | ||
441 | } | ||
442 | } | ||
443 | |||
444 | } else { | ||
445 | qDebug("error fetching text: %s",m_imap->imap_response); | ||
446 | } | ||
447 | mailimap_fetch_list_free(result); | ||
448 | target_body.setBodytext(body); | ||
449 | return; | 403 | return; |
450 | } | 404 | } |
451 | 405 | ||
452 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) | 406 | QStringList IMAPwrapper::address_list_to_stringlist(clist*list) |
453 | { | 407 | { |
454 | QStringList l; | 408 | QStringList l; |
455 | QString from; | 409 | QString from; |
456 | bool named_from; | 410 | bool named_from; |
457 | clistcell *current = NULL; | 411 | clistcell *current = NULL; |
458 | mailimap_address * current_address=NULL; | 412 | mailimap_address * current_address=NULL; |
459 | if (!list) { | 413 | if (!list) { |
460 | return l; | 414 | return l; |
461 | } | 415 | } |
462 | unsigned int count = 0; | 416 | unsigned int count = 0; |
463 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { | 417 | for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { |
464 | from = ""; | 418 | from = ""; |
465 | named_from = false; | 419 | named_from = false; |
466 | current_address=(mailimap_address*)current->data; | 420 | current_address=(mailimap_address*)current->data; |
467 | if (current_address->ad_personal_name){ | 421 | if (current_address->ad_personal_name){ |
468 | from+=QString(current_address->ad_personal_name); | 422 | from+=QString(current_address->ad_personal_name); |
469 | from+=" "; | 423 | from+=" "; |
470 | named_from = true; | 424 | named_from = true; |
471 | } | 425 | } |
472 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 426 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
473 | from+="<"; | 427 | from+="<"; |
474 | } | 428 | } |
475 | if (current_address->ad_mailbox_name) { | 429 | if (current_address->ad_mailbox_name) { |
476 | from+=QString(current_address->ad_mailbox_name); | 430 | from+=QString(current_address->ad_mailbox_name); |
477 | from+="@"; | 431 | from+="@"; |
478 | } | 432 | } |
479 | if (current_address->ad_host_name) { | 433 | if (current_address->ad_host_name) { |
480 | from+=QString(current_address->ad_host_name); | 434 | from+=QString(current_address->ad_host_name); |
481 | } | 435 | } |
482 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { | 436 | if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { |
483 | from+=">"; | 437 | from+=">"; |
484 | } | 438 | } |
485 | l.append(QString(from)); | 439 | l.append(QString(from)); |
486 | if (++count > 99) { | 440 | if (++count > 99) { |
487 | break; | 441 | break; |
488 | } | 442 | } |
489 | } | 443 | } |
490 | return l; | 444 | return l; |
491 | } | 445 | } |
492 | 446 | ||
493 | QString IMAPwrapper::fetchPart(const RecMail&mail,QValueList<int>&path,bool internal_call) | 447 | QString IMAPwrapper::fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call) |
494 | { | 448 | { |
495 | QString body(""); | 449 | QString body(""); |
496 | const char*mb; | 450 | const char*mb; |
497 | int err; | 451 | int err; |
498 | mailimap_fetch_type *fetchType; | 452 | mailimap_fetch_type *fetchType; |
499 | mailimap_set *set; | 453 | mailimap_set *set; |
500 | clistcell*current,*cur; | 454 | clistcell*current,*cur; |
501 | 455 | ||
502 | login(); | 456 | login(); |
503 | if (!m_imap) { | 457 | if (!m_imap) { |
504 | return body; | 458 | return body; |
505 | } | 459 | } |
506 | if (!internal_call) { | 460 | if (!internal_call) { |
507 | mb = mail.getMbox().latin1(); | 461 | mb = mail.getMbox().latin1(); |
508 | /* select mailbox READONLY for operations */ | 462 | /* select mailbox READONLY for operations */ |
509 | err = mailimap_examine( m_imap, (char*)mb); | 463 | err = mailimap_examine( m_imap, (char*)mb); |
510 | if ( err != MAILIMAP_NO_ERROR ) { | 464 | if ( err != MAILIMAP_NO_ERROR ) { |
511 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 465 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
512 | return body; | 466 | return body; |
513 | } | 467 | } |
514 | } | 468 | } |
515 | set = mailimap_set_new_single(mail.getNumber()); | 469 | set = mailimap_set_new_single(mail.getNumber()); |
516 | clist*id_list=clist_new(); | 470 | clist*id_list=clist_new(); |
517 | for (unsigned j=0; j < path.count();++j) { | 471 | for (unsigned j=0; j < path.count();++j) { |
518 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); | 472 | uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); |
519 | *p_id = path[j]; | 473 | *p_id = path[j]; |
520 | clist_append(id_list,p_id); | 474 | clist_append(id_list,p_id); |
521 | } | 475 | } |
522 | mailimap_section_part * section_part = mailimap_section_part_new(id_list); | 476 | mailimap_section_part * section_part = mailimap_section_part_new(id_list); |
523 | mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); | 477 | mailimap_section_spec * section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); |
524 | mailimap_section * section = mailimap_section_new(section_spec); | 478 | mailimap_section * section = mailimap_section_new(section_spec); |
525 | mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); | 479 | mailimap_fetch_att * fetch_att = mailimap_fetch_att_new_body_section(section); |
526 | 480 | ||
527 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); | 481 | fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); |
528 | 482 | ||
529 | clist*result = clist_new(); | 483 | clist*result = clist_new(); |
530 | 484 | ||
531 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 485 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
532 | mailimap_set_free( set ); | 486 | mailimap_set_free( set ); |
533 | mailimap_fetch_type_free( fetchType ); | 487 | mailimap_fetch_type_free( fetchType ); |
534 | 488 | ||
535 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 489 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
536 | mailimap_msg_att * msg_att; | 490 | mailimap_msg_att * msg_att; |
537 | msg_att = (mailimap_msg_att*)current->data; | 491 | msg_att = (mailimap_msg_att*)current->data; |
538 | mailimap_msg_att_item*msg_att_item; | 492 | mailimap_msg_att_item*msg_att_item; |
539 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { | 493 | for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { |
540 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); | 494 | msg_att_item = (mailimap_msg_att_item*)clist_content(cur); |
541 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { | 495 | if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { |
542 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { | 496 | if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { |
543 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; | 497 | char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; |
544 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; | 498 | msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; |
545 | if (text) { | 499 | if (text) { |
546 | body = QString(text); | 500 | body = QString(text); |
547 | free(text); | 501 | free(text); |
548 | } else { | 502 | } else { |
549 | body = ""; | 503 | body = ""; |
550 | } | 504 | } |
551 | } | 505 | } |
552 | } | 506 | } |
553 | } | 507 | } |
554 | 508 | ||
555 | } else { | 509 | } else { |
556 | qDebug("error fetching text: %s",m_imap->imap_response); | 510 | qDebug("error fetching text: %s",m_imap->imap_response); |
557 | } | 511 | } |
558 | mailimap_fetch_list_free(result); | 512 | mailimap_fetch_list_free(result); |
559 | return body; | 513 | return body; |
560 | } | 514 | } |
561 | 515 | ||
562 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList) | 516 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion,QValueList<int>recList) |
563 | { | 517 | { |
564 | /* current_recursion is for avoiding ugly mails which has a to deep body-structure */ | 518 | /* current_recursion is for avoiding ugly mails which has a to deep body-structure */ |
565 | if (!mailDescription||current_recursion==10) { | 519 | if (!mailDescription||current_recursion==10) { |
566 | return; | 520 | return; |
567 | } | 521 | } |
568 | clistcell*current; | 522 | clistcell*current; |
569 | mailimap_body*current_body; | 523 | mailimap_body*current_body; |
570 | unsigned int count = 0; | 524 | unsigned int count = 0; |
571 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { | 525 | for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { |
572 | /* the point in the message */ | 526 | /* the point in the message */ |
573 | ++count; | 527 | ++count; |
574 | current_body = (mailimap_body*)current->data; | 528 | current_body = (mailimap_body*)current->data; |
575 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { | 529 | if (current_body->bd_type==MAILIMAP_BODY_MPART) { |
576 | QValueList<int>clist = recList; | 530 | QValueList<int>clist = recList; |
577 | clist.append(count); | 531 | clist.append(count); |
578 | searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,clist); | 532 | searchBodyText(mail,current_body->bd_data.bd_body_mpart,target_body,current_recursion+1,clist); |
579 | } else if (current_body->bd_type==MAILIMAP_BODY_1PART){ | 533 | } else if (current_body->bd_type==MAILIMAP_BODY_1PART){ |
580 | RecPart currentPart; | 534 | RecPart currentPart; |
581 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); | 535 | fillSinglePart(currentPart,current_body->bd_data.bd_body_1part); |
582 | QValueList<int>clist = recList; | 536 | QValueList<int>clist = recList; |
583 | clist.append(count); | 537 | clist.append(count); |
584 | /* important: Check for is NULL 'cause a body can be empty! */ | 538 | /* important: Check for is NULL 'cause a body can be empty! */ |
585 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { | 539 | if (currentPart.Type()=="text" && target_body.Bodytext().isNull() ) { |
586 | QString body_text = fetchPart(mail,clist,true); | 540 | QString body_text = fetchPart(mail,clist,true); |
541 | target_body.setDescription(currentPart); | ||
587 | target_body.setBodytext(body_text); | 542 | target_body.setBodytext(body_text); |
588 | target_body.setType(currentPart.Type()); | ||
589 | target_body.setSubtype(currentPart.Subtype()); | ||
590 | } else { | 543 | } else { |
591 | QString id(""); | 544 | QString id(""); |
592 | for (unsigned int j = 0; j < clist.count();++j) { | 545 | for (unsigned int j = 0; j < clist.count();++j) { |
593 | id+=(j>0?".":""); | 546 | id+=(j>0?" ":""); |
594 | id+=QString("%1").arg(clist[j]); | 547 | id+=QString("%1").arg(clist[j]); |
595 | } | 548 | } |
596 | qDebug("ID= %s",id.latin1()); | 549 | qDebug("ID= %s",id.latin1()); |
597 | currentPart.setIdentifier(id); | 550 | currentPart.setIdentifier(id); |
551 | currentPart.setPositionlist(clist); | ||
598 | target_body.addPart(currentPart); | 552 | target_body.addPart(currentPart); |
599 | } | 553 | } |
600 | } | 554 | } |
601 | } | 555 | } |
602 | } | 556 | } |
603 | 557 | ||
604 | void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) | 558 | void IMAPwrapper::fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description) |
605 | { | 559 | { |
606 | if (!Description) { | 560 | if (!Description) { |
607 | return; | 561 | return; |
608 | } | 562 | } |
609 | switch (Description->bd_type) { | 563 | switch (Description->bd_type) { |
610 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 564 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
611 | target_part.setType("text"); | 565 | target_part.setType("text"); |
612 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); | 566 | fillSingleTextPart(target_part,Description->bd_data.bd_type_text); |
613 | break; | 567 | break; |
614 | case MAILIMAP_BODY_TYPE_1PART_BASIC: | 568 | case MAILIMAP_BODY_TYPE_1PART_BASIC: |
615 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); | 569 | fillSingleBasicPart(target_part,Description->bd_data.bd_type_basic); |
616 | break; | 570 | break; |
571 | case MAILIMAP_BODY_TYPE_1PART_MSG: | ||
572 | fillSingleMsgPart(target_part,Description->bd_data.bd_type_msg); | ||
573 | break; | ||
617 | default: | 574 | default: |
618 | break; | 575 | break; |
619 | } | 576 | } |
620 | } | 577 | } |
621 | 578 | ||
622 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) | 579 | void IMAPwrapper::fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which) |
623 | { | 580 | { |
624 | if (!which) { | 581 | if (!which) { |
625 | return; | 582 | return; |
626 | } | 583 | } |
627 | QString sub; | 584 | QString sub; |
628 | sub = which->bd_media_text; | 585 | sub = which->bd_media_text; |
629 | target_part.setSubtype(sub.lower()); | 586 | target_part.setSubtype(sub.lower()); |
630 | target_part.setLines(which->bd_lines); | 587 | target_part.setLines(which->bd_lines); |
631 | fillBodyFields(target_part,which->bd_fields); | 588 | fillBodyFields(target_part,which->bd_fields); |
632 | } | 589 | } |
633 | 590 | ||
591 | void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which) | ||
592 | { | ||
593 | if (!which) { | ||
594 | return; | ||
595 | } | ||
596 | // QString sub; | ||
597 | // sub = which->bd_media_text; | ||
598 | // target_part.setSubtype(sub.lower()); | ||
599 | qDebug("Message part"); | ||
600 | /* we set this type to text/plain */ | ||
601 | target_part.setType("text"); | ||
602 | target_part.setSubtype("plain"); | ||
603 | target_part.setLines(which->bd_lines); | ||
604 | fillBodyFields(target_part,which->bd_fields); | ||
605 | } | ||
606 | |||
634 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) | 607 | void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which) |
635 | { | 608 | { |
636 | if (!which) { | 609 | if (!which) { |
637 | return; | 610 | return; |
638 | } | 611 | } |
639 | QString type,sub; | 612 | QString type,sub; |
640 | switch (which->bd_media_basic->med_type) { | 613 | switch (which->bd_media_basic->med_type) { |
641 | case MAILIMAP_MEDIA_BASIC_APPLICATION: | 614 | case MAILIMAP_MEDIA_BASIC_APPLICATION: |
642 | type = "application"; | 615 | type = "application"; |
643 | break; | 616 | break; |
644 | case MAILIMAP_MEDIA_BASIC_AUDIO: | 617 | case MAILIMAP_MEDIA_BASIC_AUDIO: |
645 | type = "audio"; | 618 | type = "audio"; |
646 | break; | 619 | break; |
647 | case MAILIMAP_MEDIA_BASIC_IMAGE: | 620 | case MAILIMAP_MEDIA_BASIC_IMAGE: |
648 | type = "image"; | 621 | type = "image"; |
649 | break; | 622 | break; |
650 | case MAILIMAP_MEDIA_BASIC_MESSAGE: | 623 | case MAILIMAP_MEDIA_BASIC_MESSAGE: |
651 | type = "message"; | 624 | type = "message"; |
652 | break; | 625 | break; |
653 | case MAILIMAP_MEDIA_BASIC_VIDEO: | 626 | case MAILIMAP_MEDIA_BASIC_VIDEO: |
654 | type = "video"; | 627 | type = "video"; |
655 | break; | 628 | break; |
656 | case MAILIMAP_MEDIA_BASIC_OTHER: | 629 | case MAILIMAP_MEDIA_BASIC_OTHER: |
657 | default: | 630 | default: |
658 | if (which->bd_media_basic->med_basic_type) { | 631 | if (which->bd_media_basic->med_basic_type) { |
659 | type = which->bd_media_basic->med_basic_type; | 632 | type = which->bd_media_basic->med_basic_type; |
660 | } else { | 633 | } else { |
661 | type = ""; | 634 | type = ""; |
662 | } | 635 | } |
663 | break; | 636 | break; |
664 | } | 637 | } |
665 | if (which->bd_media_basic->med_subtype) { | 638 | if (which->bd_media_basic->med_subtype) { |
666 | sub = which->bd_media_basic->med_subtype; | 639 | sub = which->bd_media_basic->med_subtype; |
667 | } else { | 640 | } else { |
668 | sub = ""; | 641 | sub = ""; |
669 | } | 642 | } |
670 | qDebug("Type = %s/%s",type.latin1(),sub.latin1()); | 643 | qDebug("Type = %s/%s",type.latin1(),sub.latin1()); |
671 | target_part.setType(type.lower()); | 644 | target_part.setType(type.lower()); |
672 | target_part.setSubtype(sub.lower()); | 645 | target_part.setSubtype(sub.lower()); |
673 | fillBodyFields(target_part,which->bd_fields); | 646 | fillBodyFields(target_part,which->bd_fields); |
674 | } | 647 | } |
675 | 648 | ||
676 | void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) | 649 | void IMAPwrapper::fillBodyFields(RecPart&target_part,mailimap_body_fields*which) |
677 | { | 650 | { |
678 | if (!which) return; | 651 | if (!which) return; |
679 | clistcell*cur; | 652 | clistcell*cur; |
680 | mailimap_single_body_fld_param*param; | 653 | mailimap_single_body_fld_param*param; |
681 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { | 654 | for (cur = clist_begin(which->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) { |
682 | param = (mailimap_single_body_fld_param*)cur->data; | 655 | param = (mailimap_single_body_fld_param*)cur->data; |
656 | if (param) { | ||
657 | target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); | ||
658 | } | ||
683 | } | 659 | } |
660 | mailimap_body_fld_enc*enc = which->bd_encoding; | ||
661 | QString encoding(""); | ||
662 | switch (enc->enc_type) { | ||
663 | case MAILIMAP_BODY_FLD_ENC_7BIT: | ||
664 | encoding = "7bit"; | ||
665 | break; | ||
666 | case MAILIMAP_BODY_FLD_ENC_8BIT: | ||
667 | encoding = "8bit"; | ||
668 | break; | ||
669 | case MAILIMAP_BODY_FLD_ENC_BINARY: | ||
670 | encoding="binary"; | ||
671 | break; | ||
672 | case MAILIMAP_BODY_FLD_ENC_BASE64: | ||
673 | encoding="base64"; | ||
674 | break; | ||
675 | case MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE: | ||
676 | encoding="quoted-printable"; | ||
677 | break; | ||
678 | case MAILIMAP_BODY_FLD_ENC_OTHER: | ||
679 | default: | ||
680 | if (enc->enc_value) { | ||
681 | char*t=enc->enc_value; | ||
682 | encoding=QString(enc->enc_value); | ||
683 | enc->enc_value=0L; | ||
684 | free(t); | ||
685 | } | ||
686 | } | ||
687 | target_part.setEncoding(encoding); | ||
688 | } | ||
689 | |||
690 | QString IMAPwrapper::fetchPart(const RecMail&mail,const RecPart&part) | ||
691 | { | ||
692 | return fetchPart(mail,part.Positionlist(),false); | ||
684 | } | 693 | } |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h index 5ea45f3..95de215 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.h +++ b/noncore/net/mail/libmailwrapper/imapwrapper.h | |||
@@ -1,53 +1,55 @@ | |||
1 | #ifndef __IMAPWRAPPER | 1 | #ifndef __IMAPWRAPPER |
2 | #define __IMAPWRAPPER | 2 | #define __IMAPWRAPPER |
3 | 3 | ||
4 | #include <qlist.h> | 4 | #include <qlist.h> |
5 | #include "mailwrapper.h" | 5 | #include "mailwrapper.h" |
6 | 6 | ||
7 | struct mailimap; | 7 | struct mailimap; |
8 | struct mailimap_body_type_1part; | 8 | struct mailimap_body_type_1part; |
9 | struct mailimap_body_type_text; | 9 | struct mailimap_body_type_text; |
10 | struct mailimap_body_type_basic; | 10 | struct mailimap_body_type_basic; |
11 | struct mailimap_body_type_msg; | ||
11 | struct mailimap_body_type_mpart; | 12 | struct mailimap_body_type_mpart; |
12 | struct mailimap_body_fields; | 13 | struct mailimap_body_fields; |
13 | struct mailimap_msg_att; | 14 | struct mailimap_msg_att; |
14 | class RecMail; | 15 | class RecMail; |
15 | class RecBody; | 16 | class RecBody; |
16 | class RecPart; | 17 | class RecPart; |
17 | 18 | ||
18 | class IMAPwrapper : public QObject | 19 | class IMAPwrapper : public QObject |
19 | { | 20 | { |
20 | Q_OBJECT | 21 | Q_OBJECT |
21 | 22 | ||
22 | public: | 23 | public: |
23 | IMAPwrapper( IMAPaccount *a ); | 24 | IMAPwrapper( IMAPaccount *a ); |
24 | virtual ~IMAPwrapper(); | 25 | virtual ~IMAPwrapper(); |
25 | QList<IMAPFolder>* listFolders(); | 26 | QList<IMAPFolder>* listFolders(); |
26 | void listMessages(const QString & mailbox,QList<RecMail>&target ); | 27 | void listMessages(const QString & mailbox,QList<RecMail>&target ); |
27 | RecBody fetchBody(const RecMail&mail); | 28 | RecBody fetchBody(const RecMail&mail); |
28 | QString fetchPart(const RecMail&mail,QValueList<int>&path,bool internal_call=false); | 29 | QString fetchPart(const RecMail&mail,const QValueList<int>&path,bool internal_call=false); |
30 | QString fetchPart(const RecMail&mail,const RecPart&part); | ||
29 | static void imap_progress( size_t current, size_t maximum ); | 31 | static void imap_progress( size_t current, size_t maximum ); |
30 | 32 | ||
31 | protected: | 33 | protected: |
32 | RecMail*parse_list_result(mailimap_msg_att*); | 34 | RecMail*parse_list_result(mailimap_msg_att*); |
33 | void login(); | 35 | void login(); |
34 | void logout(); | 36 | void logout(); |
35 | 37 | ||
36 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); | 38 | void searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body); |
37 | void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); | 39 | void searchBodyText(const RecMail&mail,mailimap_body_type_mpart*mailDescription,RecBody&target_body,int current_recursion=0,QValueList<int>recList=QValueList<int>()); |
38 | 40 | ||
39 | void fillPlainBody(const RecMail&mail,RecBody&target_body); | ||
40 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); | 41 | void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); |
41 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); | 42 | void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); |
42 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); | 43 | void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); |
44 | void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); | ||
43 | 45 | ||
44 | /* just helpers */ | 46 | /* just helpers */ |
45 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); | 47 | static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); |
46 | static QStringList address_list_to_stringlist(clist*list); | 48 | static QStringList address_list_to_stringlist(clist*list); |
47 | 49 | ||
48 | private: | 50 | private: |
49 | IMAPaccount *account; | 51 | IMAPaccount *account; |
50 | mailimap *m_imap; | 52 | mailimap *m_imap; |
51 | }; | 53 | }; |
52 | 54 | ||
53 | #endif | 55 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index 6a66113..f56bb63 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -1,189 +1,211 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | 2 | ||
3 | 3 | ||
4 | RecMail::RecMail() | 4 | RecMail::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 | ||
10 | RecMail::RecMail(const RecMail&old) | 10 | RecMail::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 | ||
18 | void RecMail::copy_old(const RecMail&old) | 18 | void RecMail::copy_old(const RecMail&old) |
19 | { | 19 | { |
20 | subject = old.subject; | 20 | subject = old.subject; |
21 | date = old.date; | 21 | date = old.date; |
22 | mbox = old.mbox; | 22 | mbox = old.mbox; |
23 | msg_id = old.msg_id; | 23 | msg_id = old.msg_id; |
24 | msg_size = old.msg_size; | 24 | msg_size = old.msg_size; |
25 | msg_number = old.msg_number; | 25 | msg_number = old.msg_number; |
26 | from = old.from; | 26 | from = old.from; |
27 | msg_flags = old.msg_flags; | 27 | msg_flags = old.msg_flags; |
28 | to = old.to; | 28 | to = old.to; |
29 | cc = old.cc; | 29 | cc = old.cc; |
30 | bcc = old.bcc; | 30 | bcc = old.bcc; |
31 | } | 31 | } |
32 | 32 | ||
33 | void RecMail::init() | 33 | void RecMail::init() |
34 | { | 34 | { |
35 | to.clear(); | 35 | to.clear(); |
36 | cc.clear(); | 36 | cc.clear(); |
37 | bcc.clear(); | 37 | bcc.clear(); |
38 | } | 38 | } |
39 | 39 | ||
40 | void RecMail::setTo(const QStringList&list) | 40 | void RecMail::setTo(const QStringList&list) |
41 | { | 41 | { |
42 | to = list; | 42 | to = list; |
43 | } | 43 | } |
44 | 44 | ||
45 | const QStringList&RecMail::To()const | 45 | const QStringList&RecMail::To()const |
46 | { | 46 | { |
47 | return to; | 47 | return to; |
48 | } | 48 | } |
49 | 49 | ||
50 | void RecMail::setCC(const QStringList&list) | 50 | void RecMail::setCC(const QStringList&list) |
51 | { | 51 | { |
52 | cc = list; | 52 | cc = list; |
53 | } | 53 | } |
54 | 54 | ||
55 | const QStringList&RecMail::CC()const | 55 | const QStringList&RecMail::CC()const |
56 | { | 56 | { |
57 | return cc; | 57 | return cc; |
58 | } | 58 | } |
59 | 59 | ||
60 | void RecMail::setBcc(const QStringList&list) | 60 | void RecMail::setBcc(const QStringList&list) |
61 | { | 61 | { |
62 | bcc = list; | 62 | bcc = list; |
63 | } | 63 | } |
64 | 64 | ||
65 | const QStringList& RecMail::Bcc()const | 65 | const QStringList& RecMail::Bcc()const |
66 | { | 66 | { |
67 | return bcc; | 67 | return bcc; |
68 | } | 68 | } |
69 | 69 | ||
70 | RecPart::RecPart() | 70 | RecPart::RecPart() |
71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0) | 71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0) |
72 | { | 72 | { |
73 | } | 73 | m_Parameters.clear(); |
74 | 74 | m_poslist.clear(); | |
75 | RecPart::RecPart(const QString&identifier,const QString&type,const QString&subtype,const QString&encoding,unsigned int lines) | ||
76 | : m_type(type),m_subtype(subtype),m_identifier(identifier),m_encoding(encoding),m_lines(lines) | ||
77 | { | ||
78 | } | 75 | } |
79 | 76 | ||
80 | RecPart::~RecPart() | 77 | RecPart::~RecPart() |
81 | { | 78 | { |
82 | } | 79 | } |
83 | 80 | ||
84 | void RecPart::setLines(unsigned int lines) | 81 | void RecPart::setLines(unsigned int lines) |
85 | { | 82 | { |
86 | m_lines = lines; | 83 | m_lines = lines; |
87 | } | 84 | } |
88 | 85 | ||
89 | const unsigned int RecPart::Lines()const | 86 | const unsigned int RecPart::Lines()const |
90 | { | 87 | { |
91 | return m_lines; | 88 | return m_lines; |
92 | } | 89 | } |
93 | 90 | ||
94 | const QString& RecPart::Type()const | 91 | const QString& RecPart::Type()const |
95 | { | 92 | { |
96 | return m_type; | 93 | return m_type; |
97 | } | 94 | } |
98 | 95 | ||
99 | void RecPart::setType(const QString&type) | 96 | void RecPart::setType(const QString&type) |
100 | { | 97 | { |
101 | m_type = type; | 98 | m_type = type; |
102 | } | 99 | } |
103 | 100 | ||
104 | const QString& RecPart::Subtype()const | 101 | const QString& RecPart::Subtype()const |
105 | { | 102 | { |
106 | return m_subtype; | 103 | return m_subtype; |
107 | } | 104 | } |
108 | 105 | ||
109 | void RecPart::setSubtype(const QString&subtype) | 106 | void RecPart::setSubtype(const QString&subtype) |
110 | { | 107 | { |
111 | m_subtype = subtype; | 108 | m_subtype = subtype; |
112 | } | 109 | } |
113 | 110 | ||
114 | const QString& RecPart::Identifier()const | 111 | const QString& RecPart::Identifier()const |
115 | { | 112 | { |
116 | return m_identifier; | 113 | return m_identifier; |
117 | } | 114 | } |
118 | 115 | ||
119 | void RecPart::setIdentifier(const QString&identifier) | 116 | void RecPart::setIdentifier(const QString&identifier) |
120 | { | 117 | { |
121 | m_identifier = identifier; | 118 | m_identifier = identifier; |
122 | } | 119 | } |
123 | 120 | ||
124 | const QString& RecPart::Encoding()const | 121 | const QString& RecPart::Encoding()const |
125 | { | 122 | { |
126 | return m_encoding; | 123 | return m_encoding; |
127 | } | 124 | } |
128 | 125 | ||
129 | void RecPart::setEncoding(const QString&encoding) | 126 | void RecPart::setEncoding(const QString&encoding) |
130 | { | 127 | { |
131 | m_encoding = encoding; | 128 | m_encoding = encoding; |
132 | } | 129 | } |
133 | 130 | ||
131 | void RecPart::setParameters(const part_plist_t&list) | ||
132 | { | ||
133 | m_Parameters = list; | ||
134 | } | ||
135 | |||
136 | const part_plist_t& RecPart::Parameters()const | ||
137 | { | ||
138 | return m_Parameters; | ||
139 | } | ||
140 | |||
141 | void RecPart::addParameter(const QString&key,const QString&value) | ||
142 | { | ||
143 | m_Parameters[key]=value; | ||
144 | } | ||
145 | |||
146 | const QString RecPart::searchParamter(const QString&key)const | ||
147 | { | ||
148 | QString value(""); | ||
149 | part_plist_t::ConstIterator it = m_Parameters.find(key); | ||
150 | if (it != m_Parameters.end()) { | ||
151 | value = it.data(); | ||
152 | } | ||
153 | return value; | ||
154 | } | ||
155 | |||
156 | void RecPart::setPositionlist(const QValueList<int>&poslist) | ||
157 | { | ||
158 | m_poslist = poslist; | ||
159 | } | ||
160 | |||
161 | const QValueList<int>& RecPart::Positionlist()const | ||
162 | { | ||
163 | return m_poslist; | ||
164 | } | ||
165 | |||
134 | RecBody::RecBody() | 166 | RecBody::RecBody() |
135 | : m_BodyText(),m_PartsList() | 167 | : m_BodyText(),m_PartsList(),m_description() |
136 | { | 168 | { |
137 | m_PartsList.setAutoDelete(true); | 169 | m_PartsList.setAutoDelete(true); |
138 | } | 170 | } |
139 | 171 | ||
140 | RecBody::~RecBody() | 172 | RecBody::~RecBody() |
141 | { | 173 | { |
142 | } | 174 | } |
143 | 175 | ||
144 | void RecBody::setBodytext(const QString&bodyText) | 176 | void RecBody::setBodytext(const QString&bodyText) |
145 | { | 177 | { |
146 | m_BodyText = bodyText; | 178 | m_BodyText = bodyText; |
147 | } | 179 | } |
148 | 180 | ||
149 | const QString& RecBody::Bodytext()const | 181 | const QString& RecBody::Bodytext()const |
150 | { | 182 | { |
151 | return m_BodyText; | 183 | return m_BodyText; |
152 | } | 184 | } |
153 | 185 | ||
154 | void RecBody::setParts(const QList<RecPart>&parts) | 186 | void RecBody::setParts(const QList<RecPart>&parts) |
155 | { | 187 | { |
156 | m_PartsList = parts; | 188 | m_PartsList = parts; |
157 | m_PartsList.setAutoDelete(true); | 189 | m_PartsList.setAutoDelete(true); |
158 | } | 190 | } |
159 | 191 | ||
160 | const QList<RecPart>& RecBody::Parts()const | 192 | const QList<RecPart>& RecBody::Parts()const |
161 | { | 193 | { |
162 | return m_PartsList; | 194 | return m_PartsList; |
163 | } | 195 | } |
164 | 196 | ||
165 | void RecBody::addPart(const RecPart& part) | 197 | void RecBody::addPart(const RecPart& part) |
166 | { | 198 | { |
167 | RecPart*p = new RecPart(part); | 199 | RecPart*p = new RecPart(part); |
168 | m_PartsList.append(p); | 200 | m_PartsList.append(p); |
169 | } | 201 | } |
170 | 202 | ||
171 | void RecBody::setType(const QString&type) | 203 | void RecBody::setDescription(const RecPart&des) |
172 | { | 204 | { |
173 | m_type = type; | 205 | m_description = des; |
174 | } | 206 | } |
175 | 207 | ||
176 | const QString& RecBody::Type()const | 208 | const RecPart& RecBody::Description()const |
177 | { | 209 | { |
178 | return m_type; | 210 | return m_description; |
179 | } | ||
180 | |||
181 | void RecBody::setSubtype(const QString&type) | ||
182 | { | ||
183 | m_subtype = type; | ||
184 | } | ||
185 | |||
186 | const QString& RecBody::Subtype()const | ||
187 | { | ||
188 | return m_subtype; | ||
189 | } | 211 | } |
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index 900f10a..60db527 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -1,115 +1,128 @@ | |||
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> | ||
16 | #include <qvaluelist.h> | ||
15 | 17 | ||
16 | /* a class to describe mails in a mailbox */ | 18 | /* a class to describe mails in a mailbox */ |
17 | /* Attention! | 19 | /* Attention! |
18 | From programmers point of view it would make sense to | 20 | From programmers point of view it would make sense to |
19 | store the mail body into this class, too. | 21 | store the mail body into this class, too. |
20 | But: not from the point of view of the device. | 22 | But: not from the point of view of the device. |
21 | Mailbodies can be real large. So we request them when | 23 | Mailbodies can be real large. So we request them when |
22 | needed from the mail-wrapper class direct from the server itself | 24 | needed from the mail-wrapper class direct from the server itself |
23 | (imap) or from a file-based cache (pop3?) | 25 | (imap) or from a file-based cache (pop3?) |
24 | So there is no interface "const QString&body()" but you should | 26 | So there is no interface "const QString&body()" but you should |
25 | make a request to the mailwrapper with this class as parameter to | 27 | make a request to the mailwrapper with this class as parameter to |
26 | get the body. Same words for the attachments. | 28 | get the body. Same words for the attachments. |
27 | */ | 29 | */ |
28 | class RecMail | 30 | class RecMail |
29 | { | 31 | { |
30 | public: | 32 | public: |
31 | RecMail(); | 33 | RecMail(); |
32 | RecMail(const RecMail&old); | 34 | RecMail(const RecMail&old); |
33 | virtual ~RecMail(){} | 35 | virtual ~RecMail(){} |
34 | 36 | ||
35 | const int getNumber()const{return msg_number;} | 37 | const int getNumber()const{return msg_number;} |
36 | void setNumber(int number){msg_number=number;} | 38 | void setNumber(int number){msg_number=number;} |
37 | const QString&getDate()const{ return date; } | 39 | const QString&getDate()const{ return date; } |
38 | void setDate( const QString&a ) { date = a; } | 40 | void setDate( const QString&a ) { date = a; } |
39 | const QString&getFrom()const{ return from; } | 41 | const QString&getFrom()const{ return from; } |
40 | void setFrom( const QString&a ) { from = a; } | 42 | void setFrom( const QString&a ) { from = a; } |
41 | const QString&getSubject()const { return subject; } | 43 | const QString&getSubject()const { return subject; } |
42 | void setSubject( const QString&s ) { subject = s; } | 44 | void setSubject( const QString&s ) { subject = s; } |
43 | const QString&getMbox()const{return mbox;} | 45 | const QString&getMbox()const{return mbox;} |
44 | void setMbox(const QString&box){mbox = box;} | 46 | void setMbox(const QString&box){mbox = box;} |
45 | void setMsgid(const QString&id){msg_id=id;} | 47 | void setMsgid(const QString&id){msg_id=id;} |
46 | const QString&Msgid()const{return msg_id;} | 48 | const QString&Msgid()const{return msg_id;} |
47 | void setReplyto(const QString&reply){replyto=reply;} | 49 | void setReplyto(const QString&reply){replyto=reply;} |
48 | const QString&Replyto()const{return replyto;} | 50 | const QString&Replyto()const{return replyto;} |
49 | void setMsgsize(int size){msg_size = size;} | 51 | void setMsgsize(int size){msg_size = size;} |
50 | const int Msgsize()const{return msg_size;} | 52 | const int Msgsize()const{return msg_size;} |
51 | 53 | ||
52 | 54 | ||
53 | void setTo(const QStringList&list); | 55 | void setTo(const QStringList&list); |
54 | const QStringList&To()const; | 56 | const QStringList&To()const; |
55 | void setCC(const QStringList&list); | 57 | void setCC(const QStringList&list); |
56 | const QStringList&CC()const; | 58 | const QStringList&CC()const; |
57 | void setBcc(const QStringList&list); | 59 | void setBcc(const QStringList&list); |
58 | const QStringList&Bcc()const; | 60 | const QStringList&Bcc()const; |
59 | const QBitArray&getFlags()const{return msg_flags;} | 61 | const QBitArray&getFlags()const{return msg_flags;} |
60 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 62 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
61 | 63 | ||
62 | protected: | 64 | protected: |
63 | QString subject,date,from,mbox,msg_id,replyto; | 65 | QString subject,date,from,mbox,msg_id,replyto; |
64 | int msg_number,msg_size; | 66 | int msg_number,msg_size; |
65 | QBitArray msg_flags; | 67 | QBitArray msg_flags; |
66 | QStringList to,cc,bcc; | 68 | QStringList to,cc,bcc; |
67 | void init(); | 69 | void init(); |
68 | void copy_old(const RecMail&old); | 70 | void copy_old(const RecMail&old); |
69 | }; | 71 | }; |
70 | 72 | ||
73 | typedef QMap<QString,QString> part_plist_t; | ||
74 | |||
71 | class RecPart | 75 | class RecPart |
72 | { | 76 | { |
73 | protected: | 77 | protected: |
74 | QString m_type,m_subtype,m_identifier,m_encoding; | 78 | QString m_type,m_subtype,m_identifier,m_encoding; |
75 | unsigned int m_lines; | 79 | unsigned int m_lines; |
80 | part_plist_t m_Parameters; | ||
81 | /* describes the position in the mail */ | ||
82 | QValueList<int> m_poslist; | ||
83 | |||
76 | public: | 84 | public: |
77 | RecPart(); | 85 | RecPart(); |
78 | RecPart(const QString&identifier,const QString&type="",const QString&subtype="",const QString&encoding="BASE64",unsigned int lines=0); | ||
79 | virtual ~RecPart(); | 86 | virtual ~RecPart(); |
80 | 87 | ||
81 | const QString&Type()const; | 88 | const QString&Type()const; |
82 | void setType(const QString&type); | 89 | void setType(const QString&type); |
83 | const QString&Subtype()const; | 90 | const QString&Subtype()const; |
84 | void setSubtype(const QString&subtype); | 91 | void setSubtype(const QString&subtype); |
85 | const QString&Identifier()const; | 92 | const QString&Identifier()const; |
86 | void setIdentifier(const QString&identifier); | 93 | void setIdentifier(const QString&identifier); |
87 | const QString&Encoding()const; | 94 | const QString&Encoding()const; |
88 | void setEncoding(const QString&encoding); | 95 | void setEncoding(const QString&encoding); |
89 | void setLines(unsigned int lines); | 96 | void setLines(unsigned int lines); |
90 | const unsigned int Lines()const; | 97 | const unsigned int Lines()const; |
98 | |||
99 | void setParameters(const part_plist_t&list); | ||
100 | const part_plist_t&Parameters()const; | ||
101 | void addParameter(const QString&key,const QString&value); | ||
102 | const QString searchParamter(const QString&key)const; | ||
103 | void setPositionlist(const QValueList<int>&poslist); | ||
104 | const QValueList<int>& Positionlist()const; | ||
91 | }; | 105 | }; |
92 | 106 | ||
93 | class RecBody | 107 | class RecBody |
94 | { | 108 | { |
95 | protected: | 109 | protected: |
96 | QString m_BodyText,m_type,m_subtype; | 110 | QString m_BodyText; |
97 | QList<RecPart> m_PartsList; | 111 | QList<RecPart> m_PartsList; |
112 | RecPart m_description; | ||
98 | 113 | ||
99 | public: | 114 | public: |
100 | RecBody(); | 115 | RecBody(); |
101 | virtual ~RecBody(); | 116 | virtual ~RecBody(); |
102 | void setBodytext(const QString&); | 117 | void setBodytext(const QString&); |
103 | const QString& Bodytext()const; | 118 | const QString& Bodytext()const; |
104 | void setType(const QString&); | ||
105 | const QString&Type()const; | ||
106 | void setSubtype(const QString&); | ||
107 | const QString&Subtype()const; | ||
108 | 119 | ||
120 | void setDescription(const RecPart&des); | ||
121 | const RecPart& Description()const; | ||
109 | 122 | ||
110 | void setParts(const QList<RecPart>&parts); | 123 | void setParts(const QList<RecPart>&parts); |
111 | const QList<RecPart>& Parts()const; | 124 | const QList<RecPart>& Parts()const; |
112 | void addPart(const RecPart&part); | 125 | void addPart(const RecPart&part); |
113 | }; | 126 | }; |
114 | 127 | ||
115 | #endif | 128 | #endif |
diff --git a/noncore/net/mail/mailtypes.cpp b/noncore/net/mail/mailtypes.cpp index 6a66113..f56bb63 100644 --- a/noncore/net/mail/mailtypes.cpp +++ b/noncore/net/mail/mailtypes.cpp | |||
@@ -1,189 +1,211 @@ | |||
1 | #include "mailtypes.h" | 1 | #include "mailtypes.h" |
2 | 2 | ||
3 | 3 | ||
4 | RecMail::RecMail() | 4 | RecMail::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 | ||
10 | RecMail::RecMail(const RecMail&old) | 10 | RecMail::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 | ||
18 | void RecMail::copy_old(const RecMail&old) | 18 | void RecMail::copy_old(const RecMail&old) |
19 | { | 19 | { |
20 | subject = old.subject; | 20 | subject = old.subject; |
21 | date = old.date; | 21 | date = old.date; |
22 | mbox = old.mbox; | 22 | mbox = old.mbox; |
23 | msg_id = old.msg_id; | 23 | msg_id = old.msg_id; |
24 | msg_size = old.msg_size; | 24 | msg_size = old.msg_size; |
25 | msg_number = old.msg_number; | 25 | msg_number = old.msg_number; |
26 | from = old.from; | 26 | from = old.from; |
27 | msg_flags = old.msg_flags; | 27 | msg_flags = old.msg_flags; |
28 | to = old.to; | 28 | to = old.to; |
29 | cc = old.cc; | 29 | cc = old.cc; |
30 | bcc = old.bcc; | 30 | bcc = old.bcc; |
31 | } | 31 | } |
32 | 32 | ||
33 | void RecMail::init() | 33 | void RecMail::init() |
34 | { | 34 | { |
35 | to.clear(); | 35 | to.clear(); |
36 | cc.clear(); | 36 | cc.clear(); |
37 | bcc.clear(); | 37 | bcc.clear(); |
38 | } | 38 | } |
39 | 39 | ||
40 | void RecMail::setTo(const QStringList&list) | 40 | void RecMail::setTo(const QStringList&list) |
41 | { | 41 | { |
42 | to = list; | 42 | to = list; |
43 | } | 43 | } |
44 | 44 | ||
45 | const QStringList&RecMail::To()const | 45 | const QStringList&RecMail::To()const |
46 | { | 46 | { |
47 | return to; | 47 | return to; |
48 | } | 48 | } |
49 | 49 | ||
50 | void RecMail::setCC(const QStringList&list) | 50 | void RecMail::setCC(const QStringList&list) |
51 | { | 51 | { |
52 | cc = list; | 52 | cc = list; |
53 | } | 53 | } |
54 | 54 | ||
55 | const QStringList&RecMail::CC()const | 55 | const QStringList&RecMail::CC()const |
56 | { | 56 | { |
57 | return cc; | 57 | return cc; |
58 | } | 58 | } |
59 | 59 | ||
60 | void RecMail::setBcc(const QStringList&list) | 60 | void RecMail::setBcc(const QStringList&list) |
61 | { | 61 | { |
62 | bcc = list; | 62 | bcc = list; |
63 | } | 63 | } |
64 | 64 | ||
65 | const QStringList& RecMail::Bcc()const | 65 | const QStringList& RecMail::Bcc()const |
66 | { | 66 | { |
67 | return bcc; | 67 | return bcc; |
68 | } | 68 | } |
69 | 69 | ||
70 | RecPart::RecPart() | 70 | RecPart::RecPart() |
71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0) | 71 | : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_lines(0) |
72 | { | 72 | { |
73 | } | 73 | m_Parameters.clear(); |
74 | 74 | m_poslist.clear(); | |
75 | RecPart::RecPart(const QString&identifier,const QString&type,const QString&subtype,const QString&encoding,unsigned int lines) | ||
76 | : m_type(type),m_subtype(subtype),m_identifier(identifier),m_encoding(encoding),m_lines(lines) | ||
77 | { | ||
78 | } | 75 | } |
79 | 76 | ||
80 | RecPart::~RecPart() | 77 | RecPart::~RecPart() |
81 | { | 78 | { |
82 | } | 79 | } |
83 | 80 | ||
84 | void RecPart::setLines(unsigned int lines) | 81 | void RecPart::setLines(unsigned int lines) |
85 | { | 82 | { |
86 | m_lines = lines; | 83 | m_lines = lines; |
87 | } | 84 | } |
88 | 85 | ||
89 | const unsigned int RecPart::Lines()const | 86 | const unsigned int RecPart::Lines()const |
90 | { | 87 | { |
91 | return m_lines; | 88 | return m_lines; |
92 | } | 89 | } |
93 | 90 | ||
94 | const QString& RecPart::Type()const | 91 | const QString& RecPart::Type()const |
95 | { | 92 | { |
96 | return m_type; | 93 | return m_type; |
97 | } | 94 | } |
98 | 95 | ||
99 | void RecPart::setType(const QString&type) | 96 | void RecPart::setType(const QString&type) |
100 | { | 97 | { |
101 | m_type = type; | 98 | m_type = type; |
102 | } | 99 | } |
103 | 100 | ||
104 | const QString& RecPart::Subtype()const | 101 | const QString& RecPart::Subtype()const |
105 | { | 102 | { |
106 | return m_subtype; | 103 | return m_subtype; |
107 | } | 104 | } |
108 | 105 | ||
109 | void RecPart::setSubtype(const QString&subtype) | 106 | void RecPart::setSubtype(const QString&subtype) |
110 | { | 107 | { |
111 | m_subtype = subtype; | 108 | m_subtype = subtype; |
112 | } | 109 | } |
113 | 110 | ||
114 | const QString& RecPart::Identifier()const | 111 | const QString& RecPart::Identifier()const |
115 | { | 112 | { |
116 | return m_identifier; | 113 | return m_identifier; |
117 | } | 114 | } |
118 | 115 | ||
119 | void RecPart::setIdentifier(const QString&identifier) | 116 | void RecPart::setIdentifier(const QString&identifier) |
120 | { | 117 | { |
121 | m_identifier = identifier; | 118 | m_identifier = identifier; |
122 | } | 119 | } |
123 | 120 | ||
124 | const QString& RecPart::Encoding()const | 121 | const QString& RecPart::Encoding()const |
125 | { | 122 | { |
126 | return m_encoding; | 123 | return m_encoding; |
127 | } | 124 | } |
128 | 125 | ||
129 | void RecPart::setEncoding(const QString&encoding) | 126 | void RecPart::setEncoding(const QString&encoding) |
130 | { | 127 | { |
131 | m_encoding = encoding; | 128 | m_encoding = encoding; |
132 | } | 129 | } |
133 | 130 | ||
131 | void RecPart::setParameters(const part_plist_t&list) | ||
132 | { | ||
133 | m_Parameters = list; | ||
134 | } | ||
135 | |||
136 | const part_plist_t& RecPart::Parameters()const | ||
137 | { | ||
138 | return m_Parameters; | ||
139 | } | ||
140 | |||
141 | void RecPart::addParameter(const QString&key,const QString&value) | ||
142 | { | ||
143 | m_Parameters[key]=value; | ||
144 | } | ||
145 | |||
146 | const QString RecPart::searchParamter(const QString&key)const | ||
147 | { | ||
148 | QString value(""); | ||
149 | part_plist_t::ConstIterator it = m_Parameters.find(key); | ||
150 | if (it != m_Parameters.end()) { | ||
151 | value = it.data(); | ||
152 | } | ||
153 | return value; | ||
154 | } | ||
155 | |||
156 | void RecPart::setPositionlist(const QValueList<int>&poslist) | ||
157 | { | ||
158 | m_poslist = poslist; | ||
159 | } | ||
160 | |||
161 | const QValueList<int>& RecPart::Positionlist()const | ||
162 | { | ||
163 | return m_poslist; | ||
164 | } | ||
165 | |||
134 | RecBody::RecBody() | 166 | RecBody::RecBody() |
135 | : m_BodyText(),m_PartsList() | 167 | : m_BodyText(),m_PartsList(),m_description() |
136 | { | 168 | { |
137 | m_PartsList.setAutoDelete(true); | 169 | m_PartsList.setAutoDelete(true); |
138 | } | 170 | } |
139 | 171 | ||
140 | RecBody::~RecBody() | 172 | RecBody::~RecBody() |
141 | { | 173 | { |
142 | } | 174 | } |
143 | 175 | ||
144 | void RecBody::setBodytext(const QString&bodyText) | 176 | void RecBody::setBodytext(const QString&bodyText) |
145 | { | 177 | { |
146 | m_BodyText = bodyText; | 178 | m_BodyText = bodyText; |
147 | } | 179 | } |
148 | 180 | ||
149 | const QString& RecBody::Bodytext()const | 181 | const QString& RecBody::Bodytext()const |
150 | { | 182 | { |
151 | return m_BodyText; | 183 | return m_BodyText; |
152 | } | 184 | } |
153 | 185 | ||
154 | void RecBody::setParts(const QList<RecPart>&parts) | 186 | void RecBody::setParts(const QList<RecPart>&parts) |
155 | { | 187 | { |
156 | m_PartsList = parts; | 188 | m_PartsList = parts; |
157 | m_PartsList.setAutoDelete(true); | 189 | m_PartsList.setAutoDelete(true); |
158 | } | 190 | } |
159 | 191 | ||
160 | const QList<RecPart>& RecBody::Parts()const | 192 | const QList<RecPart>& RecBody::Parts()const |
161 | { | 193 | { |
162 | return m_PartsList; | 194 | return m_PartsList; |
163 | } | 195 | } |
164 | 196 | ||
165 | void RecBody::addPart(const RecPart& part) | 197 | void RecBody::addPart(const RecPart& part) |
166 | { | 198 | { |
167 | RecPart*p = new RecPart(part); | 199 | RecPart*p = new RecPart(part); |
168 | m_PartsList.append(p); | 200 | m_PartsList.append(p); |
169 | } | 201 | } |
170 | 202 | ||
171 | void RecBody::setType(const QString&type) | 203 | void RecBody::setDescription(const RecPart&des) |
172 | { | 204 | { |
173 | m_type = type; | 205 | m_description = des; |
174 | } | 206 | } |
175 | 207 | ||
176 | const QString& RecBody::Type()const | 208 | const RecPart& RecBody::Description()const |
177 | { | 209 | { |
178 | return m_type; | 210 | return m_description; |
179 | } | ||
180 | |||
181 | void RecBody::setSubtype(const QString&type) | ||
182 | { | ||
183 | m_subtype = type; | ||
184 | } | ||
185 | |||
186 | const QString& RecBody::Subtype()const | ||
187 | { | ||
188 | return m_subtype; | ||
189 | } | 211 | } |
diff --git a/noncore/net/mail/mailtypes.h b/noncore/net/mail/mailtypes.h index 900f10a..60db527 100644 --- a/noncore/net/mail/mailtypes.h +++ b/noncore/net/mail/mailtypes.h | |||
@@ -1,115 +1,128 @@ | |||
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> | ||
16 | #include <qvaluelist.h> | ||
15 | 17 | ||
16 | /* a class to describe mails in a mailbox */ | 18 | /* a class to describe mails in a mailbox */ |
17 | /* Attention! | 19 | /* Attention! |
18 | From programmers point of view it would make sense to | 20 | From programmers point of view it would make sense to |
19 | store the mail body into this class, too. | 21 | store the mail body into this class, too. |
20 | But: not from the point of view of the device. | 22 | But: not from the point of view of the device. |
21 | Mailbodies can be real large. So we request them when | 23 | Mailbodies can be real large. So we request them when |
22 | needed from the mail-wrapper class direct from the server itself | 24 | needed from the mail-wrapper class direct from the server itself |
23 | (imap) or from a file-based cache (pop3?) | 25 | (imap) or from a file-based cache (pop3?) |
24 | So there is no interface "const QString&body()" but you should | 26 | So there is no interface "const QString&body()" but you should |
25 | make a request to the mailwrapper with this class as parameter to | 27 | make a request to the mailwrapper with this class as parameter to |
26 | get the body. Same words for the attachments. | 28 | get the body. Same words for the attachments. |
27 | */ | 29 | */ |
28 | class RecMail | 30 | class RecMail |
29 | { | 31 | { |
30 | public: | 32 | public: |
31 | RecMail(); | 33 | RecMail(); |
32 | RecMail(const RecMail&old); | 34 | RecMail(const RecMail&old); |
33 | virtual ~RecMail(){} | 35 | virtual ~RecMail(){} |
34 | 36 | ||
35 | const int getNumber()const{return msg_number;} | 37 | const int getNumber()const{return msg_number;} |
36 | void setNumber(int number){msg_number=number;} | 38 | void setNumber(int number){msg_number=number;} |
37 | const QString&getDate()const{ return date; } | 39 | const QString&getDate()const{ return date; } |
38 | void setDate( const QString&a ) { date = a; } | 40 | void setDate( const QString&a ) { date = a; } |
39 | const QString&getFrom()const{ return from; } | 41 | const QString&getFrom()const{ return from; } |
40 | void setFrom( const QString&a ) { from = a; } | 42 | void setFrom( const QString&a ) { from = a; } |
41 | const QString&getSubject()const { return subject; } | 43 | const QString&getSubject()const { return subject; } |
42 | void setSubject( const QString&s ) { subject = s; } | 44 | void setSubject( const QString&s ) { subject = s; } |
43 | const QString&getMbox()const{return mbox;} | 45 | const QString&getMbox()const{return mbox;} |
44 | void setMbox(const QString&box){mbox = box;} | 46 | void setMbox(const QString&box){mbox = box;} |
45 | void setMsgid(const QString&id){msg_id=id;} | 47 | void setMsgid(const QString&id){msg_id=id;} |
46 | const QString&Msgid()const{return msg_id;} | 48 | const QString&Msgid()const{return msg_id;} |
47 | void setReplyto(const QString&reply){replyto=reply;} | 49 | void setReplyto(const QString&reply){replyto=reply;} |
48 | const QString&Replyto()const{return replyto;} | 50 | const QString&Replyto()const{return replyto;} |
49 | void setMsgsize(int size){msg_size = size;} | 51 | void setMsgsize(int size){msg_size = size;} |
50 | const int Msgsize()const{return msg_size;} | 52 | const int Msgsize()const{return msg_size;} |
51 | 53 | ||
52 | 54 | ||
53 | void setTo(const QStringList&list); | 55 | void setTo(const QStringList&list); |
54 | const QStringList&To()const; | 56 | const QStringList&To()const; |
55 | void setCC(const QStringList&list); | 57 | void setCC(const QStringList&list); |
56 | const QStringList&CC()const; | 58 | const QStringList&CC()const; |
57 | void setBcc(const QStringList&list); | 59 | void setBcc(const QStringList&list); |
58 | const QStringList&Bcc()const; | 60 | const QStringList&Bcc()const; |
59 | const QBitArray&getFlags()const{return msg_flags;} | 61 | const QBitArray&getFlags()const{return msg_flags;} |
60 | void setFlags(const QBitArray&flags){msg_flags = flags;} | 62 | void setFlags(const QBitArray&flags){msg_flags = flags;} |
61 | 63 | ||
62 | protected: | 64 | protected: |
63 | QString subject,date,from,mbox,msg_id,replyto; | 65 | QString subject,date,from,mbox,msg_id,replyto; |
64 | int msg_number,msg_size; | 66 | int msg_number,msg_size; |
65 | QBitArray msg_flags; | 67 | QBitArray msg_flags; |
66 | QStringList to,cc,bcc; | 68 | QStringList to,cc,bcc; |
67 | void init(); | 69 | void init(); |
68 | void copy_old(const RecMail&old); | 70 | void copy_old(const RecMail&old); |
69 | }; | 71 | }; |
70 | 72 | ||
73 | typedef QMap<QString,QString> part_plist_t; | ||
74 | |||
71 | class RecPart | 75 | class RecPart |
72 | { | 76 | { |
73 | protected: | 77 | protected: |
74 | QString m_type,m_subtype,m_identifier,m_encoding; | 78 | QString m_type,m_subtype,m_identifier,m_encoding; |
75 | unsigned int m_lines; | 79 | unsigned int m_lines; |
80 | part_plist_t m_Parameters; | ||
81 | /* describes the position in the mail */ | ||
82 | QValueList<int> m_poslist; | ||
83 | |||
76 | public: | 84 | public: |
77 | RecPart(); | 85 | RecPart(); |
78 | RecPart(const QString&identifier,const QString&type="",const QString&subtype="",const QString&encoding="BASE64",unsigned int lines=0); | ||
79 | virtual ~RecPart(); | 86 | virtual ~RecPart(); |
80 | 87 | ||
81 | const QString&Type()const; | 88 | const QString&Type()const; |
82 | void setType(const QString&type); | 89 | void setType(const QString&type); |
83 | const QString&Subtype()const; | 90 | const QString&Subtype()const; |
84 | void setSubtype(const QString&subtype); | 91 | void setSubtype(const QString&subtype); |
85 | const QString&Identifier()const; | 92 | const QString&Identifier()const; |
86 | void setIdentifier(const QString&identifier); | 93 | void setIdentifier(const QString&identifier); |
87 | const QString&Encoding()const; | 94 | const QString&Encoding()const; |
88 | void setEncoding(const QString&encoding); | 95 | void setEncoding(const QString&encoding); |
89 | void setLines(unsigned int lines); | 96 | void setLines(unsigned int lines); |
90 | const unsigned int Lines()const; | 97 | const unsigned int Lines()const; |
98 | |||
99 | void setParameters(const part_plist_t&list); | ||
100 | const part_plist_t&Parameters()const; | ||
101 | void addParameter(const QString&key,const QString&value); | ||
102 | const QString searchParamter(const QString&key)const; | ||
103 | void setPositionlist(const QValueList<int>&poslist); | ||
104 | const QValueList<int>& Positionlist()const; | ||
91 | }; | 105 | }; |
92 | 106 | ||
93 | class RecBody | 107 | class RecBody |
94 | { | 108 | { |
95 | protected: | 109 | protected: |
96 | QString m_BodyText,m_type,m_subtype; | 110 | QString m_BodyText; |
97 | QList<RecPart> m_PartsList; | 111 | QList<RecPart> m_PartsList; |
112 | RecPart m_description; | ||
98 | 113 | ||
99 | public: | 114 | public: |
100 | RecBody(); | 115 | RecBody(); |
101 | virtual ~RecBody(); | 116 | virtual ~RecBody(); |
102 | void setBodytext(const QString&); | 117 | void setBodytext(const QString&); |
103 | const QString& Bodytext()const; | 118 | const QString& Bodytext()const; |
104 | void setType(const QString&); | ||
105 | const QString&Type()const; | ||
106 | void setSubtype(const QString&); | ||
107 | const QString&Subtype()const; | ||
108 | 119 | ||
120 | void setDescription(const RecPart&des); | ||
121 | const RecPart& Description()const; | ||
109 | 122 | ||
110 | void setParts(const QList<RecPart>&parts); | 123 | void setParts(const QList<RecPart>&parts); |
111 | const QList<RecPart>& Parts()const; | 124 | const QList<RecPart>& Parts()const; |
112 | void addPart(const RecPart&part); | 125 | void addPart(const RecPart&part); |
113 | }; | 126 | }; |
114 | 127 | ||
115 | #endif | 128 | #endif |