summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt7
-rw-r--r--kmicromail/libetpan/imap/mailimap_parser.c22
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp67
-rw-r--r--kmicromail/viewmailbase.cpp2
4 files changed, 64 insertions, 34 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 5bfe1c8..cbed872 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,209 +1,216 @@
Info about the changes in new versions of KDE-Pim/Pi
********** VERSION 1.9.20 ************
KO/Pi:
Added for the "dislplay one day" agenda mode
info in the caption and in the day lables:
Now it is displayed, if the selected day is from "day before yesterday"
to "day after tomorrow".
Made it possible to delete a Todo, which has sub-todos.
Fixed two small problems in the todo view.
Added missing German translation for filter edit and print dialog.
Made search dialog closeable by cancel key.
Made it possible to select in the date picker the (ligt grey )
dates of the prev./next month with the mouse.
+OM/Pi:
+"Delete mail" icon in main window now deletes all selected mails.
+Fixed the problem, that the state flag of imap mails was ignored.
+Now mails with "FLAG_SEEN" on the imap server get no icon in the list view
+to idecate that they are already seen.
+Fixed the problem that the body of some mails was not displayed in the
+mail viewer when fetching them from the imap server directly to read them.
********** VERSION 1.9.19 ************
Added a lot of missing translations to KA/Pi,
Added some missing translations to KO/Pi and OM/Pi.
Fixed some minor problems in KA/Pi + KO/Pi.
Fixed a crash when closing PwM/Pi.
Added German translation for PwM/Pi.
Made view change and Month View update faster in KO/Pi.
********** VERSION 1.9.18 ************
FYI: The VERSION 1.9.17 was a testing release only.
Please read the changelog of VERSION 1.9.17 as well.
Cleaned up the syncing config dialog.
Added sync config options for date range for events.
Added sync config options for filters on incoming data.
Added sync config options for filters on outgoing data.
Please read the updated SyncHowTo about the new filter settings.
These filter settings make it now possible to sync with shared
calendars without writing back private or confidential data
(via the outgoing filters).
To sync only with particular parts of a shared calendar,
the incoming filter settings can be used.
An example can be found in the SyncHowTo.
Same for shared addressbooks.
Added a setting for the global kdepim data storage.
Usually the data is stored in (yourhomedir/kdepim).
Now you can set in the Global config dialog TAB, subTAB "Data storage path"
a directory where all the kdepim data is stored.
That makes it easy to save all kdepim data on a SD card on the Z, for example.
KO/Pi:
The timeedit input has a pulldown list for times.
If opened, this pulldown list should now has the right time highlighted.
Added the possibility to exclude events/todos/journals in a filter.
You should exclude journals, if you do not want them to sync with a public calendar.
KA/Pi:
Added the possibility to in/exclude public/private/confidential contacts to a filter.
If you have already defined filterrules in KA/Pi you have to adjust them all by setting the "include public/private/confidential" property manually. Sorry for that ...
Added printing of card view and details view on desktop.
Printing of list view is not working...
Added button for removing pictures in contact editor.
Parsing data fix of KA/Pi version 1.9.17.
Fixed the "parse name automatically" problem of KA/Pi version 1.9.17.
Fixed some syncing merging problems.
********** VERSION 1.9.17 ************
KO/Pi:
Fixed that tooltips were not updated after moving an item in agenda view.
Fixed a bug in sorting start date for recurring events in list view.
Changed the left button in todo viewer from "Agenda" to "Set completed".
This makes it possible to change a todo in the What's Next View quickly to the completed state without leaving the What's Next View.
Added more info in the todo viewer: Startdate, parent/sub todos.
KA/Pi:
All fields search does now actually search all the (possible) fields,
not only those listed in the contact list.
Made is possible to inline a picture in a vcard on the Z.
This was only possible on the desktop, now is it possible on the Z as well.
Fixed of missing save settings after filter configuration.
Made saving of addressbook much faster.
Fixed extension widget layout problem.
Fixed saving of default formatted name settings.
Fixed formatted name handling in edit dialog.
Added an option for changing formatted names of many contacts
(menu: File - Change - Set formatted name).
QWhatsThis was not working on the Z ( only black rectangle was shown).
This is Fixed.
KDE-Sync:
Now readonly KDE resources are synced as well.
(They are not changed in KDE itself, of course).
********** VERSION 1.9.16 ************
KO/Pi:
Fixed search dialog size on Z 6000 (480x640 display).
Added setting to hide/show time in agenda items.
Added setting to hide not running todos in todo view.
Added columns for start date/time in todo view.
Replaced the solid half-hour lines in agenda view by dot lines.
Added possibility of printing the What's Next View on the desktop
(i.e. Windows and Linux).
Fixed a crash in KO/Pi when starting KO/Pi with What's Next view.
Added tooltips in month view.(Tooltips only available on desktop)
Fixed a strange problem in KO/Pi alarm applet.
Did not find the actual problem,
such that now Qtopia reboots again if deinstalling the alarm applet.
But the alarm applet should work again.
KA/Pi:
Fixed the problem, that internal pictures were not saved.
Fixed a problem in the pi-sync mode by increasing the timeout for data transfer from 20 seconds to 5 minutes.
Fixed some minor problems. (Like word wrap in help text windows).
Fixed a compiling problem in microkde/kresources.
KO/Pi is using zdbat (renamed to db2file) for syncing with Sharp DTM.
This version now includes zdbat 1.0.0 (old version was zdbat 0.2.9)
such that now syncing KO/Pi with Sharp DTM should work on the
Zaurus C 3000 model.
********** VERSION 1.9.15 ************
Usebilty enhancements in KO/Pi:
When clicking on the date in a month view cell, the day view is shown.
Old behaviour was, that the "new event" dialog popped up.
Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu).
That means, you can restore the latest
event/todo/journal you have deleted.
A journal is deleted, if you clear all the text of the journal.
Fixed the bug of the editor dialogs in KO/Pi of version 1.9.14.
KA/Pi starting in 480x640 resolution:
Hide the filter action in toolbar
and added icons for undo/delete/redo in toolbar.
Change in OM/Pi ViewMail dialog:
When clicking on the "delete" icon the mail is deleted after confirmation as usual.
But the edit dialog is not closed as before, now the next mail in the folder is shown automatically (if there is any).
Fixed a crash when deleting mail-accounts in OM/Pi.
********** VERSION 1.9.14 ************
Fixed some problems with the dialog sizes when switching
portrait/landscape mode on 640x480 PDA display.
Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi.
Fixed an ugly bug in KOpieMail:
KOpieMail was not able to write files (mails) to MSDOS file system,
like on an usual preformatted SD card. That should work now.
To save your mail data on the Sd card do the following:
Create a dir on the SD card:
mkdir /mnt/card/localmail
Go to your home dir:
cd
Go to kopiemail data storage dir:
cd kdepim/apps/kopiemail
Create a symlink to the SD card:
ls -s /mnt/card/localmail
Now KOpieMail will store all mails on the SD card.
KO/Pi Monthview:
Now "Go to Today" selects the current month from day 1-end,
not the current date + some days.
I.e. "Go to Today" shows now always
the current month with first day of month in the first row.
Added missing German translation.
Fixed icons of executeable on Wintendo.
Added a "Show next Mail" button to the OM/Pi
mail viewer such that the mail below the current mail
in the mail list view of the current folder
can be read with a single click.
********** VERSION 1.9.13 ************
Fixed nasty PwM/Pi file reading bug, when
the used hash algo of file is different then the global
hash algo.
Added KA/Pi support for opie mailit mailapplication.
Fixed some bugs in OM/Pi.
Now character conversion tables are available for the Zaurus
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
@@ -2210,386 +2210,404 @@ mailimap_body_fields_parse(mailstream * fd, MMAPString * buffer,
* result = body_fields;
* index = cur_token;
return MAILIMAP_NO_ERROR;
fld_enc_free:
mailimap_body_fld_enc_free(body_fld_enc);
fld_desc_free:
mailimap_body_fld_desc_free(body_fld_desc);
fld_id_free:
mailimap_body_fld_id_free(body_fld_id);
fld_param_free:
if (body_fld_param != NULL)
mailimap_body_fld_param_free(body_fld_param);
err:
return res;
}
/*
body-fld-desc = nstring
*/
static int mailimap_body_fld_desc_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-dsp = "(" string SP body-fld-param ")" / nil
*/
static int
mailimap_body_fld_dsp_parse(mailstream * fd, MMAPString * buffer,
size_t * index,
struct mailimap_body_fld_dsp ** result,
size_t progr_rate,
progress_function * progr_fun)
{
size_t cur_token;
char * name;
struct mailimap_body_fld_param * body_fld_param;
struct mailimap_body_fld_dsp * body_fld_dsp;
int res;
int r;
cur_token = * index;
name = NULL;
body_fld_param = NULL;
r = mailimap_nil_parse(fd, buffer, &cur_token);
if (r == MAILIMAP_NO_ERROR) {
* result = NULL;
* index = cur_token;
return MAILIMAP_NO_ERROR;
}
if (r != MAILIMAP_ERROR_PARSE) {
res = r;
goto err;
}
r = mailimap_oparenth_parse(fd, buffer, &cur_token);
if (r != MAILIMAP_NO_ERROR) {
res = r;
goto err;
}
r = mailimap_string_parse(fd, buffer, &cur_token, &name, NULL,
progr_rate, progr_fun);
if (r != MAILIMAP_NO_ERROR) {
res = r;
goto err;
}
r = mailimap_space_parse(fd, buffer, &cur_token);
if (r != MAILIMAP_NO_ERROR) {
res = r;
goto string_free;
}
r = mailimap_body_fld_param_parse(fd, buffer, &cur_token,
&body_fld_param,
progr_rate, progr_fun);
if (r != MAILIMAP_NO_ERROR) {
res = r;
goto string_free;
}
r = mailimap_cparenth_parse(fd, buffer, &cur_token);
if (r != MAILIMAP_NO_ERROR) {
res = r;
goto string_free;
}
body_fld_dsp = mailimap_body_fld_dsp_new(name, body_fld_param);
if (body_fld_dsp == NULL) {
res = MAILIMAP_ERROR_MEMORY;
goto fld_param_free;
}
* index = cur_token;
* result = body_fld_dsp;
return MAILIMAP_NO_ERROR;
fld_param_free:
if (body_fld_param != NULL)
mailimap_body_fld_param_free(body_fld_param);
string_free:
mailimap_string_free(name);
err:
return res;
}
/*
body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/
"QUOTED-PRINTABLE") DQUOTE) / string
*/
static inline int
mailimap_body_fld_known_enc_parse(mailstream * fd, MMAPString * buffer,
size_t * index,
int * result,
size_t progr_rate,
progress_function * progr_fun)
{
size_t cur_token;
int type;
int r;
int res;
cur_token = * index;
r = mailimap_dquote_parse(fd, buffer, &cur_token);
if (r != MAILIMAP_NO_ERROR) {
res = r;
goto err;
}
type = mailimap_encoding_get_token_value(fd, buffer, &cur_token);
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
mailimap_body_fld_lang_list_parse(mailstream * fd, MMAPString * buffer,
size_t * index, clist ** result,
size_t progr_rate,
progress_function * progr_fun)
{
size_t cur_token;
clist * list;
int r;
int res;
cur_token = * index;
r = mailimap_oparenth_parse(fd, buffer, &cur_token);
if (r != MAILIMAP_NO_ERROR) {
res = r;
goto err;
}
list = clist_new();
if (list == NULL) {
res = MAILIMAP_ERROR_MEMORY;
goto err;
}
while (1) {
char * elt;
r = mailimap_string_parse(fd, buffer, &cur_token, &elt, NULL,
progr_rate, progr_fun);
if (r != MAILIMAP_ERROR_PARSE)
break;
else if (r == MAILIMAP_NO_ERROR) {
r = clist_append(list, elt);
if (r < 0) {
mailimap_string_free(elt);
res = r;
goto list_free;
}
}
else {
res = r;
goto list_free;
}
}
r = mailimap_cparenth_parse(fd, buffer, &cur_token);
if (r != MAILIMAP_NO_ERROR) {
res = r;
goto list_free;
}
* index = cur_token;
* result = list;
return MAILIMAP_NO_ERROR;
list_free:
clist_foreach(list, (clist_func) mailimap_string_free, NULL);
clist_free(list);
err:
return res;
}
/*
body-fld-lang = nstring / "(" string *(SP string) ")"
*/
static int
mailimap_body_fld_lang_parse(mailstream * fd, MMAPString * buffer,
size_t * index,
struct mailimap_body_fld_lang ** result,
size_t progr_rate,
progress_function * progr_fun)
{
char * value;
clist * list;
struct mailimap_body_fld_lang * fld_lang;
int type;
int r;
int res;
size_t cur_token;
cur_token = * index;
value = NULL;
list = NULL;
type = MAILIMAP_BODY_FLD_LANG_ERROR; /* XXX - removes a gcc warning */
r = mailimap_nstring_parse(fd, buffer, &cur_token, &value, NULL,
progr_rate, progr_fun);
if (r == MAILIMAP_NO_ERROR)
type = MAILIMAP_BODY_FLD_LANG_SINGLE;
if (r == MAILIMAP_ERROR_PARSE) {
r = mailimap_body_fld_lang_list_parse(fd, buffer, &cur_token, &list,
progr_rate, progr_fun);
if (r == MAILIMAP_NO_ERROR)
type = MAILIMAP_BODY_FLD_LANG_LIST;
}
if (r != MAILIMAP_NO_ERROR) {
res = r;
goto err;
}
fld_lang = mailimap_body_fld_lang_new(type, value, list);
if (fld_lang == NULL) {
res = MAILIMAP_ERROR_MEMORY;
goto free;
}
* index = cur_token;
* result = fld_lang;
return MAILIMAP_NO_ERROR;
free:
if (value)
mailimap_nstring_free(value);
if (list) {
clist_foreach(list, (clist_func) mailimap_string_free, NULL);
clist_free(list);
}
err:
return res;
}
/*
body-fld-lines = number
*/
static int mailimap_body_fld_lines_parse(mailstream * fd,
MMAPString * buffer, size_t * index,
uint32_t * result)
{
return mailimap_number_parse(fd, buffer, index, result);
}
/*
body-fld-md5 = nstring
*/
static int mailimap_body_fld_md5_parse(mailstream * fd, MMAPString * buffer,
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
@@ -247,556 +247,561 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma
login();
if (!m_imap) {
return;
}
/* select mailbox READONLY for operations */
err = selectMbox(mailbox);
if ( err != MAILIMAP_NO_ERROR ) {
return;
}
int last = m_imap->imap_selection_info->sel_exists;
if (last == 0) {
Global::statusMessage(i18n("Mailbox has no mails"));
return;
} else {
}
progress( i18n("Fetch "));
mMax = last;
//qDebug("last %d ", last);
Global::statusMessage(i18n("Fetching header list"));
qApp->processEvents();
/* the range has to start at 1!!! not with 0!!!! */
//LR the access to web.de imap server is no working with value 1
//qDebug("interval %d - %d ", tryAgain, last-1+tryAgain );
set = mailimap_set_new_interval( tryAgain, last );
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 );
QString date,subject,from;
if ( err == MAILIMAP_NO_ERROR ) {
tryAgain = -1;
mailimap_msg_att * msg_att;
int i = 0;
for (current = clist_begin(result); current != 0; current=clist_next(current)) {
++i;
//qDebug("iii %d ",i);
msg_att = (mailimap_msg_att*)current->data;
RecMail*m = parse_list_result(msg_att);
if (m) {
if ( maxSizeInKb == 0 || m->Msgsize()<=(unsigned int ) maxSizeInKb*1024 ) {
m->setNumber(i);
m->setMbox(mailbox);
m->setWrapper(this);
target.append(m);
}
}
}
Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count()));
} else {
--tryAgain;
--tryAgain;//disabled tryagain by adding this line
if ( tryAgain < 0 )
Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response));
else
qDebug("try again... ");
}
if (result) mailimap_fetch_list_free(result);
}
}
QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
{
const char *path, *mask;
int err = MAILIMAP_NO_ERROR;
clist *result = 0;
clistcell *current = 0;
clistcell*cur_flag = 0;
mailimap_mbx_list_flags*bflags = 0;
QValueList<FolderP>* folders = new QValueList<FolderP>();
login();
if (!m_imap) {
return folders;
}
/*
* First we have to check for INBOX 'cause it sometimes it's not inside the path.
* We must not forget to filter them out in next loop!
* it seems like ugly code. and yes - it is ugly code. but the best way.
*/
Global::statusMessage(i18n("Fetching folder list"));
qApp->processEvents();
QString temp;
mask = "INBOX" ;
mailimap_mailbox_list *list;
err = mailimap_list( m_imap, (char*)"", (char*)mask, &result );
QString del;
bool selectable = true;
bool no_inferiors = false;
if ( err == MAILIMAP_NO_ERROR ) {
current = result->first;
for ( int i = result->count; i > 0; i-- ) {
list = (mailimap_mailbox_list *) current->data;
// it is better use the deep copy mechanism of qt itself
// instead of using strdup!
temp = list->mb_name;
del = list->mb_delimiter;
current = current->next;
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;
}
}
}
folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
}
} else {
qDebug("error fetching folders: ");
}
mailimap_list_result_free( result );
/*
* second stage - get the other then inbox folders
*/
mask = "*" ;
path = account->getPrefix().latin1();
if (!path) path = "";
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)) {
no_inferiors = false;
list = (mailimap_mailbox_list *) current->data;
// it is better use the deep copy mechanism of qt itself
// instead of using strdup!
temp = list->mb_name;
if (temp.lower()=="inbox")
continue;
if (temp.lower()==account->getPrefix().lower())
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);
while (h.length()>0 && h[0]=='<') {
h.remove(0,1);
}
while (h.length()>0 && h[h.length()-1]=='>') {
h.remove(h.length()-1,1);
}
if (h.length()>0) {
m->setInreply(QStringList(h));
}
}
if (head->env_message_id != NULL) {
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;
QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
qDebug("time %s ",da.toString().latin1() );
#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) {
delete m;
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)
{
encodedString*res=new encodedString;
int err;
mailimap_fetch_type *fetchType;
mailimap_set *set;
clistcell*current,*cur;
mailimap_section_part * section_part = 0;
mailimap_section_spec * section_spec = 0;
mailimap_section * section = 0;
mailimap_fetch_att * fetch_att = 0;
login();
if (!m_imap) {
return res;
}
if (!internal_call) {
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);
if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) {
if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) {
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 {
;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl;
}
if (result) mailimap_fetch_list_free(result);
return res;
}
/* current_recursion is for recursive calls.
current_count means the position inside the internal loop! */
void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,
int current_recursion,QValueList<int>recList,int current_count)
{
if (!body || current_recursion>=10) {
return;
}
switch (body->bd_type) {
case MAILIMAP_BODY_1PART:
{
QValueList<int>countlist = recList;
countlist.append(current_count);
RecPartP currentPart = new RecPart();
mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
QString id("");
currentPart->setPositionlist(countlist);
for (unsigned int j = 0; j < countlist.count();++j) {
id+=(j>0?" ":"");
id+=QString("%1").arg(countlist[j]);
}
//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 */
if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) {
QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding());
size_t index = 0;
char*res = 0;
int err = MAILIMF_NO_ERROR;
QString charset = currentPart->searchParamter( "charset");
qDebug("CHARSET %s ",charset.latin1() );
if ( false ) {
//if ( !charset.isEmpty() ) {
target_body->setCharset( charset );
//err = mailmime_encoded_phrase_parse("iso-8859-1",
// text, strlen(text),&index, "iso-8859-1",&res);
err = mailmime_encoded_phrase_parse(charset.latin1(),
body_text.latin1(), body_text.length(),&index, "utf-8",&res);
if (err == MAILIMF_NO_ERROR && res && strlen(res)) {
//qDebug("res %d %s ", index, res);
body_text = QString::fromUtf8(res);
}
if (res) free(res);
}
//qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() );
target_body->setDescription(currentPart);
target_body->setBodytext(body_text);
if (countlist.count()>1) {
target_body->addPart(currentPart);
}
} else {
target_body->addPart(currentPart);
}
if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist);
}
}
break;
case MAILIMAP_BODY_MPART:
{
QValueList<int>countlist = recList;
clistcell*current=0;
mailimap_body*current_body=0;
unsigned int ccount = 1;
mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
current_body = (mailimap_body*)current->data;
if (current_body->bd_type==MAILIMAP_BODY_MPART) {
RecPartP targetPart = new RecPart();
targetPart->setType("multipart");
fillMultiPart(targetPart,mailDescription);
diff --git a/kmicromail/viewmailbase.cpp b/kmicromail/viewmailbase.cpp
index c4731a7..d21696a 100644
--- a/kmicromail/viewmailbase.cpp
+++ b/kmicromail/viewmailbase.cpp
@@ -1,104 +1,104 @@
// CHANGED 2004-08-06 Lutz Rogowski
#include <qtextbrowser.h>
#include <qlistview.h>
#include <qaction.h>
#include <qlabel.h>
#include <qvbox.h>
#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);
}