summaryrefslogtreecommitdiff
path: root/noncore/net/mail/libmailwrapper
authorharlekin <harlekin>2004-01-10 00:32:04 (UTC)
committer harlekin <harlekin>2004-01-10 00:32:04 (UTC)
commit76cf4990cb4171a747ac31e9832f4ee694ced2cc (patch) (side-by-side diff)
treece97c1b6b6e9f832cc09a71fe3e8e87551bb01bd /noncore/net/mail/libmailwrapper
parent241fb3509f6b62efda3c89f5bf9cec0dfba86b43 (diff)
downloadopie-76cf4990cb4171a747ac31e9832f4ee694ced2cc.zip
opie-76cf4990cb4171a747ac31e9832f4ee694ced2cc.tar.gz
opie-76cf4990cb4171a747ac31e9832f4ee694ced2cc.tar.bz2
new connection setting stuff for imap too
Diffstat (limited to 'noncore/net/mail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp36
-rw-r--r--noncore/net/mail/libmailwrapper/settings.cpp2
2 files changed, 25 insertions, 13 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 4b633ea..1c22c26 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -77,14 +77,24 @@ void IMAPwrapper::login()
user = account->getUser().latin1();
pass = account->getPassword().latin1();
}
m_imap = mailimap_new( 20, &imap_progress );
+
+
/* connect */
- if (account->getSSL()) {
+
+ bool ssl = false;
+
+ if ( account->ConnectionType() == 2 ) {
+ ssl = true;
+ }
+
+ if ( ssl ) {
+ qDebug( "using ssl" );
err = mailimap_ssl_connect( m_imap, (char*)server, port );
} else {
err = mailimap_socket_connect( m_imap, (char*)server, port );
}
if ( err != MAILIMAP_NO_ERROR &&
@@ -366,13 +376,13 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
} else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
#if 0
mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
qDebug("%i %i %i - %i %i %i",d->dt_year,d->dt_month,d->dt_day,d->dt_hour,d->dt_min,d->dt_sec);
qDebug(da.toString());
-#endif
+#endif
} else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
size = item->att_data.att_static->att_data.att_rfc822_size;
}
}
/* msg is already deleted */
if (mFlags.testBit(FLAG_DELETED) && m) {
@@ -405,13 +415,13 @@ RecBody IMAPwrapper::fetchBody(const RecMail&mail)
return body;
}
err = selectMbox(mail.getMbox());
if ( err != MAILIMAP_NO_ERROR ) {
return body;
}
-
+
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( mail.getNumber(),mail.getNumber() );
fetchAtt = mailimap_fetch_att_new_bodystructure();
fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
@@ -492,38 +502,38 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>
err = selectMbox(mail.getMbox());
if ( err != MAILIMAP_NO_ERROR ) {
return res;
}
}
set = mailimap_set_new_single(mail.getNumber());
-
+
clist*id_list = 0;
-
+
/* if path == empty then its a request for the whole rfc822 mail and generates
a "fetch <id> (body[])" statement on imap server */
if (path.count()>0 ) {
id_list = clist_new();
for (unsigned j=0; j < path.count();++j) {
uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id));
*p_id = path[j];
clist_append(id_list,p_id);
}
section_part = mailimap_section_part_new(id_list);
section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL);
}
-
+
section = mailimap_section_new(section_spec);
fetch_att = mailimap_fetch_att_new_body_section(section);
fetchType = mailimap_fetch_type_new_fetch_att(fetch_att);
-
+
clist*result = 0;
-
+
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
mailimap_fetch_type_free( fetchType );
-
+
if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
mailimap_msg_att * msg_att;
msg_att = (mailimap_msg_att*)current->data;
mailimap_msg_att_item*msg_att_item;
for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) {
msg_att_item = (mailimap_msg_att_item*)clist_content(cur);
@@ -532,13 +542,13 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMail&mail,const QValueList<int>
char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part;
/* detach - we take over the content */
msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length);
}
}
- }
+ }
} else {
qDebug("error fetching text: %s",m_imap->imap_response);
}
if (result) mailimap_fetch_list_free(result);
return res;
}
@@ -661,29 +671,29 @@ void IMAPwrapper::fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*w
return;
}
target_part.setSubtype("rfc822");
qDebug("Message part");
/* we set this type to text/plain */
target_part.setLines(which->bd_lines);
- fillBodyFields(target_part,which->bd_fields);
+ fillBodyFields(target_part,which->bd_fields);
}
void IMAPwrapper::fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which)
-{
+{
if (!which) return;
QString sub = which->bd_media_subtype;
target_part.setSubtype(sub.lower());
if (which->bd_ext_mpart && which->bd_ext_mpart->bd_parameter && which->bd_ext_mpart->bd_parameter->pa_list) {
clistcell*cur = 0;
mailimap_single_body_fld_param*param=0;
for (cur = clist_begin(which->bd_ext_mpart->bd_parameter->pa_list);cur!=NULL;cur=clist_next(cur)) {
param = (mailimap_single_body_fld_param*)cur->data;
if (param) {
target_part.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
}
- }
+ }
}
}
void IMAPwrapper::fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which)
{
if (!which) {
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp
index 7b6a58d..3279f39 100644
--- a/noncore/net/mail/libmailwrapper/settings.cpp
+++ b/noncore/net/mail/libmailwrapper/settings.cpp
@@ -161,12 +161,13 @@ void IMAPaccount::read()
accountName = conf->readEntry( "Account","" );
if (accountName.isNull()) accountName = "";
server = conf->readEntry( "Server","" );
if (server.isNull()) server="";
port = conf->readEntry( "Port","" );
if (port.isNull()) port="143";
+ connectionType = conf->readNumEntry( "ConnectionType" );
ssl = conf->readBoolEntry( "SSL",false );
user = conf->readEntry( "User","" );
if (user.isNull()) user = "";
password = conf->readEntryCrypt( "Password","" );
if (password.isNull()) password = "";
prefix = conf->readEntry("MailPrefix","");
@@ -183,12 +184,13 @@ void IMAPaccount::save()
Config *conf = new Config( getFileName(), Config::File );
conf->setGroup( "IMAP Account" );
conf->writeEntry( "Account", accountName );
conf->writeEntry( "Server", server );
conf->writeEntry( "Port", port );
conf->writeEntry( "SSL", ssl );
+ conf->writeEntry( "ConnectionType", connectionType );
conf->writeEntry( "User", user );
conf->writeEntryCrypt( "Password", password );
conf->writeEntry( "MailPrefix",prefix);
conf->writeEntry( "Offline",offline);
conf->write();
delete conf;