author | alwin <alwin> | 2004-03-19 01:04:35 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-19 01:04:35 (UTC) |
commit | 2c8db13612d37c941676b4033298afc8e757765d (patch) (unidiff) | |
tree | a1c2fa0817b00999f4b8f916978f78064c4355e1 | |
parent | 06a659114c19890a1875f22c62a96bdb908fd25f (diff) | |
download | opie-2c8db13612d37c941676b4033298afc8e757765d.zip opie-2c8db13612d37c941676b4033298afc8e757765d.tar.gz opie-2c8db13612d37c941676b4033298afc8e757765d.tar.bz2 |
set callbacks for pop3 and nntp but seems never be called
in imap qApp-processEvents() is called for avoiding gui blocking
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/nntpwrapper.cpp | 4 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/pop3wrapper.cpp | 6 |
3 files changed, 12 insertions, 0 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index 230cf53..657c2ba 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp | |||
@@ -1,169 +1,171 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <libetpan/libetpan.h> | 2 | #include <libetpan/libetpan.h> |
3 | #include <qpe/global.h> | 3 | #include <qpe/global.h> |
4 | #include <opie2/oapplication.h> | ||
4 | 5 | ||
5 | #include "imapwrapper.h" | 6 | #include "imapwrapper.h" |
6 | #include "mailtypes.h" | 7 | #include "mailtypes.h" |
7 | #include "logindialog.h" | 8 | #include "logindialog.h" |
8 | 9 | ||
9 | using namespace Opie::Core; | 10 | using namespace Opie::Core; |
10 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 11 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
11 | : AbstractMail() | 12 | : AbstractMail() |
12 | { | 13 | { |
13 | account = a; | 14 | account = a; |
14 | m_imap = 0; | 15 | m_imap = 0; |
15 | m_Lastmbox = ""; | 16 | m_Lastmbox = ""; |
16 | } | 17 | } |
17 | 18 | ||
18 | IMAPwrapper::~IMAPwrapper() | 19 | IMAPwrapper::~IMAPwrapper() |
19 | { | 20 | { |
20 | logout(); | 21 | logout(); |
21 | } | 22 | } |
22 | 23 | ||
23 | /* to avoid to often select statements in loops etc. | 24 | /* to avoid to often select statements in loops etc. |
24 | we trust that we are logged in and connection is established!*/ | 25 | we trust that we are logged in and connection is established!*/ |
25 | int IMAPwrapper::selectMbox(const QString&mbox) | 26 | int IMAPwrapper::selectMbox(const QString&mbox) |
26 | { | 27 | { |
27 | if (mbox == m_Lastmbox) { | 28 | if (mbox == m_Lastmbox) { |
28 | return MAILIMAP_NO_ERROR; | 29 | return MAILIMAP_NO_ERROR; |
29 | } | 30 | } |
30 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 31 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
31 | if ( err != MAILIMAP_NO_ERROR ) { | 32 | if ( err != MAILIMAP_NO_ERROR ) { |
32 | qDebug("error selecting mailbox: %s",m_imap->imap_response); | 33 | qDebug("error selecting mailbox: %s",m_imap->imap_response); |
33 | m_Lastmbox = ""; | 34 | m_Lastmbox = ""; |
34 | return err; | 35 | return err; |
35 | } | 36 | } |
36 | m_Lastmbox = mbox; | 37 | m_Lastmbox = mbox; |
37 | return err; | 38 | return err; |
38 | } | 39 | } |
39 | 40 | ||
40 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 41 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
41 | { | 42 | { |
43 | qApp->processEvents(); | ||
42 | qDebug( "IMAP: %i of %i", current, maximum ); | 44 | qDebug( "IMAP: %i of %i", current, maximum ); |
43 | } | 45 | } |
44 | 46 | ||
45 | bool IMAPwrapper::start_tls(bool force_tls) | 47 | bool IMAPwrapper::start_tls(bool force_tls) |
46 | { | 48 | { |
47 | int err; | 49 | int err; |
48 | bool try_tls; | 50 | bool try_tls; |
49 | mailimap_capability_data * cap_data = 0; | 51 | mailimap_capability_data * cap_data = 0; |
50 | 52 | ||
51 | err = mailimap_capability(m_imap,&cap_data); | 53 | err = mailimap_capability(m_imap,&cap_data); |
52 | if (err != MAILIMAP_NO_ERROR) { | 54 | if (err != MAILIMAP_NO_ERROR) { |
53 | Global::statusMessage("error getting capabilities!"); | 55 | Global::statusMessage("error getting capabilities!"); |
54 | qDebug("error getting capabilities!"); | 56 | qDebug("error getting capabilities!"); |
55 | return false; | 57 | return false; |
56 | } | 58 | } |
57 | clistiter * cur; | 59 | clistiter * cur; |
58 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 60 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
59 | struct mailimap_capability * cap; | 61 | struct mailimap_capability * cap; |
60 | cap = (struct mailimap_capability *)clist_content(cur); | 62 | cap = (struct mailimap_capability *)clist_content(cur); |
61 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 63 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
62 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 64 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
63 | try_tls = true; | 65 | try_tls = true; |
64 | break; | 66 | break; |
65 | } | 67 | } |
66 | } | 68 | } |
67 | } | 69 | } |
68 | if (cap_data) { | 70 | if (cap_data) { |
69 | mailimap_capability_data_free(cap_data); | 71 | mailimap_capability_data_free(cap_data); |
70 | } | 72 | } |
71 | if (try_tls) { | 73 | if (try_tls) { |
72 | err = mailimap_starttls(m_imap); | 74 | err = mailimap_starttls(m_imap); |
73 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 75 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
74 | Global::statusMessage(tr("Server has no TLS support!")); | 76 | Global::statusMessage(tr("Server has no TLS support!")); |
75 | qDebug("Server has no TLS support!"); | 77 | qDebug("Server has no TLS support!"); |
76 | try_tls = false; | 78 | try_tls = false; |
77 | } else { | 79 | } else { |
78 | mailstream_low * low; | 80 | mailstream_low * low; |
79 | mailstream_low * new_low; | 81 | mailstream_low * new_low; |
80 | low = mailstream_get_low(m_imap->imap_stream); | 82 | low = mailstream_get_low(m_imap->imap_stream); |
81 | if (!low) { | 83 | if (!low) { |
82 | try_tls = false; | 84 | try_tls = false; |
83 | } else { | 85 | } else { |
84 | int fd = mailstream_low_get_fd(low); | 86 | int fd = mailstream_low_get_fd(low); |
85 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 87 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
86 | mailstream_low_free(low); | 88 | mailstream_low_free(low); |
87 | mailstream_set_low(m_imap->imap_stream, new_low); | 89 | mailstream_set_low(m_imap->imap_stream, new_low); |
88 | } else { | 90 | } else { |
89 | try_tls = false; | 91 | try_tls = false; |
90 | } | 92 | } |
91 | } | 93 | } |
92 | } | 94 | } |
93 | } | 95 | } |
94 | return try_tls; | 96 | return try_tls; |
95 | } | 97 | } |
96 | 98 | ||
97 | void IMAPwrapper::login() | 99 | void IMAPwrapper::login() |
98 | { | 100 | { |
99 | const char *server, *user, *pass; | 101 | const char *server, *user, *pass; |
100 | uint16_t port; | 102 | uint16_t port; |
101 | int err = MAILIMAP_NO_ERROR; | 103 | int err = MAILIMAP_NO_ERROR; |
102 | 104 | ||
103 | if (account->getOffline()) return; | 105 | if (account->getOffline()) return; |
104 | /* we are connected this moment */ | 106 | /* we are connected this moment */ |
105 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 107 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
106 | if (m_imap) { | 108 | if (m_imap) { |
107 | err = mailimap_noop(m_imap); | 109 | err = mailimap_noop(m_imap); |
108 | if (err!=MAILIMAP_NO_ERROR) { | 110 | if (err!=MAILIMAP_NO_ERROR) { |
109 | logout(); | 111 | logout(); |
110 | } else { | 112 | } else { |
111 | mailstream_flush(m_imap->imap_stream); | 113 | mailstream_flush(m_imap->imap_stream); |
112 | return; | 114 | return; |
113 | } | 115 | } |
114 | } | 116 | } |
115 | server = account->getServer().latin1(); | 117 | server = account->getServer().latin1(); |
116 | port = account->getPort().toUInt(); | 118 | port = account->getPort().toUInt(); |
117 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 119 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
118 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 120 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
119 | login.show(); | 121 | login.show(); |
120 | if ( QDialog::Accepted == login.exec() ) { | 122 | if ( QDialog::Accepted == login.exec() ) { |
121 | // ok | 123 | // ok |
122 | user = login.getUser().latin1(); | 124 | user = login.getUser().latin1(); |
123 | pass = login.getPassword().latin1(); | 125 | pass = login.getPassword().latin1(); |
124 | } else { | 126 | } else { |
125 | // cancel | 127 | // cancel |
126 | qDebug( "IMAP: Login canceled" ); | 128 | qDebug( "IMAP: Login canceled" ); |
127 | return; | 129 | return; |
128 | } | 130 | } |
129 | } else { | 131 | } else { |
130 | user = account->getUser().latin1(); | 132 | user = account->getUser().latin1(); |
131 | pass = account->getPassword().latin1(); | 133 | pass = account->getPassword().latin1(); |
132 | } | 134 | } |
133 | 135 | ||
134 | m_imap = mailimap_new( 20, &imap_progress ); | 136 | m_imap = mailimap_new( 20, &imap_progress ); |
135 | 137 | ||
136 | /* connect */ | 138 | /* connect */ |
137 | bool ssl = false; | 139 | bool ssl = false; |
138 | bool try_tls = false; | 140 | bool try_tls = false; |
139 | bool force_tls = false; | 141 | bool force_tls = false; |
140 | 142 | ||
141 | if ( account->ConnectionType() == 2 ) { | 143 | if ( account->ConnectionType() == 2 ) { |
142 | ssl = true; | 144 | ssl = true; |
143 | } | 145 | } |
144 | if (account->ConnectionType()==1) { | 146 | if (account->ConnectionType()==1) { |
145 | force_tls = true; | 147 | force_tls = true; |
146 | } | 148 | } |
147 | 149 | ||
148 | if ( ssl ) { | 150 | if ( ssl ) { |
149 | qDebug( "using ssl" ); | 151 | qDebug( "using ssl" ); |
150 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); | 152 | err = mailimap_ssl_connect( m_imap, (char*)server, port ); |
151 | } else { | 153 | } else { |
152 | err = mailimap_socket_connect( m_imap, (char*)server, port ); | 154 | err = mailimap_socket_connect( m_imap, (char*)server, port ); |
153 | } | 155 | } |
154 | 156 | ||
155 | if ( err != MAILIMAP_NO_ERROR && | 157 | if ( err != MAILIMAP_NO_ERROR && |
156 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && | 158 | err != MAILIMAP_NO_ERROR_AUTHENTICATED && |
157 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { | 159 | err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { |
158 | QString failure = ""; | 160 | QString failure = ""; |
159 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { | 161 | if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { |
160 | failure="Connection refused"; | 162 | failure="Connection refused"; |
161 | } else { | 163 | } else { |
162 | failure="Unknown failure"; | 164 | failure="Unknown failure"; |
163 | } | 165 | } |
164 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); | 166 | Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); |
165 | mailimap_free( m_imap ); | 167 | mailimap_free( m_imap ); |
166 | m_imap = 0; | 168 | m_imap = 0; |
167 | return; | 169 | return; |
168 | } | 170 | } |
169 | 171 | ||
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp index cc36f32..cfded43 100644 --- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp | |||
@@ -51,234 +51,238 @@ RecBodyP NNTPwrapper::fetchBody( const RecMailP &mail ) { | |||
51 | } | 51 | } |
52 | 52 | ||
53 | QFile msg_cache(msgTempName); | 53 | QFile msg_cache(msgTempName); |
54 | 54 | ||
55 | cleanMimeCache(); | 55 | cleanMimeCache(); |
56 | 56 | ||
57 | if (mail->getNumber()!=last_msg_id) { | 57 | if (mail->getNumber()!=last_msg_id) { |
58 | if (msg_cache.exists()) { | 58 | if (msg_cache.exists()) { |
59 | msg_cache.remove(); | 59 | msg_cache.remove(); |
60 | } | 60 | } |
61 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 61 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
62 | last_msg_id = mail->getNumber(); | 62 | last_msg_id = mail->getNumber(); |
63 | err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); | 63 | err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); |
64 | err = mailmessage_fetch(mailmsg,&message,&length); | 64 | err = mailmessage_fetch(mailmsg,&message,&length); |
65 | msg_cache.writeBlock(message,length); | 65 | msg_cache.writeBlock(message,length); |
66 | } else { | 66 | } else { |
67 | QString msg=""; | 67 | QString msg=""; |
68 | msg_cache.open(IO_ReadOnly); | 68 | msg_cache.open(IO_ReadOnly); |
69 | message = new char[4096]; | 69 | message = new char[4096]; |
70 | memset(message,0,4096); | 70 | memset(message,0,4096); |
71 | while (msg_cache.readBlock(message,4095)>0) { | 71 | while (msg_cache.readBlock(message,4095)>0) { |
72 | msg+=message; | 72 | msg+=message; |
73 | memset(message,0,4096); | 73 | memset(message,0,4096); |
74 | } | 74 | } |
75 | delete message; | 75 | delete message; |
76 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 76 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
77 | memset(message,0,msg.length()+1); | 77 | memset(message,0,msg.length()+1); |
78 | memcpy(message,msg.latin1(),msg.length()); | 78 | memcpy(message,msg.latin1(),msg.length()); |
79 | /* transform to libetpan stuff */ | 79 | /* transform to libetpan stuff */ |
80 | mailmsg = mailmessage_new(); | 80 | mailmsg = mailmessage_new(); |
81 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 81 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
82 | generic_message_t * msg_data; | 82 | generic_message_t * msg_data; |
83 | msg_data = (generic_message_t *)mailmsg->msg_data; | 83 | msg_data = (generic_message_t *)mailmsg->msg_data; |
84 | msg_data->msg_fetched = 1; | 84 | msg_data->msg_fetched = 1; |
85 | msg_data->msg_message = message; | 85 | msg_data->msg_message = message; |
86 | msg_data->msg_length = strlen(message); | 86 | msg_data->msg_length = strlen(message); |
87 | } | 87 | } |
88 | body = parseMail(mailmsg); | 88 | body = parseMail(mailmsg); |
89 | 89 | ||
90 | /* clean up */ | 90 | /* clean up */ |
91 | if (mailmsg) | 91 | if (mailmsg) |
92 | mailmessage_free(mailmsg); | 92 | mailmessage_free(mailmsg); |
93 | if (message) | 93 | if (message) |
94 | free(message); | 94 | free(message); |
95 | 95 | ||
96 | return body; | 96 | return body; |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) | 100 | void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
101 | { | 101 | { |
102 | login(); | 102 | login(); |
103 | if (!m_nntp) | 103 | if (!m_nntp) |
104 | return; | 104 | return; |
105 | uint32_t res_messages,res_recent,res_unseen; | 105 | uint32_t res_messages,res_recent,res_unseen; |
106 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); | 106 | mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); |
107 | parseList(target,m_nntp->sto_session,which,true); | 107 | parseList(target,m_nntp->sto_session,which,true); |
108 | } | 108 | } |
109 | 109 | ||
110 | void NNTPwrapper::login() | 110 | void NNTPwrapper::login() |
111 | { | 111 | { |
112 | if (account->getOffline()) | 112 | if (account->getOffline()) |
113 | return; | 113 | return; |
114 | /* we'll hold the line */ | 114 | /* we'll hold the line */ |
115 | if ( m_nntp != NULL ) | 115 | if ( m_nntp != NULL ) |
116 | return; | 116 | return; |
117 | 117 | ||
118 | const char *server, *user, *pass; | 118 | const char *server, *user, *pass; |
119 | QString User,Pass; | 119 | QString User,Pass; |
120 | uint16_t port; | 120 | uint16_t port; |
121 | int err = NEWSNNTP_NO_ERROR; | 121 | int err = NEWSNNTP_NO_ERROR; |
122 | 122 | ||
123 | server = account->getServer().latin1(); | 123 | server = account->getServer().latin1(); |
124 | port = account->getPort().toUInt(); | 124 | port = account->getPort().toUInt(); |
125 | 125 | ||
126 | user = pass = 0; | 126 | user = pass = 0; |
127 | 127 | ||
128 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { | 128 | if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { |
129 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 129 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
130 | login.show(); | 130 | login.show(); |
131 | if ( QDialog::Accepted == login.exec() ) { | 131 | if ( QDialog::Accepted == login.exec() ) { |
132 | // ok | 132 | // ok |
133 | User = login.getUser().latin1(); | 133 | User = login.getUser().latin1(); |
134 | Pass = login.getPassword().latin1(); | 134 | Pass = login.getPassword().latin1(); |
135 | } else { | 135 | } else { |
136 | // cancel | 136 | // cancel |
137 | qDebug( "NNTP: Login canceled" ); | 137 | qDebug( "NNTP: Login canceled" ); |
138 | return; | 138 | return; |
139 | } | 139 | } |
140 | } else { | 140 | } else { |
141 | User = account->getUser().latin1(); | 141 | User = account->getUser().latin1(); |
142 | Pass = account->getPassword().latin1(); | 142 | Pass = account->getPassword().latin1(); |
143 | } | 143 | } |
144 | 144 | ||
145 | if (User.isEmpty()) { | 145 | if (User.isEmpty()) { |
146 | user=0; | 146 | user=0; |
147 | pass = 0; | 147 | pass = 0; |
148 | } else { | 148 | } else { |
149 | user=User.latin1(); | 149 | user=User.latin1(); |
150 | pass=Pass.latin1(); | 150 | pass=Pass.latin1(); |
151 | } | 151 | } |
152 | // bool ssl = account->getSSL(); | 152 | // bool ssl = account->getSSL(); |
153 | 153 | ||
154 | m_nntp=mailstorage_new(NULL); | 154 | m_nntp=mailstorage_new(NULL); |
155 | 155 | ||
156 | int conntypeset = account->ConnectionType(); | 156 | int conntypeset = account->ConnectionType(); |
157 | int conntype = 0; | 157 | int conntype = 0; |
158 | if ( conntypeset == 3 ) { | 158 | if ( conntypeset == 3 ) { |
159 | conntype = CONNECTION_TYPE_COMMAND; | 159 | conntype = CONNECTION_TYPE_COMMAND; |
160 | } else if ( conntypeset == 2 ) { | 160 | } else if ( conntypeset == 2 ) { |
161 | conntype = CONNECTION_TYPE_TLS; | 161 | conntype = CONNECTION_TYPE_TLS; |
162 | } else if ( conntypeset == 1 ) { | 162 | } else if ( conntypeset == 1 ) { |
163 | conntype = CONNECTION_TYPE_STARTTLS; | 163 | conntype = CONNECTION_TYPE_STARTTLS; |
164 | } else if ( conntypeset == 0 ) { | 164 | } else if ( conntypeset == 0 ) { |
165 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 165 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
166 | } | 166 | } |
167 | 167 | ||
168 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, | 168 | nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, |
169 | (char*)user,(char*)pass,0,0,0); | 169 | (char*)user,(char*)pass,0,0,0); |
170 | 170 | ||
171 | err = mailstorage_connect( m_nntp ); | 171 | err = mailstorage_connect( m_nntp ); |
172 | 172 | ||
173 | if (err != NEWSNNTP_NO_ERROR) { | 173 | if (err != NEWSNNTP_NO_ERROR) { |
174 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); | 174 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); |
175 | // Global::statusMessage(tr("Error initializing folder")); | 175 | // Global::statusMessage(tr("Error initializing folder")); |
176 | mailstorage_free(m_nntp); | 176 | mailstorage_free(m_nntp); |
177 | m_nntp = 0; | 177 | m_nntp = 0; |
178 | 178 | ||
179 | } else { | ||
180 | mailsession * session = m_nntp->sto_session; | ||
181 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; | ||
182 | news->nntp_progr_fun = &nntp_progress; | ||
179 | } | 183 | } |
180 | 184 | ||
181 | } | 185 | } |
182 | 186 | ||
183 | void NNTPwrapper::logout() | 187 | void NNTPwrapper::logout() |
184 | { | 188 | { |
185 | int err = NEWSNNTP_NO_ERROR; | 189 | int err = NEWSNNTP_NO_ERROR; |
186 | if ( m_nntp == NULL ) | 190 | if ( m_nntp == NULL ) |
187 | return; | 191 | return; |
188 | mailstorage_free(m_nntp); | 192 | mailstorage_free(m_nntp); |
189 | m_nntp = 0; | 193 | m_nntp = 0; |
190 | } | 194 | } |
191 | 195 | ||
192 | QValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { | 196 | QValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { |
193 | 197 | ||
194 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); | 198 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); |
195 | QStringList groups; | 199 | QStringList groups; |
196 | if (account) { | 200 | if (account) { |
197 | groups = account->getGroups(); | 201 | groups = account->getGroups(); |
198 | } | 202 | } |
199 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { | 203 | for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { |
200 | folders->append(new Folder((*it),".")); | 204 | folders->append(new Folder((*it),".")); |
201 | } | 205 | } |
202 | return folders; | 206 | return folders; |
203 | } | 207 | } |
204 | 208 | ||
205 | /* we made this method in raw nntp access of etpan and not via generic interface | 209 | /* we made this method in raw nntp access of etpan and not via generic interface |
206 | * 'cause in that case there will be doubled copy operations. eg. the etpan would | 210 | * 'cause in that case there will be doubled copy operations. eg. the etpan would |
207 | * copy that stuff into its own structures and we must copy it into useable c++ | 211 | * copy that stuff into its own structures and we must copy it into useable c++ |
208 | * structures for our frontend. this would not make sense, so it is better to reimplement | 212 | * structures for our frontend. this would not make sense, so it is better to reimplement |
209 | * the stuff from generic interface of etpan but copy it direct to qt classes. | 213 | * the stuff from generic interface of etpan but copy it direct to qt classes. |
210 | */ | 214 | */ |
211 | QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { | 215 | QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { |
212 | login(); | 216 | login(); |
213 | QStringList res; | 217 | QStringList res; |
214 | clist *result = 0; | 218 | clist *result = 0; |
215 | clistcell *current = 0; | 219 | clistcell *current = 0; |
216 | newsnntp_group_description *group; | 220 | newsnntp_group_description *group; |
217 | 221 | ||
218 | if ( m_nntp ) { | 222 | if ( m_nntp ) { |
219 | mailsession * session = m_nntp->sto_session; | 223 | mailsession * session = m_nntp->sto_session; |
220 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; | 224 | newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; |
221 | int err = NEWSNNTP_NO_ERROR; | 225 | int err = NEWSNNTP_NO_ERROR; |
222 | if (mask.isEmpty()) { | 226 | if (mask.isEmpty()) { |
223 | err = newsnntp_list(news, &result); | 227 | err = newsnntp_list(news, &result); |
224 | } else { | 228 | } else { |
225 | /* taken from generic wrapper of etpan */ | 229 | /* taken from generic wrapper of etpan */ |
226 | QString nmask = mask+".*"; | 230 | QString nmask = mask+".*"; |
227 | err = newsnntp_list_active(news, nmask.latin1(), &result); | 231 | err = newsnntp_list_active(news, nmask.latin1(), &result); |
228 | } | 232 | } |
229 | if ( err == NEWSNNTP_NO_ERROR && result) { | 233 | if ( err == NEWSNNTP_NO_ERROR && result) { |
230 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current) ) { | 234 | for ( current=clist_begin(result);current!=NULL;current=clist_next(current) ) { |
231 | group = ( newsnntp_group_description* ) current->data; | 235 | group = ( newsnntp_group_description* ) current->data; |
232 | if (!group||!group->grp_name||strlen(group->grp_name)==0) continue; | 236 | if (!group||!group->grp_name||strlen(group->grp_name)==0) continue; |
233 | res.append(group->grp_name); | 237 | res.append(group->grp_name); |
234 | } | 238 | } |
235 | } | 239 | } |
236 | } | 240 | } |
237 | if (result) { | 241 | if (result) { |
238 | newsnntp_list_free(result); | 242 | newsnntp_list_free(result); |
239 | } | 243 | } |
240 | return res; | 244 | return res; |
241 | } | 245 | } |
242 | 246 | ||
243 | void NNTPwrapper::answeredMail(const RecMailP&) {} | 247 | void NNTPwrapper::answeredMail(const RecMailP&) {} |
244 | 248 | ||
245 | void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { | 249 | void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { |
246 | login(); | 250 | login(); |
247 | target_stat.message_count = 0; | 251 | target_stat.message_count = 0; |
248 | target_stat.message_unseen = 0; | 252 | target_stat.message_unseen = 0; |
249 | target_stat.message_recent = 0; | 253 | target_stat.message_recent = 0; |
250 | if (!m_nntp) | 254 | if (!m_nntp) |
251 | return; | 255 | return; |
252 | int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, | 256 | int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, |
253 | &target_stat.message_recent,&target_stat.message_unseen); | 257 | &target_stat.message_recent,&target_stat.message_unseen); |
254 | } | 258 | } |
255 | 259 | ||
256 | 260 | ||
257 | encodedString* NNTPwrapper::fetchRawBody(const RecMailP&mail) { | 261 | encodedString* NNTPwrapper::fetchRawBody(const RecMailP&mail) { |
258 | char*target=0; | 262 | char*target=0; |
259 | size_t length=0; | 263 | size_t length=0; |
260 | encodedString*res = 0; | 264 | encodedString*res = 0; |
261 | mailmessage * mailmsg = 0; | 265 | mailmessage * mailmsg = 0; |
262 | int err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); | 266 | int err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); |
263 | err = mailmessage_fetch(mailmsg,&target,&length); | 267 | err = mailmessage_fetch(mailmsg,&target,&length); |
264 | if (mailmsg) | 268 | if (mailmsg) |
265 | mailmessage_free(mailmsg); | 269 | mailmessage_free(mailmsg); |
266 | if (target) { | 270 | if (target) { |
267 | res = new encodedString(target,length); | 271 | res = new encodedString(target,length); |
268 | } | 272 | } |
269 | return res; | 273 | return res; |
270 | } | 274 | } |
271 | 275 | ||
272 | MAILLIB::ATYPE NNTPwrapper::getType()const { | 276 | MAILLIB::ATYPE NNTPwrapper::getType()const { |
273 | return account->getType(); | 277 | return account->getType(); |
274 | } | 278 | } |
275 | 279 | ||
276 | const QString&NNTPwrapper::getName()const{ | 280 | const QString&NNTPwrapper::getName()const{ |
277 | return account->getAccountName(); | 281 | return account->getAccountName(); |
278 | } | 282 | } |
279 | 283 | ||
280 | void NNTPwrapper::deleteMail(const RecMailP&) { | 284 | void NNTPwrapper::deleteMail(const RecMailP&) { |
281 | } | 285 | } |
282 | 286 | ||
283 | int NNTPwrapper::deleteAllMail(const FolderP&) { | 287 | int NNTPwrapper::deleteAllMail(const FolderP&) { |
284 | } | 288 | } |
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp index 1b7a1b4..5467547 100644 --- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp +++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp | |||
@@ -41,218 +41,224 @@ RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) { | |||
41 | login(); | 41 | login(); |
42 | if ( !m_pop3 ) { | 42 | if ( !m_pop3 ) { |
43 | return body; | 43 | return body; |
44 | } | 44 | } |
45 | 45 | ||
46 | mailmessage * mailmsg; | 46 | mailmessage * mailmsg; |
47 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { | 47 | if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { |
48 | qDebug("Message to large: %i",mail->Msgsize()); | 48 | qDebug("Message to large: %i",mail->Msgsize()); |
49 | return body; | 49 | return body; |
50 | } | 50 | } |
51 | 51 | ||
52 | QFile msg_cache(msgTempName); | 52 | QFile msg_cache(msgTempName); |
53 | 53 | ||
54 | cleanMimeCache(); | 54 | cleanMimeCache(); |
55 | 55 | ||
56 | if (mail->getNumber()!=last_msg_id) { | 56 | if (mail->getNumber()!=last_msg_id) { |
57 | if (msg_cache.exists()) { | 57 | if (msg_cache.exists()) { |
58 | msg_cache.remove(); | 58 | msg_cache.remove(); |
59 | } | 59 | } |
60 | msg_cache.open(IO_ReadWrite|IO_Truncate); | 60 | msg_cache.open(IO_ReadWrite|IO_Truncate); |
61 | last_msg_id = mail->getNumber(); | 61 | last_msg_id = mail->getNumber(); |
62 | err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); | 62 | err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); |
63 | err = mailmessage_fetch(mailmsg,&message,&length); | 63 | err = mailmessage_fetch(mailmsg,&message,&length); |
64 | msg_cache.writeBlock(message,length); | 64 | msg_cache.writeBlock(message,length); |
65 | } else { | 65 | } else { |
66 | QString msg=""; | 66 | QString msg=""; |
67 | msg_cache.open(IO_ReadOnly); | 67 | msg_cache.open(IO_ReadOnly); |
68 | message = new char[4096]; | 68 | message = new char[4096]; |
69 | memset(message,0,4096); | 69 | memset(message,0,4096); |
70 | while (msg_cache.readBlock(message,4095)>0) { | 70 | while (msg_cache.readBlock(message,4095)>0) { |
71 | msg+=message; | 71 | msg+=message; |
72 | memset(message,0,4096); | 72 | memset(message,0,4096); |
73 | } | 73 | } |
74 | delete message; | 74 | delete message; |
75 | message = (char*)malloc(msg.length()+1*sizeof(char)); | 75 | message = (char*)malloc(msg.length()+1*sizeof(char)); |
76 | memset(message,0,msg.length()+1); | 76 | memset(message,0,msg.length()+1); |
77 | memcpy(message,msg.latin1(),msg.length()); | 77 | memcpy(message,msg.latin1(),msg.length()); |
78 | /* transform to libetpan stuff */ | 78 | /* transform to libetpan stuff */ |
79 | mailmsg = mailmessage_new(); | 79 | mailmsg = mailmessage_new(); |
80 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); | 80 | mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); |
81 | generic_message_t * msg_data; | 81 | generic_message_t * msg_data; |
82 | msg_data = (generic_message_t *)mailmsg->msg_data; | 82 | msg_data = (generic_message_t *)mailmsg->msg_data; |
83 | msg_data->msg_fetched = 1; | 83 | msg_data->msg_fetched = 1; |
84 | msg_data->msg_message = message; | 84 | msg_data->msg_message = message; |
85 | msg_data->msg_length = strlen(message); | 85 | msg_data->msg_length = strlen(message); |
86 | } | 86 | } |
87 | body = parseMail(mailmsg); | 87 | body = parseMail(mailmsg); |
88 | 88 | ||
89 | /* clean up */ | 89 | /* clean up */ |
90 | if (mailmsg) | 90 | if (mailmsg) |
91 | mailmessage_free(mailmsg); | 91 | mailmessage_free(mailmsg); |
92 | if (message) | 92 | if (message) |
93 | free(message); | 93 | free(message); |
94 | 94 | ||
95 | return body; | 95 | return body; |
96 | } | 96 | } |
97 | 97 | ||
98 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) | 98 | void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) |
99 | { | 99 | { |
100 | login(); | 100 | login(); |
101 | if (!m_pop3) | 101 | if (!m_pop3) |
102 | return; | 102 | return; |
103 | uint32_t res_messages,res_recent,res_unseen; | 103 | uint32_t res_messages,res_recent,res_unseen; |
104 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); | 104 | mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); |
105 | parseList(target,m_pop3->sto_session,"INBOX"); | 105 | parseList(target,m_pop3->sto_session,"INBOX"); |
106 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); | 106 | Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); |
107 | } | 107 | } |
108 | 108 | ||
109 | void POP3wrapper::login() | 109 | void POP3wrapper::login() |
110 | { | 110 | { |
111 | if (account->getOffline()) | 111 | if (account->getOffline()) |
112 | return; | 112 | return; |
113 | /* we'll hold the line */ | 113 | /* we'll hold the line */ |
114 | if ( m_pop3 != NULL ) | 114 | if ( m_pop3 != NULL ) |
115 | return; | 115 | return; |
116 | 116 | ||
117 | const char *server, *user, *pass; | 117 | const char *server, *user, *pass; |
118 | uint16_t port; | 118 | uint16_t port; |
119 | int err = MAILPOP3_NO_ERROR; | 119 | int err = MAILPOP3_NO_ERROR; |
120 | 120 | ||
121 | server = account->getServer().latin1(); | 121 | server = account->getServer().latin1(); |
122 | port = account->getPort().toUInt(); | 122 | port = account->getPort().toUInt(); |
123 | 123 | ||
124 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { | 124 | if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { |
125 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); | 125 | LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); |
126 | login.show(); | 126 | login.show(); |
127 | if ( QDialog::Accepted == login.exec() ) { | 127 | if ( QDialog::Accepted == login.exec() ) { |
128 | // ok | 128 | // ok |
129 | user = login.getUser().latin1(); | 129 | user = login.getUser().latin1(); |
130 | pass = login.getPassword().latin1(); | 130 | pass = login.getPassword().latin1(); |
131 | } else { | 131 | } else { |
132 | // cancel | 132 | // cancel |
133 | qDebug( "POP3: Login canceled" ); | 133 | qDebug( "POP3: Login canceled" ); |
134 | return; | 134 | return; |
135 | } | 135 | } |
136 | } else { | 136 | } else { |
137 | user = account->getUser().latin1(); | 137 | user = account->getUser().latin1(); |
138 | pass = account->getPassword().latin1(); | 138 | pass = account->getPassword().latin1(); |
139 | } | 139 | } |
140 | 140 | ||
141 | // bool ssl = account->getSSL(); | 141 | // bool ssl = account->getSSL(); |
142 | 142 | ||
143 | m_pop3=mailstorage_new(NULL); | 143 | m_pop3=mailstorage_new(NULL); |
144 | 144 | ||
145 | int conntypeset = account->ConnectionType(); | 145 | int conntypeset = account->ConnectionType(); |
146 | int conntype = 0; | 146 | int conntype = 0; |
147 | if ( conntypeset == 3 ) { | 147 | if ( conntypeset == 3 ) { |
148 | conntype = CONNECTION_TYPE_COMMAND; | 148 | conntype = CONNECTION_TYPE_COMMAND; |
149 | } else if ( conntypeset == 2 ) { | 149 | } else if ( conntypeset == 2 ) { |
150 | conntype = CONNECTION_TYPE_TLS; | 150 | conntype = CONNECTION_TYPE_TLS; |
151 | } else if ( conntypeset == 1 ) { | 151 | } else if ( conntypeset == 1 ) { |
152 | conntype = CONNECTION_TYPE_STARTTLS; | 152 | conntype = CONNECTION_TYPE_STARTTLS; |
153 | } else if ( conntypeset == 0 ) { | 153 | } else if ( conntypeset == 0 ) { |
154 | conntype = CONNECTION_TYPE_TRY_STARTTLS; | 154 | conntype = CONNECTION_TYPE_TRY_STARTTLS; |
155 | } | 155 | } |
156 | 156 | ||
157 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); | 157 | //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); |
158 | 158 | ||
159 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, | 159 | pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, |
160 | (char*)user,(char*)pass,0,0,0); | 160 | (char*)user,(char*)pass,0,0,0); |
161 | 161 | ||
162 | 162 | ||
163 | err = mailstorage_connect(m_pop3); | 163 | err = mailstorage_connect(m_pop3); |
164 | if (err != MAIL_NO_ERROR) { | 164 | if (err != MAIL_NO_ERROR) { |
165 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); | 165 | qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); |
166 | Global::statusMessage(tr("Error initializing folder")); | 166 | Global::statusMessage(tr("Error initializing folder")); |
167 | mailstorage_free(m_pop3); | 167 | mailstorage_free(m_pop3); |
168 | m_pop3 = 0; | 168 | m_pop3 = 0; |
169 | } else { | ||
170 | mailsession * session = m_pop3->sto_session; | ||
171 | mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; | ||
172 | if (mail) { | ||
173 | mail->pop3_progr_fun = &pop3_progress; | ||
174 | } | ||
169 | } | 175 | } |
170 | } | 176 | } |
171 | 177 | ||
172 | void POP3wrapper::logout() | 178 | void POP3wrapper::logout() |
173 | { | 179 | { |
174 | if ( m_pop3 == NULL ) | 180 | if ( m_pop3 == NULL ) |
175 | return; | 181 | return; |
176 | mailstorage_free(m_pop3); | 182 | mailstorage_free(m_pop3); |
177 | m_pop3 = 0; | 183 | m_pop3 = 0; |
178 | } | 184 | } |
179 | 185 | ||
180 | 186 | ||
181 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { | 187 | QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { |
182 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); | 188 | QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); |
183 | FolderP inb=new Folder("INBOX","/"); | 189 | FolderP inb=new Folder("INBOX","/"); |
184 | folders->append(inb); | 190 | folders->append(inb); |
185 | return folders; | 191 | return folders; |
186 | } | 192 | } |
187 | 193 | ||
188 | void POP3wrapper::deleteMail(const RecMailP&mail) { | 194 | void POP3wrapper::deleteMail(const RecMailP&mail) { |
189 | login(); | 195 | login(); |
190 | if (!m_pop3) | 196 | if (!m_pop3) |
191 | return; | 197 | return; |
192 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); | 198 | int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); |
193 | if (err != MAIL_NO_ERROR) { | 199 | if (err != MAIL_NO_ERROR) { |
194 | Global::statusMessage(tr("error deleting mail")); | 200 | Global::statusMessage(tr("error deleting mail")); |
195 | } | 201 | } |
196 | } | 202 | } |
197 | 203 | ||
198 | void POP3wrapper::answeredMail(const RecMailP&) {} | 204 | void POP3wrapper::answeredMail(const RecMailP&) {} |
199 | 205 | ||
200 | int POP3wrapper::deleteAllMail(const FolderP&) { | 206 | int POP3wrapper::deleteAllMail(const FolderP&) { |
201 | login(); | 207 | login(); |
202 | if (!m_pop3) | 208 | if (!m_pop3) |
203 | return 0; | 209 | return 0; |
204 | int res = 1; | 210 | int res = 1; |
205 | 211 | ||
206 | uint32_t result = 0; | 212 | uint32_t result = 0; |
207 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); | 213 | int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); |
208 | if (err != MAIL_NO_ERROR) { | 214 | if (err != MAIL_NO_ERROR) { |
209 | Global::statusMessage(tr("Error getting folder info")); | 215 | Global::statusMessage(tr("Error getting folder info")); |
210 | return 0; | 216 | return 0; |
211 | } | 217 | } |
212 | for (unsigned int i = 0; i < result; ++i) { | 218 | for (unsigned int i = 0; i < result; ++i) { |
213 | err = mailsession_remove_message(m_pop3->sto_session,i+1); | 219 | err = mailsession_remove_message(m_pop3->sto_session,i+1); |
214 | if (err != MAIL_NO_ERROR) { | 220 | if (err != MAIL_NO_ERROR) { |
215 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); | 221 | Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); |
216 | res=0; | 222 | res=0; |
217 | } | 223 | } |
218 | break; | 224 | break; |
219 | } | 225 | } |
220 | return res; | 226 | return res; |
221 | } | 227 | } |
222 | 228 | ||
223 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { | 229 | void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { |
224 | login(); | 230 | login(); |
225 | target_stat.message_count = 0; | 231 | target_stat.message_count = 0; |
226 | target_stat.message_unseen = 0; | 232 | target_stat.message_unseen = 0; |
227 | target_stat.message_recent = 0; | 233 | target_stat.message_recent = 0; |
228 | if (!m_pop3) | 234 | if (!m_pop3) |
229 | return; | 235 | return; |
230 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, | 236 | int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, |
231 | &target_stat.message_recent,&target_stat.message_unseen); | 237 | &target_stat.message_recent,&target_stat.message_unseen); |
232 | if (r != MAIL_NO_ERROR) { | 238 | if (r != MAIL_NO_ERROR) { |
233 | qDebug("error getting folter status."); | 239 | qDebug("error getting folter status."); |
234 | } | 240 | } |
235 | } | 241 | } |
236 | 242 | ||
237 | encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { | 243 | encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { |
238 | char*target=0; | 244 | char*target=0; |
239 | size_t length=0; | 245 | size_t length=0; |
240 | encodedString*res = 0; | 246 | encodedString*res = 0; |
241 | mailmessage * mailmsg = 0; | 247 | mailmessage * mailmsg = 0; |
242 | int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); | 248 | int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); |
243 | err = mailmessage_fetch(mailmsg,&target,&length); | 249 | err = mailmessage_fetch(mailmsg,&target,&length); |
244 | if (mailmsg) | 250 | if (mailmsg) |
245 | mailmessage_free(mailmsg); | 251 | mailmessage_free(mailmsg); |
246 | if (target) { | 252 | if (target) { |
247 | res = new encodedString(target,length); | 253 | res = new encodedString(target,length); |
248 | } | 254 | } |
249 | return res; | 255 | return res; |
250 | } | 256 | } |
251 | 257 | ||
252 | MAILLIB::ATYPE POP3wrapper::getType()const { | 258 | MAILLIB::ATYPE POP3wrapper::getType()const { |
253 | return account->getType(); | 259 | return account->getType(); |
254 | } | 260 | } |
255 | 261 | ||
256 | const QString&POP3wrapper::getName()const{ | 262 | const QString&POP3wrapper::getName()const{ |
257 | return account->getAccountName(); | 263 | return account->getAccountName(); |
258 | } | 264 | } |