Diffstat (limited to 'noncore/net/mail/composemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/composemail.cpp | 17 |
1 files changed, 8 insertions, 9 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 | ||
13 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 13 | ComposeMail::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 | ||
74 | void ComposeMail::pickAddress( QLineEdit *line ) | 75 | void 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 | ||
85 | void ComposeMail::setTo( const QString & to ) | 86 | void 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 | */ | ||
94 | toLine->setText( to ); | ||
95 | } | 89 | } |
96 | 90 | ||
97 | void ComposeMail::setSubject( const QString & subject ) | 91 | void ComposeMail::setSubject( const QString & subject ) |
98 | { | 92 | { |
99 | subjectLine->setText( subject ); | 93 | subjectLine->setText( subject ); |
100 | } | 94 | } |
101 | 95 | ||
102 | void ComposeMail::setInReplyTo( const QString & messageId ) | 96 | void ComposeMail::setInReplyTo( const QString & messageId ) |
103 | { | 97 | { |
104 | 98 | m_replyid = messageId; | |
105 | } | 99 | } |
106 | 100 | ||
107 | void ComposeMail::setMessage( const QString & text ) | 101 | void ComposeMail::setMessage( const QString & text ) |
108 | { | 102 | { |
109 | message->setText( text ); | 103 | message->setText( text ); |
110 | } | 104 | } |
111 | 105 | ||
112 | 106 | ||
113 | void ComposeMail::pickAddressTo() | 107 | void ComposeMail::pickAddressTo() |
114 | { | 108 | { |
115 | pickAddress( toLine ); | 109 | pickAddress( toLine ); |
116 | } | 110 | } |
117 | 111 | ||
118 | void ComposeMail::pickAddressCC() | 112 | void ComposeMail::pickAddressCC() |
119 | { | 113 | { |
120 | pickAddress( ccLine ); | 114 | pickAddress( ccLine ); |
121 | } | 115 | } |
122 | 116 | ||
123 | void ComposeMail::pickAddressBCC() | 117 | void ComposeMail::pickAddressBCC() |
124 | { | 118 | { |
125 | pickAddress( bccLine ); | 119 | pickAddress( bccLine ); |
126 | } | 120 | } |
127 | 121 | ||
128 | void ComposeMail::pickAddressReply() | 122 | void 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 | ||
229 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) | 228 | AttachViewItem::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() ); |