summaryrefslogtreecommitdiff
path: root/noncore
authoralwin <alwin>2004-03-08 03:06:39 (UTC)
committer alwin <alwin>2004-03-08 03:06:39 (UTC)
commit38301e81221e7e51cc67a5e366498a71df288263 (patch) (side-by-side diff)
tree47cfc2c2bf399c7f8bec3be4007d4f69a4d0b07a /noncore
parenta3836842bfabc973f27f2686320f7a207c59b10a (diff)
downloadopie-38301e81221e7e51cc67a5e366498a71df288263.zip
opie-38301e81221e7e51cc67a5e366498a71df288263.tar.gz
opie-38301e81221e7e51cc67a5e366498a71df288263.tar.bz2
when reply to a mail, a in-reply-to header will generated.
ToDo: setup the reference-list-header.
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/composemail.cpp17
-rw-r--r--noncore/net/mail/composemail.h6
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp13
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h4
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.h3
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp29
-rw-r--r--noncore/net/mail/viewmail.cpp6
7 files changed, 61 insertions, 17 deletions
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
@@ -5,24 +5,25 @@
#include <qpe/config.h>
#include <qpe/global.h>
#include <qpe/contact.h>
#include "composemail.h"
#include <libmailwrapper/smtpwrapper.h>
ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
: ComposeMailUI( parent, name, modal, flags )
{
settings = s;
+ m_replyid = "";
QString vfilename = Global::applicationFileName("addressbook",
"businesscard.vcf");
Contact c;
if (QFile::exists(vfilename)) {
c = Contact::readVCard( vfilename )[0];
}
QStringList mails = c.emailList();
QString defmail = c.defaultEmail();
if (defmail.length()!=0) {
@@ -75,42 +76,35 @@ void ComposeMail::pickAddress( QLineEdit *line )
{
QString names = AddressPicker::getNames();
if ( line->text().isEmpty() ) {
line->setText( names );
} else if ( !names.isEmpty() ) {
line->setText( line->text() + ", " + names );
}
}
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 )
{
subjectLine->setText( subject );
}
void ComposeMail::setInReplyTo( const QString & messageId )
{
-
+ m_replyid = messageId;
}
void ComposeMail::setMessage( const QString & text )
{
message->setText( text );
}
void ComposeMail::pickAddressTo()
{
pickAddress( toLine );
}
@@ -198,24 +192,29 @@ void ComposeMail::accept()
if ( !toLine->text().isEmpty() ) {
mail->setTo( toLine->text() );
} else {
qDebug( "No Reciever spezified -> returning" );
return;
}
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();
if ( !sigMultiLine->text().isEmpty() ) {
txt.append( "\n--\n" );
txt.append( sigMultiLine->text() );
}
qDebug(txt);
mail->setMessage( txt );
AttachViewItem *it = (AttachViewItem *) attList->firstChild();
while ( it != NULL ) {
mail->addAttachment( it->getAttachment() );
it = (AttachViewItem *) it->nextSibling();
}
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
@@ -45,30 +45,28 @@ protected slots:
void accept();
private slots:
void fillValues( int current );
void pickAddress( QLineEdit *line );
void pickAddressTo();
void pickAddressCC();
void pickAddressBCC();
void pickAddressReply();
void addAttachment();
void removeAttachment();
-
-
-private:
+protected:
Settings *settings;
QList<SMTPaccount> smtpAccounts;
-
+ QString m_replyid;
};
class AttachViewItem : public QListViewItem
{
public:
AttachViewItem( QListView *parent, Attachment *att );
Attachment *getAttachment() { return attachment; }
private:
Attachment *attachment;
};
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
@@ -25,31 +25,33 @@ void RecMail::copy_old(const RecMail&old)
subject = old.subject;
date = old.date;
mbox = old.mbox;
msg_id = old.msg_id;
msg_size = old.msg_size;
msg_number = old.msg_number;
from = old.from;
msg_flags = old.msg_flags;
to = old.to;
cc = old.cc;
bcc = old.bcc;
wrapper = old.wrapper;
+ in_reply_to = old.in_reply_to;
}
void RecMail::init()
{
to.clear();
cc.clear();
bcc.clear();
+ in_reply_to.clear();
wrapper = 0;
}
void RecMail::setWrapper(AbstractMail*awrapper)
{
wrapper = awrapper;
}
AbstractMail* RecMail::Wrapper()
{
return wrapper;
}
@@ -75,24 +77,35 @@ const QStringList&RecMail::CC()const
}
void RecMail::setBcc(const QStringList&list)
{
bcc = list;
}
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)
{
m_Parameters.clear();
m_poslist.clear();
}
RecPart::~RecPart()
{
}
void RecPart::setSize(unsigned int size)
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
@@ -50,35 +50,37 @@ public:
void setReplyto(const QString&reply){replyto=reply;}
const QString&Replyto()const{return replyto;}
void setMsgsize(int size){msg_size = size;}
const int Msgsize()const{return msg_size;}
void setTo(const QStringList&list);
const QStringList&To()const;
void setCC(const QStringList&list);
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;}
void setWrapper(AbstractMail*wrapper);
AbstractMail* Wrapper();
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);
};
typedef QMap<QString,QString> part_plist_t;
class RecPart
{
protected:
QString m_type,m_subtype,m_identifier,m_encoding,m_description;
unsigned int m_lines,m_size;
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
@@ -46,28 +46,31 @@ public:
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;}
private:
QList<Attachment> attList;
QString name, mail, to, cc, bcc, reply, subject, message;
+ QStringList m_in_reply_to;
};
class Folder : public QObject
{
Q_OBJECT
public:
Folder( const QString&init_name,const QString&sep );
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;}
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
@@ -140,24 +140,25 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) {
qDebug( "Parse success! %s",(*it).latin1());
}
}
return addresses;
}
mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) {
mailimf_fields *fields;
mailimf_field *xmailer;
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;
sender = newMailbox( mail.getName(), mail.getMail() );
if ( sender == NULL )
goto err_free;
fromBox = newMailbox( mail.getName(), mail.getMail() );
if ( fromBox == NULL )
goto err_free_sender;
from = mailimf_mailbox_list_new_empty();
@@ -166,27 +167,53 @@ mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) {
err = mailimf_mailbox_list_add( from, fromBox );
if ( err != MAILIMF_NO_ERROR )
goto err_free_from;
to = parseAddresses( mail.getTo() );
if ( to == NULL )
goto err_free_from;
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;
xmailer = mailimf_field_new_custom( strdup( "User-Agent" ),
strdup( USER_AGENT ) );
if ( xmailer == NULL )
goto err_free_fields;
err = mailimf_fields_add( fields, xmailer );
if ( err != MAILIMF_NO_ERROR )
goto err_free_xmailer;
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
@@ -400,32 +400,34 @@ void ViewMail::slotReply()
.arg( m_mail[3] );
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 = "";
+ 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);
}
}
void ViewMail::slotForward()
{
if (!m_gotBody)
{
QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
return;