-rw-r--r-- | noncore/net/mail/accountview.cpp | 9 | ||||
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 14 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 14 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/pop3wrapper.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 2 |
7 files changed, 29 insertions, 16 deletions
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp index 847b099..d725b87 100644 --- a/noncore/net/mail/accountview.cpp +++ b/noncore/net/mail/accountview.cpp | |||
@@ -1,172 +1,177 @@ | |||
1 | #include "accountview.h" | 1 | #include "accountview.h" |
2 | #include "mailtypes.h" | 2 | #include "mailtypes.h" |
3 | #include "defines.h" | 3 | #include "defines.h" |
4 | 4 | ||
5 | 5 | ||
6 | /** | 6 | /** |
7 | * POP3 Account stuff | 7 | * POP3 Account stuff |
8 | */ | 8 | */ |
9 | 9 | ||
10 | POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) | 10 | POP3viewItem::POP3viewItem( POP3account *a, QListView *parent ) |
11 | : AccountViewItem( parent ) | 11 | : AccountViewItem( parent ) |
12 | { | 12 | { |
13 | account = a; | 13 | account = a; |
14 | wrapper = AbstractMail::getWrapper( account ); | 14 | wrapper = AbstractMail::getWrapper( account ); |
15 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 15 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
16 | setText( 0, account->getAccountName() ); | 16 | setText( 0, account->getAccountName() ); |
17 | } | 17 | } |
18 | 18 | ||
19 | POP3viewItem::~POP3viewItem() | 19 | POP3viewItem::~POP3viewItem() |
20 | { | 20 | { |
21 | delete wrapper; | 21 | delete wrapper; |
22 | } | 22 | } |
23 | 23 | ||
24 | void POP3viewItem::refresh( QList<RecMail> &target ) | 24 | void POP3viewItem::refresh( QList<RecMail> &target ) |
25 | { | 25 | { |
26 | qDebug( "POP3: refresh" ); | 26 | qDebug( "POP3: refresh" ); |
27 | wrapper->listMessages("INBOX", target ); | 27 | wrapper->listMessages("INBOX", target ); |
28 | } | 28 | } |
29 | 29 | ||
30 | 30 | ||
31 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) | 31 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) |
32 | { | 32 | { |
33 | qDebug( "POP3 fetchBody" ); | 33 | qDebug( "POP3 fetchBody" ); |
34 | return wrapper->fetchBody( mail ); | 34 | return wrapper->fetchBody( mail ); |
35 | } | 35 | } |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * IMAP Account stuff | 38 | * IMAP Account stuff |
39 | */ | 39 | */ |
40 | 40 | ||
41 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) | 41 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, QListView *parent ) |
42 | : AccountViewItem( parent ) | 42 | : AccountViewItem( parent ) |
43 | { | 43 | { |
44 | account = a; | 44 | account = a; |
45 | wrapper = AbstractMail::getWrapper( account ); | 45 | wrapper = AbstractMail::getWrapper( account ); |
46 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 46 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
47 | setText( 0, account->getAccountName() ); | 47 | setText( 0, account->getAccountName() ); |
48 | setOpen( true ); | 48 | setOpen( true ); |
49 | } | 49 | } |
50 | 50 | ||
51 | IMAPviewItem::~IMAPviewItem() | 51 | IMAPviewItem::~IMAPviewItem() |
52 | { | 52 | { |
53 | delete wrapper; | 53 | delete wrapper; |
54 | } | 54 | } |
55 | 55 | ||
56 | AbstractMail *IMAPviewItem::getWrapper() | 56 | AbstractMail *IMAPviewItem::getWrapper() |
57 | { | 57 | { |
58 | return wrapper; | 58 | return wrapper; |
59 | } | 59 | } |
60 | 60 | ||
61 | void IMAPviewItem::refresh(QList<RecMail>&) | 61 | void IMAPviewItem::refresh(QList<RecMail>&) |
62 | { | 62 | { |
63 | QList<Folder> *folders = wrapper->listFolders(); | 63 | QList<Folder> *folders = wrapper->listFolders(); |
64 | 64 | ||
65 | QListViewItem *child = firstChild(); | 65 | QListViewItem *child = firstChild(); |
66 | while ( child ) { | 66 | while ( child ) { |
67 | QListViewItem *tmp = child; | 67 | QListViewItem *tmp = child; |
68 | child = child->nextSibling(); | 68 | child = child->nextSibling(); |
69 | delete tmp; | 69 | delete tmp; |
70 | } | 70 | } |
71 | 71 | ||
72 | Folder *it; | 72 | Folder *it; |
73 | QListViewItem*item = 0; | 73 | QListViewItem*item = 0; |
74 | for ( it = folders->first(); it; it = folders->next() ) { | 74 | for ( it = folders->first(); it; it = folders->next() ) { |
75 | item = new IMAPfolderItem( it, this , item ); | 75 | item = new IMAPfolderItem( it, this , item ); |
76 | item->setSelectable(it->may_select()); | ||
76 | } | 77 | } |
78 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
79 | folders->setAutoDelete(false); | ||
80 | delete folders; | ||
77 | } | 81 | } |
78 | 82 | ||
79 | RecBody IMAPviewItem::fetchBody(const RecMail&) | 83 | RecBody IMAPviewItem::fetchBody(const RecMail&) |
80 | { | 84 | { |
81 | return RecBody(); | 85 | return RecBody(); |
82 | } | 86 | } |
83 | 87 | ||
84 | IMAPfolderItem::~IMAPfolderItem() | 88 | IMAPfolderItem::~IMAPfolderItem() |
85 | { | 89 | { |
86 | delete folder; | 90 | delete folder; |
87 | } | 91 | } |
88 | 92 | ||
89 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) | 93 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) |
90 | : AccountViewItem( parent,after ) | 94 | : AccountViewItem( parent,after ) |
91 | { | 95 | { |
92 | folder = folderInit; | 96 | folder = folderInit; |
93 | imap = parent; | 97 | imap = parent; |
94 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 98 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
95 | setText( 0, folder->getDisplayName() ); | 99 | setText( 0, folder->getDisplayName() ); |
96 | } | 100 | } |
97 | 101 | ||
98 | void IMAPfolderItem::refresh(QList<RecMail>&target) | 102 | void IMAPfolderItem::refresh(QList<RecMail>&target) |
99 | { | 103 | { |
100 | imap->getWrapper()->listMessages( folder->getName(),target ); | 104 | if (folder->may_select()) |
105 | imap->getWrapper()->listMessages( folder->getName(),target ); | ||
101 | } | 106 | } |
102 | 107 | ||
103 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | 108 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) |
104 | { | 109 | { |
105 | return imap->getWrapper()->fetchBody(aMail); | 110 | return imap->getWrapper()->fetchBody(aMail); |
106 | } | 111 | } |
107 | 112 | ||
108 | /** | 113 | /** |
109 | * Generic stuff | 114 | * Generic stuff |
110 | */ | 115 | */ |
111 | 116 | ||
112 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) | 117 | AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) |
113 | : QListView( parent, name, flags ) | 118 | : QListView( parent, name, flags ) |
114 | { | 119 | { |
115 | connect( this, SIGNAL( clicked( QListViewItem * ) ), | 120 | connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), |
116 | SLOT( refresh( QListViewItem * ) ) ); | 121 | SLOT( refresh( QListViewItem * ) ) ); |
117 | setSorting(-1); | 122 | setSorting(-1); |
118 | } | 123 | } |
119 | 124 | ||
120 | void AccountView::populate( QList<Account> list ) | 125 | void AccountView::populate( QList<Account> list ) |
121 | { | 126 | { |
122 | clear(); | 127 | clear(); |
123 | 128 | ||
124 | Account *it; | 129 | Account *it; |
125 | for ( it = list.first(); it; it = list.next() ) { | 130 | for ( it = list.first(); it; it = list.next() ) { |
126 | if ( it->getType().compare( "IMAP" ) == 0 ) { | 131 | if ( it->getType().compare( "IMAP" ) == 0 ) { |
127 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); | 132 | IMAPaccount *imap = static_cast<IMAPaccount *>(it); |
128 | qDebug( "added IMAP " + imap->getAccountName() ); | 133 | qDebug( "added IMAP " + imap->getAccountName() ); |
129 | (void) new IMAPviewItem( imap, this ); | 134 | (void) new IMAPviewItem( imap, this ); |
130 | } else if ( it->getType().compare( "POP3" ) == 0 ) { | 135 | } else if ( it->getType().compare( "POP3" ) == 0 ) { |
131 | POP3account *pop3 = static_cast<POP3account *>(it); | 136 | POP3account *pop3 = static_cast<POP3account *>(it); |
132 | qDebug( "added POP3 " + pop3->getAccountName() ); | 137 | qDebug( "added POP3 " + pop3->getAccountName() ); |
133 | (void) new POP3viewItem( pop3, this ); | 138 | (void) new POP3viewItem( pop3, this ); |
134 | } | 139 | } |
135 | } | 140 | } |
136 | } | 141 | } |
137 | 142 | ||
138 | void AccountView::refresh(QListViewItem *item) { | 143 | void AccountView::refresh(QListViewItem *item) { |
139 | 144 | ||
140 | qDebug("AccountView refresh..."); | 145 | qDebug("AccountView refresh..."); |
141 | if ( item ) { | 146 | if ( item ) { |
142 | m_currentItem = item; | 147 | m_currentItem = item; |
143 | QList<RecMail> headerlist; | 148 | QList<RecMail> headerlist; |
144 | headerlist.setAutoDelete(true); | 149 | headerlist.setAutoDelete(true); |
145 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 150 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
146 | view->refresh(headerlist); | 151 | view->refresh(headerlist); |
147 | emit refreshMailview(&headerlist); | 152 | emit refreshMailview(&headerlist); |
148 | } | 153 | } |
149 | } | 154 | } |
150 | 155 | ||
151 | void AccountView::refreshCurrent() | 156 | void AccountView::refreshCurrent() |
152 | { | 157 | { |
153 | if ( !m_currentItem ) return; | 158 | if ( !m_currentItem ) return; |
154 | QList<RecMail> headerlist; | 159 | QList<RecMail> headerlist; |
155 | headerlist.setAutoDelete(true); | 160 | headerlist.setAutoDelete(true); |
156 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); | 161 | AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); |
157 | view->refresh(headerlist); | 162 | view->refresh(headerlist); |
158 | emit refreshMailview(&headerlist); | 163 | emit refreshMailview(&headerlist); |
159 | } | 164 | } |
160 | 165 | ||
161 | void AccountView::refreshAll() | 166 | void AccountView::refreshAll() |
162 | { | 167 | { |
163 | 168 | ||
164 | } | 169 | } |
165 | 170 | ||
166 | RecBody AccountView::fetchBody(const RecMail&aMail) | 171 | RecBody AccountView::fetchBody(const RecMail&aMail) |
167 | { | 172 | { |
168 | QListViewItem*item = selectedItem (); | 173 | QListViewItem*item = selectedItem (); |
169 | if (!item) return RecBody(); | 174 | if (!item) return RecBody(); |
170 | AccountViewItem *view = static_cast<AccountViewItem *>(item); | 175 | AccountViewItem *view = static_cast<AccountViewItem *>(item); |
171 | return view->fetchBody(aMail); | 176 | return view->fetchBody(aMail); |
172 | } | 177 | } |
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index 9ee0dff..912a412 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp | |||
@@ -1,395 +1,399 @@ | |||
1 | 1 | ||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | #include "imapwrapper.h" | 4 | #include "imapwrapper.h" |
5 | #include "mailtypes.h" | 5 | #include "mailtypes.h" |
6 | #include <libetpan/mailimap.h> | 6 | #include <libetpan/mailimap.h> |
7 | 7 | ||
8 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 8 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
9 | : AbstractMail() | 9 | : AbstractMail() |
10 | { | 10 | { |
11 | account = a; | 11 | account = a; |
12 | m_imap = 0; | 12 | m_imap = 0; |
13 | } | 13 | } |
14 | 14 | ||
15 | IMAPwrapper::~IMAPwrapper() | 15 | IMAPwrapper::~IMAPwrapper() |
16 | { | 16 | { |
17 | logout(); | 17 | logout(); |
18 | } | 18 | } |
19 | 19 | ||
20 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 20 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
21 | { | 21 | { |
22 | qDebug( "IMAP: %i of %i", current, maximum ); | 22 | qDebug( "IMAP: %i of %i", current, maximum ); |
23 | } | 23 | } |
24 | 24 | ||
25 | void IMAPwrapper::login() | 25 | void IMAPwrapper::login() |
26 | { | 26 | { |
27 | const char *server, *user, *pass; | 27 | const char *server, *user, *pass; |
28 | uint16_t port; | 28 | uint16_t port; |
29 | int err = MAILIMAP_NO_ERROR; | 29 | int err = MAILIMAP_NO_ERROR; |
30 | 30 | ||
31 | /* we are connected this moment */ | 31 | /* we are connected this moment */ |
32 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 32 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
33 | if (m_imap) { | 33 | if (m_imap) { |
34 | mailstream_flush(m_imap->imap_stream); | 34 | mailstream_flush(m_imap->imap_stream); |
35 | return; | 35 | return; |
36 | } | 36 | } |
37 | server = account->getServer().latin1(); | 37 | server = account->getServer().latin1(); |
38 | port = account->getPort().toUInt(); | 38 | port = account->getPort().toUInt(); |
39 | user = account->getUser().latin1(); | 39 | user = account->getUser().latin1(); |
40 | pass = account->getPassword().latin1(); | 40 | pass = account->getPassword().latin1(); |
41 | 41 | ||
42 | m_imap = mailimap_new( 20, &imap_progress ); | 42 | m_imap = mailimap_new( 20, &imap_progress ); |
43 | /* connect */ | 43 | /* connect */ |
44 | if (account->getSSL()) { | 44 | if (account->getSSL()) { |
45 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); | 45 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); |
46 | } else { | 46 | } else { |
47 | err = mailimap_socket_connect( m_imap, (char*)server, port ); | 47 | err = mailimap_socket_connect( m_imap, (char*)server, port ); |
48 | } | 48 | } |
49 | 49 | ||
50 | if ( err != MAILIMAP_NO_ERROR && | 50 | if ( err != MAILIMAP_NO_ERROR && |
51 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 51 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
52 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 52 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
53 | qDebug("error connecting server: %s",m_imap->imap_response); | 53 | qDebug("error connecting server: %s",m_imap->imap_response); |
54 | mailimap_free( m_imap ); | 54 | mailimap_free( m_imap ); |
55 | m_imap = 0; | 55 | m_imap = 0; |
56 | return; | 56 | return; |
57 | } | 57 | } |
58 | 58 | ||
59 | /* login */ | 59 | /* login */ |
60 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 60 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
61 | if ( err != MAILIMAP_NO_ERROR ) { | 61 | if ( err != MAILIMAP_NO_ERROR ) { |
62 | qDebug("error logging in imap: %s",m_imap->imap_response); | 62 | qDebug("error logging in imap: %s",m_imap->imap_response); |
63 | err = mailimap_close( m_imap ); | 63 | err = mailimap_close( m_imap ); |
64 | mailimap_free( m_imap ); | 64 | mailimap_free( m_imap ); |
65 | m_imap = 0; | 65 | m_imap = 0; |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | void IMAPwrapper::logout() | 69 | void IMAPwrapper::logout() |
70 | { | 70 | { |
71 | int err = MAILIMAP_NO_ERROR; | 71 | int err = MAILIMAP_NO_ERROR; |
72 | if (!m_imap) return; | 72 | if (!m_imap) return; |
73 | err = mailimap_logout( m_imap ); | 73 | err = mailimap_logout( m_imap ); |
74 | err = mailimap_close( m_imap ); | 74 | err = mailimap_close( m_imap ); |
75 | mailimap_free( m_imap ); | 75 | mailimap_free( m_imap ); |
76 | m_imap = 0; | 76 | m_imap = 0; |
77 | } | 77 | } |
78 | 78 | ||
79 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | 79 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) |
80 | { | 80 | { |
81 | const char *mb; | 81 | const char *mb; |
82 | int err = MAILIMAP_NO_ERROR; | 82 | int err = MAILIMAP_NO_ERROR; |
83 | clist *result; | 83 | clist *result; |
84 | clistcell *current; | 84 | clistcell *current; |
85 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; | 85 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; |
86 | mailimap_fetch_type *fetchType; | 86 | mailimap_fetch_type *fetchType; |
87 | mailimap_set *set; | 87 | mailimap_set *set; |
88 | 88 | ||
89 | mb = mailbox.latin1(); | 89 | mb = mailbox.latin1(); |
90 | login(); | 90 | login(); |
91 | if (!m_imap) { | 91 | if (!m_imap) { |
92 | return; | 92 | return; |
93 | } | 93 | } |
94 | /* select mailbox READONLY for operations */ | 94 | /* select mailbox READONLY for operations */ |
95 | err = mailimap_examine( m_imap, (char*)mb); | 95 | err = mailimap_examine( m_imap, (char*)mb); |
96 | if ( err != MAILIMAP_NO_ERROR ) { | 96 | if ( err != MAILIMAP_NO_ERROR ) { |
97 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 97 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
98 | return; | 98 | return; |
99 | } | 99 | } |
100 | 100 | ||
101 | int last = m_imap->imap_selection_info->sel_exists; | 101 | int last = m_imap->imap_selection_info->sel_exists; |
102 | 102 | ||
103 | if (last == 0) { | 103 | if (last == 0) { |
104 | qDebug("mailbox has no mails"); | 104 | qDebug("mailbox has no mails"); |
105 | return; | 105 | return; |
106 | } | 106 | } |
107 | 107 | ||
108 | result = clist_new(); | 108 | result = clist_new(); |
109 | /* the range has to start at 1!!! not with 0!!!! */ | 109 | /* the range has to start at 1!!! not with 0!!!! */ |
110 | set = mailimap_set_new_interval( 1, last ); | 110 | set = mailimap_set_new_interval( 1, last ); |
111 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 111 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
112 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 112 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
113 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 113 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
114 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 114 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
115 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 115 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
116 | 116 | ||
117 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 117 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
118 | mailimap_set_free( set ); | 118 | mailimap_set_free( set ); |
119 | mailimap_fetch_type_free( fetchType ); | 119 | mailimap_fetch_type_free( fetchType ); |
120 | 120 | ||
121 | QString date,subject,from; | 121 | QString date,subject,from; |
122 | 122 | ||
123 | if ( err == MAILIMAP_NO_ERROR ) { | 123 | if ( err == MAILIMAP_NO_ERROR ) { |
124 | 124 | ||
125 | mailimap_msg_att * msg_att; | 125 | mailimap_msg_att * msg_att; |
126 | int i = 0; | 126 | int i = 0; |
127 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 127 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
128 | ++i; | 128 | ++i; |
129 | msg_att = (mailimap_msg_att*)current->data; | 129 | msg_att = (mailimap_msg_att*)current->data; |
130 | RecMail*m = parse_list_result(msg_att); | 130 | RecMail*m = parse_list_result(msg_att); |
131 | if (m) { | 131 | if (m) { |
132 | m->setNumber(i); | 132 | m->setNumber(i); |
133 | m->setMbox(mailbox); | 133 | m->setMbox(mailbox); |
134 | m->setWrapper(this); | 134 | m->setWrapper(this); |
135 | target.append(m); | 135 | target.append(m); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | } else { | 138 | } else { |
139 | qDebug("Error fetching headers: %s",m_imap->imap_response); | 139 | qDebug("Error fetching headers: %s",m_imap->imap_response); |
140 | } | 140 | } |
141 | mailimap_fetch_list_free(result); | 141 | mailimap_fetch_list_free(result); |
142 | } | 142 | } |
143 | 143 | ||
144 | QList<Folder>* IMAPwrapper::listFolders() | 144 | QList<Folder>* IMAPwrapper::listFolders() |
145 | { | 145 | { |
146 | const char *path, *mask; | 146 | const char *path, *mask; |
147 | int err = MAILIMAP_NO_ERROR; | 147 | int err = MAILIMAP_NO_ERROR; |
148 | clist *result; | 148 | clist *result; |
149 | clistcell *current; | 149 | clistcell *current; |
150 | 150 | ||
151 | QList<Folder> * folders = new QList<Folder>(); | 151 | QList<Folder> * folders = new QList<Folder>(); |
152 | folders->setAutoDelete( true ); | 152 | folders->setAutoDelete( false ); |
153 | login(); | 153 | login(); |
154 | if (!m_imap) { | 154 | if (!m_imap) { |
155 | return folders; | 155 | return folders; |
156 | } | 156 | } |
157 | 157 | ||
158 | /* | 158 | /* |
159 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 159 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
160 | * We must not forget to filter them out in next loop! | 160 | * We must not forget to filter them out in next loop! |
161 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 161 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
162 | */ | 162 | */ |
163 | QString temp; | 163 | QString temp; |
164 | mask = "INBOX" ; | 164 | mask = "INBOX" ; |
165 | result = clist_new(); | 165 | result = clist_new(); |
166 | mailimap_mailbox_list *list; | 166 | mailimap_mailbox_list *list; |
167 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 167 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
168 | if ( err == MAILIMAP_NO_ERROR ) { | 168 | if ( err == MAILIMAP_NO_ERROR ) { |
169 | current = result->first; | 169 | current = result->first; |
170 | for ( int i = result->count; i > 0; i-- ) { | 170 | for ( int i = result->count; i > 0; i-- ) { |
171 | list = (mailimap_mailbox_list *) current->data; | 171 | list = (mailimap_mailbox_list *) current->data; |
172 | // it is better use the deep copy mechanism of qt itself | 172 | // it is better use the deep copy mechanism of qt itself |
173 | // instead of using strdup! | 173 | // instead of using strdup! |
174 | temp = list->mb_name; | 174 | temp = list->mb_name; |
175 | folders->append( new IMAPFolder(temp)); | 175 | folders->append( new IMAPFolder(temp)); |
176 | current = current->next; | 176 | current = current->next; |
177 | } | 177 | } |
178 | } else { | 178 | } else { |
179 | qDebug("error fetching folders: %s",m_imap->imap_response); | 179 | qDebug("error fetching folders: %s",m_imap->imap_response); |
180 | } | 180 | } |
181 | mailimap_list_result_free( result ); | 181 | mailimap_list_result_free( result ); |
182 | 182 | ||
183 | /* | 183 | /* |
184 | * second stage - get the other then inbox folders | 184 | * second stage - get the other then inbox folders |
185 | */ | 185 | */ |
186 | mask = "*" ; | 186 | mask = "*" ; |
187 | path = account->getPrefix().latin1(); | 187 | path = account->getPrefix().latin1(); |
188 | if (!path) path = ""; | 188 | if (!path) path = ""; |
189 | result = clist_new(); | 189 | result = clist_new(); |
190 | qDebug(path); | 190 | qDebug(path); |
191 | bool selectable = true; | ||
192 | mailimap_mbx_list_flags*bflags; | ||
191 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 193 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
192 | if ( err == MAILIMAP_NO_ERROR ) { | 194 | if ( err == MAILIMAP_NO_ERROR ) { |
193 | current = result->first; | 195 | current = result->first; |
194 | for ( int i = result->count; i > 0; i-- ) { | 196 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
195 | list = (mailimap_mailbox_list *) current->data; | 197 | list = (mailimap_mailbox_list *) current->data; |
196 | // it is better use the deep copy mechanism of qt itself | 198 | // it is better use the deep copy mechanism of qt itself |
197 | // instead of using strdup! | 199 | // instead of using strdup! |
198 | temp = list->mb_name; | 200 | temp = list->mb_name; |
199 | current = current->next; | ||
200 | if (temp.lower()=="inbox") | 201 | if (temp.lower()=="inbox") |
201 | continue; | 202 | continue; |
202 | folders->append(new IMAPFolder(temp)); | 203 | if ( (bflags = list->mb_flag) ) { |
203 | 204 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | |
205 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | ||
206 | } | ||
207 | folders->append(new IMAPFolder(temp,selectable)); | ||
204 | } | 208 | } |
205 | } else { | 209 | } else { |
206 | qDebug("error fetching folders %s",m_imap->imap_response); | 210 | qDebug("error fetching folders %s",m_imap->imap_response); |
207 | } | 211 | } |
208 | mailimap_list_result_free( result ); | 212 | mailimap_list_result_free( result ); |
209 | return folders; | 213 | return folders; |
210 | } | 214 | } |
211 | 215 | ||
212 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 216 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
213 | { | 217 | { |
214 | RecMail * m = 0; | 218 | RecMail * m = 0; |
215 | mailimap_msg_att_item *item=0; | 219 | mailimap_msg_att_item *item=0; |
216 | clistcell *current,*c,*cf; | 220 | clistcell *current,*c,*cf; |
217 | mailimap_msg_att_dynamic*flist; | 221 | mailimap_msg_att_dynamic*flist; |
218 | mailimap_flag_fetch*cflag; | 222 | mailimap_flag_fetch*cflag; |
219 | int size; | 223 | int size; |
220 | QBitArray mFlags(7); | 224 | QBitArray mFlags(7); |
221 | QStringList addresslist; | 225 | QStringList addresslist; |
222 | 226 | ||
223 | if (!m_att) { | 227 | if (!m_att) { |
224 | return m; | 228 | return m; |
225 | } | 229 | } |
226 | m = new RecMail(); | 230 | m = new RecMail(); |
227 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 231 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
228 | current = c; | 232 | current = c; |
229 | size = 0; | 233 | size = 0; |
230 | item = (mailimap_msg_att_item*)current->data; | 234 | item = (mailimap_msg_att_item*)current->data; |
231 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 235 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
232 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 236 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
233 | if (!flist->att_list) { | 237 | if (!flist->att_list) { |
234 | continue; | 238 | continue; |
235 | } | 239 | } |
236 | cf = flist->att_list->first; | 240 | cf = flist->att_list->first; |
237 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 241 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
238 | cflag = (mailimap_flag_fetch*)cf->data; | 242 | cflag = (mailimap_flag_fetch*)cf->data; |
239 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 243 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
240 | switch (cflag->fl_flag->fl_type) { | 244 | switch (cflag->fl_flag->fl_type) { |
241 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 245 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
242 | mFlags.setBit(FLAG_ANSWERED); | 246 | mFlags.setBit(FLAG_ANSWERED); |
243 | break; | 247 | break; |
244 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 248 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
245 | mFlags.setBit(FLAG_FLAGGED); | 249 | mFlags.setBit(FLAG_FLAGGED); |
246 | break; | 250 | break; |
247 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 251 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
248 | mFlags.setBit(FLAG_DELETED); | 252 | mFlags.setBit(FLAG_DELETED); |
249 | break; | 253 | break; |
250 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 254 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
251 | mFlags.setBit(FLAG_SEEN); | 255 | mFlags.setBit(FLAG_SEEN); |
252 | break; | 256 | break; |
253 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 257 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
254 | mFlags.setBit(FLAG_DRAFT); | 258 | mFlags.setBit(FLAG_DRAFT); |
255 | break; | 259 | break; |
256 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 260 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
257 | break; | 261 | break; |
258 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 262 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
259 | break; | 263 | break; |
260 | default: | 264 | default: |
261 | break; | 265 | break; |
262 | } | 266 | } |
263 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 267 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
264 | mFlags.setBit(FLAG_RECENT); | 268 | mFlags.setBit(FLAG_RECENT); |
265 | } | 269 | } |
266 | } | 270 | } |
267 | continue; | 271 | continue; |
268 | } | 272 | } |
269 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 273 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
270 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 274 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
271 | m->setDate(head->env_date); | 275 | m->setDate(head->env_date); |
272 | m->setSubject(head->env_subject); | 276 | m->setSubject(head->env_subject); |
273 | if (head->env_from!=NULL) { | 277 | if (head->env_from!=NULL) { |
274 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 278 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
275 | if (addresslist.count()) { | 279 | if (addresslist.count()) { |
276 | m->setFrom(addresslist.first()); | 280 | m->setFrom(addresslist.first()); |
277 | } | 281 | } |
278 | } | 282 | } |
279 | if (head->env_to!=NULL) { | 283 | if (head->env_to!=NULL) { |
280 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 284 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
281 | m->setTo(addresslist); | 285 | m->setTo(addresslist); |
282 | } | 286 | } |
283 | if (head->env_cc!=NULL) { | 287 | if (head->env_cc!=NULL) { |
284 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 288 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
285 | m->setCC(addresslist); | 289 | m->setCC(addresslist); |
286 | } | 290 | } |
287 | if (head->env_bcc!=NULL) { | 291 | if (head->env_bcc!=NULL) { |
288 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 292 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
289 | m->setBcc(addresslist); | 293 | m->setBcc(addresslist); |
290 | } | 294 | } |
291 | if (head->env_reply_to!=NULL) { | 295 | if (head->env_reply_to!=NULL) { |
292 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 296 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
293 | if (addresslist.count()) { | 297 | if (addresslist.count()) { |
294 | m->setReplyto(addresslist.first()); | 298 | m->setReplyto(addresslist.first()); |
295 | } | 299 | } |
296 | } | 300 | } |
297 | m->setMsgid(QString(head->env_message_id)); | 301 | m->setMsgid(QString(head->env_message_id)); |
298 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 302 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
299 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 303 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
300 | #if 0 | 304 | #if 0 |
301 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 305 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
302 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); | 306 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); |
303 | qDebug(da.toString()); | 307 | qDebug(da.toString()); |
304 | #endif | 308 | #endif |
305 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 309 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
306 | size = item->att_data.att_static->att_data.att_rfc822_size; | 310 | size = item->att_data.att_static->att_data.att_rfc822_size; |
307 | } | 311 | } |
308 | } | 312 | } |
309 | /* msg is already deleted */ | 313 | /* msg is already deleted */ |
310 | if (mFlags.testBit(FLAG_DELETED) && m) { | 314 | if (mFlags.testBit(FLAG_DELETED) && m) { |
311 | delete m; | 315 | delete m; |
312 | m = 0; | 316 | m = 0; |
313 | } | 317 | } |
314 | if (m) { | 318 | if (m) { |
315 | m->setFlags(mFlags); | 319 | m->setFlags(mFlags); |
316 | m->setMsgsize(size); | 320 | m->setMsgsize(size); |
317 | } | 321 | } |
318 | return m; | 322 | return m; |
319 | } | 323 | } |
320 | 324 | ||
321 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) | 325 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) |
322 | { | 326 | { |
323 | RecBody body; | 327 | RecBody body; |
324 | const char *mb; | 328 | const char *mb; |
325 | int err = MAILIMAP_NO_ERROR; | 329 | int err = MAILIMAP_NO_ERROR; |
326 | clist *result; | 330 | clist *result; |
327 | clistcell *current; | 331 | clistcell *current; |
328 | mailimap_fetch_att *fetchAtt; | 332 | mailimap_fetch_att *fetchAtt; |
329 | mailimap_fetch_type *fetchType; | 333 | mailimap_fetch_type *fetchType; |
330 | mailimap_set *set; | 334 | mailimap_set *set; |
331 | mailimap_body*body_desc; | 335 | mailimap_body*body_desc; |
332 | 336 | ||
333 | mb = mail.getMbox().latin1(); | 337 | mb = mail.getMbox().latin1(); |
334 | 338 | ||
335 | login(); | 339 | login(); |
336 | if (!m_imap) { | 340 | if (!m_imap) { |
337 | return body; | 341 | return body; |
338 | } | 342 | } |
339 | 343 | ||
340 | err = mailimap_select( m_imap, (char*)mb); | 344 | err = mailimap_select( m_imap, (char*)mb); |
341 | if ( err != MAILIMAP_NO_ERROR ) { | 345 | if ( err != MAILIMAP_NO_ERROR ) { |
342 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 346 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
343 | return body; | 347 | return body; |
344 | } | 348 | } |
345 | 349 | ||
346 | result = clist_new(); | 350 | result = clist_new(); |
347 | /* the range has to start at 1!!! not with 0!!!! */ | 351 | /* the range has to start at 1!!! not with 0!!!! */ |
348 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | 352 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); |
349 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 353 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
350 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 354 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
351 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 355 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
352 | mailimap_set_free( set ); | 356 | mailimap_set_free( set ); |
353 | mailimap_fetch_type_free( fetchType ); | 357 | mailimap_fetch_type_free( fetchType ); |
354 | 358 | ||
355 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 359 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
356 | mailimap_msg_att * msg_att; | 360 | mailimap_msg_att * msg_att; |
357 | msg_att = (mailimap_msg_att*)current->data; | 361 | msg_att = (mailimap_msg_att*)current->data; |
358 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 362 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
359 | body_desc = item->att_data.att_static->att_data.att_body; | 363 | body_desc = item->att_data.att_static->att_data.att_body; |
360 | if (body_desc->bd_type==MAILIMAP_BODY_1PART) { | 364 | if (body_desc->bd_type==MAILIMAP_BODY_1PART) { |
361 | searchBodyText(mail,body_desc->bd_data.bd_body_1part,body); | 365 | searchBodyText(mail,body_desc->bd_data.bd_body_1part,body); |
362 | } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) { | 366 | } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) { |
363 | qDebug("Mulitpart mail"); | 367 | qDebug("Mulitpart mail"); |
364 | searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); | 368 | searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); |
365 | } | 369 | } |
366 | } else { | 370 | } else { |
367 | qDebug("error fetching body: %s",m_imap->imap_response); | 371 | qDebug("error fetching body: %s",m_imap->imap_response); |
368 | } | 372 | } |
369 | mailimap_fetch_list_free(result); | 373 | mailimap_fetch_list_free(result); |
370 | return body; | 374 | return body; |
371 | } | 375 | } |
372 | 376 | ||
373 | /* this routine is just called when the mail has only ONE part. | 377 | /* this routine is just called when the mail has only ONE part. |
374 | for filling the parts of a multi-part-message there are other | 378 | for filling the parts of a multi-part-message there are other |
375 | routines 'cause we can not simply fetch the whole body. */ | 379 | routines 'cause we can not simply fetch the whole body. */ |
376 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) | 380 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) |
377 | { | 381 | { |
378 | if (!mailDescription) { | 382 | if (!mailDescription) { |
379 | return; | 383 | return; |
380 | } | 384 | } |
381 | QString sub,body_text; | 385 | QString sub,body_text; |
382 | RecPart singlePart; | 386 | RecPart singlePart; |
383 | QValueList<int> path; | 387 | QValueList<int> path; |
384 | fillSinglePart(singlePart,mailDescription); | 388 | fillSinglePart(singlePart,mailDescription); |
385 | switch (mailDescription->bd_type) { | 389 | switch (mailDescription->bd_type) { |
386 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 390 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
387 | path.append(1); | 391 | path.append(1); |
388 | body_text = fetchPart(mail,path,true); | 392 | body_text = fetchPart(mail,path,true); |
389 | target_body.setBodytext(body_text); | 393 | target_body.setBodytext(body_text); |
390 | target_body.setDescription(singlePart); | 394 | target_body.setDescription(singlePart); |
391 | break; | 395 | break; |
392 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 396 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
393 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); | 397 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); |
394 | path.append(1); | 398 | path.append(1); |
395 | body_text = fetchPart(mail,path,true); | 399 | body_text = fetchPart(mail,path,true); |
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 9ee0dff..912a412 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,395 +1,399 @@ | |||
1 | 1 | ||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | #include "imapwrapper.h" | 4 | #include "imapwrapper.h" |
5 | #include "mailtypes.h" | 5 | #include "mailtypes.h" |
6 | #include <libetpan/mailimap.h> | 6 | #include <libetpan/mailimap.h> |
7 | 7 | ||
8 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 8 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
9 | : AbstractMail() | 9 | : AbstractMail() |
10 | { | 10 | { |
11 | account = a; | 11 | account = a; |
12 | m_imap = 0; | 12 | m_imap = 0; |
13 | } | 13 | } |
14 | 14 | ||
15 | IMAPwrapper::~IMAPwrapper() | 15 | IMAPwrapper::~IMAPwrapper() |
16 | { | 16 | { |
17 | logout(); | 17 | logout(); |
18 | } | 18 | } |
19 | 19 | ||
20 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 20 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
21 | { | 21 | { |
22 | qDebug( "IMAP: %i of %i", current, maximum ); | 22 | qDebug( "IMAP: %i of %i", current, maximum ); |
23 | } | 23 | } |
24 | 24 | ||
25 | void IMAPwrapper::login() | 25 | void IMAPwrapper::login() |
26 | { | 26 | { |
27 | const char *server, *user, *pass; | 27 | const char *server, *user, *pass; |
28 | uint16_t port; | 28 | uint16_t port; |
29 | int err = MAILIMAP_NO_ERROR; | 29 | int err = MAILIMAP_NO_ERROR; |
30 | 30 | ||
31 | /* we are connected this moment */ | 31 | /* we are connected this moment */ |
32 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 32 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
33 | if (m_imap) { | 33 | if (m_imap) { |
34 | mailstream_flush(m_imap->imap_stream); | 34 | mailstream_flush(m_imap->imap_stream); |
35 | return; | 35 | return; |
36 | } | 36 | } |
37 | server = account->getServer().latin1(); | 37 | server = account->getServer().latin1(); |
38 | port = account->getPort().toUInt(); | 38 | port = account->getPort().toUInt(); |
39 | user = account->getUser().latin1(); | 39 | user = account->getUser().latin1(); |
40 | pass = account->getPassword().latin1(); | 40 | pass = account->getPassword().latin1(); |
41 | 41 | ||
42 | m_imap = mailimap_new( 20, &imap_progress ); | 42 | m_imap = mailimap_new( 20, &imap_progress ); |
43 | /* connect */ | 43 | /* connect */ |
44 | if (account->getSSL()) { | 44 | if (account->getSSL()) { |
45 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); | 45 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); |
46 | } else { | 46 | } else { |
47 | err = mailimap_socket_connect( m_imap, (char*)server, port ); | 47 | err = mailimap_socket_connect( m_imap, (char*)server, port ); |
48 | } | 48 | } |
49 | 49 | ||
50 | if ( err != MAILIMAP_NO_ERROR && | 50 | if ( err != MAILIMAP_NO_ERROR && |
51 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 51 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
52 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 52 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
53 | qDebug("error connecting server: %s",m_imap->imap_response); | 53 | qDebug("error connecting server: %s",m_imap->imap_response); |
54 | mailimap_free( m_imap ); | 54 | mailimap_free( m_imap ); |
55 | m_imap = 0; | 55 | m_imap = 0; |
56 | return; | 56 | return; |
57 | } | 57 | } |
58 | 58 | ||
59 | /* login */ | 59 | /* login */ |
60 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); | 60 | err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); |
61 | if ( err != MAILIMAP_NO_ERROR ) { | 61 | if ( err != MAILIMAP_NO_ERROR ) { |
62 | qDebug("error logging in imap: %s",m_imap->imap_response); | 62 | qDebug("error logging in imap: %s",m_imap->imap_response); |
63 | err = mailimap_close( m_imap ); | 63 | err = mailimap_close( m_imap ); |
64 | mailimap_free( m_imap ); | 64 | mailimap_free( m_imap ); |
65 | m_imap = 0; | 65 | m_imap = 0; |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | void IMAPwrapper::logout() | 69 | void IMAPwrapper::logout() |
70 | { | 70 | { |
71 | int err = MAILIMAP_NO_ERROR; | 71 | int err = MAILIMAP_NO_ERROR; |
72 | if (!m_imap) return; | 72 | if (!m_imap) return; |
73 | err = mailimap_logout( m_imap ); | 73 | err = mailimap_logout( m_imap ); |
74 | err = mailimap_close( m_imap ); | 74 | err = mailimap_close( m_imap ); |
75 | mailimap_free( m_imap ); | 75 | mailimap_free( m_imap ); |
76 | m_imap = 0; | 76 | m_imap = 0; |
77 | } | 77 | } |
78 | 78 | ||
79 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) | 79 | void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) |
80 | { | 80 | { |
81 | const char *mb; | 81 | const char *mb; |
82 | int err = MAILIMAP_NO_ERROR; | 82 | int err = MAILIMAP_NO_ERROR; |
83 | clist *result; | 83 | clist *result; |
84 | clistcell *current; | 84 | clistcell *current; |
85 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; | 85 | // mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate,*fetchAttSize; |
86 | mailimap_fetch_type *fetchType; | 86 | mailimap_fetch_type *fetchType; |
87 | mailimap_set *set; | 87 | mailimap_set *set; |
88 | 88 | ||
89 | mb = mailbox.latin1(); | 89 | mb = mailbox.latin1(); |
90 | login(); | 90 | login(); |
91 | if (!m_imap) { | 91 | if (!m_imap) { |
92 | return; | 92 | return; |
93 | } | 93 | } |
94 | /* select mailbox READONLY for operations */ | 94 | /* select mailbox READONLY for operations */ |
95 | err = mailimap_examine( m_imap, (char*)mb); | 95 | err = mailimap_examine( m_imap, (char*)mb); |
96 | if ( err != MAILIMAP_NO_ERROR ) { | 96 | if ( err != MAILIMAP_NO_ERROR ) { |
97 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 97 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
98 | return; | 98 | return; |
99 | } | 99 | } |
100 | 100 | ||
101 | int last = m_imap->imap_selection_info->sel_exists; | 101 | int last = m_imap->imap_selection_info->sel_exists; |
102 | 102 | ||
103 | if (last == 0) { | 103 | if (last == 0) { |
104 | qDebug("mailbox has no mails"); | 104 | qDebug("mailbox has no mails"); |
105 | return; | 105 | return; |
106 | } | 106 | } |
107 | 107 | ||
108 | result = clist_new(); | 108 | result = clist_new(); |
109 | /* the range has to start at 1!!! not with 0!!!! */ | 109 | /* the range has to start at 1!!! not with 0!!!! */ |
110 | set = mailimap_set_new_interval( 1, last ); | 110 | set = mailimap_set_new_interval( 1, last ); |
111 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); | 111 | fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); |
112 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); | 112 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); |
113 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); | 113 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); |
114 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); | 114 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); |
115 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); | 115 | mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); |
116 | 116 | ||
117 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 117 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
118 | mailimap_set_free( set ); | 118 | mailimap_set_free( set ); |
119 | mailimap_fetch_type_free( fetchType ); | 119 | mailimap_fetch_type_free( fetchType ); |
120 | 120 | ||
121 | QString date,subject,from; | 121 | QString date,subject,from; |
122 | 122 | ||
123 | if ( err == MAILIMAP_NO_ERROR ) { | 123 | if ( err == MAILIMAP_NO_ERROR ) { |
124 | 124 | ||
125 | mailimap_msg_att * msg_att; | 125 | mailimap_msg_att * msg_att; |
126 | int i = 0; | 126 | int i = 0; |
127 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { | 127 | for (current = clist_begin(result); current != 0; current=clist_next(current)) { |
128 | ++i; | 128 | ++i; |
129 | msg_att = (mailimap_msg_att*)current->data; | 129 | msg_att = (mailimap_msg_att*)current->data; |
130 | RecMail*m = parse_list_result(msg_att); | 130 | RecMail*m = parse_list_result(msg_att); |
131 | if (m) { | 131 | if (m) { |
132 | m->setNumber(i); | 132 | m->setNumber(i); |
133 | m->setMbox(mailbox); | 133 | m->setMbox(mailbox); |
134 | m->setWrapper(this); | 134 | m->setWrapper(this); |
135 | target.append(m); | 135 | target.append(m); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | } else { | 138 | } else { |
139 | qDebug("Error fetching headers: %s",m_imap->imap_response); | 139 | qDebug("Error fetching headers: %s",m_imap->imap_response); |
140 | } | 140 | } |
141 | mailimap_fetch_list_free(result); | 141 | mailimap_fetch_list_free(result); |
142 | } | 142 | } |
143 | 143 | ||
144 | QList<Folder>* IMAPwrapper::listFolders() | 144 | QList<Folder>* IMAPwrapper::listFolders() |
145 | { | 145 | { |
146 | const char *path, *mask; | 146 | const char *path, *mask; |
147 | int err = MAILIMAP_NO_ERROR; | 147 | int err = MAILIMAP_NO_ERROR; |
148 | clist *result; | 148 | clist *result; |
149 | clistcell *current; | 149 | clistcell *current; |
150 | 150 | ||
151 | QList<Folder> * folders = new QList<Folder>(); | 151 | QList<Folder> * folders = new QList<Folder>(); |
152 | folders->setAutoDelete( true ); | 152 | folders->setAutoDelete( false ); |
153 | login(); | 153 | login(); |
154 | if (!m_imap) { | 154 | if (!m_imap) { |
155 | return folders; | 155 | return folders; |
156 | } | 156 | } |
157 | 157 | ||
158 | /* | 158 | /* |
159 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. | 159 | * First we have to check for INBOX 'cause it sometimes it's not inside the path. |
160 | * We must not forget to filter them out in next loop! | 160 | * We must not forget to filter them out in next loop! |
161 | * it seems like ugly code. and yes - it is ugly code. but the best way. | 161 | * it seems like ugly code. and yes - it is ugly code. but the best way. |
162 | */ | 162 | */ |
163 | QString temp; | 163 | QString temp; |
164 | mask = "INBOX" ; | 164 | mask = "INBOX" ; |
165 | result = clist_new(); | 165 | result = clist_new(); |
166 | mailimap_mailbox_list *list; | 166 | mailimap_mailbox_list *list; |
167 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); | 167 | err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); |
168 | if ( err == MAILIMAP_NO_ERROR ) { | 168 | if ( err == MAILIMAP_NO_ERROR ) { |
169 | current = result->first; | 169 | current = result->first; |
170 | for ( int i = result->count; i > 0; i-- ) { | 170 | for ( int i = result->count; i > 0; i-- ) { |
171 | list = (mailimap_mailbox_list *) current->data; | 171 | list = (mailimap_mailbox_list *) current->data; |
172 | // it is better use the deep copy mechanism of qt itself | 172 | // it is better use the deep copy mechanism of qt itself |
173 | // instead of using strdup! | 173 | // instead of using strdup! |
174 | temp = list->mb_name; | 174 | temp = list->mb_name; |
175 | folders->append( new IMAPFolder(temp)); | 175 | folders->append( new IMAPFolder(temp)); |
176 | current = current->next; | 176 | current = current->next; |
177 | } | 177 | } |
178 | } else { | 178 | } else { |
179 | qDebug("error fetching folders: %s",m_imap->imap_response); | 179 | qDebug("error fetching folders: %s",m_imap->imap_response); |
180 | } | 180 | } |
181 | mailimap_list_result_free( result ); | 181 | mailimap_list_result_free( result ); |
182 | 182 | ||
183 | /* | 183 | /* |
184 | * second stage - get the other then inbox folders | 184 | * second stage - get the other then inbox folders |
185 | */ | 185 | */ |
186 | mask = "*" ; | 186 | mask = "*" ; |
187 | path = account->getPrefix().latin1(); | 187 | path = account->getPrefix().latin1(); |
188 | if (!path) path = ""; | 188 | if (!path) path = ""; |
189 | result = clist_new(); | 189 | result = clist_new(); |
190 | qDebug(path); | 190 | qDebug(path); |
191 | bool selectable = true; | ||
192 | mailimap_mbx_list_flags*bflags; | ||
191 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); | 193 | err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); |
192 | if ( err == MAILIMAP_NO_ERROR ) { | 194 | if ( err == MAILIMAP_NO_ERROR ) { |
193 | current = result->first; | 195 | current = result->first; |
194 | for ( int i = result->count; i > 0; i-- ) { | 196 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { |
195 | list = (mailimap_mailbox_list *) current->data; | 197 | list = (mailimap_mailbox_list *) current->data; |
196 | // it is better use the deep copy mechanism of qt itself | 198 | // it is better use the deep copy mechanism of qt itself |
197 | // instead of using strdup! | 199 | // instead of using strdup! |
198 | temp = list->mb_name; | 200 | temp = list->mb_name; |
199 | current = current->next; | ||
200 | if (temp.lower()=="inbox") | 201 | if (temp.lower()=="inbox") |
201 | continue; | 202 | continue; |
202 | folders->append(new IMAPFolder(temp)); | 203 | if ( (bflags = list->mb_flag) ) { |
203 | 204 | selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& | |
205 | bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); | ||
206 | } | ||
207 | folders->append(new IMAPFolder(temp,selectable)); | ||
204 | } | 208 | } |
205 | } else { | 209 | } else { |
206 | qDebug("error fetching folders %s",m_imap->imap_response); | 210 | qDebug("error fetching folders %s",m_imap->imap_response); |
207 | } | 211 | } |
208 | mailimap_list_result_free( result ); | 212 | mailimap_list_result_free( result ); |
209 | return folders; | 213 | return folders; |
210 | } | 214 | } |
211 | 215 | ||
212 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | 216 | RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) |
213 | { | 217 | { |
214 | RecMail * m = 0; | 218 | RecMail * m = 0; |
215 | mailimap_msg_att_item *item=0; | 219 | mailimap_msg_att_item *item=0; |
216 | clistcell *current,*c,*cf; | 220 | clistcell *current,*c,*cf; |
217 | mailimap_msg_att_dynamic*flist; | 221 | mailimap_msg_att_dynamic*flist; |
218 | mailimap_flag_fetch*cflag; | 222 | mailimap_flag_fetch*cflag; |
219 | int size; | 223 | int size; |
220 | QBitArray mFlags(7); | 224 | QBitArray mFlags(7); |
221 | QStringList addresslist; | 225 | QStringList addresslist; |
222 | 226 | ||
223 | if (!m_att) { | 227 | if (!m_att) { |
224 | return m; | 228 | return m; |
225 | } | 229 | } |
226 | m = new RecMail(); | 230 | m = new RecMail(); |
227 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 231 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
228 | current = c; | 232 | current = c; |
229 | size = 0; | 233 | size = 0; |
230 | item = (mailimap_msg_att_item*)current->data; | 234 | item = (mailimap_msg_att_item*)current->data; |
231 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 235 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
232 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 236 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
233 | if (!flist->att_list) { | 237 | if (!flist->att_list) { |
234 | continue; | 238 | continue; |
235 | } | 239 | } |
236 | cf = flist->att_list->first; | 240 | cf = flist->att_list->first; |
237 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 241 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
238 | cflag = (mailimap_flag_fetch*)cf->data; | 242 | cflag = (mailimap_flag_fetch*)cf->data; |
239 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 243 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
240 | switch (cflag->fl_flag->fl_type) { | 244 | switch (cflag->fl_flag->fl_type) { |
241 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 245 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
242 | mFlags.setBit(FLAG_ANSWERED); | 246 | mFlags.setBit(FLAG_ANSWERED); |
243 | break; | 247 | break; |
244 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 248 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
245 | mFlags.setBit(FLAG_FLAGGED); | 249 | mFlags.setBit(FLAG_FLAGGED); |
246 | break; | 250 | break; |
247 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 251 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
248 | mFlags.setBit(FLAG_DELETED); | 252 | mFlags.setBit(FLAG_DELETED); |
249 | break; | 253 | break; |
250 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 254 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
251 | mFlags.setBit(FLAG_SEEN); | 255 | mFlags.setBit(FLAG_SEEN); |
252 | break; | 256 | break; |
253 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 257 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
254 | mFlags.setBit(FLAG_DRAFT); | 258 | mFlags.setBit(FLAG_DRAFT); |
255 | break; | 259 | break; |
256 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 260 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
257 | break; | 261 | break; |
258 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 262 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
259 | break; | 263 | break; |
260 | default: | 264 | default: |
261 | break; | 265 | break; |
262 | } | 266 | } |
263 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 267 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
264 | mFlags.setBit(FLAG_RECENT); | 268 | mFlags.setBit(FLAG_RECENT); |
265 | } | 269 | } |
266 | } | 270 | } |
267 | continue; | 271 | continue; |
268 | } | 272 | } |
269 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 273 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
270 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 274 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
271 | m->setDate(head->env_date); | 275 | m->setDate(head->env_date); |
272 | m->setSubject(head->env_subject); | 276 | m->setSubject(head->env_subject); |
273 | if (head->env_from!=NULL) { | 277 | if (head->env_from!=NULL) { |
274 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 278 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
275 | if (addresslist.count()) { | 279 | if (addresslist.count()) { |
276 | m->setFrom(addresslist.first()); | 280 | m->setFrom(addresslist.first()); |
277 | } | 281 | } |
278 | } | 282 | } |
279 | if (head->env_to!=NULL) { | 283 | if (head->env_to!=NULL) { |
280 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 284 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
281 | m->setTo(addresslist); | 285 | m->setTo(addresslist); |
282 | } | 286 | } |
283 | if (head->env_cc!=NULL) { | 287 | if (head->env_cc!=NULL) { |
284 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 288 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
285 | m->setCC(addresslist); | 289 | m->setCC(addresslist); |
286 | } | 290 | } |
287 | if (head->env_bcc!=NULL) { | 291 | if (head->env_bcc!=NULL) { |
288 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 292 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
289 | m->setBcc(addresslist); | 293 | m->setBcc(addresslist); |
290 | } | 294 | } |
291 | if (head->env_reply_to!=NULL) { | 295 | if (head->env_reply_to!=NULL) { |
292 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 296 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
293 | if (addresslist.count()) { | 297 | if (addresslist.count()) { |
294 | m->setReplyto(addresslist.first()); | 298 | m->setReplyto(addresslist.first()); |
295 | } | 299 | } |
296 | } | 300 | } |
297 | m->setMsgid(QString(head->env_message_id)); | 301 | m->setMsgid(QString(head->env_message_id)); |
298 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 302 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
299 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 303 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
300 | #if 0 | 304 | #if 0 |
301 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 305 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
302 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); | 306 | qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec); |
303 | qDebug(da.toString()); | 307 | qDebug(da.toString()); |
304 | #endif | 308 | #endif |
305 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 309 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
306 | size = item->att_data.att_static->att_data.att_rfc822_size; | 310 | size = item->att_data.att_static->att_data.att_rfc822_size; |
307 | } | 311 | } |
308 | } | 312 | } |
309 | /* msg is already deleted */ | 313 | /* msg is already deleted */ |
310 | if (mFlags.testBit(FLAG_DELETED) && m) { | 314 | if (mFlags.testBit(FLAG_DELETED) && m) { |
311 | delete m; | 315 | delete m; |
312 | m = 0; | 316 | m = 0; |
313 | } | 317 | } |
314 | if (m) { | 318 | if (m) { |
315 | m->setFlags(mFlags); | 319 | m->setFlags(mFlags); |
316 | m->setMsgsize(size); | 320 | m->setMsgsize(size); |
317 | } | 321 | } |
318 | return m; | 322 | return m; |
319 | } | 323 | } |
320 | 324 | ||
321 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) | 325 | RecBody IMAPwrapper::fetchBody(const RecMail&mail) |
322 | { | 326 | { |
323 | RecBody body; | 327 | RecBody body; |
324 | const char *mb; | 328 | const char *mb; |
325 | int err = MAILIMAP_NO_ERROR; | 329 | int err = MAILIMAP_NO_ERROR; |
326 | clist *result; | 330 | clist *result; |
327 | clistcell *current; | 331 | clistcell *current; |
328 | mailimap_fetch_att *fetchAtt; | 332 | mailimap_fetch_att *fetchAtt; |
329 | mailimap_fetch_type *fetchType; | 333 | mailimap_fetch_type *fetchType; |
330 | mailimap_set *set; | 334 | mailimap_set *set; |
331 | mailimap_body*body_desc; | 335 | mailimap_body*body_desc; |
332 | 336 | ||
333 | mb = mail.getMbox().latin1(); | 337 | mb = mail.getMbox().latin1(); |
334 | 338 | ||
335 | login(); | 339 | login(); |
336 | if (!m_imap) { | 340 | if (!m_imap) { |
337 | return body; | 341 | return body; |
338 | } | 342 | } |
339 | 343 | ||
340 | err = mailimap_select( m_imap, (char*)mb); | 344 | err = mailimap_select( m_imap, (char*)mb); |
341 | if ( err != MAILIMAP_NO_ERROR ) { | 345 | if ( err != MAILIMAP_NO_ERROR ) { |
342 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 346 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
343 | return body; | 347 | return body; |
344 | } | 348 | } |
345 | 349 | ||
346 | result = clist_new(); | 350 | result = clist_new(); |
347 | /* the range has to start at 1!!! not with 0!!!! */ | 351 | /* the range has to start at 1!!! not with 0!!!! */ |
348 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); | 352 | set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() ); |
349 | fetchAtt = mailimap_fetch_att_new_bodystructure(); | 353 | fetchAtt = mailimap_fetch_att_new_bodystructure(); |
350 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); | 354 | fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); |
351 | err = mailimap_fetch( m_imap, set, fetchType, &result ); | 355 | err = mailimap_fetch( m_imap, set, fetchType, &result ); |
352 | mailimap_set_free( set ); | 356 | mailimap_set_free( set ); |
353 | mailimap_fetch_type_free( fetchType ); | 357 | mailimap_fetch_type_free( fetchType ); |
354 | 358 | ||
355 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { | 359 | if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { |
356 | mailimap_msg_att * msg_att; | 360 | mailimap_msg_att * msg_att; |
357 | msg_att = (mailimap_msg_att*)current->data; | 361 | msg_att = (mailimap_msg_att*)current->data; |
358 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; | 362 | mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; |
359 | body_desc = item->att_data.att_static->att_data.att_body; | 363 | body_desc = item->att_data.att_static->att_data.att_body; |
360 | if (body_desc->bd_type==MAILIMAP_BODY_1PART) { | 364 | if (body_desc->bd_type==MAILIMAP_BODY_1PART) { |
361 | searchBodyText(mail,body_desc->bd_data.bd_body_1part,body); | 365 | searchBodyText(mail,body_desc->bd_data.bd_body_1part,body); |
362 | } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) { | 366 | } else if (body_desc->bd_type==MAILIMAP_BODY_MPART) { |
363 | qDebug("Mulitpart mail"); | 367 | qDebug("Mulitpart mail"); |
364 | searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); | 368 | searchBodyText(mail,body_desc->bd_data.bd_body_mpart,body); |
365 | } | 369 | } |
366 | } else { | 370 | } else { |
367 | qDebug("error fetching body: %s",m_imap->imap_response); | 371 | qDebug("error fetching body: %s",m_imap->imap_response); |
368 | } | 372 | } |
369 | mailimap_fetch_list_free(result); | 373 | mailimap_fetch_list_free(result); |
370 | return body; | 374 | return body; |
371 | } | 375 | } |
372 | 376 | ||
373 | /* this routine is just called when the mail has only ONE part. | 377 | /* this routine is just called when the mail has only ONE part. |
374 | for filling the parts of a multi-part-message there are other | 378 | for filling the parts of a multi-part-message there are other |
375 | routines 'cause we can not simply fetch the whole body. */ | 379 | routines 'cause we can not simply fetch the whole body. */ |
376 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) | 380 | void IMAPwrapper::searchBodyText(const RecMail&mail,mailimap_body_type_1part*mailDescription,RecBody&target_body) |
377 | { | 381 | { |
378 | if (!mailDescription) { | 382 | if (!mailDescription) { |
379 | return; | 383 | return; |
380 | } | 384 | } |
381 | QString sub,body_text; | 385 | QString sub,body_text; |
382 | RecPart singlePart; | 386 | RecPart singlePart; |
383 | QValueList<int> path; | 387 | QValueList<int> path; |
384 | fillSinglePart(singlePart,mailDescription); | 388 | fillSinglePart(singlePart,mailDescription); |
385 | switch (mailDescription->bd_type) { | 389 | switch (mailDescription->bd_type) { |
386 | case MAILIMAP_BODY_TYPE_1PART_MSG: | 390 | case MAILIMAP_BODY_TYPE_1PART_MSG: |
387 | path.append(1); | 391 | path.append(1); |
388 | body_text = fetchPart(mail,path,true); | 392 | body_text = fetchPart(mail,path,true); |
389 | target_body.setBodytext(body_text); | 393 | target_body.setBodytext(body_text); |
390 | target_body.setDescription(singlePart); | 394 | target_body.setDescription(singlePart); |
391 | break; | 395 | break; |
392 | case MAILIMAP_BODY_TYPE_1PART_TEXT: | 396 | case MAILIMAP_BODY_TYPE_1PART_TEXT: |
393 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); | 397 | qDebug("Mediatype single: %s",mailDescription->bd_data.bd_type_text->bd_media_text); |
394 | path.append(1); | 398 | path.append(1); |
395 | body_text = fetchPart(mail,path,true); | 399 | body_text = fetchPart(mail,path,true); |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 62523bf..5065d29 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -84,206 +84,206 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | |||
84 | mail->setWrapper(this); | 84 | mail->setWrapper(this); |
85 | target.append( mail ); | 85 | target.append( mail ); |
86 | } | 86 | } |
87 | 87 | ||
88 | logout(); | 88 | logout(); |
89 | } | 89 | } |
90 | 90 | ||
91 | RecMail *POP3wrapper::parseHeader( const char *header ) | 91 | RecMail *POP3wrapper::parseHeader( const char *header ) |
92 | { | 92 | { |
93 | int err = MAILIMF_NO_ERROR; | 93 | int err = MAILIMF_NO_ERROR; |
94 | size_t curTok; | 94 | size_t curTok; |
95 | RecMail *mail = new RecMail(); | 95 | RecMail *mail = new RecMail(); |
96 | mailimf_fields *fields; | 96 | mailimf_fields *fields; |
97 | 97 | ||
98 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); | 98 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); |
99 | for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { | 99 | for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { |
100 | mailimf_field *field = (mailimf_field *) current->data; | 100 | mailimf_field *field = (mailimf_field *) current->data; |
101 | switch ( field->fld_type ) { | 101 | switch ( field->fld_type ) { |
102 | case MAILIMF_FIELD_FROM: | 102 | case MAILIMF_FIELD_FROM: |
103 | mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) ); | 103 | mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) ); |
104 | break; | 104 | break; |
105 | case MAILIMF_FIELD_TO: | 105 | case MAILIMF_FIELD_TO: |
106 | mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) ); | 106 | mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) ); |
107 | break; | 107 | break; |
108 | case MAILIMF_FIELD_CC: | 108 | case MAILIMF_FIELD_CC: |
109 | mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) ); | 109 | mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) ); |
110 | break; | 110 | break; |
111 | case MAILIMF_FIELD_BCC: | 111 | case MAILIMF_FIELD_BCC: |
112 | mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) ); | 112 | mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) ); |
113 | break; | 113 | break; |
114 | case MAILIMF_FIELD_SUBJECT: | 114 | case MAILIMF_FIELD_SUBJECT: |
115 | mail->setSubject( QString( field->fld_data.fld_subject->sbj_value ) ); | 115 | mail->setSubject( QString( field->fld_data.fld_subject->sbj_value ) ); |
116 | break; | 116 | break; |
117 | case MAILIMF_FIELD_ORIG_DATE: | 117 | case MAILIMF_FIELD_ORIG_DATE: |
118 | mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); | 118 | mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); |
119 | break; | 119 | break; |
120 | default: | 120 | default: |
121 | break; | 121 | break; |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | return mail; | 125 | return mail; |
126 | } | 126 | } |
127 | 127 | ||
128 | QString POP3wrapper::parseDateTime( mailimf_date_time *date ) | 128 | QString POP3wrapper::parseDateTime( mailimf_date_time *date ) |
129 | { | 129 | { |
130 | char tmp[23]; | 130 | char tmp[23]; |
131 | 131 | ||
132 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 132 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
133 | date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 133 | date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
134 | 134 | ||
135 | return QString( tmp ); | 135 | return QString( tmp ); |
136 | } | 136 | } |
137 | 137 | ||
138 | QString POP3wrapper::parseAddressList( mailimf_address_list *list ) | 138 | QString POP3wrapper::parseAddressList( mailimf_address_list *list ) |
139 | { | 139 | { |
140 | QString result( "" ); | 140 | QString result( "" ); |
141 | 141 | ||
142 | bool first = true; | 142 | bool first = true; |
143 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 143 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
144 | mailimf_address *addr = (mailimf_address *) current->data; | 144 | mailimf_address *addr = (mailimf_address *) current->data; |
145 | 145 | ||
146 | if ( !first ) { | 146 | if ( !first ) { |
147 | result.append( "," ); | 147 | result.append( "," ); |
148 | } else { | 148 | } else { |
149 | first = false; | 149 | first = false; |
150 | } | 150 | } |
151 | 151 | ||
152 | switch ( addr->ad_type ) { | 152 | switch ( addr->ad_type ) { |
153 | case MAILIMF_ADDRESS_MAILBOX: | 153 | case MAILIMF_ADDRESS_MAILBOX: |
154 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 154 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
155 | break; | 155 | break; |
156 | case MAILIMF_ADDRESS_GROUP: | 156 | case MAILIMF_ADDRESS_GROUP: |
157 | result.append( parseGroup( addr->ad_data.ad_group ) ); | 157 | result.append( parseGroup( addr->ad_data.ad_group ) ); |
158 | break; | 158 | break; |
159 | default: | 159 | default: |
160 | qDebug( "POP3: unkown mailimf address type" ); | 160 | qDebug( "POP3: unkown mailimf address type" ); |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | return result; | 165 | return result; |
166 | } | 166 | } |
167 | 167 | ||
168 | QString POP3wrapper::parseGroup( mailimf_group *group ) | 168 | QString POP3wrapper::parseGroup( mailimf_group *group ) |
169 | { | 169 | { |
170 | QString result( "" ); | 170 | QString result( "" ); |
171 | 171 | ||
172 | result.append( group->grp_display_name ); | 172 | result.append( group->grp_display_name ); |
173 | result.append( ": " ); | 173 | result.append( ": " ); |
174 | 174 | ||
175 | if ( group->grp_mb_list != NULL ) { | 175 | if ( group->grp_mb_list != NULL ) { |
176 | result.append( parseMailboxList( group->grp_mb_list ) ); | 176 | result.append( parseMailboxList( group->grp_mb_list ) ); |
177 | } | 177 | } |
178 | 178 | ||
179 | result.append( ";" ); | 179 | result.append( ";" ); |
180 | 180 | ||
181 | return result; | 181 | return result; |
182 | } | 182 | } |
183 | 183 | ||
184 | QString POP3wrapper::parseMailbox( mailimf_mailbox *box ) | 184 | QString POP3wrapper::parseMailbox( mailimf_mailbox *box ) |
185 | { | 185 | { |
186 | QString result( "" ); | 186 | QString result( "" ); |
187 | 187 | ||
188 | if ( box->mb_display_name == NULL ) { | 188 | if ( box->mb_display_name == NULL ) { |
189 | result.append( box->mb_addr_spec ); | 189 | result.append( box->mb_addr_spec ); |
190 | } else { | 190 | } else { |
191 | result.append( box->mb_display_name ); | 191 | result.append( box->mb_display_name ); |
192 | result.append( " <" ); | 192 | result.append( " <" ); |
193 | result.append( box->mb_addr_spec ); | 193 | result.append( box->mb_addr_spec ); |
194 | result.append( ">" ); | 194 | result.append( ">" ); |
195 | } | 195 | } |
196 | 196 | ||
197 | return result; | 197 | return result; |
198 | } | 198 | } |
199 | 199 | ||
200 | QString POP3wrapper::parseMailboxList( mailimf_mailbox_list *list ) | 200 | QString POP3wrapper::parseMailboxList( mailimf_mailbox_list *list ) |
201 | { | 201 | { |
202 | QString result( "" ); | 202 | QString result( "" ); |
203 | 203 | ||
204 | bool first = true; | 204 | bool first = true; |
205 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { | 205 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { |
206 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; | 206 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; |
207 | 207 | ||
208 | if ( !first ) { | 208 | if ( !first ) { |
209 | result.append( "," ); | 209 | result.append( "," ); |
210 | } else { | 210 | } else { |
211 | first = false; | 211 | first = false; |
212 | } | 212 | } |
213 | 213 | ||
214 | result.append( parseMailbox( box ) ); | 214 | result.append( parseMailbox( box ) ); |
215 | } | 215 | } |
216 | 216 | ||
217 | return result; | 217 | return result; |
218 | } | 218 | } |
219 | 219 | ||
220 | void POP3wrapper::login() | 220 | void POP3wrapper::login() |
221 | { | 221 | { |
222 | if ( m_pop3 != NULL ) logout(); | 222 | if ( m_pop3 != NULL ) logout(); |
223 | 223 | ||
224 | const char *server, *user, *pass; | 224 | const char *server, *user, *pass; |
225 | uint16_t port; | 225 | uint16_t port; |
226 | int err = MAILPOP3_NO_ERROR; | 226 | int err = MAILPOP3_NO_ERROR; |
227 | 227 | ||
228 | server = account->getServer().latin1(); | 228 | server = account->getServer().latin1(); |
229 | port = account->getPort().toUInt(); | 229 | port = account->getPort().toUInt(); |
230 | user = account->getUser().latin1(); | 230 | user = account->getUser().latin1(); |
231 | pass = account->getPassword().latin1(); | 231 | pass = account->getPassword().latin1(); |
232 | 232 | ||
233 | m_pop3 = mailpop3_new( 200, &pop3_progress ); | 233 | m_pop3 = mailpop3_new( 200, &pop3_progress ); |
234 | 234 | ||
235 | // connect | 235 | // connect |
236 | if (account->getSSL()) { | 236 | if (account->getSSL()) { |
237 | err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); | 237 | err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); |
238 | } else { | 238 | } else { |
239 | err = mailpop3_socket_connect( m_pop3, (char*)server, port ); | 239 | err = mailpop3_socket_connect( m_pop3, (char*)server, port ); |
240 | } | 240 | } |
241 | 241 | ||
242 | if ( err != MAILPOP3_NO_ERROR ) { | 242 | if ( err != MAILPOP3_NO_ERROR ) { |
243 | qDebug( "pop3: error connecting to %s\n reason: %s", server, | 243 | qDebug( "pop3: error connecting to %s\n reason: %s", server, |
244 | m_pop3->pop3_response ); | 244 | m_pop3->pop3_response ); |
245 | mailpop3_free( m_pop3 ); | 245 | mailpop3_free( m_pop3 ); |
246 | m_pop3 = NULL; | 246 | m_pop3 = NULL; |
247 | return; | 247 | return; |
248 | } | 248 | } |
249 | qDebug( "POP3: connected!" ); | 249 | qDebug( "POP3: connected!" ); |
250 | 250 | ||
251 | // login | 251 | // login |
252 | // TODO: decide if apop or plain login should be used | 252 | // TODO: decide if apop or plain login should be used |
253 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); | 253 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); |
254 | if ( err != MAILPOP3_NO_ERROR ) { | 254 | if ( err != MAILPOP3_NO_ERROR ) { |
255 | qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); | 255 | qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); |
256 | logout(); | 256 | logout(); |
257 | return; | 257 | return; |
258 | } | 258 | } |
259 | 259 | ||
260 | qDebug( "POP3: logged in!" ); | 260 | qDebug( "POP3: logged in!" ); |
261 | } | 261 | } |
262 | 262 | ||
263 | void POP3wrapper::logout() | 263 | void POP3wrapper::logout() |
264 | { | 264 | { |
265 | int err = MAILPOP3_NO_ERROR; | 265 | int err = MAILPOP3_NO_ERROR; |
266 | if ( m_pop3 == NULL ) return; | 266 | if ( m_pop3 == NULL ) return; |
267 | err = mailpop3_quit( m_pop3 ); | 267 | err = mailpop3_quit( m_pop3 ); |
268 | mailpop3_free( m_pop3 ); | 268 | mailpop3_free( m_pop3 ); |
269 | m_pop3 = NULL; | 269 | m_pop3 = NULL; |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | QList<Folder>* POP3wrapper::listFolders() | 273 | QList<Folder>* POP3wrapper::listFolders() |
274 | { | 274 | { |
275 | QList<Folder> * folders = new QList<Folder>(); | 275 | QList<Folder> * folders = new QList<Folder>(); |
276 | folders->setAutoDelete( true ); | 276 | folders->setAutoDelete( false ); |
277 | Folder*inb=new Folder("INBOX"); | 277 | Folder*inb=new Folder("INBOX"); |
278 | folders->append(inb); | 278 | folders->append(inb); |
279 | return folders; | 279 | return folders; |
280 | } | 280 | } |
281 | 281 | ||
282 | QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) | 282 | QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) |
283 | { | 283 | { |
284 | return ""; | 284 | return ""; |
285 | } | 285 | } |
286 | 286 | ||
287 | void POP3wrapper::deleteMail(const RecMail&) | 287 | void POP3wrapper::deleteMail(const RecMail&) |
288 | { | 288 | { |
289 | } | 289 | } |
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index cab1a66..fae3e97 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -1,222 +1,222 @@ | |||
1 | #include <qlabel.h> | 1 | #include <qlabel.h> |
2 | #include <qvbox.h> | 2 | #include <qvbox.h> |
3 | #include <qheader.h> | 3 | #include <qheader.h> |
4 | #include <qtimer.h> | 4 | #include <qtimer.h> |
5 | #include <qlayout.h> | 5 | #include <qlayout.h> |
6 | #include <qmessagebox.h> | 6 | #include <qmessagebox.h> |
7 | 7 | ||
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | #include <qpe/resource.h> | 9 | #include <qpe/resource.h> |
10 | 10 | ||
11 | #include "defines.h" | 11 | #include "defines.h" |
12 | #include "mainwindow.h" | 12 | #include "mainwindow.h" |
13 | #include "viewmail.h" | 13 | #include "viewmail.h" |
14 | #include "mailtypes.h" | 14 | #include "mailtypes.h" |
15 | #include "mailistviewitem.h" | 15 | #include "mailistviewitem.h" |
16 | 16 | ||
17 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 17 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
18 | : QMainWindow( parent, name, flags ) | 18 | : QMainWindow( parent, name, flags ) |
19 | { | 19 | { |
20 | setCaption( tr( "Mail" ) ); | 20 | setCaption( tr( "Mail" ) ); |
21 | setToolBarsMovable( false ); | 21 | setToolBarsMovable( false ); |
22 | 22 | ||
23 | toolBar = new QToolBar( this ); | 23 | toolBar = new QToolBar( this ); |
24 | menuBar = new QMenuBar( toolBar ); | 24 | menuBar = new QMenuBar( toolBar ); |
25 | mailMenu = new QPopupMenu( menuBar ); | 25 | mailMenu = new QPopupMenu( menuBar ); |
26 | menuBar->insertItem( tr( "Mail" ), mailMenu ); | 26 | menuBar->insertItem( tr( "Mail" ), mailMenu ); |
27 | settingsMenu = new QPopupMenu( menuBar ); | 27 | settingsMenu = new QPopupMenu( menuBar ); |
28 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); | 28 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); |
29 | 29 | ||
30 | addToolBar( toolBar ); | 30 | addToolBar( toolBar ); |
31 | toolBar->setHorizontalStretchable( true ); | 31 | toolBar->setHorizontalStretchable( true ); |
32 | 32 | ||
33 | QLabel *spacer = new QLabel( toolBar ); | 33 | QLabel *spacer = new QLabel( toolBar ); |
34 | spacer->setBackgroundMode( QWidget::PaletteButton ); | 34 | spacer->setBackgroundMode( QWidget::PaletteButton ); |
35 | toolBar->setStretchableWidget( spacer ); | 35 | toolBar->setStretchableWidget( spacer ); |
36 | 36 | ||
37 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, | 37 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, |
38 | 0, 0, this ); | 38 | 0, 0, this ); |
39 | composeMail->addTo( toolBar ); | 39 | composeMail->addTo( toolBar ); |
40 | composeMail->addTo( mailMenu ); | 40 | composeMail->addTo( mailMenu ); |
41 | 41 | ||
42 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, | 42 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, |
43 | 0, 0, this ); | 43 | 0, 0, this ); |
44 | sendQueued->addTo( toolBar ); | 44 | sendQueued->addTo( toolBar ); |
45 | sendQueued->addTo( mailMenu ); | 45 | sendQueued->addTo( mailMenu ); |
46 | 46 | ||
47 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, | 47 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, |
48 | 0, 0, this ); | 48 | 0, 0, this ); |
49 | syncFolders->addTo( toolBar ); | 49 | syncFolders->addTo( toolBar ); |
50 | syncFolders->addTo( mailMenu ); | 50 | syncFolders->addTo( mailMenu ); |
51 | 51 | ||
52 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, | 52 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, |
53 | 0, 0, this, 0, true ); | 53 | 0, 0, this, 0, true ); |
54 | showFolders->addTo( toolBar ); | 54 | showFolders->addTo( toolBar ); |
55 | showFolders->addTo( mailMenu ); | 55 | showFolders->addTo( mailMenu ); |
56 | showFolders->setOn( true ); | 56 | showFolders->setOn( true ); |
57 | connect(showFolders, SIGNAL( toggled( bool ) ), | 57 | connect(showFolders, SIGNAL( toggled( bool ) ), |
58 | SLOT( slotShowFolders( bool ) ) ); | 58 | SLOT( slotShowFolders( bool ) ) ); |
59 | 59 | ||
60 | searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, | 60 | searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, |
61 | 0, 0, this ); | 61 | 0, 0, this ); |
62 | searchMails->addTo( toolBar ); | 62 | searchMails->addTo( toolBar ); |
63 | searchMails->addTo( mailMenu ); | 63 | searchMails->addTo( mailMenu ); |
64 | 64 | ||
65 | deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); | 65 | deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); |
66 | deleteMails->addTo( toolBar ); | 66 | deleteMails->addTo( toolBar ); |
67 | deleteMails->addTo( mailMenu ); | 67 | deleteMails->addTo( mailMenu ); |
68 | connect( deleteMails, SIGNAL( activated() ), | 68 | connect( deleteMails, SIGNAL( activated() ), |
69 | SLOT( slotDeleteMail() ) ); | 69 | SLOT( slotDeleteMail() ) ); |
70 | 70 | ||
71 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, | 71 | editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, |
72 | 0, 0, this ); | 72 | 0, 0, this ); |
73 | editSettings->addTo( settingsMenu ); | 73 | editSettings->addTo( settingsMenu ); |
74 | 74 | ||
75 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, | 75 | editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, |
76 | 0, 0, this ); | 76 | 0, 0, this ); |
77 | editAccounts->addTo( settingsMenu ); | 77 | editAccounts->addTo( settingsMenu ); |
78 | 78 | ||
79 | QWidget *view = new QWidget( this ); | 79 | QWidget *view = new QWidget( this ); |
80 | setCentralWidget( view ); | 80 | setCentralWidget( view ); |
81 | 81 | ||
82 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); | 82 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); |
83 | 83 | ||
84 | folderView = new AccountView( view ); | 84 | folderView = new AccountView( view ); |
85 | folderView->header()->hide(); | 85 | folderView->header()->hide(); |
86 | folderView->setRootIsDecorated( false ); | 86 | folderView->setRootIsDecorated( true ); |
87 | folderView->addColumn( tr( "Mailbox" ) ); | 87 | folderView->addColumn( tr( "Mailbox" ) ); |
88 | //folderView->hide(); | 88 | //folderView->hide(); |
89 | 89 | ||
90 | layout->addWidget( folderView ); | 90 | layout->addWidget( folderView ); |
91 | 91 | ||
92 | mailView = new QListView( view ); | 92 | mailView = new QListView( view ); |
93 | mailView->addColumn( tr( "" ) ); | 93 | mailView->addColumn( tr( "" ) ); |
94 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 94 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
95 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 95 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
96 | mailView->addColumn( tr( "Date" )); | 96 | mailView->addColumn( tr( "Date" )); |
97 | mailView->setAllColumnsShowFocus(true); | 97 | mailView->setAllColumnsShowFocus(true); |
98 | mailView->setSorting(-1); | 98 | mailView->setSorting(-1); |
99 | 99 | ||
100 | layout->addWidget( mailView ); | 100 | layout->addWidget( mailView ); |
101 | layout->setStretchFactor( folderView, 1 ); | 101 | layout->setStretchFactor( folderView, 1 ); |
102 | layout->setStretchFactor( mailView, 2 ); | 102 | layout->setStretchFactor( mailView, 2 ); |
103 | 103 | ||
104 | slotAdjustLayout(); | 104 | slotAdjustLayout(); |
105 | 105 | ||
106 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, | 106 | connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, |
107 | SLOT( displayMail( QListViewItem * ) ) ); | 107 | SLOT( displayMail( QListViewItem * ) ) ); |
108 | 108 | ||
109 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); | 109 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
110 | 110 | ||
111 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 111 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
112 | 112 | ||
113 | } | 113 | } |
114 | 114 | ||
115 | 115 | ||
116 | void MainWindow::slotAdjustLayout() { | 116 | void MainWindow::slotAdjustLayout() { |
117 | 117 | ||
118 | QWidget *d = QApplication::desktop(); | 118 | QWidget *d = QApplication::desktop(); |
119 | 119 | ||
120 | if ( d->width() < d->height() ) { | 120 | if ( d->width() < d->height() ) { |
121 | layout->setDirection( QBoxLayout::TopToBottom ); | 121 | layout->setDirection( QBoxLayout::TopToBottom ); |
122 | } else { | 122 | } else { |
123 | layout->setDirection( QBoxLayout::LeftToRight ); | 123 | layout->setDirection( QBoxLayout::LeftToRight ); |
124 | } | 124 | } |
125 | delete d; | 125 | delete d; |
126 | } | 126 | } |
127 | 127 | ||
128 | void MainWindow::slotAdjustColumns() | 128 | void MainWindow::slotAdjustColumns() |
129 | { | 129 | { |
130 | bool hidden = folderView->isHidden(); | 130 | bool hidden = folderView->isHidden(); |
131 | if ( hidden ) folderView->show(); | 131 | if ( hidden ) folderView->show(); |
132 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 132 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
133 | if ( hidden ) folderView->hide(); | 133 | if ( hidden ) folderView->hide(); |
134 | 134 | ||
135 | mailView->setColumnWidth( 0, 10 ); | 135 | mailView->setColumnWidth( 0, 10 ); |
136 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); | 136 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); |
137 | mailView->setColumnWidth( 2, 80 ); | 137 | mailView->setColumnWidth( 2, 80 ); |
138 | mailView->setColumnWidth( 3, 50 ); | 138 | mailView->setColumnWidth( 3, 50 ); |
139 | } | 139 | } |
140 | 140 | ||
141 | void MainWindow::slotShowFolders( bool show ) | 141 | void MainWindow::slotShowFolders( bool show ) |
142 | { | 142 | { |
143 | qDebug( "Show Folders" ); | 143 | qDebug( "Show Folders" ); |
144 | if ( show && folderView->isHidden() ) { | 144 | if ( show && folderView->isHidden() ) { |
145 | qDebug( "-> showing" ); | 145 | qDebug( "-> showing" ); |
146 | folderView->show(); | 146 | folderView->show(); |
147 | } else if ( !show && !folderView->isHidden() ) { | 147 | } else if ( !show && !folderView->isHidden() ) { |
148 | qDebug( "-> hiding" ); | 148 | qDebug( "-> hiding" ); |
149 | folderView->hide(); | 149 | folderView->hide(); |
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 | ||
153 | void MainWindow::refreshMailView(QList<RecMail>*list) | 153 | void MainWindow::refreshMailView(QList<RecMail>*list) |
154 | { | 154 | { |
155 | MailListViewItem*item = 0; | 155 | MailListViewItem*item = 0; |
156 | mailView->clear(); | 156 | mailView->clear(); |
157 | for (unsigned int i = 0; i < list->count();++i) { | 157 | for (unsigned int i = 0; i < list->count();++i) { |
158 | item = new MailListViewItem(mailView,item); | 158 | item = new MailListViewItem(mailView,item); |
159 | item->storeData(*(list->at(i))); | 159 | item->storeData(*(list->at(i))); |
160 | item->showEntry(); | 160 | item->showEntry(); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | void MainWindow::displayMail(QListViewItem*item) | 163 | void MainWindow::displayMail(QListViewItem*item) |
164 | { | 164 | { |
165 | 165 | ||
166 | if (!item) return; | 166 | if (!item) return; |
167 | RecMail mail = ((MailListViewItem*)item)->data(); | 167 | RecMail mail = ((MailListViewItem*)item)->data(); |
168 | RecBody body = folderView->fetchBody(mail); | 168 | RecBody body = folderView->fetchBody(mail); |
169 | 169 | ||
170 | ViewMail readMail( this ); | 170 | ViewMail readMail( this ); |
171 | readMail.setBody( body ); | 171 | readMail.setBody( body ); |
172 | readMail.setMail( mail ); | 172 | readMail.setMail( mail ); |
173 | readMail.showMaximized(); | 173 | readMail.showMaximized(); |
174 | readMail.exec(); | 174 | readMail.exec(); |
175 | 175 | ||
176 | if ( readMail.deleted ) { | 176 | if ( readMail.deleted ) { |
177 | folderView->refreshCurrent(); | 177 | folderView->refreshCurrent(); |
178 | } else { | 178 | } else { |
179 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); | 179 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | void MainWindow::slotDeleteMail() | 183 | void MainWindow::slotDeleteMail() |
184 | { | 184 | { |
185 | if (!mailView->currentItem()) return; | 185 | if (!mailView->currentItem()) return; |
186 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 186 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
187 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { | 187 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { |
188 | mail.Wrapper()->deleteMail( mail ); | 188 | mail.Wrapper()->deleteMail( mail ); |
189 | folderView->refreshCurrent(); | 189 | folderView->refreshCurrent(); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | 192 | ||
193 | 193 | ||
194 | 194 | ||
195 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) | 195 | MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) |
196 | :QListViewItem(parent,item),mail_data() | 196 | :QListViewItem(parent,item),mail_data() |
197 | { | 197 | { |
198 | } | 198 | } |
199 | 199 | ||
200 | void MailListViewItem::showEntry() | 200 | void MailListViewItem::showEntry() |
201 | { | 201 | { |
202 | if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { | 202 | if ( mail_data.getFlags().testBit( FLAG_SEEN ) == true ) { |
203 | setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); | 203 | setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgunseen") ); |
204 | } else { | 204 | } else { |
205 | setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") ); | 205 | setPixmap( 0, Resource::loadPixmap( "opiemail/kmmsgnew") ); |
206 | } | 206 | } |
207 | setText(1,mail_data.getSubject()); | 207 | setText(1,mail_data.getSubject()); |
208 | setText(2,mail_data.getFrom()); | 208 | setText(2,mail_data.getFrom()); |
209 | setText(3,mail_data.getDate()); | 209 | setText(3,mail_data.getDate()); |
210 | } | 210 | } |
211 | 211 | ||
212 | void MailListViewItem::storeData(const RecMail&data) | 212 | void MailListViewItem::storeData(const RecMail&data) |
213 | { | 213 | { |
214 | mail_data = data; | 214 | mail_data = data; |
215 | } | 215 | } |
216 | 216 | ||
217 | const RecMail& MailListViewItem::data()const | 217 | const RecMail& MailListViewItem::data()const |
218 | { | 218 | { |
219 | return mail_data; | 219 | return mail_data; |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
diff --git a/noncore/net/mail/pop3wrapper.cpp b/noncore/net/mail/pop3wrapper.cpp index 62523bf..5065d29 100644 --- a/noncore/net/mail/pop3wrapper.cpp +++ b/noncore/net/mail/pop3wrapper.cpp | |||
@@ -84,206 +84,206 @@ void POP3wrapper::listMessages(const QString &, QList<RecMail> &target ) | |||
84 | mail->setWrapper(this); | 84 | mail->setWrapper(this); |
85 | target.append( mail ); | 85 | target.append( mail ); |
86 | } | 86 | } |
87 | 87 | ||
88 | logout(); | 88 | logout(); |
89 | } | 89 | } |
90 | 90 | ||
91 | RecMail *POP3wrapper::parseHeader( const char *header ) | 91 | RecMail *POP3wrapper::parseHeader( const char *header ) |
92 | { | 92 | { |
93 | int err = MAILIMF_NO_ERROR; | 93 | int err = MAILIMF_NO_ERROR; |
94 | size_t curTok; | 94 | size_t curTok; |
95 | RecMail *mail = new RecMail(); | 95 | RecMail *mail = new RecMail(); |
96 | mailimf_fields *fields; | 96 | mailimf_fields *fields; |
97 | 97 | ||
98 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); | 98 | err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields ); |
99 | for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { | 99 | for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) { |
100 | mailimf_field *field = (mailimf_field *) current->data; | 100 | mailimf_field *field = (mailimf_field *) current->data; |
101 | switch ( field->fld_type ) { | 101 | switch ( field->fld_type ) { |
102 | case MAILIMF_FIELD_FROM: | 102 | case MAILIMF_FIELD_FROM: |
103 | mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) ); | 103 | mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) ); |
104 | break; | 104 | break; |
105 | case MAILIMF_FIELD_TO: | 105 | case MAILIMF_FIELD_TO: |
106 | mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) ); | 106 | mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) ); |
107 | break; | 107 | break; |
108 | case MAILIMF_FIELD_CC: | 108 | case MAILIMF_FIELD_CC: |
109 | mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) ); | 109 | mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) ); |
110 | break; | 110 | break; |
111 | case MAILIMF_FIELD_BCC: | 111 | case MAILIMF_FIELD_BCC: |
112 | mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) ); | 112 | mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) ); |
113 | break; | 113 | break; |
114 | case MAILIMF_FIELD_SUBJECT: | 114 | case MAILIMF_FIELD_SUBJECT: |
115 | mail->setSubject( QString( field->fld_data.fld_subject->sbj_value ) ); | 115 | mail->setSubject( QString( field->fld_data.fld_subject->sbj_value ) ); |
116 | break; | 116 | break; |
117 | case MAILIMF_FIELD_ORIG_DATE: | 117 | case MAILIMF_FIELD_ORIG_DATE: |
118 | mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); | 118 | mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) ); |
119 | break; | 119 | break; |
120 | default: | 120 | default: |
121 | break; | 121 | break; |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | return mail; | 125 | return mail; |
126 | } | 126 | } |
127 | 127 | ||
128 | QString POP3wrapper::parseDateTime( mailimf_date_time *date ) | 128 | QString POP3wrapper::parseDateTime( mailimf_date_time *date ) |
129 | { | 129 | { |
130 | char tmp[23]; | 130 | char tmp[23]; |
131 | 131 | ||
132 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 132 | snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
133 | date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 133 | date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
134 | 134 | ||
135 | return QString( tmp ); | 135 | return QString( tmp ); |
136 | } | 136 | } |
137 | 137 | ||
138 | QString POP3wrapper::parseAddressList( mailimf_address_list *list ) | 138 | QString POP3wrapper::parseAddressList( mailimf_address_list *list ) |
139 | { | 139 | { |
140 | QString result( "" ); | 140 | QString result( "" ); |
141 | 141 | ||
142 | bool first = true; | 142 | bool first = true; |
143 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { | 143 | for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { |
144 | mailimf_address *addr = (mailimf_address *) current->data; | 144 | mailimf_address *addr = (mailimf_address *) current->data; |
145 | 145 | ||
146 | if ( !first ) { | 146 | if ( !first ) { |
147 | result.append( "," ); | 147 | result.append( "," ); |
148 | } else { | 148 | } else { |
149 | first = false; | 149 | first = false; |
150 | } | 150 | } |
151 | 151 | ||
152 | switch ( addr->ad_type ) { | 152 | switch ( addr->ad_type ) { |
153 | case MAILIMF_ADDRESS_MAILBOX: | 153 | case MAILIMF_ADDRESS_MAILBOX: |
154 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); | 154 | result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); |
155 | break; | 155 | break; |
156 | case MAILIMF_ADDRESS_GROUP: | 156 | case MAILIMF_ADDRESS_GROUP: |
157 | result.append( parseGroup( addr->ad_data.ad_group ) ); | 157 | result.append( parseGroup( addr->ad_data.ad_group ) ); |
158 | break; | 158 | break; |
159 | default: | 159 | default: |
160 | qDebug( "POP3: unkown mailimf address type" ); | 160 | qDebug( "POP3: unkown mailimf address type" ); |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | return result; | 165 | return result; |
166 | } | 166 | } |
167 | 167 | ||
168 | QString POP3wrapper::parseGroup( mailimf_group *group ) | 168 | QString POP3wrapper::parseGroup( mailimf_group *group ) |
169 | { | 169 | { |
170 | QString result( "" ); | 170 | QString result( "" ); |
171 | 171 | ||
172 | result.append( group->grp_display_name ); | 172 | result.append( group->grp_display_name ); |
173 | result.append( ": " ); | 173 | result.append( ": " ); |
174 | 174 | ||
175 | if ( group->grp_mb_list != NULL ) { | 175 | if ( group->grp_mb_list != NULL ) { |
176 | result.append( parseMailboxList( group->grp_mb_list ) ); | 176 | result.append( parseMailboxList( group->grp_mb_list ) ); |
177 | } | 177 | } |
178 | 178 | ||
179 | result.append( ";" ); | 179 | result.append( ";" ); |
180 | 180 | ||
181 | return result; | 181 | return result; |
182 | } | 182 | } |
183 | 183 | ||
184 | QString POP3wrapper::parseMailbox( mailimf_mailbox *box ) | 184 | QString POP3wrapper::parseMailbox( mailimf_mailbox *box ) |
185 | { | 185 | { |
186 | QString result( "" ); | 186 | QString result( "" ); |
187 | 187 | ||
188 | if ( box->mb_display_name == NULL ) { | 188 | if ( box->mb_display_name == NULL ) { |
189 | result.append( box->mb_addr_spec ); | 189 | result.append( box->mb_addr_spec ); |
190 | } else { | 190 | } else { |
191 | result.append( box->mb_display_name ); | 191 | result.append( box->mb_display_name ); |
192 | result.append( " <" ); | 192 | result.append( " <" ); |
193 | result.append( box->mb_addr_spec ); | 193 | result.append( box->mb_addr_spec ); |
194 | result.append( ">" ); | 194 | result.append( ">" ); |
195 | } | 195 | } |
196 | 196 | ||
197 | return result; | 197 | return result; |
198 | } | 198 | } |
199 | 199 | ||
200 | QString POP3wrapper::parseMailboxList( mailimf_mailbox_list *list ) | 200 | QString POP3wrapper::parseMailboxList( mailimf_mailbox_list *list ) |
201 | { | 201 | { |
202 | QString result( "" ); | 202 | QString result( "" ); |
203 | 203 | ||
204 | bool first = true; | 204 | bool first = true; |
205 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { | 205 | for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { |
206 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; | 206 | mailimf_mailbox *box = (mailimf_mailbox *) current->data; |
207 | 207 | ||
208 | if ( !first ) { | 208 | if ( !first ) { |
209 | result.append( "," ); | 209 | result.append( "," ); |
210 | } else { | 210 | } else { |
211 | first = false; | 211 | first = false; |
212 | } | 212 | } |
213 | 213 | ||
214 | result.append( parseMailbox( box ) ); | 214 | result.append( parseMailbox( box ) ); |
215 | } | 215 | } |
216 | 216 | ||
217 | return result; | 217 | return result; |
218 | } | 218 | } |
219 | 219 | ||
220 | void POP3wrapper::login() | 220 | void POP3wrapper::login() |
221 | { | 221 | { |
222 | if ( m_pop3 != NULL ) logout(); | 222 | if ( m_pop3 != NULL ) logout(); |
223 | 223 | ||
224 | const char *server, *user, *pass; | 224 | const char *server, *user, *pass; |
225 | uint16_t port; | 225 | uint16_t port; |
226 | int err = MAILPOP3_NO_ERROR; | 226 | int err = MAILPOP3_NO_ERROR; |
227 | 227 | ||
228 | server = account->getServer().latin1(); | 228 | server = account->getServer().latin1(); |
229 | port = account->getPort().toUInt(); | 229 | port = account->getPort().toUInt(); |
230 | user = account->getUser().latin1(); | 230 | user = account->getUser().latin1(); |
231 | pass = account->getPassword().latin1(); | 231 | pass = account->getPassword().latin1(); |
232 | 232 | ||
233 | m_pop3 = mailpop3_new( 200, &pop3_progress ); | 233 | m_pop3 = mailpop3_new( 200, &pop3_progress ); |
234 | 234 | ||
235 | // connect | 235 | // connect |
236 | if (account->getSSL()) { | 236 | if (account->getSSL()) { |
237 | err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); | 237 | err = mailpop3_ssl_connect( m_pop3, (char*)server, port ); |
238 | } else { | 238 | } else { |
239 | err = mailpop3_socket_connect( m_pop3, (char*)server, port ); | 239 | err = mailpop3_socket_connect( m_pop3, (char*)server, port ); |
240 | } | 240 | } |
241 | 241 | ||
242 | if ( err != MAILPOP3_NO_ERROR ) { | 242 | if ( err != MAILPOP3_NO_ERROR ) { |
243 | qDebug( "pop3: error connecting to %s\n reason: %s", server, | 243 | qDebug( "pop3: error connecting to %s\n reason: %s", server, |
244 | m_pop3->pop3_response ); | 244 | m_pop3->pop3_response ); |
245 | mailpop3_free( m_pop3 ); | 245 | mailpop3_free( m_pop3 ); |
246 | m_pop3 = NULL; | 246 | m_pop3 = NULL; |
247 | return; | 247 | return; |
248 | } | 248 | } |
249 | qDebug( "POP3: connected!" ); | 249 | qDebug( "POP3: connected!" ); |
250 | 250 | ||
251 | // login | 251 | // login |
252 | // TODO: decide if apop or plain login should be used | 252 | // TODO: decide if apop or plain login should be used |
253 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); | 253 | err = mailpop3_login( m_pop3, (char *) user, (char *) pass ); |
254 | if ( err != MAILPOP3_NO_ERROR ) { | 254 | if ( err != MAILPOP3_NO_ERROR ) { |
255 | qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); | 255 | qDebug( "pop3: error logging in: %s", m_pop3->pop3_response ); |
256 | logout(); | 256 | logout(); |
257 | return; | 257 | return; |
258 | } | 258 | } |
259 | 259 | ||
260 | qDebug( "POP3: logged in!" ); | 260 | qDebug( "POP3: logged in!" ); |
261 | } | 261 | } |
262 | 262 | ||
263 | void POP3wrapper::logout() | 263 | void POP3wrapper::logout() |
264 | { | 264 | { |
265 | int err = MAILPOP3_NO_ERROR; | 265 | int err = MAILPOP3_NO_ERROR; |
266 | if ( m_pop3 == NULL ) return; | 266 | if ( m_pop3 == NULL ) return; |
267 | err = mailpop3_quit( m_pop3 ); | 267 | err = mailpop3_quit( m_pop3 ); |
268 | mailpop3_free( m_pop3 ); | 268 | mailpop3_free( m_pop3 ); |
269 | m_pop3 = NULL; | 269 | m_pop3 = NULL; |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | QList<Folder>* POP3wrapper::listFolders() | 273 | QList<Folder>* POP3wrapper::listFolders() |
274 | { | 274 | { |
275 | QList<Folder> * folders = new QList<Folder>(); | 275 | QList<Folder> * folders = new QList<Folder>(); |
276 | folders->setAutoDelete( true ); | 276 | folders->setAutoDelete( false ); |
277 | Folder*inb=new Folder("INBOX"); | 277 | Folder*inb=new Folder("INBOX"); |
278 | folders->append(inb); | 278 | folders->append(inb); |
279 | return folders; | 279 | return folders; |
280 | } | 280 | } |
281 | 281 | ||
282 | QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) | 282 | QString POP3wrapper::fetchPart(const RecMail&,const RecPart&) |
283 | { | 283 | { |
284 | return ""; | 284 | return ""; |
285 | } | 285 | } |
286 | 286 | ||
287 | void POP3wrapper::deleteMail(const RecMail&) | 287 | void POP3wrapper::deleteMail(const RecMail&) |
288 | { | 288 | { |
289 | } | 289 | } |
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 2415c82..e53f4a3 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,194 +1,194 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qmessagebox.h>? | 2 | #include <qmessagebox.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qaction.h> | 4 | #include <qaction.h> |
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | 7 | ||
8 | #include <opie/ofiledialog.h> | 8 | #include <opie/ofiledialog.h> |
9 | 9 | ||
10 | #include "settings.h" | 10 | #include "settings.h" |
11 | #include "composemail.h" | 11 | #include "composemail.h" |
12 | #include "viewmail.h" | 12 | #include "viewmail.h" |
13 | #include "abstractmail.h" | 13 | #include "abstractmail.h" |
14 | #include "accountview.h" | 14 | #include "accountview.h" |
15 | 15 | ||
16 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num) | 16 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&file,const QString&desc,int num) |
17 | : QListViewItem(parent,after),_partNum(num) | 17 | : QListViewItem(parent,after),_partNum(num) |
18 | { | 18 | { |
19 | setText(0, mime); | 19 | setText(0, mime); |
20 | setText(1, file); | 20 | setText(1, file); |
21 | setText(2, desc); | 21 | setText(2, desc); |
22 | } | 22 | } |
23 | 23 | ||
24 | void ViewMail::setBody( RecBody body ) { | 24 | void ViewMail::setBody( RecBody body ) { |
25 | 25 | ||
26 | m_body = body; | 26 | m_body = body; |
27 | m_mail[2] = body.Bodytext(); | 27 | m_mail[2] = body.Bodytext(); |
28 | attachbutton->setEnabled(body.Parts().count()>0); | 28 | attachbutton->setEnabled(body.Parts().count()>0); |
29 | attachments->setEnabled(body.Parts().count()>0); | 29 | attachments->setEnabled(body.Parts().count()>0); |
30 | if (body.Parts().count()==0) { | 30 | if (body.Parts().count()==0) { |
31 | return; | 31 | return; |
32 | } | 32 | } |
33 | AttachItem * curItem=0; | 33 | AttachItem * curItem=0; |
34 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); | 34 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); |
35 | QString desc; | 35 | QString desc; |
36 | double s = body.Description().Size(); | 36 | double s = body.Description().Size(); |
37 | int w; | 37 | int w; |
38 | w=0; | 38 | w=0; |
39 | 39 | ||
40 | while (s>1024) { | 40 | while (s>1024) { |
41 | s/=1024; | 41 | s/=1024; |
42 | ++w; | 42 | ++w; |
43 | if (w>=2) break; | 43 | if (w>=2) break; |
44 | } | 44 | } |
45 | 45 | ||
46 | QString q=""; | 46 | QString q=""; |
47 | switch(w) { | 47 | switch(w) { |
48 | case 1: | 48 | case 1: |
49 | q="k"; | 49 | q="k"; |
50 | break; | 50 | break; |
51 | case 2: | 51 | case 2: |
52 | q="M"; | 52 | q="M"; |
53 | break; | 53 | break; |
54 | default: | 54 | default: |
55 | break; | 55 | break; |
56 | } | 56 | } |
57 | 57 | ||
58 | { | 58 | { |
59 | /* I did not found a method to make a CONTENT reset on a QTextStream | 59 | /* I did not found a method to make a CONTENT reset on a QTextStream |
60 | so I use this construct that the stream will re-constructed in each | 60 | so I use this construct that the stream will re-constructed in each |
61 | loop. To let it work, the textstream is packed into a own area of | 61 | loop. To let it work, the textstream is packed into a own area of |
62 | code is it will be destructed after finishing its small job. | 62 | code is it will be destructed after finishing its small job. |
63 | */ | 63 | */ |
64 | QTextOStream o(&desc); | 64 | QTextOStream o(&desc); |
65 | if (w>0) o.precision(2); else o.precision(0); | 65 | if (w>0) o.precision(2); else o.precision(0); |
66 | o.setf(QTextStream::fixed); | 66 | o.setf(QTextStream::fixed); |
67 | o << s << " " << q << "Byte"; | 67 | o << s << " " << q << "Byte"; |
68 | } | 68 | } |
69 | 69 | ||
70 | curItem=new AttachItem(attachments,curItem,type,"Mailbody",desc,-1); | 70 | curItem=new AttachItem(attachments,curItem,type,"Mailbody",desc,-1); |
71 | QString filename = ""; | 71 | QString filename = ""; |
72 | for (unsigned int i = 0; i < body.Parts().count();++i) { | 72 | for (unsigned int i = 0; i < body.Parts().count();++i) { |
73 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); | 73 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); |
74 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); | 74 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); |
75 | for (;it!=body.Parts()[i].Parameters().end();++it) { | 75 | for (;it!=body.Parts()[i].Parameters().end();++it) { |
76 | if (it.key().lower()=="name") { | 76 | if (it.key().lower()=="name") { |
77 | filename=it.data(); | 77 | filename=it.data(); |
78 | } | 78 | } |
79 | } | 79 | } |
80 | s = body.Parts()[i].Size(); | 80 | s = body.Parts()[i].Size(); |
81 | w = 0; | 81 | w = 0; |
82 | while (s>1024) { | 82 | while (s>1024) { |
83 | s/=1024; | 83 | s/=1024; |
84 | ++w; | 84 | ++w; |
85 | if (w>=2) break; | 85 | if (w>=2) break; |
86 | } | 86 | } |
87 | switch(w) { | 87 | switch(w) { |
88 | case 1: | 88 | case 1: |
89 | q="k"; | 89 | q="k"; |
90 | break; | 90 | break; |
91 | case 2: | 91 | case 2: |
92 | q="M"; | 92 | q="M"; |
93 | break; | 93 | break; |
94 | default: | 94 | default: |
95 | q=""; | 95 | q=""; |
96 | break; | 96 | break; |
97 | } | 97 | } |
98 | QTextOStream o(&desc); | 98 | QTextOStream o(&desc); |
99 | if (w>0) o.precision(2); else o.precision(0); | 99 | if (w>0) o.precision(2); else o.precision(0); |
100 | o.setf(QTextStream::fixed); | 100 | o.setf(QTextStream::fixed); |
101 | o << s << " " << q << "Byte"; | 101 | o << s << " " << q << "Byte"; |
102 | curItem=new AttachItem(attachments,curItem,type,filename,desc,i); | 102 | curItem=new AttachItem(attachments,curItem,type,filename,desc,i); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int c ) { | 106 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int c ) { |
107 | if (!item ) | 107 | if (!item ) |
108 | return; | 108 | return; |
109 | 109 | ||
110 | QPopupMenu *menu = new QPopupMenu(); | 110 | QPopupMenu *menu = new QPopupMenu(); |
111 | int ret=0; | 111 | int ret=0; |
112 | 112 | ||
113 | if ( item->text( 0 ).left( 4 ) == "text" ) { | 113 | if ( item->text( 0 ).left( 4 ) == "text" ) { |
114 | menu->insertItem( tr( "Show Text" ), 1 ); | 114 | menu->insertItem( tr( "Show Text" ), 1 ); |
115 | } | 115 | } |
116 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 116 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
117 | menu->insertSeparator(1); | 117 | menu->insertSeparator(1); |
118 | 118 | ||
119 | ret = menu->exec( point, 0 ); | 119 | ret = menu->exec( point, 0 ); |
120 | 120 | ||
121 | switch(ret) { | 121 | switch(ret) { |
122 | case 0: | 122 | case 0: |
123 | { MimeTypes types; | 123 | { MimeTypes types; |
124 | types.insert( "all", "*" ); | 124 | types.insert( "all", "*" ); |
125 | QString str = OFileDialog::getSaveFileName( 1, | 125 | QString str = OFileDialog::getSaveFileName( 1, |
126 | "/", item->text( 1 ) , types, 0 ); | 126 | "/", item->text( 1 ) , types, 0 ); |
127 | 127 | ||
128 | if( !str.isEmpty() ) { | 128 | if( !str.isEmpty() ) { |
129 | qDebug( "first we will need a MIME wrapper" ); | 129 | qDebug( "first we will need a MIME wrapper" ); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | break ; | 132 | break ; |
133 | 133 | ||
134 | case 1: | 134 | case 1: |
135 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { | 135 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { |
136 | setText(); | 136 | setText(); |
137 | } else { | 137 | } else { |
138 | if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions | 138 | if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions |
139 | browser->setText( m_recMail.Wrapper()->fetchPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 139 | browser->setText( m_recMail.Wrapper()->fetchPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | break; | 142 | break; |
143 | } | 143 | } |
144 | delete menu; | 144 | delete menu; |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | void ViewMail::setMail( RecMail mail ) { | 148 | void ViewMail::setMail( RecMail mail ) { |
149 | 149 | ||
150 | m_recMail = mail; | 150 | m_recMail = mail; |
151 | 151 | ||
152 | m_mail[0] = mail.getFrom(); | 152 | m_mail[0] = mail.getFrom(); |
153 | m_mail[1] = mail.getSubject(); | 153 | m_mail[1] = mail.getSubject(); |
154 | m_mail[3] = mail.getDate(); | 154 | m_mail[3] = mail.getDate(); |
155 | m_mail[4] = mail.Msgid(); | 155 | m_mail[4] = mail.Msgid(); |
156 | 156 | ||
157 | m_mail2[0] = mail.To(); | 157 | m_mail2[0] = mail.To(); |
158 | m_mail2[1] = mail.CC(); | 158 | m_mail2[1] = mail.CC(); |
159 | m_mail2[2] = mail.Bcc(); | 159 | m_mail2[2] = mail.Bcc(); |
160 | 160 | ||
161 | setText(); | 161 | setText(); |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | 165 | ||
166 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 166 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
167 | : ViewMailBase(parent, name, fl), _inLoop(false) | 167 | : ViewMailBase(parent, name, fl), _inLoop(false) |
168 | { | 168 | { |
169 | m_gotBody = false; | 169 | m_gotBody = false; |
170 | 170 | ||
171 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); | 171 | connect(reply, SIGNAL(activated()), SLOT(slotReply())); |
172 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); | 172 | connect(forward, SIGNAL(activated()), SLOT(slotForward())); |
173 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); | 173 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); |
174 | 174 | ||
175 | attachments->setEnabled(m_gotBody); | 175 | attachments->setEnabled(m_gotBody); |
176 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); | 176 | connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); |
177 | 177 | ||
178 | } | 178 | } |
179 | 179 | ||
180 | void ViewMail::setText() | 180 | void ViewMail::setText() |
181 | { | 181 | { |
182 | 182 | ||
183 | QString toString; | 183 | QString toString; |
184 | QString ccString; | 184 | QString ccString; |
185 | QString bccString; | 185 | QString bccString; |
186 | 186 | ||
187 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { | 187 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { |
188 | toString += (*it); | 188 | toString += (*it); |
189 | } | 189 | } |
190 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { | 190 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { |
191 | ccString += (*it); | 191 | ccString += (*it); |
192 | } | 192 | } |
193 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { | 193 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { |
194 | bccString += (*it); | 194 | bccString += (*it); |