author | zautrix <zautrix> | 2004-11-07 17:35:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-11-07 17:35:51 (UTC) |
commit | d90d17044d7daf6677074b0964d59f94407157d5 (patch) (side-by-side diff) | |
tree | 82bf4f2001465637572534650769a864c15a6f7c /kmicromail | |
parent | b6ef669713ee1d52adcfc9754dd039a4ff6675da (diff) | |
download | kdepimpi-d90d17044d7daf6677074b0964d59f94407157d5.zip kdepimpi-d90d17044d7daf6677074b0964d59f94407157d5.tar.gz kdepimpi-d90d17044d7daf6677074b0964d59f94407157d5.tar.bz2 |
some mail fixes and warnings removed
-rw-r--r-- | kmicromail/koprefsdialog.cpp | 7 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/generatemail.cpp | 16 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/generatemail.h | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 3 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 4 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailwrapper.h | 2 | ||||
-rw-r--r-- | kmicromail/mainwindow.cpp | 3 |
7 files changed, 23 insertions, 13 deletions
diff --git a/kmicromail/koprefsdialog.cpp b/kmicromail/koprefsdialog.cpp index 4abf859..13d6681 100644 --- a/kmicromail/koprefsdialog.cpp +++ b/kmicromail/koprefsdialog.cpp @@ -86,187 +86,188 @@ KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) : setupViewsTab(); //setupSyncTab(); //setupSyncAlgTab(); //setupPrinterTab(); //setupGroupSchedulingTab(); //setupGroupAutomationTab(); #endif } #include "kpimglobalprefs.h" KOPrefsDialog::~KOPrefsDialog() { } void KOPrefsDialog::setupGlobalTab() { QFrame *topFrame = addPage(i18n("Global"),0,0); kdelibcfg = new KDEPIMConfigWidget( KPimGlobalPrefs::instance(), topFrame, "KCMKdeLibConfig" ); QVBoxLayout *topLayout = new QVBoxLayout(topFrame); topLayout->addWidget( kdelibcfg ); } void KOPrefsDialog::setupMainTab() { QFrame *topFrame = addPage(i18n("General"),0,0); QGridLayout *topLayout = new QGridLayout(topFrame,6,2); topLayout->setSpacing(spacingHint()); topLayout->setMargin(marginHint()); mNameEdit = new QLineEdit(topFrame); mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); topLayout->addWidget(mNameLabel,0,0); topLayout->addWidget(mNameEdit,0,1); mEmailEdit = new QLineEdit(topFrame); mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); topLayout->addWidget(mEmailLabel,1,0); topLayout->addWidget(mEmailEdit,1,1); QLabel *lab = new QLabel( i18n("HINT: Separate multiple\neMail addresses by \";\""), topFrame); topLayout->addMultiCellWidget(lab,2,2,0,1); KPrefsDialogWidBool* ttt = addWidBool(i18n("Ignore above settings and\nuse KA/Pi \"Who am I\" instead!"), &(KOPrefs::instance()->mUseKapi),topFrame); topLayout->addMultiCellWidget(ttt->checkBox(),3,3,0,1); } void KOPrefsDialog::setupMailTab() { QFrame *topFrame = addPage(i18n("Mail"),0,0); QGridLayout *topLayout = new QGridLayout(topFrame,4,2); topLayout->setSpacing(spacingHint()); topLayout->setMargin(marginHint()); KPrefsDialogWidBool* ttt = addWidBool(i18n("View mail as html"), &(KOPrefs::instance()->mViewAsHtml),topFrame); topLayout->addMultiCellWidget(ttt->checkBox(),0,0,0,1); ttt = addWidBool(i18n("Send mails later"), &(KOPrefs::instance()->mSendLater),topFrame); topLayout->addMultiCellWidget(ttt->checkBox(),1,1,0,1); + /* mCodecEdit = new QLineEdit(topFrame); topLayout->addMultiCellWidget( new QLabel(mCodecEdit, i18n("User defined codec for new mails:"), topFrame),2,2,0,1); topLayout->addMultiCellWidget(mCodecEdit,3,3,0,1); topLayout->addMultiCellWidget( new QLabel(0, i18n("Example: iso-8859-15"), topFrame),4,4,0,1); - + */ } void KOPrefsDialog::setupFontsTab() { QFrame *topFrame = addPage(i18n("Fonts"),0,0); // DesktopIcon("fonts",KIcon::SizeMedium)); QGridLayout *topLayout = new QGridLayout(topFrame,7,3); topLayout->setSpacing(1); topLayout->setMargin(3); KPrefsDialogWidFont * tVFont; int i = 0; KPrefsDialogWidFont *timeLabelsFont = addWidFont(i18n("OK"),i18n("Application(nr)"), &(KOPrefs::instance()->mAppFont),topFrame); topLayout->addWidget(timeLabelsFont->label(),i,0); topLayout->addWidget(timeLabelsFont->preview(),i,1); topLayout->addWidget(timeLabelsFont->button(),i,2); ++i; timeLabelsFont = addWidFont(i18n("Dear Mr."),i18n("Compose mail:"), &(KOPrefs::instance()->mComposeFont),topFrame); topLayout->addWidget(timeLabelsFont->label(),i,0); topLayout->addWidget(timeLabelsFont->preview(),i,1); topLayout->addWidget(timeLabelsFont->button(),i,2); ++i; KPrefsDialogWidFont *timeBarFont = addWidFont(i18n("Hello"),i18n("Read mail:"), &(KOPrefs::instance()->mReadFont),topFrame); topLayout->addWidget(timeBarFont->label(),i,0); topLayout->addWidget(timeBarFont->preview(),i,1); topLayout->addWidget(timeBarFont->button(),i,2); ++i; topLayout->setColStretch(1,1); topLayout->setRowStretch(4,1); } void KOPrefsDialog::usrReadConfig() { mNameEdit->setText(KOPrefs::instance()->mName); mEmailEdit->setText(KOPrefs::instance()->mEmail); - mCodecEdit->setText(KOPrefs::instance()->mSendCodec); + //mCodecEdit->setText(KOPrefs::instance()->mSendCodec); kdelibcfg->readConfig(); } void KOPrefsDialog::usrWriteConfig() { KOPrefs::instance()->mName = mNameEdit->text(); KOPrefs::instance()->mEmail = mEmailEdit->text(); - KOPrefs::instance()->mSendCodec = mCodecEdit->text(); + //KOPrefs::instance()->mSendCodec = mCodecEdit->text(); kdelibcfg->writeConfig(); } #if 0 void KOPrefsDialog::setupLocaleDateTab() { QFrame *topFrame = addPage(i18n("Date Format"),0,0); QGridLayout *topLayout = new QGridLayout(topFrame,3,2); topLayout->setSpacing(spacingHint()); topLayout->setMargin(marginHint()); int iii = 0; KPrefsWidRadios *syncPrefsGroup = addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame); QString format; if ( QApplication::desktop()->width() < 480 ) format = "(%d.%m.%Y)"; else format = "(%d.%m.%Y|%A %d %B %Y)"; syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); if ( QApplication::desktop()->width() < 480 ) format = "(%m.%d.%Y)"; else format = "(%m.%d.%Y|%A %B %d %Y)"; syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); if ( QApplication::desktop()->width() < 480 ) format = "(%Y-%m-%d)"; else format = "(%Y-%m-%d|%A %Y %B %d)"; syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); syncPrefsGroup->addRadio(i18n("User defined")); topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); ++iii; ++iii; QLabel * lab; mUserDateFormatLong = new QLineEdit(topFrame); lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); topLayout->addWidget(lab ,iii,0); topLayout->addWidget(mUserDateFormatLong,iii,1); ++iii; mUserDateFormatShort = new QLineEdit(topFrame); lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); topLayout->addWidget(lab ,iii,0); topLayout->addWidget(mUserDateFormatShort,iii,1); ++iii; lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); topLayout->addMultiCellWidget(lab ,iii,iii,0,1); ++iii; lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); topLayout->addMultiCellWidget(lab ,iii,iii,0,1); ++iii; lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); topLayout->addMultiCellWidget(lab ,iii,iii,0,1); ++iii; } void KOPrefsDialog::setupLocaleTab() { QFrame *topFrame = addPage(i18n("Locale"),0,0); QGridLayout *topLayout = new QGridLayout(topFrame,4,2); diff --git a/kmicromail/libmailwrapper/generatemail.cpp b/kmicromail/libmailwrapper/generatemail.cpp index 32311d7..2d213fe 100644 --- a/kmicromail/libmailwrapper/generatemail.cpp +++ b/kmicromail/libmailwrapper/generatemail.cpp @@ -1,79 +1,80 @@ #include "generatemail.h" #include "mailwrapper.h" #include <libetpan/libetpan.h> //#include <qt.h> #include <stdlib.h> #include <qfileinfo.h> using namespace Opie::Core; const char* Generatemail::USER_AGENT="KOpieMail 33 1/3"; Generatemail::Generatemail() { + mCharset = "iso-8859-1"; } Generatemail::~Generatemail() { } void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { clistiter *it, *it2; for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { mailimf_address *addr; addr = (mailimf_address *) it->data; if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { mailimf_mailbox *mbox; mbox = (mailimf_mailbox *) it2->data; esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); } } } } char *Generatemail::getFrom( mailimf_field *ffrom) { char *from = NULL; if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; clistiter *it; for ( it = clist_begin( cl ); it; it = it->next ) { mailimf_mailbox *mb = (mailimf_mailbox *) it->data; from = strdup( mb->mb_addr_spec ); } } return from; } char *Generatemail::getFrom( mailmime *mail ) { /* no need to delete - its just a pointer to structure content */ mailimf_field *ffrom = 0; ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); return getFrom(ffrom); } mailimf_field *Generatemail::getField( mailimf_fields *fields, int type ) { mailimf_field *field; clistiter *it; it = clist_begin( fields->fld_list ); while ( it ) { field = (mailimf_field *) it->data; if ( field->fld_type == type ) { return field; } it = it->next; } return NULL; } @@ -84,233 +85,236 @@ mailimf_address_list *Generatemail::parseAddresses(const QString&addr ) { return NULL; addresses = mailimf_address_list_new_empty(); bool literal_open = false; unsigned int startpos = 0; QStringList list; QString s; unsigned int i = 0; for (; i < addr.length();++i) { switch (addr[i]) { case '\"': literal_open = !literal_open; break; case ',': if (!literal_open) { s = addr.mid(startpos,i-startpos); if (!s.isEmpty()) { list.append(s); } // !!!! this is a MUST BE! startpos = ++i; } break; default: break; } } s = addr.mid(startpos,i-startpos); if (!s.isEmpty()) { list.append(s); } QStringList::Iterator it; for ( it = list.begin(); it != list.end(); it++ ) { int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); if ( err != MAILIMF_NO_ERROR ) { qDebug(" Error parsing"); // *it } else { } } return addresses; } mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { mailmime * filePart = 0; mailmime_fields * fields = 0; mailmime_content * content = 0; mailmime_parameter * param = 0; char*name = 0; char*file = 0; int err; int pos = filename.findRev( '/' ); if (filename.length()>0) { QString tmp = filename.right( filename.length() - ( pos + 1 ) ); name = strdup( tmp.latin1() ); // just filename file = strdup( filename.latin1() ); // full name with path } int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; int mechanism = MAILMIME_MECHANISM_BASE64; if ( mimetype.startsWith( "text/" ) ) { param = mailmime_parameter_new( strdup( "charset" ), - strdup( "iso-8859-1" ) ); + strdup( mCharset.latin1() ) ); mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; } fields = mailmime_fields_new_filename( disptype, name, mechanism ); content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); if (content!=0 && fields != 0) { if (param) { clist_append(content->ct_parameters,param); param = 0; } if (filename.length()>0) { QFileInfo f(filename); param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); clist_append(content->ct_parameters,param); param = 0; } filePart = mailmime_new_empty( content, fields ); } if (filePart) { if (filename.length()>0) { err = mailmime_set_body_file( filePart, file ); } else { - err = mailmime_set_body_text(filePart,strdup( TextContent.utf8()),TextContent.utf8().length()); + err = mailmime_set_body_text(filePart,strdup( TextContent.utf8().data()),TextContent.utf8().length()); + //err = mailmime_set_body_text(filePart,strdup( TextContent.latin1()),TextContent.length()); } if (err != MAILIMF_NO_ERROR) { qDebug("Error setting body with file "); mailmime_free( filePart ); filePart = 0; } } if (!filePart) { if ( param != NULL ) { mailmime_parameter_free( param ); } if (content) { mailmime_content_free( content ); } if (fields) { mailmime_fields_free( fields ); } else { if (name) { free( name ); } if (file) { free( file ); } } } return filePart; // Success :) } void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) { const Attachment *it; unsigned int count = files.count(); for ( unsigned int i = 0; i < count; ++i ) { mailmime *filePart; int err; it = ((QList<Attachment>)files).at(i); filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); if ( filePart == NULL ) { continue; } err = mailmime_smart_add_part( message, filePart ); if ( err != MAILIMF_NO_ERROR ) { mailmime_free( filePart ); } } } mailmime *Generatemail::buildTxtPart(const QString&str ) { mailmime *txtPart; mailmime_fields *fields; mailmime_content *content; mailmime_parameter *param; int err; QCString __str; + //qDebug(" Generatemail::buildTxtPart %s", str.latin1()); param = mailmime_parameter_new( strdup( "charset" ), - strdup( "iso-8859-1" ) ); + strdup( mCharset.latin1() ) ); if ( param == NULL ) goto err_free; content = mailmime_content_new_with_str( "text/plain" ); if ( content == NULL ) goto err_free_param; err = clist_append( content->ct_parameters, param ); if ( err != MAILIMF_NO_ERROR ) goto err_free_content; fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); if ( fields == NULL ) goto err_free_content; txtPart = mailmime_new_empty( content, fields ); if ( txtPart == NULL ) goto err_free_fields; { - __str = str.utf8(); - err = mailmime_set_body_text( txtPart, __str.data(), __str.length() ); + //__str = str.utf8(); + __str = QCString (str.latin1()); + err = mailmime_set_body_text( txtPart, strdup(__str.data()), __str.length() ); } if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; return txtPart; // Success :) err_free_txtPart: mailmime_free( txtPart ); err_free_fields: mailmime_fields_free( fields ); err_free_content: mailmime_content_free( content ); err_free_param: mailmime_parameter_free( param ); err_free: ; return NULL; // Error :( } mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { return mailimf_mailbox_new( strdup( name.latin1() ), strdup( mail.latin1() ) ); } mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Mail>&mail ) { mailimf_fields *fields = NULL; mailimf_field *xmailer = NULL; mailimf_mailbox *sender=0,*fromBox=0; mailimf_mailbox_list *from=0; mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; clist*in_reply_to = 0; char *subject = strdup( mail->getSubject().latin1() ); int err; int res = 1; sender = newMailbox( mail->getName(), mail->getMail() ); if ( sender == NULL ) { res = 0; } if (res) { fromBox = newMailbox( mail->getName(), mail->getMail() ); } if ( fromBox == NULL ) { res = 0; } if (res) { from = mailimf_mailbox_list_new_empty(); } if ( from == NULL ) { res = 0; } if (res && from) { err = mailimf_mailbox_list_add( from, fromBox ); if ( err != MAILIMF_NO_ERROR ) { res = 0; } } if (res) to = parseAddresses( mail->getTo() ); @@ -337,125 +341,127 @@ mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Ma nsize = strlen(h.latin1()); /* yes! must be malloc! */ c_reply = (char*)malloc( (nsize+1)*sizeof(char)); memset(c_reply,0,nsize+1); memcpy(c_reply,h.latin1(),nsize); clist_append(in_reply_to,c_reply); } } if (res) { fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, in_reply_to, NULL, subject ); if ( fields == NULL ) { res = 0; } } if (res) xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), strdup( USER_AGENT ) ); if ( xmailer == NULL ) { res = 0; } else { err = mailimf_fields_add( fields, xmailer ); if ( err != MAILIMF_NO_ERROR ) { res = 0; } } if (!res ) { if (xmailer) { mailimf_field_free( xmailer ); xmailer = NULL; } if (fields) { mailimf_fields_free( fields ); fields = NULL; } else { if (reply) mailimf_address_list_free( reply ); if (bcc) mailimf_address_list_free( bcc ); if (cc) mailimf_address_list_free( cc ); if (to) mailimf_address_list_free( to ); if (fromBox) { mailimf_mailbox_free( fromBox ); } else if (from) { mailimf_mailbox_list_free( from ); } if (sender) { mailimf_mailbox_free( sender ); } if (subject) { free( subject ); } } } return fields; } mailmime *Generatemail::createMimeMail(const Opie::Core::OSmartPointer<Mail> &mail ) { mailmime *message, *txtPart; mailimf_fields *fields; int err; + //LR disabled for now + //mCharset = mail->getCharset().lower(); fields = createImfFields( mail ); if ( fields == NULL ) goto err_free; message = mailmime_new_message_data( NULL ); if ( message == NULL ) goto err_free_fields; mailmime_set_imf_fields( message, fields ); txtPart = buildTxtPart( mail->getMessage() ); if ( txtPart == NULL ) goto err_free_message; err = mailmime_smart_add_part( message, txtPart ); if ( err != MAILIMF_NO_ERROR ) goto err_free_txtPart; addFileParts( message, mail->getAttachments() ); return message; // Success :) err_free_txtPart: mailmime_free( txtPart ); err_free_message: mailmime_free( message ); err_free_fields: mailimf_fields_free( fields ); err_free: ; return NULL; // Error :( } clist *Generatemail::createRcptList( mailimf_fields *fields ) { clist *rcptList; mailimf_field *field; rcptList = esmtp_address_list_new(); field = getField( fields, MAILIMF_FIELD_TO ); if ( field && (field->fld_type == MAILIMF_FIELD_TO) && field->fld_data.fld_to->to_addr_list ) { addRcpts( rcptList, field->fld_data.fld_to->to_addr_list ); } field = getField( fields, MAILIMF_FIELD_CC ); if ( field && (field->fld_type == MAILIMF_FIELD_CC) && field->fld_data.fld_cc->cc_addr_list ) { addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list ); } field = getField( fields, MAILIMF_FIELD_BCC ); if ( field && (field->fld_type == MAILIMF_FIELD_BCC) && field->fld_data.fld_bcc->bcc_addr_list ) { addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list ); } return rcptList; } diff --git a/kmicromail/libmailwrapper/generatemail.h b/kmicromail/libmailwrapper/generatemail.h index b9f8285..a9fb648 100644 --- a/kmicromail/libmailwrapper/generatemail.h +++ b/kmicromail/libmailwrapper/generatemail.h @@ -1,47 +1,48 @@ #ifndef __GENERATE_MAIL_H #define __GENERATE_MAIL_H //#include <qpe/applnk.h> #include <qobject.h> #include <libetpan/clist.h> #include "mailwrapper.h" #include <opie2/osmartpointer.h> class Mail; class RecMail; struct mailimf_fields; struct mailimf_field; struct mailimf_mailbox; struct mailmime; struct mailimf_address_list; class progressMailSend; struct mailsmtp; class Generatemail : public QObject { Q_OBJECT public: Generatemail(); virtual ~Generatemail(); protected: static void addRcpts( clist *list, mailimf_address_list *addr_list ); static char *getFrom( mailmime *mail ); static char *getFrom( mailimf_field *ffrom); static mailimf_field *getField( mailimf_fields *fields, int type ); mailimf_address_list *parseAddresses(const QString&addr ); void addFileParts( mailmime *message,const QList<Attachment>&files ); mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); mailmime *buildTxtPart(const QString&str ); mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); mailimf_fields *createImfFields(const Opie::Core::OSmartPointer<Mail> &mail ); mailmime *createMimeMail(const Opie::Core::OSmartPointer<Mail>&mail ); clist *createRcptList( mailimf_fields *fields ); static const char* USER_AGENT; + QString mCharset; }; #endif diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index 28d45ce..eac05e5 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp @@ -164,129 +164,130 @@ QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) enc = "8bit"; break; case MAILMIME_MECHANISM_BINARY: enc = "binary"; break; case MAILMIME_MECHANISM_QUOTED_PRINTABLE: enc = "quoted-printable"; break; case MAILMIME_MECHANISM_BASE64: enc = "base64"; break; case MAILMIME_MECHANISM_TOKEN: default: if (aEnc->enc_token) { enc = QString(aEnc->enc_token); } break; } return enc; } void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) { if (current_rec >= 10) { ; // odebug << "too deep recursion!" << oendl; } if (!message || !mime) { return; } int r; char*data = 0; size_t len; clistiter * cur = 0; QString b; RecPartP part = new RecPart(); switch (mime->mm_type) { case MAILMIME_SINGLE: { QValueList<int>countlist = recList; countlist.append(current_count); r = mailmessage_fetch_section(message,mime,&data,&len); part->setSize(len); part->setPositionlist(countlist); b = gen_attachment_id(); part->setIdentifier(b); fillSingleBody(part,message,mime); if (part->Type()=="text" && target->Bodytext().isNull()) { encodedString*rs = new encodedString(); rs->setContent(data,len); encodedString*res = decode_String(rs,part->Encoding()); if (countlist.count()>2) { bodyCache[b]=rs; target->addPart(part); } else { delete rs; } b = QString(res->Content()); delete res; size_t index = 0; char*resu = 0; int err = MAILIMF_NO_ERROR; QString charset = part->searchParamter( "charset"); qDebug("CHARSET %s ",charset.latin1() ); - if ( !charset.isEmpty() ) { + if (false ) { + //if ( !charset.isEmpty() ) { target->setCharset( charset ); err = mailmime_encoded_phrase_parse(charset.latin1(), b.latin1(), b.length(),&index, "utf-8",&resu); if (err == MAILIMF_NO_ERROR && resu && strlen(resu)) { //qDebug("res %d %s ", index, resu); b = QString::fromUtf8(resu); } if (resu) free(resu); } target->setBodytext(b); target->setDescription(part); } else { bodyCache[b]=new encodedString(data,len); target->addPart(part); } } break; case MAILMIME_MULTIPLE: { unsigned int ccount = 1; mailmime*cbody=0; QValueList<int>countlist = recList; for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { cbody = (mailmime*)clist_content(cur); if (cbody->mm_type==MAILMIME_MULTIPLE) { RecPartP targetPart = new RecPart(); targetPart->setType("multipart"); countlist.append(current_count); targetPart->setPositionlist(countlist); target->addPart(targetPart); } traverseBody(target,message, cbody,countlist,current_rec+1,ccount); if (cbody->mm_type==MAILMIME_MULTIPLE) { countlist = recList; } ++ccount; } } break; case MAILMIME_MESSAGE: { QValueList<int>countlist = recList; countlist.append(current_count); /* the own header is always at recursion 0 - we don't need that */ if (current_rec > 0) { part->setPositionlist(countlist); r = mailmessage_fetch_section(message,mime,&data,&len); part->setSize(len); part->setPositionlist(countlist); b = gen_attachment_id(); part->setIdentifier(b); part->setType("message"); part->setSubtype("rfc822"); bodyCache[b]=new encodedString(data,len); target->addPart(part); } if (mime->mm_data.mm_message.mm_msg_mime != NULL) { traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); } } break; } } diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 2a54381..da7065f 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp @@ -698,130 +698,130 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int 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() ) { + 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); countlist.append(current_count); targetPart->setPositionlist(countlist); target_body->addPart(targetPart); QString id(""); for (unsigned int j = 0; j < countlist.count();++j) { id+=(j>0?" ":""); id+=QString("%1").arg(countlist[j]); } // 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; } ++ccount; } } break; default: break; } } void IMAPwrapper::fillSinglePart(RecPartP&target_part,mailimap_body_type_1part*Description) { if (!Description) { diff --git a/kmicromail/libmailwrapper/mailwrapper.h b/kmicromail/libmailwrapper/mailwrapper.h index ea6bf36..3e8b51f 100644 --- a/kmicromail/libmailwrapper/mailwrapper.h +++ b/kmicromail/libmailwrapper/mailwrapper.h @@ -22,110 +22,110 @@ public: const QString getMimeType()const{ return doc.type(); } const QPixmap getPixmap()const{ return doc.pixmap(); } const int getSize()const { return size; } DocLnk getDocLnk() { return doc; } protected: DocLnk doc; int size; }; */ class Attachment { public: Attachment( QString lnk ); virtual ~Attachment(){} const QString getFileName()const{ return doc; } const QString getName()const{ return QFileInfo( doc ).baseName (); } const QString getMimeType()const{ return QFileInfo( doc ).extension(false); } const QPixmap getPixmap()const{ return mPix; } const int getSize()const { return size; } QString getDocLnk() { return doc; } protected: QPixmap mPix; QString doc; int size; }; class Mail:public Opie::Core::ORefCount { public: Mail(); /* Possible that this destructor must not be declared virtual * 'cause it seems that it will never have some child classes. * in this case this object will not get a virtual table -> memory and * speed will be a little bit better? */ virtual ~Mail(){} void addAttachment( Attachment *att ) { attList.append( att ); } const QList<Attachment>& getAttachments()const { return attList; } void removeAttachment( Attachment *att ) { attList.remove( att ); } const QString&getName()const { return name; } void setName( QString s ) { name = s; } const QString&getMail()const{ return mail; } void setMail( const QString&s ) { mail = s; } const QString&getTo()const{ return to; } void setTo( const QString&s ) { to = s; } const QString&getCC()const{ return cc; } void setCC( const QString&s ) { cc = s; } const QString&getBCC()const { return bcc; } void setBCC( const QString&s ) { bcc = s; } const QString&getMessage()const { return message; } void setMessage( const QString&s ) { message = s; } const QString&getSubject()const { return subject; } void setSubject( const QString&s ) { subject = s; } const QString&getReply()const{ return reply; } void setReply( const QString&a ) { reply = a; } void setInreply(const QStringList&list){m_in_reply_to = list;} const QStringList&Inreply()const{return m_in_reply_to;} void setCharset( const QString&a ) { charset= a; } - const QString& getCharset() { return charset; } + const QString& getCharset() const { return charset; } private: QList<Attachment> attList; QString name, mail, to, cc, bcc, reply, subject, message, charset; QStringList m_in_reply_to; }; class Folder:public Opie::Core::ORefCount { public: Folder( const QString&init_name,const QString&sep ); virtual ~Folder(); const QString&getDisplayName()const { return nameDisplay; } const QString&getName()const { return name; } const QString&getPrefix()const{return prefix; } virtual bool may_select()const{return true;} virtual bool no_inferior()const{return true;} const QString&Separator()const; protected: QString nameDisplay, name, separator,prefix; }; typedef Opie::Core::OSmartPointer<Folder> FolderP; class MHFolder : public Folder { public: MHFolder(const QString&disp_name,const QString&mbox); virtual ~MHFolder(); }; class IMAPFolder : public Folder { public: IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); virtual ~IMAPFolder(); virtual bool may_select()const{return m_MaySelect;} virtual bool no_inferior()const{return m_NoInferior;} static QString decodeFolderName( const QString &name ); private: bool m_MaySelect,m_NoInferior; }; #endif diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp index 3013931..8c0a4cb 100644 --- a/kmicromail/mainwindow.cpp +++ b/kmicromail/mainwindow.cpp @@ -46,129 +46,130 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) connect(getMail, SIGNAL( activated() ), SLOT( slotGetAllMail() ) ); getMail->addTo( mailMenu ); getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"), 0, 0, this ); getMail->addTo( toolBar ); getMail->addTo( mailMenu ); connect(getMail, SIGNAL( activated() ), SLOT( slotGetMail() ) ); composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"), 0, 0, this ); composeMail->addTo( toolBar ); composeMail->addTo( mailMenu ); sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") , 0, 0, this ); sendQueued->addTo( toolBar ); sendQueued->addTo( mailMenu ); /* syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC, 0, 0, this ); syncFolders->addTo( toolBar ); syncFolders->addTo( mailMenu ); */ showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") , 0, 0, this, 0, true ); showFolders->addTo( toolBar ); showFolders->addTo( mailMenu ); showFolders->setOn( true ); connect(showFolders, SIGNAL( toggled(bool) ), SLOT( slotShowFolders(bool) ) ); /* searchMails = new QAction( i18n( "Search mails" ), SmallIcon("find") ), 0, 0, this ); searchMails->addTo( toolBar ); searchMails->addTo( mailMenu ); */ deleteMails = new QAction(i18n("Delete Mail"), SmallIcon("trash"), 0, 0, this); deleteMails->addTo( toolBar ); deleteMails->addTo( mailMenu ); connect( deleteMails, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); editSettings = new QAction( i18n( "Edit settings" ), SmallIcon("SettingsIcon") , 0, 0, this ); editSettings->addTo( settingsMenu ); connect( editSettings, SIGNAL( activated() ), SLOT( slotEditSettings() ) ); editAccounts = new QAction( i18n( "Configure accounts" ), SmallIcon("editaccounts") , 0, 0, this ); editAccounts->addTo( settingsMenu ); codecMenu = new QPopupMenu( menuBar ); codecMenu->insertItem( "Western (iso-8859-1)",0,0); codecMenu->insertItem( "Cyrillic (iso-8859-5)",1,1); codecMenu->insertItem( "Western (iso-8859-15)",2,2); codecMenu->insertItem( "Chinese (big-5)",3,3); codecMenu->insertItem( "Unicode (utf-8)",4,4); codecMenu->insertItem( "Userdefined ("+KOPrefs::instance()->mSendCodec+")",5,5); - settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu); + //disabled + //settingsMenu->insertItem( i18n("Codec for new mails"), codecMenu); //setCentralWidget( view ); QVBox* wrapperBox = new QVBox( this ); setCentralWidget( wrapperBox ); // QWidget *view = new QWidget( wrapperBox ); KDGanttMinimizeSplitter* split = new KDGanttMinimizeSplitter( Qt::Horizontal, wrapperBox); split->setMinimizeDirection( KDGanttMinimizeSplitter::Left); //layout = new QBoxLayout ( split, QBoxLayout::LeftToRight ); folderView = new AccountView( split ); folderView->header()->hide(); folderView->setRootIsDecorated( false ); folderView->addColumn( i18n( "Mailbox" ) ); //layout->addWidget( folderView ); mailView = new QListView( split ); mailView->addColumn( i18n( " " ) ); mailView->addColumn( i18n( "Subject" ),QListView::Manual ); mailView->addColumn( i18n( "Sender" ),QListView::Manual ); mailView->addColumn( i18n( "Size" ),QListView::Manual); mailView->addColumn( i18n( "Date" ),QListView::Manual); mailView->setAllColumnsShowFocus(true); //mailView->setSorting(-1); mailView->setRootIsDecorated( false ); statusWidget = new StatusWidget( wrapperBox ); statusWidget->hide(); //layout->addWidget( mailView ); //layout->setStretchFactor( folderView, 1 ); //layout->setStretchFactor( mailView, 2 ); slotAdjustLayout(); #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); #endif connect( mailView, SIGNAL( doubleClicked (QListViewItem* )),this, SLOT( mailLeftClicked(QListViewItem*) ) ); connect( mailView, SIGNAL( returnPressed (QListViewItem* )),this, SLOT( mailLeftClicked(QListViewItem*) ) ); connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); connect(folderView, SIGNAL(refreshMailview(const QValueList<RecMailP>&)), this,SLOT(refreshMailView(const QValueList<RecMailP>&))); connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); //mailView->setMultiSelection ( true ); mailView->setSelectionMode( QListView::Extended ); QValueList<int> list; int fw = 100; if ( QApplication::desktop()->width() > 320 ) fw = 50; list.append( fw ); list.append( 100 ); split->setSizes( list ); QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); mailView->setShowSortIndicator ( true ); QLabel *spacer = new QLabel( toolBar ); spacer->setBackgroundMode( QWidget::PaletteButton ); toolBar->setStretchableWidget( spacer ); |