| 510 | } |
| 511 | |
| 512 | Data * POPSession::fetchMessage(unsigned int index, POPProgressCallback * callback, ErrorCode * pError) |
| 513 | { |
| 514 | int r; |
| 515 | char * content; |
| 516 | size_t content_len; |
| 517 | |
| 518 | listIfNeeded(pError); |
| 519 | if (* pError != ErrorNone) { |
| 520 | return NULL; |
| 521 | } |
| 522 | |
| 523 | mProgressCallback = callback; |
| 524 | |
| 525 | r = mailpop3_retr(mPop, index, &content, &content_len); |
| 526 | mProgressCallback = NULL; |
| 527 | if (r == MAILPOP3_ERROR_STREAM) { |
| 528 | * pError = ErrorConnection; |
| 529 | return NULL; |
| 530 | } |
| 531 | else if (r != MAILPOP3_NO_ERROR) { |
| 532 | * pError = ErrorFetch; |
| 533 | return NULL; |
| 534 | } |
| 535 | |
| 536 | Data * result; |
| 537 | result = Data::dataWithBytes(content, (unsigned int) content_len); |
| 538 | mailpop3_retr_free(content); |
| 539 | * pError = ErrorNone; |
| 540 | |
| 541 | return result; |
| 542 | } |
| 543 | |
| 544 | Data * POPSession::fetchMessage(POPMessageInfo * msg, POPProgressCallback * callback, ErrorCode * pError) |
| 545 | { |