author | zautrix <zautrix> | 2005-02-28 14:46:07 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-28 14:46:07 (UTC) |
commit | b1f912cbb6a9daf050e94d337de0e0e73417284a (patch) (unidiff) | |
tree | 09220df0ef11ccc32c4eafcc2a63b64056068036 /kmicromail/opiemail.cpp | |
parent | ff810f8f74f6928e664bf52f8e8d128edb8ac5ad (diff) | |
download | kdepimpi-b1f912cbb6a9daf050e94d337de0e0e73417284a.zip kdepimpi-b1f912cbb6a9daf050e94d337de0e0e73417284a.tar.gz kdepimpi-b1f912cbb6a9daf050e94d337de0e0e73417284a.tar.bz2 |
ompi refresh outgoing fix
-rw-r--r-- | kmicromail/opiemail.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index e159b73..f68467c 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -47,385 +47,385 @@ 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 | } | 56 | } |
57 | 57 | ||
58 | OpieMail::~OpieMail() | 58 | OpieMail::~OpieMail() |
59 | { | 59 | { |
60 | if (settings) delete settings; | 60 | if (settings) delete settings; |
61 | if ( tb ) | 61 | if ( tb ) |
62 | delete tb; | 62 | delete tb; |
63 | } | 63 | } |
64 | 64 | ||
65 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 65 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
66 | { | 66 | { |
67 | 67 | ||
68 | } | 68 | } |
69 | #include <stdlib.h> | 69 | #include <stdlib.h> |
70 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 70 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
71 | { | 71 | { |
72 | // copied from old mail2 | 72 | // copied from old mail2 |
73 | static int ii = 0; | 73 | static int ii = 0; |
74 | //qDebug("QCOP CALL ############################# %d ", ii); | 74 | //qDebug("QCOP CALL ############################# %d ", ii); |
75 | //QString mess ( msg ); | 75 | //QString mess ( msg ); |
76 | //qDebug("Message = %s ",mess.latin1()); | 76 | //qDebug("Message = %s ",mess.latin1()); |
77 | ++ii; | 77 | ++ii; |
78 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 78 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
79 | 79 | ||
80 | mPendingEmail = QString::null; | 80 | mPendingEmail = QString::null; |
81 | mPendingName = QString::null; | 81 | mPendingName = QString::null; |
82 | if (msg == "writeMail(QString,QString)") | 82 | if (msg == "writeMail(QString,QString)") |
83 | { | 83 | { |
84 | //qDebug("writeMail(QString,QString) "); | 84 | //qDebug("writeMail(QString,QString) "); |
85 | QDataStream stream(data,IO_ReadOnly); | 85 | QDataStream stream(data,IO_ReadOnly); |
86 | stream >> mPendingName >> mPendingEmail; | 86 | stream >> mPendingName >> mPendingEmail; |
87 | // removing the whitespaces at beginning and end is needed! | 87 | // removing the whitespaces at beginning and end is needed! |
88 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 88 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
89 | } | 89 | } |
90 | else if (msg == "newMail()") | 90 | else if (msg == "newMail()") |
91 | { | 91 | { |
92 | //qDebug("slotComposeMail() "); | 92 | //qDebug("slotComposeMail() "); |
93 | // 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 |
94 | // 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 |
95 | // 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 |
96 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 96 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
97 | // slotComposeMail(); | 97 | // slotComposeMail(); |
98 | } | 98 | } |
99 | else if (msg == "newMail(QString)") | 99 | else if (msg == "newMail(QString)") |
100 | { | 100 | { |
101 | //qDebug(" newMail(QString)"); | 101 | //qDebug(" newMail(QString)"); |
102 | QDataStream stream(data,IO_ReadOnly); | 102 | QDataStream stream(data,IO_ReadOnly); |
103 | stream >> mPendingName; | 103 | stream >> mPendingName; |
104 | // the format is | 104 | // the format is |
105 | // NAME <EMAIL>:SUBJECT | 105 | // NAME <EMAIL>:SUBJECT |
106 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 106 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
107 | } else { | 107 | } else { |
108 | mPendingData = data; | 108 | mPendingData = data; |
109 | mPendingMessage = msg; | 109 | mPendingMessage = msg; |
110 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); | 110 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); |
111 | } | 111 | } |
112 | 112 | ||
113 | //qDebug("END OpieMail::message "); | 113 | //qDebug("END OpieMail::message "); |
114 | } | 114 | } |
115 | void OpieMail::slotExtAppHandler() | 115 | void OpieMail::slotExtAppHandler() |
116 | { | 116 | { |
117 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); | 117 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); |
118 | } | 118 | } |
119 | void OpieMail::slotwriteMail2(const QString& namemail ) | 119 | void OpieMail::slotwriteMail2(const QString& namemail ) |
120 | { | 120 | { |
121 | //qDebug("OpieMail::slotwriteMail2 "); | 121 | //qDebug("OpieMail::slotwriteMail2 "); |
122 | //qApp->processEvents(); | 122 | //qApp->processEvents(); |
123 | ComposeMail compose( settings, this, 0, true ); | 123 | ComposeMail compose( settings, this, 0, true ); |
124 | if ( !namemail.isEmpty() ) { | 124 | if ( !namemail.isEmpty() ) { |
125 | QString to = namemail; | 125 | QString to = namemail; |
126 | if ( namemail.find( " <") > 1 ) { | 126 | if ( namemail.find( " <") > 1 ) { |
127 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 127 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
128 | } else | 128 | } else |
129 | if ( namemail.find( "<") > 1 ) { | 129 | if ( namemail.find( "<") > 1 ) { |
130 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 130 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
131 | } | 131 | } |
132 | int sub = to.find( ">:"); | 132 | int sub = to.find( ">:"); |
133 | if ( sub > 0 ) { | 133 | if ( sub > 0 ) { |
134 | compose.setTo( to.left(sub+1) ); | 134 | compose.setTo( to.left(sub+1) ); |
135 | compose.setSubject( to.mid(sub+2) ); | 135 | compose.setSubject( to.mid(sub+2) ); |
136 | } else | 136 | } else |
137 | compose.setTo( to ); | 137 | compose.setTo( to ); |
138 | } | 138 | } |
139 | compose.slotAdjustColumns(); | 139 | compose.slotAdjustColumns(); |
140 | #ifndef DESKTOP_VERSION | 140 | #ifndef DESKTOP_VERSION |
141 | compose.showMaximized(); | 141 | compose.showMaximized(); |
142 | #endif | 142 | #endif |
143 | mCurrentComposer = &compose; | 143 | mCurrentComposer = &compose; |
144 | compose.exec(); | 144 | compose.exec(); |
145 | mCurrentComposer = 0; | 145 | mCurrentComposer = 0; |
146 | raise(); | 146 | raise(); |
147 | //qDebug("retttich "); | 147 | //qDebug("retttich "); |
148 | } | 148 | } |
149 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 149 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
150 | { | 150 | { |
151 | // qDebug("OpieMail::slotwriteMail "); | 151 | // qDebug("OpieMail::slotwriteMail "); |
152 | ComposeMail compose( settings, this, 0, true ); | 152 | ComposeMail compose( settings, this, 0, true ); |
153 | if (!email.isEmpty()) | 153 | if (!email.isEmpty()) |
154 | { | 154 | { |
155 | if (!name.isEmpty()) | 155 | if (!name.isEmpty()) |
156 | { | 156 | { |
157 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 157 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
158 | } | 158 | } |
159 | else | 159 | else |
160 | { | 160 | { |
161 | compose.setTo(email); | 161 | compose.setTo(email); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | compose.slotAdjustColumns(); | 164 | compose.slotAdjustColumns(); |
165 | #ifndef DESKTOP_VERSION | 165 | #ifndef DESKTOP_VERSION |
166 | compose.showMaximized(); | 166 | compose.showMaximized(); |
167 | #endif | 167 | #endif |
168 | 168 | ||
169 | mCurrentComposer = &compose; | 169 | mCurrentComposer = &compose; |
170 | compose.exec(); | 170 | compose.exec(); |
171 | mCurrentComposer = 0; | 171 | mCurrentComposer = 0; |
172 | raise(); | 172 | raise(); |
173 | } | 173 | } |
174 | 174 | ||
175 | void OpieMail::slotComposeMail() | 175 | void OpieMail::slotComposeMail() |
176 | { | 176 | { |
177 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 177 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
178 | slotwriteMail2( QString () ); | 178 | slotwriteMail2( QString () ); |
179 | else { | 179 | else { |
180 | if ( mPendingEmail == QString::null ) | 180 | if ( mPendingEmail == QString::null ) |
181 | slotwriteMail2( mPendingName ); | 181 | slotwriteMail2( mPendingName ); |
182 | else | 182 | else |
183 | slotwriteMail( mPendingName, mPendingEmail ); | 183 | slotwriteMail( mPendingName, mPendingEmail ); |
184 | } | 184 | } |
185 | //slotwriteMail(0l,0l); | 185 | //slotwriteMail(0l,0l); |
186 | } | 186 | } |
187 | 187 | ||
188 | void OpieMail::slotSendQueued() | 188 | void OpieMail::slotSendQueued() |
189 | { | 189 | { |
190 | SMTPaccount *smtp = 0; | 190 | SMTPaccount *smtp = 0; |
191 | 191 | ||
192 | QList<Account> list = settings->getAccounts(); | 192 | QList<Account> list = settings->getAccounts(); |
193 | QList<SMTPaccount> smtpList; | 193 | QList<SMTPaccount> smtpList; |
194 | smtpList.setAutoDelete(false); | 194 | smtpList.setAutoDelete(false); |
195 | Account *it; | 195 | Account *it; |
196 | for ( it = list.first(); it; it = list.next() ) | 196 | for ( it = list.first(); it; it = list.next() ) |
197 | { | 197 | { |
198 | if ( it->getType() == MAILLIB::A_SMTP ) | 198 | if ( it->getType() == MAILLIB::A_SMTP ) |
199 | { | 199 | { |
200 | smtp = static_cast<SMTPaccount *>(it); | 200 | smtp = static_cast<SMTPaccount *>(it); |
201 | smtpList.append(smtp); | 201 | smtpList.append(smtp); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | if (smtpList.count()==0) | 204 | if (smtpList.count()==0) |
205 | { | 205 | { |
206 | 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")); |
207 | return; | 207 | return; |
208 | } | 208 | } |
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 ) | 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 ) |
210 | return; | 210 | return; |
211 | if (smtpList.count()==1) | 211 | if (smtpList.count()==1) |
212 | { | 212 | { |
213 | smtp = smtpList.at(0); | 213 | smtp = smtpList.at(0); |
214 | } | 214 | } |
215 | else | 215 | else |
216 | { | 216 | { |
217 | smtp = 0; | 217 | smtp = 0; |
218 | selectsmtp selsmtp; | 218 | selectsmtp selsmtp; |
219 | selsmtp.setSelectionlist(&smtpList); | 219 | selsmtp.setSelectionlist(&smtpList); |
220 | #ifndef DESKTOP_VERSION | 220 | #ifndef DESKTOP_VERSION |
221 | selsmtp.showMaximized(); | 221 | selsmtp.showMaximized(); |
222 | #endif | 222 | #endif |
223 | if ( selsmtp.exec() == QDialog::Accepted ) | 223 | if ( selsmtp.exec() == QDialog::Accepted ) |
224 | { | 224 | { |
225 | smtp = selsmtp.selected_smtp(); | 225 | smtp = selsmtp.selected_smtp(); |
226 | } | 226 | } |
227 | } | 227 | } |
228 | if (smtp) | 228 | if (smtp) |
229 | { | 229 | { |
230 | 230 | ||
231 | Global::statusMessage("Sending mails...!"); | 231 | Global::statusMessage("Sending mails...!"); |
232 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 232 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
233 | if ( wrap->flushOutbox() ) | 233 | if ( wrap->flushOutbox() ) |
234 | { | 234 | { |
235 | Global::statusMessage("Mails sent!"); | 235 | Global::statusMessage("Mails sent!"); |
236 | } | 236 | } |
237 | delete wrap; | 237 | delete wrap; |
238 | } | 238 | } |
239 | // pending refresh list view, if outgoing is displayed | 239 | folderView->refreshOutgoing(); |
240 | } | 240 | } |
241 | 241 | ||
242 | void OpieMail::slotSearchMails() | 242 | void OpieMail::slotSearchMails() |
243 | { | 243 | { |
244 | qDebug("OpieMail::slotSearchMails():not implemented "); | 244 | qDebug("OpieMail::slotSearchMails():not implemented "); |
245 | } | 245 | } |
246 | 246 | ||
247 | void OpieMail::slotEditSettings() | 247 | void OpieMail::slotEditSettings() |
248 | { | 248 | { |
249 | 249 | ||
250 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 250 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
251 | #ifndef DESKTOP_VERSION | 251 | #ifndef DESKTOP_VERSION |
252 | settingsDialog.showMaximized(); | 252 | settingsDialog.showMaximized(); |
253 | #endif | 253 | #endif |
254 | settingsDialog.exec(); | 254 | settingsDialog.exec(); |
255 | 255 | ||
256 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | 256 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); |
257 | // KApplication::execDialog(settingsDialog); | 257 | // KApplication::execDialog(settingsDialog); |
258 | } | 258 | } |
259 | 259 | ||
260 | void OpieMail::slotEditAccounts() | 260 | void OpieMail::slotEditAccounts() |
261 | { | 261 | { |
262 | EditAccounts eaDialog( settings, this, 0, true ); | 262 | EditAccounts eaDialog( settings, this, 0, true ); |
263 | eaDialog.slotAdjustColumns(); | 263 | eaDialog.slotAdjustColumns(); |
264 | #ifndef DESKTOP_VERSION | 264 | #ifndef DESKTOP_VERSION |
265 | eaDialog.showMaximized(); | 265 | eaDialog.showMaximized(); |
266 | #endif | 266 | #endif |
267 | eaDialog.exec(); | 267 | eaDialog.exec(); |
268 | if ( settings ) delete settings; | 268 | if ( settings ) delete settings; |
269 | settings = new Settings(); | 269 | settings = new Settings(); |
270 | 270 | ||
271 | folderView->populate( settings->getAccounts() ); | 271 | folderView->populate( settings->getAccounts() ); |
272 | } | 272 | } |
273 | void OpieMail::replyMail() | 273 | void OpieMail::replyMail() |
274 | { | 274 | { |
275 | 275 | ||
276 | QListViewItem*item = mailView->currentItem(); | 276 | QListViewItem*item = mailView->currentItem(); |
277 | if (!item) return; | 277 | if (!item) return; |
278 | RecMailP mail = ((MailListViewItem*)item)->data(); | 278 | RecMailP mail = ((MailListViewItem*)item)->data(); |
279 | RecBodyP body = folderView->fetchBody(mail); | 279 | RecBodyP body = folderView->fetchBody(mail); |
280 | 280 | ||
281 | QString rtext; | 281 | QString rtext; |
282 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 282 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
283 | .arg( mail->getFrom()) | 283 | .arg( mail->getFrom()) |
284 | .arg( mail->getDate()); | 284 | .arg( mail->getDate()); |
285 | 285 | ||
286 | QString text = body->Bodytext(); | 286 | QString text = body->Bodytext(); |
287 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 287 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
288 | QStringList::Iterator it; | 288 | QStringList::Iterator it; |
289 | for (it = lines.begin(); it != lines.end(); it++) | 289 | for (it = lines.begin(); it != lines.end(); it++) |
290 | { | 290 | { |
291 | rtext += "> " + *it + "\n"; | 291 | rtext += "> " + *it + "\n"; |
292 | } | 292 | } |
293 | rtext += "\n"; | 293 | rtext += "\n"; |
294 | 294 | ||
295 | QString prefix; | 295 | QString prefix; |
296 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 296 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
297 | else prefix = "Re: "; // no i18n on purpose | 297 | else prefix = "Re: "; // no i18n on purpose |
298 | 298 | ||
299 | Settings *settings = new Settings(); | 299 | Settings *settings = new Settings(); |
300 | ComposeMail composer( settings ,this, 0, true); | 300 | ComposeMail composer( settings ,this, 0, true); |
301 | if (mail->Replyto().isEmpty()) { | 301 | if (mail->Replyto().isEmpty()) { |
302 | composer.setTo( mail->getFrom()); | 302 | composer.setTo( mail->getFrom()); |
303 | } else { | 303 | } else { |
304 | composer.setTo( mail->Replyto()); | 304 | composer.setTo( mail->Replyto()); |
305 | } | 305 | } |
306 | composer.setSubject( prefix + mail->getSubject()); | 306 | composer.setSubject( prefix + mail->getSubject()); |
307 | composer.setMessage( rtext ); | 307 | composer.setMessage( rtext ); |
308 | composer.setInReplyTo( mail->Msgid()); | 308 | composer.setInReplyTo( mail->Msgid()); |
309 | composer.setCharset( body->getCharset() ); | 309 | composer.setCharset( body->getCharset() ); |
310 | 310 | ||
311 | mCurrentComposer = &composer; | 311 | mCurrentComposer = &composer; |
312 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 312 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
313 | { | 313 | { |
314 | mail->Wrapper()->answeredMail(mail); | 314 | mail->Wrapper()->answeredMail(mail); |
315 | } | 315 | } |
316 | mCurrentComposer = 0; | 316 | mCurrentComposer = 0; |
317 | delete settings; | 317 | delete settings; |
318 | 318 | ||
319 | } | 319 | } |
320 | void OpieMail::closeViewMail(ViewMail * vm) | 320 | void OpieMail::closeViewMail(ViewMail * vm) |
321 | { | 321 | { |
322 | vm->hide(); | 322 | vm->hide(); |
323 | } | 323 | } |
324 | 324 | ||
325 | void OpieMail::slotDownloadMail( ) | 325 | void OpieMail::slotDownloadMail( ) |
326 | { | 326 | { |
327 | QListViewItem*item = mailView->currentItem(); | 327 | QListViewItem*item = mailView->currentItem(); |
328 | if (!item ) { | 328 | if (!item ) { |
329 | Global::statusMessage("Error: No item slected!"); | 329 | Global::statusMessage("Error: No item slected!"); |
330 | return; | 330 | return; |
331 | } | 331 | } |
332 | RecMailP mail = ((MailListViewItem*)item)->data(); | 332 | RecMailP mail = ((MailListViewItem*)item)->data(); |
333 | Account * acc = mail->Wrapper()->getAccount(); | 333 | Account * acc = mail->Wrapper()->getAccount(); |
334 | if ( !acc ) { | 334 | if ( !acc ) { |
335 | Global::statusMessage("Mail is already stored locally!"); | 335 | Global::statusMessage("Mail is already stored locally!"); |
336 | return; | 336 | return; |
337 | } | 337 | } |
338 | QString lfName = acc->getLocalFolder(); | 338 | QString lfName = acc->getLocalFolder(); |
339 | //qDebug("local folder " + lfName ); | 339 | //qDebug("local folder " + lfName ); |
340 | if ( lfName.isEmpty() ) | 340 | if ( lfName.isEmpty() ) |
341 | lfName = acc->getAccountName(); | 341 | lfName = acc->getAccountName(); |
342 | AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); | 342 | AbstractMail* targetMail = folderView->allAccounts()[0]->getWrapper(); |
343 | //qDebug("target %d %d ",targetMail,mail->Wrapper() ); | 343 | //qDebug("target %d %d ",targetMail,mail->Wrapper() ); |
344 | if ( targetMail == mail->Wrapper() ) { | 344 | if ( targetMail == mail->Wrapper() ) { |
345 | Global::statusMessage("Mail is already locally stored!"); | 345 | Global::statusMessage("Mail is already locally stored!"); |
346 | return; | 346 | return; |
347 | } | 347 | } |
348 | if ( !targetMail->createMbox(lfName)) { | 348 | if ( !targetMail->createMbox(lfName)) { |
349 | Global::statusMessage("Error creating folder!"); | 349 | Global::statusMessage("Error creating folder!"); |
350 | return; | 350 | return; |
351 | } | 351 | } |
352 | Global::statusMessage("Fetching mail...please wait!"); | 352 | Global::statusMessage("Fetching mail...please wait!"); |
353 | qApp->processEvents(); | 353 | qApp->processEvents(); |
354 | encodedString*st = 0; | 354 | encodedString*st = 0; |
355 | st = mail->Wrapper()->fetchRawBody(mail); | 355 | st = mail->Wrapper()->fetchRawBody(mail); |
356 | if ( st ) { | 356 | if ( st ) { |
357 | targetMail->storeMessage(st->Content(),st->Length(),lfName); | 357 | targetMail->storeMessage(st->Content(),st->Length(),lfName); |
358 | Global::statusMessage("Mail stored in "+ lfName); | 358 | Global::statusMessage("Mail stored in "+ lfName); |
359 | delete st; | 359 | delete st; |
360 | } else { | 360 | } else { |
361 | Global::statusMessage("Error: Cannot fetch mail!"); | 361 | Global::statusMessage("Error: Cannot fetch mail!"); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) | 366 | void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) |
367 | { | 367 | { |
368 | QListViewItem*item = mailView->currentItem(); | 368 | QListViewItem*item = mailView->currentItem(); |
369 | if (!item ) { | 369 | if (!item ) { |
370 | closeViewMail(vm); | 370 | closeViewMail(vm); |
371 | return; | 371 | return; |
372 | } | 372 | } |
373 | RecMailP mail = ((MailListViewItem*)item)->data(); | 373 | RecMailP mail = ((MailListViewItem*)item)->data(); |
374 | mail->Wrapper()->deleteMail( mail ); | 374 | mail->Wrapper()->deleteMail( mail ); |
375 | item = item->itemBelow(); | 375 | item = item->itemBelow(); |
376 | if (!item ) { | 376 | if (!item ) { |
377 | closeViewMail(vm); | 377 | closeViewMail(vm); |
378 | return; | 378 | return; |
379 | } | 379 | } |
380 | mailView->setCurrentItem(item); | 380 | mailView->setCurrentItem(item); |
381 | mail = ((MailListViewItem*)item)->data(); | 381 | mail = ((MailListViewItem*)item)->data(); |
382 | RecBodyP body = folderView->fetchBody(mail); | 382 | RecBodyP body = folderView->fetchBody(mail); |
383 | vm->setBody( body ); | 383 | vm->setBody( body ); |
384 | vm->setMail( mail ); | 384 | vm->setMail( mail ); |
385 | } | 385 | } |
386 | void OpieMail::displayNextMail(ViewMail * vm) | 386 | void OpieMail::displayNextMail(ViewMail * vm) |
387 | { | 387 | { |
388 | QListViewItem*item = mailView->currentItem(); | 388 | QListViewItem*item = mailView->currentItem(); |
389 | if (!item) return; | 389 | if (!item) return; |
390 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 390 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
391 | item = item->itemBelow(); | 391 | item = item->itemBelow(); |
392 | if (!item) { | 392 | if (!item) { |
393 | vm->setCaption(i18n("End of List" )); | 393 | vm->setCaption(i18n("End of List" )); |
394 | return; | 394 | return; |
395 | } | 395 | } |
396 | mailView->setCurrentItem(item); | 396 | mailView->setCurrentItem(item); |
397 | RecMailP mail = ((MailListViewItem*)item)->data(); | 397 | RecMailP mail = ((MailListViewItem*)item)->data(); |
398 | RecBodyP body = folderView->fetchBody(mail); | 398 | RecBodyP body = folderView->fetchBody(mail); |
399 | vm->setBody( body ); | 399 | vm->setBody( body ); |
400 | vm->setMail( mail ); | 400 | vm->setMail( mail ); |
401 | } | 401 | } |
402 | void OpieMail::displayMail() | 402 | void OpieMail::displayMail() |
403 | { | 403 | { |
404 | QListViewItem*item = mailView->currentItem(); | 404 | QListViewItem*item = mailView->currentItem(); |
405 | if (!item) return; | 405 | if (!item) return; |
406 | RecMailP mail = ((MailListViewItem*)item)->data(); | 406 | RecMailP mail = ((MailListViewItem*)item)->data(); |
407 | RecBodyP body = folderView->fetchBody(mail); | 407 | RecBodyP body = folderView->fetchBody(mail); |
408 | ViewMail readMail( this,"", Qt::WType_Modal ); | 408 | ViewMail readMail( this,"", Qt::WType_Modal ); |
409 | readMail.setBody( body ); | 409 | readMail.setBody( body ); |
410 | readMail.setMail( mail ); | 410 | readMail.setMail( mail ); |
411 | #ifndef DESKTOP_VERSION | 411 | #ifndef DESKTOP_VERSION |
412 | readMail.showMaximized(); | 412 | readMail.showMaximized(); |
413 | #else | 413 | #else |
414 | readMail.resize( 640, 480); | 414 | readMail.resize( 640, 480); |
415 | #endif | 415 | #endif |
416 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); | 416 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); |
417 | connect( &readMail,SIGNAL( deleteAndDisplayNextMail(ViewMail *) ), this, SLOT(deleteAndDisplayNextMail(ViewMail *) ) ); | 417 | connect( &readMail,SIGNAL( deleteAndDisplayNextMail(ViewMail *) ), this, SLOT(deleteAndDisplayNextMail(ViewMail *) ) ); |
418 | connect( &readMail,SIGNAL( signalDownloadMail() ), this, SLOT( slotDownloadMail() ) ); | 418 | connect( &readMail,SIGNAL( signalDownloadMail() ), this, SLOT( slotDownloadMail() ) ); |
419 | 419 | ||
420 | readMail.exec(); | 420 | readMail.exec(); |
421 | 421 | ||
422 | if ( readMail.deleted ) | 422 | if ( readMail.deleted ) |
423 | { | 423 | { |
424 | folderView->refreshCurrent(); | 424 | folderView->refreshCurrent(); |
425 | } | 425 | } |
426 | else | 426 | else |
427 | { | 427 | { |
428 | QListViewItem*item = mailView->currentItem(); | 428 | QListViewItem*item = mailView->currentItem(); |
429 | if (item) | 429 | if (item) |
430 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 430 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
431 | } | 431 | } |