summaryrefslogtreecommitdiff
authoralwin <alwin>2003-12-10 20:33:31 (UTC)
committer alwin <alwin>2003-12-10 20:33:31 (UTC)
commit7dc6ff83f138c78b6bd5e8a4d922a6e60c533a1f (patch) (unidiff)
treec3f53894691dd71cbdf05e69603f7ac55ea2474c
parent66aa51039689ab2dab153469d7f6527bcedd9318 (diff)
downloadopie-7dc6ff83f138c78b6bd5e8a4d922a6e60c533a1f.zip
opie-7dc6ff83f138c78b6bd5e8a4d922a6e60c533a1f.tar.gz
opie-7dc6ff83f138c78b6bd5e8a4d922a6e60c533a1f.tar.bz2
changes to work with libetpan 0.3.1
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.cpp50
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp52
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h1
-rw-r--r--noncore/net/mail/mailwrapper.cpp50
-rw-r--r--noncore/net/mail/pop3wrapper.cpp52
-rw-r--r--noncore/net/mail/pop3wrapper.h1
6 files changed, 104 insertions, 102 deletions
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
index 898e9d6..3ffc274 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
@@ -104,526 +104,526 @@ mailimf_address_list *MailWrapper::parseAddresses(const QString&addr )
104 QStringList::Iterator it; 104 QStringList::Iterator it;
105 for ( it = list.begin(); it != list.end(); it++ ) { 105 for ( it = list.begin(); it != list.end(); it++ ) {
106 char *str = strdup( (*it).latin1() ); 106 char *str = strdup( (*it).latin1() );
107 int err = mailimf_address_list_add_parse( addresses, str ); 107 int err = mailimf_address_list_add_parse( addresses, str );
108 if ( err != MAILIMF_NO_ERROR ) { 108 if ( err != MAILIMF_NO_ERROR ) {
109 qDebug( "Error parsing" ); 109 qDebug( "Error parsing" );
110 qDebug( *it ); 110 qDebug( *it );
111 free( str ); 111 free( str );
112 } else { 112 } else {
113 qDebug( "Parse success! :)" ); 113 qDebug( "Parse success! :)" );
114 } 114 }
115 } 115 }
116 116
117 return addresses; 117 return addresses;
118} 118}
119 119
120mailimf_fields *MailWrapper::createImfFields( Mail *mail ) 120mailimf_fields *MailWrapper::createImfFields( Mail *mail )
121{ 121{
122 mailimf_fields *fields; 122 mailimf_fields *fields;
123 mailimf_field *xmailer; 123 mailimf_field *xmailer;
124 mailimf_mailbox *sender, *fromBox; 124 mailimf_mailbox *sender, *fromBox;
125 mailimf_mailbox_list *from; 125 mailimf_mailbox_list *from;
126 mailimf_address_list *to, *cc, *bcc, *reply; 126 mailimf_address_list *to, *cc, *bcc, *reply;
127 char *subject = strdup( mail->getSubject().latin1() ); 127 char *subject = strdup( mail->getSubject().latin1() );
128 int err; 128 int err;
129 129
130 sender = newMailbox( mail->getName(), mail->getMail() ); 130 sender = newMailbox( mail->getName(), mail->getMail() );
131 if ( sender == NULL ) goto err_free; 131 if ( sender == NULL ) goto err_free;
132 132
133 fromBox = newMailbox( mail->getName(), mail->getMail() ); 133 fromBox = newMailbox( mail->getName(), mail->getMail() );
134 if ( fromBox == NULL ) goto err_free_sender; 134 if ( fromBox == NULL ) goto err_free_sender;
135 135
136 from = mailimf_mailbox_list_new_empty(); 136 from = mailimf_mailbox_list_new_empty();
137 if ( from == NULL ) goto err_free_fromBox; 137 if ( from == NULL ) goto err_free_fromBox;
138 138
139 err = mailimf_mailbox_list_add( from, fromBox ); 139 err = mailimf_mailbox_list_add( from, fromBox );
140 if ( err != MAILIMF_NO_ERROR ) goto err_free_from; 140 if ( err != MAILIMF_NO_ERROR ) goto err_free_from;
141 141
142 to = parseAddresses( mail->getTo() ); 142 to = parseAddresses( mail->getTo() );
143 if ( to == NULL ) goto err_free_from; 143 if ( to == NULL ) goto err_free_from;
144 144
145 cc = parseAddresses( mail->getCC() ); 145 cc = parseAddresses( mail->getCC() );
146 bcc = parseAddresses( mail->getBCC() ); 146 bcc = parseAddresses( mail->getBCC() );
147 reply = parseAddresses( mail->getReply() ); 147 reply = parseAddresses( mail->getReply() );
148 148
149 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, 149 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc,
150 NULL, NULL, subject ); 150 NULL, NULL, subject );
151 if ( fields == NULL ) goto err_free_reply; 151 if ( fields == NULL ) goto err_free_reply;
152 152
153 xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), 153 xmailer = mailimf_field_new_custom( strdup( "User-Agent" ),
154 strdup( USER_AGENT ) ); 154 strdup( USER_AGENT ) );
155 if ( xmailer == NULL ) goto err_free_fields; 155 if ( xmailer == NULL ) goto err_free_fields;
156 156
157 err = mailimf_fields_add( fields, xmailer ); 157 err = mailimf_fields_add( fields, xmailer );
158 if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; 158 if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer;
159 159
160 return fields; // Success :) 160 return fields; // Success :)
161 161
162err_free_xmailer: 162err_free_xmailer:
163 mailimf_field_free( xmailer ); 163 mailimf_field_free( xmailer );
164err_free_fields: 164err_free_fields:
165 mailimf_fields_free( fields ); 165 mailimf_fields_free( fields );
166err_free_reply: 166err_free_reply:
167 mailimf_address_list_free( reply ); 167 mailimf_address_list_free( reply );
168 mailimf_address_list_free( bcc ); 168 mailimf_address_list_free( bcc );
169 mailimf_address_list_free( cc ); 169 mailimf_address_list_free( cc );
170 mailimf_address_list_free( to ); 170 mailimf_address_list_free( to );
171err_free_from: 171err_free_from:
172 mailimf_mailbox_list_free( from ); 172 mailimf_mailbox_list_free( from );
173err_free_fromBox: 173err_free_fromBox:
174 mailimf_mailbox_free( fromBox ); 174 mailimf_mailbox_free( fromBox );
175err_free_sender: 175err_free_sender:
176 mailimf_mailbox_free( sender ); 176 mailimf_mailbox_free( sender );
177err_free: 177err_free:
178 free( subject ); 178 free( subject );
179 qDebug( "createImfFields - error" ); 179 qDebug( "createImfFields - error" );
180 180
181 return NULL; // Error :( 181 return NULL; // Error :(
182} 182}
183 183
184mailmime *MailWrapper::buildTxtPart( QString str ) 184mailmime *MailWrapper::buildTxtPart( QString str )
185{ 185{
186 mailmime *txtPart; 186 mailmime *txtPart;
187 mailmime_fields *fields; 187 mailmime_fields *fields;
188 mailmime_content *content; 188 mailmime_content *content;
189 mailmime_parameter *param; 189 mailmime_parameter *param;
190 char *txt = strdup( str.latin1() ); 190 char *txt = strdup( str.latin1() );
191 int err; 191 int err;
192 192
193 param = mailmime_parameter_new( strdup( "charset" ), 193 param = mailmime_parameter_new( strdup( "charset" ),
194 strdup( "iso-8859-1" ) ); 194 strdup( "iso-8859-1" ) );
195 if ( param == NULL ) goto err_free; 195 if ( param == NULL ) goto err_free;
196 196
197 content = mailmime_content_new_with_str( "text/plain" ); 197 content = mailmime_content_new_with_str( "text/plain" );
198 if ( content == NULL ) goto err_free_param; 198 if ( content == NULL ) goto err_free_param;
199 199
200 err = clist_append( content->parameters, param ); 200 err = clist_append( content->ct_parameters, param );
201 if ( err != MAILIMF_NO_ERROR ) goto err_free_content; 201 if ( err != MAILIMF_NO_ERROR ) goto err_free_content;
202 202
203 fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT ); 203 fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT );
204 if ( fields == NULL ) goto err_free_content; 204 if ( fields == NULL ) goto err_free_content;
205 205
206 txtPart = mailmime_new_empty( content, fields ); 206 txtPart = mailmime_new_empty( content, fields );
207 if ( txtPart == NULL ) goto err_free_fields; 207 if ( txtPart == NULL ) goto err_free_fields;
208 208
209 err = mailmime_set_body_text( txtPart, txt, strlen( txt ) ); 209 err = mailmime_set_body_text( txtPart, txt, strlen( txt ) );
210 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; 210 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart;
211 211
212 return txtPart; // Success :) 212 return txtPart; // Success :)
213 213
214err_free_txtPart: 214err_free_txtPart:
215 mailmime_free( txtPart ); 215 mailmime_free( txtPart );
216err_free_fields: 216err_free_fields:
217 mailmime_fields_free( fields ); 217 mailmime_fields_free( fields );
218err_free_content: 218err_free_content:
219 mailmime_content_free( content ); 219 mailmime_content_free( content );
220err_free_param: 220err_free_param:
221 mailmime_parameter_free( param ); 221 mailmime_parameter_free( param );
222err_free: 222err_free:
223 free( txt ); 223 free( txt );
224 qDebug( "buildTxtPart - error" ); 224 qDebug( "buildTxtPart - error" );
225 225
226 return NULL; // Error :( 226 return NULL; // Error :(
227} 227}
228 228
229mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) 229mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype )
230{ 230{
231 mailmime * filePart; 231 mailmime * filePart;
232 mailmime_fields * fields; 232 mailmime_fields * fields;
233 mailmime_content * content; 233 mailmime_content * content;
234 mailmime_parameter * param = NULL; 234 mailmime_parameter * param = NULL;
235 int err; 235 int err;
236 236
237 int pos = filename.findRev( '/' ); 237 int pos = filename.findRev( '/' );
238 QString tmp = filename.right( filename.length() - ( pos + 1 ) ); 238 QString tmp = filename.right( filename.length() - ( pos + 1 ) );
239 char *name = strdup( tmp.latin1() ); // just filename 239 char *name = strdup( tmp.latin1() ); // just filename
240 char *file = strdup( filename.latin1() ); // full name with path 240 char *file = strdup( filename.latin1() ); // full name with path
241 char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain 241 char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain
242 242
243 fields = mailmime_fields_new_filename( 243 fields = mailmime_fields_new_filename(
244 MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name, 244 MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name,
245 MAILMIME_MECHANISM_BASE64 ); 245 MAILMIME_MECHANISM_BASE64 );
246 if ( fields == NULL ) goto err_free; 246 if ( fields == NULL ) goto err_free;
247 247
248 content = mailmime_content_new_with_str( mime ); 248 content = mailmime_content_new_with_str( mime );
249 if ( content == NULL ) goto err_free_fields; 249 if ( content == NULL ) goto err_free_fields;
250 250
251 if ( mimetype.compare( "text/plain" ) == 0 ) { 251 if ( mimetype.compare( "text/plain" ) == 0 ) {
252 param = mailmime_parameter_new( strdup( "charset" ), 252 param = mailmime_parameter_new( strdup( "charset" ),
253 strdup( "iso-8859-1" ) ); 253 strdup( "iso-8859-1" ) );
254 if ( param == NULL ) goto err_free_content; 254 if ( param == NULL ) goto err_free_content;
255 255
256 err = clist_append( content->parameters, param ); 256 err = clist_append( content->ct_parameters, param );
257 if ( err != MAILIMF_NO_ERROR ) goto err_free_param; 257 if ( err != MAILIMF_NO_ERROR ) goto err_free_param;
258 } 258 }
259 259
260 filePart = mailmime_new_empty( content, fields ); 260 filePart = mailmime_new_empty( content, fields );
261 if ( filePart == NULL ) goto err_free_param; 261 if ( filePart == NULL ) goto err_free_param;
262 262
263 err = mailmime_set_body_file( filePart, file ); 263 err = mailmime_set_body_file( filePart, file );
264 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; 264 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart;
265 265
266 return filePart; // Success :) 266 return filePart; // Success :)
267 267
268err_free_filePart: 268err_free_filePart:
269 mailmime_free( filePart ); 269 mailmime_free( filePart );
270err_free_param: 270err_free_param:
271 if ( param != NULL ) mailmime_parameter_free( param ); 271 if ( param != NULL ) mailmime_parameter_free( param );
272err_free_content: 272err_free_content:
273 mailmime_content_free( content ); 273 mailmime_content_free( content );
274err_free_fields: 274err_free_fields:
275 mailmime_fields_free( fields ); 275 mailmime_fields_free( fields );
276err_free: 276err_free:
277 free( name ); 277 free( name );
278 free( mime ); 278 free( mime );
279 free( file ); 279 free( file );
280 qDebug( "buildFilePart - error" ); 280 qDebug( "buildFilePart - error" );
281 281
282 return NULL; // Error :( 282 return NULL; // Error :(
283} 283}
284 284
285void MailWrapper::addFileParts( mailmime *message, QList<Attachment> files ) 285void MailWrapper::addFileParts( mailmime *message, QList<Attachment> files )
286{ 286{
287 Attachment *it; 287 Attachment *it;
288 for ( it = files.first(); it; it = files.next() ) { 288 for ( it = files.first(); it; it = files.next() ) {
289 qDebug( "Adding file" ); 289 qDebug( "Adding file" );
290 mailmime *filePart; 290 mailmime *filePart;
291 int err; 291 int err;
292 292
293 filePart = buildFilePart( it->getFileName(), it->getMimeType() ); 293 filePart = buildFilePart( it->getFileName(), it->getMimeType() );
294 if ( filePart == NULL ) goto err_free; 294 if ( filePart == NULL ) goto err_free;
295 295
296 err = mailmime_smart_add_part( message, filePart ); 296 err = mailmime_smart_add_part( message, filePart );
297 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; 297 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart;
298 298
299 continue; // Success :) 299 continue; // Success :)
300 300
301 err_free_filePart: 301 err_free_filePart:
302 mailmime_free( filePart ); 302 mailmime_free( filePart );
303 err_free: 303 err_free:
304 qDebug( "addFileParts: error adding file:" ); 304 qDebug( "addFileParts: error adding file:" );
305 qDebug( it->getFileName() ); 305 qDebug( it->getFileName() );
306 } 306 }
307} 307}
308 308
309mailmime *MailWrapper::createMimeMail( Mail *mail ) 309mailmime *MailWrapper::createMimeMail( Mail *mail )
310{ 310{
311 mailmime *message, *txtPart; 311 mailmime *message, *txtPart;
312 mailimf_fields *fields; 312 mailimf_fields *fields;
313 int err; 313 int err;
314 314
315 fields = createImfFields( mail ); 315 fields = createImfFields( mail );
316 if ( fields == NULL ) goto err_free; 316 if ( fields == NULL ) goto err_free;
317 317
318 message = mailmime_new_message_data( NULL ); 318 message = mailmime_new_message_data( NULL );
319 if ( message == NULL ) goto err_free_fields; 319 if ( message == NULL ) goto err_free_fields;
320 320
321 mailmime_set_imf_fields( message, fields ); 321 mailmime_set_imf_fields( message, fields );
322 322
323 txtPart = buildTxtPart( mail->getMessage() ); 323 txtPart = buildTxtPart( mail->getMessage() );
324 if ( txtPart == NULL ) goto err_free_message; 324 if ( txtPart == NULL ) goto err_free_message;
325 325
326 err = mailmime_smart_add_part( message, txtPart ); 326 err = mailmime_smart_add_part( message, txtPart );
327 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; 327 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart;
328 328
329 addFileParts( message, mail->getAttachments() ); 329 addFileParts( message, mail->getAttachments() );
330 330
331 return message; // Success :) 331 return message; // Success :)
332 332
333err_free_txtPart: 333err_free_txtPart:
334 mailmime_free( txtPart ); 334 mailmime_free( txtPart );
335err_free_message: 335err_free_message:
336 mailmime_free( message ); 336 mailmime_free( message );
337err_free_fields: 337err_free_fields:
338 mailimf_fields_free( fields ); 338 mailimf_fields_free( fields );
339err_free: 339err_free:
340 qDebug( "createMimeMail: error" ); 340 qDebug( "createMimeMail: error" );
341 341
342 return NULL; // Error :( 342 return NULL; // Error :(
343} 343}
344 344
345mailimf_field *MailWrapper::getField( mailimf_fields *fields, int type ) 345mailimf_field *MailWrapper::getField( mailimf_fields *fields, int type )
346{ 346{
347 mailimf_field *field; 347 mailimf_field *field;
348 clistiter *it; 348 clistiter *it;
349 349
350 it = clist_begin( fields->list ); 350 it = clist_begin( fields->fld_list );
351 while ( it ) { 351 while ( it ) {
352 field = (mailimf_field *) it->data; 352 field = (mailimf_field *) it->data;
353 if ( field->type == type ) { 353 if ( field->fld_type == type ) {
354 return field; 354 return field;
355 } 355 }
356 it = it->next; 356 it = it->next;
357 } 357 }
358 358
359 return NULL; 359 return NULL;
360} 360}
361 361
362static void addRcpts( clist *list, mailimf_address_list *addr_list ) 362static void addRcpts( clist *list, mailimf_address_list *addr_list )
363{ 363{
364 clistiter *it, *it2; 364 clistiter *it, *it2;
365 365
366 for ( it = clist_begin( addr_list->list ); it; it = it->next ) { 366 for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) {
367 mailimf_address *addr; 367 mailimf_address *addr;
368 addr = (mailimf_address *) it->data; 368 addr = (mailimf_address *) it->data;
369 369
370 if ( addr->type == MAILIMF_ADDRESS_MAILBOX ) { 370 if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) {
371 esmtp_address_list_add( list, addr->mailbox->addr_spec, 0, NULL ); 371 esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL );
372 } else if ( addr->type == MAILIMF_ADDRESS_GROUP ) { 372 } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) {
373 clist *l = addr->group->mb_list->list; 373 clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list;
374 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { 374 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) {
375 mailimf_mailbox *mbox; 375 mailimf_mailbox *mbox;
376 mbox = (mailimf_mailbox *) it2->data; 376 mbox = (mailimf_mailbox *) it2->data;
377 esmtp_address_list_add( list, mbox->addr_spec, 0, NULL ); 377 esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL );
378 } 378 }
379 } 379 }
380 } 380 }
381} 381}
382 382
383clist *MailWrapper::createRcptList( mailimf_fields *fields ) 383clist *MailWrapper::createRcptList( mailimf_fields *fields )
384{ 384{
385 clist *rcptList; 385 clist *rcptList;
386 mailimf_field *field; 386 mailimf_field *field;
387 387
388 rcptList = esmtp_address_list_new(); 388 rcptList = esmtp_address_list_new();
389 389
390 field = getField( fields, MAILIMF_FIELD_TO ); 390 field = getField( fields, MAILIMF_FIELD_TO );
391 if ( field && (field->type == MAILIMF_FIELD_TO) 391 if ( field && (field->fld_type == MAILIMF_FIELD_TO)
392 && field->field.to->addr_list ) { 392 && field->fld_data.fld_to->to_addr_list ) {
393 addRcpts( rcptList, field->field.to->addr_list ); 393 addRcpts( rcptList, field->fld_data.fld_to->to_addr_list );
394 } 394 }
395 395
396 field = getField( fields, MAILIMF_FIELD_CC ); 396 field = getField( fields, MAILIMF_FIELD_CC );
397 if ( field && (field->type == MAILIMF_FIELD_CC) 397 if ( field && (field->fld_type == MAILIMF_FIELD_CC)
398 && field->field.cc->addr_list ) { 398 && field->fld_data.fld_cc->cc_addr_list ) {
399 addRcpts( rcptList, field->field.cc->addr_list ); 399 addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list );
400 } 400 }
401 401
402 field = getField( fields, MAILIMF_FIELD_BCC ); 402 field = getField( fields, MAILIMF_FIELD_BCC );
403 if ( field && (field->type == MAILIMF_FIELD_BCC) 403 if ( field && (field->fld_type == MAILIMF_FIELD_BCC)
404 && field->field.bcc->addr_list ) { 404 && field->fld_data.fld_bcc->bcc_addr_list ) {
405 addRcpts( rcptList, field->field.bcc->addr_list ); 405 addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list );
406 } 406 }
407 407
408 return rcptList; 408 return rcptList;
409} 409}
410 410
411char *MailWrapper::getFrom( mailmime *mail ) 411char *MailWrapper::getFrom( mailmime *mail )
412{ 412{
413 char *from = NULL; 413 char *from = NULL;
414 414
415 mailimf_field *ffrom; 415 mailimf_field *ffrom;
416 ffrom = getField( mail->fields, MAILIMF_FIELD_FROM ); 416 ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM );
417 if ( ffrom && (ffrom->type == MAILIMF_FIELD_FROM) 417 if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM)
418 && ffrom->field.from->mb_list && ffrom->field.from->mb_list->list ) { 418 && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) {
419 clist *cl = ffrom->field.from->mb_list->list; 419 clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list;
420 clistiter *it; 420 clistiter *it;
421 for ( it = clist_begin( cl ); it; it = it->next ) { 421 for ( it = clist_begin( cl ); it; it = it->next ) {
422 mailimf_mailbox *mb = (mailimf_mailbox *) it->data; 422 mailimf_mailbox *mb = (mailimf_mailbox *) it->data;
423 from = strdup( mb->addr_spec ); 423 from = strdup( mb->mb_addr_spec );
424 } 424 }
425 } 425 }
426 426
427 return from; 427 return from;
428} 428}
429 429
430SMTPaccount *MailWrapper::getAccount( QString from ) 430SMTPaccount *MailWrapper::getAccount( QString from )
431{ 431{
432 SMTPaccount *smtp; 432 SMTPaccount *smtp;
433 433
434 QList<Account> list = settings->getAccounts(); 434 QList<Account> list = settings->getAccounts();
435 Account *it; 435 Account *it;
436 for ( it = list.first(); it; it = list.next() ) { 436 for ( it = list.first(); it; it = list.next() ) {
437 if ( it->getType().compare( "SMTP" ) == 0 ) { 437 if ( it->getType().compare( "SMTP" ) == 0 ) {
438 smtp = static_cast<SMTPaccount *>(it); 438 smtp = static_cast<SMTPaccount *>(it);
439 if ( smtp->getMail().compare( from ) == 0 ) { 439 if ( smtp->getMail().compare( from ) == 0 ) {
440 qDebug( "SMTPaccount found for" ); 440 qDebug( "SMTPaccount found for" );
441 qDebug( from ); 441 qDebug( from );
442 return smtp; 442 return smtp;
443 } 443 }
444 } 444 }
445 } 445 }
446 446
447 return NULL; 447 return NULL;
448} 448}
449 449
450QString MailWrapper::getTmpFile() { 450QString MailWrapper::getTmpFile() {
451 int num = 0; 451 int num = 0;
452 QString unique; 452 QString unique;
453 453
454 QDir dir( "/tmp" ); 454 QDir dir( "/tmp" );
455 QStringList::Iterator it; 455 QStringList::Iterator it;
456 456
457 QStringList list = dir.entryList( "opiemail-tmp-*" ); 457 QStringList list = dir.entryList( "opiemail-tmp-*" );
458 do { 458 do {
459 unique.setNum( num++ ); 459 unique.setNum( num++ );
460 } while ( list.contains( "opiemail-tmp-" + unique ) > 0 ); 460 } while ( list.contains( "opiemail-tmp-" + unique ) > 0 );
461 461
462 return "/tmp/opiemail-tmp-" + unique; 462 return "/tmp/opiemail-tmp-" + unique;
463} 463}
464 464
465void MailWrapper::writeToFile( QString file, mailmime *mail ) 465void MailWrapper::writeToFile( QString file, mailmime *mail )
466{ 466{
467 FILE *f; 467 FILE *f;
468 int err, col = 0; 468 int err, col = 0;
469 469
470 f = fopen( file.latin1(), "w" ); 470 f = fopen( file.latin1(), "w" );
471 if ( f == NULL ) { 471 if ( f == NULL ) {
472 qDebug( "writeToFile: error opening file" ); 472 qDebug( "writeToFile: error opening file" );
473 return; 473 return;
474 } 474 }
475 475
476 err = mailmime_write( f, &col, mail ); 476 err = mailmime_write( f, &col, mail );
477 if ( err != MAILIMF_NO_ERROR ) { 477 if ( err != MAILIMF_NO_ERROR ) {
478 fclose( f ); 478 fclose( f );
479 qDebug( "writeToFile: error writing mailmime" ); 479 qDebug( "writeToFile: error writing mailmime" );
480 return; 480 return;
481 } 481 }
482 482
483 fclose( f ); 483 fclose( f );
484} 484}
485 485
486void MailWrapper::readFromFile( QString file, char **data, size_t *size ) 486void MailWrapper::readFromFile( QString file, char **data, size_t *size )
487{ 487{
488 char *buf; 488 char *buf;
489 struct stat st; 489 struct stat st;
490 int fd, count = 0, total = 0; 490 int fd, count = 0, total = 0;
491 491
492 fd = open( file.latin1(), O_RDONLY, 0 ); 492 fd = open( file.latin1(), O_RDONLY, 0 );
493 if ( fd == -1 ) return; 493 if ( fd == -1 ) return;
494 494
495 if ( fstat( fd, &st ) != 0 ) goto err_close; 495 if ( fstat( fd, &st ) != 0 ) goto err_close;
496 if ( !st.st_size ) goto err_close; 496 if ( !st.st_size ) goto err_close;
497 497
498 buf = (char *) malloc( st.st_size ); 498 buf = (char *) malloc( st.st_size );
499 if ( !buf ) goto err_close; 499 if ( !buf ) goto err_close;
500 500
501 while ( ( total < st.st_size ) && ( count >= 0 ) ) { 501 while ( ( total < st.st_size ) && ( count >= 0 ) ) {
502 count = read( fd, buf + total, st.st_size - total ); 502 count = read( fd, buf + total, st.st_size - total );
503 total += count; 503 total += count;
504 } 504 }
505 if ( count < 0 ) goto err_free; 505 if ( count < 0 ) goto err_free;
506 506
507 *data = buf; 507 *data = buf;
508 *size = st.st_size; 508 *size = st.st_size;
509 509
510 close( fd ); 510 close( fd );
511 511
512 return; // Success :) 512 return; // Success :)
513 513
514err_free: 514err_free:
515 free( buf ); 515 free( buf );
516err_close: 516err_close:
517 close( fd ); 517 close( fd );
518} 518}
519 519
520void progress( size_t current, size_t maximum ) 520void progress( size_t current, size_t maximum )
521{ 521{
522 qDebug( "Current: %i of %i", current, maximum ); 522 qDebug( "Current: %i of %i", current, maximum );
523} 523}
524 524
525void MailWrapper::smtpSend( mailmime *mail ) 525void MailWrapper::smtpSend( mailmime *mail )
526{ 526{
527 mailsmtp *session; 527 mailsmtp *session;
528 clist *rcpts; 528 clist *rcpts;
529 char *from, *data, *server, *user = NULL, *pass = NULL; 529 char *from, *data, *server, *user = NULL, *pass = NULL;
530 size_t size; 530 size_t size;
531 int err; 531 int err;
532 bool ssl; 532 bool ssl;
533 uint16_t port; 533 uint16_t port;
534 534
535 535
536 from = getFrom( mail ); 536 from = getFrom( mail );
537 SMTPaccount *smtp = getAccount( from ); 537 SMTPaccount *smtp = getAccount( from );
538 if ( smtp == NULL ) { 538 if ( smtp == NULL ) {
539 free(from); 539 free(from);
540 return; 540 return;
541 } 541 }
542 server = strdup( smtp->getServer().latin1() ); 542 server = strdup( smtp->getServer().latin1() );
543 ssl = smtp->getSSL(); 543 ssl = smtp->getSSL();
544 port = smtp->getPort().toUInt(); 544 port = smtp->getPort().toUInt();
545 rcpts = createRcptList( mail->fields ); 545 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
546 546
547 QString file = getTmpFile(); 547 QString file = getTmpFile();
548 writeToFile( file, mail ); 548 writeToFile( file, mail );
549 readFromFile( file, &data, &size ); 549 readFromFile( file, &data, &size );
550 QFile f( file ); 550 QFile f( file );
551 f.remove(); 551 f.remove();
552 552
553 session = mailsmtp_new( 20, &progress ); 553 session = mailsmtp_new( 20, &progress );
554 if ( session == NULL ) goto free_mem; 554 if ( session == NULL ) goto free_mem;
555 555
556 qDebug( "Servername %s at port %i", server, port ); 556 qDebug( "Servername %s at port %i", server, port );
557 if ( ssl ) { 557 if ( ssl ) {
558 qDebug( "SSL session" ); 558 qDebug( "SSL session" );
559 err = mailsmtp_ssl_connect( session, server, port ); 559 err = mailsmtp_ssl_connect( session, server, port );
560 } else { 560 } else {
561 qDebug( "No SSL session" ); 561 qDebug( "No SSL session" );
562 err = mailsmtp_socket_connect( session, server, port ); 562 err = mailsmtp_socket_connect( session, server, port );
563 } 563 }
564 if ( err != MAILSMTP_NO_ERROR ) goto free_mem_session; 564 if ( err != MAILSMTP_NO_ERROR ) goto free_mem_session;
565 565
566 err = mailsmtp_init( session ); 566 err = mailsmtp_init( session );
567 if ( err != MAILSMTP_NO_ERROR ) goto free_con_session; 567 if ( err != MAILSMTP_NO_ERROR ) goto free_con_session;
568 568
569 qDebug( "INIT OK" ); 569 qDebug( "INIT OK" );
570 570
571 if ( smtp->getLogin() ) { 571 if ( smtp->getLogin() ) {
572 if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) { 572 if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) {
573 // get'em 573 // get'em
574 LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true ); 574 LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true );
575 login.show(); 575 login.show();
576 if ( QDialog::Accepted == login.exec() ) { 576 if ( QDialog::Accepted == login.exec() ) {
577 // ok 577 // ok
578 user = strdup( login.getUser().latin1() ); 578 user = strdup( login.getUser().latin1() );
579 pass = strdup( login.getPassword().latin1() ); 579 pass = strdup( login.getPassword().latin1() );
580 } else { 580 } else {
581 goto free_con_session; 581 goto free_con_session;
582 } 582 }
583 } else { 583 } else {
584 user = strdup( smtp->getUser().latin1() ); 584 user = strdup( smtp->getUser().latin1() );
585 pass = strdup( smtp->getPassword().latin1() ); 585 pass = strdup( smtp->getPassword().latin1() );
586 } 586 }
587 qDebug( "session->auth: %i", session->auth); 587 qDebug( "session->auth: %i", session->auth);
588 err = mailsmtp_auth( session, user, pass ); 588 err = mailsmtp_auth( session, user, pass );
589 if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); 589 if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok");
590 qDebug( "Done auth!" ); 590 qDebug( "Done auth!" );
591 } 591 }
592 592
593 err = mailsmtp_send( session, from, rcpts, data, size ); 593 err = mailsmtp_send( session, from, rcpts, data, size );
594 if ( err != MAILSMTP_NO_ERROR ) goto free_con_session; 594 if ( err != MAILSMTP_NO_ERROR ) goto free_con_session;
595 595
596 qDebug( "Mail sent." ); 596 qDebug( "Mail sent." );
597 597
598free_con_session: 598free_con_session:
599 mailsmtp_quit( session ); 599 mailsmtp_quit( session );
600free_mem_session: 600free_mem_session:
601 mailsmtp_free( session ); 601 mailsmtp_free( session );
602free_mem: 602free_mem:
603 smtp_address_list_free( rcpts ); 603 smtp_address_list_free( rcpts );
604 free( data ); 604 free( data );
605 free( server ); 605 free( server );
606 if ( smtp->getLogin() ) { 606 if ( smtp->getLogin() ) {
607 free( user ); 607 free( user );
608 free( pass ); 608 free( pass );
609 } 609 }
610 free( from ); 610 free( from );
611} 611}
612 612
613void MailWrapper::sendMail( Mail mail ) 613void MailWrapper::sendMail( Mail mail )
614{ 614{
615 mailmime *mimeMail; 615 mailmime *mimeMail;
616 616
617 mimeMail = createMimeMail( &mail ); 617 mimeMail = createMimeMail( &mail );
618 if ( mimeMail == NULL ) { 618 if ( mimeMail == NULL ) {
619 qDebug( "sendMail: error creating mime mail" ); 619 qDebug( "sendMail: error creating mime mail" );
620 } else { 620 } else {
621 smtpSend( mimeMail ); 621 smtpSend( mimeMail );
622 mailmime_free( mimeMail ); 622 mailmime_free( mimeMail );
623 } 623 }
624} 624}
625 625
626Mail::Mail() 626Mail::Mail()
627 :name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") 627 :name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("")
628{ 628{
629} 629}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 72f3c36..633faf6 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -1,243 +1,243 @@
1 1
2#include "pop3wrapper.h" 2#include "pop3wrapper.h"
3#include "mailtypes.h" 3#include "mailtypes.h"
4#include <libetpan/mailpop3.h> 4#include <libetpan/mailpop3.h>
5 5
6POP3wrapper::POP3wrapper( POP3account *a ) 6POP3wrapper::POP3wrapper( POP3account *a )
7{ 7{
8 account = a; 8 account = a;
9 m_pop3 = NULL; 9 m_pop3 = NULL;
10} 10}
11 11
12POP3wrapper::~POP3wrapper() 12POP3wrapper::~POP3wrapper()
13{ 13{
14 logout(); 14 logout();
15} 15}
16 16
17void POP3wrapper::pop3_progress( size_t current, size_t maximum ) 17void POP3wrapper::pop3_progress( size_t current, size_t maximum )
18{ 18{
19 qDebug( "POP3: %i of %i", current, maximum ); 19 qDebug( "POP3: %i of %i", current, maximum );
20} 20}
21 21
22void POP3wrapper::listMessages( QList<RecMail> &target ) 22void POP3wrapper::listMessages( QList<RecMail> &target )
23{ 23{
24 int err = MAILPOP3_NO_ERROR; 24 int err = MAILPOP3_NO_ERROR;
25 char *header; 25 char *header;
26 size_t length; 26 size_t length;
27 carray *messages; 27 carray *messages;
28 28
29 login(); 29 login();
30 if (!m_pop3) return; 30 if (!m_pop3) return;
31 mailpop3_list( m_pop3, &messages ); 31 mailpop3_list( m_pop3, &messages );
32 32
33 for ( int i = carray_count( messages ); i > 0; i-- ) { 33 for ( int i = carray_count( messages ); i > 0; i-- ) {
34 mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 ); 34 mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 );
35 35
36 err = mailpop3_header( m_pop3, info->index, &header, &length ); 36 err = mailpop3_header( m_pop3, info->msg_index, &header, &length );
37 if ( err != MAILPOP3_NO_ERROR ) { 37 if ( err != MAILPOP3_NO_ERROR ) {
38 qDebug( "POP3: error retrieving header msgid: %i", info->index ); 38 qDebug( "POP3: error retrieving header msgid: %i", info->msg_index );
39 logout(); 39 logout();
40 return; 40 return;
41 } 41 }
42 RecMail *mail = parseHeader( header ); 42 RecMail *mail = parseHeader( header );
43 mail->setNumber( info->index ); 43 mail->setNumber( info->msg_index );
44 target.append( mail ); 44 target.append( mail );
45 } 45 }
46 46
47 logout(); 47 logout();
48} 48}
49 49
50RecMail *POP3wrapper::parseHeader( const char *header ) 50RecMail *POP3wrapper::parseHeader( const char *header )
51{ 51{
52 int err = MAILIMF_NO_ERROR; 52 int err = MAILIMF_NO_ERROR;
53 size_t curTok; 53 size_t curTok;
54 RecMail *mail = new RecMail(); 54 RecMail *mail = new RecMail();
55 mailimf_fields *fields; 55 mailimf_fields *fields;
56 56
57 err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); 57 err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields );
58 for ( clistiter *current = clist_begin( fields->list ); current != NULL; current = current->next ) { 58 for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) {
59 mailimf_field *field = (mailimf_field *) current->data; 59 mailimf_field *field = (mailimf_field *) current->data;
60 switch ( field->type ) { 60 switch ( field->fld_type ) {
61 case MAILIMF_FIELD_FROM: 61 case MAILIMF_FIELD_FROM:
62 mail->setFrom( *parseMailboxList( field->field.from->mb_list ) ); 62 mail->setFrom( *parseMailboxList( field->fld_data.fld_from->frm_mb_list ) );
63 break; 63 break;
64 case MAILIMF_FIELD_TO: 64 case MAILIMF_FIELD_TO:
65 mail->setTo( *parseAddressList( field->field.to->addr_list ) ); 65 mail->setTo( *parseAddressList( field->fld_data.fld_to->to_addr_list ) );
66 break; 66 break;
67 case MAILIMF_FIELD_CC: 67 case MAILIMF_FIELD_CC:
68 mail->setCC( *parseAddressList( field->field.cc->addr_list ) ); 68 mail->setCC( *parseAddressList( field->fld_data.fld_cc->cc_addr_list ) );
69 break; 69 break;
70 case MAILIMF_FIELD_BCC: 70 case MAILIMF_FIELD_BCC:
71 mail->setBcc( *parseAddressList( field->field.bcc->addr_list ) ); 71 mail->setBcc( *parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) );
72 break; 72 break;
73 case MAILIMF_FIELD_SUBJECT: 73 case MAILIMF_FIELD_SUBJECT:
74 mail->setSubject( QString( field->field.subject->value ) ); 74 mail->setSubject( QString( field->fld_data.fld_subject->sbj_value ) );
75 break; 75 break;
76 case MAILIMF_FIELD_ORIG_DATE: 76 case MAILIMF_FIELD_ORIG_DATE:
77 mail->setDate( *parseDateTime( field->field.orig_date->date_time ) ); 77 mail->setDate( *parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) );
78 break; 78 break;
79 default: 79 default:
80 break; 80 break;
81 } 81 }
82 } 82 }
83 83
84 return mail; 84 return mail;
85} 85}
86 86
87QString *POP3wrapper::parseDateTime( mailimf_date_time *date ) 87QString *POP3wrapper::parseDateTime( mailimf_date_time *date )
88{ 88{
89 char tmp[23]; 89 char tmp[23];
90 90
91 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", 91 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
92 date->day, date->month, date->year, date->hour, date->min, date->sec, date->zone ); 92 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
93 93
94 QString *result = new QString( tmp ); 94 QString *result = new QString( tmp );
95 95
96 return result; 96 return result;
97} 97}
98 98
99QString *POP3wrapper::parseAddressList( mailimf_address_list *list ) 99QString *POP3wrapper::parseAddressList( mailimf_address_list *list )
100{ 100{
101 QString *result = new QString( "" ); 101 QString *result = new QString( "" );
102 102
103 bool first = true; 103 bool first = true;
104 for ( clistiter *current = clist_begin( list->list ); current != NULL; current = current->next ) { 104 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
105 mailimf_address *addr = (mailimf_address *) current->data; 105 mailimf_address *addr = (mailimf_address *) current->data;
106 106
107 if ( !first ) { 107 if ( !first ) {
108 result->append( "," ); 108 result->append( "," );
109 } else { 109 } else {
110 first = false; 110 first = false;
111 } 111 }
112 112
113 QString *tmp; 113 QString *tmp;
114 114
115 switch ( addr->type ) { 115 switch ( addr->ad_type ) {
116 case MAILIMF_ADDRESS_MAILBOX: 116 case MAILIMF_ADDRESS_MAILBOX:
117 tmp = parseMailbox( addr->mailbox ); 117 tmp = parseMailbox( addr->ad_data.ad_mailbox );
118 result->append( *tmp ); 118 result->append( *tmp );
119 delete tmp; 119 delete tmp;
120 break; 120 break;
121 case MAILIMF_ADDRESS_GROUP: 121 case MAILIMF_ADDRESS_GROUP:
122 tmp = parseGroup( addr->group ); 122 tmp = parseGroup( addr->ad_data.ad_group );
123 result->append( *tmp ); 123 result->append( *tmp );
124 delete tmp; 124 delete tmp;
125 break; 125 break;
126 default: 126 default:
127 qDebug( "POP3: unkown mailimf address type" ); 127 qDebug( "POP3: unkown mailimf address type" );
128 break; 128 break;
129 } 129 }
130 } 130 }
131 131
132 return result; 132 return result;
133} 133}
134 134
135QString *POP3wrapper::parseGroup( mailimf_group *group ) 135QString *POP3wrapper::parseGroup( mailimf_group *group )
136{ 136{
137 QString *result = new QString( "" ); 137 QString *result = new QString( "" );
138 138
139 result->append( group->display_name ); 139 result->append( group->grp_display_name );
140 result->append( ": " ); 140 result->append( ": " );
141 141
142 if ( group->mb_list != NULL ) { 142 if ( group->grp_mb_list != NULL ) {
143 QString *tmp = parseMailboxList( group->mb_list ); 143 QString *tmp = parseMailboxList( group->grp_mb_list );
144 result->append( *tmp ); 144 result->append( *tmp );
145 delete tmp; 145 delete tmp;
146 } 146 }
147 147
148 result->append( ";" ); 148 result->append( ";" );
149 149
150 return result; 150 return result;
151} 151}
152 152
153QString *POP3wrapper::parseMailbox( mailimf_mailbox *box ) 153QString *POP3wrapper::parseMailbox( mailimf_mailbox *box )
154{ 154{
155 QString *result = new QString( "" ); 155 QString *result = new QString( "" );
156 156
157 if ( box->display_name == NULL ) { 157 if ( box->mb_display_name == NULL ) {
158 result->append( box->addr_spec ); 158 result->append( box->mb_addr_spec );
159 } else { 159 } else {
160 result->append( box->display_name ); 160 result->append( box->mb_display_name );
161 result->append( " <" ); 161 result->append( " <" );
162 result->append( box->addr_spec ); 162 result->append( box->mb_addr_spec );
163 result->append( ">" ); 163 result->append( ">" );
164 } 164 }
165 165
166 return result; 166 return result;
167} 167}
168 168
169QString *POP3wrapper::parseMailboxList( mailimf_mailbox_list *list ) 169QString *POP3wrapper::parseMailboxList( mailimf_mailbox_list *list )
170{ 170{
171 QString *result = new QString( "" ); 171 QString *result = new QString( "" );
172 172
173 bool first = true; 173 bool first = true;
174 for ( clistiter *current = clist_begin( list->list ); current != NULL; current = current->next ) { 174 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
175 mailimf_mailbox *box = (mailimf_mailbox *) current->data; 175 mailimf_mailbox *box = (mailimf_mailbox *) current->data;
176 176
177 if ( !first ) { 177 if ( !first ) {
178 result->append( "," ); 178 result->append( "," );
179 } else { 179 } else {
180 first = false; 180 first = false;
181 } 181 }
182 182
183 QString *tmp = parseMailbox( box ); 183 QString *tmp = parseMailbox( box );
184 result->append( *tmp ); 184 result->append( *tmp );
185 delete tmp; 185 delete tmp;
186 } 186 }
187 187
188 return result; 188 return result;
189} 189}
190 190
191void POP3wrapper::login() 191void POP3wrapper::login()
192{ 192{
193 if ( m_pop3 != NULL ) logout(); 193 if ( m_pop3 != NULL ) logout();
194 194
195 const char *server, *user, *pass; 195 const char *server, *user, *pass;
196 uint16_t port; 196 uint16_t port;
197 int err = MAILPOP3_NO_ERROR; 197 int err = MAILPOP3_NO_ERROR;
198 198
199 server = account->getServer().latin1(); 199 server = account->getServer().latin1();
200 port = account->getPort().toUInt(); 200 port = account->getPort().toUInt();
201 user = account->getUser().latin1(); 201 user = account->getUser().latin1();
202 pass = account->getPassword().latin1(); 202 pass = account->getPassword().latin1();
203 203
204 m_pop3 = mailpop3_new( 200, &pop3_progress ); 204 m_pop3 = mailpop3_new( 200, &pop3_progress );
205 205
206 // connect 206 // connect
207 if (account->getSSL()) { 207 if (account->getSSL()) {
208 err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); 208 err = mailpop3_ssl_connect( m_pop3, (char*)server, port );
209 } else { 209 } else {
210 err = mailpop3_socket_connect( m_pop3, (char*)server, port ); 210 err = mailpop3_socket_connect( m_pop3, (char*)server, port );
211 } 211 }
212 212
213 if ( err != MAILPOP3_NO_ERROR ) { 213 if ( err != MAILPOP3_NO_ERROR ) {
214 qDebug( "pop3: error connecting to %s\n reason: %s", server, 214 qDebug( "pop3: error connecting to %s\n reason: %s", server,
215 m_pop3->response ); 215 m_pop3->pop3_response );
216 mailpop3_free( m_pop3 ); 216 mailpop3_free( m_pop3 );
217 m_pop3 = NULL; 217 m_pop3 = NULL;
218 return; 218 return;
219 } 219 }
220 qDebug( "POP3: connected!" ); 220 qDebug( "POP3: connected!" );
221 221
222 // login 222 // login
223 // TODO: decide if apop or plain login should be used 223 // TODO: decide if apop or plain login should be used
224 err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); 224 err = mailpop3_login( m_pop3, (char *) user, (char *) pass );
225 if ( err != MAILPOP3_NO_ERROR ) { 225 if ( err != MAILPOP3_NO_ERROR ) {
226 qDebug( "pop3: error logging in: %s", m_pop3->response ); 226 qDebug( "pop3: error logging in: %s", m_pop3->pop3_response );
227 logout(); 227 logout();
228 return; 228 return;
229 } 229 }
230 230
231 qDebug( "POP3: logged in!" ); 231 qDebug( "POP3: logged in!" );
232} 232}
233 233
234void POP3wrapper::logout() 234void POP3wrapper::logout()
235{ 235{
236 int err = MAILPOP3_NO_ERROR; 236 int err = MAILPOP3_NO_ERROR;
237 if ( m_pop3 == NULL ) return; 237 if ( m_pop3 == NULL ) return;
238 err = mailpop3_quit( m_pop3 ); 238 err = mailpop3_quit( m_pop3 );
239 mailpop3_free( m_pop3 ); 239 mailpop3_free( m_pop3 );
240 m_pop3 = NULL; 240 m_pop3 = NULL;
241} 241}
242 242
243 243
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index a8937fb..4e4abad 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -1,34 +1,35 @@
1#ifndef __POP3WRAPPER 1#ifndef __POP3WRAPPER
2#define __POP3WRAPPER 2#define __POP3WRAPPER
3 3
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5 5
6class RecMail; 6class RecMail;
7struct mailpop3;
7 8
8class POP3wrapper : public QObject 9class POP3wrapper : public QObject
9{ 10{
10 Q_OBJECT 11 Q_OBJECT
11 12
12public: 13public:
13 POP3wrapper( POP3account *a ); 14 POP3wrapper( POP3account *a );
14 virtual ~POP3wrapper(); 15 virtual ~POP3wrapper();
15 void listMessages( QList<RecMail> &target ); 16 void listMessages( QList<RecMail> &target );
16 static void pop3_progress( size_t current, size_t maximum ); 17 static void pop3_progress( size_t current, size_t maximum );
17 18
18protected: 19protected:
19 void login(); 20 void login();
20 void logout(); 21 void logout();
21 22
22private: 23private:
23 RecMail *parseHeader( const char *header ); 24 RecMail *parseHeader( const char *header );
24 QString *parseMailboxList( mailimf_mailbox_list *list ); 25 QString *parseMailboxList( mailimf_mailbox_list *list );
25 QString *parseMailbox( mailimf_mailbox *box ); 26 QString *parseMailbox( mailimf_mailbox *box );
26 QString *parseGroup( mailimf_group *group ); 27 QString *parseGroup( mailimf_group *group );
27 QString *parseAddressList( mailimf_address_list *list ); 28 QString *parseAddressList( mailimf_address_list *list );
28 QString *parseDateTime( mailimf_date_time *date ); 29 QString *parseDateTime( mailimf_date_time *date );
29 POP3account *account; 30 POP3account *account;
30 mailpop3 *m_pop3; 31 mailpop3 *m_pop3;
31 32
32}; 33};
33 34
34#endif 35#endif
diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp
index 898e9d6..3ffc274 100644
--- a/noncore/net/mail/mailwrapper.cpp
+++ b/noncore/net/mail/mailwrapper.cpp
@@ -104,526 +104,526 @@ mailimf_address_list *MailWrapper::parseAddresses(const QString&addr )
104 QStringList::Iterator it; 104 QStringList::Iterator it;
105 for ( it = list.begin(); it != list.end(); it++ ) { 105 for ( it = list.begin(); it != list.end(); it++ ) {
106 char *str = strdup( (*it).latin1() ); 106 char *str = strdup( (*it).latin1() );
107 int err = mailimf_address_list_add_parse( addresses, str ); 107 int err = mailimf_address_list_add_parse( addresses, str );
108 if ( err != MAILIMF_NO_ERROR ) { 108 if ( err != MAILIMF_NO_ERROR ) {
109 qDebug( "Error parsing" ); 109 qDebug( "Error parsing" );
110 qDebug( *it ); 110 qDebug( *it );
111 free( str ); 111 free( str );
112 } else { 112 } else {
113 qDebug( "Parse success! :)" ); 113 qDebug( "Parse success! :)" );
114 } 114 }
115 } 115 }
116 116
117 return addresses; 117 return addresses;
118} 118}
119 119
120mailimf_fields *MailWrapper::createImfFields( Mail *mail ) 120mailimf_fields *MailWrapper::createImfFields( Mail *mail )
121{ 121{
122 mailimf_fields *fields; 122 mailimf_fields *fields;
123 mailimf_field *xmailer; 123 mailimf_field *xmailer;
124 mailimf_mailbox *sender, *fromBox; 124 mailimf_mailbox *sender, *fromBox;
125 mailimf_mailbox_list *from; 125 mailimf_mailbox_list *from;
126 mailimf_address_list *to, *cc, *bcc, *reply; 126 mailimf_address_list *to, *cc, *bcc, *reply;
127 char *subject = strdup( mail->getSubject().latin1() ); 127 char *subject = strdup( mail->getSubject().latin1() );
128 int err; 128 int err;
129 129
130 sender = newMailbox( mail->getName(), mail->getMail() ); 130 sender = newMailbox( mail->getName(), mail->getMail() );
131 if ( sender == NULL ) goto err_free; 131 if ( sender == NULL ) goto err_free;
132 132
133 fromBox = newMailbox( mail->getName(), mail->getMail() ); 133 fromBox = newMailbox( mail->getName(), mail->getMail() );
134 if ( fromBox == NULL ) goto err_free_sender; 134 if ( fromBox == NULL ) goto err_free_sender;
135 135
136 from = mailimf_mailbox_list_new_empty(); 136 from = mailimf_mailbox_list_new_empty();
137 if ( from == NULL ) goto err_free_fromBox; 137 if ( from == NULL ) goto err_free_fromBox;
138 138
139 err = mailimf_mailbox_list_add( from, fromBox ); 139 err = mailimf_mailbox_list_add( from, fromBox );
140 if ( err != MAILIMF_NO_ERROR ) goto err_free_from; 140 if ( err != MAILIMF_NO_ERROR ) goto err_free_from;
141 141
142 to = parseAddresses( mail->getTo() ); 142 to = parseAddresses( mail->getTo() );
143 if ( to == NULL ) goto err_free_from; 143 if ( to == NULL ) goto err_free_from;
144 144
145 cc = parseAddresses( mail->getCC() ); 145 cc = parseAddresses( mail->getCC() );
146 bcc = parseAddresses( mail->getBCC() ); 146 bcc = parseAddresses( mail->getBCC() );
147 reply = parseAddresses( mail->getReply() ); 147 reply = parseAddresses( mail->getReply() );
148 148
149 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, 149 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc,
150 NULL, NULL, subject ); 150 NULL, NULL, subject );
151 if ( fields == NULL ) goto err_free_reply; 151 if ( fields == NULL ) goto err_free_reply;
152 152
153 xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), 153 xmailer = mailimf_field_new_custom( strdup( "User-Agent" ),
154 strdup( USER_AGENT ) ); 154 strdup( USER_AGENT ) );
155 if ( xmailer == NULL ) goto err_free_fields; 155 if ( xmailer == NULL ) goto err_free_fields;
156 156
157 err = mailimf_fields_add( fields, xmailer ); 157 err = mailimf_fields_add( fields, xmailer );
158 if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer; 158 if ( err != MAILIMF_NO_ERROR ) goto err_free_xmailer;
159 159
160 return fields; // Success :) 160 return fields; // Success :)
161 161
162err_free_xmailer: 162err_free_xmailer:
163 mailimf_field_free( xmailer ); 163 mailimf_field_free( xmailer );
164err_free_fields: 164err_free_fields:
165 mailimf_fields_free( fields ); 165 mailimf_fields_free( fields );
166err_free_reply: 166err_free_reply:
167 mailimf_address_list_free( reply ); 167 mailimf_address_list_free( reply );
168 mailimf_address_list_free( bcc ); 168 mailimf_address_list_free( bcc );
169 mailimf_address_list_free( cc ); 169 mailimf_address_list_free( cc );
170 mailimf_address_list_free( to ); 170 mailimf_address_list_free( to );
171err_free_from: 171err_free_from:
172 mailimf_mailbox_list_free( from ); 172 mailimf_mailbox_list_free( from );
173err_free_fromBox: 173err_free_fromBox:
174 mailimf_mailbox_free( fromBox ); 174 mailimf_mailbox_free( fromBox );
175err_free_sender: 175err_free_sender:
176 mailimf_mailbox_free( sender ); 176 mailimf_mailbox_free( sender );
177err_free: 177err_free:
178 free( subject ); 178 free( subject );
179 qDebug( "createImfFields - error" ); 179 qDebug( "createImfFields - error" );
180 180
181 return NULL; // Error :( 181 return NULL; // Error :(
182} 182}
183 183
184mailmime *MailWrapper::buildTxtPart( QString str ) 184mailmime *MailWrapper::buildTxtPart( QString str )
185{ 185{
186 mailmime *txtPart; 186 mailmime *txtPart;
187 mailmime_fields *fields; 187 mailmime_fields *fields;
188 mailmime_content *content; 188 mailmime_content *content;
189 mailmime_parameter *param; 189 mailmime_parameter *param;
190 char *txt = strdup( str.latin1() ); 190 char *txt = strdup( str.latin1() );
191 int err; 191 int err;
192 192
193 param = mailmime_parameter_new( strdup( "charset" ), 193 param = mailmime_parameter_new( strdup( "charset" ),
194 strdup( "iso-8859-1" ) ); 194 strdup( "iso-8859-1" ) );
195 if ( param == NULL ) goto err_free; 195 if ( param == NULL ) goto err_free;
196 196
197 content = mailmime_content_new_with_str( "text/plain" ); 197 content = mailmime_content_new_with_str( "text/plain" );
198 if ( content == NULL ) goto err_free_param; 198 if ( content == NULL ) goto err_free_param;
199 199
200 err = clist_append( content->parameters, param ); 200 err = clist_append( content->ct_parameters, param );
201 if ( err != MAILIMF_NO_ERROR ) goto err_free_content; 201 if ( err != MAILIMF_NO_ERROR ) goto err_free_content;
202 202
203 fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT ); 203 fields = mailmime_fields_new_encoding( MAILMIME_MECHANISM_8BIT );
204 if ( fields == NULL ) goto err_free_content; 204 if ( fields == NULL ) goto err_free_content;
205 205
206 txtPart = mailmime_new_empty( content, fields ); 206 txtPart = mailmime_new_empty( content, fields );
207 if ( txtPart == NULL ) goto err_free_fields; 207 if ( txtPart == NULL ) goto err_free_fields;
208 208
209 err = mailmime_set_body_text( txtPart, txt, strlen( txt ) ); 209 err = mailmime_set_body_text( txtPart, txt, strlen( txt ) );
210 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; 210 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart;
211 211
212 return txtPart; // Success :) 212 return txtPart; // Success :)
213 213
214err_free_txtPart: 214err_free_txtPart:
215 mailmime_free( txtPart ); 215 mailmime_free( txtPart );
216err_free_fields: 216err_free_fields:
217 mailmime_fields_free( fields ); 217 mailmime_fields_free( fields );
218err_free_content: 218err_free_content:
219 mailmime_content_free( content ); 219 mailmime_content_free( content );
220err_free_param: 220err_free_param:
221 mailmime_parameter_free( param ); 221 mailmime_parameter_free( param );
222err_free: 222err_free:
223 free( txt ); 223 free( txt );
224 qDebug( "buildTxtPart - error" ); 224 qDebug( "buildTxtPart - error" );
225 225
226 return NULL; // Error :( 226 return NULL; // Error :(
227} 227}
228 228
229mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype ) 229mailmime *MailWrapper::buildFilePart( QString filename, QString mimetype )
230{ 230{
231 mailmime * filePart; 231 mailmime * filePart;
232 mailmime_fields * fields; 232 mailmime_fields * fields;
233 mailmime_content * content; 233 mailmime_content * content;
234 mailmime_parameter * param = NULL; 234 mailmime_parameter * param = NULL;
235 int err; 235 int err;
236 236
237 int pos = filename.findRev( '/' ); 237 int pos = filename.findRev( '/' );
238 QString tmp = filename.right( filename.length() - ( pos + 1 ) ); 238 QString tmp = filename.right( filename.length() - ( pos + 1 ) );
239 char *name = strdup( tmp.latin1() ); // just filename 239 char *name = strdup( tmp.latin1() ); // just filename
240 char *file = strdup( filename.latin1() ); // full name with path 240 char *file = strdup( filename.latin1() ); // full name with path
241 char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain 241 char *mime = strdup( mimetype.latin1() ); // mimetype -e.g. text/plain
242 242
243 fields = mailmime_fields_new_filename( 243 fields = mailmime_fields_new_filename(
244 MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name, 244 MAILMIME_DISPOSITION_TYPE_ATTACHMENT, name,
245 MAILMIME_MECHANISM_BASE64 ); 245 MAILMIME_MECHANISM_BASE64 );
246 if ( fields == NULL ) goto err_free; 246 if ( fields == NULL ) goto err_free;
247 247
248 content = mailmime_content_new_with_str( mime ); 248 content = mailmime_content_new_with_str( mime );
249 if ( content == NULL ) goto err_free_fields; 249 if ( content == NULL ) goto err_free_fields;
250 250
251 if ( mimetype.compare( "text/plain" ) == 0 ) { 251 if ( mimetype.compare( "text/plain" ) == 0 ) {
252 param = mailmime_parameter_new( strdup( "charset" ), 252 param = mailmime_parameter_new( strdup( "charset" ),
253 strdup( "iso-8859-1" ) ); 253 strdup( "iso-8859-1" ) );
254 if ( param == NULL ) goto err_free_content; 254 if ( param == NULL ) goto err_free_content;
255 255
256 err = clist_append( content->parameters, param ); 256 err = clist_append( content->ct_parameters, param );
257 if ( err != MAILIMF_NO_ERROR ) goto err_free_param; 257 if ( err != MAILIMF_NO_ERROR ) goto err_free_param;
258 } 258 }
259 259
260 filePart = mailmime_new_empty( content, fields ); 260 filePart = mailmime_new_empty( content, fields );
261 if ( filePart == NULL ) goto err_free_param; 261 if ( filePart == NULL ) goto err_free_param;
262 262
263 err = mailmime_set_body_file( filePart, file ); 263 err = mailmime_set_body_file( filePart, file );
264 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; 264 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart;
265 265
266 return filePart; // Success :) 266 return filePart; // Success :)
267 267
268err_free_filePart: 268err_free_filePart:
269 mailmime_free( filePart ); 269 mailmime_free( filePart );
270err_free_param: 270err_free_param:
271 if ( param != NULL ) mailmime_parameter_free( param ); 271 if ( param != NULL ) mailmime_parameter_free( param );
272err_free_content: 272err_free_content:
273 mailmime_content_free( content ); 273 mailmime_content_free( content );
274err_free_fields: 274err_free_fields:
275 mailmime_fields_free( fields ); 275 mailmime_fields_free( fields );
276err_free: 276err_free:
277 free( name ); 277 free( name );
278 free( mime ); 278 free( mime );
279 free( file ); 279 free( file );
280 qDebug( "buildFilePart - error" ); 280 qDebug( "buildFilePart - error" );
281 281
282 return NULL; // Error :( 282 return NULL; // Error :(
283} 283}
284 284
285void MailWrapper::addFileParts( mailmime *message, QList<Attachment> files ) 285void MailWrapper::addFileParts( mailmime *message, QList<Attachment> files )
286{ 286{
287 Attachment *it; 287 Attachment *it;
288 for ( it = files.first(); it; it = files.next() ) { 288 for ( it = files.first(); it; it = files.next() ) {
289 qDebug( "Adding file" ); 289 qDebug( "Adding file" );
290 mailmime *filePart; 290 mailmime *filePart;
291 int err; 291 int err;
292 292
293 filePart = buildFilePart( it->getFileName(), it->getMimeType() ); 293 filePart = buildFilePart( it->getFileName(), it->getMimeType() );
294 if ( filePart == NULL ) goto err_free; 294 if ( filePart == NULL ) goto err_free;
295 295
296 err = mailmime_smart_add_part( message, filePart ); 296 err = mailmime_smart_add_part( message, filePart );
297 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart; 297 if ( err != MAILIMF_NO_ERROR ) goto err_free_filePart;
298 298
299 continue; // Success :) 299 continue; // Success :)
300 300
301 err_free_filePart: 301 err_free_filePart:
302 mailmime_free( filePart ); 302 mailmime_free( filePart );
303 err_free: 303 err_free:
304 qDebug( "addFileParts: error adding file:" ); 304 qDebug( "addFileParts: error adding file:" );
305 qDebug( it->getFileName() ); 305 qDebug( it->getFileName() );
306 } 306 }
307} 307}
308 308
309mailmime *MailWrapper::createMimeMail( Mail *mail ) 309mailmime *MailWrapper::createMimeMail( Mail *mail )
310{ 310{
311 mailmime *message, *txtPart; 311 mailmime *message, *txtPart;
312 mailimf_fields *fields; 312 mailimf_fields *fields;
313 int err; 313 int err;
314 314
315 fields = createImfFields( mail ); 315 fields = createImfFields( mail );
316 if ( fields == NULL ) goto err_free; 316 if ( fields == NULL ) goto err_free;
317 317
318 message = mailmime_new_message_data( NULL ); 318 message = mailmime_new_message_data( NULL );
319 if ( message == NULL ) goto err_free_fields; 319 if ( message == NULL ) goto err_free_fields;
320 320
321 mailmime_set_imf_fields( message, fields ); 321 mailmime_set_imf_fields( message, fields );
322 322
323 txtPart = buildTxtPart( mail->getMessage() ); 323 txtPart = buildTxtPart( mail->getMessage() );
324 if ( txtPart == NULL ) goto err_free_message; 324 if ( txtPart == NULL ) goto err_free_message;
325 325
326 err = mailmime_smart_add_part( message, txtPart ); 326 err = mailmime_smart_add_part( message, txtPart );
327 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; 327 if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart;
328 328
329 addFileParts( message, mail->getAttachments() ); 329 addFileParts( message, mail->getAttachments() );
330 330
331 return message; // Success :) 331 return message; // Success :)
332 332
333err_free_txtPart: 333err_free_txtPart:
334 mailmime_free( txtPart ); 334 mailmime_free( txtPart );
335err_free_message: 335err_free_message:
336 mailmime_free( message ); 336 mailmime_free( message );
337err_free_fields: 337err_free_fields:
338 mailimf_fields_free( fields ); 338 mailimf_fields_free( fields );
339err_free: 339err_free:
340 qDebug( "createMimeMail: error" ); 340 qDebug( "createMimeMail: error" );
341 341
342 return NULL; // Error :( 342 return NULL; // Error :(
343} 343}
344 344
345mailimf_field *MailWrapper::getField( mailimf_fields *fields, int type ) 345mailimf_field *MailWrapper::getField( mailimf_fields *fields, int type )
346{ 346{
347 mailimf_field *field; 347 mailimf_field *field;
348 clistiter *it; 348 clistiter *it;
349 349
350 it = clist_begin( fields->list ); 350 it = clist_begin( fields->fld_list );
351 while ( it ) { 351 while ( it ) {
352 field = (mailimf_field *) it->data; 352 field = (mailimf_field *) it->data;
353 if ( field->type == type ) { 353 if ( field->fld_type == type ) {
354 return field; 354 return field;
355 } 355 }
356 it = it->next; 356 it = it->next;
357 } 357 }
358 358
359 return NULL; 359 return NULL;
360} 360}
361 361
362static void addRcpts( clist *list, mailimf_address_list *addr_list ) 362static void addRcpts( clist *list, mailimf_address_list *addr_list )
363{ 363{
364 clistiter *it, *it2; 364 clistiter *it, *it2;
365 365
366 for ( it = clist_begin( addr_list->list ); it; it = it->next ) { 366 for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) {
367 mailimf_address *addr; 367 mailimf_address *addr;
368 addr = (mailimf_address *) it->data; 368 addr = (mailimf_address *) it->data;
369 369
370 if ( addr->type == MAILIMF_ADDRESS_MAILBOX ) { 370 if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) {
371 esmtp_address_list_add( list, addr->mailbox->addr_spec, 0, NULL ); 371 esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL );
372 } else if ( addr->type == MAILIMF_ADDRESS_GROUP ) { 372 } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) {
373 clist *l = addr->group->mb_list->list; 373 clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list;
374 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { 374 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) {
375 mailimf_mailbox *mbox; 375 mailimf_mailbox *mbox;
376 mbox = (mailimf_mailbox *) it2->data; 376 mbox = (mailimf_mailbox *) it2->data;
377 esmtp_address_list_add( list, mbox->addr_spec, 0, NULL ); 377 esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL );
378 } 378 }
379 } 379 }
380 } 380 }
381} 381}
382 382
383clist *MailWrapper::createRcptList( mailimf_fields *fields ) 383clist *MailWrapper::createRcptList( mailimf_fields *fields )
384{ 384{
385 clist *rcptList; 385 clist *rcptList;
386 mailimf_field *field; 386 mailimf_field *field;
387 387
388 rcptList = esmtp_address_list_new(); 388 rcptList = esmtp_address_list_new();
389 389
390 field = getField( fields, MAILIMF_FIELD_TO ); 390 field = getField( fields, MAILIMF_FIELD_TO );
391 if ( field && (field->type == MAILIMF_FIELD_TO) 391 if ( field && (field->fld_type == MAILIMF_FIELD_TO)
392 && field->field.to->addr_list ) { 392 && field->fld_data.fld_to->to_addr_list ) {
393 addRcpts( rcptList, field->field.to->addr_list ); 393 addRcpts( rcptList, field->fld_data.fld_to->to_addr_list );
394 } 394 }
395 395
396 field = getField( fields, MAILIMF_FIELD_CC ); 396 field = getField( fields, MAILIMF_FIELD_CC );
397 if ( field && (field->type == MAILIMF_FIELD_CC) 397 if ( field && (field->fld_type == MAILIMF_FIELD_CC)
398 && field->field.cc->addr_list ) { 398 && field->fld_data.fld_cc->cc_addr_list ) {
399 addRcpts( rcptList, field->field.cc->addr_list ); 399 addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list );
400 } 400 }
401 401
402 field = getField( fields, MAILIMF_FIELD_BCC ); 402 field = getField( fields, MAILIMF_FIELD_BCC );
403 if ( field && (field->type == MAILIMF_FIELD_BCC) 403 if ( field && (field->fld_type == MAILIMF_FIELD_BCC)
404 && field->field.bcc->addr_list ) { 404 && field->fld_data.fld_bcc->bcc_addr_list ) {
405 addRcpts( rcptList, field->field.bcc->addr_list ); 405 addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list );
406 } 406 }
407 407
408 return rcptList; 408 return rcptList;
409} 409}
410 410
411char *MailWrapper::getFrom( mailmime *mail ) 411char *MailWrapper::getFrom( mailmime *mail )
412{ 412{
413 char *from = NULL; 413 char *from = NULL;
414 414
415 mailimf_field *ffrom; 415 mailimf_field *ffrom;
416 ffrom = getField( mail->fields, MAILIMF_FIELD_FROM ); 416 ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM );
417 if ( ffrom && (ffrom->type == MAILIMF_FIELD_FROM) 417 if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM)
418 && ffrom->field.from->mb_list && ffrom->field.from->mb_list->list ) { 418 && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) {
419 clist *cl = ffrom->field.from->mb_list->list; 419 clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list;
420 clistiter *it; 420 clistiter *it;
421 for ( it = clist_begin( cl ); it; it = it->next ) { 421 for ( it = clist_begin( cl ); it; it = it->next ) {
422 mailimf_mailbox *mb = (mailimf_mailbox *) it->data; 422 mailimf_mailbox *mb = (mailimf_mailbox *) it->data;
423 from = strdup( mb->addr_spec ); 423 from = strdup( mb->mb_addr_spec );
424 } 424 }
425 } 425 }
426 426
427 return from; 427 return from;
428} 428}
429 429
430SMTPaccount *MailWrapper::getAccount( QString from ) 430SMTPaccount *MailWrapper::getAccount( QString from )
431{ 431{
432 SMTPaccount *smtp; 432 SMTPaccount *smtp;
433 433
434 QList<Account> list = settings->getAccounts(); 434 QList<Account> list = settings->getAccounts();
435 Account *it; 435 Account *it;
436 for ( it = list.first(); it; it = list.next() ) { 436 for ( it = list.first(); it; it = list.next() ) {
437 if ( it->getType().compare( "SMTP" ) == 0 ) { 437 if ( it->getType().compare( "SMTP" ) == 0 ) {
438 smtp = static_cast<SMTPaccount *>(it); 438 smtp = static_cast<SMTPaccount *>(it);
439 if ( smtp->getMail().compare( from ) == 0 ) { 439 if ( smtp->getMail().compare( from ) == 0 ) {
440 qDebug( "SMTPaccount found for" ); 440 qDebug( "SMTPaccount found for" );
441 qDebug( from ); 441 qDebug( from );
442 return smtp; 442 return smtp;
443 } 443 }
444 } 444 }
445 } 445 }
446 446
447 return NULL; 447 return NULL;
448} 448}
449 449
450QString MailWrapper::getTmpFile() { 450QString MailWrapper::getTmpFile() {
451 int num = 0; 451 int num = 0;
452 QString unique; 452 QString unique;
453 453
454 QDir dir( "/tmp" ); 454 QDir dir( "/tmp" );
455 QStringList::Iterator it; 455 QStringList::Iterator it;
456 456
457 QStringList list = dir.entryList( "opiemail-tmp-*" ); 457 QStringList list = dir.entryList( "opiemail-tmp-*" );
458 do { 458 do {
459 unique.setNum( num++ ); 459 unique.setNum( num++ );
460 } while ( list.contains( "opiemail-tmp-" + unique ) > 0 ); 460 } while ( list.contains( "opiemail-tmp-" + unique ) > 0 );
461 461
462 return "/tmp/opiemail-tmp-" + unique; 462 return "/tmp/opiemail-tmp-" + unique;
463} 463}
464 464
465void MailWrapper::writeToFile( QString file, mailmime *mail ) 465void MailWrapper::writeToFile( QString file, mailmime *mail )
466{ 466{
467 FILE *f; 467 FILE *f;
468 int err, col = 0; 468 int err, col = 0;
469 469
470 f = fopen( file.latin1(), "w" ); 470 f = fopen( file.latin1(), "w" );
471 if ( f == NULL ) { 471 if ( f == NULL ) {
472 qDebug( "writeToFile: error opening file" ); 472 qDebug( "writeToFile: error opening file" );
473 return; 473 return;
474 } 474 }
475 475
476 err = mailmime_write( f, &col, mail ); 476 err = mailmime_write( f, &col, mail );
477 if ( err != MAILIMF_NO_ERROR ) { 477 if ( err != MAILIMF_NO_ERROR ) {
478 fclose( f ); 478 fclose( f );
479 qDebug( "writeToFile: error writing mailmime" ); 479 qDebug( "writeToFile: error writing mailmime" );
480 return; 480 return;
481 } 481 }
482 482
483 fclose( f ); 483 fclose( f );
484} 484}
485 485
486void MailWrapper::readFromFile( QString file, char **data, size_t *size ) 486void MailWrapper::readFromFile( QString file, char **data, size_t *size )
487{ 487{
488 char *buf; 488 char *buf;
489 struct stat st; 489 struct stat st;
490 int fd, count = 0, total = 0; 490 int fd, count = 0, total = 0;
491 491
492 fd = open( file.latin1(), O_RDONLY, 0 ); 492 fd = open( file.latin1(), O_RDONLY, 0 );
493 if ( fd == -1 ) return; 493 if ( fd == -1 ) return;
494 494
495 if ( fstat( fd, &st ) != 0 ) goto err_close; 495 if ( fstat( fd, &st ) != 0 ) goto err_close;
496 if ( !st.st_size ) goto err_close; 496 if ( !st.st_size ) goto err_close;
497 497
498 buf = (char *) malloc( st.st_size ); 498 buf = (char *) malloc( st.st_size );
499 if ( !buf ) goto err_close; 499 if ( !buf ) goto err_close;
500 500
501 while ( ( total < st.st_size ) && ( count >= 0 ) ) { 501 while ( ( total < st.st_size ) && ( count >= 0 ) ) {
502 count = read( fd, buf + total, st.st_size - total ); 502 count = read( fd, buf + total, st.st_size - total );
503 total += count; 503 total += count;
504 } 504 }
505 if ( count < 0 ) goto err_free; 505 if ( count < 0 ) goto err_free;
506 506
507 *data = buf; 507 *data = buf;
508 *size = st.st_size; 508 *size = st.st_size;
509 509
510 close( fd ); 510 close( fd );
511 511
512 return; // Success :) 512 return; // Success :)
513 513
514err_free: 514err_free:
515 free( buf ); 515 free( buf );
516err_close: 516err_close:
517 close( fd ); 517 close( fd );
518} 518}
519 519
520void progress( size_t current, size_t maximum ) 520void progress( size_t current, size_t maximum )
521{ 521{
522 qDebug( "Current: %i of %i", current, maximum ); 522 qDebug( "Current: %i of %i", current, maximum );
523} 523}
524 524
525void MailWrapper::smtpSend( mailmime *mail ) 525void MailWrapper::smtpSend( mailmime *mail )
526{ 526{
527 mailsmtp *session; 527 mailsmtp *session;
528 clist *rcpts; 528 clist *rcpts;
529 char *from, *data, *server, *user = NULL, *pass = NULL; 529 char *from, *data, *server, *user = NULL, *pass = NULL;
530 size_t size; 530 size_t size;
531 int err; 531 int err;
532 bool ssl; 532 bool ssl;
533 uint16_t port; 533 uint16_t port;
534 534
535 535
536 from = getFrom( mail ); 536 from = getFrom( mail );
537 SMTPaccount *smtp = getAccount( from ); 537 SMTPaccount *smtp = getAccount( from );
538 if ( smtp == NULL ) { 538 if ( smtp == NULL ) {
539 free(from); 539 free(from);
540 return; 540 return;
541 } 541 }
542 server = strdup( smtp->getServer().latin1() ); 542 server = strdup( smtp->getServer().latin1() );
543 ssl = smtp->getSSL(); 543 ssl = smtp->getSSL();
544 port = smtp->getPort().toUInt(); 544 port = smtp->getPort().toUInt();
545 rcpts = createRcptList( mail->fields ); 545 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
546 546
547 QString file = getTmpFile(); 547 QString file = getTmpFile();
548 writeToFile( file, mail ); 548 writeToFile( file, mail );
549 readFromFile( file, &data, &size ); 549 readFromFile( file, &data, &size );
550 QFile f( file ); 550 QFile f( file );
551 f.remove(); 551 f.remove();
552 552
553 session = mailsmtp_new( 20, &progress ); 553 session = mailsmtp_new( 20, &progress );
554 if ( session == NULL ) goto free_mem; 554 if ( session == NULL ) goto free_mem;
555 555
556 qDebug( "Servername %s at port %i", server, port ); 556 qDebug( "Servername %s at port %i", server, port );
557 if ( ssl ) { 557 if ( ssl ) {
558 qDebug( "SSL session" ); 558 qDebug( "SSL session" );
559 err = mailsmtp_ssl_connect( session, server, port ); 559 err = mailsmtp_ssl_connect( session, server, port );
560 } else { 560 } else {
561 qDebug( "No SSL session" ); 561 qDebug( "No SSL session" );
562 err = mailsmtp_socket_connect( session, server, port ); 562 err = mailsmtp_socket_connect( session, server, port );
563 } 563 }
564 if ( err != MAILSMTP_NO_ERROR ) goto free_mem_session; 564 if ( err != MAILSMTP_NO_ERROR ) goto free_mem_session;
565 565
566 err = mailsmtp_init( session ); 566 err = mailsmtp_init( session );
567 if ( err != MAILSMTP_NO_ERROR ) goto free_con_session; 567 if ( err != MAILSMTP_NO_ERROR ) goto free_con_session;
568 568
569 qDebug( "INIT OK" ); 569 qDebug( "INIT OK" );
570 570
571 if ( smtp->getLogin() ) { 571 if ( smtp->getLogin() ) {
572 if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) { 572 if ( smtp->getUser().isEmpty() || smtp->getPassword().isEmpty() ) {
573 // get'em 573 // get'em
574 LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true ); 574 LoginDialog login( smtp->getUser(), smtp->getPassword(), NULL, 0, true );
575 login.show(); 575 login.show();
576 if ( QDialog::Accepted == login.exec() ) { 576 if ( QDialog::Accepted == login.exec() ) {
577 // ok 577 // ok
578 user = strdup( login.getUser().latin1() ); 578 user = strdup( login.getUser().latin1() );
579 pass = strdup( login.getPassword().latin1() ); 579 pass = strdup( login.getPassword().latin1() );
580 } else { 580 } else {
581 goto free_con_session; 581 goto free_con_session;
582 } 582 }
583 } else { 583 } else {
584 user = strdup( smtp->getUser().latin1() ); 584 user = strdup( smtp->getUser().latin1() );
585 pass = strdup( smtp->getPassword().latin1() ); 585 pass = strdup( smtp->getPassword().latin1() );
586 } 586 }
587 qDebug( "session->auth: %i", session->auth); 587 qDebug( "session->auth: %i", session->auth);
588 err = mailsmtp_auth( session, user, pass ); 588 err = mailsmtp_auth( session, user, pass );
589 if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok"); 589 if ( err == MAILSMTP_NO_ERROR ) qDebug("auth ok");
590 qDebug( "Done auth!" ); 590 qDebug( "Done auth!" );
591 } 591 }
592 592
593 err = mailsmtp_send( session, from, rcpts, data, size ); 593 err = mailsmtp_send( session, from, rcpts, data, size );
594 if ( err != MAILSMTP_NO_ERROR ) goto free_con_session; 594 if ( err != MAILSMTP_NO_ERROR ) goto free_con_session;
595 595
596 qDebug( "Mail sent." ); 596 qDebug( "Mail sent." );
597 597
598free_con_session: 598free_con_session:
599 mailsmtp_quit( session ); 599 mailsmtp_quit( session );
600free_mem_session: 600free_mem_session:
601 mailsmtp_free( session ); 601 mailsmtp_free( session );
602free_mem: 602free_mem:
603 smtp_address_list_free( rcpts ); 603 smtp_address_list_free( rcpts );
604 free( data ); 604 free( data );
605 free( server ); 605 free( server );
606 if ( smtp->getLogin() ) { 606 if ( smtp->getLogin() ) {
607 free( user ); 607 free( user );
608 free( pass ); 608 free( pass );
609 } 609 }
610 free( from ); 610 free( from );
611} 611}
612 612
613void MailWrapper::sendMail( Mail mail ) 613void MailWrapper::sendMail( Mail mail )
614{ 614{
615 mailmime *mimeMail; 615 mailmime *mimeMail;
616 616
617 mimeMail = createMimeMail( &mail ); 617 mimeMail = createMimeMail( &mail );
618 if ( mimeMail == NULL ) { 618 if ( mimeMail == NULL ) {
619 qDebug( "sendMail: error creating mime mail" ); 619 qDebug( "sendMail: error creating mime mail" );
620 } else { 620 } else {
621 smtpSend( mimeMail ); 621 smtpSend( mimeMail );
622 mailmime_free( mimeMail ); 622 mailmime_free( mimeMail );
623 } 623 }
624} 624}
625 625
626Mail::Mail() 626Mail::Mail()
627 :name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") 627 :name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("")
628{ 628{
629} 629}
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp
index 72f3c36..633faf6 100644
--- a/noncore/net/mail/pop3wrapper.cpp
+++ b/noncore/net/mail/pop3wrapper.cpp
@@ -1,243 +1,243 @@
1 1
2#include "pop3wrapper.h" 2#include "pop3wrapper.h"
3#include "mailtypes.h" 3#include "mailtypes.h"
4#include <libetpan/mailpop3.h> 4#include <libetpan/mailpop3.h>
5 5
6POP3wrapper::POP3wrapper( POP3account *a ) 6POP3wrapper::POP3wrapper( POP3account *a )
7{ 7{
8 account = a; 8 account = a;
9 m_pop3 = NULL; 9 m_pop3 = NULL;
10} 10}
11 11
12POP3wrapper::~POP3wrapper() 12POP3wrapper::~POP3wrapper()
13{ 13{
14 logout(); 14 logout();
15} 15}
16 16
17void POP3wrapper::pop3_progress( size_t current, size_t maximum ) 17void POP3wrapper::pop3_progress( size_t current, size_t maximum )
18{ 18{
19 qDebug( "POP3: %i of %i", current, maximum ); 19 qDebug( "POP3: %i of %i", current, maximum );
20} 20}
21 21
22void POP3wrapper::listMessages( QList<RecMail> &target ) 22void POP3wrapper::listMessages( QList<RecMail> &target )
23{ 23{
24 int err = MAILPOP3_NO_ERROR; 24 int err = MAILPOP3_NO_ERROR;
25 char *header; 25 char *header;
26 size_t length; 26 size_t length;
27 carray *messages; 27 carray *messages;
28 28
29 login(); 29 login();
30 if (!m_pop3) return; 30 if (!m_pop3) return;
31 mailpop3_list( m_pop3, &messages ); 31 mailpop3_list( m_pop3, &messages );
32 32
33 for ( int i = carray_count( messages ); i > 0; i-- ) { 33 for ( int i = carray_count( messages ); i > 0; i-- ) {
34 mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 ); 34 mailpop3_msg_info *info = (mailpop3_msg_info *) carray_get( messages, i - 1 );
35 35
36 err = mailpop3_header( m_pop3, info->index, &header, &length ); 36 err = mailpop3_header( m_pop3, info->msg_index, &header, &length );
37 if ( err != MAILPOP3_NO_ERROR ) { 37 if ( err != MAILPOP3_NO_ERROR ) {
38 qDebug( "POP3: error retrieving header msgid: %i", info->index ); 38 qDebug( "POP3: error retrieving header msgid: %i", info->msg_index );
39 logout(); 39 logout();
40 return; 40 return;
41 } 41 }
42 RecMail *mail = parseHeader( header ); 42 RecMail *mail = parseHeader( header );
43 mail->setNumber( info->index ); 43 mail->setNumber( info->msg_index );
44 target.append( mail ); 44 target.append( mail );
45 } 45 }
46 46
47 logout(); 47 logout();
48} 48}
49 49
50RecMail *POP3wrapper::parseHeader( const char *header ) 50RecMail *POP3wrapper::parseHeader( const char *header )
51{ 51{
52 int err = MAILIMF_NO_ERROR; 52 int err = MAILIMF_NO_ERROR;
53 size_t curTok; 53 size_t curTok;
54 RecMail *mail = new RecMail(); 54 RecMail *mail = new RecMail();
55 mailimf_fields *fields; 55 mailimf_fields *fields;
56 56
57 err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); 57 err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields );
58 for ( clistiter *current = clist_begin( fields->list ); current != NULL; current = current->next ) { 58 for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) {
59 mailimf_field *field = (mailimf_field *) current->data; 59 mailimf_field *field = (mailimf_field *) current->data;
60 switch ( field->type ) { 60 switch ( field->fld_type ) {
61 case MAILIMF_FIELD_FROM: 61 case MAILIMF_FIELD_FROM:
62 mail->setFrom( *parseMailboxList( field->field.from->mb_list ) ); 62 mail->setFrom( *parseMailboxList( field->fld_data.fld_from->frm_mb_list ) );
63 break; 63 break;
64 case MAILIMF_FIELD_TO: 64 case MAILIMF_FIELD_TO:
65 mail->setTo( *parseAddressList( field->field.to->addr_list ) ); 65 mail->setTo( *parseAddressList( field->fld_data.fld_to->to_addr_list ) );
66 break; 66 break;
67 case MAILIMF_FIELD_CC: 67 case MAILIMF_FIELD_CC:
68 mail->setCC( *parseAddressList( field->field.cc->addr_list ) ); 68 mail->setCC( *parseAddressList( field->fld_data.fld_cc->cc_addr_list ) );
69 break; 69 break;
70 case MAILIMF_FIELD_BCC: 70 case MAILIMF_FIELD_BCC:
71 mail->setBcc( *parseAddressList( field->field.bcc->addr_list ) ); 71 mail->setBcc( *parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) );
72 break; 72 break;
73 case MAILIMF_FIELD_SUBJECT: 73 case MAILIMF_FIELD_SUBJECT:
74 mail->setSubject( QString( field->field.subject->value ) ); 74 mail->setSubject( QString( field->fld_data.fld_subject->sbj_value ) );
75 break; 75 break;
76 case MAILIMF_FIELD_ORIG_DATE: 76 case MAILIMF_FIELD_ORIG_DATE:
77 mail->setDate( *parseDateTime( field->field.orig_date->date_time ) ); 77 mail->setDate( *parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) );
78 break; 78 break;
79 default: 79 default:
80 break; 80 break;
81 } 81 }
82 } 82 }
83 83
84 return mail; 84 return mail;
85} 85}
86 86
87QString *POP3wrapper::parseDateTime( mailimf_date_time *date ) 87QString *POP3wrapper::parseDateTime( mailimf_date_time *date )
88{ 88{
89 char tmp[23]; 89 char tmp[23];
90 90
91 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", 91 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
92 date->day, date->month, date->year, date->hour, date->min, date->sec, date->zone ); 92 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
93 93
94 QString *result = new QString( tmp ); 94 QString *result = new QString( tmp );
95 95
96 return result; 96 return result;
97} 97}
98 98
99QString *POP3wrapper::parseAddressList( mailimf_address_list *list ) 99QString *POP3wrapper::parseAddressList( mailimf_address_list *list )
100{ 100{
101 QString *result = new QString( "" ); 101 QString *result = new QString( "" );
102 102
103 bool first = true; 103 bool first = true;
104 for ( clistiter *current = clist_begin( list->list ); current != NULL; current = current->next ) { 104 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
105 mailimf_address *addr = (mailimf_address *) current->data; 105 mailimf_address *addr = (mailimf_address *) current->data;
106 106
107 if ( !first ) { 107 if ( !first ) {
108 result->append( "," ); 108 result->append( "," );
109 } else { 109 } else {
110 first = false; 110 first = false;
111 } 111 }
112 112
113 QString *tmp; 113 QString *tmp;
114 114
115 switch ( addr->type ) { 115 switch ( addr->ad_type ) {
116 case MAILIMF_ADDRESS_MAILBOX: 116 case MAILIMF_ADDRESS_MAILBOX:
117 tmp = parseMailbox( addr->mailbox ); 117 tmp = parseMailbox( addr->ad_data.ad_mailbox );
118 result->append( *tmp ); 118 result->append( *tmp );
119 delete tmp; 119 delete tmp;
120 break; 120 break;
121 case MAILIMF_ADDRESS_GROUP: 121 case MAILIMF_ADDRESS_GROUP:
122 tmp = parseGroup( addr->group ); 122 tmp = parseGroup( addr->ad_data.ad_group );
123 result->append( *tmp ); 123 result->append( *tmp );
124 delete tmp; 124 delete tmp;
125 break; 125 break;
126 default: 126 default:
127 qDebug( "POP3: unkown mailimf address type" ); 127 qDebug( "POP3: unkown mailimf address type" );
128 break; 128 break;
129 } 129 }
130 } 130 }
131 131
132 return result; 132 return result;
133} 133}
134 134
135QString *POP3wrapper::parseGroup( mailimf_group *group ) 135QString *POP3wrapper::parseGroup( mailimf_group *group )
136{ 136{
137 QString *result = new QString( "" ); 137 QString *result = new QString( "" );
138 138
139 result->append( group->display_name ); 139 result->append( group->grp_display_name );
140 result->append( ": " ); 140 result->append( ": " );
141 141
142 if ( group->mb_list != NULL ) { 142 if ( group->grp_mb_list != NULL ) {
143 QString *tmp = parseMailboxList( group->mb_list ); 143 QString *tmp = parseMailboxList( group->grp_mb_list );
144 result->append( *tmp ); 144 result->append( *tmp );
145 delete tmp; 145 delete tmp;
146 } 146 }
147 147
148 result->append( ";" ); 148 result->append( ";" );
149 149
150 return result; 150 return result;
151} 151}
152 152
153QString *POP3wrapper::parseMailbox( mailimf_mailbox *box ) 153QString *POP3wrapper::parseMailbox( mailimf_mailbox *box )
154{ 154{
155 QString *result = new QString( "" ); 155 QString *result = new QString( "" );
156 156
157 if ( box->display_name == NULL ) { 157 if ( box->mb_display_name == NULL ) {
158 result->append( box->addr_spec ); 158 result->append( box->mb_addr_spec );
159 } else { 159 } else {
160 result->append( box->display_name ); 160 result->append( box->mb_display_name );
161 result->append( " <" ); 161 result->append( " <" );
162 result->append( box->addr_spec ); 162 result->append( box->mb_addr_spec );
163 result->append( ">" ); 163 result->append( ">" );
164 } 164 }
165 165
166 return result; 166 return result;
167} 167}
168 168
169QString *POP3wrapper::parseMailboxList( mailimf_mailbox_list *list ) 169QString *POP3wrapper::parseMailboxList( mailimf_mailbox_list *list )
170{ 170{
171 QString *result = new QString( "" ); 171 QString *result = new QString( "" );
172 172
173 bool first = true; 173 bool first = true;
174 for ( clistiter *current = clist_begin( list->list ); current != NULL; current = current->next ) { 174 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
175 mailimf_mailbox *box = (mailimf_mailbox *) current->data; 175 mailimf_mailbox *box = (mailimf_mailbox *) current->data;
176 176
177 if ( !first ) { 177 if ( !first ) {
178 result->append( "," ); 178 result->append( "," );
179 } else { 179 } else {
180 first = false; 180 first = false;
181 } 181 }
182 182
183 QString *tmp = parseMailbox( box ); 183 QString *tmp = parseMailbox( box );
184 result->append( *tmp ); 184 result->append( *tmp );
185 delete tmp; 185 delete tmp;
186 } 186 }
187 187
188 return result; 188 return result;
189} 189}
190 190
191void POP3wrapper::login() 191void POP3wrapper::login()
192{ 192{
193 if ( m_pop3 != NULL ) logout(); 193 if ( m_pop3 != NULL ) logout();
194 194
195 const char *server, *user, *pass; 195 const char *server, *user, *pass;
196 uint16_t port; 196 uint16_t port;
197 int err = MAILPOP3_NO_ERROR; 197 int err = MAILPOP3_NO_ERROR;
198 198
199 server = account->getServer().latin1(); 199 server = account->getServer().latin1();
200 port = account->getPort().toUInt(); 200 port = account->getPort().toUInt();
201 user = account->getUser().latin1(); 201 user = account->getUser().latin1();
202 pass = account->getPassword().latin1(); 202 pass = account->getPassword().latin1();
203 203
204 m_pop3 = mailpop3_new( 200, &pop3_progress ); 204 m_pop3 = mailpop3_new( 200, &pop3_progress );
205 205
206 // connect 206 // connect
207 if (account->getSSL()) { 207 if (account->getSSL()) {
208 err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); 208 err = mailpop3_ssl_connect( m_pop3, (char*)server, port );
209 } else { 209 } else {
210 err = mailpop3_socket_connect( m_pop3, (char*)server, port ); 210 err = mailpop3_socket_connect( m_pop3, (char*)server, port );
211 } 211 }
212 212
213 if ( err != MAILPOP3_NO_ERROR ) { 213 if ( err != MAILPOP3_NO_ERROR ) {
214 qDebug( "pop3: error connecting to %s\n reason: %s", server, 214 qDebug( "pop3: error connecting to %s\n reason: %s", server,
215 m_pop3->response ); 215 m_pop3->pop3_response );
216 mailpop3_free( m_pop3 ); 216 mailpop3_free( m_pop3 );
217 m_pop3 = NULL; 217 m_pop3 = NULL;
218 return; 218 return;
219 } 219 }
220 qDebug( "POP3: connected!" ); 220 qDebug( "POP3: connected!" );
221 221
222 // login 222 // login
223 // TODO: decide if apop or plain login should be used 223 // TODO: decide if apop or plain login should be used
224 err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); 224 err = mailpop3_login( m_pop3, (char *) user, (char *) pass );
225 if ( err != MAILPOP3_NO_ERROR ) { 225 if ( err != MAILPOP3_NO_ERROR ) {
226 qDebug( "pop3: error logging in: %s", m_pop3->response ); 226 qDebug( "pop3: error logging in: %s", m_pop3->pop3_response );
227 logout(); 227 logout();
228 return; 228 return;
229 } 229 }
230 230
231 qDebug( "POP3: logged in!" ); 231 qDebug( "POP3: logged in!" );
232} 232}
233 233
234void POP3wrapper::logout() 234void POP3wrapper::logout()
235{ 235{
236 int err = MAILPOP3_NO_ERROR; 236 int err = MAILPOP3_NO_ERROR;
237 if ( m_pop3 == NULL ) return; 237 if ( m_pop3 == NULL ) return;
238 err = mailpop3_quit( m_pop3 ); 238 err = mailpop3_quit( m_pop3 );
239 mailpop3_free( m_pop3 ); 239 mailpop3_free( m_pop3 );
240 m_pop3 = NULL; 240 m_pop3 = NULL;
241} 241}
242 242
243 243
diff --git a/noncore/net/mail/pop3wrapper.h b/noncore/net/mail/pop3wrapper.h
index a8937fb..4e4abad 100644
--- a/noncore/net/mail/pop3wrapper.h
+++ b/noncore/net/mail/pop3wrapper.h
@@ -1,34 +1,35 @@
1#ifndef __POP3WRAPPER 1#ifndef __POP3WRAPPER
2#define __POP3WRAPPER 2#define __POP3WRAPPER
3 3
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5 5
6class RecMail; 6class RecMail;
7struct mailpop3;
7 8
8class POP3wrapper : public QObject 9class POP3wrapper : public QObject
9{ 10{
10 Q_OBJECT 11 Q_OBJECT
11 12
12public: 13public:
13 POP3wrapper( POP3account *a ); 14 POP3wrapper( POP3account *a );
14 virtual ~POP3wrapper(); 15 virtual ~POP3wrapper();
15 void listMessages( QList<RecMail> &target ); 16 void listMessages( QList<RecMail> &target );
16 static void pop3_progress( size_t current, size_t maximum ); 17 static void pop3_progress( size_t current, size_t maximum );
17 18
18protected: 19protected:
19 void login(); 20 void login();
20 void logout(); 21 void logout();
21 22
22private: 23private:
23 RecMail *parseHeader( const char *header ); 24 RecMail *parseHeader( const char *header );
24 QString *parseMailboxList( mailimf_mailbox_list *list ); 25 QString *parseMailboxList( mailimf_mailbox_list *list );
25 QString *parseMailbox( mailimf_mailbox *box ); 26 QString *parseMailbox( mailimf_mailbox *box );
26 QString *parseGroup( mailimf_group *group ); 27 QString *parseGroup( mailimf_group *group );
27 QString *parseAddressList( mailimf_address_list *list ); 28 QString *parseAddressList( mailimf_address_list *list );
28 QString *parseDateTime( mailimf_date_time *date ); 29 QString *parseDateTime( mailimf_date_time *date );
29 POP3account *account; 30 POP3account *account;
30 mailpop3 *m_pop3; 31 mailpop3 *m_pop3;
31 32
32}; 33};
33 34
34#endif 35#endif