From 38301e81221e7e51cc67a5e366498a71df288263 Mon Sep 17 00:00:00 2001 From: alwin Date: Mon, 08 Mar 2004 03:06:39 +0000 Subject: when reply to a mail, a in-reply-to header will generated. ToDo: setup the reference-list-header. --- (limited to 'noncore') diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index f8ac76f..b5cd75b 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp @@ -14,6 +14,7 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m : ComposeMailUI( parent, name, modal, flags ) { settings = s; + m_replyid = ""; QString vfilename = Global::applicationFileName("addressbook", "businesscard.vcf"); @@ -84,14 +85,7 @@ void ComposeMail::pickAddress( QLineEdit *line ) void ComposeMail::setTo( const QString & to ) { -/* QString toline; - QStringList toEntry = to; - for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) { - toline += (*it); - } - toLine->setText( toline ); -*/ -toLine->setText( to ); + toLine->setText( to ); } void ComposeMail::setSubject( const QString & subject ) @@ -101,7 +95,7 @@ void ComposeMail::setSubject( const QString & subject ) void ComposeMail::setInReplyTo( const QString & messageId ) { - + m_replyid = messageId; } void ComposeMail::setMessage( const QString & text ) @@ -207,6 +201,11 @@ void ComposeMail::accept() 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(); if ( !sigMultiLine->text().isEmpty() ) { txt.append( "\n--\n" ); diff --git a/noncore/net/mail/composemail.h b/noncore/net/mail/composemail.h index 604c862..886fb1d 100644 --- a/noncore/net/mail/composemail.h +++ b/noncore/net/mail/composemail.h @@ -54,12 +54,10 @@ private slots: void addAttachment(); void removeAttachment(); - - -private: +protected: Settings *settings; QList smtpAccounts; - + QString m_replyid; }; class AttachViewItem : public QListViewItem diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index bf91c63..96e0fd5 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp @@ -34,6 +34,7 @@ void RecMail::copy_old(const RecMail&old) cc = old.cc; bcc = old.bcc; wrapper = old.wrapper; + in_reply_to = old.in_reply_to; } void RecMail::init() @@ -41,6 +42,7 @@ void RecMail::init() to.clear(); cc.clear(); bcc.clear(); + in_reply_to.clear(); wrapper = 0; } @@ -84,6 +86,17 @@ const QStringList& RecMail::Bcc()const return bcc; } +void RecMail::setInreply(const QStringList&list) +{ + in_reply_to = list; +} + +const QStringList& RecMail::Inreply()const +{ + return in_reply_to; +} + + RecPart::RecPart() : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) { diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index b2047cb..1420f79 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h @@ -59,6 +59,8 @@ public: const QStringList&CC()const; void setBcc(const QStringList&list); const QStringList&Bcc()const; + void setInreply(const QStringList&list); + const QStringList&Inreply()const; const QBitArray&getFlags()const{return msg_flags;} void setFlags(const QBitArray&flags){msg_flags = flags;} @@ -69,7 +71,7 @@ protected: QString subject,date,from,mbox,msg_id,replyto; int msg_number,msg_size; QBitArray msg_flags; - QStringList to,cc,bcc; + QStringList to,cc,bcc,in_reply_to; AbstractMail*wrapper; void init(); void copy_old(const RecMail&old); diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h index caaa3a2..3a9f97b 100644 --- a/noncore/net/mail/libmailwrapper/mailwrapper.h +++ b/noncore/net/mail/libmailwrapper/mailwrapper.h @@ -55,10 +55,13 @@ public: 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;} private: QList attList; QString name, mail, to, cc, bcc, reply, subject, message; + QStringList m_in_reply_to; }; class Folder : public QObject diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index d7a005e..63acfd5 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp @@ -149,6 +149,7 @@ mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { 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; @@ -175,9 +176,35 @@ mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { cc = parseAddresses( mail.getCC() ); bcc = parseAddresses( mail.getBCC() ); reply = parseAddresses( mail.getReply() ); + + if (mail.Inreply().count()>0) { + in_reply_to = clist_new(); + char*c_reply; + unsigned int nsize = 0; + for (QStringList::ConstIterator it=mail.Inreply().begin(); + it != mail.Inreply().end();++it) { + /* yes! must be malloc! */ + if ((*it).isEmpty()) + continue; + QString h((*it)); + 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.isEmpty()) continue; + nsize = strlen(h.latin1()); + 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); + qDebug("In reply to: %s",c_reply); + } + } fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, - NULL, NULL, subject ); + in_reply_to, NULL, subject ); if ( fields == NULL ) goto err_free_reply; diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index ec93f8d..84f8a90 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp @@ -409,14 +409,16 @@ void ViewMail::slotReply() rtext += "\n"; QString prefix; - if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) 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); composer.setTo( m_mail[0] ); - composer.setSubject( "Re: " + m_mail[1] ); + composer.setSubject( prefix + m_mail[1] ); composer.setMessage( rtext ); + composer.setInReplyTo(m_recMail.Msgid()); + if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) ) { m_recMail.Wrapper()->answeredMail(m_recMail); -- cgit v0.9.0.2