-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,89 +1,91 @@ #include <stdlib.h> #include <libetpan/libetpan.h> #include <qpe/global.h> +#include <opie2/oapplication.h> #include "imapwrapper.h" #include "mailtypes.h" #include "logindialog.h" using namespace Opie::Core; IMAPwrapper::IMAPwrapper( IMAPaccount *a ) : AbstractMail() { account = a; m_imap = 0; m_Lastmbox = ""; } IMAPwrapper::~IMAPwrapper() { logout(); } /* to avoid to often select statements in loops etc. we trust that we are logged in and connection is established!*/ int IMAPwrapper::selectMbox(const QString&mbox) { if (mbox == m_Lastmbox) { return MAILIMAP_NO_ERROR; } int err = mailimap_select( m_imap, (char*)mbox.latin1()); if ( err != MAILIMAP_NO_ERROR ) { qDebug("error selecting mailbox: %s",m_imap->imap_response); m_Lastmbox = ""; return err; } m_Lastmbox = mbox; return err; } void IMAPwrapper::imap_progress( size_t current, size_t maximum ) { + qApp->processEvents(); qDebug( "IMAP: %i of %i", current, maximum ); } bool IMAPwrapper::start_tls(bool force_tls) { int err; bool try_tls; mailimap_capability_data * cap_data = 0; err = mailimap_capability(m_imap,&cap_data); if (err != MAILIMAP_NO_ERROR) { Global::statusMessage("error getting capabilities!"); qDebug("error getting capabilities!"); return false; } clistiter * cur; for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { struct mailimap_capability * cap; cap = (struct mailimap_capability *)clist_content(cur); if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { try_tls = true; break; } } } if (cap_data) { mailimap_capability_data_free(cap_data); } if (try_tls) { err = mailimap_starttls(m_imap); if (err != MAILIMAP_NO_ERROR && force_tls) { Global::statusMessage(tr("Server has no TLS support!")); qDebug("Server has no TLS support!"); try_tls = false; } else { mailstream_low * low; mailstream_low * new_low; low = mailstream_get_low(m_imap->imap_stream); if (!low) { try_tls = false; } else { int fd = mailstream_low_get_fd(low); if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { mailstream_low_free(low); mailstream_set_low(m_imap->imap_stream, new_low); } else { 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() if ( QDialog::Accepted == login.exec() ) { // ok User = login.getUser().latin1(); Pass = login.getPassword().latin1(); } else { // cancel qDebug( "NNTP: Login canceled" ); return; } } else { User = account->getUser().latin1(); Pass = account->getPassword().latin1(); } if (User.isEmpty()) { user=0; pass = 0; } else { user=User.latin1(); pass=Pass.latin1(); } // bool ssl = account->getSSL(); m_nntp=mailstorage_new(NULL); int conntypeset = account->ConnectionType(); int conntype = 0; if ( conntypeset == 3 ) { conntype = CONNECTION_TYPE_COMMAND; } else if ( conntypeset == 2 ) { conntype = CONNECTION_TYPE_TLS; } else if ( conntypeset == 1 ) { conntype = CONNECTION_TYPE_STARTTLS; } else if ( conntypeset == 0 ) { conntype = CONNECTION_TYPE_TRY_STARTTLS; } nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, (char*)user,(char*)pass,0,0,0); err = mailstorage_connect( m_nntp ); if (err != NEWSNNTP_NO_ERROR) { qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); // Global::statusMessage(tr("Error initializing folder")); mailstorage_free(m_nntp); m_nntp = 0; + } else { + mailsession * session = m_nntp->sto_session; + newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; + news->nntp_progr_fun = &nntp_progress; } } void NNTPwrapper::logout() { int err = NEWSNNTP_NO_ERROR; if ( m_nntp == NULL ) return; mailstorage_free(m_nntp); m_nntp = 0; } QValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); QStringList groups; if (account) { groups = account->getGroups(); } for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { folders->append(new Folder((*it),".")); } return folders; } /* we made this method in raw nntp access of etpan and not via generic interface * 'cause in that case there will be doubled copy operations. eg. the etpan would * copy that stuff into its own structures and we must copy it into useable c++ * structures for our frontend. this would not make sense, so it is better to reimplement * the stuff from generic interface of etpan but copy it direct to qt classes. */ QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { login(); QStringList res; clist *result = 0; clistcell *current = 0; newsnntp_group_description *group; if ( m_nntp ) { mailsession * session = m_nntp->sto_session; newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; int err = NEWSNNTP_NO_ERROR; if (mask.isEmpty()) { err = newsnntp_list(news, &result); } else { /* taken from generic wrapper of etpan */ 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() server = account->getServer().latin1(); port = account->getPort().toUInt(); if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); login.show(); if ( QDialog::Accepted == login.exec() ) { // ok user = login.getUser().latin1(); pass = login.getPassword().latin1(); } else { // cancel qDebug( "POP3: Login canceled" ); return; } } else { user = account->getUser().latin1(); pass = account->getPassword().latin1(); } // bool ssl = account->getSSL(); m_pop3=mailstorage_new(NULL); int conntypeset = account->ConnectionType(); int conntype = 0; if ( conntypeset == 3 ) { conntype = CONNECTION_TYPE_COMMAND; } else if ( conntypeset == 2 ) { conntype = CONNECTION_TYPE_TLS; } else if ( conntypeset == 1 ) { conntype = CONNECTION_TYPE_STARTTLS; } else if ( conntypeset == 0 ) { conntype = CONNECTION_TYPE_TRY_STARTTLS; } //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, (char*)user,(char*)pass,0,0,0); err = mailstorage_connect(m_pop3); if (err != MAIL_NO_ERROR) { qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); Global::statusMessage(tr("Error initializing folder")); mailstorage_free(m_pop3); m_pop3 = 0; + } else { + mailsession * session = m_pop3->sto_session; + mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; + if (mail) { + mail->pop3_progr_fun = &pop3_progress; + } } } void POP3wrapper::logout() { if ( m_pop3 == NULL ) return; mailstorage_free(m_pop3); m_pop3 = 0; } QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() { QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); FolderP inb=new Folder("INBOX","/"); folders->append(inb); return folders; } void POP3wrapper::deleteMail(const RecMailP&mail) { login(); if (!m_pop3) return; int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); if (err != MAIL_NO_ERROR) { Global::statusMessage(tr("error deleting mail")); } } void POP3wrapper::answeredMail(const RecMailP&) {} int POP3wrapper::deleteAllMail(const FolderP&) { login(); if (!m_pop3) return 0; int res = 1; uint32_t result = 0; int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); if (err != MAIL_NO_ERROR) { Global::statusMessage(tr("Error getting folder info")); return 0; } for (unsigned int i = 0; i < result; ++i) { err = mailsession_remove_message(m_pop3->sto_session,i+1); if (err != MAIL_NO_ERROR) { Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); res=0; |