summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/composemail.cpp15
-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, 60 insertions, 16 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
@@ -1,152 +1,146 @@
#include <qt.h>
#include <opie2/ofiledialog.h>
#include <qpe/resource.h>
#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) {
fromBox->insertItem(defmail);
}
QStringList::ConstIterator sit = mails.begin();
for (;sit!=mails.end();++sit) {
if ( (*sit)==defmail)
continue;
fromBox->insertItem((*sit));
}
senderNameEdit->setText(c.firstName()+" "+c.lastName());
Config cfg( "mail" );
cfg.setGroup( "Compose" );
checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) );
attList->addColumn( tr( "Name" ) );
attList->addColumn( tr( "Size" ) );
QList<Account> accounts = settings->getAccounts();
Account *it;
for ( it = accounts.first(); it; it = accounts.next() ) {
if ( it->getType()==MAILLIB::A_SMTP ) {
SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
smtpAccountBox->insertItem( smtp->getAccountName() );
smtpAccounts.append( smtp );
}
}
if ( smtpAccounts.count() > 0 ) {
fillValues( smtpAccountBox->currentItem() );
} else {
QMessageBox::information( this, tr( "Problem" ),
tr( "<p>Please create an SMTP account first.</p>" ),
tr( "Ok" ) );
return;
}
connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
}
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 );
}
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 );
}
void ComposeMail::pickAddressCC()
{
pickAddress( ccLine );
}
void ComposeMail::pickAddressBCC()
{
pickAddress( bccLine );
}
void ComposeMail::pickAddressReply()
{
pickAddress( replyLine );
}
void ComposeMail::fillValues( int current )
{
#if 0
SMTPaccount *smtp = smtpAccounts.at( current );
ccLine->clear();
if ( smtp->getUseCC() ) {
ccLine->setText( smtp->getCC() );
}
bccLine->clear();
if ( smtp->getUseBCC() ) {
bccLine->setText( smtp->getBCC() );
}
replyLine->clear();
if ( smtp->getUseReply() ) {
replyLine->setText( smtp->getReply() );
}
sigMultiLine->setText( smtp->getSignature() );
#endif
}
@@ -162,79 +156,84 @@ void ComposeMail::slotAdjustColumns()
}
void ComposeMail::addAttachment()
{
DocLnk lnk = Opie::OFileDialog::getOpenFileName( 1, "/" );
if ( !lnk.name().isEmpty() ) {
Attachment *att = new Attachment( lnk );
(void) new AttachViewItem( attList, att );
}
}
void ComposeMail::removeAttachment()
{
if ( !attList->currentItem() ) {
QMessageBox::information( this, tr( "Error" ),
tr( "<p>Please select a File.</p>" ),
tr( "Ok" ) );
} else {
attList->takeItem( attList->currentItem() );
}
}
void ComposeMail::accept()
{
if ( checkBoxLater->isChecked() ) {
qDebug( "Send later" );
}
#if 0
qDebug( "Sending Mail with " +
smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() );
#endif
Mail *mail = new Mail();
SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
mail->setMail(fromBox->currentText());
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();
}
SMTPwrapper wrapper( smtp );
wrapper.sendMail( *mail,checkBoxLater->isChecked() );
QDialog::accept();
}
AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
: QListViewItem( parent )
{
attachment = att;
qDebug( att->getMimeType() );
setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ?
Resource::loadPixmap( "UnknownDocument-14" ) :
attachment->getDocLnk().pixmap() );
setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
setText( 1, QString::number( att->getSize() ) );
}
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
@@ -9,68 +9,66 @@
#include <libmailwrapper/settings.h>
#include <libmailwrapper/mailwrapper.h>
class AddressPicker : public AddressPickerUI
{
Q_OBJECT
public:
AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
static QString getNames();
protected:
QString selectedNames;
void accept();
};
class ComposeMail : public ComposeMailUI
{
Q_OBJECT
public:
ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
public slots:
void slotAdjustColumns();
void setTo( const QString & to );
void setSubject( const QString & subject );
void setInReplyTo( const QString & messageId );
void setMessage( const QString & text );
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;
};
#endif
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
@@ -1,134 +1,147 @@
#include "mailtypes.h"
#include <stdlib.h>
RecMail::RecMail()
:subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7)
{
init();
}
RecMail::RecMail(const RecMail&old)
:subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
{
init();
copy_old(old);
qDebug("Copy constructor RecMail");
}
RecMail::~RecMail()
{
wrapper = 0;
}
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;
}
void RecMail::setTo(const QStringList&list)
{
to = list;
}
const QStringList&RecMail::To()const
{
return to;
}
void RecMail::setCC(const QStringList&list)
{
cc = list;
}
const QStringList&RecMail::CC()const
{
return cc;
}
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)
{
m_size = size;
}
const unsigned int RecPart::Size()const
{
return m_size;
}
void RecPart::setLines(unsigned int lines)
{
m_lines = lines;
}
const unsigned int RecPart::Lines()const
{
return m_lines;
}
const QString& RecPart::Type()const
{
return m_type;
}
void RecPart::setType(const QString&type)
{
m_type = type;
}
const QString& RecPart::Subtype()const
{
return m_subtype;
}
void RecPart::setSubtype(const QString&subtype)
{
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
@@ -14,107 +14,109 @@
#include <qstringlist.h>
#include <qmap.h>
#include <qvaluelist.h>
class AbstractMail;
/* a class to describe mails in a mailbox */
/* Attention!
From programmers point of view it would make sense to
store the mail body into this class, too.
But: not from the point of view of the device.
Mailbodies can be real large. So we request them when
needed from the mail-wrapper class direct from the server itself
(imap) or from a file-based cache (pop3?)
So there is no interface "const QString&body()" but you should
make a request to the mailwrapper with this class as parameter to
get the body. Same words for the attachments.
*/
class RecMail
{
public:
RecMail();
RecMail(const RecMail&old);
virtual ~RecMail();
const int getNumber()const{return msg_number;}
void setNumber(int number){msg_number=number;}
const QString&getDate()const{ return date; }
void setDate( const QString&a ) { date = a; }
const QString&getFrom()const{ return from; }
void setFrom( const QString&a ) { from = a; }
const QString&getSubject()const { return subject; }
void setSubject( const QString&s ) { subject = s; }
const QString&getMbox()const{return mbox;}
void setMbox(const QString&box){mbox = box;}
void setMsgid(const QString&id){msg_id=id;}
const QString&Msgid()const{return msg_id;}
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;
part_plist_t m_Parameters;
/* describes the position in the mail */
QValueList<int> m_poslist;
public:
RecPart();
virtual ~RecPart();
const QString&Type()const;
void setType(const QString&type);
const QString&Subtype()const;
void setSubtype(const QString&subtype);
const QString&Identifier()const;
void setIdentifier(const QString&identifier);
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;
};
class RecBody
{
protected:
QString m_BodyText;
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
@@ -10,90 +10,93 @@
class Attachment
{
public:
Attachment( DocLnk lnk );
virtual ~Attachment(){}
const QString getFileName()const{ return doc.file(); }
const QString getName()const{ return doc.name(); }
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 Mail
{
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;}
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;}
virtual bool no_inferior()const{return true;}
const QString&Separator()const;
protected:
QString nameDisplay, name, separator,prefix;
};
class MHFolder : public Folder
{
Q_OBJECT
public:
MHFolder(const QString&disp_name,const QString&mbox);
};
class IMAPFolder : public Folder
{
public:
IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" );
virtual bool may_select()const{return m_MaySelect;}
virtual bool no_inferior()const{return m_NoInferior;}
private:
static QString decodeFolderName( const QString &name );
bool m_MaySelect,m_NoInferior;
};
#endif
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
@@ -104,125 +104,152 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) {
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);
qDebug("Appended %s",s.latin1());
}
// !!!! this is a MUST BE!
startpos = ++i;
}
break;
default:
break;
}
}
s = addr.mid(startpos,i-startpos);
if (!s.isEmpty()) {
list.append(s);
qDebug("Appended %s",s.latin1());
}
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" );
qDebug( *it );
} else {
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();
if ( from == NULL )
goto err_free_fromBox;
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;
return fields; // Success :)
err_free_xmailer:
if (xmailer)
mailimf_field_free( xmailer );
err_free_fields:
if (fields)
mailimf_fields_free( fields );
err_free_reply:
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 );
err_free_from:
if (from)
mailimf_mailbox_list_free( from );
err_free_fromBox:
mailimf_mailbox_free( fromBox );
err_free_sender:
if (sender)
mailimf_mailbox_free( sender );
err_free:
if (subject)
free( subject );
qDebug( "createImfFields - error" );
return NULL; // Error :(
}
mailmime *SMTPwrapper::buildTxtPart(const QString&str ) {
mailmime *txtPart;
mailmime_fields *fields;
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
@@ -364,104 +364,106 @@ void ViewMail::hide()
}
void ViewMail::exec()
{
show();
if (!_inLoop)
{
_inLoop = true;
qApp->enter_loop();
}
}
QString ViewMail::deHtml(const QString &string)
{
QString string_ = string;
string_.replace(QRegExp("&"), "&amp;");
string_.replace(QRegExp("<"), "&lt;");
string_.replace(QRegExp(">"), "&gt;");
string_.replace(QRegExp("\\n"), "<br>");
return string_;
}
void ViewMail::slotReply()
{
if (!m_gotBody)
{
QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
return;
}
QString rtext;
rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
.arg( m_mail[0] )
.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;
}
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")
.arg( m_mail[0] );
if (!m_mail[1].isNull())
ftext += QString("Subject: %1\n")
.arg( m_mail[1] );
ftext += QString("\n%1\n")
.arg( m_mail[2]);
ftext += QString("----- End forwarded message -----\n");
Settings *settings = new Settings();
ComposeMail composer( settings ,this, 0, true);
composer.setSubject( "Fwd: " + m_mail[1] );
composer.setMessage( ftext );
if ( QDialog::Accepted == QPEApplication::execDialog( &composer ))
{
}
}
void ViewMail::slotDeleteMail( )
{
if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
{
m_recMail.Wrapper()->deleteMail( m_recMail );
hide();
deleted = true;