Diffstat (limited to 'noncore/net/mail/libmailwrapper/mboxwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/mboxwrapper.cpp | 72 |
1 files changed, 4 insertions, 68 deletions
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp index 162a0c9..0aa33dd 100644 --- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp | |||
@@ -26,95 +26,31 @@ void MBOXwrapper::listMessages(const QString & mailbox, QList<RecMail> &target ) | |||
26 | p+=mailbox; | 26 | p+=mailbox; |
27 | 27 | ||
28 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); | 28 | int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); |
29 | mailfolder*folder; | 29 | mailfolder*folder; |
30 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); | 30 | folder = mailfolder_new( storage,(char*)p.latin1(),NULL); |
31 | r = mailfolder_connect(folder); | 31 | r = mailfolder_connect(folder); |
32 | if (r != MAIL_NO_ERROR) { | 32 | if (r != MAIL_NO_ERROR) { |
33 | qDebug("Error initializing mbox"); | 33 | qDebug("Error initializing mbox"); |
34 | mailfolder_free(folder); | 34 | mailfolder_free(folder); |
35 | mailstorage_free(storage); | 35 | mailstorage_free(storage); |
36 | return; | 36 | return; |
37 | } | 37 | } |
38 | mailmessage_list * env_list = 0; | 38 | |
39 | r = mailsession_get_messages_list(folder->fld_session,&env_list); | 39 | parseList(target,folder->fld_session,mailbox); |
40 | if (r != MAIL_NO_ERROR) { | 40 | |
41 | qDebug("Error message list"); | ||
42 | mailfolder_free(folder); | ||
43 | mailstorage_free(storage); | ||
44 | return; | ||
45 | } | ||
46 | r = mailsession_get_envelopes_list(folder->fld_session, env_list); | ||
47 | if (r != MAIL_NO_ERROR) { | ||
48 | qDebug("Error filling message list"); | ||
49 | if (env_list) { | ||
50 | mailmessage_list_free(env_list); | ||
51 | } | ||
52 | mailfolder_free(folder); | ||
53 | mailstorage_free(storage); | ||
54 | return; | ||
55 | } | ||
56 | mailimf_references * refs; | ||
57 | |||
58 | uint32_t i = 0; | ||
59 | for(; i < carray_count(env_list->msg_tab) ; ++i) { | ||
60 | mailmessage * msg; | ||
61 | QBitArray mFlags(7); | ||
62 | msg = (mailmessage*)carray_get(env_list->msg_tab, i); | ||
63 | if (msg->msg_fields == NULL) { | ||
64 | qDebug("could not fetch envelope of message %i", i); | ||
65 | continue; | ||
66 | } | ||
67 | RecMail * mail = new RecMail(); | ||
68 | mail->setWrapper(this); | ||
69 | mail_flags * flag_result = 0; | ||
70 | r = mailmessage_get_flags(msg,&flag_result); | ||
71 | if (r == MAIL_ERROR_NOT_IMPLEMENTED) { | ||
72 | mFlags.setBit(FLAG_SEEN); | ||
73 | } | ||
74 | mailimf_single_fields single_fields; | ||
75 | mailimf_single_fields_init(&single_fields, msg->msg_fields); | ||
76 | mail->setMsgsize(msg->msg_size); | ||
77 | mail->setFlags(mFlags); | ||
78 | mail->setMbox(mailbox); | ||
79 | mail->setNumber(i+1); | ||
80 | if (single_fields.fld_subject) | ||
81 | mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); | ||
82 | if (single_fields.fld_from) | ||
83 | mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); | ||
84 | if (single_fields.fld_to) | ||
85 | mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); | ||
86 | if (single_fields.fld_cc) | ||
87 | mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); | ||
88 | if (single_fields.fld_bcc) | ||
89 | mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); | ||
90 | if (single_fields.fld_orig_date) | ||
91 | mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); | ||
92 | if (single_fields.fld_message_id->mid_value) | ||
93 | mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); | ||
94 | refs = single_fields.fld_references; | ||
95 | if (refs && refs->mid_list && clist_count(refs->mid_list)) { | ||
96 | char * text = (char*)refs->mid_list->first->data; | ||
97 | mail->setReplyto(QString(text)); | ||
98 | } | ||
99 | |||
100 | target.append(mail); | ||
101 | } | ||
102 | if (env_list) { | ||
103 | mailmessage_list_free(env_list); | ||
104 | } | ||
105 | mailfolder_disconnect(folder); | 41 | mailfolder_disconnect(folder); |
106 | mailfolder_free(folder); | 42 | mailfolder_free(folder); |
107 | mailstorage_free(storage); | 43 | mailstorage_free(storage); |
108 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(i)); | 44 | Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); |
109 | } | 45 | } |
110 | 46 | ||
111 | QList<Folder>* MBOXwrapper::listFolders() | 47 | QList<Folder>* MBOXwrapper::listFolders() |
112 | { | 48 | { |
113 | QList<Folder> * folders = new QList<Folder>(); | 49 | QList<Folder> * folders = new QList<Folder>(); |
114 | folders->setAutoDelete( false ); | 50 | folders->setAutoDelete( false ); |
115 | QDir dir(MBOXPath); | 51 | QDir dir(MBOXPath); |
116 | if (!dir.exists()) return folders; | 52 | if (!dir.exists()) return folders; |
117 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); | 53 | dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); |
118 | QStringList entries = dir.entryList(); | 54 | QStringList entries = dir.entryList(); |
119 | QStringList::ConstIterator it = entries.begin(); | 55 | QStringList::ConstIterator it = entries.begin(); |
120 | for (;it!=entries.end();++it) { | 56 | for (;it!=entries.end();++it) { |