summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp2
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.cpp4
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp6
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,89 +1,91 @@
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
9using namespace Opie::Core; 10using namespace Opie::Core;
10IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 11IMAPwrapper::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
18IMAPwrapper::~IMAPwrapper() 19IMAPwrapper::~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!*/
25int IMAPwrapper::selectMbox(const QString&mbox) 26int 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
40void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 41void 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
45bool IMAPwrapper::start_tls(bool force_tls) 47bool 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;
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
@@ -131,96 +131,100 @@ void NNTPwrapper::login()
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
183void NNTPwrapper::logout() 187void 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
192QValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { 196QValueList<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 */
211QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { 215QStringList 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+".*";
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
@@ -121,96 +121,102 @@ void POP3wrapper::login()
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
172void POP3wrapper::logout() 178void 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
181QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { 187QValueList<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
188void POP3wrapper::deleteMail(const RecMailP&mail) { 194void 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
198void POP3wrapper::answeredMail(const RecMailP&) {} 204void POP3wrapper::answeredMail(const RecMailP&) {}
199 205
200int POP3wrapper::deleteAllMail(const FolderP&) { 206int 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;