-rw-r--r-- | kmicromail/opiemail.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index f56711d..e159b73 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,402 +1,412 @@ | |||
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 | settings = new Settings(); | 50 | settings = new Settings(); |
50 | tb = 0; | 51 | tb = 0; |
51 | setIcon(SmallIcon( "kmicromail" ) ); | 52 | setIcon(SmallIcon( "kmicromail" ) ); |
52 | folderView->populate( settings->getAccounts() ); | 53 | folderView->populate( settings->getAccounts() ); |
53 | 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&))); | ||
54 | } | 56 | } |
55 | 57 | ||
56 | OpieMail::~OpieMail() | 58 | OpieMail::~OpieMail() |
57 | { | 59 | { |
58 | if (settings) delete settings; | 60 | if (settings) delete settings; |
59 | if ( tb ) | 61 | if ( tb ) |
60 | delete tb; | 62 | delete tb; |
61 | } | 63 | } |
62 | 64 | ||
63 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 65 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
64 | { | 66 | { |
65 | 67 | ||
66 | } | 68 | } |
67 | #include <stdlib.h> | 69 | #include <stdlib.h> |
68 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 70 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
69 | { | 71 | { |
70 | // copied from old mail2 | 72 | // copied from old mail2 |
71 | static int ii = 0; | 73 | static int ii = 0; |
72 | //qDebug("QCOP CALL ############################# %d ", ii); | 74 | //qDebug("QCOP CALL ############################# %d ", ii); |
73 | //QString mess ( msg ); | 75 | //QString mess ( msg ); |
74 | //qDebug("Message = %s ",mess.latin1()); | 76 | //qDebug("Message = %s ",mess.latin1()); |
75 | ++ii; | 77 | ++ii; |
76 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 78 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
77 | 79 | ||
78 | mPendingEmail = QString::null; | 80 | mPendingEmail = QString::null; |
79 | mPendingName = QString::null; | 81 | mPendingName = QString::null; |
80 | if (msg == "writeMail(QString,QString)") | 82 | if (msg == "writeMail(QString,QString)") |
81 | { | 83 | { |
82 | //qDebug("writeMail(QString,QString) "); | 84 | //qDebug("writeMail(QString,QString) "); |
83 | QDataStream stream(data,IO_ReadOnly); | 85 | QDataStream stream(data,IO_ReadOnly); |
84 | stream >> mPendingName >> mPendingEmail; | 86 | stream >> mPendingName >> mPendingEmail; |
85 | // removing the whitespaces at beginning and end is needed! | 87 | // removing the whitespaces at beginning and end is needed! |
86 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 88 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
87 | } | 89 | } |
88 | else if (msg == "newMail()") | 90 | else if (msg == "newMail()") |
89 | { | 91 | { |
90 | //qDebug("slotComposeMail() "); | 92 | //qDebug("slotComposeMail() "); |
91 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 93 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
92 | // and a QCOP call does not like a processevents in his execution | 94 | // and a QCOP call does not like a processevents in his execution |
93 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 95 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
94 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 96 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
95 | // slotComposeMail(); | 97 | // slotComposeMail(); |
96 | } | 98 | } |
97 | else if (msg == "newMail(QString)") | 99 | else if (msg == "newMail(QString)") |
98 | { | 100 | { |
99 | //qDebug(" newMail(QString)"); | 101 | //qDebug(" newMail(QString)"); |
100 | QDataStream stream(data,IO_ReadOnly); | 102 | QDataStream stream(data,IO_ReadOnly); |
101 | stream >> mPendingName; | 103 | stream >> mPendingName; |
102 | // the format is | 104 | // the format is |
103 | // NAME <EMAIL>:SUBJECT | 105 | // NAME <EMAIL>:SUBJECT |
104 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 106 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
105 | } else { | 107 | } else { |
106 | mPendingData = data; | 108 | mPendingData = data; |
107 | mPendingMessage = msg; | 109 | mPendingMessage = msg; |
108 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); | 110 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); |
109 | } | 111 | } |
110 | 112 | ||
111 | //qDebug("END OpieMail::message "); | 113 | //qDebug("END OpieMail::message "); |
112 | } | 114 | } |
113 | void OpieMail::slotExtAppHandler() | 115 | void OpieMail::slotExtAppHandler() |
114 | { | 116 | { |
115 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); | 117 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); |
116 | } | 118 | } |
117 | void OpieMail::slotwriteMail2(const QString& namemail ) | 119 | void OpieMail::slotwriteMail2(const QString& namemail ) |
118 | { | 120 | { |
119 | //qDebug("OpieMail::slotwriteMail2 "); | 121 | //qDebug("OpieMail::slotwriteMail2 "); |
120 | //qApp->processEvents(); | 122 | //qApp->processEvents(); |
121 | ComposeMail compose( settings, this, 0, true ); | 123 | ComposeMail compose( settings, this, 0, true ); |
122 | if ( !namemail.isEmpty() ) { | 124 | if ( !namemail.isEmpty() ) { |
123 | QString to = namemail; | 125 | QString to = namemail; |
124 | if ( namemail.find( " <") > 1 ) { | 126 | if ( namemail.find( " <") > 1 ) { |
125 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 127 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
126 | } else | 128 | } else |
127 | if ( namemail.find( "<") > 1 ) { | 129 | if ( namemail.find( "<") > 1 ) { |
128 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 130 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
129 | } | 131 | } |
130 | int sub = to.find( ">:"); | 132 | int sub = to.find( ">:"); |
131 | if ( sub > 0 ) { | 133 | if ( sub > 0 ) { |
132 | compose.setTo( to.left(sub+1) ); | 134 | compose.setTo( to.left(sub+1) ); |
133 | compose.setSubject( to.mid(sub+2) ); | 135 | compose.setSubject( to.mid(sub+2) ); |
134 | } else | 136 | } else |
135 | compose.setTo( to ); | 137 | compose.setTo( to ); |
136 | } | 138 | } |
137 | compose.slotAdjustColumns(); | 139 | compose.slotAdjustColumns(); |
138 | #ifndef DESKTOP_VERSION | 140 | #ifndef DESKTOP_VERSION |
139 | compose.showMaximized(); | 141 | compose.showMaximized(); |
140 | #endif | 142 | #endif |
143 | mCurrentComposer = &compose; | ||
141 | compose.exec(); | 144 | compose.exec(); |
145 | mCurrentComposer = 0; | ||
142 | raise(); | 146 | raise(); |
143 | //qDebug("retttich "); | 147 | //qDebug("retttich "); |
144 | } | 148 | } |
145 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 149 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
146 | { | 150 | { |
147 | // qDebug("OpieMail::slotwriteMail "); | 151 | // qDebug("OpieMail::slotwriteMail "); |
148 | ComposeMail compose( settings, this, 0, true ); | 152 | ComposeMail compose( settings, this, 0, true ); |
149 | if (!email.isEmpty()) | 153 | if (!email.isEmpty()) |
150 | { | 154 | { |
151 | if (!name.isEmpty()) | 155 | if (!name.isEmpty()) |
152 | { | 156 | { |
153 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 157 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
154 | } | 158 | } |
155 | else | 159 | else |
156 | { | 160 | { |
157 | compose.setTo(email); | 161 | compose.setTo(email); |
158 | } | 162 | } |
159 | } | 163 | } |
160 | compose.slotAdjustColumns(); | 164 | compose.slotAdjustColumns(); |
161 | #ifndef DESKTOP_VERSION | 165 | #ifndef DESKTOP_VERSION |
162 | compose.showMaximized(); | 166 | compose.showMaximized(); |
163 | #endif | 167 | #endif |
168 | |||
169 | mCurrentComposer = &compose; | ||
164 | compose.exec(); | 170 | compose.exec(); |
171 | mCurrentComposer = 0; | ||
165 | raise(); | 172 | raise(); |
166 | } | 173 | } |
167 | 174 | ||
168 | void OpieMail::slotComposeMail() | 175 | void OpieMail::slotComposeMail() |
169 | { | 176 | { |
170 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 177 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
171 | slotwriteMail2( QString () ); | 178 | slotwriteMail2( QString () ); |
172 | else { | 179 | else { |
173 | if ( mPendingEmail == QString::null ) | 180 | if ( mPendingEmail == QString::null ) |
174 | slotwriteMail2( mPendingName ); | 181 | slotwriteMail2( mPendingName ); |
175 | else | 182 | else |
176 | slotwriteMail( mPendingName, mPendingEmail ); | 183 | slotwriteMail( mPendingName, mPendingEmail ); |
177 | } | 184 | } |
178 | //slotwriteMail(0l,0l); | 185 | //slotwriteMail(0l,0l); |
179 | } | 186 | } |
180 | 187 | ||
181 | void OpieMail::slotSendQueued() | 188 | void OpieMail::slotSendQueued() |
182 | { | 189 | { |
183 | SMTPaccount *smtp = 0; | 190 | SMTPaccount *smtp = 0; |
184 | 191 | ||
185 | QList<Account> list = settings->getAccounts(); | 192 | QList<Account> list = settings->getAccounts(); |
186 | QList<SMTPaccount> smtpList; | 193 | QList<SMTPaccount> smtpList; |
187 | smtpList.setAutoDelete(false); | 194 | smtpList.setAutoDelete(false); |
188 | Account *it; | 195 | Account *it; |
189 | for ( it = list.first(); it; it = list.next() ) | 196 | for ( it = list.first(); it; it = list.next() ) |
190 | { | 197 | { |
191 | if ( it->getType() == MAILLIB::A_SMTP ) | 198 | if ( it->getType() == MAILLIB::A_SMTP ) |
192 | { | 199 | { |
193 | smtp = static_cast<SMTPaccount *>(it); | 200 | smtp = static_cast<SMTPaccount *>(it); |
194 | smtpList.append(smtp); | 201 | smtpList.append(smtp); |
195 | } | 202 | } |
196 | } | 203 | } |
197 | if (smtpList.count()==0) | 204 | if (smtpList.count()==0) |
198 | { | 205 | { |
199 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); | 206 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); |
200 | return; | 207 | return; |
201 | } | 208 | } |
202 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 209 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
203 | return; | 210 | return; |
204 | if (smtpList.count()==1) | 211 | if (smtpList.count()==1) |
205 | { | 212 | { |
206 | smtp = smtpList.at(0); | 213 | smtp = smtpList.at(0); |
207 | } | 214 | } |
208 | else | 215 | else |
209 | { | 216 | { |
210 | smtp = 0; | 217 | smtp = 0; |
211 | selectsmtp selsmtp; | 218 | selectsmtp selsmtp; |
212 | selsmtp.setSelectionlist(&smtpList); | 219 | selsmtp.setSelectionlist(&smtpList); |
213 | #ifndef DESKTOP_VERSION | 220 | #ifndef DESKTOP_VERSION |
214 | selsmtp.showMaximized(); | 221 | selsmtp.showMaximized(); |
215 | #endif | 222 | #endif |
216 | if ( selsmtp.exec() == QDialog::Accepted ) | 223 | if ( selsmtp.exec() == QDialog::Accepted ) |
217 | { | 224 | { |
218 | smtp = selsmtp.selected_smtp(); | 225 | smtp = selsmtp.selected_smtp(); |
219 | } | 226 | } |
220 | } | 227 | } |
221 | if (smtp) | 228 | if (smtp) |
222 | { | 229 | { |
223 | 230 | ||
224 | Global::statusMessage("Sending mails...!"); | 231 | Global::statusMessage("Sending mails...!"); |
225 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 232 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
226 | if ( wrap->flushOutbox() ) | 233 | if ( wrap->flushOutbox() ) |
227 | { | 234 | { |
228 | Global::statusMessage("Mails sent!"); | 235 | Global::statusMessage("Mails sent!"); |
229 | } | 236 | } |
230 | delete wrap; | 237 | delete wrap; |
231 | } | 238 | } |
232 | // pending refresh list view, if outgoing is displayed | 239 | // pending refresh list view, if outgoing is displayed |
233 | } | 240 | } |
234 | 241 | ||
235 | void OpieMail::slotSearchMails() | 242 | void OpieMail::slotSearchMails() |
236 | { | 243 | { |
237 | qDebug("OpieMail::slotSearchMails():not implemented "); | 244 | qDebug("OpieMail::slotSearchMails():not implemented "); |
238 | } | 245 | } |
239 | 246 | ||
240 | void OpieMail::slotEditSettings() | 247 | void OpieMail::slotEditSettings() |
241 | { | 248 | { |
242 | 249 | ||
243 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 250 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
244 | #ifndef DESKTOP_VERSION | 251 | #ifndef DESKTOP_VERSION |
245 | settingsDialog.showMaximized(); | 252 | settingsDialog.showMaximized(); |
246 | #endif | 253 | #endif |
247 | settingsDialog.exec(); | 254 | settingsDialog.exec(); |
248 | 255 | ||
249 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | 256 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); |
250 | // KApplication::execDialog(settingsDialog); | 257 | // KApplication::execDialog(settingsDialog); |
251 | } | 258 | } |
252 | 259 | ||
253 | void OpieMail::slotEditAccounts() | 260 | void OpieMail::slotEditAccounts() |
254 | { | 261 | { |
255 | EditAccounts eaDialog( settings, this, 0, true ); | 262 | EditAccounts eaDialog( settings, this, 0, true ); |
256 | eaDialog.slotAdjustColumns(); | 263 | eaDialog.slotAdjustColumns(); |
257 | #ifndef DESKTOP_VERSION | 264 | #ifndef DESKTOP_VERSION |
258 | eaDialog.showMaximized(); | 265 | eaDialog.showMaximized(); |
259 | #endif | 266 | #endif |
260 | eaDialog.exec(); | 267 | eaDialog.exec(); |
261 | if ( settings ) delete settings; | 268 | if ( settings ) delete settings; |
262 | settings = new Settings(); | 269 | settings = new Settings(); |
263 | 270 | ||
264 | folderView->populate( settings->getAccounts() ); | 271 | folderView->populate( settings->getAccounts() ); |
265 | } | 272 | } |
266 | void OpieMail::replyMail() | 273 | void OpieMail::replyMail() |
267 | { | 274 | { |
268 | 275 | ||
269 | QListViewItem*item = mailView->currentItem(); | 276 | QListViewItem*item = mailView->currentItem(); |
270 | if (!item) return; | 277 | if (!item) return; |
271 | RecMailP mail = ((MailListViewItem*)item)->data(); | 278 | RecMailP mail = ((MailListViewItem*)item)->data(); |
272 | RecBodyP body = folderView->fetchBody(mail); | 279 | RecBodyP body = folderView->fetchBody(mail); |
273 | 280 | ||
274 | QString rtext; | 281 | QString rtext; |
275 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 282 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
276 | .arg( mail->getFrom()) | 283 | .arg( mail->getFrom()) |
277 | .arg( mail->getDate()); | 284 | .arg( mail->getDate()); |
278 | 285 | ||
279 | QString text = body->Bodytext(); | 286 | QString text = body->Bodytext(); |
280 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 287 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
281 | QStringList::Iterator it; | 288 | QStringList::Iterator it; |
282 | for (it = lines.begin(); it != lines.end(); it++) | 289 | for (it = lines.begin(); it != lines.end(); it++) |
283 | { | 290 | { |
284 | rtext += "> " + *it + "\n"; | 291 | rtext += "> " + *it + "\n"; |
285 | } | 292 | } |
286 | rtext += "\n"; | 293 | rtext += "\n"; |
287 | 294 | ||
288 | QString prefix; | 295 | QString prefix; |
289 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 296 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
290 | else prefix = "Re: "; // no i18n on purpose | 297 | else prefix = "Re: "; // no i18n on purpose |
291 | 298 | ||
292 | Settings *settings = new Settings(); | 299 | Settings *settings = new Settings(); |
293 | ComposeMail composer( settings ,this, 0, true); | 300 | ComposeMail composer( settings ,this, 0, true); |
294 | if (mail->Replyto().isEmpty()) { | 301 | if (mail->Replyto().isEmpty()) { |
295 | composer.setTo( mail->getFrom()); | 302 | composer.setTo( mail->getFrom()); |
296 | } else { | 303 | } else { |
297 | composer.setTo( mail->Replyto()); | 304 | composer.setTo( mail->Replyto()); |
298 | } | 305 | } |
299 | composer.setSubject( prefix + mail->getSubject()); | 306 | composer.setSubject( prefix + mail->getSubject()); |
300 | composer.setMessage( rtext ); | 307 | composer.setMessage( rtext ); |
301 | composer.setInReplyTo( mail->Msgid()); | 308 | composer.setInReplyTo( mail->Msgid()); |
302 | composer.setCharset( body->getCharset() ); | 309 | composer.setCharset( body->getCharset() ); |
310 | |||
311 | mCurrentComposer = &composer; | ||
303 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 312 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
304 | { | 313 | { |
305 | mail->Wrapper()->answeredMail(mail); | 314 | mail->Wrapper()->answeredMail(mail); |
306 | } | 315 | } |
316 | mCurrentComposer = 0; | ||
307 | delete settings; | 317 | delete settings; |
308 | 318 | ||
309 | } | 319 | } |
310 | void OpieMail::closeViewMail(ViewMail * vm) | 320 | void OpieMail::closeViewMail(ViewMail * vm) |
311 | { | 321 | { |
312 | vm->hide(); | 322 | vm->hide(); |
313 | } | 323 | } |
314 | 324 | ||
315 | void OpieMail::slotDownloadMail( ) | 325 | void OpieMail::slotDownloadMail( ) |
316 | { | 326 | { |
317 | QListViewItem*item = mailView->currentItem(); | 327 | QListViewItem*item = mailView->currentItem(); |
318 | if (!item ) { | 328 | if (!item ) { |
319 | Global::statusMessage("Error: No item slected!"); | 329 | Global::statusMessage("Error: No item slected!"); |
320 | return; | 330 | return; |
321 | } | 331 | } |
322 | RecMailP mail = ((MailListViewItem*)item)->data(); | 332 | RecMailP mail = ((MailListViewItem*)item)->data(); |
323 | Account * acc = mail->Wrapper()->getAccount(); | 333 | Account * acc = mail->Wrapper()->getAccount(); |
324 | if ( !acc ) { | 334 | if ( !acc ) { |
325 | Global::statusMessage("Mail is already stored locally!"); | 335 | Global::statusMessage("Mail is already stored locally!"); |
326 | return; | 336 | return; |
327 | } | 337 | } |
328 | QString lfName = acc->getLocalFolder(); | 338 | QString lfName = acc->getLocalFolder(); |
329 | //qDebug("local folder " + lfName ); | 339 | //qDebug("local folder " + lfName ); |
330 | if ( lfName.isEmpty() ) | 340 | if ( lfName.isEmpty() ) |
331 | lfName = acc->getAccountName(); | 341 | lfName = acc->getAccountName(); |
332 | AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); | 342 | AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); |
333 | //qDebug("target %d %d ",targetMail,mail->Wrapper() ); | 343 | //qDebug("target %d %d ",targetMail,mail->Wrapper() ); |
334 | if ( targetMail == mail->Wrapper() ) { | 344 | if ( targetMail == mail->Wrapper() ) { |
335 | Global::statusMessage("Mail is already locally stored!"); | 345 | Global::statusMessage("Mail is already locally stored!"); |
336 | return; | 346 | return; |
337 | } | 347 | } |
338 | if ( !targetMail->createMbox(lfName)) { | 348 | if ( !targetMail->createMbox(lfName)) { |
339 | Global::statusMessage("Error creating folder!"); | 349 | Global::statusMessage("Error creating folder!"); |
340 | return; | 350 | return; |
341 | } | 351 | } |
342 | Global::statusMessage("Fetching mail...please wait!"); | 352 | Global::statusMessage("Fetching mail...please wait!"); |
343 | qApp->processEvents(); | 353 | qApp->processEvents(); |
344 | encodedString*st = 0; | 354 | encodedString*st = 0; |
345 | st = mail->Wrapper()->fetchRawBody(mail); | 355 | st = mail->Wrapper()->fetchRawBody(mail); |
346 | if ( st ) { | 356 | if ( st ) { |
347 | targetMail->storeMessage(st->Content(),st->Length(),lfName); | 357 | targetMail->storeMessage(st->Content(),st->Length(),lfName); |
348 | Global::statusMessage("Mail stored in "+ lfName); | 358 | Global::statusMessage("Mail stored in "+ lfName); |
349 | delete st; | 359 | delete st; |
350 | } else { | 360 | } else { |
351 | Global::statusMessage("Error: Cannot fetch mail!"); | 361 | Global::statusMessage("Error: Cannot fetch mail!"); |
352 | } | 362 | } |
353 | } | 363 | } |
354 | 364 | ||
355 | 365 | ||
356 | void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) | 366 | void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) |
357 | { | 367 | { |
358 | QListViewItem*item = mailView->currentItem(); | 368 | QListViewItem*item = mailView->currentItem(); |
359 | if (!item ) { | 369 | if (!item ) { |
360 | closeViewMail(vm); | 370 | closeViewMail(vm); |
361 | return; | 371 | return; |
362 | } | 372 | } |
363 | RecMailP mail = ((MailListViewItem*)item)->data(); | 373 | RecMailP mail = ((MailListViewItem*)item)->data(); |
364 | mail->Wrapper()->deleteMail( mail ); | 374 | mail->Wrapper()->deleteMail( mail ); |
365 | item = item->itemBelow(); | 375 | item = item->itemBelow(); |
366 | if (!item ) { | 376 | if (!item ) { |
367 | closeViewMail(vm); | 377 | closeViewMail(vm); |
368 | return; | 378 | return; |
369 | } | 379 | } |
370 | mailView->setCurrentItem(item); | 380 | mailView->setCurrentItem(item); |
371 | mail = ((MailListViewItem*)item)->data(); | 381 | mail = ((MailListViewItem*)item)->data(); |
372 | RecBodyP body = folderView->fetchBody(mail); | 382 | RecBodyP body = folderView->fetchBody(mail); |
373 | vm->setBody( body ); | 383 | vm->setBody( body ); |
374 | vm->setMail( mail ); | 384 | vm->setMail( mail ); |
375 | } | 385 | } |
376 | void OpieMail::displayNextMail(ViewMail * vm) | 386 | void OpieMail::displayNextMail(ViewMail * vm) |
377 | { | 387 | { |
378 | QListViewItem*item = mailView->currentItem(); | 388 | QListViewItem*item = mailView->currentItem(); |
379 | if (!item) return; | 389 | if (!item) return; |
380 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 390 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
381 | item = item->itemBelow(); | 391 | item = item->itemBelow(); |
382 | if (!item) { | 392 | if (!item) { |
383 | vm->setCaption(i18n("End of List" )); | 393 | vm->setCaption(i18n("End of List" )); |
384 | return; | 394 | return; |
385 | } | 395 | } |
386 | mailView->setCurrentItem(item); | 396 | mailView->setCurrentItem(item); |
387 | RecMailP mail = ((MailListViewItem*)item)->data(); | 397 | RecMailP mail = ((MailListViewItem*)item)->data(); |
388 | RecBodyP body = folderView->fetchBody(mail); | 398 | RecBodyP body = folderView->fetchBody(mail); |
389 | vm->setBody( body ); | 399 | vm->setBody( body ); |
390 | vm->setMail( mail ); | 400 | vm->setMail( mail ); |
391 | } | 401 | } |
392 | void OpieMail::displayMail() | 402 | void OpieMail::displayMail() |
393 | { | 403 | { |
394 | QListViewItem*item = mailView->currentItem(); | 404 | QListViewItem*item = mailView->currentItem(); |
395 | if (!item) return; | 405 | if (!item) return; |
396 | RecMailP mail = ((MailListViewItem*)item)->data(); | 406 | RecMailP mail = ((MailListViewItem*)item)->data(); |
397 | RecBodyP body = folderView->fetchBody(mail); | 407 | RecBodyP body = folderView->fetchBody(mail); |
398 | ViewMail readMail( this,"", Qt::WType_Modal ); | 408 | ViewMail readMail( this,"", Qt::WType_Modal ); |
399 | readMail.setBody( body ); | 409 | readMail.setBody( body ); |
400 | readMail.setMail( mail ); | 410 | readMail.setMail( mail ); |
401 | #ifndef DESKTOP_VERSION | 411 | #ifndef DESKTOP_VERSION |
402 | readMail.showMaximized(); | 412 | readMail.showMaximized(); |
@@ -544,98 +554,119 @@ void OpieMail::mailLeftClicked( QListViewItem *item ) | |||
544 | /* just LEFT button - or tap with stylus on pda */ | 554 | /* just LEFT button - or tap with stylus on pda */ |
545 | //if (button!=1) return; | 555 | //if (button!=1) return; |
546 | if (!item) return; | 556 | if (!item) return; |
547 | if (folderView->currentisDraft()) { | 557 | if (folderView->currentisDraft()) { |
548 | reEditMail(); | 558 | reEditMail(); |
549 | } else { | 559 | } else { |
550 | displayMail(); | 560 | displayMail(); |
551 | } | 561 | } |
552 | } | 562 | } |
553 | 563 | ||
554 | void OpieMail::slotMoveCopyMail() | 564 | void OpieMail::slotMoveCopyMail() |
555 | { | 565 | { |
556 | if (!mailView->currentItem()) return; | 566 | if (!mailView->currentItem()) return; |
557 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 567 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
558 | AbstractMail*targetMail = 0; | 568 | AbstractMail*targetMail = 0; |
559 | QString targetFolder = ""; | 569 | QString targetFolder = ""; |
560 | Selectstore sels; | 570 | Selectstore sels; |
561 | folderView->setupFolderselect(&sels); | 571 | folderView->setupFolderselect(&sels); |
562 | if (!sels.exec()) return; | 572 | if (!sels.exec()) return; |
563 | targetMail = sels.currentMail(); | 573 | targetMail = sels.currentMail(); |
564 | targetFolder = sels.currentFolder(); | 574 | targetFolder = sels.currentFolder(); |
565 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 575 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
566 | targetFolder.isEmpty()) | 576 | targetFolder.isEmpty()) |
567 | { | 577 | { |
568 | return; | 578 | return; |
569 | } | 579 | } |
570 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 580 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
571 | { | 581 | { |
572 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 582 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
573 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 583 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
574 | return; | 584 | return; |
575 | } | 585 | } |
576 | sels.hide(); | 586 | sels.hide(); |
577 | qApp->processEvents(); | 587 | qApp->processEvents(); |
578 | // qDebug("hiding sels "); | 588 | // qDebug("hiding sels "); |
579 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | 589 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); |
580 | folderView->refreshCurrent(); | 590 | folderView->refreshCurrent(); |
581 | } | 591 | } |
582 | 592 | ||
583 | void OpieMail::slotMoveCopyAllMail() | 593 | void OpieMail::slotMoveCopyAllMail() |
584 | { | 594 | { |
585 | 595 | ||
586 | if (!mailView->currentItem()) return; | 596 | if (!mailView->currentItem()) return; |
587 | QValueList<RecMailP> t; | 597 | QValueList<RecMailP> t; |
588 | // 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 ) | 598 | // 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 ) |
589 | { | 599 | { |
590 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 600 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
591 | while ( item ) { | 601 | while ( item ) { |
592 | if ( item->isSelected() ) { | 602 | if ( item->isSelected() ) { |
593 | t.append( item->data() ); | 603 | t.append( item->data() ); |
594 | } | 604 | } |
595 | item = (MailListViewItem*)item->nextSibling(); | 605 | item = (MailListViewItem*)item->nextSibling(); |
596 | } | 606 | } |
597 | } | 607 | } |
598 | // else | 608 | // else |
599 | // return; | 609 | // return; |
600 | if ( t.count() == 0 ) | 610 | if ( t.count() == 0 ) |
601 | return; | 611 | return; |
602 | RecMailP mail = t.first(); | 612 | RecMailP mail = t.first(); |
603 | AbstractMail*targetMail = 0; | 613 | AbstractMail*targetMail = 0; |
604 | QString targetFolder = ""; | 614 | QString targetFolder = ""; |
605 | Selectstore sels; | 615 | Selectstore sels; |
606 | folderView->setupFolderselect(&sels); | 616 | folderView->setupFolderselect(&sels); |
607 | if (!sels.exec()) return; | 617 | if (!sels.exec()) return; |
608 | targetMail = sels.currentMail(); | 618 | targetMail = sels.currentMail(); |
609 | targetFolder = sels.currentFolder(); | 619 | targetFolder = sels.currentFolder(); |
610 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 620 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
611 | targetFolder.isEmpty()) | 621 | targetFolder.isEmpty()) |
612 | { | 622 | { |
613 | return; | 623 | return; |
614 | } | 624 | } |
615 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 625 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
616 | { | 626 | { |
617 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 627 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
618 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 628 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
619 | return; | 629 | return; |
620 | } | 630 | } |
621 | sels.hide(); | 631 | sels.hide(); |
622 | qApp->processEvents(); | 632 | qApp->processEvents(); |
623 | //qDebug("hiding sels "); | 633 | //qDebug("hiding sels "); |
624 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); | 634 | mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); |
625 | folderView->refreshCurrent(); | 635 | folderView->refreshCurrent(); |
626 | } | 636 | } |
627 | 637 | ||
628 | void OpieMail::reEditMail() | 638 | void OpieMail::reEditMail() |
629 | { | 639 | { |
630 | if (!mailView->currentItem()) return; | 640 | if (!mailView->currentItem()) return; |
631 | 641 | ||
632 | ComposeMail compose( settings, this, 0, true ); | 642 | ComposeMail compose( settings, this, 0, true ); |
633 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); | 643 | compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); |
634 | compose.slotAdjustColumns(); | 644 | compose.slotAdjustColumns(); |
635 | #ifndef DESKTOP_VERSION | 645 | #ifndef DESKTOP_VERSION |
636 | compose.showMaximized(); | 646 | compose.showMaximized(); |
637 | #else | 647 | #else |
638 | compose.resize(640,480); | 648 | compose.resize(640,480); |
639 | #endif | 649 | #endif |
650 | mCurrentComposer = &compose; | ||
640 | compose.exec(); | 651 | compose.exec(); |
652 | mCurrentComposer = 0; | ||
653 | } | ||
654 | |||
655 | void OpieMail::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | ||
656 | { | ||
657 | |||
658 | if ( mCurrentComposer ) { | ||
659 | mCurrentComposer->insertAttendees(uid,nameList,emailList,uidList); | ||
660 | } else { | ||
661 | ComposeMail compose( settings, this, 0, true ); | ||
662 | compose.slotAdjustColumns(); | ||
663 | #ifndef DESKTOP_VERSION | ||
664 | compose.showMaximized(); | ||
665 | #endif | ||
666 | mCurrentComposer = &compose; | ||
667 | mCurrentComposer->insertAttendees(uid,nameList,emailList,uidList); | ||
668 | compose.exec(); | ||
669 | mCurrentComposer = 0; | ||
670 | raise(); | ||
671 | } | ||
641 | } | 672 | } |