Diffstat (limited to 'noncore/net/mail/composemail.cpp') (more/less context) (show 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 @@ | |||
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 | #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 ) |
15 | { | 18 | { |
16 | settings = s; | 19 | settings = s; |
17 | m_replyid = ""; | 20 | m_replyid = ""; |
@@ -121,13 +124,13 @@ void ComposeMail::pickAddressBCC() | |||
121 | 124 | ||
122 | void ComposeMail::pickAddressReply() | 125 | void ComposeMail::pickAddressReply() |
123 | { | 126 | { |
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 ); |
131 | ccLine->clear(); | 134 | ccLine->clear(); |
132 | if ( smtp->getUseCC() ) { | 135 | if ( smtp->getUseCC() ) { |
133 | ccLine->setText( smtp->getCC() ); | 136 | ccLine->setText( smtp->getCC() ); |
@@ -182,52 +185,111 @@ void ComposeMail::accept() | |||
182 | } | 185 | } |
183 | 186 | ||
184 | #if 0 | 187 | #if 0 |
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() ) { |
211 | txt.append( "\n--\n" ); | 215 | txt.append( "\n--\n" ); |
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 | { |
231 | attachment = att; | 293 | attachment = att; |
232 | qDebug( att->getMimeType() ); | 294 | qDebug( att->getMimeType() ); |
233 | setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? | 295 | setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? |