-rw-r--r-- | kmicromail/opiemail.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index af5376f..18a5600 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -4,64 +4,65 @@ | |||
4 | #include "koprefsdialog.h" | 4 | #include "koprefsdialog.h" |
5 | #include <kapplication.h> | 5 | #include <kapplication.h> |
6 | #include <libkdepim/externalapphandler.h> | 6 | #include <libkdepim/externalapphandler.h> |
7 | #include <libkdepim/kpimglobalprefs.h> | 7 | #include <libkdepim/kpimglobalprefs.h> |
8 | #ifdef MINIKDE_KDIALOG_H | 8 | #ifdef MINIKDE_KDIALOG_H |
9 | #undef MINIKDE_KDIALOG_H | 9 | #undef MINIKDE_KDIALOG_H |
10 | #endif | 10 | #endif |
11 | #include "settingsdialog.h" | 11 | #include "settingsdialog.h" |
12 | #include "opiemail.h" | 12 | #include "opiemail.h" |
13 | #include "editaccounts.h" | 13 | #include "editaccounts.h" |
14 | #include "composemail.h" | 14 | #include "composemail.h" |
15 | #include "mailistviewitem.h" | 15 | #include "mailistviewitem.h" |
16 | #include "viewmail.h" | 16 | #include "viewmail.h" |
17 | #include "selectstore.h" | 17 | #include "selectstore.h" |
18 | #include "selectsmtp.h" | 18 | #include "selectsmtp.h" |
19 | #include "accountitem.h" | 19 | #include "accountitem.h" |
20 | #include "klocale.h" | 20 | #include "klocale.h" |
21 | 21 | ||
22 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qcursor.h> | 24 | #include <qcursor.h> |
25 | #include <qregexp.h> | 25 | #include <qregexp.h> |
26 | #include <qpe/global.h> | 26 | #include <qpe/global.h> |
27 | 27 | ||
28 | #ifdef DESKTOP_VERSION | 28 | #ifdef DESKTOP_VERSION |
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | #else | 30 | #else |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #endif | 32 | #endif |
33 | #include <libmailwrapper/smtpwrapper.h> | 33 | #include <libmailwrapper/smtpwrapper.h> |
34 | #include <libmailwrapper/mailtypes.h> | 34 | #include <libmailwrapper/mailtypes.h> |
35 | #include <libmailwrapper/abstractmail.h> | 35 | #include <libmailwrapper/abstractmail.h> |
36 | #include "koprefs.h" | ||
36 | 37 | ||
37 | //using namespace Opie::Core; | 38 | //using namespace Opie::Core; |
38 | 39 | ||
39 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 40 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
40 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 41 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
41 | { | 42 | { |
42 | settings = new Settings(); | 43 | settings = new Settings(); |
43 | 44 | ||
44 | setIcon(SmallIcon( "kmicromail" ) ); | 45 | setIcon(SmallIcon( "kmicromail" ) ); |
45 | folderView->populate( settings->getAccounts() ); | 46 | folderView->populate( settings->getAccounts() ); |
46 | 47 | ||
47 | } | 48 | } |
48 | 49 | ||
49 | OpieMail::~OpieMail() | 50 | OpieMail::~OpieMail() |
50 | { | 51 | { |
51 | if (settings) delete settings; | 52 | if (settings) delete settings; |
52 | } | 53 | } |
53 | 54 | ||
54 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 55 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
55 | { | 56 | { |
56 | 57 | ||
57 | } | 58 | } |
58 | #include <stdlib.h> | 59 | #include <stdlib.h> |
59 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 60 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
60 | { | 61 | { |
61 | // copied from old mail2 | 62 | // copied from old mail2 |
62 | static int ii = 0; | 63 | static int ii = 0; |
63 | //qDebug("QCOP CALL ############################# %d ", ii); | 64 | //qDebug("QCOP CALL ############################# %d ", ii); |
64 | //QString mess ( msg ); | 65 | //QString mess ( msg ); |
65 | //qDebug("Message = %s ",mess.latin1()); | 66 | //qDebug("Message = %s ",mess.latin1()); |
66 | ++ii; | 67 | ++ii; |
67 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 68 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
@@ -208,116 +209,117 @@ void OpieMail::slotSendQueued() | |||
208 | { | 209 | { |
209 | smtp = selsmtp.selected_smtp(); | 210 | smtp = selsmtp.selected_smtp(); |
210 | } | 211 | } |
211 | } | 212 | } |
212 | if (smtp) | 213 | if (smtp) |
213 | { | 214 | { |
214 | 215 | ||
215 | Global::statusMessage("Sending mails...!"); | 216 | Global::statusMessage("Sending mails...!"); |
216 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 217 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
217 | if ( wrap->flushOutbox() ) | 218 | if ( wrap->flushOutbox() ) |
218 | { | 219 | { |
219 | Global::statusMessage("Mails sent!"); | 220 | Global::statusMessage("Mails sent!"); |
220 | } | 221 | } |
221 | delete wrap; | 222 | delete wrap; |
222 | } | 223 | } |
223 | // pending refresh list view, if outgoing is displayed | 224 | // pending refresh list view, if outgoing is displayed |
224 | } | 225 | } |
225 | 226 | ||
226 | void OpieMail::slotSearchMails() | 227 | void OpieMail::slotSearchMails() |
227 | { | 228 | { |
228 | qDebug("OpieMail::slotSearchMails():not implemented "); | 229 | qDebug("OpieMail::slotSearchMails():not implemented "); |
229 | } | 230 | } |
230 | 231 | ||
231 | void OpieMail::slotEditSettings() | 232 | void OpieMail::slotEditSettings() |
232 | { | 233 | { |
233 | 234 | ||
234 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 235 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
235 | #ifndef DESKTOP_VERSION | 236 | #ifndef DESKTOP_VERSION |
236 | settingsDialog.showMaximized(); | 237 | settingsDialog.showMaximized(); |
237 | #endif | 238 | #endif |
238 | settingsDialog.exec(); | 239 | settingsDialog.exec(); |
239 | 240 | ||
241 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | ||
240 | // KApplication::execDialog(settingsDialog); | 242 | // KApplication::execDialog(settingsDialog); |
241 | } | 243 | } |
242 | 244 | ||
243 | void OpieMail::slotEditAccounts() | 245 | void OpieMail::slotEditAccounts() |
244 | { | 246 | { |
245 | EditAccounts eaDialog( settings, this, 0, true ); | 247 | EditAccounts eaDialog( settings, this, 0, true ); |
246 | eaDialog.slotAdjustColumns(); | 248 | eaDialog.slotAdjustColumns(); |
247 | #ifndef DESKTOP_VERSION | 249 | #ifndef DESKTOP_VERSION |
248 | eaDialog.showMaximized(); | 250 | eaDialog.showMaximized(); |
249 | #endif | 251 | #endif |
250 | eaDialog.exec(); | 252 | eaDialog.exec(); |
251 | if ( settings ) delete settings; | 253 | if ( settings ) delete settings; |
252 | settings = new Settings(); | 254 | settings = new Settings(); |
253 | 255 | ||
254 | folderView->populate( settings->getAccounts() ); | 256 | folderView->populate( settings->getAccounts() ); |
255 | } | 257 | } |
256 | void OpieMail::replyMail() | 258 | void OpieMail::replyMail() |
257 | { | 259 | { |
258 | 260 | ||
259 | QListViewItem*item = mailView->currentItem(); | 261 | QListViewItem*item = mailView->currentItem(); |
260 | if (!item) return; | 262 | if (!item) return; |
261 | RecMailP mail = ((MailListViewItem*)item)->data(); | 263 | RecMailP mail = ((MailListViewItem*)item)->data(); |
262 | RecBodyP body = folderView->fetchBody(mail); | 264 | RecBodyP body = folderView->fetchBody(mail); |
263 | 265 | ||
264 | QString rtext; | 266 | QString rtext; |
265 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 267 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
266 | .arg( QString::fromUtf8( mail->getFrom().latin1())) | 268 | .arg( mail->getFrom()) |
267 | .arg( QString::fromUtf8( mail->getDate().latin1() )); | 269 | .arg( mail->getDate()); |
268 | 270 | ||
269 | QString text = QString::fromUtf8( body->Bodytext().latin1() ); | 271 | QString text = body->Bodytext(); |
270 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 272 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
271 | QStringList::Iterator it; | 273 | QStringList::Iterator it; |
272 | for (it = lines.begin(); it != lines.end(); it++) | 274 | for (it = lines.begin(); it != lines.end(); it++) |
273 | { | 275 | { |
274 | rtext += "> " + *it + "\n"; | 276 | rtext += "> " + *it + "\n"; |
275 | } | 277 | } |
276 | rtext += "\n"; | 278 | rtext += "\n"; |
277 | 279 | ||
278 | QString prefix; | 280 | QString prefix; |
279 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 281 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
280 | else prefix = "Re: "; // no i18n on purpose | 282 | else prefix = "Re: "; // no i18n on purpose |
281 | 283 | ||
282 | Settings *settings = new Settings(); | 284 | Settings *settings = new Settings(); |
283 | ComposeMail composer( settings ,this, 0, true); | 285 | ComposeMail composer( settings ,this, 0, true); |
284 | if (mail->Replyto().isEmpty()) { | 286 | if (mail->Replyto().isEmpty()) { |
285 | composer.setTo( QString::fromUtf8( mail->getFrom().latin1())); | 287 | composer.setTo( mail->getFrom()); |
286 | } else { | 288 | } else { |
287 | composer.setTo( QString::fromUtf8(mail->Replyto().latin1())); | 289 | composer.setTo( mail->Replyto()); |
288 | } | 290 | } |
289 | composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) ); | 291 | composer.setSubject( prefix + mail->getSubject()); |
290 | composer.setMessage( rtext ); | 292 | composer.setMessage( rtext ); |
291 | composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1())); | 293 | composer.setInReplyTo( mail->Msgid()); |
292 | 294 | ||
293 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 295 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
294 | { | 296 | { |
295 | mail->Wrapper()->answeredMail(mail); | 297 | mail->Wrapper()->answeredMail(mail); |
296 | } | 298 | } |
297 | delete settings; | 299 | delete settings; |
298 | 300 | ||
299 | } | 301 | } |
300 | void OpieMail::displayMail() | 302 | void OpieMail::displayMail() |
301 | { | 303 | { |
302 | QListViewItem*item = mailView->currentItem(); | 304 | QListViewItem*item = mailView->currentItem(); |
303 | if (!item) return; | 305 | if (!item) return; |
304 | RecMailP mail = ((MailListViewItem*)item)->data(); | 306 | RecMailP mail = ((MailListViewItem*)item)->data(); |
305 | RecBodyP body = folderView->fetchBody(mail); | 307 | RecBodyP body = folderView->fetchBody(mail); |
306 | ViewMail readMail( this,"", Qt::WType_Modal ); | 308 | ViewMail readMail( this,"", Qt::WType_Modal ); |
307 | readMail.setBody( body ); | 309 | readMail.setBody( body ); |
308 | readMail.setMail( mail ); | 310 | readMail.setMail( mail ); |
309 | #ifndef DESKTOP_VERSION | 311 | #ifndef DESKTOP_VERSION |
310 | readMail.showMaximized(); | 312 | readMail.showMaximized(); |
311 | #else | 313 | #else |
312 | readMail.resize( 640, 480); | 314 | readMail.resize( 640, 480); |
313 | #endif | 315 | #endif |
314 | readMail.exec(); | 316 | readMail.exec(); |
315 | 317 | ||
316 | if ( readMail.deleted ) | 318 | if ( readMail.deleted ) |
317 | { | 319 | { |
318 | folderView->refreshCurrent(); | 320 | folderView->refreshCurrent(); |
319 | } | 321 | } |
320 | else | 322 | else |
321 | { | 323 | { |
322 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 324 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
323 | } | 325 | } |