summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 19ffdb3..4e7c6be 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,44 +1,45 @@
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 "settingsdialog.h" 4#include "settingsdialog.h"
5#include "opiemail.h" 5#include "opiemail.h"
6#include "editaccounts.h" 6#include "editaccounts.h"
7#include "composemail.h" 7#include "composemail.h"
8#include "mailistviewitem.h" 8#include "mailistviewitem.h"
9#include "viewmail.h" 9#include "viewmail.h"
10#include "selectstore.h" 10#include "selectstore.h"
11#include "selectsmtp.h" 11#include "selectsmtp.h"
12#include "accountitem.h" 12#include "accountitem.h"
13#include "koprefsdialog.h"
13 14
14#include <qmessagebox.h> 15#include <qmessagebox.h>
15#include <qtimer.h> 16#include <qtimer.h>
16#include <libkdepim/externalapphandler.h> 17#include <libkdepim/externalapphandler.h>
17 18
18#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
19#include <libmailwrapper/smtpwrapper.h> 20#include <libmailwrapper/smtpwrapper.h>
20#include <libmailwrapper/mailtypes.h> 21#include <libmailwrapper/mailtypes.h>
21#include <libmailwrapper/abstractmail.h> 22#include <libmailwrapper/abstractmail.h>
22/* OPIE */ 23/* OPIE */
23//#include <qpe/resource.h> 24//#include <qpe/resource.h>
24//#include <qpe/qpeapplication.h> 25//#include <qpe/qpeapplication.h>
25 26
26/* QT */ 27/* QT */
27 28
28//using namespace Opie::Core; 29//using namespace Opie::Core;
29 30
30OpieMail::OpieMail( QWidget *parent, const char *name ) 31OpieMail::OpieMail( QWidget *parent, const char *name )
31 : MainWindow( parent, name) //, WStyle_ContextHelp ) 32 : MainWindow( parent, name) //, WStyle_ContextHelp )
32{ 33{
33 settings = new Settings(); 34 settings = new Settings();
34 35
35 folderView->populate( settings->getAccounts() ); 36 folderView->populate( settings->getAccounts() );
36 37
37} 38}
38 39
39OpieMail::~OpieMail() 40OpieMail::~OpieMail()
40{ 41{
41 if (settings) delete settings; 42 if (settings) delete settings;
42} 43}
43 44
44void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 45void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
@@ -55,73 +56,75 @@ void OpieMail::message(const QCString &msg, const QByteArray &data)
55 //qDebug("Message = %s ",mess.latin1()); 56 //qDebug("Message = %s ",mess.latin1());
56 ++ii; 57 ++ii;
57 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 58 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
58 59
59 mPendingEmail = QString::null; 60 mPendingEmail = QString::null;
60 mPendingName = QString::null; 61 mPendingName = QString::null;
61 if (msg == "writeMail(QString,QString)") 62 if (msg == "writeMail(QString,QString)")
62 { 63 {
63 //qDebug("writeMail(QString,QString) "); 64 //qDebug("writeMail(QString,QString) ");
64 QDataStream stream(data,IO_ReadOnly); 65 QDataStream stream(data,IO_ReadOnly);
65 stream >> mPendingName >> mPendingEmail; 66 stream >> mPendingName >> mPendingEmail;
66 // removing the whitespaces at beginning and end is needed! 67 // removing the whitespaces at beginning and end is needed!
67 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 68 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
68 } 69 }
69 else if (msg == "newMail()") 70 else if (msg == "newMail()")
70 { 71 {
71 //qDebug("slotComposeMail() "); 72 //qDebug("slotComposeMail() ");
72 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call 73 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call
73 // and a QCOP call does not like a processevents in his execution 74 // and a QCOP call does not like a processevents in his execution
74 // with the Qtimer we call slotComposeMail() after we reached the main event loop 75 // with the Qtimer we call slotComposeMail() after we reached the main event loop
75 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 76 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
76 // slotComposeMail(); 77 // slotComposeMail();
77 } 78 }
78 else if (msg == "newMail(QString)") 79 else if (msg == "newMail(QString)")
79 { 80 {
80 //qDebug(" newMail(QString)"); 81 //qDebug(" newMail(QString)");
81 QDataStream stream(data,IO_ReadOnly); 82 QDataStream stream(data,IO_ReadOnly);
82 stream >> mPendingName; 83 stream >> mPendingName;
83 // the format is 84 // the format is
84 // NAME <EMAIL>:SUBJECT 85 // NAME <EMAIL>:SUBJECT
85 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 86 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
86 } else { 87 } else {
87 if ( ii == 1 ) { 88 mPendingData = data;
88 qDebug("Kopiemail::Error:: Initial QCOP call for ExternalAppHandler not supported "); 89 mPendingMessage = msg;
89 return; 90 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) );
90 }
91 ExternalAppHandler::instance()->appMessage ( msg, data);
92 } 91 }
93 92
94 //qDebug("END OpieMail::message "); 93 //qDebug("END OpieMail::message ");
95} 94}
95void OpieMail::slotExtAppHandler()
96{
97 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData );
98}
96void OpieMail::slotwriteMail2(const QString& namemail ) 99void OpieMail::slotwriteMail2(const QString& namemail )
97{ 100{
98 //qDebug("OpieMail::slotwriteMail2 "); 101 //qDebug("OpieMail::slotwriteMail2 ");
99 //qApp->processEvents(); 102 //qApp->processEvents();
100 ComposeMail compose( settings, this, 0, true ); 103 ComposeMail compose( settings, this, 0, true );
101 if ( !namemail.isEmpty() ) { 104 if ( !namemail.isEmpty() ) {
102 QString to = namemail; 105 QString to = namemail;
103 if ( namemail.find( " <") > 1 ) { 106 if ( namemail.find( " <") > 1 ) {
104 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 107 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
105 } else 108 } else
106 if ( namemail.find( "<") > 1 ) { 109 if ( namemail.find( "<") > 1 ) {
107 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 110 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
108 } 111 }
109 int sub = to.find( ">:"); 112 int sub = to.find( ">:");
110 if ( sub > 0 ) { 113 if ( sub > 0 ) {
111 compose.setTo( to.left(sub+1) ); 114 compose.setTo( to.left(sub+1) );
112 compose.setSubject( to.mid(sub+2) ); 115 compose.setSubject( to.mid(sub+2) );
113 } else 116 } else
114 compose.setTo( to ); 117 compose.setTo( to );
115 } 118 }
116 compose.slotAdjustColumns(); 119 compose.slotAdjustColumns();
117 compose.showMaximized(); 120 compose.showMaximized();
118 compose.exec(); 121 compose.exec();
119 raise(); 122 raise();
120 //qDebug("retttich "); 123 //qDebug("retttich ");
121} 124}
122void OpieMail::slotwriteMail(const QString&name,const QString&email) 125void OpieMail::slotwriteMail(const QString&name,const QString&email)
123{ 126{
124 // qDebug("OpieMail::slotwriteMail "); 127 // qDebug("OpieMail::slotwriteMail ");
125 ComposeMail compose( settings, this, 0, true ); 128 ComposeMail compose( settings, this, 0, true );
126 if (!email.isEmpty()) 129 if (!email.isEmpty())
127 { 130 {
@@ -178,88 +181,93 @@ void OpieMail::slotSendQueued()
178 { 181 {
179 smtp = smtpList.at(0); 182 smtp = smtpList.at(0);
180 } 183 }
181 else 184 else
182 { 185 {
183 smtp = 0; 186 smtp = 0;
184 selectsmtp selsmtp; 187 selectsmtp selsmtp;
185 selsmtp.setSelectionlist(&smtpList); 188 selsmtp.setSelectionlist(&smtpList);
186 selsmtp.showMaximized(); 189 selsmtp.showMaximized();
187 if ( selsmtp.exec() == QDialog::Accepted ) 190 if ( selsmtp.exec() == QDialog::Accepted )
188 { 191 {
189 smtp = selsmtp.selected_smtp(); 192 smtp = selsmtp.selected_smtp();
190 } 193 }
191 } 194 }
192 if (smtp) 195 if (smtp)
193 { 196 {
194 SMTPwrapper * wrap = new SMTPwrapper(smtp); 197 SMTPwrapper * wrap = new SMTPwrapper(smtp);
195 if ( wrap->flushOutbox() ) 198 if ( wrap->flushOutbox() )
196 { 199 {
197 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 200 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
198 } 201 }
199 delete wrap; 202 delete wrap;
200 } 203 }
201} 204}
202 205
203void OpieMail::slotSearchMails() 206void OpieMail::slotSearchMails()
204{ 207{
205 qDebug("OpieMail::slotSearchMails():not implemented "); 208 qDebug("OpieMail::slotSearchMails():not implemented ");
206} 209}
207 210
208void OpieMail::slotEditSettings() 211void OpieMail::slotEditSettings()
209{ 212{
213#if 0
210 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 214 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
211 settingsDialog.showMaximized(); 215 settingsDialog.showMaximized();
212 settingsDialog.exec(); 216 settingsDialog.exec();
217#endif
218 KOPrefsDialog settingsDialog( this, "koprefs", true );
219 settingsDialog.showMaximized();
220 settingsDialog.exec();
213} 221}
214 222
215void OpieMail::slotEditAccounts() 223void OpieMail::slotEditAccounts()
216{ 224{
217 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 225 EditAccounts eaDialog( settings, this, 0, true );
218 eaDialog.slotAdjustColumns(); 226 eaDialog.slotAdjustColumns();
219 eaDialog.showMaximized(); 227 eaDialog.showMaximized();
220 eaDialog.exec(); 228 eaDialog.exec();
221 if ( settings ) delete settings; 229 if ( settings ) delete settings;
222 settings = new Settings(); 230 settings = new Settings();
223 231
224 folderView->populate( settings->getAccounts() ); 232 folderView->populate( settings->getAccounts() );
225} 233}
226 234
227void OpieMail::displayMail() 235void OpieMail::displayMail()
228{ 236{
229 QListViewItem*item = mailView->currentItem(); 237 QListViewItem*item = mailView->currentItem();
230 if (!item) return; 238 if (!item) return;
231 RecMailP mail = ((MailListViewItem*)item)->data(); 239 RecMailP mail = ((MailListViewItem*)item)->data();
232 RecBodyP body = folderView->fetchBody(mail); 240 RecBodyP body = folderView->fetchBody(mail);
233 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); 241 ViewMail readMail( this,"", Qt::WType_Modal );
234 readMail.setBody( body ); 242 readMail.setBody( body );
235 readMail.setMail( mail ); 243 readMail.setMail( mail );
236 readMail.showMaximized(); 244 readMail.showMaximized();
237 readMail.exec(); 245 readMail.exec();
238 246
239 if ( readMail.deleted ) 247 if ( readMail.deleted )
240 { 248 {
241 folderView->refreshCurrent(); 249 folderView->refreshCurrent();
242 } 250 }
243 else 251 else
244 { 252 {
245 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 253 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
246 } 254 }
247} 255}
248void OpieMail::slotGetMail() 256void OpieMail::slotGetMail()
249{ 257{
250 QListViewItem * item = folderView->currentItem(); 258 QListViewItem * item = folderView->currentItem();
251 if ( ! item ) return; 259 if ( ! item ) return;
252 while ( item->parent () ) 260 while ( item->parent () )
253 item = item->parent (); 261 item = item->parent ();
254 ((AccountViewItem *)item)->contextMenuSelected( 101 ); 262 ((AccountViewItem *)item)->contextMenuSelected( 101 );
255} 263}
256void OpieMail::slotDeleteMail() 264void OpieMail::slotDeleteMail()
257{ 265{
258 if (!mailView->currentItem()) return; 266 if (!mailView->currentItem()) return;
259 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 267 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
260 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 268 if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
261 { 269 {
262 mail->Wrapper()->deleteMail( mail ); 270 mail->Wrapper()->deleteMail( mail );
263 folderView->refreshCurrent(); 271 folderView->refreshCurrent();
264 } 272 }
265} 273}