summaryrefslogtreecommitdiffabout
path: root/kmicromail/opiemail.cpp
authorzautrix <zautrix>2004-09-01 10:23:29 (UTC)
committer zautrix <zautrix>2004-09-01 10:23:29 (UTC)
commit6cefbdc9c8f3f3001373f10715361e2740c45395 (patch) (unidiff)
treecb2c36f57620e698913c27ca4ebe59e4a7c9d46e /kmicromail/opiemail.cpp
parentb9257cb225cd29bab5d96fcdaf557926603ee587 (diff)
downloadkdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.zip
kdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.tar.gz
kdepimpi-6cefbdc9c8f3f3001373f10715361e2740c45395.tar.bz2
Mail fixes and libetpan updated
Diffstat (limited to 'kmicromail/opiemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/opiemail.cpp47
1 files changed, 30 insertions, 17 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index 3fbdcec..251f15a 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,85 +1,85 @@
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 12
13#include <qmessagebox.h> 13#include <qmessagebox.h>
14 14
15#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
16#include <libmailwrapper/smtpwrapper.h> 16#include <libmailwrapper/smtpwrapper.h>
17#include <libmailwrapper/mailtypes.h> 17#include <libmailwrapper/mailtypes.h>
18#include <libmailwrapper/abstractmail.h> 18#include <libmailwrapper/abstractmail.h>
19/* OPIE */ 19/* OPIE */
20//#include <qpe/resource.h> 20//#include <qpe/resource.h>
21#include <qpe/qpeapplication.h> 21//#include <qpe/qpeapplication.h>
22 22
23/* QT */ 23/* QT */
24 24
25using namespace Opie::Core; 25using namespace Opie::Core;
26 26
27OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 27OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
28 : MainWindow( parent, name) //, WStyle_ContextHelp ) 28 : MainWindow( parent, name) //, WStyle_ContextHelp )
29{ 29{
30 settings = new Settings(); 30 settings = new Settings();
31 31
32 folderView->populate( settings->getAccounts() ); 32 folderView->populate( settings->getAccounts() );
33 33
34} 34}
35 35
36OpieMail::~OpieMail() 36OpieMail::~OpieMail()
37{ 37{
38 if (settings) delete settings; 38 if (settings) delete settings;
39} 39}
40 40
41void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 41void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
42{ 42{
43 43
44} 44}
45#include <stdlib.h> 45#include <stdlib.h>
46void OpieMail::message(const QCString &msg, const QByteArray &data) 46void OpieMail::message(const QCString &msg, const QByteArray &data)
47{ 47{
48 // copied from old mail2 48 // copied from old mail2
49 static int ii = 0; 49 static int ii = 0;
50 50
51 // block second call 51 // block second call
52 if ( ii < 2 ) { 52 if ( ii < 2 ) {
53 ++ii; 53 ++ii;
54 if ( ii > 1 ) { 54 if ( ii > 1 ) {
55 qDebug("qcop call blocked "); 55 qDebug("qcop call blocked ");
56 return; 56 return;
57 } 57 }
58 } 58 }
59 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 59 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
60 if (msg == "writeMail(QString,QString)") 60 if (msg == "writeMail(QString,QString)")
61 { 61 {
62 QDataStream stream(data,IO_ReadOnly); 62 QDataStream stream(data,IO_ReadOnly);
63 QString name, email; 63 QString name, email;
64 stream >> name >> email; 64 stream >> name >> email;
65 // removing the whitespaces at beginning and end is needed! 65 // removing the whitespaces at beginning and end is needed!
66 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 66 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
67 } 67 }
68 else if (msg == "newMail()") 68 else if (msg == "newMail()")
69 { 69 {
70 slotComposeMail(); 70 slotComposeMail();
71 } 71 }
72 else if (msg == "newMail(QString)") 72 else if (msg == "newMail(QString)")
73 { 73 {
74 QDataStream stream(data,IO_ReadOnly); 74 QDataStream stream(data,IO_ReadOnly);
75 QString nameemail; 75 QString nameemail;
76 stream >> nameemail; 76 stream >> nameemail;
77 // the format is 77 // the format is
78 // NAME <EMAIL>:SUBJECT 78 // NAME <EMAIL>:SUBJECT
79 //qDebug("message %s ", nameemail.latin1()); 79 //qDebug("message %s ", nameemail.latin1());
80 80
81 slotwriteMail2( nameemail ); 81 slotwriteMail2( nameemail );
82 } 82 }
83} 83}
84void OpieMail::slotwriteMail2(const QString& namemail ) 84void OpieMail::slotwriteMail2(const QString& namemail )
85{ 85{
@@ -176,233 +176,246 @@ void OpieMail::slotSendQueued()
176 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 176 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
177 } 177 }
178 delete wrap; 178 delete wrap;
179 } 179 }
180} 180}
181 181
182void OpieMail::slotSearchMails() 182void OpieMail::slotSearchMails()
183{ 183{
184 qDebug("OpieMail::slotSearchMails():not implemented "); 184 qDebug("OpieMail::slotSearchMails():not implemented ");
185} 185}
186 186
187void OpieMail::slotEditSettings() 187void OpieMail::slotEditSettings()
188{ 188{
189 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 189 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
190 settingsDialog.showMaximized(); 190 settingsDialog.showMaximized();
191 settingsDialog.exec(); 191 settingsDialog.exec();
192} 192}
193 193
194void OpieMail::slotEditAccounts() 194void OpieMail::slotEditAccounts()
195{ 195{
196 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 196 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
197 eaDialog.slotAdjustColumns(); 197 eaDialog.slotAdjustColumns();
198 eaDialog.showMaximized(); 198 eaDialog.showMaximized();
199 eaDialog.exec(); 199 eaDialog.exec();
200 if ( settings ) delete settings; 200 if ( settings ) delete settings;
201 settings = new Settings(); 201 settings = new Settings();
202 202
203 folderView->populate( settings->getAccounts() ); 203 folderView->populate( settings->getAccounts() );
204} 204}
205 205
206void OpieMail::displayMail() 206void OpieMail::displayMail()
207{ 207{
208 QListViewItem*item = mailView->currentItem(); 208 QListViewItem*item = mailView->currentItem();
209 if (!item) return; 209 if (!item) return;
210 RecMailP mail = ((MailListViewItem*)item)->data(); 210 RecMailP mail = ((MailListViewItem*)item)->data();
211 RecBodyP body = folderView->fetchBody(mail); 211 RecBodyP body = folderView->fetchBody(mail);
212 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); 212 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
213 readMail.setBody( body ); 213 readMail.setBody( body );
214 readMail.setMail( mail ); 214 readMail.setMail( mail );
215 readMail.showMaximized(); 215 readMail.showMaximized();
216 readMail.exec(); 216 readMail.exec();
217 217
218 if ( readMail.deleted ) 218 if ( readMail.deleted )
219 { 219 {
220 folderView->refreshCurrent(); 220 folderView->refreshCurrent();
221 } 221 }
222 else 222 else
223 { 223 {
224 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); 224 ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() );
225 } 225 }
226} 226}
227 227
228void OpieMail::slotDeleteMail() 228void OpieMail::slotDeleteMail()
229{ 229{
230 if (!mailView->currentItem()) return; 230 if (!mailView->currentItem()) return;
231 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 231 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
232 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 ) 232 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 )
233 { 233 {
234 mail->Wrapper()->deleteMail( mail ); 234 mail->Wrapper()->deleteMail( mail );
235 folderView->refreshCurrent(); 235 folderView->refreshCurrent();
236 } 236 }
237} 237}
238void OpieMail::slotDeleteAllMail() 238void OpieMail::slotDeleteAllMail()
239{ 239{
240 if (!mailView->currentItem()) return; 240
241 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 241 QValueList<RecMailP> t;
242 if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 242 if ( QMessageBox::warning(this, tr("Delete All Mails"), tr("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
243 { 243 {
244 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 244 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
245 while ( item ) { 245 while ( item ) {
246 if ( item->isSelected() ) { 246 if ( item->isSelected() ) {
247 RecMailP mail = item->data(); 247 t.append( item->data() );
248 mail->Wrapper()->deleteMail( mail ); 248 }
249 item = (MailListViewItem*)item->nextSibling();
249 } 250 }
250 item = (MailListViewItem*)item->nextSibling();
251 } 251 }
252 folderView->refreshCurrent(); 252 else
253 } 253 return;
254 if ( t.count() == 0 )
255 return;
256 RecMailP mail = t.first();
257 mail->Wrapper()->deleteMailList(t);
258 folderView->refreshCurrent();
259
260
254} 261}
255void OpieMail::clearSelection() 262void OpieMail::clearSelection()
256{ 263{
257 mailView->clearSelection(); 264 mailView->clearSelection();
258 265
259} 266}
260 267
261void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 268void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
262{ 269{
263 if (!mailView->currentItem()) return; 270 if (!mailView->currentItem()) return;
264 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); 271 MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType();
265 /* just the RIGHT button - or hold on pda */ 272 /* just the RIGHT button - or hold on pda */
266 if (button!=2) {return;} 273 if (button!=2) {return;}
267 if (!item) return; 274 if (!item) return;
268 QPopupMenu *m = new QPopupMenu(0); 275 QPopupMenu *m = new QPopupMenu(0);
269 if (m) 276 if (m)
270 { 277 {
271 if (mailtype==MAILLIB::A_NNTP) { 278 if (mailtype==MAILLIB::A_NNTP) {
272 m->insertItem(tr("Read this posting"),this,SLOT(displayMail())); 279 m->insertItem(tr("Read this posting"),this,SLOT(displayMail()));
273// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail())); 280// m->insertItem(tr("Copy this posting"),this,SLOT(slotMoveCopyMail()));
274 } else { 281 } else {
275 if (folderView->currentisDraft()) { 282 if (folderView->currentisDraft()) {
276 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail())); 283 m->insertItem(tr("Edit this mail"),this,SLOT(reEditMail()));
277 } 284 }
278 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 285 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
279 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); 286 m->insertItem(tr("Move/Copy this mail"),this,SLOT(slotMoveCopyMail()));
280 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 287 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
281 m->insertSeparator(); 288 m->insertSeparator();
282 m->insertItem(tr("Copy/Move all selected mail"),this,SLOT(slotMoveCopyAllMail())); 289 m->insertItem(tr("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail()));
283 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); 290 m->insertItem(tr("Delete all selected mails"),this,SLOT(slotDeleteAllMail()));
284 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection())); 291 m->insertItem(tr("Clear selection"),this,SLOT(clearSelection()));
285 } 292 }
286 m->setFocus(); 293 m->setFocus();
287 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 294 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
288 delete m; 295 delete m;
289 } 296 }
290} 297}
291 298
292void OpieMail::slotShowFolders( bool show ) 299void OpieMail::slotShowFolders( bool show )
293{ 300{
294 if ( show && folderView->isHidden() ) 301 if ( show && folderView->isHidden() )
295 { 302 {
296 folderView->show(); 303 folderView->show();
297 } 304 }
298 else if ( !show && !folderView->isHidden() ) 305 else if ( !show && !folderView->isHidden() )
299 { 306 {
300 folderView->hide(); 307 folderView->hide();
301 } 308 }
302} 309}
303 310
304void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 311void OpieMail::refreshMailView(const QValueList<RecMailP>&list)
305{ 312{
306 MailListViewItem*item = 0; 313 MailListViewItem*item = 0;
307 mailView->clear(); 314 mailView->clear();
308 315
309 QValueList<RecMailP>::ConstIterator it; 316 QValueList<RecMailP>::ConstIterator it;
310 for (it = list.begin(); it != list.end();++it) 317 for (it = list.begin(); it != list.end();++it)
311 { 318 {
312 item = new MailListViewItem(mailView,item); 319 item = new MailListViewItem(mailView,item);
313 item->storeData((*it)); 320 item->storeData((*it));
314 item->showEntry(); 321 item->showEntry();
315 } 322 }
316} 323}
317 324
318void OpieMail::mailLeftClicked( QListViewItem *item ) 325void OpieMail::mailLeftClicked( QListViewItem *item )
319{ 326{
320 mailView->clearSelection(); 327 mailView->clearSelection();
321 /* just LEFT button - or tap with stylus on pda */ 328 /* just LEFT button - or tap with stylus on pda */
322 //if (button!=1) return; 329 //if (button!=1) return;
323 if (!item) return; 330 if (!item) return;
324 if (folderView->currentisDraft()) { 331 if (folderView->currentisDraft()) {
325 reEditMail(); 332 reEditMail();
326 } else { 333 } else {
327 displayMail(); 334 displayMail();
328 } 335 }
329} 336}
330 337
331void OpieMail::slotMoveCopyMail() 338void OpieMail::slotMoveCopyMail()
332{ 339{
333 if (!mailView->currentItem()) return; 340 if (!mailView->currentItem()) return;
334 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 341 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
335 AbstractMail*targetMail = 0; 342 AbstractMail*targetMail = 0;
336 QString targetFolder = ""; 343 QString targetFolder = "";
337 Selectstore sels; 344 Selectstore sels;
338 folderView->setupFolderselect(&sels); 345 folderView->setupFolderselect(&sels);
339 if (!sels.exec()) return; 346 if (!sels.exec()) return;
340 targetMail = sels.currentMail(); 347 targetMail = sels.currentMail();
341 targetFolder = sels.currentFolder(); 348 targetFolder = sels.currentFolder();
342 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 349 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
343 targetFolder.isEmpty()) 350 targetFolder.isEmpty())
344 { 351 {
345 return; 352 return;
346 } 353 }
347 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 354 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
348 { 355 {
349 QMessageBox::critical(0,tr("Error creating new Folder"), 356 QMessageBox::critical(0,tr("Error creating new Folder"),
350 tr("<center>Error while creating<br>new folder - breaking.</center>")); 357 tr("<center>Error while creating<br>new folder - breaking.</center>"));
351 return; 358 return;
352 } 359 }
360 sels.hide();
361 qApp->processEvents();
362 // qDebug("hiding sels ");
353 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 363 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
354 folderView->refreshCurrent(); 364 folderView->refreshCurrent();
355} 365}
356 366
357void OpieMail::slotMoveCopyAllMail() 367void OpieMail::slotMoveCopyAllMail()
358{ 368{
359 369
360 if (!mailView->currentItem()) return; 370 if (!mailView->currentItem()) return;
361 QValueList<RecMailP> t; 371 QValueList<RecMailP> t;
362 if ( QMessageBox::warning(this, tr("Copy/Move all selected mails"), tr("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) 372 // if ( QMessageBox::warning(this, tr("Move/Copy all selected mails"), tr("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
363 { 373 {
364 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 374 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
365 while ( item ) { 375 while ( item ) {
366 if ( item->isSelected() ) { 376 if ( item->isSelected() ) {
367 t.append( item->data() ); 377 t.append( item->data() );
368 } 378 }
369 item = (MailListViewItem*)item->nextSibling(); 379 item = (MailListViewItem*)item->nextSibling();
370 } 380 }
371 } 381 }
372 else 382 // else
373 return; 383 // return;
374 if ( t.count() == 0 ) 384 if ( t.count() == 0 )
375 return; 385 return;
376 RecMailP mail = t.first(); 386 RecMailP mail = t.first();
377 AbstractMail*targetMail = 0; 387 AbstractMail*targetMail = 0;
378 QString targetFolder = ""; 388 QString targetFolder = "";
379 Selectstore sels; 389 Selectstore sels;
380 folderView->setupFolderselect(&sels); 390 folderView->setupFolderselect(&sels);
381 if (!sels.exec()) return; 391 if (!sels.exec()) return;
382 targetMail = sels.currentMail(); 392 targetMail = sels.currentMail();
383 targetFolder = sels.currentFolder(); 393 targetFolder = sels.currentFolder();
384 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 394 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
385 targetFolder.isEmpty()) 395 targetFolder.isEmpty())
386 { 396 {
387 return; 397 return;
388 } 398 }
389 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 399 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
390 { 400 {
391 QMessageBox::critical(0,tr("Error creating new Folder"), 401 QMessageBox::critical(0,tr("Error creating new Folder"),
392 tr("<center>Error while creating<br>new folder - breaking.</center>")); 402 tr("<center>Error while creating<br>new folder - breaking.</center>"));
393 return; 403 return;
394 } 404 }
405 sels.hide();
406 qApp->processEvents();
407 //qDebug("hiding sels ");
395 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); 408 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
396 folderView->refreshCurrent(); 409 folderView->refreshCurrent();
397} 410}
398 411
399void OpieMail::reEditMail() 412void OpieMail::reEditMail()
400{ 413{
401 if (!mailView->currentItem()) return; 414 if (!mailView->currentItem()) return;
402 415
403 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 416 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
404 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); 417 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
405 compose.slotAdjustColumns(); 418 compose.slotAdjustColumns();
406 compose.showMaximized(); 419 compose.showMaximized();
407 compose.exec(); 420 compose.exec();
408} 421}