author | harlekin <harlekin> | 2003-12-10 02:02:53 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-12-10 02:02:53 (UTC) |
commit | 1f0b92e554b76852af210ceb277b3e9ecb09a43d (patch) (side-by-side diff) | |
tree | a813761b2f0d1a2b8a9a1a996d6e37d511d24f0f | |
parent | a908d0ffdb5cee72b7823fc411119b8e1e3faad8 (diff) | |
download | opie-1f0b92e554b76852af210ceb277b3e9ecb09a43d.zip opie-1f0b92e554b76852af210ceb277b3e9ecb09a43d.tar.gz opie-1f0b92e554b76852af210ceb277b3e9ecb09a43d.tar.bz2 |
ssl for imap now working
-rw-r--r-- | noncore/net/mail/imapwrapper.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/imapwrapper.cpp | 6 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 2 |
3 files changed, 13 insertions, 1 deletions
diff --git a/noncore/net/mail/imapwrapper.cpp b/noncore/net/mail/imapwrapper.cpp index eae85a7..dc02780 100644 --- a/noncore/net/mail/imapwrapper.cpp +++ b/noncore/net/mail/imapwrapper.cpp @@ -1,134 +1,140 @@ #include <stdlib.h> #include "imapwrapper.h" #include "mailtypes.h" #include <libetpan/mailimap.h> IMAPwrapper::IMAPwrapper( IMAPaccount *a ) { account = a; m_imap = 0; } IMAPwrapper::~IMAPwrapper() { logout(); } void IMAPwrapper::imap_progress( size_t current, size_t maximum ) { qDebug( "IMAP: %i of %i", current, maximum ); } void IMAPwrapper::login() { logout(); const char *server, *user, *pass; uint16_t port; int err = MAILIMAP_NO_ERROR; server = account->getServer().latin1(); port = account->getPort().toUInt(); user = account->getUser().latin1(); pass = account->getPassword().latin1(); m_imap = mailimap_new( 20, &imap_progress ); /* connect */ + // err = mailimap_socket_connect( m_imap, (char*)server, port ); + if (account->getSSL()) { + err = mailimap_ssl_connect( m_imap, (char*)server, port ); + } else { err = mailimap_socket_connect( m_imap, (char*)server, port ); + } + if ( err != MAILIMAP_NO_ERROR && err != MAILIMAP_NO_ERROR_AUTHENTICATED && err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { qDebug("error connecting server: %s",m_imap->response); mailimap_free( m_imap ); m_imap = 0; return; } /* login */ err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); if ( err != MAILIMAP_NO_ERROR ) { qDebug("error logging in imap: %s",m_imap->response); err = mailimap_close( m_imap ); mailimap_free( m_imap ); m_imap = 0; } } void IMAPwrapper::logout() { int err = MAILIMAP_NO_ERROR; if (!m_imap) return; err = mailimap_logout( m_imap ); err = mailimap_close( m_imap ); mailimap_free( m_imap ); m_imap = 0; } void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) { const char *mb; int err = MAILIMAP_NO_ERROR; clist *result; clistcell *current; mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate; mailimap_fetch_type *fetchType; mailimap_set *set; mb = mailbox.latin1(); login(); if (!m_imap) { return; } /* select mailbox READONLY for operations */ err = mailimap_examine( m_imap, (char*)mb); if ( err != MAILIMAP_NO_ERROR ) { qDebug("error selecting mailbox: %s",m_imap->response); logout(); return; } int last = m_imap->selection_info->exists; if (last == 0) { qDebug("mailbox has no mails"); logout(); return; } result = clist_new(); /* the range has to start at 1!!! not with 0!!!! */ set = mailimap_set_new_interval( 1, last ); fetchAtt = mailimap_fetch_att_new_envelope(); fetchAttFlags = mailimap_fetch_att_new_flags(); fetchAttDate = mailimap_fetch_att_new_internaldate(); //fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAtt); mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttFlags); mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttDate); err = mailimap_fetch( m_imap, set, fetchType, &result ); mailimap_set_free( set ); /* cleans up the fetch_att's too! */ mailimap_fetch_type_free( fetchType ); QString date,subject,from; if ( err == MAILIMAP_NO_ERROR ) { current = clist_begin(result); mailimap_msg_att * msg_att; int i = 0; while ( current != 0 ) { ++i; msg_att = (mailimap_msg_att*)current->data; RecMail*m = parse_list_result(msg_att); if (m) { m->setNumber(i); m->setMbox(mailbox); target.append(m); } current = current->next; } } else { diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp index eae85a7..dc02780 100644 --- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp @@ -1,134 +1,140 @@ #include <stdlib.h> #include "imapwrapper.h" #include "mailtypes.h" #include <libetpan/mailimap.h> IMAPwrapper::IMAPwrapper( IMAPaccount *a ) { account = a; m_imap = 0; } IMAPwrapper::~IMAPwrapper() { logout(); } void IMAPwrapper::imap_progress( size_t current, size_t maximum ) { qDebug( "IMAP: %i of %i", current, maximum ); } void IMAPwrapper::login() { logout(); const char *server, *user, *pass; uint16_t port; int err = MAILIMAP_NO_ERROR; server = account->getServer().latin1(); port = account->getPort().toUInt(); user = account->getUser().latin1(); pass = account->getPassword().latin1(); m_imap = mailimap_new( 20, &imap_progress ); /* connect */ + // err = mailimap_socket_connect( m_imap, (char*)server, port ); + if (account->getSSL()) { + err = mailimap_ssl_connect( m_imap, (char*)server, port ); + } else { err = mailimap_socket_connect( m_imap, (char*)server, port ); + } + if ( err != MAILIMAP_NO_ERROR && err != MAILIMAP_NO_ERROR_AUTHENTICATED && err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { qDebug("error connecting server: %s",m_imap->response); mailimap_free( m_imap ); m_imap = 0; return; } /* login */ err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); if ( err != MAILIMAP_NO_ERROR ) { qDebug("error logging in imap: %s",m_imap->response); err = mailimap_close( m_imap ); mailimap_free( m_imap ); m_imap = 0; } } void IMAPwrapper::logout() { int err = MAILIMAP_NO_ERROR; if (!m_imap) return; err = mailimap_logout( m_imap ); err = mailimap_close( m_imap ); mailimap_free( m_imap ); m_imap = 0; } void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target ) { const char *mb; int err = MAILIMAP_NO_ERROR; clist *result; clistcell *current; mailimap_fetch_att *fetchAtt,*fetchAttFlags,*fetchAttDate; mailimap_fetch_type *fetchType; mailimap_set *set; mb = mailbox.latin1(); login(); if (!m_imap) { return; } /* select mailbox READONLY for operations */ err = mailimap_examine( m_imap, (char*)mb); if ( err != MAILIMAP_NO_ERROR ) { qDebug("error selecting mailbox: %s",m_imap->response); logout(); return; } int last = m_imap->selection_info->exists; if (last == 0) { qDebug("mailbox has no mails"); logout(); return; } result = clist_new(); /* the range has to start at 1!!! not with 0!!!! */ set = mailimap_set_new_interval( 1, last ); fetchAtt = mailimap_fetch_att_new_envelope(); fetchAttFlags = mailimap_fetch_att_new_flags(); fetchAttDate = mailimap_fetch_att_new_internaldate(); //fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAtt); mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttFlags); mailimap_fetch_type_new_fetch_att_list_add(fetchType,fetchAttDate); err = mailimap_fetch( m_imap, set, fetchType, &result ); mailimap_set_free( set ); /* cleans up the fetch_att's too! */ mailimap_fetch_type_free( fetchType ); QString date,subject,from; if ( err == MAILIMAP_NO_ERROR ) { current = clist_begin(result); mailimap_msg_att * msg_att; int i = 0; while ( current != 0 ) { ++i; msg_att = (mailimap_msg_att*)current->data; RecMail*m = parse_list_result(msg_att); if (m) { m->setNumber(i); m->setMbox(mailbox); target.append(m); } current = current->next; } } else { diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 3edfff1..6d13a8b 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp @@ -1,114 +1,114 @@ #include <qlabel.h> #include <qvbox.h> #include <qheader.h> #include <qtimer.h> #include <qlayout.h> #include <qpe/qpeapplication.h> #include "defines.h" #include "mainwindow.h" #include "viewmail.h" #include "mailtypes.h" #include "mailistviewitem.h" MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) : QMainWindow( parent, name, flags ) { - setCaption( tr( "Opie-Mail" ) ); + setCaption( tr( "Mail" ) ); setToolBarsMovable( false ); toolBar = new QToolBar( this ); menuBar = new QMenuBar( toolBar ); mailMenu = new QPopupMenu( menuBar ); menuBar->insertItem( tr( "Mail" ), mailMenu ); settingsMenu = new QPopupMenu( menuBar ); menuBar->insertItem( tr( "Settings" ), settingsMenu ); addToolBar( toolBar ); toolBar->setHorizontalStretchable( true ); QLabel *spacer = new QLabel( toolBar ); spacer->setBackgroundMode( QWidget::PaletteButton ); toolBar->setStretchableWidget( spacer ); composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, 0, 0, this ); composeMail->addTo( toolBar ); composeMail->addTo( mailMenu ); sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, 0, 0, this ); sendQueued->addTo( toolBar ); sendQueued->addTo( mailMenu ); syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 0, 0, this ); syncFolders->addTo( toolBar ); syncFolders->addTo( mailMenu ); showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, 0, 0, this, 0, true ); showFolders->addTo( toolBar ); showFolders->addTo( mailMenu ); connect(showFolders, SIGNAL( toggled( bool ) ), SLOT( slotShowFolders( bool ) ) ); searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, 0, 0, this ); searchMails->addTo( toolBar ); searchMails->addTo( mailMenu ); editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, 0, 0, this ); editSettings->addTo( settingsMenu ); editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, 0, 0, this ); editAccounts->addTo( settingsMenu ); QWidget *view = new QWidget( this ); setCentralWidget( view ); layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); folderView = new AccountView( view ); folderView->header()->hide(); folderView->addColumn( tr( "Mailbox" ) ); folderView->hide(); layout->addWidget( folderView ); mailView = new QListView( view ); mailView->addColumn( tr( "Subject" ),QListView::Manual ); mailView->addColumn( tr( "Sender" ),QListView::Manual ); mailView->addColumn( tr( "Date" )); mailView->setAllColumnsShowFocus(true); mailView->setSorting(-1); layout->addWidget( mailView ); layout->setStretchFactor( folderView, 1 ); layout->setStretchFactor( mailView, 2 ); slotAdjustLayout(); connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, SLOT( displayMail( QListViewItem * ) ) ); connect(folderView,SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); } void MainWindow::slotAdjustLayout() { QWidget *d = QApplication::desktop(); if ( d->width() < d->height() ) { layout->setDirection( QBoxLayout::TopToBottom ); } else { layout->setDirection( QBoxLayout::LeftToRight ); } delete d; |