summaryrefslogtreecommitdiff
authorharlekin <harlekin>2003-12-10 02:02:53 (UTC)
committer harlekin <harlekin>2003-12-10 02:02:53 (UTC)
commit1f0b92e554b76852af210ceb277b3e9ecb09a43d (patch) (side-by-side diff)
treea813761b2f0d1a2b8a9a1a996d6e37d511d24f0f
parenta908d0ffdb5cee72b7823fc411119b8e1e3faad8 (diff)
downloadopie-1f0b92e554b76852af210ceb277b3e9ecb09a43d.zip
opie-1f0b92e554b76852af210ceb277b3e9ecb09a43d.tar.gz
opie-1f0b92e554b76852af210ceb277b3e9ecb09a43d.tar.bz2
ssl for imap now working
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/imapwrapper.cpp60
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp60
-rw-r--r--noncore/net/mail/mainwindow.cpp2
3 files changed, 67 insertions, 55 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
@@ -28,14 +28,20 @@ void IMAPwrapper::login()
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 );
+
+ m_imap = mailimap_new( 20, &imap_progress );
/* connect */
- err = mailimap_socket_connect( m_imap, (char*)server, port );
- if ( err != MAILIMAP_NO_ERROR &&
+ // 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 ) {
@@ -45,5 +51,5 @@ void IMAPwrapper::login()
return;
}
-
+
/* login */
err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
@@ -75,5 +81,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
mailimap_fetch_type *fetchType;
mailimap_set *set;
-
+
mb = mailbox.latin1();
login();
@@ -96,6 +102,6 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
return;
}
-
- result = clist_new();
+
+ result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( 1, last );
@@ -103,5 +109,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
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();
@@ -109,5 +115,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
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 );
@@ -145,5 +151,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders()
clist *result;
clistcell *current;
-
+
QList<IMAPFolder> * folders = new QList<IMAPFolder>();
folders->setAutoDelete( true );
@@ -152,5 +158,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders()
return folders;
}
-
+
/*
* First we have to check for INBOX 'cause it sometimes it's not inside the path.
@@ -177,9 +183,9 @@ QList<IMAPFolder>* IMAPwrapper::listFolders()
}
mailimap_list_result_free( result );
-
+
/*
* second stage - get the other then inbox folders
*/
- mask = "*" ;
+ mask = "*" ;
path = account->getPrefix().latin1();
result = clist_new();
@@ -197,5 +203,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders()
continue;
folders->append(new IMAPFolder(temp));
-
+
}
} else {
@@ -215,5 +221,5 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
QBitArray mFlags(7);
QStringList addresslist;
-
+
if (!m_att) {
return m;
@@ -330,7 +336,7 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
mailimap_set *set;
mailimap_body*body_desc;
-
+
mb = mail.getMbox().latin1();
-
+
login();
if (!m_imap) {
@@ -344,8 +350,8 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
return body;
}
- result = clist_new();
+ result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
- fetchAtt = mailimap_fetch_att_new_body();
+ fetchAtt = mailimap_fetch_att_new_body();
fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
err = mailimap_fetch( m_imap, set, fetchType, &result );
@@ -362,5 +368,5 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
} else {
}
-
+
} else {
qDebug("error fetching body: %s",m_imap->response);
@@ -368,5 +374,5 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
clist_free(result);
- logout();
+ logout();
return body;
}
@@ -397,12 +403,12 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap
mailimap_fetch_type *fetchType;
mailimap_set *set;
-
+
mb = mail.getMbox().latin1();
-
+
if (!m_imap) {
return;
}
- result = clist_new();
+ result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
@@ -412,5 +418,5 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap
mailimap_set_free( set );
mailimap_fetch_type_free( fetchType );
-
+
if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
mailimap_msg_att * msg_att;
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
@@ -28,14 +28,20 @@ void IMAPwrapper::login()
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 );
+
+ m_imap = mailimap_new( 20, &imap_progress );
/* connect */
- err = mailimap_socket_connect( m_imap, (char*)server, port );
- if ( err != MAILIMAP_NO_ERROR &&
+ // 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 ) {
@@ -45,5 +51,5 @@ void IMAPwrapper::login()
return;
}
-
+
/* login */
err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
@@ -75,5 +81,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
mailimap_fetch_type *fetchType;
mailimap_set *set;
-
+
mb = mailbox.latin1();
login();
@@ -96,6 +102,6 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
return;
}
-
- result = clist_new();
+
+ result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( 1, last );
@@ -103,5 +109,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
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();
@@ -109,5 +115,5 @@ void IMAPwrapper::listMessages(const QString&mailbox,QList<RecMail> &target )
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 );
@@ -145,5 +151,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders()
clist *result;
clistcell *current;
-
+
QList<IMAPFolder> * folders = new QList<IMAPFolder>();
folders->setAutoDelete( true );
@@ -152,5 +158,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders()
return folders;
}
-
+
/*
* First we have to check for INBOX 'cause it sometimes it's not inside the path.
@@ -177,9 +183,9 @@ QList<IMAPFolder>* IMAPwrapper::listFolders()
}
mailimap_list_result_free( result );
-
+
/*
* second stage - get the other then inbox folders
*/
- mask = "*" ;
+ mask = "*" ;
path = account->getPrefix().latin1();
result = clist_new();
@@ -197,5 +203,5 @@ QList<IMAPFolder>* IMAPwrapper::listFolders()
continue;
folders->append(new IMAPFolder(temp));
-
+
}
} else {
@@ -215,5 +221,5 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
QBitArray mFlags(7);
QStringList addresslist;
-
+
if (!m_att) {
return m;
@@ -330,7 +336,7 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
mailimap_set *set;
mailimap_body*body_desc;
-
+
mb = mail.getMbox().latin1();
-
+
login();
if (!m_imap) {
@@ -344,8 +350,8 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
return body;
}
- result = clist_new();
+ result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
- fetchAtt = mailimap_fetch_att_new_body();
+ fetchAtt = mailimap_fetch_att_new_body();
fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
err = mailimap_fetch( m_imap, set, fetchType, &result );
@@ -362,5 +368,5 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
} else {
}
-
+
} else {
qDebug("error fetching body: %s",m_imap->response);
@@ -368,5 +374,5 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
clist_free(result);
- logout();
+ logout();
return body;
}
@@ -397,12 +403,12 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap
mailimap_fetch_type *fetchType;
mailimap_set *set;
-
+
mb = mail.getMbox().latin1();
-
+
if (!m_imap) {
return;
}
- result = clist_new();
+ result = clist_new();
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
@@ -412,5 +418,5 @@ void IMAPwrapper::fillPlainBody(const RecMail&mail,RecBody&target_body, mailimap
mailimap_set_free( set );
mailimap_fetch_type_free( fetchType );
-
+
if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
mailimap_msg_att * msg_att;
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
@@ -16,5 +16,5 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags )
: QMainWindow( parent, name, flags )
{
- setCaption( tr( "Opie-Mail" ) );
+ setCaption( tr( "Mail" ) );
setToolBarsMovable( false );