summaryrefslogtreecommitdiff
path: root/noncore/net/mail/libmailwrapper/imapwrapper.cpp
authoralwin <alwin>2004-10-24 00:55:14 (UTC)
committer alwin <alwin>2004-10-24 00:55:14 (UTC)
commit9755bc969d17fc683791abc5c6fbd50fa3112486 (patch) (side-by-side diff)
tree0fdcf7b52b2f4627dd3efcd7330b116c4d9c4d98 /noncore/net/mail/libmailwrapper/imapwrapper.cpp
parent12eed25c7f18285f0e342d49fd3c41eb4b14e151 (diff)
downloadopie-9755bc969d17fc683791abc5c6fbd50fa3112486.zip
opie-9755bc969d17fc683791abc5c6fbd50fa3112486.tar.gz
opie-9755bc969d17fc683791abc5c6fbd50fa3112486.tar.bz2
new options for pop3 accounts
KATE eated a lot of last spaces in files some tryouts
Diffstat (limited to 'noncore/net/mail/libmailwrapper/imapwrapper.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp86
1 files changed, 48 insertions, 38 deletions
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 9b7c0e0..fe75a15 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -30,9 +30,9 @@ int IMAPwrapper::selectMbox(const QString&mbox)
return MAILIMAP_NO_ERROR;
}
int err = mailimap_select( m_imap, (char*)mbox.latin1());
if ( err != MAILIMAP_NO_ERROR ) {
- odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl;
+ odebug << "error selecting mailbox: " << m_imap->imap_response << "" << oendl;
m_Lastmbox = "";
return err;
}
m_Lastmbox = mbox;
@@ -41,9 +41,9 @@ int IMAPwrapper::selectMbox(const QString&mbox)
void IMAPwrapper::imap_progress( size_t current, size_t maximum )
{
qApp->processEvents();
- odebug << "IMAP: " << current << " of " << maximum << "" << oendl;
+ odebug << "IMAP: " << current << " of " << maximum << "" << oendl;
}
bool IMAPwrapper::start_tls(bool force_tls)
{
@@ -53,9 +53,9 @@ bool IMAPwrapper::start_tls(bool force_tls)
err = mailimap_capability(m_imap,&cap_data);
if (err != MAILIMAP_NO_ERROR) {
Global::statusMessage("error getting capabilities!");
- odebug << "error getting capabilities!" << oendl;
+ odebug << "error getting capabilities!" << oendl;
return false;
}
clistiter * cur;
for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) {
@@ -74,9 +74,9 @@ bool IMAPwrapper::start_tls(bool force_tls)
if (try_tls) {
err = mailimap_starttls(m_imap);
if (err != MAILIMAP_NO_ERROR && force_tls) {
Global::statusMessage(tr("Server has no TLS support!"));
- odebug << "Server has no TLS support!" << oendl;
+ odebug << "Server has no TLS support!" << oendl;
try_tls = false;
} else {
mailstream_low * low;
mailstream_low * new_low;
@@ -125,9 +125,9 @@ void IMAPwrapper::login()
user = login.getUser().latin1();
pass = login.getPassword().latin1();
} else {
// cancel
- odebug << "IMAP: Login canceled" << oendl;
+ odebug << "IMAP: Login canceled" << oendl;
return;
}
} else {
user = account->getUser().latin1();
@@ -148,9 +148,9 @@ void IMAPwrapper::login()
force_tls = true;
}
if ( ssl ) {
- odebug << "using ssl" << oendl;
+ odebug << "using ssl" << oendl;
err = mailimap_ssl_connect( m_imap, (char*)server, port );
} else {
err = mailimap_socket_connect( m_imap, (char*)server, port );
}
@@ -176,9 +176,9 @@ void IMAPwrapper::login()
bool ok = true;
if (force_tls && !try_tls) {
Global::statusMessage(tr("Server has no TLS support!"));
- odebug << "Server has no TLS support!" << oendl;
+ odebug << "Server has no TLS support!" << oendl;
ok = false;
}
@@ -236,14 +236,18 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma
}
/* the range has to start at 1!!! not with 0!!!! */
set = mailimap_set_new_interval( 1, last );
+
+
+ fetchType = mailimap_fetch_type_new_all();
+/*
fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
-
+*/
err = mailimap_fetch( m_imap, set, fetchType, &result );
mailimap_set_free( set );
mailimap_fetch_type_free( fetchType );
@@ -317,9 +321,9 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
}
folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
}
} else {
- odebug << "error fetching folders: " << m_imap->imap_response << "" << oendl;
+ odebug << "error fetching folders: " << m_imap->imap_response << "" << oendl;
}
mailimap_list_result_free( result );
/*
@@ -327,9 +331,9 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
*/
mask = "*" ;
path = account->getPrefix().latin1();
if (!path) path = "";
- odebug << path << oendl;
+ odebug << path << oendl;
err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
if ( err == MAILIMAP_NO_ERROR ) {
current = result->first;
for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) {
@@ -354,9 +358,9 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
del = list->mb_delimiter;
folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
}
} else {
- odebug << "error fetching folders " << m_imap->imap_response << "" << oendl;
+ odebug << "error fetching folders " << m_imap->imap_response << "" << oendl;
}
if (result) mailimap_list_result_free( result );
return folders;
}
@@ -374,12 +378,12 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
if (!m_att) {
return m;
}
+ size = 0;
m = new RecMail();
for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
current = c;
- size = 0;
item = (mailimap_msg_att_item*)current->data;
if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
if (!flist->att_list) {
@@ -464,15 +468,22 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
m->setMsgid(QString(head->env_message_id));
}
} 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;
+ mailimap_date_time*date = item->att_data.att_static->att_data.att_internal_date;
+ if (date->dt_sec>60 || date->dt_sec<0) date->dt_sec=0;
+ //QDateTime da(QDate(d->dt_year,date->dt_month,date->dt_day),QTime(date->dt_hour,date->dt_min,date->dt_sec));
+ QString timestring = TimeString::numberDateString(QDate(date->dt_year,date->dt_month,date->dt_day))+" ";
+ timestring+=TimeString::timeString(QTime(date->dt_hour,date->dt_min,date->dt_sec))+" ";
+ timestring.sprintf(timestring+" %+05i",date->dt_zone);
+ m->setDate(timestring);
QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
- odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl;
- odebug << da.toString() << oendl;
+ odebug << "" << d->dt_year << " " << d->dt_month << " " << d->dt_day << " - " << d->dt_hour << " " << d->dt_min << " " << d->dt_sec << "" << oendl;
+ odebug << da.toString() << oendl;
#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;
+ //size = item->att_data.att_static->att_data.att_rfc822_size;
+ m->setMsgsize(item->att_data.att_static->att_data.att_rfc822_size);
}
}
/* msg is already deleted */
if (mFlags.testBit(FLAG_DELETED) && m) {
@@ -480,9 +491,8 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
m = 0;
}
if (m) {
m->setFlags(mFlags);
- m->setMsgsize(size);
}
return m;
}
@@ -524,9 +534,9 @@ RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail)
QValueList<int> path;
body_desc = item->att_data.att_static->att_data.att_body;
traverseBody(mail,body_desc,body,0,path);
} else {
- odebug << "error fetching body: " << m_imap->imap_response << "" << oendl;
+ odebug << "error fetching body: " << m_imap->imap_response << "" << oendl;
}
if (result) mailimap_fetch_list_free(result);
return body;
}
@@ -636,9 +646,9 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int
}
}
}
} else {
- odebug << "error fetching text: " << m_imap->imap_response << "" << oendl;
+ odebug << "error fetching text: " << m_imap->imap_response << "" << oendl;
}
if (result) mailimap_fetch_list_free(result);
return res;
}
@@ -663,9 +673,9 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t
for (unsigned int j = 0; j < countlist.count();++j) {
id+=(j>0?" ":"");
id+=QString("%1").arg(countlist[j]);
}
- odebug << "ID = " << id.latin1() << "" << oendl;
+ odebug << "ID = " << id.latin1() << "" << oendl;
currentPart->setIdentifier(id);
fillSinglePart(currentPart,part1);
/* important: Check for is NULL 'cause a body can be empty!
And we put it only into the mail if it is the FIRST part */
@@ -704,9 +714,9 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t
for (unsigned int j = 0; j < countlist.count();++j) {
id+=(j>0?" ":"");
id+=QString("%1").arg(countlist[j]);
}
- odebug << "ID(mpart) = " << id.latin1() << "" << oendl;
+ odebug << "ID(mpart) = " << id.latin1() << "" << oendl;
}
traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount);
if (current_body->bd_type==MAILIMAP_BODY_MPART) {
countlist = recList;
@@ -748,9 +758,9 @@ void IMAPwrapper::fillSingleTextPart(RecPartP&target_part,mailimap_body_type_tex
return;
}
QString sub;
sub = which->bd_media_text;
- odebug << "Type= text/" << which->bd_media_text << "" << oendl;
+ odebug << "Type= text/" << which->bd_media_text << "" << oendl;
target_part->setSubtype(sub.lower());
target_part->setLines(which->bd_lines);
fillBodyFields(target_part,which->bd_fields);
}
@@ -760,9 +770,9 @@ void IMAPwrapper::fillSingleMsgPart(RecPartP&target_part,mailimap_body_type_msg*
if (!which) {
return;
}
target_part->setSubtype("rfc822");
- odebug << "Message part" << oendl;
+ odebug << "Message part" << oendl;
/* we set this type to text/plain */
target_part->setLines(which->bd_lines);
fillBodyFields(target_part,which->bd_fields);
}
@@ -819,9 +829,9 @@ void IMAPwrapper::fillSingleBasicPart(RecPartP&target_part,mailimap_body_type_ba
sub = which->bd_media_basic->med_subtype;
} else {
sub = "";
}
- odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl;
+ odebug << "Type = " << type.latin1() << "/" << sub.latin1() << "" << oendl;
target_part->setType(type.lower());
target_part->setSubtype(sub.lower());
fillBodyFields(target_part,which->bd_fields);
}
@@ -895,18 +905,18 @@ void IMAPwrapper::deleteMail(const RecMailP&mail)
mailimap_set_free( set );
mailimap_store_att_flags_free(store_flags);
if (err != MAILIMAP_NO_ERROR) {
- odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
+ odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
return;
}
- odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
+ odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
/* should we realy do that at this moment? */
err = mailimap_expunge(m_imap);
if (err != MAILIMAP_NO_ERROR) {
- odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
+ odebug << "error deleting mail: " << m_imap->imap_response << "" << oendl;
}
- odebug << "Delete successfull " << m_imap->imap_response << "" << oendl;
+ odebug << "Delete successfull " << m_imap->imap_response << "" << oendl;
}
void IMAPwrapper::answeredMail(const RecMailP&mail)
{
@@ -930,9 +940,9 @@ void IMAPwrapper::answeredMail(const RecMailP&mail)
mailimap_set_free( set );
mailimap_store_att_flags_free(store_flags);
if (err != MAILIMAP_NO_ERROR) {
- odebug << "error marking mail: " << m_imap->imap_response << "" << oendl;
+ odebug << "error marking mail: " << m_imap->imap_response << "" << oendl;
return;
}
}
@@ -998,16 +1008,16 @@ int IMAPwrapper::deleteAllMail(const FolderP&folder)
if (err != MAILIMAP_NO_ERROR) {
Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
return 0;
}
- odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
+ odebug << "deleting mail: " << m_imap->imap_response << "" << oendl;
/* should we realy do that at this moment? */
err = mailimap_expunge(m_imap);
if (err != MAILIMAP_NO_ERROR) {
Global::statusMessage(tr("error deleting mail: %s").arg(m_imap->imap_response));
return 0;
}
- odebug << "Delete successfull " << m_imap->imap_response << "" << oendl;
+ odebug << "Delete successfull " << m_imap->imap_response << "" << oendl;
return 1;
}
int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder)
@@ -1030,9 +1040,9 @@ int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,cons
Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre));
return 0;
}
}
- odebug << "Creating " << pre.latin1() << "" << oendl;
+ odebug << "Creating " << pre.latin1() << "" << oendl;
int res = mailimap_create(m_imap,pre.latin1());
if (res != MAILIMAP_NO_ERROR) {
Global::statusMessage(tr("%1").arg(m_imap->imap_response));
return 0;
@@ -1089,9 +1099,9 @@ void IMAPwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
break;
}
}
} else {
- odebug << "Error retrieving status" << oendl;
+ odebug << "Error retrieving status" << oendl;
}
if (status) mailimap_mailbox_data_status_free(status);
if (att_list) mailimap_status_att_list_free(att_list);
}
@@ -1113,9 +1123,9 @@ MAILLIB::ATYPE IMAPwrapper::getType()const
}
const QString&IMAPwrapper::getName()const
{
- odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl;
+ odebug << "Get name: " << account->getAccountName().latin1() << "" << oendl;
return account->getAccountName();
}
encodedString* IMAPwrapper::fetchRawBody(const RecMailP&mail)
@@ -1129,9 +1139,9 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder,
const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
if (targetWrapper != this) {
AbstractMail::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit);
- odebug << "Using generic" << oendl;
+ odebug << "Using generic" << oendl;
return;
}
mailimap_set *set = 0;
login();
@@ -1148,9 +1158,9 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder,
mailimap_set_free( set );
if ( err != MAILIMAP_NO_ERROR ) {
QString error_msg = tr("error copy mails: %1").arg(m_imap->imap_response);
Global::statusMessage(error_msg);
- odebug << error_msg << oendl;
+ odebug << error_msg << oendl;
return;
}
if (moveit) {
deleteAllMail(fromFolder);
@@ -1159,9 +1169,9 @@ void IMAPwrapper::mvcpAllMails(const FolderP&fromFolder,
void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
{
if (targetWrapper != this) {
- odebug << "Using generic" << oendl;
+ odebug << "Using generic" << oendl;
AbstractMail::mvcpMail(mail,targetFolder,targetWrapper,moveit);
return;
}
mailimap_set *set = 0;
@@ -1178,9 +1188,9 @@ void IMAPwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,Abstra
mailimap_set_free( set );
if ( err != MAILIMAP_NO_ERROR ) {
QString error_msg = tr("error copy mail: %1").arg(m_imap->imap_response);
Global::statusMessage(error_msg);
- odebug << error_msg << oendl;
+ odebug << error_msg << oendl;
return;
}
if (moveit) {
deleteMail(mail);