summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
Unidiff
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index b2119e6..19ffdb3 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,107 +1,108 @@
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 13
13#include <qmessagebox.h> 14#include <qmessagebox.h>
14#include <qtimer.h> 15#include <qtimer.h>
15#include <libkdepim/externalapphandler.h> 16#include <libkdepim/externalapphandler.h>
16 17
17#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
18#include <libmailwrapper/smtpwrapper.h> 19#include <libmailwrapper/smtpwrapper.h>
19#include <libmailwrapper/mailtypes.h> 20#include <libmailwrapper/mailtypes.h>
20#include <libmailwrapper/abstractmail.h> 21#include <libmailwrapper/abstractmail.h>
21/* OPIE */ 22/* OPIE */
22//#include <qpe/resource.h> 23//#include <qpe/resource.h>
23//#include <qpe/qpeapplication.h> 24//#include <qpe/qpeapplication.h>
24 25
25/* QT */ 26/* QT */
26 27
27//using namespace Opie::Core; 28//using namespace Opie::Core;
28 29
29OpieMail::OpieMail( QWidget *parent, const char *name ) 30OpieMail::OpieMail( QWidget *parent, const char *name )
30 : MainWindow( parent, name) //, WStyle_ContextHelp ) 31 : MainWindow( parent, name) //, WStyle_ContextHelp )
31{ 32{
32 settings = new Settings(); 33 settings = new Settings();
33 34
34 folderView->populate( settings->getAccounts() ); 35 folderView->populate( settings->getAccounts() );
35 36
36} 37}
37 38
38OpieMail::~OpieMail() 39OpieMail::~OpieMail()
39{ 40{
40 if (settings) delete settings; 41 if (settings) delete settings;
41} 42}
42 43
43void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 44void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
44{ 45{
45 46
46} 47}
47#include <stdlib.h> 48#include <stdlib.h>
48void OpieMail::message(const QCString &msg, const QByteArray &data) 49void OpieMail::message(const QCString &msg, const QByteArray &data)
49{ 50{
50 // copied from old mail2 51 // copied from old mail2
51 static int ii = 0; 52 static int ii = 0;
52 //qDebug("QCOP CALL ############################# %d ", ii); 53 //qDebug("QCOP CALL ############################# %d ", ii);
53 //QString mess ( msg ); 54 //QString mess ( msg );
54 //qDebug("Message = %s ",mess.latin1()); 55 //qDebug("Message = %s ",mess.latin1());
55 ++ii; 56 ++ii;
56 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 57 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
57 58
58 mPendingEmail = QString::null; 59 mPendingEmail = QString::null;
59 mPendingName = QString::null; 60 mPendingName = QString::null;
60 if (msg == "writeMail(QString,QString)") 61 if (msg == "writeMail(QString,QString)")
61 { 62 {
62 //qDebug("writeMail(QString,QString) "); 63 //qDebug("writeMail(QString,QString) ");
63 QDataStream stream(data,IO_ReadOnly); 64 QDataStream stream(data,IO_ReadOnly);
64 stream >> mPendingName >> mPendingEmail; 65 stream >> mPendingName >> mPendingEmail;
65 // removing the whitespaces at beginning and end is needed! 66 // removing the whitespaces at beginning and end is needed!
66 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 67 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
67 } 68 }
68 else if (msg == "newMail()") 69 else if (msg == "newMail()")
69 { 70 {
70 //qDebug("slotComposeMail() "); 71 //qDebug("slotComposeMail() ");
71 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call 72 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call
72 // and a QCOP call does not like a processevents in his execution 73 // and a QCOP call does not like a processevents in his execution
73 // with the Qtimer we call slotComposeMail() after we reached the main event loop 74 // with the Qtimer we call slotComposeMail() after we reached the main event loop
74 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 75 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
75 // slotComposeMail(); 76 // slotComposeMail();
76 } 77 }
77 else if (msg == "newMail(QString)") 78 else if (msg == "newMail(QString)")
78 { 79 {
79 //qDebug(" newMail(QString)"); 80 //qDebug(" newMail(QString)");
80 QDataStream stream(data,IO_ReadOnly); 81 QDataStream stream(data,IO_ReadOnly);
81 stream >> mPendingName; 82 stream >> mPendingName;
82 // the format is 83 // the format is
83 // NAME <EMAIL>:SUBJECT 84 // NAME <EMAIL>:SUBJECT
84 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 85 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
85 } else { 86 } else {
86 if ( ii == 1 ) { 87 if ( ii == 1 ) {
87 qDebug("Kopiemail::Error:: Initial QCOP call for ExternalAppHandler not supported "); 88 qDebug("Kopiemail::Error:: Initial QCOP call for ExternalAppHandler not supported ");
88 return; 89 return;
89 } 90 }
90 ExternalAppHandler::instance()->appMessage ( msg, data); 91 ExternalAppHandler::instance()->appMessage ( msg, data);
91 } 92 }
92 93
93 //qDebug("END OpieMail::message "); 94 //qDebug("END OpieMail::message ");
94} 95}
95void OpieMail::slotwriteMail2(const QString& namemail ) 96void OpieMail::slotwriteMail2(const QString& namemail )
96{ 97{
97 //qDebug("OpieMail::slotwriteMail2 "); 98 //qDebug("OpieMail::slotwriteMail2 ");
98 //qApp->processEvents(); 99 //qApp->processEvents();
99 ComposeMail compose( settings, this, 0, true ); 100 ComposeMail compose( settings, this, 0, true );
100 if ( !namemail.isEmpty() ) { 101 if ( !namemail.isEmpty() ) {
101 QString to = namemail; 102 QString to = namemail;
102 if ( namemail.find( " <") > 1 ) { 103 if ( namemail.find( " <") > 1 ) {
103 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 104 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
104 } else 105 } else
105 if ( namemail.find( "<") > 1 ) { 106 if ( namemail.find( "<") > 1 ) {
106 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 107 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
107 } 108 }
@@ -151,193 +152,200 @@ void OpieMail::slotComposeMail()
151 } 152 }
152 //slotwriteMail(0l,0l); 153 //slotwriteMail(0l,0l);
153} 154}
154 155
155void OpieMail::slotSendQueued() 156void OpieMail::slotSendQueued()
156{ 157{
157 SMTPaccount *smtp = 0; 158 SMTPaccount *smtp = 0;
158 159
159 QList<Account> list = settings->getAccounts(); 160 QList<Account> list = settings->getAccounts();
160 QList<SMTPaccount> smtpList; 161 QList<SMTPaccount> smtpList;
161 smtpList.setAutoDelete(false); 162 smtpList.setAutoDelete(false);
162 Account *it; 163 Account *it;
163 for ( it = list.first(); it; it = list.next() ) 164 for ( it = list.first(); it; it = list.next() )
164 { 165 {
165 if ( it->getType() == MAILLIB::A_SMTP ) 166 if ( it->getType() == MAILLIB::A_SMTP )
166 { 167 {
167 smtp = static_cast<SMTPaccount *>(it); 168 smtp = static_cast<SMTPaccount *>(it);
168 smtpList.append(smtp); 169 smtpList.append(smtp);
169 } 170 }
170 } 171 }
171 if (smtpList.count()==0) 172 if (smtpList.count()==0)
172 { 173 {
173 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n")); 174 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n"));
174 return; 175 return;
175 } 176 }
176 if (smtpList.count()==1) 177 if (smtpList.count()==1)
177 { 178 {
178 smtp = smtpList.at(0); 179 smtp = smtpList.at(0);
179 } 180 }
180 else 181 else
181 { 182 {
182 smtp = 0; 183 smtp = 0;
183 selectsmtp selsmtp; 184 selectsmtp selsmtp;
184 selsmtp.setSelectionlist(&smtpList); 185 selsmtp.setSelectionlist(&smtpList);
185 selsmtp.showMaximized(); 186 selsmtp.showMaximized();
186 if ( selsmtp.exec() == QDialog::Accepted ) 187 if ( selsmtp.exec() == QDialog::Accepted )
187 { 188 {
188 smtp = selsmtp.selected_smtp(); 189 smtp = selsmtp.selected_smtp();
189 } 190 }
190 } 191 }
191 if (smtp) 192 if (smtp)
192 { 193 {
193 SMTPwrapper * wrap = new SMTPwrapper(smtp); 194 SMTPwrapper * wrap = new SMTPwrapper(smtp);
194 if ( wrap->flushOutbox() ) 195 if ( wrap->flushOutbox() )
195 { 196 {
196 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 197 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
197 } 198 }
198 delete wrap; 199 delete wrap;
199 } 200 }
200} 201}
201 202
202void OpieMail::slotSearchMails() 203void OpieMail::slotSearchMails()
203{ 204{
204 qDebug("OpieMail::slotSearchMails():not implemented "); 205 qDebug("OpieMail::slotSearchMails():not implemented ");
205} 206}
206 207
207void OpieMail::slotEditSettings() 208void OpieMail::slotEditSettings()
208{ 209{
209 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 210 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
210 settingsDialog.showMaximized(); 211 settingsDialog.showMaximized();
211 settingsDialog.exec(); 212 settingsDialog.exec();
212} 213}
213 214
214void OpieMail::slotEditAccounts() 215void OpieMail::slotEditAccounts()
215{ 216{
216 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 217 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
217 eaDialog.slotAdjustColumns(); 218 eaDialog.slotAdjustColumns();
218 eaDialog.showMaximized(); 219 eaDialog.showMaximized();
219 eaDialog.exec(); 220 eaDialog.exec();
220 if ( settings ) delete settings; 221 if ( settings ) delete settings;
221 settings = new Settings(); 222 settings = new Settings();
222 223
223 folderView->populate( settings->getAccounts() ); 224 folderView->populate( settings->getAccounts() );
224} 225}
225 226
226void OpieMail::displayMail() 227void OpieMail::displayMail()
227{ 228{
228 QListViewItem*item = mailView->currentItem(); 229 QListViewItem*item = mailView->currentItem();
229 if (!item) return; 230 if (!item) return;
230 RecMailP mail = ((MailListViewItem*)item)->data(); 231 RecMailP mail = ((MailListViewItem*)item)->data();
231 RecBodyP body = folderView->fetchBody(mail); 232 RecBodyP body = folderView->fetchBody(mail);
232 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); 233 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
233 readMail.setBody( body ); 234 readMail.setBody( body );
234 readMail.setMail( mail ); 235 readMail.setMail( mail );
235 readMail.showMaximized(); 236 readMail.showMaximized();
236 readMail.exec(); 237 readMail.exec();
237 238
238 if ( readMail.deleted ) 239 if ( readMail.deleted )
239 { 240 {
240 folderView->refreshCurrent(); 241 folderView->refreshCurrent();
241 } 242 }
242 else 243 else
243 { 244 {
244 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 245 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
245 } 246 }
246} 247}
247 248void OpieMail::slotGetMail()
249{
250 QListViewItem * item = folderView->currentItem();
251 if ( ! item ) return;
252 while ( item->parent () )
253 item = item->parent ();
254 ((AccountViewItem *)item)->contextMenuSelected( 101 );
255}
248void OpieMail::slotDeleteMail() 256void OpieMail::slotDeleteMail()
249{ 257{
250 if (!mailView->currentItem()) return; 258 if (!mailView->currentItem()) return;
251 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 259 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
252 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 ) 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 )
253 { 261 {
254 mail->Wrapper()->deleteMail( mail ); 262 mail->Wrapper()->deleteMail( mail );
255 folderView->refreshCurrent(); 263 folderView->refreshCurrent();
256 } 264 }
257} 265}
258void OpieMail::slotDeleteAllMail() 266void OpieMail::slotDeleteAllMail()
259{ 267{
260 268
261 QValueList<RecMailP> t; 269 QValueList<RecMailP> t;
262 if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 270 if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
263 { 271 {
264 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 272 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
265 while ( item ) { 273 while ( item ) {
266 if ( item->isSelected() ) { 274 if ( item->isSelected() ) {
267 t.append( item->data() ); 275 t.append( item->data() );
268 } 276 }
269 item = (MailListViewItem*)item->nextSibling(); 277 item = (MailListViewItem*)item->nextSibling();
270 } 278 }
271 } 279 }
272 else 280 else
273 return; 281 return;
274 if ( t.count() == 0 ) 282 if ( t.count() == 0 )
275 return; 283 return;
276 RecMailP mail = t.first(); 284 RecMailP mail = t.first();
277 mail->Wrapper()->deleteMailList(t); 285 mail->Wrapper()->deleteMailList(t);
278 folderView->refreshCurrent(); 286 folderView->refreshCurrent();
279 287
280 288
281} 289}
282void OpieMail::clearSelection() 290void OpieMail::clearSelection()
283{ 291{
284 mailView->clearSelection(); 292 mailView->clearSelection();
285 293
286} 294}
287 295
288void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 296void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
289{ 297{
290 if (!mailView->currentItem()) return; 298 if (!mailView->currentItem()) return;
291 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 299 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
292 /* just the RIGHT button - or hold on pda */ 300 /* just the RIGHT button - or hold on pda */
293 if (button!=2) {return;} 301 if (button!=2) {return;}
294 if (!item) return; 302 if (!item) return;
295 QPopupMenu *m = new QPopupMenu(0); 303 QPopupMenu *m = new QPopupMenu(0);
296 if (m) 304 if (m)
297 { 305 {
298 if (mailtype==MAILLIB::A_NNTP) { 306 if (mailtype==MAILLIB::A_NNTP) {
299 m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); 307 m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
300// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); 308// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail()));
301 } else { 309 } else {
302 if (folderView->currentisDraft()) { 310 if (folderView->currentisDraft()) {
303 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); 311 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
304 } 312 }
305 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 313 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
306 m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); 314 m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail()));
307 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 315 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
308 m->insertSeparator(); 316 m->insertSeparator();
309 m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); 317 m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail()));
310 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 318 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
311 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); 319 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection()));
312 } 320 }
313 m->setFocus(); 321 m->setFocus();
314 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 322 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
315 delete m; 323 delete m;
316 } 324 }
317} 325}
318 326
319void OpieMail::slotShowFolders( bool show ) 327void OpieMail::slotShowFolders( bool show )
320{ 328{
321 if ( show && folderView->isHidden() ) 329 if ( show && folderView->isHidden() )
322 { 330 {
323 folderView->show(); 331 folderView->show();
324 } 332 }
325 else if ( !show && !folderView->isHidden() ) 333 else if ( !show && !folderView->isHidden() )
326 { 334 {
327 folderView->hide(); 335 folderView->hide();
328 } 336 }
329} 337}
330 338
331void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 339void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
332{ 340{
333 MailListViewItem*item = 0; 341 MailListViewItem*item = 0;
334 mailView->clear(); 342 mailView->clear();
335 343
336 QValueList<RecMailP>::ConstIterator it; 344 QValueList<RecMailP>::ConstIterator it;
337 for (it = list.begin(); it != list.end();++it) 345 for (it = list.begin(); it != list.end();++it)
338 { 346 {
339 item = new MailListViewItem(mailView,item); 347 item = new MailListViewItem(mailView,item);
340 item->storeData((*it)); 348 item->storeData((*it));
341 item->showEntry(); 349 item->showEntry();
342 } 350 }
343} 351}