author | alwin <alwin> | 2004-03-10 22:44:44 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-10 22:44:44 (UTC) |
commit | 9454ac48a53f3b49e03288311b71436ccacd2d04 (patch) (side-by-side diff) | |
tree | e05d40f575c87431d84c5ac374ff8ce656e6a419 /noncore/net/mail/composemail.cpp | |
parent | a72855867dedd2b4c16f703fa104b5c6175ce484 (diff) | |
download | opie-9454ac48a53f3b49e03288311b71436ccacd2d04.zip opie-9454ac48a53f3b49e03288311b71436ccacd2d04.tar.gz opie-9454ac48a53f3b49e03288311b71436ccacd2d04.tar.bz2 |
some bugfixes
When edit a mail to send and cancel is pressed the mail can stored in a draft
folder and later edit again. This moment we will not store attachments into
drafts.
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 @@ -6,12 +6,15 @@ #include <qpe/global.h> #include <qpe/contact.h> #include "composemail.h" #include <libmailwrapper/smtpwrapper.h> +#include <libmailwrapper/storemail.h> +#include <libmailwrapper/abstractmail.h> +#include <libmailwrapper/mailtypes.h> ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) : ComposeMailUI( parent, name, modal, flags ) { settings = s; m_replyid = ""; @@ -121,13 +124,13 @@ void ComposeMail::pickAddressBCC() void ComposeMail::pickAddressReply() { pickAddress( replyLine ); } -void ComposeMail::fillValues( int current ) +void ComposeMail::fillValues( int ) { #if 0 SMTPaccount *smtp = smtpAccounts.at( current ); ccLine->clear(); if ( smtp->getUseCC() ) { ccLine->setText( smtp->getCC() ); @@ -182,52 +185,111 @@ void ComposeMail::accept() } #if 0 qDebug( "Sending Mail with " + smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); #endif - Mail *mail = new Mail(); + Mail mail; SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); - mail->setMail(fromBox->currentText()); + mail.setMail(fromBox->currentText()); if ( !toLine->text().isEmpty() ) { - mail->setTo( toLine->text() ); + mail.setTo( toLine->text() ); } else { - qDebug( "No Reciever spezified -> returning" ); + QMessageBox::warning(0,tr("Sending mail"), + tr("No Receiver spezified" ) ); return; } - mail->setName(senderNameEdit->text()); - mail->setCC( ccLine->text() ); - mail->setBCC( bccLine->text() ); - mail->setReply( replyLine->text() ); - mail->setSubject( subjectLine->text() ); + 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); + mail.setInreply(ids); } QString txt = message->text(); if ( !sigMultiLine->text().isEmpty() ) { txt.append( "\n--\n" ); txt.append( sigMultiLine->text() ); } qDebug(txt); - mail->setMessage( txt ); + mail.setMessage( txt ); AttachViewItem *it = (AttachViewItem *) attList->firstChild(); while ( it != NULL ) { - mail->addAttachment( it->getAttachment() ); + mail.addAttachment( it->getAttachment() ); it = (AttachViewItem *) it->nextSibling(); } SMTPwrapper wrapper( smtp ); - wrapper.sendMail( *mail,checkBoxLater->isChecked() ); + wrapper.sendMail( mail,checkBoxLater->isChecked() ); QDialog::accept(); } +void ComposeMail::reject() +{ + int yesno = QMessageBox::warning(0,tr("Store message"), + tr("Store message into drafts?"), + tr("Yes"), + tr("No"),QString::null,0,1); + + if (yesno == 0) { + Mail mail; + mail.setMail(fromBox->currentText()); + mail.setTo( toLine->text() ); + 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 ); + + /* only use the default drafts folder name! */ + Storemail wrapper(AbstractMail::draftFolder()); + wrapper.storeMail(mail); + + AttachViewItem *it = (AttachViewItem *) attList->firstChild(); + /* attachments we will ignore! */ + if ( it != NULL ) { + QMessageBox::warning(0,tr("Store message"), + tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); + } + } + QDialog::reject(); +} + +ComposeMail::~ComposeMail() +{ +} + +void ComposeMail::reEditMail(const RecMail¤t) +{ + RecMail data = current; + message->setText(data.Wrapper()->fetchBody(current).Bodytext()); + subjectLine->setText( data.getSubject()); + toLine->setText(data.To().join(",")); + ccLine->setText(data.CC().join(",")); + bccLine->setText(data.Bcc().join(",")); + replyLine->setText(data.Replyto()); +} + AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) : QListViewItem( parent ) { attachment = att; qDebug( att->getMimeType() ); setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? |