-rw-r--r-- | kmicromail/composemail.cpp | 58 | ||||
-rw-r--r-- | kmicromail/composemail.h | 2 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 11 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.cpp | 11 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailtypes.h | 3 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/mailwrapper.h | 5 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/storemail.cpp | 12 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 2 | ||||
-rw-r--r-- | kmicromail/viewmail.cpp | 1 |
10 files changed, 74 insertions, 32 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index f44100b..49fd14f 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp @@ -1,75 +1,77 @@ // CHANGED 2004-08-06 Lutz Rogowski -#include <kabc/addresseedialog.h> -#include <kabc/stdaddressbook.h> -#include <kabc/addressee.h> + #ifdef DESKTOP_VERSION #include <qapplication.h> #include <kabc/addresseedialog.h> +#include <kabc/stdaddressbook.h> +#include <kabc/addressee.h> #endif //DESKTOP_VERSION #include <libkdepim/externalapphandler.h> #include "koprefs.h" #ifdef MINIKDE_KDIALOG_H #undef MINIKDE_KDIALOG_H #endif #include "composemail.h" #include <libmailwrapper/smtpwrapper.h> #include <libmailwrapper/storemail.h> #include <libmailwrapper/abstractmail.h> #include <libmailwrapper/mailtypes.h> /* OPIE */ //#include <opie2/ofiledialog.h> //#include <opie2/odebug.h> #include <kfiledialog.h> //#include <qpe/resource.h> #include <qpe/global.h> //#include <qpe/contact.h> #include <qcombobox.h> #include <qcheckbox.h> #include <qiconset.h> #include <qtimer.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qmultilineedit.h> #include <qlabel.h> #include <qtabwidget.h> #include <qlistview.h> //using namespace Opie::Core; //using namespace Opie::Ui; ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, bool modal ) : ComposeMailUI( parent, name, modal ) { + mPickLineEdit = 0; + mEncoding = KOPrefs::instance()->mCurrentCodeName; connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); settings = sett; m_replyid = ""; if ( KOPrefs::instance()->mUseKapi) { KConfig config( locateLocal("config", "kabcrc") ); config.setGroup( "General" ); QString whoami_uid = config.readEntry( "WhoAmI" ); if ( whoami_uid.isEmpty() ) { QMessageBox::information( 0, i18n( "Hint" ), i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), i18n( "Ok" ) ); fillSettings(); } else ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); #ifdef DESKTOP_VERSION KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); QStringList mails = con.emails(); QString defmail = con.preferredEmail(); @@ -144,67 +146,67 @@ ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, boo } connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); } void ComposeMail::fillSettings() { if ( QApplication::desktop()->width() < 320 ) fromBox->setMaximumWidth( 100 ); QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); QStringList::ConstIterator sit = mailList.begin(); int pref = 0; for (;sit!=mailList.end();++sit) { fromBox->insertItem((*sit)); } senderNameEdit->setText(KOPrefs::instance()->mName); } void ComposeMail::saveAsDraft() { Opie::Core::OSmartPointer<Mail> mail= new Mail(); - mail->setMail(fromBox->currentText().utf8 ()); - mail->setTo( toLine->text().utf8 () ); - mail->setName(senderNameEdit->text().utf8 ()); - mail->setCC( ccLine->text().utf8 () ); - mail->setBCC( bccLine->text().utf8 () ); - mail->setReply( replyLine->text().utf8 () ); - mail->setSubject( subjectLine->text().utf8 () ); + mail->setMail(fromBox->currentText()); + mail->setTo( toLine->text() ); + mail->setName(senderNameEdit->text()); + mail->setCC( ccLine->text() ); + mail->setBCC( bccLine->text() ); + mail->setReply( replyLine->text() ); + mail->setSubject( subjectLine->text() ); if (!m_replyid.isEmpty()) { QStringList ids; ids.append(m_replyid); mail->setInreply(ids); } - QString txt = message->text().utf8 (); + QString txt = message->text(); if ( !sigMultiLine->text().isEmpty() ) { txt.append( "\n--\n" ); txt.append( sigMultiLine->text() ); } mail->setMessage( txt ); - + mail->setCharset (mEncoding); /* only use the default drafts folder name! */ Storemail wrapper(AbstractMail::draftFolder()); wrapper.storeMail(mail); AttachViewItem *it = (AttachViewItem *) attList->firstChild(); /* attachments we will ignore! */ if ( it != 0 ) { if ( warnAttach ) QMessageBox::warning(0,i18n("Store message"), i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); warnAttach = false; } setStatus( i18n("Mail saved as draft!") ); } void ComposeMail::clearStatus() { topLevelWidget()->setCaption( i18n("Compose mail") ); } void ComposeMail::setStatus( QString status ) { topLevelWidget()->setCaption( status ); QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; } void ComposeMail::pickAddress( ) @@ -387,117 +389,127 @@ void ComposeMail::accept() { if ( smtpAccountBox->count() == 0 ) { reject(); return; } if (! checkBoxLater->isChecked() ) { int yesno = QMessageBox::warning(0,i18n("Stop editing message"), i18n("Send this message?"), i18n("Yes"), i18n("Cancel")); if (yesno == 1) { return; } } #if 0 odebug << "Sending Mail with " << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; #endif Opie::Core::OSmartPointer<Mail> mail=new Mail; SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); - mail->setMail(fromBox->currentText().utf8 ()); + mail->setMail(fromBox->currentText()); if ( !toLine->text().isEmpty() ) { - mail->setTo( toLine->text().utf8 () ); + mail->setTo( toLine->text() ); } else { QMessageBox::warning(0,i18n("Sending mail"), i18n("No Receiver spezified" ) ); return; } - mail->setName(senderNameEdit->text().utf8 ()); - mail->setCC( ccLine->text().utf8 () ); - mail->setBCC( bccLine->text().utf8 () ); - mail->setReply( replyLine->text().utf8 () ); - mail->setSubject( subjectLine->text().utf8 () ); + mail->setName(senderNameEdit->text()); + mail->setCC( ccLine->text() ); + mail->setBCC( bccLine->text() ); + mail->setReply( replyLine->text() ); + mail->setSubject( subjectLine->text() ); if (!m_replyid.isEmpty()) { QStringList ids; - ids.append(m_replyid.utf8 ()); + ids.append(m_replyid); mail->setInreply(ids); } - QString txt = message->text().utf8 (); + QString txt = message->text(); if ( !sigMultiLine->text().isEmpty() ) { txt.append( "\n--\n" ); - txt.append( sigMultiLine->text().utf8 () ); + txt.append( sigMultiLine->text() ); } mail->setMessage( txt ); + mail->setCharset (mEncoding); AttachViewItem *it = (AttachViewItem *) attList->firstChild(); while ( it != 0 ) { mail->addAttachment( it->getAttachment() ); it = (AttachViewItem *) it->nextSibling(); } SMTPwrapper wrapper( smtp ); if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) setStatus( tr ("Mail sent")); else { setStatus( tr ("Error: Something went wrong. Nothing sent")); return; } QDialog::accept(); } void ComposeMail::reject() { //qDebug("ComposeMail::reject() "); int yesno = QMessageBox::warning(0,i18n("Store message?"), i18n("Store message into drafts?\n"), i18n("Yes"), i18n("No")); //qDebug("button %d ", yesno); if (yesno == 0) { if ( toLine->text().isEmpty() ) { QMessageBox::warning(0,i18n("Sending mail"), i18n("No Receiver spezified" ) ); return; } saveAsDraft(); } if (yesno == 2) { qDebug("return "); return; } QDialog::reject(); } +void ComposeMail::setCharset(const QString& charset) +{ + if ( !charset.isEmpty() ) + mEncoding = charset; + qDebug("ComposeMail::setCharset %s ", mEncoding.latin1()); +} ComposeMail::~ComposeMail() { } void ComposeMail::reEditMail(const RecMailP¤t) { RecMailP data = current; - message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); + RecBodyP body = data->Wrapper()->fetchBody(current); + + message->setText(body->Bodytext()); subjectLine->setText( data->getSubject()); toLine->setText(data->To().join(",")); ccLine->setText(data->CC().join(",")); bccLine->setText(data->Bcc().join(",")); replyLine->setText(data->Replyto()); + setCharset(body->getCharset()); } AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) : QListViewItem( parent ) { attachment = att; if ( !attachment->getPixmap().isNull() ) setPixmap( 0,attachment->getPixmap() ); setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); setText( 1, QString::number( att->getSize() ) ); } diff --git a/kmicromail/composemail.h b/kmicromail/composemail.h index 0fc41fb..a7fa41c 100644 --- a/kmicromail/composemail.h +++ b/kmicromail/composemail.h @@ -27,65 +27,67 @@ protected: }; #endif class RecMail; class ComposeMail : public ComposeMailUI { Q_OBJECT public: ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false ); virtual ~ComposeMail(); void reEditMail(const Opie::Core::OSmartPointer<RecMail>¤t); public slots: void slotAdjustColumns(); void setTo( const QString & to ); void setSubject( const QString & subject ); void setInReplyTo( const QString & messageId ); void setMessage( const QString & text ); void insertAttendees(const QString&, const QStringList& namelist, const QStringList& emaillist, const QStringList& uidlist); + void setCharset(const QString&); protected slots: void accept(); void reject(); private slots: void fillValues( int current ); void fillSettings(); void pickAddress(); void pickAddressTo(); void pickAddressCC(); void pickAddressBCC(); void pickAddressReply(); void saveAsDraft(); void addAttachment(); void removeAttachment(); void clearStatus(); void setStatus( QString ); protected: QLineEdit* mPickLineEdit; Opie::Core::OSmartPointer<Mail> mMail; Settings *settings; QList<SMTPaccount> smtpAccounts; QString m_replyid; + QString mEncoding; bool warnAttach; }; class AttachViewItem : public QListViewItem { public: AttachViewItem( QListView *parent, Attachment *att ); Attachment *getAttachment() { return attachment; } private: Attachment *attachment; }; #endif diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index 49227dd..28d45ce 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp @@ -205,48 +205,49 @@ void Genericwrapper::traverseBody(RecBodyP&target,mailmessage*message,mailmime*m 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() ) { + 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) { diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index eb2b47d..2a54381 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp @@ -29,49 +29,49 @@ IMAPwrapper::~IMAPwrapper() logout(); } /* to avoid to often select statements in loops etc. we trust that we are logged in and connection is established!*/ int IMAPwrapper::selectMbox(const QString&mbox) { if (mbox == m_Lastmbox) { return MAILIMAP_NO_ERROR; } int err = mailimap_select( m_imap, (char*)mbox.latin1()); if ( err != MAILIMAP_NO_ERROR ) { m_Lastmbox = ""; return err; } m_Lastmbox = mbox; return err; } void IMAPwrapper::imap_progress( size_t current, size_t maximum ) { //qDebug("imap progress %d of %d ",current,maximum ); //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); //qApp->processEvents() - static int last = 0; + static unsigned int last = 0; if ( last != current ) IMAPwrapper::progress(); last = current; } void IMAPwrapper::progress( QString m ) { static QString mProgrMess; if ( m != QString::null ) { mProgrMess = m; mCurrent = 1; return; } QString mess; //qDebug("progress "); if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); Global::statusMessage(mess); //qDebug("Progress %s %s", mess.latin1(), m.latin1()); qApp->processEvents(); } bool IMAPwrapper::start_tls(bool force_tls) { int err; @@ -268,52 +268,52 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma 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; + msg_att = (mailimap_msg_att*)current->data; RecMail*m = parse_list_result(msg_att); if (m) { - if ( maxSizeInKb == 0 || m->Msgsize()<=maxSizeInKb*1024 ) { + 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; @@ -394,49 +394,49 @@ QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() 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; + 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 "); @@ -740,48 +740,49 @@ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&t 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; @@ -1161,49 +1162,49 @@ int IMAPwrapper::deleteAllMail(const FolderP&folder) err = mailimap_store(m_imap,set,store_flags); mailimap_set_free( set ); mailimap_store_att_flags_free(store_flags); if (err != MAILIMAP_NO_ERROR) { Global::statusMessage(i18n("error deleting mail: %s").arg(m_imap->imap_response)); return 0; } // 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(i18n("error deleting mail: %s").arg(m_imap->imap_response)); return 0; } // odebug << "Delete successfull " << m_imap->imap_response << "" << oendl; return 1; } int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder) { if (folder.length()==0) return 0; login(); if (!m_imap) {return 0;} QString pre = account->getPrefix(); - if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) { + if (delemiter.length()>0 && pre.findRev(delemiter)!=((int)pre.length())-1) { pre+=delemiter; } if (parentfolder) { pre += parentfolder->getDisplayName()+delemiter; } pre+=folder; if (getsubfolder) { if (delemiter.length()>0) { pre+=delemiter; } else { Global::statusMessage(i18n("Cannot create folder %1 for holding subfolders").arg(pre)); return 0; } } // odebug << "Creating " << pre.latin1() << "" << oendl; int res = mailimap_create(m_imap,pre.latin1()); if (res != MAILIMAP_NO_ERROR) { Global::statusMessage(i18n("%1").arg(m_imap->imap_response)); return 0; } return 1; } int IMAPwrapper::deleteMbox(const FolderP&folder) diff --git a/kmicromail/libmailwrapper/mailtypes.cpp b/kmicromail/libmailwrapper/mailtypes.cpp index af3b9d0..89150ad 100644 --- a/kmicromail/libmailwrapper/mailtypes.cpp +++ b/kmicromail/libmailwrapper/mailtypes.cpp @@ -266,91 +266,102 @@ const QString RecPart::searchParamter(const QString&key)const } void RecPart::setPositionlist(const QValueList<int>&poslist) { m_poslist = poslist; } const QValueList<int>& RecPart::Positionlist()const { return m_poslist; } RecBody::RecBody() : Opie::Core::ORefCount(),m_BodyText(),m_description(new RecPart()) { m_PartsList.clear(); } RecBody::RecBody(const RecBody&old) :Opie::Core::ORefCount(),m_BodyText(),m_PartsList(),m_description(new RecPart()) { m_BodyText = old.m_BodyText; m_PartsList = old.m_PartsList; m_description = old.m_description; + mCharset = old.mCharset; // odebug << "Recbody copy constructor" << oendl; } RecBody::~RecBody() { } void RecBody::setBodytext(const QString&bodyText) { m_BodyText = bodyText; } const QString& RecBody::Bodytext()const { return m_BodyText; } void RecBody::setParts(const QValueList<RecPartP>&parts) { m_PartsList.clear(); m_PartsList = parts; } const QValueList<RecPartP>& RecBody::Parts()const { return m_PartsList; } void RecBody::addPart(const RecPartP& part) { m_PartsList.append(part); } void RecBody::setDescription(const RecPartP&des) { m_description = des; } const RecPartP& RecBody::Description()const { return m_description; } +void RecBody::setCharset(const QString& str) +{ + mCharset = str; +} + +QString RecBody::getCharset()const +{ + return mCharset; +} + /* handling encoded content */ encodedString::encodedString() { init(); } encodedString::encodedString(const char*nContent,unsigned int nSize) { init(); setContent(nContent,nSize); } encodedString::encodedString(char*nContent,unsigned int nSize) { init(); setContent(nContent,nSize); } encodedString::encodedString(const encodedString&old) { init(); copy_old(old); // odebug << "encodedeString: copy constructor!" << oendl; } diff --git a/kmicromail/libmailwrapper/mailtypes.h b/kmicromail/libmailwrapper/mailtypes.h index c1c1a74..32d92c0 100644 --- a/kmicromail/libmailwrapper/mailtypes.h +++ b/kmicromail/libmailwrapper/mailtypes.h @@ -112,57 +112,60 @@ public: const QString&Encoding()const; void setEncoding(const QString&encoding); const QString&Description()const; void setDescription(const QString&desc); void setLines(unsigned int lines); const unsigned int Lines()const; void setSize(unsigned int size); const unsigned int Size()const; void setParameters(const part_plist_t&list); const part_plist_t&Parameters()const; void addParameter(const QString&key,const QString&value); const QString searchParamter(const QString&key)const; void setPositionlist(const QValueList<int>&poslist); const QValueList<int>& Positionlist()const; }; typedef Opie::Core::OSmartPointer<RecPart> RecPartP; class RecBody:public Opie::Core::ORefCount { protected: QString m_BodyText; + QString mCharset; QValueList<RecPartP> m_PartsList; RecPartP m_description; public: RecBody(); RecBody(const RecBody&old); virtual ~RecBody(); void setBodytext(const QString&); const QString& Bodytext()const; + void setCharset(const QString&); + QString getCharset()const; void setDescription(const RecPartP&des); const RecPartP& Description()const; void setParts(const QValueList<RecPartP>&parts); const QValueList<RecPartP>& Parts()const; void addPart(const RecPartP&part); }; typedef Opie::Core::OSmartPointer<RecBody> RecBodyP; class encodedString { public: encodedString(); /* creates an new content string. it makes a deep copy of it! */ encodedString(const char*nContent,unsigned int length); /* Take over the nContent. Means: it will just copy the pointer, not the content. so make sure: No one else frees the string, the string has allocated with malloc for compatibility with c-based libs diff --git a/kmicromail/libmailwrapper/mailwrapper.h b/kmicromail/libmailwrapper/mailwrapper.h index 88f10da..ea6bf36 100644 --- a/kmicromail/libmailwrapper/mailwrapper.h +++ b/kmicromail/libmailwrapper/mailwrapper.h @@ -61,51 +61,54 @@ public: */ 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; } + private: QList<Attachment> attList; - QString name, mail, to, cc, bcc, reply, subject, message; + 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: diff --git a/kmicromail/libmailwrapper/storemail.cpp b/kmicromail/libmailwrapper/storemail.cpp index ed1d44a..9d1735f 100644 --- a/kmicromail/libmailwrapper/storemail.cpp +++ b/kmicromail/libmailwrapper/storemail.cpp @@ -1,33 +1,34 @@ #include "storemail.h" #include "mailwrapper.h" #include "settings.h" #include "abstractmail.h" #include <libetpan/libetpan.h> #include <qstring.h> #include <stdlib.h> +#include <kglobal.h> using namespace Opie::Core; Storemail::Storemail(Account*aAccount,const QString&aFolder) : Generatemail() { wrapper = 0; m_Account = aAccount; m_tfolder = aFolder; wrapper = AbstractMail::getWrapper(m_Account); if (wrapper) { wrapper->createMbox(m_tfolder); } } Storemail::Storemail(const QString&dir,const QString&aFolder) : Generatemail() { wrapper = 0; m_Account = 0; m_tfolder = aFolder; wrapper = AbstractMail::getWrapper(dir); if (wrapper) { wrapper->createMbox(m_tfolder); } @@ -44,47 +45,54 @@ Storemail::Storemail(const QString&aFolder) wrapper->createMbox(m_tfolder); } } Storemail::~Storemail() { } int Storemail::storeMail(const Opie::Core::OSmartPointer<Mail>&mail) { if (!wrapper) return 0; int ret = 1; mailmime * mimeMail = 0; mimeMail = createMimeMail(mail ); if ( mimeMail == NULL ) { qDebug("storeMail: error creating mime mail "); return 0; } char *data; size_t size; data = 0; mailmessage * msg = 0; - msg = mime_message_init(mimeMail); - mime_message_set_tmpdir(msg,getenv( "HOME" )); + msg = mime_message_init(mimeMail); + QString fileName; +#ifdef DESKTOP_VERSION + fileName = locateLocal("tmp", ""); +#else + fileName = "/tmp/"; +#endif + //mime_message_set_tmpdir(msg,getenv( "HOME" )); + mime_message_set_tmpdir(msg,(char*)fileName.latin1()); int r = mailmessage_fetch(msg,&data,&size); mime_message_detach_mime(msg); mailmessage_free(msg); msg = 0; if (r != MAIL_NO_ERROR || !data) { qDebug("Error fetching mime... "); ret = 0; } if (ret) { wrapper->storeMessage(data,size,m_tfolder); } if (data) { free(data); } if (mimeMail) { mailmime_free( mimeMail ); } return ret; } diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index 18a5600..c20c7ce 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp @@ -270,49 +270,49 @@ void OpieMail::replyMail() QString text = body->Bodytext(); QStringList lines = QStringList::split(QRegExp("\\n"), text); QStringList::Iterator it; for (it = lines.begin(); it != lines.end(); it++) { rtext += "> " + *it + "\n"; } rtext += "\n"; QString prefix; if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; else prefix = "Re: "; // no i18n on purpose Settings *settings = new Settings(); ComposeMail composer( settings ,this, 0, true); if (mail->Replyto().isEmpty()) { composer.setTo( mail->getFrom()); } else { composer.setTo( mail->Replyto()); } composer.setSubject( prefix + mail->getSubject()); composer.setMessage( rtext ); composer.setInReplyTo( mail->Msgid()); - + composer.setCharset( body->getCharset() ); if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) { mail->Wrapper()->answeredMail(mail); } delete settings; } void OpieMail::displayMail() { QListViewItem*item = mailView->currentItem(); if (!item) return; RecMailP mail = ((MailListViewItem*)item)->data(); RecBodyP body = folderView->fetchBody(mail); ViewMail readMail( this,"", Qt::WType_Modal ); readMail.setBody( body ); readMail.setMail( mail ); #ifndef DESKTOP_VERSION readMail.showMaximized(); #else readMail.resize( 640, 480); #endif readMail.exec(); if ( readMail.deleted ) diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index 4883231..3bd6f41 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp @@ -436,48 +436,49 @@ void ViewMail::slotReply() QString text = m_mail[2]; QStringList lines = QStringList::split(QRegExp("\\n"), text); QStringList::Iterator it; for (it = lines.begin(); it != lines.end(); it++) { rtext += "> " + *it + "\n"; } rtext += "\n"; QString prefix; if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; else prefix = "Re: "; // no i18n on purpose Settings *settings = new Settings(); ComposeMail composer( settings ,this, 0, true); if (m_recMail->Replyto().isEmpty()) { composer.setTo(m_recMail->getFrom()); } else { composer.setTo(m_recMail->Replyto()); } composer.setSubject( prefix + m_mail[1] ); composer.setMessage( rtext ); composer.setInReplyTo(m_recMail->Msgid()); + composer.setCharset( m_body->getCharset() ); if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) { m_recMail->Wrapper()->answeredMail(m_recMail); } delete settings; } void ViewMail::slotForward() { if (!m_gotBody) { QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); return; } QString ftext; ftext += QString("\n----- Forwarded message from %1 -----\n\n") .arg( m_mail[0] ); if (!m_mail[3].isNull()) ftext += QString("Date: %1\n") .arg( m_mail[3] ); if (!m_mail[0].isNull()) ftext += QString("From: %1\n") |