author | zautrix <zautrix> | 2004-11-06 23:30:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-11-06 23:30:02 (UTC) |
commit | 023e0e82dd8bf6421d12492a2dd25534fc43ad31 (patch) (unidiff) | |
tree | cf0533e3ccc642cb57a41953f184f457fa5365ba /kmicromail/opiemail.cpp | |
parent | f8841c92d5251f713eb7a025af8fdee52de45b3d (diff) | |
download | kdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.zip kdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.tar.gz kdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.tar.bz2 |
many ompi fixes
-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 | |||
@@ -1,99 +1,100 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | 3 | ||
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); |
68 | 69 | ||
69 | mPendingEmail = QString::null; | 70 | mPendingEmail = QString::null; |
70 | mPendingName = QString::null; | 71 | mPendingName = QString::null; |
71 | if (msg == "writeMail(QString,QString)") | 72 | if (msg == "writeMail(QString,QString)") |
72 | { | 73 | { |
73 | //qDebug("writeMail(QString,QString) "); | 74 | //qDebug("writeMail(QString,QString) "); |
74 | QDataStream stream(data,IO_ReadOnly); | 75 | QDataStream stream(data,IO_ReadOnly); |
75 | stream >> mPendingName >> mPendingEmail; | 76 | stream >> mPendingName >> mPendingEmail; |
76 | // removing the whitespaces at beginning and end is needed! | 77 | // removing the whitespaces at beginning and end is needed! |
77 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 78 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
78 | } | 79 | } |
79 | else if (msg == "newMail()") | 80 | else if (msg == "newMail()") |
80 | { | 81 | { |
81 | //qDebug("slotComposeMail() "); | 82 | //qDebug("slotComposeMail() "); |
82 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 83 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
83 | // and a QCOP call does not like a processevents in his execution | 84 | // and a QCOP call does not like a processevents in his execution |
84 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 85 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
85 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 86 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
86 | // slotComposeMail(); | 87 | // slotComposeMail(); |
87 | } | 88 | } |
88 | else if (msg == "newMail(QString)") | 89 | else if (msg == "newMail(QString)") |
89 | { | 90 | { |
90 | //qDebug(" newMail(QString)"); | 91 | //qDebug(" newMail(QString)"); |
91 | QDataStream stream(data,IO_ReadOnly); | 92 | QDataStream stream(data,IO_ReadOnly); |
92 | stream >> mPendingName; | 93 | stream >> mPendingName; |
93 | // the format is | 94 | // the format is |
94 | // NAME <EMAIL>:SUBJECT | 95 | // NAME <EMAIL>:SUBJECT |
95 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 96 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
96 | } else { | 97 | } else { |
97 | mPendingData = data; | 98 | mPendingData = data; |
98 | mPendingMessage = msg; | 99 | mPendingMessage = msg; |
99 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); | 100 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); |
@@ -176,180 +177,181 @@ void OpieMail::slotSendQueued() | |||
176 | QList<Account> list = settings->getAccounts(); | 177 | QList<Account> list = settings->getAccounts(); |
177 | QList<SMTPaccount> smtpList; | 178 | QList<SMTPaccount> smtpList; |
178 | smtpList.setAutoDelete(false); | 179 | smtpList.setAutoDelete(false); |
179 | Account *it; | 180 | Account *it; |
180 | for ( it = list.first(); it; it = list.next() ) | 181 | for ( it = list.first(); it; it = list.next() ) |
181 | { | 182 | { |
182 | if ( it->getType() == MAILLIB::A_SMTP ) | 183 | if ( it->getType() == MAILLIB::A_SMTP ) |
183 | { | 184 | { |
184 | smtp = static_cast<SMTPaccount *>(it); | 185 | smtp = static_cast<SMTPaccount *>(it); |
185 | smtpList.append(smtp); | 186 | smtpList.append(smtp); |
186 | } | 187 | } |
187 | } | 188 | } |
188 | if (smtpList.count()==0) | 189 | if (smtpList.count()==0) |
189 | { | 190 | { |
190 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); | 191 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); |
191 | return; | 192 | return; |
192 | } | 193 | } |
193 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 194 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
194 | return; | 195 | return; |
195 | if (smtpList.count()==1) | 196 | if (smtpList.count()==1) |
196 | { | 197 | { |
197 | smtp = smtpList.at(0); | 198 | smtp = smtpList.at(0); |
198 | } | 199 | } |
199 | else | 200 | else |
200 | { | 201 | { |
201 | smtp = 0; | 202 | smtp = 0; |
202 | selectsmtp selsmtp; | 203 | selectsmtp selsmtp; |
203 | selsmtp.setSelectionlist(&smtpList); | 204 | selsmtp.setSelectionlist(&smtpList); |
204 | #ifndef DESKTOP_VERSION | 205 | #ifndef DESKTOP_VERSION |
205 | selsmtp.showMaximized(); | 206 | selsmtp.showMaximized(); |
206 | #endif | 207 | #endif |
207 | if ( selsmtp.exec() == QDialog::Accepted ) | 208 | if ( selsmtp.exec() == QDialog::Accepted ) |
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 | } |
324 | } | 326 | } |
325 | void OpieMail::slotGetAllMail() | 327 | void OpieMail::slotGetAllMail() |
326 | { | 328 | { |
327 | QListViewItem * item = folderView->firstChild(); | 329 | QListViewItem * item = folderView->firstChild(); |
328 | while ( item ){ | 330 | while ( item ){ |
329 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 331 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
330 | item = item->nextSibling (); | 332 | item = item->nextSibling (); |
331 | } | 333 | } |
332 | } | 334 | } |
333 | void OpieMail::slotGetMail() | 335 | void OpieMail::slotGetMail() |
334 | { | 336 | { |
335 | QListViewItem * item = folderView->currentItem(); | 337 | QListViewItem * item = folderView->currentItem(); |
336 | if ( ! item ) return; | 338 | if ( ! item ) return; |
337 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 339 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
338 | } | 340 | } |
339 | void OpieMail::slotDeleteMail() | 341 | void OpieMail::slotDeleteMail() |
340 | { | 342 | { |
341 | if (!mailView->currentItem()) return; | 343 | if (!mailView->currentItem()) return; |
342 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 344 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
343 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 345 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
344 | { | 346 | { |
345 | mail->Wrapper()->deleteMail( mail ); | 347 | mail->Wrapper()->deleteMail( mail ); |
346 | folderView->refreshCurrent(); | 348 | folderView->refreshCurrent(); |
347 | } | 349 | } |
348 | } | 350 | } |
349 | void OpieMail::slotDeleteAllMail() | 351 | void OpieMail::slotDeleteAllMail() |
350 | { | 352 | { |
351 | 353 | ||
352 | QValueList<RecMailP> t; | 354 | QValueList<RecMailP> t; |
353 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 355 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
354 | { | 356 | { |
355 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 357 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |