summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index ca3faaf..fe9df87 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -11,64 +11,65 @@
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 26
27#ifdef DESKTOP_VERSION 27#ifdef DESKTOP_VERSION
28#include <qapplication.h> 28#include <qapplication.h>
29#else 29#else
30#include <qpe/qpeapplication.h> 30#include <qpe/qpeapplication.h>
31#endif 31#endif
32#include <libmailwrapper/smtpwrapper.h> 32#include <libmailwrapper/smtpwrapper.h>
33#include <libmailwrapper/mailtypes.h> 33#include <libmailwrapper/mailtypes.h>
34#include <libmailwrapper/abstractmail.h> 34#include <libmailwrapper/abstractmail.h>
35 35
36//using namespace Opie::Core; 36//using namespace Opie::Core;
37 37
38OpieMail::OpieMail( QWidget *parent, const char *name ) 38OpieMail::OpieMail( QWidget *parent, const char *name )
39 : MainWindow( parent, name) //, WStyle_ContextHelp ) 39 : MainWindow( parent, name) //, WStyle_ContextHelp )
40{ 40{
41 settings = new Settings(); 41 settings = new Settings();
42 42
43 setIcon(SmallIcon( "kmicromail" ) );
43 folderView->populate( settings->getAccounts() ); 44 folderView->populate( settings->getAccounts() );
44 45
45} 46}
46 47
47OpieMail::~OpieMail() 48OpieMail::~OpieMail()
48{ 49{
49 if (settings) delete settings; 50 if (settings) delete settings;
50} 51}
51 52
52void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 53void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
53{ 54{
54 55
55} 56}
56#include <stdlib.h> 57#include <stdlib.h>
57void OpieMail::message(const QCString &msg, const QByteArray &data) 58void OpieMail::message(const QCString &msg, const QByteArray &data)
58{ 59{
59 // copied from old mail2 60 // copied from old mail2
60 static int ii = 0; 61 static int ii = 0;
61 //qDebug("QCOP CALL ############################# %d ", ii); 62 //qDebug("QCOP CALL ############################# %d ", ii);
62 //QString mess ( msg ); 63 //QString mess ( msg );
63 //qDebug("Message = %s ",mess.latin1()); 64 //qDebug("Message = %s ",mess.latin1());
64 ++ii; 65 ++ii;
65 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 66 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
66 67
67 mPendingEmail = QString::null; 68 mPendingEmail = QString::null;
68 mPendingName = QString::null; 69 mPendingName = QString::null;
69 if (msg == "writeMail(QString,QString)") 70 if (msg == "writeMail(QString,QString)")
70 { 71 {
71 //qDebug("writeMail(QString,QString) "); 72 //qDebug("writeMail(QString,QString) ");
72 QDataStream stream(data,IO_ReadOnly); 73 QDataStream stream(data,IO_ReadOnly);
73 stream >> mPendingName >> mPendingEmail; 74 stream >> mPendingName >> mPendingEmail;
74 // removing the whitespaces at beginning and end is needed! 75 // removing the whitespaces at beginning and end is needed!
@@ -211,65 +212,108 @@ void OpieMail::slotSendQueued()
211} 212}
212 213
213void OpieMail::slotSearchMails() 214void OpieMail::slotSearchMails()
214{ 215{
215 qDebug("OpieMail::slotSearchMails():not implemented "); 216 qDebug("OpieMail::slotSearchMails():not implemented ");
216} 217}
217 218
218void OpieMail::slotEditSettings() 219void OpieMail::slotEditSettings()
219{ 220{
220 221
221 KOPrefsDialog settingsDialog( this, "koprefs", true ); 222 KOPrefsDialog settingsDialog( this, "koprefs", true );
222#ifndef DESKTOP_VERSION 223#ifndef DESKTOP_VERSION
223 settingsDialog.showMaximized(); 224 settingsDialog.showMaximized();
224#endif 225#endif
225 settingsDialog.exec(); 226 settingsDialog.exec();
226 227
227 // KApplication::execDialog(settingsDialog); 228 // KApplication::execDialog(settingsDialog);
228} 229}
229 230
230void OpieMail::slotEditAccounts() 231void OpieMail::slotEditAccounts()
231{ 232{
232 EditAccounts eaDialog( settings, this, 0, true ); 233 EditAccounts eaDialog( settings, this, 0, true );
233 eaDialog.slotAdjustColumns(); 234 eaDialog.slotAdjustColumns();
234#ifndef DESKTOP_VERSION 235#ifndef DESKTOP_VERSION
235 eaDialog.showMaximized(); 236 eaDialog.showMaximized();
236#endif 237#endif
237 eaDialog.exec(); 238 eaDialog.exec();
238 if ( settings ) delete settings; 239 if ( settings ) delete settings;
239 settings = new Settings(); 240 settings = new Settings();
240 241
241 folderView->populate( settings->getAccounts() ); 242 folderView->populate( settings->getAccounts() );
242} 243}
244void OpieMail::replyMail()
245{
246
247 QListViewItem*item = mailView->currentItem();
248 if (!item) return;
249 RecMailP mail = ((MailListViewItem*)item)->data();
250 RecBodyP body = folderView->fetchBody(mail);
251
252 QString rtext;
253 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
254 .arg( QString::fromUtf8( mail->getFrom().latin1()))
255 .arg( QString::fromUtf8( mail->getDate().latin1() ));
256
257 QString text = QString::fromUtf8( body->Bodytext().latin1() );
258 QStringList lines = QStringList::split(QRegExp("\\n"), text);
259 QStringList::Iterator it;
260 for (it = lines.begin(); it != lines.end(); it++)
261 {
262 rtext += "> " + *it + "\n";
263 }
264 rtext += "\n";
243 265
266 QString prefix;
267 if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = "";
268 else prefix = "Re: "; // no i18n on purpose
269
270 Settings *settings = new Settings();
271 ComposeMail composer( settings ,this, 0, true);
272 if (mail->Replyto().isEmpty()) {
273 composer.setTo( QString::fromUtf8( mail->getFrom().latin1()));
274 } else {
275 composer.setTo( QString::fromUtf8(mail->Replyto().latin1()));
276 }
277 composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) );
278 composer.setMessage( rtext );
279 composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1()));
280
281 if ( QDialog::Accepted == KApplication::execDialog( &composer ) )
282 {
283 mail->Wrapper()->answeredMail(mail);
284 }
285 delete settings;
286
287}
244void OpieMail::displayMail() 288void OpieMail::displayMail()
245{ 289{
246 QListViewItem*item = mailView->currentItem(); 290 QListViewItem*item = mailView->currentItem();
247 if (!item) return; 291 if (!item) return;
248 RecMailP mail = ((MailListViewItem*)item)->data(); 292 RecMailP mail = ((MailListViewItem*)item)->data();
249 RecBodyP body = folderView->fetchBody(mail); 293 RecBodyP body = folderView->fetchBody(mail);
250 ViewMail readMail( this,"", Qt::WType_Modal ); 294 ViewMail readMail( this,"", Qt::WType_Modal );
251 readMail.setBody( body ); 295 readMail.setBody( body );
252 readMail.setMail( mail ); 296 readMail.setMail( mail );
253#ifndef DESKTOP_VERSION 297#ifndef DESKTOP_VERSION
254 readMail.showMaximized(); 298 readMail.showMaximized();
255#else 299#else
256 readMail.resize( 640, 480); 300 readMail.resize( 640, 480);
257#endif 301#endif
258 readMail.exec(); 302 readMail.exec();
259 303
260 if ( readMail.deleted ) 304 if ( readMail.deleted )
261 { 305 {
262 folderView->refreshCurrent(); 306 folderView->refreshCurrent();
263 } 307 }
264 else 308 else
265 { 309 {
266 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 310 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
267 } 311 }
268} 312}
269void OpieMail::slotGetAllMail() 313void OpieMail::slotGetAllMail()
270{ 314{
271 QListViewItem * item = folderView->firstChild(); 315 QListViewItem * item = folderView->firstChild();
272 while ( item ){ 316 while ( item ){
273 ((AccountViewItem *)item)->contextMenuSelected( 101 ); 317 ((AccountViewItem *)item)->contextMenuSelected( 101 );
274 item = item->nextSibling (); 318 item = item->nextSibling ();
275 } 319 }
@@ -311,64 +355,66 @@ void OpieMail::slotDeleteAllMail()
311 RecMailP mail = t.first(); 355 RecMailP mail = t.first();
312 mail->Wrapper()->deleteMailList(t); 356 mail->Wrapper()->deleteMailList(t);
313 folderView->refreshCurrent(); 357 folderView->refreshCurrent();
314 358
315 359
316} 360}
317void OpieMail::clearSelection() 361void OpieMail::clearSelection()
318{ 362{
319 mailView->clearSelection(); 363 mailView->clearSelection();
320 364
321} 365}
322 366
323void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 367void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
324{ 368{
325 if (!mailView->currentItem()) return; 369 if (!mailView->currentItem()) return;
326 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 370 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
327 /* just the RIGHT button - or hold on pda */ 371 /* just the RIGHT button - or hold on pda */
328 if (button!=2) {return;} 372 if (button!=2) {return;}
329 if (!item) return; 373 if (!item) return;
330 QPopupMenu *m = new QPopupMenu(0); 374 QPopupMenu *m = new QPopupMenu(0);
331 if (m) 375 if (m)
332 { 376 {
333 if (mailtype==MAILLIB::A_NNTP) { 377 if (mailtype==MAILLIB::A_NNTP) {
334 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); 378 m->insertItem(i18n("Read this posting"),this,SLOT(displayMail()));
335 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); 379 m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail()));
336 m->insertSeparator(); 380 m->insertSeparator();
337 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); 381 m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail()));
338 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 382 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
339 } else { 383 } else {
340 if (folderView->currentisDraft()) { 384 if (folderView->currentisDraft()) {
341 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); 385 m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail()));
342 } 386 }
387 m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail()));
388 m->insertSeparator();
343 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); 389 m->insertItem(i18n("Read this mail"),this,SLOT(displayMail()));
344 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); 390 m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail()));
345 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); 391 m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail()));
346 m->insertSeparator(); 392 m->insertSeparator();
347 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); 393 m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail()));
348 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 394 m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
349 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); 395 m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection()));
350 } 396 }
351 m->setFocus(); 397 m->setFocus();
352 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 398 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
353 delete m; 399 delete m;
354 } 400 }
355} 401}
356 402
357void OpieMail::slotShowFolders( bool show ) 403void OpieMail::slotShowFolders( bool show )
358{ 404{
359 if ( show && folderView->isHidden() ) 405 if ( show && folderView->isHidden() )
360 { 406 {
361 folderView->show(); 407 folderView->show();
362 } 408 }
363 else if ( !show && !folderView->isHidden() ) 409 else if ( !show && !folderView->isHidden() )
364 { 410 {
365 folderView->hide(); 411 folderView->hide();
366 } 412 }
367} 413}
368 414
369void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 415void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
370{ 416{
371 MailListViewItem*item = 0; 417 MailListViewItem*item = 0;
372 mailView->clear(); 418 mailView->clear();
373 419
374 QValueList<RecMailP>::ConstIterator it; 420 QValueList<RecMailP>::ConstIterator it;