summaryrefslogtreecommitdiffabout
path: root/kmicromail
Side-by-side diff
Diffstat (limited to 'kmicromail') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libetpan/imap/mailimap_parser.c22
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp67
-rw-r--r--kmicromail/viewmailbase.cpp2
3 files changed, 57 insertions, 34 deletions
diff --git a/kmicromail/libetpan/imap/mailimap_parser.c b/kmicromail/libetpan/imap/mailimap_parser.c
index 1c2ecde..560e58a 100644
--- a/kmicromail/libetpan/imap/mailimap_parser.c
+++ b/kmicromail/libetpan/imap/mailimap_parser.c
@@ -2354,98 +2354,116 @@ mailimap_body_fld_known_enc_parse(mailstream * fd, MMAPString * buffer,
if (type == -1) {
res = MAILIMAP_ERROR_PARSE;
goto err;
}
r = mailimap_dquote_parse(fd, buffer, &cur_token);
if (r != MAILIMAP_NO_ERROR) {
res = r;
goto err;
}
* result = type;
* index = cur_token;
return MAILIMAP_NO_ERROR;
err:
return res;
}
static int
mailimap_body_fld_enc_parse(mailstream * fd, MMAPString * buffer,
size_t * index,
struct mailimap_body_fld_enc ** result,
size_t progr_rate,
progress_function * progr_fun)
{
size_t cur_token;
int type;
char * value;
struct mailimap_body_fld_enc * body_fld_enc;
int r;
int res;
cur_token = * index;
r = mailimap_body_fld_known_enc_parse(fd, buffer, &cur_token,
&type, progr_rate, progr_fun);
if (r == MAILIMAP_NO_ERROR) {
value = NULL;
}
else if (r == MAILIMAP_ERROR_PARSE) {
type = MAILIMAP_BODY_FLD_ENC_OTHER;
r = mailimap_string_parse(fd, buffer, &cur_token, &value, NULL,
progr_rate, progr_fun);
if (r != MAILIMAP_NO_ERROR) {
- res = r;
- goto err;
+ // LR start
+ // accept NIL and set type to utf8
+ int ret = r;
+ r = mailimap_char_parse(fd, buffer, &cur_token, 'N');
+ if (r == MAILIMAP_NO_ERROR) {
+ r = mailimap_char_parse(fd, buffer, &cur_token, 'I');
+ if (r == MAILIMAP_NO_ERROR) {
+ r = mailimap_char_parse(fd, buffer, &cur_token, 'L');
+ if (r == MAILIMAP_NO_ERROR) {
+ type = 4;
+ ret = MAILIMAP_NO_ERROR;
+ value = NULL;
+ }
+ }
+ }
+ if ( ret != MAILIMAP_NO_ERROR ) {
+ res = ret;
+ goto err;
+ }
+ // LR end
}
}
else {
res = r;
goto err;
}
body_fld_enc = mailimap_body_fld_enc_new(type, value);
if (body_fld_enc == NULL) {
res = MAILIMAP_ERROR_MEMORY;
goto value_free;
}
* result = body_fld_enc;
* index = cur_token;
return MAILIMAP_NO_ERROR;
value_free:
if (value)
mailimap_string_free(value);
err:
return res;
}
/*
body-fld-id = nstring
*/
static int mailimap_body_fld_id_parse(mailstream * fd, MMAPString * buffer,
size_t * index, char ** result,
size_t progr_rate,
progress_function * progr_fun)
{
return mailimap_nstring_parse(fd, buffer, index, result, NULL,
progr_rate, progr_fun);
}
/*
body-fld-lang = nstring / "(" string *(SP string) ")"
*/
/*
"(" string *(SP string) ")"
*/
static int
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index d9496af..93fb7de 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -391,145 +391,150 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
continue;
if ( (bflags = list->mb_flag) ) {
selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
no_inferiors = true;
}
}
}
del = list->mb_delimiter;
folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
}
} else {
qDebug("error fetching folders ");
}
if (result) mailimap_list_result_free( result );
return folders;
}
RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
{
RecMail * m = 0;
mailimap_msg_att_item *item=0;
clistcell *current,*c,*cf;
mailimap_msg_att_dynamic*flist;
mailimap_flag_fetch*cflag;
int size = 0;
QBitArray mFlags(7);
QStringList addresslist;
if (!m_att) {
return m;
}
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 )
continue;
if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
if (!flist || !flist->att_list) {
continue;
}
cf = flist->att_list->first;
- if( ! cf )
- for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
- cflag = (mailimap_flag_fetch*)cf->data;
- if( ! cflag )
- qDebug("imap:not cflag ");
- if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
- switch (cflag->fl_flag->fl_type) {
- case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
- mFlags.setBit(FLAG_ANSWERED);
- break;
- case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */
- mFlags.setBit(FLAG_FLAGGED);
- break;
- case MAILIMAP_FLAG_DELETED: /* \Deleted flag */
- mFlags.setBit(FLAG_DELETED);
- break;
- case MAILIMAP_FLAG_SEEN: /* \Seen flag */
- mFlags.setBit(FLAG_SEEN);
- break;
- case MAILIMAP_FLAG_DRAFT: /* \Draft flag */
- mFlags.setBit(FLAG_DRAFT);
- break;
- case MAILIMAP_FLAG_KEYWORD: /* keyword flag */
- break;
- case MAILIMAP_FLAG_EXTENSION: /* \extension flag */
- break;
- default:
- break;
+ if( cf ) {
+ for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
+ cflag = (mailimap_flag_fetch*)cf->data;
+ if( ! cflag )
+ qDebug("imap:NO cflag ");
+ else {
+ if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
+ switch (cflag->fl_flag->fl_type) {
+ case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
+ mFlags.setBit(FLAG_ANSWERED);
+ break;
+ case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */
+ mFlags.setBit(FLAG_FLAGGED);
+ break;
+ case MAILIMAP_FLAG_DELETED: /* \Deleted flag */
+ mFlags.setBit(FLAG_DELETED);
+ break;
+ case MAILIMAP_FLAG_SEEN: /* \Seen flag */
+ mFlags.setBit(FLAG_SEEN);
+ break;
+ case MAILIMAP_FLAG_DRAFT: /* \Draft flag */
+ mFlags.setBit(FLAG_DRAFT);
+ break;
+ case MAILIMAP_FLAG_KEYWORD: /* keyword flag */
+ break;
+ case MAILIMAP_FLAG_EXTENSION: /* \extension flag */
+ break;
+ default:
+ break;
+ }
+ } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
+ mFlags.setBit(FLAG_RECENT);
+ }
}
- } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
- mFlags.setBit(FLAG_RECENT);
}
}
+ //qDebug(" continue");
continue;
}
if ( item->att_data.att_static == NULL )
continue;
if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) {
mailimap_envelope * head = item->att_data.att_static->att_data.att_env;
if ( head == NULL )
continue;
if ( head->env_date != NULL ) {
m->setDate(head->env_date);
//struct mailimf_date_time result;
struct mailimf_date_time* date;// = &result;
struct mailimf_date_time **re = &date;
size_t length = m->getDate().length();
size_t index = 0;
if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) {
+ //qDebug("parseDateTime ");
QDateTime dt = Genericwrapper::parseDateTime( date );
QString ret;
if ( dt.date() == QDate::currentDate () )
ret = KGlobal::locale()->formatTime( dt.time(),true);
else {
ret = KGlobal::locale()->formatDateTime( dt,true,true);
}
m->setDate( ret );
char tmp[20];
snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i",
dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() );
//qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date);
m->setIsoDate( QString( tmp ) );
mailimf_date_time_free ( date );
} else {
m->setIsoDate(head->env_date);
}
}
if ( head->env_subject != NULL )
m->setSubject(convert_String((const char*)head->env_subject));
//m->setSubject(head->env_subject);
if (head->env_from!=NULL) {
addresslist = address_list_to_stringlist(head->env_from->frm_list);
if (addresslist.count()) {
m->setFrom(addresslist.first());
}
}
if (head->env_to!=NULL) {
addresslist = address_list_to_stringlist(head->env_to->to_list);
m->setTo(addresslist);
}
if (head->env_cc!=NULL) {
addresslist = address_list_to_stringlist(head->env_cc->cc_list);
m->setCC(addresslist);
}
if (head->env_bcc!=NULL) {
addresslist = address_list_to_stringlist(head->env_bcc->bcc_list);
m->setBcc(addresslist);
}
/* reply to address, eg. email. */
if (head->env_reply_to!=NULL) {
addresslist = address_list_to_stringlist(head->env_reply_to->rt_list);
if (addresslist.count()) {
m->setReplyto(addresslist.first());
}
}
if (head->env_in_reply_to!=NULL) {
QString h(head->env_in_reply_to);
@@ -562,97 +567,97 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
m = 0;
}
if (m) {
m->setFlags(mFlags);
m->setMsgsize(size);
}
return m;
}
RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail)
{
RecBodyP body = new RecBody();
const char *mb;
int err = MAILIMAP_NO_ERROR;
clist *result = 0;
clistcell *current;
mailimap_fetch_att *fetchAtt = 0;
mailimap_fetch_type *fetchType = 0;
mailimap_set *set = 0;
mailimap_body*body_desc = 0;
mb = mail->getMbox().latin1();
login();
if (!m_imap) {
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 );
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*item = (mailimap_msg_att_item*)msg_att->att_list->first->data;
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;
+ qDebug("error fetching body %d (%d): %s", err, MAILIMAP_NO_ERROR, m_imap->imap_response );
}
if (result) mailimap_fetch_list_free(result);
return body;
}
QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
{
QStringList l;
QString from;
bool named_from;
clistcell *current = NULL;
mailimap_address * current_address=NULL;
if (!list) {
return l;
}
unsigned int count = 0;
for (current=clist_begin(list);current!= NULL;current=clist_next(current)) {
from = "";
named_from = false;
current_address=(mailimap_address*)current->data;
if (current_address->ad_personal_name){
from+=convert_String((const char*)current_address->ad_personal_name);
from+=" ";
named_from = true;
}
if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
from+="<";
}
if (current_address->ad_mailbox_name) {
from+=QString(current_address->ad_mailbox_name);
from+="@";
}
if (current_address->ad_host_name) {
from+=QString(current_address->ad_host_name);
}
if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
from+=">";
}
l.append(QString(from));
if (++count > 99) {
break;
}
}
return l;
}
encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call)
{
diff --git a/kmicromail/viewmailbase.cpp b/kmicromail/viewmailbase.cpp
index c4731a7..d21696a 100644
--- a/kmicromail/viewmailbase.cpp
+++ b/kmicromail/viewmailbase.cpp
@@ -7,97 +7,97 @@
#include <qtoolbar.h>
#include <qmenubar.h>
#include <kiconloader.h>
//#include <qpe/resource.h>
#include <klocale.h>
#include "viewmailbase.h"
//#include "opendiag.h"
ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl)
: QMainWindow(parent, name, fl)
{
setToolBarsMovable(false);
toolbar = new QToolBar(this);
menubar = new QMenuBar( toolbar );
mailmenu = new QPopupMenu( menubar );
menubar->insertItem( i18n( "Mail" ), mailmenu );
toolbar->setHorizontalStretchable(true);
addToolBar(toolbar);
reply = new QAction(i18n("Reply"),SmallIcon("reply"), 0, 0, this);
reply->addTo(toolbar);
reply->addTo(mailmenu);
forward = new QAction(i18n("Forward"),SmallIcon("forward"), 0, 0, this);
forward->addTo(toolbar);
forward->addTo(mailmenu);
attachbutton = new QAction(i18n("Attachments"),SmallIcon("attach"), 0, 0, this, 0, true);
attachbutton->addTo(toolbar);
attachbutton->addTo(mailmenu);
connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool)));
showHtml = new QAction( i18n( "Show Html" ), SmallIcon( "html" ), 0, 0, this, 0, true );
showHtml->addTo( toolbar );
showHtml->addTo( mailmenu );
deleteMail = new QAction(i18n("Delete Mail"),SmallIcon("trash"), 0, 0, this);
deleteMail->addTo(toolbar);
deleteMail->addTo(mailmenu);
- nextMail = new QAction(i18n("Show next mail"),SmallIcon("add"), 0, 0, this);
+ nextMail = new QAction(i18n("Show next mail"),SmallIcon("enter"), 0, 0, this);
QLabel *spacer = new QLabel(toolbar);
nextMail->addTo(toolbar);
nextMail->addTo(mailmenu);
closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this);
//QLabel *spacer = new QLabel(toolbar);
spacer->setBackgroundMode(QWidget::PaletteButton);
toolbar->setStretchableWidget(spacer);
closeMail->addTo(toolbar);
closeMail->addTo(mailmenu);
QVBox *view = new QVBox(this);
setCentralWidget(view);
attachments = new QListView(view);
attachments->setMinimumHeight(90);
attachments->setMaximumHeight(90);
attachments->setAllColumnsShowFocus(true);
attachments->addColumn("Mime Type", 60);
attachments->addColumn(i18n("Description"), 100);
attachments->addColumn(i18n("Filename"), 80);
attachments->addColumn(i18n("Size"), 80);
attachments->setSorting(-1);
attachments->hide();
browser = new QTextBrowser(view);
// openDiag = new OpenDiag(view);
// openDiag->hide();
}
void ViewMailBase::slotChangeAttachview(bool state)
{
if (state) attachments->show();
else attachments->hide();
}
void ViewMailBase::keyPressEvent ( QKeyEvent * e )
{
if( e->key()==Qt::Key_Escape ) {
close();
e->accept();
return;
}
QWidget::keyPressEvent(e);