-rw-r--r-- | kmicromail/opiemail.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index a1c5645..0c581c0 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,180 +1,180 @@ | |||
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 | #include <libkdepim/externalapphandler.h> | 14 | #include <libkdepim/externalapphandler.h> |
15 | 15 | ||
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | #include <libmailwrapper/smtpwrapper.h> | 17 | #include <libmailwrapper/smtpwrapper.h> |
18 | #include <libmailwrapper/mailtypes.h> | 18 | #include <libmailwrapper/mailtypes.h> |
19 | #include <libmailwrapper/abstractmail.h> | 19 | #include <libmailwrapper/abstractmail.h> |
20 | /* OPIE */ | 20 | /* OPIE */ |
21 | //#include <qpe/resource.h> | 21 | //#include <qpe/resource.h> |
22 | //#include <qpe/qpeapplication.h> | 22 | //#include <qpe/qpeapplication.h> |
23 | 23 | ||
24 | /* QT */ | 24 | /* QT */ |
25 | 25 | ||
26 | using namespace Opie::Core; | 26 | //using namespace Opie::Core; |
27 | 27 | ||
28 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) | 28 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
29 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 29 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
30 | { | 30 | { |
31 | settings = new Settings(); | 31 | settings = new Settings(); |
32 | 32 | ||
33 | folderView->populate( settings->getAccounts() ); | 33 | folderView->populate( settings->getAccounts() ); |
34 | 34 | ||
35 | } | 35 | } |
36 | 36 | ||
37 | OpieMail::~OpieMail() | 37 | OpieMail::~OpieMail() |
38 | { | 38 | { |
39 | if (settings) delete settings; | 39 | if (settings) delete settings; |
40 | } | 40 | } |
41 | 41 | ||
42 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 42 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
43 | { | 43 | { |
44 | 44 | ||
45 | } | 45 | } |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 47 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
48 | { | 48 | { |
49 | // copied from old mail2 | 49 | // copied from old mail2 |
50 | static int ii = 0; | 50 | static int ii = 0; |
51 | qDebug("call ############################# %d ", ii); | 51 | qDebug("call ############################# %d ", ii); |
52 | // block second call | 52 | // block second call |
53 | if ( ii < 2 ) { | 53 | if ( ii < 2 ) { |
54 | //++ii; | 54 | //++ii; |
55 | if ( ii > 1 ) { | 55 | if ( ii > 1 ) { |
56 | qDebug("qcop call blocked "); | 56 | qDebug("qcop call blocked "); |
57 | //return; | 57 | //return; |
58 | } | 58 | } |
59 | } | 59 | } |
60 | ++ii; | 60 | ++ii; |
61 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 61 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
62 | if (msg == "writeMail(QString,QString)") | 62 | if (msg == "writeMail(QString,QString)") |
63 | { | 63 | { |
64 | QDataStream stream(data,IO_ReadOnly); | 64 | QDataStream stream(data,IO_ReadOnly); |
65 | QString name, email; | 65 | QString name, email; |
66 | stream >> name >> email; | 66 | stream >> name >> email; |
67 | // removing the whitespaces at beginning and end is needed! | 67 | // removing the whitespaces at beginning and end is needed! |
68 | slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); | 68 | slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); |
69 | } | 69 | } |
70 | else if (msg == "newMail()") | 70 | else if (msg == "newMail()") |
71 | { | 71 | { |
72 | slotComposeMail(); | 72 | slotComposeMail(); |
73 | } | 73 | } |
74 | else if (msg == "newMail(QString)") | 74 | else if (msg == "newMail(QString)") |
75 | { | 75 | { |
76 | QDataStream stream(data,IO_ReadOnly); | 76 | QDataStream stream(data,IO_ReadOnly); |
77 | QString nameemail; | 77 | QString nameemail; |
78 | stream >> nameemail; | 78 | stream >> nameemail; |
79 | // the format is | 79 | // the format is |
80 | // NAME <EMAIL>:SUBJECT | 80 | // NAME <EMAIL>:SUBJECT |
81 | //qDebug("message %s ", nameemail.latin1()); | 81 | //qDebug("message %s ", nameemail.latin1()); |
82 | 82 | ||
83 | slotwriteMail2( nameemail ); | 83 | slotwriteMail2( nameemail ); |
84 | } else | 84 | } else |
85 | ExternalAppHandler::instance()->appMessage ( msg, data); | 85 | ExternalAppHandler::instance()->appMessage ( msg, data); |
86 | } | 86 | } |
87 | void OpieMail::slotwriteMail2(const QString& namemail ) | 87 | void OpieMail::slotwriteMail2(const QString& namemail ) |
88 | { | 88 | { |
89 | // qDebug("OpieMail::slotwriteMail2 "); | 89 | // qDebug("OpieMail::slotwriteMail2 "); |
90 | qApp->processEvents(); | 90 | qApp->processEvents(); |
91 | ComposeMail compose( settings, this, 0, true ); | 91 | ComposeMail compose( settings, this, 0, true ); |
92 | if ( !namemail.isEmpty() ) { | 92 | if ( !namemail.isEmpty() ) { |
93 | QString to = namemail; | 93 | QString to = namemail; |
94 | if ( namemail.find( " <") > 1 ) { | 94 | if ( namemail.find( " <") > 1 ) { |
95 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 95 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
96 | } else | 96 | } else |
97 | if ( namemail.find( "<") > 1 ) { | 97 | if ( namemail.find( "<") > 1 ) { |
98 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 98 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
99 | } | 99 | } |
100 | int sub = to.find( ">:"); | 100 | int sub = to.find( ">:"); |
101 | if ( sub > 0 ) { | 101 | if ( sub > 0 ) { |
102 | compose.setTo( to.left(sub+1) ); | 102 | compose.setTo( to.left(sub+1) ); |
103 | compose.setSubject( to.mid(sub+2) ); | 103 | compose.setSubject( to.mid(sub+2) ); |
104 | } else | 104 | } else |
105 | compose.setTo( to ); | 105 | compose.setTo( to ); |
106 | } | 106 | } |
107 | compose.slotAdjustColumns(); | 107 | compose.slotAdjustColumns(); |
108 | compose.showMaximized(); | 108 | compose.showMaximized(); |
109 | compose.exec(); | 109 | compose.exec(); |
110 | raise(); | 110 | raise(); |
111 | //qDebug("retttich "); | 111 | //qDebug("retttich "); |
112 | } | 112 | } |
113 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 113 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
114 | { | 114 | { |
115 | // qDebug("OpieMail::slotwriteMail "); | 115 | // qDebug("OpieMail::slotwriteMail "); |
116 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); | 116 | ComposeMail compose( settings, this, 0, true ); |
117 | if (!email.isEmpty()) | 117 | if (!email.isEmpty()) |
118 | { | 118 | { |
119 | if (!name.isEmpty()) | 119 | if (!name.isEmpty()) |
120 | { | 120 | { |
121 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 121 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
122 | } | 122 | } |
123 | else | 123 | else |
124 | { | 124 | { |
125 | compose.setTo(email); | 125 | compose.setTo(email); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | compose.slotAdjustColumns(); | 128 | compose.slotAdjustColumns(); |
129 | compose.showMaximized(); | 129 | compose.showMaximized(); |
130 | compose.exec(); | 130 | compose.exec(); |
131 | } | 131 | } |
132 | 132 | ||
133 | void OpieMail::slotComposeMail() | 133 | void OpieMail::slotComposeMail() |
134 | { | 134 | { |
135 | slotwriteMail2( QString () ); | 135 | slotwriteMail2( QString () ); |
136 | //slotwriteMail(0l,0l); | 136 | //slotwriteMail(0l,0l); |
137 | } | 137 | } |
138 | 138 | ||
139 | void OpieMail::slotSendQueued() | 139 | void OpieMail::slotSendQueued() |
140 | { | 140 | { |
141 | SMTPaccount *smtp = 0; | 141 | SMTPaccount *smtp = 0; |
142 | 142 | ||
143 | QList<Account> list = settings->getAccounts(); | 143 | QList<Account> list = settings->getAccounts(); |
144 | QList<SMTPaccount> smtpList; | 144 | QList<SMTPaccount> smtpList; |
145 | smtpList.setAutoDelete(false); | 145 | smtpList.setAutoDelete(false); |
146 | Account *it; | 146 | Account *it; |
147 | for ( it = list.first(); it; it = list.next() ) | 147 | for ( it = list.first(); it; it = list.next() ) |
148 | { | 148 | { |
149 | if ( it->getType() == MAILLIB::A_SMTP ) | 149 | if ( it->getType() == MAILLIB::A_SMTP ) |
150 | { | 150 | { |
151 | smtp = static_cast<SMTPaccount *>(it); | 151 | smtp = static_cast<SMTPaccount *>(it); |
152 | smtpList.append(smtp); | 152 | smtpList.append(smtp); |
153 | } | 153 | } |
154 | } | 154 | } |
155 | if (smtpList.count()==0) | 155 | if (smtpList.count()==0) |
156 | { | 156 | { |
157 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n")); | 157 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first!\n")); |
158 | return; | 158 | return; |
159 | } | 159 | } |
160 | if (smtpList.count()==1) | 160 | if (smtpList.count()==1) |
161 | { | 161 | { |
162 | smtp = smtpList.at(0); | 162 | smtp = smtpList.at(0); |
163 | } | 163 | } |
164 | else | 164 | else |
165 | { | 165 | { |
166 | smtp = 0; | 166 | smtp = 0; |
167 | selectsmtp selsmtp; | 167 | selectsmtp selsmtp; |
168 | selsmtp.setSelectionlist(&smtpList); | 168 | selsmtp.setSelectionlist(&smtpList); |
169 | selsmtp.showMaximized(); | 169 | selsmtp.showMaximized(); |
170 | if ( selsmtp.exec() == QDialog::Accepted ) | 170 | if ( selsmtp.exec() == QDialog::Accepted ) |
171 | { | 171 | { |
172 | smtp = selsmtp.selected_smtp(); | 172 | smtp = selsmtp.selected_smtp(); |
173 | } | 173 | } |
174 | } | 174 | } |
175 | if (smtp) | 175 | if (smtp) |
176 | { | 176 | { |
177 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 177 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
178 | if ( wrap->flushOutbox() ) | 178 | if ( wrap->flushOutbox() ) |
179 | { | 179 | { |
180 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); | 180 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); |
@@ -356,70 +356,70 @@ void OpieMail::slotMoveCopyMail() | |||
356 | return; | 356 | return; |
357 | } | 357 | } |
358 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 358 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
359 | { | 359 | { |
360 | QMessageBox::critical(0,tr("Error creating new Folder"), | 360 | QMessageBox::critical(0,tr("Error creating new Folder"), |
361 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 361 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | sels.hide(); | 364 | sels.hide(); |
365 | qApp->processEvents(); | 365 | qApp->processEvents(); |
366 | // qDebug("hiding sels "); | 366 | // qDebug("hiding sels "); |
367 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | 367 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); |
368 | folderView->refreshCurrent(); | 368 | folderView->refreshCurrent(); |
369 | } | 369 | } |
370 | 370 | ||
371 | void OpieMail::slotMoveCopyAllMail() | 371 | void OpieMail::slotMoveCopyAllMail() |
372 | { | 372 | { |
373 | 373 | ||
374 | if (!mailView->currentItem()) return; | 374 | if (!mailView->currentItem()) return; |
375 | QValueList<RecMailP> t; | 375 | QValueList<RecMailP> t; |
376 | // 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 ) | 376 | // 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 ) |
377 | { | 377 | { |
378 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 378 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
379 | while ( item ) { | 379 | while ( item ) { |
380 | if ( item->isSelected() ) { | 380 | if ( item->isSelected() ) { |
381 | t.append( item->data() ); | 381 | t.append( item->data() ); |
382 | } | 382 | } |
383 | item = (MailListViewItem*)item->nextSibling(); | 383 | item = (MailListViewItem*)item->nextSibling(); |
384 | } | 384 | } |
385 | } | 385 | } |
386 | // else | 386 | // else |
387 | // return; | 387 | // return; |
388 | if ( t.count() == 0 ) | 388 | if ( t.count() == 0 ) |
389 | return; | 389 | return; |
390 | RecMailP mail = t.first(); | 390 | RecMailP mail = t.first(); |
391 | AbstractMail*targetMail = 0; | 391 | AbstractMail*targetMail = 0; |
392 | QString targetFolder = ""; | 392 | QString targetFolder = ""; |
393 | Selectstore sels; | 393 | Selectstore sels; |
394 | folderView->setupFolderselect(&sels); | 394 | folderView->setupFolderselect(&sels); |
395 | if (!sels.exec()) return; | 395 | if (!sels.exec()) return; |
396 | targetMail = sels.currentMail(); | 396 | targetMail = sels.currentMail(); |
397 | targetFolder = sels.currentFolder(); | 397 | targetFolder = sels.currentFolder(); |
398 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 398 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
399 | targetFolder.isEmpty()) | 399 | targetFolder.isEmpty()) |
400 | { | 400 | { |
401 | return; | 401 | return; |
402 | } | 402 | } |
403 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 403 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
404 | { | 404 | { |
405 | QMessageBox::critical(0,tr("Error creating new Folder"), | 405 | QMessageBox::critical(0,tr("Error creating new Folder"), |
406 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 406 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
407 | return; | 407 | return; |
408 | } | 408 | } |
409 | sels.hide(); | 409 | sels.hide(); |
410 | qApp->processEvents(); | 410 | qApp->processEvents(); |
411 | //qDebug("hiding sels "); | 411 | //qDebug("hiding sels "); |
412 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); | 412 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); |
413 | folderView->refreshCurrent(); | 413 | folderView->refreshCurrent(); |
414 | } | 414 | } |
415 | 415 | ||
416 | void OpieMail::reEditMail() | 416 | void OpieMail::reEditMail() |
417 | { | 417 | { |
418 | if (!mailView->currentItem()) return; | 418 | if (!mailView->currentItem()) return; |
419 | 419 | ||
420 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); | 420 | ComposeMail compose( settings, this, 0, true ); |
421 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); | 421 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); |
422 | compose.slotAdjustColumns(); | 422 | compose.slotAdjustColumns(); |
423 | compose.showMaximized(); | 423 | compose.showMaximized(); |
424 | compose.exec(); | 424 | compose.exec(); |
425 | } | 425 | } |