-rw-r--r-- | kmicromail/opiemail.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index 3aa7905..a32983c 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,293 +1,292 @@ | |||
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 | #include "koprefsdialog.h" |
14 | #include "klocale.h" | 14 | #include "klocale.h" |
15 | 15 | ||
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #include <qtimer.h> | 17 | #include <qtimer.h> |
18 | #include <libkdepim/externalapphandler.h> | 18 | #include <libkdepim/externalapphandler.h> |
19 | #include <libkdepim/kpimglobalprefs.h> | 19 | #include <libkdepim/kpimglobalprefs.h> |
20 | 20 | ||
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <libmailwrapper/smtpwrapper.h> | 22 | #include <libmailwrapper/smtpwrapper.h> |
23 | #include <libmailwrapper/mailtypes.h> | 23 | #include <libmailwrapper/mailtypes.h> |
24 | #include <libmailwrapper/abstractmail.h> | 24 | #include <libmailwrapper/abstractmail.h> |
25 | /* OPIE */ | 25 | /* OPIE */ |
26 | //#include <qpe/resource.h> | 26 | //#include <qpe/resource.h> |
27 | //#include <qpe/qpeapplication.h> | 27 | //#include <qpe/qpeapplication.h> |
28 | 28 | ||
29 | /* QT */ | 29 | /* QT */ |
30 | 30 | ||
31 | //using namespace Opie::Core; | 31 | //using namespace Opie::Core; |
32 | 32 | ||
33 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 33 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
34 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 34 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
35 | { | 35 | { |
36 | settings = new Settings(); | 36 | settings = new Settings(); |
37 | KPimGlobalPrefs::instance()->setGlobalConfig(); | ||
38 | 37 | ||
39 | folderView->populate( settings->getAccounts() ); | 38 | folderView->populate( settings->getAccounts() ); |
40 | 39 | ||
41 | } | 40 | } |
42 | 41 | ||
43 | OpieMail::~OpieMail() | 42 | OpieMail::~OpieMail() |
44 | { | 43 | { |
45 | if (settings) delete settings; | 44 | if (settings) delete settings; |
46 | } | 45 | } |
47 | 46 | ||
48 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 47 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
49 | { | 48 | { |
50 | 49 | ||
51 | } | 50 | } |
52 | #include <stdlib.h> | 51 | #include <stdlib.h> |
53 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 52 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
54 | { | 53 | { |
55 | // copied from old mail2 | 54 | // copied from old mail2 |
56 | static int ii = 0; | 55 | static int ii = 0; |
57 | //qDebug("QCOP CALL ############################# %d ", ii); | 56 | //qDebug("QCOP CALL ############################# %d ", ii); |
58 | //QString mess ( msg ); | 57 | //QString mess ( msg ); |
59 | //qDebug("Message = %s ",mess.latin1()); | 58 | //qDebug("Message = %s ",mess.latin1()); |
60 | ++ii; | 59 | ++ii; |
61 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 60 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
62 | 61 | ||
63 | mPendingEmail = QString::null; | 62 | mPendingEmail = QString::null; |
64 | mPendingName = QString::null; | 63 | mPendingName = QString::null; |
65 | if (msg == "writeMail(QString,QString)") | 64 | if (msg == "writeMail(QString,QString)") |
66 | { | 65 | { |
67 | //qDebug("writeMail(QString,QString) "); | 66 | //qDebug("writeMail(QString,QString) "); |
68 | QDataStream stream(data,IO_ReadOnly); | 67 | QDataStream stream(data,IO_ReadOnly); |
69 | stream >> mPendingName >> mPendingEmail; | 68 | stream >> mPendingName >> mPendingEmail; |
70 | // removing the whitespaces at beginning and end is needed! | 69 | // removing the whitespaces at beginning and end is needed! |
71 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 70 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
72 | } | 71 | } |
73 | else if (msg == "newMail()") | 72 | else if (msg == "newMail()") |
74 | { | 73 | { |
75 | //qDebug("slotComposeMail() "); | 74 | //qDebug("slotComposeMail() "); |
76 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 75 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
77 | // and a QCOP call does not like a processevents in his execution | 76 | // and a QCOP call does not like a processevents in his execution |
78 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 77 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
79 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 78 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
80 | // slotComposeMail(); | 79 | // slotComposeMail(); |
81 | } | 80 | } |
82 | else if (msg == "newMail(QString)") | 81 | else if (msg == "newMail(QString)") |
83 | { | 82 | { |
84 | //qDebug(" newMail(QString)"); | 83 | //qDebug(" newMail(QString)"); |
85 | QDataStream stream(data,IO_ReadOnly); | 84 | QDataStream stream(data,IO_ReadOnly); |
86 | stream >> mPendingName; | 85 | stream >> mPendingName; |
87 | // the format is | 86 | // the format is |
88 | // NAME <EMAIL>:SUBJECT | 87 | // NAME <EMAIL>:SUBJECT |
89 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 88 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
90 | } else { | 89 | } else { |
91 | mPendingData = data; | 90 | mPendingData = data; |
92 | mPendingMessage = msg; | 91 | mPendingMessage = msg; |
93 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); | 92 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); |
94 | } | 93 | } |
95 | 94 | ||
96 | //qDebug("END OpieMail::message "); | 95 | //qDebug("END OpieMail::message "); |
97 | } | 96 | } |
98 | void OpieMail::slotExtAppHandler() | 97 | void OpieMail::slotExtAppHandler() |
99 | { | 98 | { |
100 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); | 99 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); |
101 | } | 100 | } |
102 | void OpieMail::slotwriteMail2(const QString& namemail ) | 101 | void OpieMail::slotwriteMail2(const QString& namemail ) |
103 | { | 102 | { |
104 | //qDebug("OpieMail::slotwriteMail2 "); | 103 | //qDebug("OpieMail::slotwriteMail2 "); |
105 | //qApp->processEvents(); | 104 | //qApp->processEvents(); |
106 | ComposeMail compose( settings, this, 0, true ); | 105 | ComposeMail compose( settings, this, 0, true ); |
107 | if ( !namemail.isEmpty() ) { | 106 | if ( !namemail.isEmpty() ) { |
108 | QString to = namemail; | 107 | QString to = namemail; |
109 | if ( namemail.find( " <") > 1 ) { | 108 | if ( namemail.find( " <") > 1 ) { |
110 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 109 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
111 | } else | 110 | } else |
112 | if ( namemail.find( "<") > 1 ) { | 111 | if ( namemail.find( "<") > 1 ) { |
113 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 112 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
114 | } | 113 | } |
115 | int sub = to.find( ">:"); | 114 | int sub = to.find( ">:"); |
116 | if ( sub > 0 ) { | 115 | if ( sub > 0 ) { |
117 | compose.setTo( to.left(sub+1) ); | 116 | compose.setTo( to.left(sub+1) ); |
118 | compose.setSubject( to.mid(sub+2) ); | 117 | compose.setSubject( to.mid(sub+2) ); |
119 | } else | 118 | } else |
120 | compose.setTo( to ); | 119 | compose.setTo( to ); |
121 | } | 120 | } |
122 | compose.slotAdjustColumns(); | 121 | compose.slotAdjustColumns(); |
123 | compose.showMaximized(); | 122 | compose.showMaximized(); |
124 | compose.exec(); | 123 | compose.exec(); |
125 | raise(); | 124 | raise(); |
126 | //qDebug("retttich "); | 125 | //qDebug("retttich "); |
127 | } | 126 | } |
128 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 127 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
129 | { | 128 | { |
130 | // qDebug("OpieMail::slotwriteMail "); | 129 | // qDebug("OpieMail::slotwriteMail "); |
131 | ComposeMail compose( settings, this, 0, true ); | 130 | ComposeMail compose( settings, this, 0, true ); |
132 | if (!email.isEmpty()) | 131 | if (!email.isEmpty()) |
133 | { | 132 | { |
134 | if (!name.isEmpty()) | 133 | if (!name.isEmpty()) |
135 | { | 134 | { |
136 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 135 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
137 | } | 136 | } |
138 | else | 137 | else |
139 | { | 138 | { |
140 | compose.setTo(email); | 139 | compose.setTo(email); |
141 | } | 140 | } |
142 | } | 141 | } |
143 | compose.slotAdjustColumns(); | 142 | compose.slotAdjustColumns(); |
144 | compose.showMaximized(); | 143 | compose.showMaximized(); |
145 | compose.exec(); | 144 | compose.exec(); |
146 | raise(); | 145 | raise(); |
147 | } | 146 | } |
148 | 147 | ||
149 | void OpieMail::slotComposeMail() | 148 | void OpieMail::slotComposeMail() |
150 | { | 149 | { |
151 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 150 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
152 | slotwriteMail2( QString () ); | 151 | slotwriteMail2( QString () ); |
153 | else { | 152 | else { |
154 | if ( mPendingEmail == QString::null ) | 153 | if ( mPendingEmail == QString::null ) |
155 | slotwriteMail2( mPendingName ); | 154 | slotwriteMail2( mPendingName ); |
156 | else | 155 | else |
157 | slotwriteMail( mPendingName, mPendingEmail ); | 156 | slotwriteMail( mPendingName, mPendingEmail ); |
158 | } | 157 | } |
159 | //slotwriteMail(0l,0l); | 158 | //slotwriteMail(0l,0l); |
160 | } | 159 | } |
161 | 160 | ||
162 | void OpieMail::slotSendQueued() | 161 | void OpieMail::slotSendQueued() |
163 | { | 162 | { |
164 | SMTPaccount *smtp = 0; | 163 | SMTPaccount *smtp = 0; |
165 | 164 | ||
166 | QList<Account> list = settings->getAccounts(); | 165 | QList<Account> list = settings->getAccounts(); |
167 | QList<SMTPaccount> smtpList; | 166 | QList<SMTPaccount> smtpList; |
168 | smtpList.setAutoDelete(false); | 167 | smtpList.setAutoDelete(false); |
169 | Account *it; | 168 | Account *it; |
170 | for ( it = list.first(); it; it = list.next() ) | 169 | for ( it = list.first(); it; it = list.next() ) |
171 | { | 170 | { |
172 | if ( it->getType() == MAILLIB::A_SMTP ) | 171 | if ( it->getType() == MAILLIB::A_SMTP ) |
173 | { | 172 | { |
174 | smtp = static_cast<SMTPaccount *>(it); | 173 | smtp = static_cast<SMTPaccount *>(it); |
175 | smtpList.append(smtp); | 174 | smtpList.append(smtp); |
176 | } | 175 | } |
177 | } | 176 | } |
178 | if (smtpList.count()==0) | 177 | if (smtpList.count()==0) |
179 | { | 178 | { |
180 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); | 179 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); |
181 | return; | 180 | return; |
182 | } | 181 | } |
183 | if (smtpList.count()==1) | 182 | if (smtpList.count()==1) |
184 | { | 183 | { |
185 | smtp = smtpList.at(0); | 184 | smtp = smtpList.at(0); |
186 | } | 185 | } |
187 | else | 186 | else |
188 | { | 187 | { |
189 | smtp = 0; | 188 | smtp = 0; |
190 | selectsmtp selsmtp; | 189 | selectsmtp selsmtp; |
191 | selsmtp.setSelectionlist(&smtpList); | 190 | selsmtp.setSelectionlist(&smtpList); |
192 | selsmtp.showMaximized(); | 191 | selsmtp.showMaximized(); |
193 | if ( selsmtp.exec() == QDialog::Accepted ) | 192 | if ( selsmtp.exec() == QDialog::Accepted ) |
194 | { | 193 | { |
195 | smtp = selsmtp.selected_smtp(); | 194 | smtp = selsmtp.selected_smtp(); |
196 | } | 195 | } |
197 | } | 196 | } |
198 | if (smtp) | 197 | if (smtp) |
199 | { | 198 | { |
200 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 199 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
201 | if ( wrap->flushOutbox() ) | 200 | if ( wrap->flushOutbox() ) |
202 | { | 201 | { |
203 | QMessageBox::information(0,i18n("Info"),i18n("Mail queue flushed")); | 202 | QMessageBox::information(0,i18n("Info"),i18n("Mail queue flushed")); |
204 | } | 203 | } |
205 | delete wrap; | 204 | delete wrap; |
206 | } | 205 | } |
207 | } | 206 | } |
208 | 207 | ||
209 | void OpieMail::slotSearchMails() | 208 | void OpieMail::slotSearchMails() |
210 | { | 209 | { |
211 | qDebug("OpieMail::slotSearchMails():not implemented "); | 210 | qDebug("OpieMail::slotSearchMails():not implemented "); |
212 | } | 211 | } |
213 | 212 | ||
214 | void OpieMail::slotEditSettings() | 213 | void OpieMail::slotEditSettings() |
215 | { | 214 | { |
216 | #if 0 | 215 | #if 0 |
217 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); | 216 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); |
218 | settingsDialog.showMaximized(); | 217 | settingsDialog.showMaximized(); |
219 | settingsDialog.exec(); | 218 | settingsDialog.exec(); |
220 | #endif | 219 | #endif |
221 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 220 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
222 | settingsDialog.showMaximized(); | 221 | settingsDialog.showMaximized(); |
223 | settingsDialog.exec(); | 222 | settingsDialog.exec(); |
224 | } | 223 | } |
225 | 224 | ||
226 | void OpieMail::slotEditAccounts() | 225 | void OpieMail::slotEditAccounts() |
227 | { | 226 | { |
228 | EditAccounts eaDialog( settings, this, 0, true ); | 227 | EditAccounts eaDialog( settings, this, 0, true ); |
229 | eaDialog.slotAdjustColumns(); | 228 | eaDialog.slotAdjustColumns(); |
230 | eaDialog.showMaximized(); | 229 | eaDialog.showMaximized(); |
231 | eaDialog.exec(); | 230 | eaDialog.exec(); |
232 | if ( settings ) delete settings; | 231 | if ( settings ) delete settings; |
233 | settings = new Settings(); | 232 | settings = new Settings(); |
234 | 233 | ||
235 | folderView->populate( settings->getAccounts() ); | 234 | folderView->populate( settings->getAccounts() ); |
236 | } | 235 | } |
237 | 236 | ||
238 | void OpieMail::displayMail() | 237 | void OpieMail::displayMail() |
239 | { | 238 | { |
240 | QListViewItem*item = mailView->currentItem(); | 239 | QListViewItem*item = mailView->currentItem(); |
241 | if (!item) return; | 240 | if (!item) return; |
242 | RecMailP mail = ((MailListViewItem*)item)->data(); | 241 | RecMailP mail = ((MailListViewItem*)item)->data(); |
243 | RecBodyP body = folderView->fetchBody(mail); | 242 | RecBodyP body = folderView->fetchBody(mail); |
244 | ViewMail readMail( this,"", Qt::WType_Modal ); | 243 | ViewMail readMail( this,"", Qt::WType_Modal ); |
245 | readMail.setBody( body ); | 244 | readMail.setBody( body ); |
246 | readMail.setMail( mail ); | 245 | readMail.setMail( mail ); |
247 | readMail.showMaximized(); | 246 | readMail.showMaximized(); |
248 | readMail.exec(); | 247 | readMail.exec(); |
249 | 248 | ||
250 | if ( readMail.deleted ) | 249 | if ( readMail.deleted ) |
251 | { | 250 | { |
252 | folderView->refreshCurrent(); | 251 | folderView->refreshCurrent(); |
253 | } | 252 | } |
254 | else | 253 | else |
255 | { | 254 | { |
256 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 255 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
257 | } | 256 | } |
258 | } | 257 | } |
259 | void OpieMail::slotGetAllMail() | 258 | void OpieMail::slotGetAllMail() |
260 | { | 259 | { |
261 | QListViewItem * item = folderView->firstChild(); | 260 | QListViewItem * item = folderView->firstChild(); |
262 | while ( item ){ | 261 | while ( item ){ |
263 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 262 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
264 | item = item->nextSibling (); | 263 | item = item->nextSibling (); |
265 | } | 264 | } |
266 | } | 265 | } |
267 | void OpieMail::slotGetMail() | 266 | void OpieMail::slotGetMail() |
268 | { | 267 | { |
269 | QListViewItem * item = folderView->currentItem(); | 268 | QListViewItem * item = folderView->currentItem(); |
270 | if ( ! item ) return; | 269 | if ( ! item ) return; |
271 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 270 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
272 | } | 271 | } |
273 | void OpieMail::slotDeleteMail() | 272 | void OpieMail::slotDeleteMail() |
274 | { | 273 | { |
275 | if (!mailView->currentItem()) return; | 274 | if (!mailView->currentItem()) return; |
276 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 275 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
277 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 276 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
278 | { | 277 | { |
279 | mail->Wrapper()->deleteMail( mail ); | 278 | mail->Wrapper()->deleteMail( mail ); |
280 | folderView->refreshCurrent(); | 279 | folderView->refreshCurrent(); |
281 | } | 280 | } |
282 | } | 281 | } |
283 | void OpieMail::slotDeleteAllMail() | 282 | void OpieMail::slotDeleteAllMail() |
284 | { | 283 | { |
285 | 284 | ||
286 | QValueList<RecMailP> t; | 285 | QValueList<RecMailP> t; |
287 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 286 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
288 | { | 287 | { |
289 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 288 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
290 | while ( item ) { | 289 | while ( item ) { |
291 | if ( item->isSelected() ) { | 290 | if ( item->isSelected() ) { |
292 | t.append( item->data() ); | 291 | t.append( item->data() ); |
293 | } | 292 | } |