summaryrefslogtreecommitdiff
authoralwin <alwin>2004-03-08 03:06:39 (UTC)
committer alwin <alwin>2004-03-08 03:06:39 (UTC)
commit38301e81221e7e51cc67a5e366498a71df288263 (patch) (unidiff)
tree47cfc2c2bf399c7f8bec3be4007d4f69a4d0b07a
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 (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
@@ -1,40 +1,41 @@
1#include <qt.h> 1#include <qt.h>
2 2
3#include <opie2/ofiledialog.h> 3#include <opie2/ofiledialog.h>
4#include <qpe/resource.h> 4#include <qpe/resource.h>
5#include <qpe/config.h> 5#include <qpe/config.h>
6#include <qpe/global.h> 6#include <qpe/global.h>
7#include <qpe/contact.h> 7#include <qpe/contact.h>
8 8
9#include "composemail.h" 9#include "composemail.h"
10 10
11#include <libmailwrapper/smtpwrapper.h> 11#include <libmailwrapper/smtpwrapper.h>
12 12
13ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 13ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
14 : ComposeMailUI( parent, name, modal, flags ) 14 : ComposeMailUI( parent, name, modal, flags )
15{ 15{
16 settings = s; 16 settings = s;
17 m_replyid = "";
17 18
18 QString vfilename = Global::applicationFileName("addressbook", 19 QString vfilename = Global::applicationFileName("addressbook",
19 "businesscard.vcf"); 20 "businesscard.vcf");
20 Contact c; 21 Contact c;
21 if (QFile::exists(vfilename)) { 22 if (QFile::exists(vfilename)) {
22 c = Contact::readVCard( vfilename )[0]; 23 c = Contact::readVCard( vfilename )[0];
23 } 24 }
24 25
25 QStringList mails = c.emailList(); 26 QStringList mails = c.emailList();
26 QString defmail = c.defaultEmail(); 27 QString defmail = c.defaultEmail();
27 28
28 if (defmail.length()!=0) { 29 if (defmail.length()!=0) {
29 fromBox->insertItem(defmail); 30 fromBox->insertItem(defmail);
30 } 31 }
31 QStringList::ConstIterator sit = mails.begin(); 32 QStringList::ConstIterator sit = mails.begin();
32 for (;sit!=mails.end();++sit) { 33 for (;sit!=mails.end();++sit) {
33 if ( (*sit)==defmail) 34 if ( (*sit)==defmail)
34 continue; 35 continue;
35 fromBox->insertItem((*sit)); 36 fromBox->insertItem((*sit));
36 } 37 }
37 senderNameEdit->setText(c.firstName()+" "+c.lastName()); 38 senderNameEdit->setText(c.firstName()+" "+c.lastName());
38 Config cfg( "mail" ); 39 Config cfg( "mail" );
39 cfg.setGroup( "Compose" ); 40 cfg.setGroup( "Compose" );
40 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); 41 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) );
@@ -63,66 +64,59 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m
63 } 64 }
64 65
65 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 66 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
66 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 67 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
67 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 68 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
68 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 69 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
69 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 70 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
70 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 71 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
71 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 72 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
72} 73}
73 74
74void ComposeMail::pickAddress( QLineEdit *line ) 75void ComposeMail::pickAddress( QLineEdit *line )
75{ 76{
76 QString names = AddressPicker::getNames(); 77 QString names = AddressPicker::getNames();
77 if ( line->text().isEmpty() ) { 78 if ( line->text().isEmpty() ) {
78 line->setText( names ); 79 line->setText( names );
79 } else if ( !names.isEmpty() ) { 80 } else if ( !names.isEmpty() ) {
80 line->setText( line->text() + ", " + names ); 81 line->setText( line->text() + ", " + names );
81 } 82 }
82} 83}
83 84
84 85
85void ComposeMail::setTo( const QString & to ) 86void ComposeMail::setTo( const QString & to )
86{ 87{
87/* QString toline; 88 toLine->setText( to );
88 QStringList toEntry = to;
89 for ( QStringList::Iterator it = toEntry.begin(); it != toEntry.end(); ++it ) {
90 toline += (*it);
91 }
92 toLine->setText( toline );
93*/
94toLine->setText( to );
95} 89}
96 90
97void ComposeMail::setSubject( const QString & subject ) 91void ComposeMail::setSubject( const QString & subject )
98{ 92{
99 subjectLine->setText( subject ); 93 subjectLine->setText( subject );
100} 94}
101 95
102void ComposeMail::setInReplyTo( const QString & messageId ) 96void ComposeMail::setInReplyTo( const QString & messageId )
103{ 97{
104 98 m_replyid = messageId;
105} 99}
106 100
107void ComposeMail::setMessage( const QString & text ) 101void ComposeMail::setMessage( const QString & text )
108{ 102{
109 message->setText( text ); 103 message->setText( text );
110} 104}
111 105
112 106
113void ComposeMail::pickAddressTo() 107void ComposeMail::pickAddressTo()
114{ 108{
115 pickAddress( toLine ); 109 pickAddress( toLine );
116} 110}
117 111
118void ComposeMail::pickAddressCC() 112void ComposeMail::pickAddressCC()
119{ 113{
120 pickAddress( ccLine ); 114 pickAddress( ccLine );
121} 115}
122 116
123void ComposeMail::pickAddressBCC() 117void ComposeMail::pickAddressBCC()
124{ 118{
125 pickAddress( bccLine ); 119 pickAddress( bccLine );
126} 120}
127 121
128void ComposeMail::pickAddressReply() 122void ComposeMail::pickAddressReply()
@@ -186,48 +180,53 @@ void ComposeMail::accept()
186 if ( checkBoxLater->isChecked() ) { 180 if ( checkBoxLater->isChecked() ) {
187 qDebug( "Send later" ); 181 qDebug( "Send later" );
188 } 182 }
189 183
190#if 0 184#if 0
191 qDebug( "Sending Mail with " + 185 qDebug( "Sending Mail with " +
192 smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); 186 smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() );
193#endif 187#endif
194 Mail *mail = new Mail(); 188 Mail *mail = new Mail();
195 189
196 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); 190 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
197 mail->setMail(fromBox->currentText()); 191 mail->setMail(fromBox->currentText());
198 192
199 if ( !toLine->text().isEmpty() ) { 193 if ( !toLine->text().isEmpty() ) {
200 mail->setTo( toLine->text() ); 194 mail->setTo( toLine->text() );
201 } else { 195 } else {
202 qDebug( "No Reciever spezified -> returning" ); 196 qDebug( "No Reciever spezified -> returning" );
203 return; 197 return;
204 } 198 }
205 mail->setName(senderNameEdit->text()); 199 mail->setName(senderNameEdit->text());
206 mail->setCC( ccLine->text() ); 200 mail->setCC( ccLine->text() );
207 mail->setBCC( bccLine->text() ); 201 mail->setBCC( bccLine->text() );
208 mail->setReply( replyLine->text() ); 202 mail->setReply( replyLine->text() );
209 mail->setSubject( subjectLine->text() ); 203 mail->setSubject( subjectLine->text() );
204 if (!m_replyid.isEmpty()) {
205 QStringList ids;
206 ids.append(m_replyid);
207 mail->setInreply(ids);
208 }
210 QString txt = message->text(); 209 QString txt = message->text();
211 if ( !sigMultiLine->text().isEmpty() ) { 210 if ( !sigMultiLine->text().isEmpty() ) {
212 txt.append( "\n--\n" ); 211 txt.append( "\n--\n" );
213 txt.append( sigMultiLine->text() ); 212 txt.append( sigMultiLine->text() );
214 } 213 }
215 qDebug(txt); 214 qDebug(txt);
216 mail->setMessage( txt ); 215 mail->setMessage( txt );
217 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 216 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
218 while ( it != NULL ) { 217 while ( it != NULL ) {
219 mail->addAttachment( it->getAttachment() ); 218 mail->addAttachment( it->getAttachment() );
220 it = (AttachViewItem *) it->nextSibling(); 219 it = (AttachViewItem *) it->nextSibling();
221 } 220 }
222 221
223 SMTPwrapper wrapper( smtp ); 222 SMTPwrapper wrapper( smtp );
224 wrapper.sendMail( *mail,checkBoxLater->isChecked() ); 223 wrapper.sendMail( *mail,checkBoxLater->isChecked() );
225 224
226 QDialog::accept(); 225 QDialog::accept();
227} 226}
228 227
229AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 228AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
230 : QListViewItem( parent ) 229 : QListViewItem( parent )
231{ 230{
232 attachment = att; 231 attachment = att;
233 qDebug( att->getMimeType() ); 232 qDebug( att->getMimeType() );
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
@@ -33,44 +33,42 @@ class ComposeMail : public ComposeMailUI
33public: 33public:
34 ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); 34 ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
35 35
36public slots: 36public slots:
37 void slotAdjustColumns(); 37 void slotAdjustColumns();
38 38
39 void setTo( const QString & to ); 39 void setTo( const QString & to );
40 void setSubject( const QString & subject ); 40 void setSubject( const QString & subject );
41 void setInReplyTo( const QString & messageId ); 41 void setInReplyTo( const QString & messageId );
42 void setMessage( const QString & text ); 42 void setMessage( const QString & text );
43 43
44protected slots: 44protected slots:
45 void accept(); 45 void accept();
46 46
47private slots: 47private slots:
48 void fillValues( int current ); 48 void fillValues( int current );
49 void pickAddress( QLineEdit *line ); 49 void pickAddress( QLineEdit *line );
50 void pickAddressTo(); 50 void pickAddressTo();
51 void pickAddressCC(); 51 void pickAddressCC();
52 void pickAddressBCC(); 52 void pickAddressBCC();
53 void pickAddressReply(); 53 void pickAddressReply();
54 void addAttachment(); 54 void addAttachment();
55 void removeAttachment(); 55 void removeAttachment();
56 56
57 57protected:
58
59private:
60 Settings *settings; 58 Settings *settings;
61 QList<SMTPaccount> smtpAccounts; 59 QList<SMTPaccount> smtpAccounts;
62 60 QString m_replyid;
63}; 61};
64 62
65class AttachViewItem : public QListViewItem 63class AttachViewItem : public QListViewItem
66{ 64{
67 public: 65 public:
68 AttachViewItem( QListView *parent, Attachment *att ); 66 AttachViewItem( QListView *parent, Attachment *att );
69 Attachment *getAttachment() { return attachment; } 67 Attachment *getAttachment() { return attachment; }
70 68
71private: 69private:
72 Attachment *attachment; 70 Attachment *attachment;
73 71
74}; 72};
75 73
76#endif 74#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
@@ -13,98 +13,111 @@ RecMail::RecMail(const RecMail&old)
13 init(); 13 init();
14 copy_old(old); 14 copy_old(old);
15 qDebug("Copy constructor RecMail"); 15 qDebug("Copy constructor RecMail");
16} 16}
17 17
18RecMail::~RecMail() 18RecMail::~RecMail()
19{ 19{
20 wrapper = 0; 20 wrapper = 0;
21} 21}
22 22
23void RecMail::copy_old(const RecMail&old) 23void RecMail::copy_old(const RecMail&old)
24{ 24{
25 subject = old.subject; 25 subject = old.subject;
26 date = old.date; 26 date = old.date;
27 mbox = old.mbox; 27 mbox = old.mbox;
28 msg_id = old.msg_id; 28 msg_id = old.msg_id;
29 msg_size = old.msg_size; 29 msg_size = old.msg_size;
30 msg_number = old.msg_number; 30 msg_number = old.msg_number;
31 from = old.from; 31 from = old.from;
32 msg_flags = old.msg_flags; 32 msg_flags = old.msg_flags;
33 to = old.to; 33 to = old.to;
34 cc = old.cc; 34 cc = old.cc;
35 bcc = old.bcc; 35 bcc = old.bcc;
36 wrapper = old.wrapper; 36 wrapper = old.wrapper;
37 in_reply_to = old.in_reply_to;
37} 38}
38 39
39void RecMail::init() 40void RecMail::init()
40{ 41{
41 to.clear(); 42 to.clear();
42 cc.clear(); 43 cc.clear();
43 bcc.clear(); 44 bcc.clear();
45 in_reply_to.clear();
44 wrapper = 0; 46 wrapper = 0;
45} 47}
46 48
47void RecMail::setWrapper(AbstractMail*awrapper) 49void RecMail::setWrapper(AbstractMail*awrapper)
48{ 50{
49 wrapper = awrapper; 51 wrapper = awrapper;
50} 52}
51 53
52AbstractMail* RecMail::Wrapper() 54AbstractMail* RecMail::Wrapper()
53{ 55{
54 return wrapper; 56 return wrapper;
55} 57}
56 58
57void RecMail::setTo(const QStringList&list) 59void RecMail::setTo(const QStringList&list)
58{ 60{
59 to = list; 61 to = list;
60} 62}
61 63
62const QStringList&RecMail::To()const 64const QStringList&RecMail::To()const
63{ 65{
64 return to; 66 return to;
65} 67}
66 68
67void RecMail::setCC(const QStringList&list) 69void RecMail::setCC(const QStringList&list)
68{ 70{
69 cc = list; 71 cc = list;
70} 72}
71 73
72const QStringList&RecMail::CC()const 74const QStringList&RecMail::CC()const
73{ 75{
74 return cc; 76 return cc;
75} 77}
76 78
77void RecMail::setBcc(const QStringList&list) 79void RecMail::setBcc(const QStringList&list)
78{ 80{
79 bcc = list; 81 bcc = list;
80} 82}
81 83
82const QStringList& RecMail::Bcc()const 84const QStringList& RecMail::Bcc()const
83{ 85{
84 return bcc; 86 return bcc;
85} 87}
86 88
89void RecMail::setInreply(const QStringList&list)
90{
91 in_reply_to = list;
92}
93
94const QStringList& RecMail::Inreply()const
95{
96 return in_reply_to;
97}
98
99
87RecPart::RecPart() 100RecPart::RecPart()
88 : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) 101 : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0)
89{ 102{
90 m_Parameters.clear(); 103 m_Parameters.clear();
91 m_poslist.clear(); 104 m_poslist.clear();
92} 105}
93 106
94RecPart::~RecPart() 107RecPart::~RecPart()
95{ 108{
96} 109}
97 110
98void RecPart::setSize(unsigned int size) 111void RecPart::setSize(unsigned int size)
99{ 112{
100 m_size = size; 113 m_size = size;
101} 114}
102 115
103const unsigned int RecPart::Size()const 116const unsigned int RecPart::Size()const
104{ 117{
105 return m_size; 118 return m_size;
106} 119}
107 120
108void RecPart::setLines(unsigned int lines) 121void RecPart::setLines(unsigned int lines)
109{ 122{
110 m_lines = lines; 123 m_lines = lines;
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
@@ -38,59 +38,61 @@ public:
38 const int getNumber()const{return msg_number;} 38 const int getNumber()const{return msg_number;}
39 void setNumber(int number){msg_number=number;} 39 void setNumber(int number){msg_number=number;}
40 const QString&getDate()const{ return date; } 40 const QString&getDate()const{ return date; }
41 void setDate( const QString&a ) { date = a; } 41 void setDate( const QString&a ) { date = a; }
42 const QString&getFrom()const{ return from; } 42 const QString&getFrom()const{ return from; }
43 void setFrom( const QString&a ) { from = a; } 43 void setFrom( const QString&a ) { from = a; }
44 const QString&getSubject()const { return subject; } 44 const QString&getSubject()const { return subject; }
45 void setSubject( const QString&s ) { subject = s; } 45 void setSubject( const QString&s ) { subject = s; }
46 const QString&getMbox()const{return mbox;} 46 const QString&getMbox()const{return mbox;}
47 void setMbox(const QString&box){mbox = box;} 47 void setMbox(const QString&box){mbox = box;}
48 void setMsgid(const QString&id){msg_id=id;} 48 void setMsgid(const QString&id){msg_id=id;}
49 const QString&Msgid()const{return msg_id;} 49 const QString&Msgid()const{return msg_id;}
50 void setReplyto(const QString&reply){replyto=reply;} 50 void setReplyto(const QString&reply){replyto=reply;}
51 const QString&Replyto()const{return replyto;} 51 const QString&Replyto()const{return replyto;}
52 void setMsgsize(int size){msg_size = size;} 52 void setMsgsize(int size){msg_size = size;}
53 const int Msgsize()const{return msg_size;} 53 const int Msgsize()const{return msg_size;}
54 54
55 55
56 void setTo(const QStringList&list); 56 void setTo(const QStringList&list);
57 const QStringList&To()const; 57 const QStringList&To()const;
58 void setCC(const QStringList&list); 58 void setCC(const QStringList&list);
59 const QStringList&CC()const; 59 const QStringList&CC()const;
60 void setBcc(const QStringList&list); 60 void setBcc(const QStringList&list);
61 const QStringList&Bcc()const; 61 const QStringList&Bcc()const;
62 void setInreply(const QStringList&list);
63 const QStringList&Inreply()const;
62 const QBitArray&getFlags()const{return msg_flags;} 64 const QBitArray&getFlags()const{return msg_flags;}
63 void setFlags(const QBitArray&flags){msg_flags = flags;} 65 void setFlags(const QBitArray&flags){msg_flags = flags;}
64 66
65 void setWrapper(AbstractMail*wrapper); 67 void setWrapper(AbstractMail*wrapper);
66 AbstractMail* Wrapper(); 68 AbstractMail* Wrapper();
67 69
68protected: 70protected:
69 QString subject,date,from,mbox,msg_id,replyto; 71 QString subject,date,from,mbox,msg_id,replyto;
70 int msg_number,msg_size; 72 int msg_number,msg_size;
71 QBitArray msg_flags; 73 QBitArray msg_flags;
72 QStringList to,cc,bcc; 74 QStringList to,cc,bcc,in_reply_to;
73 AbstractMail*wrapper; 75 AbstractMail*wrapper;
74 void init(); 76 void init();
75 void copy_old(const RecMail&old); 77 void copy_old(const RecMail&old);
76}; 78};
77 79
78typedef QMap<QString,QString> part_plist_t; 80typedef QMap<QString,QString> part_plist_t;
79 81
80class RecPart 82class RecPart
81{ 83{
82protected: 84protected:
83 QString m_type,m_subtype,m_identifier,m_encoding,m_description; 85 QString m_type,m_subtype,m_identifier,m_encoding,m_description;
84 unsigned int m_lines,m_size; 86 unsigned int m_lines,m_size;
85 part_plist_t m_Parameters; 87 part_plist_t m_Parameters;
86 /* describes the position in the mail */ 88 /* describes the position in the mail */
87 QValueList<int> m_poslist; 89 QValueList<int> m_poslist;
88 90
89public: 91public:
90 RecPart(); 92 RecPart();
91 virtual ~RecPart(); 93 virtual ~RecPart();
92 94
93 const QString&Type()const; 95 const QString&Type()const;
94 void setType(const QString&type); 96 void setType(const QString&type);
95 const QString&Subtype()const; 97 const QString&Subtype()const;
96 void setSubtype(const QString&subtype); 98 void setSubtype(const QString&subtype);
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
@@ -34,52 +34,55 @@ public:
34 * 'cause it seems that it will never have some child classes. 34 * 'cause it seems that it will never have some child classes.
35 * in this case this object will not get a virtual table -> memory and 35 * in this case this object will not get a virtual table -> memory and
36 * speed will be a little bit better? 36 * speed will be a little bit better?
37 */ 37 */
38 virtual ~Mail(){} 38 virtual ~Mail(){}
39 void addAttachment( Attachment *att ) { attList.append( att ); } 39 void addAttachment( Attachment *att ) { attList.append( att ); }
40 const QList<Attachment>& getAttachments()const { return attList; } 40 const QList<Attachment>& getAttachments()const { return attList; }
41 void removeAttachment( Attachment *att ) { attList.remove( att ); } 41 void removeAttachment( Attachment *att ) { attList.remove( att ); }
42 const QString&getName()const { return name; } 42 const QString&getName()const { return name; }
43 void setName( QString s ) { name = s; } 43 void setName( QString s ) { name = s; }
44 const QString&getMail()const{ return mail; } 44 const QString&getMail()const{ return mail; }
45 void setMail( const QString&s ) { mail = s; } 45 void setMail( const QString&s ) { mail = s; }
46 const QString&getTo()const{ return to; } 46 const QString&getTo()const{ return to; }
47 void setTo( const QString&s ) { to = s; } 47 void setTo( const QString&s ) { to = s; }
48 const QString&getCC()const{ return cc; } 48 const QString&getCC()const{ return cc; }
49 void setCC( const QString&s ) { cc = s; } 49 void setCC( const QString&s ) { cc = s; }
50 const QString&getBCC()const { return bcc; } 50 const QString&getBCC()const { return bcc; }
51 void setBCC( const QString&s ) { bcc = s; } 51 void setBCC( const QString&s ) { bcc = s; }
52 const QString&getMessage()const { return message; } 52 const QString&getMessage()const { return message; }
53 void setMessage( const QString&s ) { message = s; } 53 void setMessage( const QString&s ) { message = s; }
54 const QString&getSubject()const { return subject; } 54 const QString&getSubject()const { return subject; }
55 void setSubject( const QString&s ) { subject = s; } 55 void setSubject( const QString&s ) { subject = s; }
56 const QString&getReply()const{ return reply; } 56 const QString&getReply()const{ return reply; }
57 void setReply( const QString&a ) { reply = a; } 57 void setReply( const QString&a ) { reply = a; }
58 void setInreply(const QStringList&list){m_in_reply_to = list;}
59 const QStringList&Inreply()const{return m_in_reply_to;}
58 60
59private: 61private:
60 QList<Attachment> attList; 62 QList<Attachment> attList;
61 QString name, mail, to, cc, bcc, reply, subject, message; 63 QString name, mail, to, cc, bcc, reply, subject, message;
64 QStringList m_in_reply_to;
62}; 65};
63 66
64class Folder : public QObject 67class Folder : public QObject
65{ 68{
66 Q_OBJECT 69 Q_OBJECT
67 70
68public: 71public:
69 Folder( const QString&init_name,const QString&sep ); 72 Folder( const QString&init_name,const QString&sep );
70 const QString&getDisplayName()const { return nameDisplay; } 73 const QString&getDisplayName()const { return nameDisplay; }
71 const QString&getName()const { return name; } 74 const QString&getName()const { return name; }
72 const QString&getPrefix()const{return prefix; } 75 const QString&getPrefix()const{return prefix; }
73 virtual bool may_select()const{return true;} 76 virtual bool may_select()const{return true;}
74 virtual bool no_inferior()const{return true;} 77 virtual bool no_inferior()const{return true;}
75 const QString&Separator()const; 78 const QString&Separator()const;
76 79
77protected: 80protected:
78 QString nameDisplay, name, separator,prefix; 81 QString nameDisplay, name, separator,prefix;
79}; 82};
80 83
81class MHFolder : public Folder 84class MHFolder : public Folder
82{ 85{
83 Q_OBJECT 86 Q_OBJECT
84public: 87public:
85 MHFolder(const QString&disp_name,const QString&mbox); 88 MHFolder(const QString&disp_name,const QString&mbox);
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
@@ -128,77 +128,104 @@ mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) {
128 s = addr.mid(startpos,i-startpos); 128 s = addr.mid(startpos,i-startpos);
129 if (!s.isEmpty()) { 129 if (!s.isEmpty()) {
130 list.append(s); 130 list.append(s);
131 qDebug("Appended %s",s.latin1()); 131 qDebug("Appended %s",s.latin1());
132 } 132 }
133 QStringList::Iterator it; 133 QStringList::Iterator it;
134 for ( it = list.begin(); it != list.end(); it++ ) { 134 for ( it = list.begin(); it != list.end(); it++ ) {
135 int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); 135 int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() );
136 if ( err != MAILIMF_NO_ERROR ) { 136 if ( err != MAILIMF_NO_ERROR ) {
137 qDebug( "Error parsing" ); 137 qDebug( "Error parsing" );
138 qDebug( *it ); 138 qDebug( *it );
139 } else { 139 } else {
140 qDebug( "Parse success! %s",(*it).latin1()); 140 qDebug( "Parse success! %s",(*it).latin1());
141 } 141 }
142 } 142 }
143 return addresses; 143 return addresses;
144} 144}
145 145
146mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { 146mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) {
147 mailimf_fields *fields; 147 mailimf_fields *fields;
148 mailimf_field *xmailer; 148 mailimf_field *xmailer;
149 mailimf_mailbox *sender=0,*fromBox=0; 149 mailimf_mailbox *sender=0,*fromBox=0;
150 mailimf_mailbox_list *from=0; 150 mailimf_mailbox_list *from=0;
151 mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; 151 mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0;
152 clist*in_reply_to = 0;
152 char *subject = strdup( mail.getSubject().latin1() ); 153 char *subject = strdup( mail.getSubject().latin1() );
153 int err; 154 int err;
154 155
155 sender = newMailbox( mail.getName(), mail.getMail() ); 156 sender = newMailbox( mail.getName(), mail.getMail() );
156 if ( sender == NULL ) 157 if ( sender == NULL )
157 goto err_free; 158 goto err_free;
158 159
159 fromBox = newMailbox( mail.getName(), mail.getMail() ); 160 fromBox = newMailbox( mail.getName(), mail.getMail() );
160 if ( fromBox == NULL ) 161 if ( fromBox == NULL )
161 goto err_free_sender; 162 goto err_free_sender;
162 163
163 from = mailimf_mailbox_list_new_empty(); 164 from = mailimf_mailbox_list_new_empty();
164 if ( from == NULL ) 165 if ( from == NULL )
165 goto err_free_fromBox; 166 goto err_free_fromBox;
166 167
167 err = mailimf_mailbox_list_add( from, fromBox ); 168 err = mailimf_mailbox_list_add( from, fromBox );
168 if ( err != MAILIMF_NO_ERROR ) 169 if ( err != MAILIMF_NO_ERROR )
169 goto err_free_from; 170 goto err_free_from;
170 171
171 to = parseAddresses( mail.getTo() ); 172 to = parseAddresses( mail.getTo() );
172 if ( to == NULL ) 173 if ( to == NULL )
173 goto err_free_from; 174 goto err_free_from;
174 175
175 cc = parseAddresses( mail.getCC() ); 176 cc = parseAddresses( mail.getCC() );
176 bcc = parseAddresses( mail.getBCC() ); 177 bcc = parseAddresses( mail.getBCC() );
177 reply = parseAddresses( mail.getReply() ); 178 reply = parseAddresses( mail.getReply() );
179
180 if (mail.Inreply().count()>0) {
181 in_reply_to = clist_new();
182 char*c_reply;
183 unsigned int nsize = 0;
184 for (QStringList::ConstIterator it=mail.Inreply().begin();
185 it != mail.Inreply().end();++it) {
186 /* yes! must be malloc! */
187 if ((*it).isEmpty())
188 continue;
189 QString h((*it));
190 while (h.length()>0 && h[0]=='<') {
191 h.remove(0,1);
192 }
193 while (h.length()>0 && h[h.length()-1]=='>') {
194 h.remove(h.length()-1,1);
195 }
196 if (h.isEmpty()) continue;
197 nsize = strlen(h.latin1());
198 c_reply = (char*)malloc( (nsize+1)*sizeof(char));
199 memset(c_reply,0,nsize+1);
200 memcpy(c_reply,h.latin1(),nsize);
201 clist_append(in_reply_to,c_reply);
202 qDebug("In reply to: %s",c_reply);
203 }
204 }
178 205
179 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, 206 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc,
180 NULL, NULL, subject ); 207 in_reply_to, NULL, subject );
181 if ( fields == NULL ) 208 if ( fields == NULL )
182 goto err_free_reply; 209 goto err_free_reply;
183 210
184 xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), 211 xmailer = mailimf_field_new_custom( strdup( "User-Agent" ),
185 strdup( USER_AGENT ) ); 212 strdup( USER_AGENT ) );
186 if ( xmailer == NULL ) 213 if ( xmailer == NULL )
187 goto err_free_fields; 214 goto err_free_fields;
188 215
189 err = mailimf_fields_add( fields, xmailer ); 216 err = mailimf_fields_add( fields, xmailer );
190 if ( err != MAILIMF_NO_ERROR ) 217 if ( err != MAILIMF_NO_ERROR )
191 goto err_free_xmailer; 218 goto err_free_xmailer;
192 219
193 return fields; // Success :) 220 return fields; // Success :)
194 221
195err_free_xmailer: 222err_free_xmailer:
196 if (xmailer) 223 if (xmailer)
197 mailimf_field_free( xmailer ); 224 mailimf_field_free( xmailer );
198err_free_fields: 225err_free_fields:
199 if (fields) 226 if (fields)
200 mailimf_fields_free( fields ); 227 mailimf_fields_free( fields );
201err_free_reply: 228err_free_reply:
202 if (reply) 229 if (reply)
203 mailimf_address_list_free( reply ); 230 mailimf_address_list_free( reply );
204 if (bcc) 231 if (bcc)
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
@@ -388,56 +388,58 @@ QString ViewMail::deHtml(const QString &string)
388 388
389void ViewMail::slotReply() 389void ViewMail::slotReply()
390{ 390{
391 if (!m_gotBody) 391 if (!m_gotBody)
392 { 392 {
393 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); 393 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
394 return; 394 return;
395 } 395 }
396 396
397 QString rtext; 397 QString rtext;
398 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 398 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
399 .arg( m_mail[0] ) 399 .arg( m_mail[0] )
400 .arg( m_mail[3] ); 400 .arg( m_mail[3] );
401 401
402 QString text = m_mail[2]; 402 QString text = m_mail[2];
403 QStringList lines = QStringList::split(QRegExp("\\n"), text); 403 QStringList lines = QStringList::split(QRegExp("\\n"), text);
404 QStringList::Iterator it; 404 QStringList::Iterator it;
405 for (it = lines.begin(); it != lines.end(); it++) 405 for (it = lines.begin(); it != lines.end(); it++)
406 { 406 {
407 rtext += "> " + *it + "\n"; 407 rtext += "> " + *it + "\n";
408 } 408 }
409 rtext += "\n"; 409 rtext += "\n";
410 410
411 QString prefix; 411 QString prefix;
412 if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; 412 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = "";
413 else prefix = "Re: "; // no i18n on purpose 413 else prefix = "Re: "; // no i18n on purpose
414 414
415 Settings *settings = new Settings(); 415 Settings *settings = new Settings();
416 ComposeMail composer( settings ,this, 0, true); 416 ComposeMail composer( settings ,this, 0, true);
417 composer.setTo( m_mail[0] ); 417 composer.setTo( m_mail[0] );
418 composer.setSubject( "Re: " + m_mail[1] ); 418 composer.setSubject( prefix + m_mail[1] );
419 composer.setMessage( rtext ); 419 composer.setMessage( rtext );
420 composer.setInReplyTo(m_recMail.Msgid());
421
420 if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) ) 422 if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) )
421 { 423 {
422 m_recMail.Wrapper()->answeredMail(m_recMail); 424 m_recMail.Wrapper()->answeredMail(m_recMail);
423 } 425 }
424} 426}
425 427
426void ViewMail::slotForward() 428void ViewMail::slotForward()
427{ 429{
428 if (!m_gotBody) 430 if (!m_gotBody)
429 { 431 {
430 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); 432 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
431 return; 433 return;
432 } 434 }
433 435
434 QString ftext; 436 QString ftext;
435 ftext += QString("\n----- Forwarded message from %1 -----\n\n") 437 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
436 .arg( m_mail[0] ); 438 .arg( m_mail[0] );
437 if (!m_mail[3].isNull()) 439 if (!m_mail[3].isNull())
438 ftext += QString("Date: %1\n") 440 ftext += QString("Date: %1\n")
439 .arg( m_mail[3] ); 441 .arg( m_mail[3] );
440 if (!m_mail[0].isNull()) 442 if (!m_mail[0].isNull())
441 ftext += QString("From: %1\n") 443 ftext += QString("From: %1\n")
442 .arg( m_mail[0] ); 444 .arg( m_mail[0] );
443 if (!m_mail[1].isNull()) 445 if (!m_mail[1].isNull())