Diffstat (limited to 'noncore/net/mail/composemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/composemail.cpp | 90 |
1 files changed, 76 insertions, 14 deletions
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp index b5cd75b..b9c9cbc 100644 --- a/noncore/net/mail/composemail.cpp +++ b/noncore/net/mail/composemail.cpp | |||
@@ -9,6 +9,9 @@ | |||
9 | #include "composemail.h" | 9 | #include "composemail.h" |
10 | 10 | ||
11 | #include <libmailwrapper/smtpwrapper.h> | 11 | #include <libmailwrapper/smtpwrapper.h> |
12 | #include <libmailwrapper/storemail.h> | ||
13 | #include <libmailwrapper/abstractmail.h> | ||
14 | #include <libmailwrapper/mailtypes.h> | ||
12 | 15 | ||
13 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 16 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) |
14 | : ComposeMailUI( parent, name, modal, flags ) | 17 | : ComposeMailUI( parent, name, modal, flags ) |
@@ -124,7 +127,7 @@ void ComposeMail::pickAddressReply() | |||
124 | pickAddress( replyLine ); | 127 | pickAddress( replyLine ); |
125 | } | 128 | } |
126 | 129 | ||
127 | void ComposeMail::fillValues( int current ) | 130 | void ComposeMail::fillValues( int ) |
128 | { | 131 | { |
129 | #if 0 | 132 | #if 0 |
130 | SMTPaccount *smtp = smtpAccounts.at( current ); | 133 | SMTPaccount *smtp = smtpAccounts.at( current ); |
@@ -185,26 +188,27 @@ void ComposeMail::accept() | |||
185 | qDebug( "Sending Mail with " + | 188 | qDebug( "Sending Mail with " + |
186 | smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); | 189 | smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); |
187 | #endif | 190 | #endif |
188 | Mail *mail = new Mail(); | 191 | Mail mail; |
189 | 192 | ||
190 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); | 193 | SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); |
191 | mail->setMail(fromBox->currentText()); | 194 | mail.setMail(fromBox->currentText()); |
192 | 195 | ||
193 | if ( !toLine->text().isEmpty() ) { | 196 | if ( !toLine->text().isEmpty() ) { |
194 | mail->setTo( toLine->text() ); | 197 | mail.setTo( toLine->text() ); |
195 | } else { | 198 | } else { |
196 | qDebug( "No Reciever spezified -> returning" ); | 199 | QMessageBox::warning(0,tr("Sending mail"), |
200 | tr("No Receiver spezified" ) ); | ||
197 | return; | 201 | return; |
198 | } | 202 | } |
199 | mail->setName(senderNameEdit->text()); | 203 | mail.setName(senderNameEdit->text()); |
200 | mail->setCC( ccLine->text() ); | 204 | mail.setCC( ccLine->text() ); |
201 | mail->setBCC( bccLine->text() ); | 205 | mail.setBCC( bccLine->text() ); |
202 | mail->setReply( replyLine->text() ); | 206 | mail.setReply( replyLine->text() ); |
203 | mail->setSubject( subjectLine->text() ); | 207 | mail.setSubject( subjectLine->text() ); |
204 | if (!m_replyid.isEmpty()) { | 208 | if (!m_replyid.isEmpty()) { |
205 | QStringList ids; | 209 | QStringList ids; |
206 | ids.append(m_replyid); | 210 | ids.append(m_replyid); |
207 | mail->setInreply(ids); | 211 | mail.setInreply(ids); |
208 | } | 212 | } |
209 | QString txt = message->text(); | 213 | QString txt = message->text(); |
210 | if ( !sigMultiLine->text().isEmpty() ) { | 214 | if ( !sigMultiLine->text().isEmpty() ) { |
@@ -212,19 +216,77 @@ void ComposeMail::accept() | |||
212 | txt.append( sigMultiLine->text() ); | 216 | txt.append( sigMultiLine->text() ); |
213 | } | 217 | } |
214 | qDebug(txt); | 218 | qDebug(txt); |
215 | mail->setMessage( txt ); | 219 | mail.setMessage( txt ); |
216 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 220 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
217 | while ( it != NULL ) { | 221 | while ( it != NULL ) { |
218 | mail->addAttachment( it->getAttachment() ); | 222 | mail.addAttachment( it->getAttachment() ); |
219 | it = (AttachViewItem *) it->nextSibling(); | 223 | it = (AttachViewItem *) it->nextSibling(); |
220 | } | 224 | } |
221 | 225 | ||
222 | SMTPwrapper wrapper( smtp ); | 226 | SMTPwrapper wrapper( smtp ); |
223 | wrapper.sendMail( *mail,checkBoxLater->isChecked() ); | 227 | wrapper.sendMail( mail,checkBoxLater->isChecked() ); |
224 | 228 | ||
225 | QDialog::accept(); | 229 | QDialog::accept(); |
226 | } | 230 | } |
227 | 231 | ||
232 | void ComposeMail::reject() | ||
233 | { | ||
234 | int yesno = QMessageBox::warning(0,tr("Store message"), | ||
235 | tr("Store message into drafts?"), | ||
236 | tr("Yes"), | ||
237 | tr("No"),QString::null,0,1); | ||
238 | |||
239 | if (yesno == 0) { | ||
240 | Mail mail; | ||
241 | mail.setMail(fromBox->currentText()); | ||
242 | mail.setTo( toLine->text() ); | ||
243 | mail.setName(senderNameEdit->text()); | ||
244 | mail.setCC( ccLine->text() ); | ||
245 | mail.setBCC( bccLine->text() ); | ||
246 | mail.setReply( replyLine->text() ); | ||
247 | mail.setSubject( subjectLine->text() ); | ||
248 | if (!m_replyid.isEmpty()) { | ||
249 | QStringList ids; | ||
250 | ids.append(m_replyid); | ||
251 | mail.setInreply(ids); | ||
252 | } | ||
253 | QString txt = message->text(); | ||
254 | if ( !sigMultiLine->text().isEmpty() ) { | ||
255 | txt.append( "\n--\n" ); | ||
256 | txt.append( sigMultiLine->text() ); | ||
257 | } | ||
258 | qDebug(txt); | ||
259 | mail.setMessage( txt ); | ||
260 | |||
261 | /* only use the default drafts folder name! */ | ||
262 | Storemail wrapper(AbstractMail::draftFolder()); | ||
263 | wrapper.storeMail(mail); | ||
264 | |||
265 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | ||
266 | /* attachments we will ignore! */ | ||
267 | if ( it != NULL ) { | ||
268 | QMessageBox::warning(0,tr("Store message"), | ||
269 | tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); | ||
270 | } | ||
271 | } | ||
272 | QDialog::reject(); | ||
273 | } | ||
274 | |||
275 | ComposeMail::~ComposeMail() | ||
276 | { | ||
277 | } | ||
278 | |||
279 | void ComposeMail::reEditMail(const RecMail¤t) | ||
280 | { | ||
281 | RecMail data = current; | ||
282 | message->setText(data.Wrapper()->fetchBody(current).Bodytext()); | ||
283 | subjectLine->setText( data.getSubject()); | ||
284 | toLine->setText(data.To().join(",")); | ||
285 | ccLine->setText(data.CC().join(",")); | ||
286 | bccLine->setText(data.Bcc().join(",")); | ||
287 | replyLine->setText(data.Replyto()); | ||
288 | } | ||
289 | |||
228 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) | 290 | AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) |
229 | : QListViewItem( parent ) | 291 | : QListViewItem( parent ) |
230 | { | 292 | { |