-rw-r--r-- | kmicromail/opiemail.cpp | 9 | ||||
-rw-r--r-- | kmicromail/opiemail.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index 8ac3451..e296d9c 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,681 +1,690 @@ | |||
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 | 4 | ||
5 | #define protected public | 5 | #define protected public |
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #undef protected | 7 | #undef protected |
8 | #include "koprefsdialog.h" | 8 | #include "koprefsdialog.h" |
9 | #include <kapplication.h> | 9 | #include <kapplication.h> |
10 | #include <libkdepim/externalapphandler.h> | 10 | #include <libkdepim/externalapphandler.h> |
11 | #include <libkdepim/kpimglobalprefs.h> | 11 | #include <libkdepim/kpimglobalprefs.h> |
12 | #ifdef MINIKDE_KDIALOG_H | 12 | #ifdef MINIKDE_KDIALOG_H |
13 | #undef MINIKDE_KDIALOG_H | 13 | #undef MINIKDE_KDIALOG_H |
14 | #endif | 14 | #endif |
15 | #include "settingsdialog.h" | 15 | #include "settingsdialog.h" |
16 | #include "opiemail.h" | 16 | #include "opiemail.h" |
17 | #include "editaccounts.h" | 17 | #include "editaccounts.h" |
18 | #include "composemail.h" | 18 | #include "composemail.h" |
19 | #include "mailistviewitem.h" | 19 | #include "mailistviewitem.h" |
20 | #include "viewmail.h" | 20 | #include "viewmail.h" |
21 | #include "selectstore.h" | 21 | #include "selectstore.h" |
22 | #include "selectsmtp.h" | 22 | #include "selectsmtp.h" |
23 | #include "accountitem.h" | 23 | #include "accountitem.h" |
24 | #include "accountview.h" | 24 | #include "accountview.h" |
25 | #include "klocale.h" | 25 | #include "klocale.h" |
26 | 26 | ||
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qcursor.h> | 29 | #include <qcursor.h> |
30 | #include <qtextbrowser.h> | 30 | #include <qtextbrowser.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
33 | 33 | ||
34 | #ifdef DESKTOP_VERSION | 34 | #ifdef DESKTOP_VERSION |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #else | 36 | #else |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #endif | 38 | #endif |
39 | #include <libmailwrapper/smtpwrapper.h> | 39 | #include <libmailwrapper/smtpwrapper.h> |
40 | #include <libmailwrapper/mailtypes.h> | 40 | #include <libmailwrapper/mailtypes.h> |
41 | #include <libmailwrapper/abstractmail.h> | 41 | #include <libmailwrapper/abstractmail.h> |
42 | #include "koprefs.h" | 42 | #include "koprefs.h" |
43 | 43 | ||
44 | //using namespace Opie::Core; | 44 | //using namespace Opie::Core; |
45 | 45 | ||
46 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 46 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
47 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 47 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
48 | { | 48 | { |
49 | mCurrentComposer = 0; | 49 | mCurrentComposer = 0; |
50 | settings = new Settings(); | 50 | settings = new Settings(); |
51 | tb = 0; | 51 | tb = 0; |
52 | setIcon(SmallIcon( "kmicromail" ) ); | 52 | setIcon(SmallIcon( "kmicromail" ) ); |
53 | folderView->populate( settings->getAccounts() ); | 53 | folderView->populate( settings->getAccounts() ); |
54 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 54 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
55 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 55 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
56 | folderView->setFocus(); | 56 | folderView->setFocus(); |
57 | } | 57 | } |
58 | 58 | ||
59 | OpieMail::~OpieMail() | 59 | OpieMail::~OpieMail() |
60 | { | 60 | { |
61 | if (settings) delete settings; | 61 | if (settings) delete settings; |
62 | if ( tb ) | 62 | if ( tb ) |
63 | delete tb; | 63 | delete tb; |
64 | } | 64 | } |
65 | 65 | ||
66 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 66 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
67 | { | 67 | { |
68 | 68 | ||
69 | } | 69 | } |
70 | #include <stdlib.h> | 70 | #include <stdlib.h> |
71 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 71 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
72 | { | 72 | { |
73 | // copied from old mail2 | 73 | // copied from old mail2 |
74 | static int ii = 0; | 74 | static int ii = 0; |
75 | //qDebug("QCOP CALL ############################# %d ", ii); | 75 | //qDebug("QCOP CALL ############################# %d ", ii); |
76 | //QString mess ( msg ); | 76 | //QString mess ( msg ); |
77 | //qDebug("Message = %s ",mess.latin1()); | 77 | //qDebug("Message = %s ",mess.latin1()); |
78 | ++ii; | 78 | ++ii; |
79 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 79 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
80 | 80 | ||
81 | mPendingEmail = QString::null; | 81 | mPendingEmail = QString::null; |
82 | mPendingName = QString::null; | 82 | mPendingName = QString::null; |
83 | if (msg == "writeMail(QString,QString)") | 83 | if (msg == "writeMail(QString,QString)") |
84 | { | 84 | { |
85 | //qDebug("writeMail(QString,QString) "); | 85 | //qDebug("writeMail(QString,QString) "); |
86 | QDataStream stream(data,IO_ReadOnly); | 86 | QDataStream stream(data,IO_ReadOnly); |
87 | stream >> mPendingName >> mPendingEmail; | 87 | stream >> mPendingName >> mPendingEmail; |
88 | // removing the whitespaces at beginning and end is needed! | 88 | // removing the whitespaces at beginning and end is needed! |
89 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 89 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
90 | } | 90 | } |
91 | else if (msg == "newMail()") | 91 | else if (msg == "newMail()") |
92 | { | 92 | { |
93 | //qDebug("slotComposeMail() "); | 93 | //qDebug("slotComposeMail() "); |
94 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 94 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
95 | // and a QCOP call does not like a processevents in his execution | 95 | // and a QCOP call does not like a processevents in his execution |
96 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 96 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
97 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 97 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
98 | // slotComposeMail(); | 98 | // slotComposeMail(); |
99 | } | 99 | } |
100 | else if (msg == "newMail(QString)") | 100 | else if (msg == "newMail(QString)") |
101 | { | 101 | { |
102 | //qDebug(" newMail(QString)"); | 102 | //qDebug(" newMail(QString)"); |
103 | QDataStream stream(data,IO_ReadOnly); | 103 | QDataStream stream(data,IO_ReadOnly); |
104 | stream >> mPendingName; | 104 | stream >> mPendingName; |
105 | // the format is | 105 | // the format is |
106 | // NAME <EMAIL>:SUBJECT | 106 | // NAME <EMAIL>:SUBJECT |
107 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 107 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
108 | } else { | 108 | } else { |
109 | mPendingData = data; | 109 | mPendingData = data; |
110 | mPendingMessage = msg; | 110 | mPendingMessage = msg; |
111 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); | 111 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); |
112 | } | 112 | } |
113 | 113 | ||
114 | //qDebug("END OpieMail::message "); | 114 | //qDebug("END OpieMail::message "); |
115 | } | 115 | } |
116 | void OpieMail::slotExtAppHandler() | 116 | void OpieMail::slotExtAppHandler() |
117 | { | 117 | { |
118 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); | 118 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); |
119 | } | 119 | } |
120 | void OpieMail::slotwriteMail2(const QString& namemail ) | 120 | void OpieMail::slotwriteMail2(const QString& namemail ) |
121 | { | 121 | { |
122 | //qDebug("OpieMail::slotwriteMail2 "); | 122 | //qDebug("OpieMail::slotwriteMail2 "); |
123 | //qApp->processEvents(); | 123 | //qApp->processEvents(); |
124 | ComposeMail compose( settings, this, 0, true ); | 124 | ComposeMail compose( settings, this, 0, true ); |
125 | if ( !namemail.isEmpty() ) { | 125 | if ( !namemail.isEmpty() ) { |
126 | QString to = namemail; | 126 | QString to = namemail; |
127 | if ( namemail.find( " <") > 1 ) { | 127 | if ( namemail.find( " <") > 1 ) { |
128 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 128 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
129 | } else | 129 | } else |
130 | if ( namemail.find( "<") > 1 ) { | 130 | if ( namemail.find( "<") > 1 ) { |
131 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 131 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
132 | } | 132 | } |
133 | int sub = to.find( ">:"); | 133 | int sub = to.find( ">:"); |
134 | if ( sub > 0 ) { | 134 | if ( sub > 0 ) { |
135 | compose.setTo( to.left(sub+1) ); | 135 | compose.setTo( to.left(sub+1) ); |
136 | compose.setSubject( to.mid(sub+2) ); | 136 | compose.setSubject( to.mid(sub+2) ); |
137 | } else | 137 | } else |
138 | compose.setTo( to ); | 138 | compose.setTo( to ); |
139 | } | 139 | } |
140 | compose.slotAdjustColumns(); | 140 | compose.slotAdjustColumns(); |
141 | #ifndef DESKTOP_VERSION | 141 | #ifndef DESKTOP_VERSION |
142 | compose.showMaximized(); | 142 | compose.showMaximized(); |
143 | #endif | 143 | #endif |
144 | mCurrentComposer = &compose; | 144 | mCurrentComposer = &compose; |
145 | compose.exec(); | 145 | compose.exec(); |
146 | mCurrentComposer = 0; | 146 | mCurrentComposer = 0; |
147 | folderView->refreshOutgoing(); | 147 | folderView->refreshOutgoing(); |
148 | raise(); | 148 | raise(); |
149 | //qDebug("retttich "); | 149 | //qDebug("retttich "); |
150 | } | 150 | } |
151 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 151 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
152 | { | 152 | { |
153 | // qDebug("OpieMail::slotwriteMail "); | 153 | // qDebug("OpieMail::slotwriteMail "); |
154 | ComposeMail compose( settings, this, 0, true ); | 154 | ComposeMail compose( settings, this, 0, true ); |
155 | if (!email.isEmpty()) | 155 | if (!email.isEmpty()) |
156 | { | 156 | { |
157 | if (!name.isEmpty()) | 157 | if (!name.isEmpty()) |
158 | { | 158 | { |
159 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 159 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
160 | } | 160 | } |
161 | else | 161 | else |
162 | { | 162 | { |
163 | compose.setTo(email); | 163 | compose.setTo(email); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | compose.slotAdjustColumns(); | 166 | compose.slotAdjustColumns(); |
167 | #ifndef DESKTOP_VERSION | 167 | #ifndef DESKTOP_VERSION |
168 | compose.showMaximized(); | 168 | compose.showMaximized(); |
169 | #endif | 169 | #endif |
170 | 170 | ||
171 | mCurrentComposer = &compose; | 171 | mCurrentComposer = &compose; |
172 | compose.exec(); | 172 | compose.exec(); |
173 | mCurrentComposer = 0; | 173 | mCurrentComposer = 0; |
174 | folderView->refreshOutgoing(); | 174 | folderView->refreshOutgoing(); |
175 | raise(); | 175 | raise(); |
176 | } | 176 | } |
177 | 177 | ||
178 | void OpieMail::slotComposeMail() | 178 | void OpieMail::slotComposeMail() |
179 | { | 179 | { |
180 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 180 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
181 | slotwriteMail2( QString () ); | 181 | slotwriteMail2( QString () ); |
182 | else { | 182 | else { |
183 | if ( mPendingEmail == QString::null ) | 183 | if ( mPendingEmail == QString::null ) |
184 | slotwriteMail2( mPendingName ); | 184 | slotwriteMail2( mPendingName ); |
185 | else | 185 | else |
186 | slotwriteMail( mPendingName, mPendingEmail ); | 186 | slotwriteMail( mPendingName, mPendingEmail ); |
187 | } | 187 | } |
188 | //slotwriteMail(0l,0l); | 188 | //slotwriteMail(0l,0l); |
189 | } | 189 | } |
190 | 190 | ||
191 | void OpieMail::slotSendQueued() | 191 | void OpieMail::slotSendQueued() |
192 | { | 192 | { |
193 | SMTPaccount *smtp = 0; | 193 | SMTPaccount *smtp = 0; |
194 | 194 | ||
195 | QList<Account> list = settings->getAccounts(); | 195 | QList<Account> list = settings->getAccounts(); |
196 | QList<SMTPaccount> smtpList; | 196 | QList<SMTPaccount> smtpList; |
197 | smtpList.setAutoDelete(false); | 197 | smtpList.setAutoDelete(false); |
198 | Account *it; | 198 | Account *it; |
199 | for ( it = list.first(); it; it = list.next() ) | 199 | for ( it = list.first(); it; it = list.next() ) |
200 | { | 200 | { |
201 | if ( it->getType() == MAILLIB::A_SMTP ) | 201 | if ( it->getType() == MAILLIB::A_SMTP ) |
202 | { | 202 | { |
203 | smtp = static_cast<SMTPaccount *>(it); | 203 | smtp = static_cast<SMTPaccount *>(it); |
204 | smtpList.append(smtp); | 204 | smtpList.append(smtp); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | if (smtpList.count()==0) | 207 | if (smtpList.count()==0) |
208 | { | 208 | { |
209 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp\n account first!\n")); | 209 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp\n account first!\n")); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to\nsend all queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 212 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to\nsend all queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
213 | return; | 213 | return; |
214 | if (smtpList.count()==1) | 214 | if (smtpList.count()==1) |
215 | { | 215 | { |
216 | smtp = smtpList.at(0); | 216 | smtp = smtpList.at(0); |
217 | } | 217 | } |
218 | else | 218 | else |
219 | { | 219 | { |
220 | smtp = 0; | 220 | smtp = 0; |
221 | selectsmtp selsmtp; | 221 | selectsmtp selsmtp; |
222 | selsmtp.setSelectionlist(&smtpList); | 222 | selsmtp.setSelectionlist(&smtpList); |
223 | selsmtp.resize( selsmtp.sizeHint() ); | 223 | selsmtp.resize( selsmtp.sizeHint() ); |
224 | if ( selsmtp.exec() == QDialog::Accepted ) | 224 | if ( selsmtp.exec() == QDialog::Accepted ) |
225 | { | 225 | { |
226 | smtp = selsmtp.selected_smtp(); | 226 | smtp = selsmtp.selected_smtp(); |
227 | } | 227 | } |
228 | } | 228 | } |
229 | if (smtp) | 229 | if (smtp) |
230 | { | 230 | { |
231 | 231 | ||
232 | Global::statusMessage("Sending mails...!"); | 232 | Global::statusMessage("Sending mails...!"); |
233 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 233 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
234 | if ( wrap->flushOutbox() ) | 234 | if ( wrap->flushOutbox() ) |
235 | { | 235 | { |
236 | Global::statusMessage("Mails sent!"); | 236 | Global::statusMessage("Mails sent!"); |
237 | } | 237 | } |
238 | delete wrap; | 238 | delete wrap; |
239 | } | 239 | } |
240 | folderView->refreshOutgoing(); | 240 | folderView->refreshOutgoing(); |
241 | } | 241 | } |
242 | 242 | ||
243 | void OpieMail::slotSearchMails() | 243 | void OpieMail::slotSearchMails() |
244 | { | 244 | { |
245 | qDebug("OpieMail::slotSearchMails():not implemented "); | 245 | qDebug("OpieMail::slotSearchMails():not implemented "); |
246 | } | 246 | } |
247 | void OpieMail::slotEditGlobalSettings() | 247 | void OpieMail::slotEditGlobalSettings() |
248 | { | 248 | { |
249 | KPimPrefsGlobalDialog gc ( this ); | 249 | KPimPrefsGlobalDialog gc ( this ); |
250 | gc.exec(); | 250 | gc.exec(); |
251 | } | 251 | } |
252 | 252 | ||
253 | void OpieMail::slotEditSettings() | 253 | void OpieMail::slotEditSettings() |
254 | { | 254 | { |
255 | 255 | ||
256 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 256 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
257 | #ifndef DESKTOP_VERSION | 257 | #ifndef DESKTOP_VERSION |
258 | settingsDialog.showMaximized(); | 258 | settingsDialog.showMaximized(); |
259 | #endif | 259 | #endif |
260 | settingsDialog.exec(); | 260 | settingsDialog.exec(); |
261 | 261 | ||
262 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | 262 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); |
263 | // KApplication::execDialog(settingsDialog); | 263 | // KApplication::execDialog(settingsDialog); |
264 | } | 264 | } |
265 | 265 | ||
266 | void OpieMail::slotEditAccounts() | 266 | void OpieMail::slotEditAccounts() |
267 | { | 267 | { |
268 | EditAccounts eaDialog( settings, this, 0, true ); | 268 | EditAccounts eaDialog( settings, this, 0, true ); |
269 | eaDialog.slotAdjustColumns(); | 269 | eaDialog.slotAdjustColumns(); |
270 | #ifndef DESKTOP_VERSION | 270 | #ifndef DESKTOP_VERSION |
271 | eaDialog.showMaximized(); | 271 | eaDialog.showMaximized(); |
272 | #endif | 272 | #endif |
273 | eaDialog.exec(); | 273 | eaDialog.exec(); |
274 | if ( settings ) delete settings; | 274 | if ( settings ) delete settings; |
275 | settings = new Settings(); | 275 | settings = new Settings(); |
276 | 276 | ||
277 | folderView->populate( settings->getAccounts() ); | 277 | folderView->populate( settings->getAccounts() ); |
278 | } | 278 | } |
279 | void OpieMail::replyMail() | 279 | void OpieMail::replyMail() |
280 | { | 280 | { |
281 | 281 | ||
282 | QListViewItem*item = mailView->currentItem(); | 282 | QListViewItem*item = mailView->currentItem(); |
283 | if (!item) return; | 283 | if (!item) return; |
284 | RecMailP mail = ((MailListViewItem*)item)->data(); | 284 | RecMailP mail = ((MailListViewItem*)item)->data(); |
285 | RecBodyP body = folderView->fetchBody(mail); | 285 | RecBodyP body = folderView->fetchBody(mail); |
286 | 286 | ||
287 | QString rtext; | 287 | QString rtext; |
288 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 288 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
289 | .arg( mail->getFrom()) | 289 | .arg( mail->getFrom()) |
290 | .arg( mail->getDate()); | 290 | .arg( mail->getDate()); |
291 | 291 | ||
292 | QString text = body->Bodytext(); | 292 | QString text = body->Bodytext(); |
293 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 293 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
294 | QStringList::Iterator it; | 294 | QStringList::Iterator it; |
295 | for (it = lines.begin(); it != lines.end(); it++) | 295 | for (it = lines.begin(); it != lines.end(); it++) |
296 | { | 296 | { |
297 | rtext += "> " + *it + "\n"; | 297 | rtext += "> " + *it + "\n"; |
298 | } | 298 | } |
299 | rtext += "\n"; | 299 | rtext += "\n"; |
300 | 300 | ||
301 | QString prefix; | 301 | QString prefix; |
302 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 302 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
303 | else prefix = "Re: "; // no i18n on purpose | 303 | else prefix = "Re: "; // no i18n on purpose |
304 | 304 | ||
305 | Settings *settings = new Settings(); | 305 | Settings *settings = new Settings(); |
306 | ComposeMail composer( settings ,this, 0, true); | 306 | ComposeMail composer( settings ,this, 0, true); |
307 | if (mail->Replyto().isEmpty()) { | 307 | if (mail->Replyto().isEmpty()) { |
308 | composer.setTo( mail->getFrom()); | 308 | composer.setTo( mail->getFrom()); |
309 | } else { | 309 | } else { |
310 | composer.setTo( mail->Replyto()); | 310 | composer.setTo( mail->Replyto()); |
311 | } | 311 | } |
312 | composer.setSubject( prefix + mail->getSubject()); | 312 | composer.setSubject( prefix + mail->getSubject()); |
313 | composer.setMessage( rtext ); | 313 | composer.setMessage( rtext ); |
314 | composer.setInReplyTo( mail->Msgid()); | 314 | composer.setInReplyTo( mail->Msgid()); |
315 | composer.setCharset( body->getCharset() ); | 315 | composer.setCharset( body->getCharset() ); |
316 | 316 | ||
317 | mCurrentComposer = &composer; | 317 | mCurrentComposer = &composer; |
318 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 318 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
319 | { | 319 | { |
320 | mail->Wrapper()->answeredMail(mail); | 320 | mail->Wrapper()->answeredMail(mail); |
321 | } | 321 | } |
322 | mCurrentComposer = 0; | 322 | mCurrentComposer = 0; |
323 | folderView->refreshOutgoing(); | 323 | folderView->refreshOutgoing(); |
324 | delete settings; | 324 | delete settings; |
325 | 325 | ||
326 | } | 326 | } |
327 | void OpieMail::closeViewMail(ViewMail * vm) | 327 | void OpieMail::closeViewMail(ViewMail * vm) |
328 | { | 328 | { |
329 | vm->hide(); | 329 | vm->hide(); |
330 | } | 330 | } |
331 | 331 | ||
332 | void OpieMail::slotDownloadMail( ) | 332 | void OpieMail::slotDownloadMail( ) |
333 | { | 333 | { |
334 | QListViewItem*item = mailView->currentItem(); | 334 | QListViewItem*item = mailView->currentItem(); |
335 | if (!item ) { | 335 | if (!item ) { |
336 | Global::statusMessage("Error: No item slected!"); | 336 | Global::statusMessage("Error: No item slected!"); |
337 | return; | 337 | return; |
338 | } | 338 | } |
339 | RecMailP mail = ((MailListViewItem*)item)->data(); | 339 | RecMailP mail = ((MailListViewItem*)item)->data(); |
340 | Account * acc = mail->Wrapper()->getAccount(); | 340 | Account * acc = mail->Wrapper()->getAccount(); |
341 | if ( !acc ) { | 341 | if ( !acc ) { |
342 | Global::statusMessage("Mail is already stored locally!"); | 342 | Global::statusMessage("Mail is already stored locally!"); |
343 | return; | 343 | return; |
344 | } | 344 | } |
345 | QString lfName = acc->getLocalFolder(); | 345 | QString lfName = acc->getLocalFolder(); |
346 | //qDebug("local folder " + lfName ); | 346 | //qDebug("local folder " + lfName ); |
347 | if ( lfName.isEmpty() ) | 347 | if ( lfName.isEmpty() ) |
348 | lfName = acc->getAccountName(); | 348 | lfName = acc->getAccountName(); |
349 | AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); | 349 | AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); |
350 | //qDebug("target %d %d ",targetMail,mail->Wrapper() ); | 350 | //qDebug("target %d %d ",targetMail,mail->Wrapper() ); |
351 | if ( targetMail == mail->Wrapper() ) { | 351 | if ( targetMail == mail->Wrapper() ) { |
352 | Global::statusMessage("Mail is already locally stored!"); | 352 | Global::statusMessage("Mail is already locally stored!"); |
353 | return; | 353 | return; |
354 | } | 354 | } |
355 | if ( !targetMail->createMbox(lfName)) { | 355 | if ( !targetMail->createMbox(lfName)) { |
356 | Global::statusMessage("Error creating folder!"); | 356 | Global::statusMessage("Error creating folder!"); |
357 | return; | 357 | return; |
358 | } | 358 | } |
359 | Global::statusMessage("Fetching mail...please wait!"); | 359 | Global::statusMessage("Fetching mail...please wait!"); |
360 | qApp->processEvents(); | 360 | qApp->processEvents(); |
361 | encodedString*st = 0; | 361 | encodedString*st = 0; |
362 | st = mail->Wrapper()->fetchRawBody(mail); | 362 | st = mail->Wrapper()->fetchRawBody(mail); |
363 | if ( st ) { | 363 | if ( st ) { |
364 | targetMail->storeMessage(st->Content(),st->Length(),lfName); | 364 | targetMail->storeMessage(st->Content(),st->Length(),lfName); |
365 | Global::statusMessage("Mail stored in "+ lfName); | 365 | Global::statusMessage("Mail stored in "+ lfName); |
366 | delete st; | 366 | delete st; |
367 | } else { | 367 | } else { |
368 | Global::statusMessage("Error: Cannot fetch mail!"); | 368 | Global::statusMessage("Error: Cannot fetch mail!"); |
369 | } | 369 | } |
370 | } | 370 | } |
371 | 371 | ||
372 | 372 | ||
373 | void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) | 373 | void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) |
374 | { | 374 | { |
375 | QListViewItem*item = mailView->currentItem(); | 375 | QListViewItem*item = mailView->currentItem(); |
376 | if (!item ) { | 376 | if (!item ) { |
377 | closeViewMail(vm); | 377 | closeViewMail(vm); |
378 | return; | 378 | return; |
379 | } | 379 | } |
380 | RecMailP mail = ((MailListViewItem*)item)->data(); | 380 | RecMailP mail = ((MailListViewItem*)item)->data(); |
381 | mail->Wrapper()->deleteMail( mail ); | 381 | mail->Wrapper()->deleteMail( mail ); |
382 | item = item->itemBelow(); | 382 | item = item->itemBelow(); |
383 | if (!item ) { | 383 | if (!item ) { |
384 | closeViewMail(vm); | 384 | closeViewMail(vm); |
385 | return; | 385 | return; |
386 | } | 386 | } |
387 | mailView->setCurrentItem(item); | 387 | mailView->setCurrentItem(item); |
388 | mail = ((MailListViewItem*)item)->data(); | 388 | mail = ((MailListViewItem*)item)->data(); |
389 | RecBodyP body = folderView->fetchBody(mail); | 389 | RecBodyP body = folderView->fetchBody(mail); |
390 | vm->setBody( body ); | 390 | vm->setBody( body ); |
391 | vm->setMail( mail ); | 391 | vm->setMail( mail ); |
392 | } | 392 | } |
393 | void OpieMail::displayNextMail(ViewMail * vm) | 393 | void OpieMail::displayNextMail(ViewMail * vm) |
394 | { | 394 | { |
395 | QListViewItem*item = mailView->currentItem(); | 395 | QListViewItem*item = mailView->currentItem(); |
396 | if (!item) return; | 396 | if (!item) return; |
397 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 397 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
398 | item = item->itemBelow(); | 398 | item = item->itemBelow(); |
399 | if (!item) { | 399 | if (!item) { |
400 | vm->setCaption(i18n("End of List" )); | 400 | vm->setCaption(i18n("End of List" )); |
401 | return; | 401 | return; |
402 | } | 402 | } |
403 | mailView->setCurrentItem(item); | 403 | mailView->setCurrentItem(item); |
404 | RecMailP mail = ((MailListViewItem*)item)->data(); | 404 | RecMailP mail = ((MailListViewItem*)item)->data(); |
405 | RecBodyP body = folderView->fetchBody(mail); | 405 | RecBodyP body = folderView->fetchBody(mail); |
406 | vm->setBody( body ); | 406 | vm->setBody( body ); |
407 | vm->setMail( mail ); | 407 | vm->setMail( mail ); |
408 | } | 408 | } |
409 | void OpieMail::displayMail() | 409 | void OpieMail::displayMail() |
410 | { | 410 | { |
411 | QListViewItem*item = mailView->currentItem(); | 411 | QListViewItem*item = mailView->currentItem(); |
412 | if (!item) return; | 412 | if (!item) return; |
413 | RecMailP mail = ((MailListViewItem*)item)->data(); | 413 | RecMailP mail = ((MailListViewItem*)item)->data(); |
414 | RecBodyP body = folderView->fetchBody(mail); | 414 | RecBodyP body = folderView->fetchBody(mail); |
415 | ViewMail readMail( this,"", Qt::WType_Modal ); | 415 | ViewMail readMail( this,"", Qt::WType_Modal ); |
416 | readMail.setBody( body ); | 416 | readMail.setBody( body ); |
417 | readMail.setMail( mail ); | 417 | readMail.setMail( mail ); |
418 | #ifndef DESKTOP_VERSION | 418 | #ifndef DESKTOP_VERSION |
419 | readMail.showMaximized(); | 419 | readMail.showMaximized(); |
420 | #else | 420 | #else |
421 | readMail.resize( 640, 480); | 421 | readMail.resize( 640, 480); |
422 | #endif | 422 | #endif |
423 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); | 423 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); |
424 | connect( &readMail,SIGNAL( deleteAndDisplayNextMail(ViewMail *) ), this, SLOT(deleteAndDisplayNextMail(ViewMail *) ) ); | 424 | connect( &readMail,SIGNAL( deleteAndDisplayNextMail(ViewMail *) ), this, SLOT(deleteAndDisplayNextMail(ViewMail *) ) ); |
425 | connect( &readMail,SIGNAL( signalDownloadMail() ), this, SLOT( slotDownloadMail() ) ); | 425 | connect( &readMail,SIGNAL( signalDownloadMail() ), this, SLOT( slotDownloadMail() ) ); |
426 | 426 | ||
427 | readMail.exec(); | 427 | readMail.exec(); |
428 | 428 | ||
429 | if ( readMail.deleted ) | 429 | if ( readMail.deleted ) |
430 | { | 430 | { |
431 | folderView->refreshCurrent(); | 431 | folderView->refreshCurrent(); |
432 | } | 432 | } |
433 | else | 433 | else |
434 | { | 434 | { |
435 | QListViewItem*item = mailView->currentItem(); | 435 | QListViewItem*item = mailView->currentItem(); |
436 | if (item) | 436 | if (item) |
437 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 437 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
438 | } | 438 | } |
439 | } | 439 | } |
440 | void OpieMail::slotGetAllMail() | 440 | void OpieMail::slotGetAllMail() |
441 | { | 441 | { |
442 | QListViewItem * item = folderView->firstChild(); | 442 | QListViewItem * item = folderView->firstChild(); |
443 | while ( item ){ | 443 | while ( item ){ |
444 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 444 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
445 | item = item->nextSibling (); | 445 | item = item->nextSibling (); |
446 | } | 446 | } |
447 | } | 447 | } |
448 | void OpieMail::slotGetMail() | 448 | void OpieMail::slotGetMail() |
449 | { | 449 | { |
450 | QListViewItem * item = folderView->currentItem(); | 450 | QListViewItem * item = folderView->currentItem(); |
451 | if ( ! item ) return; | 451 | if ( ! item ) return; |
452 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 452 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
453 | } | 453 | } |
454 | void OpieMail::slotDeleteMail() | 454 | void OpieMail::slotDeleteMail() |
455 | { | 455 | { |
456 | if (!mailView->currentItem()) return; | 456 | if (!mailView->currentItem()) return; |
457 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 457 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
458 | 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 ) | 458 | 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 ) |
459 | { | 459 | { |
460 | mail->Wrapper()->deleteMail( mail ); | 460 | mail->Wrapper()->deleteMail( mail ); |
461 | folderView->refreshCurrent(); | 461 | folderView->refreshCurrent(); |
462 | } | 462 | } |
463 | } | 463 | } |
464 | void OpieMail::slotDeleteAllMail() | 464 | void OpieMail::slotDeleteAllMail() |
465 | { | 465 | { |
466 | 466 | ||
467 | QValueList<RecMailP> t; | 467 | QValueList<RecMailP> t; |
468 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 468 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
469 | { | 469 | { |
470 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 470 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
471 | while ( item ) { | 471 | while ( item ) { |
472 | if ( item->isSelected() ) { | 472 | if ( item->isSelected() ) { |
473 | t.append( item->data() ); | 473 | t.append( item->data() ); |
474 | } | 474 | } |
475 | item = (MailListViewItem*)item->nextSibling(); | 475 | item = (MailListViewItem*)item->nextSibling(); |
476 | } | 476 | } |
477 | } | 477 | } |
478 | else | 478 | else |
479 | return; | 479 | return; |
480 | if ( t.count() == 0 ) | 480 | if ( t.count() == 0 ) |
481 | return; | 481 | return; |
482 | RecMailP mail = t.first(); | 482 | RecMailP mail = t.first(); |
483 | mail->Wrapper()->deleteMailList(t); | 483 | mail->Wrapper()->deleteMailList(t); |
484 | folderView->refreshCurrent(); | 484 | folderView->refreshCurrent(); |
485 | 485 | ||
486 | 486 | ||
487 | } | 487 | } |
488 | void OpieMail::clearSelection() | 488 | void OpieMail::clearSelection() |
489 | { | 489 | { |
490 | mailView->clearSelection(); | 490 | mailView->clearSelection(); |
491 | 491 | ||
492 | } | 492 | } |
493 | void OpieMail::selectAll() | ||
494 | { | ||
495 | QListViewItem* item = mailView->firstChild (); | ||
496 | while ( item ) { | ||
497 | mailView->setSelected ( item, true ); | ||
498 | item = item->nextSibling(); | ||
499 | } | ||
500 | } | ||
493 | 501 | ||
494 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 502 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
495 | { | 503 | { |
496 | if (!mailView->currentItem()) return; | 504 | if (!mailView->currentItem()) return; |
497 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 505 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
498 | /* just the RIGHT button - or hold on pda */ | 506 | /* just the RIGHT button - or hold on pda */ |
499 | if (button!=2) {return;} | 507 | if (button!=2) {return;} |
500 | if (!item) return; | 508 | if (!item) return; |
501 | QPopupMenu *m = new QPopupMenu(0); | 509 | QPopupMenu *m = new QPopupMenu(0); |
502 | if (m) | 510 | if (m) |
503 | { | 511 | { |
504 | if (mailtype==MAILLIB::A_NNTP) { | 512 | if (mailtype==MAILLIB::A_NNTP) { |
505 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); | 513 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); |
506 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 514 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
507 | m->insertSeparator(); | 515 | m->insertSeparator(); |
508 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); | 516 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); |
509 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 517 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
510 | } else { | 518 | } else { |
511 | if (folderView->currentisDraft()) { | 519 | if (folderView->currentisDraft()) { |
512 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); | 520 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); |
513 | } | 521 | } |
514 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); | 522 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); |
515 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); | 523 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); |
516 | m->insertSeparator(); | 524 | m->insertSeparator(); |
517 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); | 525 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); |
518 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); | 526 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); |
519 | m->insertSeparator(); | 527 | m->insertSeparator(); |
520 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); | 528 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); |
521 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); | 529 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); |
522 | m->insertSeparator(); | 530 | m->insertSeparator(); |
531 | m->insertItem(i18n("Select all"),this,SLOT(selectAll())); | ||
523 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 532 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
524 | } | 533 | } |
525 | m->setFocus(); | 534 | m->setFocus(); |
526 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 535 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
527 | delete m; | 536 | delete m; |
528 | } | 537 | } |
529 | } | 538 | } |
530 | 539 | ||
531 | void OpieMail::slotShowFolders( bool show ) | 540 | void OpieMail::slotShowFolders( bool show ) |
532 | { | 541 | { |
533 | if ( show && folderView->isHidden() ) | 542 | if ( show && folderView->isHidden() ) |
534 | { | 543 | { |
535 | folderView->show(); | 544 | folderView->show(); |
536 | } | 545 | } |
537 | else if ( !show && !folderView->isHidden() ) | 546 | else if ( !show && !folderView->isHidden() ) |
538 | { | 547 | { |
539 | folderView->hide(); | 548 | folderView->hide(); |
540 | } | 549 | } |
541 | } | 550 | } |
542 | 551 | ||
543 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 552 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
544 | { | 553 | { |
545 | MailListViewItem*item = 0; | 554 | MailListViewItem*item = 0; |
546 | mailView->clear(); | 555 | mailView->clear(); |
547 | 556 | ||
548 | QValueList<RecMailP>::ConstIterator it; | 557 | QValueList<RecMailP>::ConstIterator it; |
549 | for (it = list.begin(); it != list.end();++it) | 558 | for (it = list.begin(); it != list.end();++it) |
550 | { | 559 | { |
551 | item = new MailListViewItem(mailView,item); | 560 | item = new MailListViewItem(mailView,item); |
552 | item->storeData((*it)); | 561 | item->storeData((*it)); |
553 | item->showEntry(); | 562 | item->showEntry(); |
554 | } | 563 | } |
555 | mailView->setSorting ( 4, false ); | 564 | mailView->setSorting ( 4, false ); |
556 | } | 565 | } |
557 | 566 | ||
558 | void OpieMail::mailLeftClicked( QListViewItem *item ) | 567 | void OpieMail::mailLeftClicked( QListViewItem *item ) |
559 | { | 568 | { |
560 | mailView->clearSelection(); | 569 | mailView->clearSelection(); |
561 | /* just LEFT button - or tap with stylus on pda */ | 570 | /* just LEFT button - or tap with stylus on pda */ |
562 | //if (button!=1) return; | 571 | //if (button!=1) return; |
563 | if (!item) return; | 572 | if (!item) return; |
564 | if (folderView->currentisDraft()) { | 573 | if (folderView->currentisDraft()) { |
565 | reEditMail(); | 574 | reEditMail(); |
566 | } else { | 575 | } else { |
567 | displayMail(); | 576 | displayMail(); |
568 | } | 577 | } |
569 | } | 578 | } |
570 | 579 | ||
571 | void OpieMail::slotMoveCopyMail() | 580 | void OpieMail::slotMoveCopyMail() |
572 | { | 581 | { |
573 | if (!mailView->currentItem()) return; | 582 | if (!mailView->currentItem()) return; |
574 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 583 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
575 | AbstractMail*targetMail = 0; | 584 | AbstractMail*targetMail = 0; |
576 | QString targetFolder = ""; | 585 | QString targetFolder = ""; |
577 | Selectstore sels; | 586 | Selectstore sels; |
578 | folderView->setupFolderselect(&sels); | 587 | folderView->setupFolderselect(&sels); |
579 | if (!sels.exec()) return; | 588 | if (!sels.exec()) return; |
580 | targetMail = sels.currentMail(); | 589 | targetMail = sels.currentMail(); |
581 | targetFolder = sels.currentFolder(); | 590 | targetFolder = sels.currentFolder(); |
582 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 591 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
583 | targetFolder.isEmpty()) | 592 | targetFolder.isEmpty()) |
584 | { | 593 | { |
585 | return; | 594 | return; |
586 | } | 595 | } |
587 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 596 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
588 | { | 597 | { |
589 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 598 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
590 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 599 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
591 | return; | 600 | return; |
592 | } | 601 | } |
593 | sels.hide(); | 602 | sels.hide(); |
594 | qApp->processEvents(); | 603 | qApp->processEvents(); |
595 | // qDebug("hiding sels "); | 604 | // qDebug("hiding sels "); |
596 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | 605 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); |
597 | folderView->refreshCurrent(); | 606 | folderView->refreshCurrent(); |
598 | } | 607 | } |
599 | 608 | ||
600 | void OpieMail::slotMoveCopyAllMail() | 609 | void OpieMail::slotMoveCopyAllMail() |
601 | { | 610 | { |
602 | 611 | ||
603 | if (!mailView->currentItem()) return; | 612 | if (!mailView->currentItem()) return; |
604 | QValueList<RecMailP> t; | 613 | QValueList<RecMailP> t; |
605 | // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 614 | // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
606 | { | 615 | { |
607 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 616 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
608 | while ( item ) { | 617 | while ( item ) { |
609 | if ( item->isSelected() ) { | 618 | if ( item->isSelected() ) { |
610 | t.append( item->data() ); | 619 | t.append( item->data() ); |
611 | } | 620 | } |
612 | item = (MailListViewItem*)item->nextSibling(); | 621 | item = (MailListViewItem*)item->nextSibling(); |
613 | } | 622 | } |
614 | } | 623 | } |
615 | // else | 624 | // else |
616 | // return; | 625 | // return; |
617 | if ( t.count() == 0 ) | 626 | if ( t.count() == 0 ) |
618 | return; | 627 | return; |
619 | RecMailP mail = t.first(); | 628 | RecMailP mail = t.first(); |
620 | AbstractMail*targetMail = 0; | 629 | AbstractMail*targetMail = 0; |
621 | QString targetFolder = ""; | 630 | QString targetFolder = ""; |
622 | Selectstore sels; | 631 | Selectstore sels; |
623 | folderView->setupFolderselect(&sels); | 632 | folderView->setupFolderselect(&sels); |
624 | if (!sels.exec()) return; | 633 | if (!sels.exec()) return; |
625 | targetMail = sels.currentMail(); | 634 | targetMail = sels.currentMail(); |
626 | targetFolder = sels.currentFolder(); | 635 | targetFolder = sels.currentFolder(); |
627 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 636 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
628 | targetFolder.isEmpty()) | 637 | targetFolder.isEmpty()) |
629 | { | 638 | { |
630 | return; | 639 | return; |
631 | } | 640 | } |
632 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 641 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
633 | { | 642 | { |
634 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 643 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
635 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 644 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
636 | return; | 645 | return; |
637 | } | 646 | } |
638 | sels.hide(); | 647 | sels.hide(); |
639 | qApp->processEvents(); | 648 | qApp->processEvents(); |
640 | //qDebug("hiding sels "); | 649 | //qDebug("hiding sels "); |
641 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); | 650 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); |
642 | folderView->refreshCurrent(); | 651 | folderView->refreshCurrent(); |
643 | } | 652 | } |
644 | 653 | ||
645 | void OpieMail::reEditMail() | 654 | void OpieMail::reEditMail() |
646 | { | 655 | { |
647 | if (!mailView->currentItem()) return; | 656 | if (!mailView->currentItem()) return; |
648 | 657 | ||
649 | ComposeMail compose( settings, this, 0, true ); | 658 | ComposeMail compose( settings, this, 0, true ); |
650 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); | 659 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); |
651 | compose.slotAdjustColumns(); | 660 | compose.slotAdjustColumns(); |
652 | #ifndef DESKTOP_VERSION | 661 | #ifndef DESKTOP_VERSION |
653 | compose.showMaximized(); | 662 | compose.showMaximized(); |
654 | #else | 663 | #else |
655 | compose.resize(640,480); | 664 | compose.resize(640,480); |
656 | #endif | 665 | #endif |
657 | mCurrentComposer = &compose; | 666 | mCurrentComposer = &compose; |
658 | compose.exec(); | 667 | compose.exec(); |
659 | folderView->refreshOutgoing(); | 668 | folderView->refreshOutgoing(); |
660 | mCurrentComposer = 0; | 669 | mCurrentComposer = 0; |
661 | } | 670 | } |
662 | 671 | ||
663 | void OpieMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 672 | void OpieMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
664 | { | 673 | { |
665 | 674 | ||
666 | if ( mCurrentComposer ) { | 675 | if ( mCurrentComposer ) { |
667 | mCurrentComposer->insertAttendees(uid,nameList,emailList,uidList); | 676 | mCurrentComposer->insertAttendees(uid,nameList,emailList,uidList); |
668 | } else { | 677 | } else { |
669 | ComposeMail compose( settings, this, 0, true ); | 678 | ComposeMail compose( settings, this, 0, true ); |
670 | compose.slotAdjustColumns(); | 679 | compose.slotAdjustColumns(); |
671 | #ifndef DESKTOP_VERSION | 680 | #ifndef DESKTOP_VERSION |
672 | compose.showMaximized(); | 681 | compose.showMaximized(); |
673 | #endif | 682 | #endif |
674 | mCurrentComposer = &compose; | 683 | mCurrentComposer = &compose; |
675 | mCurrentComposer->insertAttendees(uid,nameList,emailList,uidList); | 684 | mCurrentComposer->insertAttendees(uid,nameList,emailList,uidList); |
676 | compose.exec(); | 685 | compose.exec(); |
677 | mCurrentComposer = 0; | 686 | mCurrentComposer = 0; |
678 | folderView->refreshOutgoing(); | 687 | folderView->refreshOutgoing(); |
679 | raise(); | 688 | raise(); |
680 | } | 689 | } |
681 | } | 690 | } |
diff --git a/kmicromail/opiemail.h b/kmicromail/opiemail.h index 48c5dda..bdd9058 100644 --- a/kmicromail/opiemail.h +++ b/kmicromail/opiemail.h | |||
@@ -1,67 +1,68 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #ifndef OPIEMAIL_H | 2 | #ifndef OPIEMAIL_H |
3 | #define OPIEMAIL_H | 3 | #define OPIEMAIL_H |
4 | 4 | ||
5 | #include "mainwindow.h" | 5 | #include "mainwindow.h" |
6 | #include <libmailwrapper/settings.h> | 6 | #include <libmailwrapper/settings.h> |
7 | 7 | ||
8 | #include <opie2/osmartpointer.h> | 8 | #include <opie2/osmartpointer.h> |
9 | #include <libmailwrapper/mailtypes.h> | 9 | #include <libmailwrapper/mailtypes.h> |
10 | #include <viewmail.h> | 10 | #include <viewmail.h> |
11 | #include <qstringlist.h> | 11 | #include <qstringlist.h> |
12 | 12 | ||
13 | class ComposeMail; | 13 | class ComposeMail; |
14 | 14 | ||
15 | class OpieMail : public MainWindow | 15 | class OpieMail : public MainWindow |
16 | { | 16 | { |
17 | Q_OBJECT | 17 | Q_OBJECT |
18 | 18 | ||
19 | public: | 19 | public: |
20 | OpieMail( QWidget *parent = 0, const char *name = 0 ); | 20 | OpieMail( QWidget *parent = 0, const char *name = 0 ); |
21 | virtual ~OpieMail(); | 21 | virtual ~OpieMail(); |
22 | static QString appName() { return QString::fromLatin1("kopiemail"); } | 22 | static QString appName() { return QString::fromLatin1("kopiemail"); } |
23 | 23 | ||
24 | public slots: | 24 | public slots: |
25 | virtual void slotwriteMail(const QString&name,const QString&email); | 25 | virtual void slotwriteMail(const QString&name,const QString&email); |
26 | virtual void slotwriteMail2(const QString&nameemail); | 26 | virtual void slotwriteMail2(const QString&nameemail); |
27 | virtual void slotComposeMail(); | 27 | virtual void slotComposeMail(); |
28 | virtual void slotExtAppHandler(); | 28 | virtual void slotExtAppHandler(); |
29 | virtual void appMessage(const QCString &msg, const QByteArray &data); | 29 | virtual void appMessage(const QCString &msg, const QByteArray &data); |
30 | virtual void message(const QCString &msg, const QByteArray &data); | 30 | virtual void message(const QCString &msg, const QByteArray &data); |
31 | void insertAttendees(const QString&, const QStringList& namelist, const QStringList& emaillist, const QStringList& uidlist); | 31 | void insertAttendees(const QString&, const QStringList& namelist, const QStringList& emaillist, const QStringList& uidlist); |
32 | protected slots: | 32 | protected slots: |
33 | virtual void deleteAndDisplayNextMail(ViewMail * vm); | 33 | virtual void deleteAndDisplayNextMail(ViewMail * vm); |
34 | virtual void displayNextMail(ViewMail * vm); | 34 | virtual void displayNextMail(ViewMail * vm); |
35 | virtual void slotSendQueued(); | 35 | virtual void slotSendQueued(); |
36 | virtual void slotSearchMails(); | 36 | virtual void slotSearchMails(); |
37 | virtual void slotEditSettings(); | 37 | virtual void slotEditSettings(); |
38 | virtual void slotEditGlobalSettings(); | 38 | virtual void slotEditGlobalSettings(); |
39 | virtual void slotEditAccounts(); | 39 | virtual void slotEditAccounts(); |
40 | virtual void displayMail(); | 40 | virtual void displayMail(); |
41 | virtual void replyMail(); | 41 | virtual void replyMail(); |
42 | virtual void slotDeleteMail(); | 42 | virtual void slotDeleteMail(); |
43 | virtual void slotGetMail(); | 43 | virtual void slotGetMail(); |
44 | virtual void slotGetAllMail(); | 44 | virtual void slotGetAllMail(); |
45 | virtual void slotDeleteAllMail(); | 45 | virtual void slotDeleteAllMail(); |
46 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); | 46 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); |
47 | virtual void slotShowFolders( bool show ); | 47 | virtual void slotShowFolders( bool show ); |
48 | virtual void refreshMailView(const QValueList<RecMailP>&); | 48 | virtual void refreshMailView(const QValueList<RecMailP>&); |
49 | virtual void mailLeftClicked( QListViewItem * ); | 49 | virtual void mailLeftClicked( QListViewItem * ); |
50 | virtual void slotMoveCopyMail(); | 50 | virtual void slotMoveCopyMail(); |
51 | virtual void slotMoveCopyAllMail(); | 51 | virtual void slotMoveCopyAllMail(); |
52 | virtual void reEditMail(); | 52 | virtual void reEditMail(); |
53 | void clearSelection(); | 53 | void clearSelection(); |
54 | void selectAll(); | ||
54 | void slotDownloadMail(); | 55 | void slotDownloadMail(); |
55 | private: | 56 | private: |
56 | ComposeMail* mCurrentComposer; | 57 | ComposeMail* mCurrentComposer; |
57 | void closeViewMail(ViewMail * vm); | 58 | void closeViewMail(ViewMail * vm); |
58 | QString mPendingEmail; | 59 | QString mPendingEmail; |
59 | QString mPendingName; | 60 | QString mPendingName; |
60 | QByteArray mPendingData; | 61 | QByteArray mPendingData; |
61 | QCString mPendingMessage; | 62 | QCString mPendingMessage; |
62 | Settings *settings; | 63 | Settings *settings; |
63 | QTextBrowser * tb; | 64 | QTextBrowser * tb; |
64 | 65 | ||
65 | }; | 66 | }; |
66 | 67 | ||
67 | #endif | 68 | #endif |