-rw-r--r-- | kmicromail/libmailwrapper/settings.cpp | 2 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 27 | ||||
-rw-r--r-- | kmicromail/opiemail.h | 2 | ||||
-rw-r--r-- | kmicromail/viewmail.cpp | 5 | ||||
-rw-r--r-- | kmicromail/viewmail.h | 1 |
5 files changed, 34 insertions, 3 deletions
diff --git a/kmicromail/libmailwrapper/settings.cpp b/kmicromail/libmailwrapper/settings.cpp index 04afe7c..19093b1 100644 --- a/kmicromail/libmailwrapper/settings.cpp +++ b/kmicromail/libmailwrapper/settings.cpp | |||
@@ -1,182 +1,182 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | 3 | ||
4 | //#include <opie2/odebug.h> | 4 | //#include <opie2/odebug.h> |
5 | #include <kconfig.h> | 5 | #include <kconfig.h> |
6 | 6 | ||
7 | #include <kstandarddirs.h> | 7 | #include <kstandarddirs.h> |
8 | #include "settings.h" | 8 | #include "settings.h" |
9 | //#include "defines.h" | 9 | //#include "defines.h" |
10 | 10 | ||
11 | #define IMAP_PORT "143" | 11 | #define IMAP_PORT "143" |
12 | #define IMAP_SSL_PORT "993" | 12 | #define IMAP_SSL_PORT "993" |
13 | #define SMTP_PORT "25" | 13 | #define SMTP_PORT "25" |
14 | #define SMTP_SSL_PORT "465" | 14 | #define SMTP_SSL_PORT "465" |
15 | #define POP3_PORT "110" | 15 | #define POP3_PORT "110" |
16 | #define POP3_SSL_PORT "995" | 16 | #define POP3_SSL_PORT "995" |
17 | #define NNTP_PORT "119" | 17 | #define NNTP_PORT "119" |
18 | #define NNTP_SSL_PORT "563" | 18 | #define NNTP_SSL_PORT "563" |
19 | 19 | ||
20 | 20 | ||
21 | Settings::Settings() | 21 | Settings::Settings() |
22 | : QObject() | 22 | : QObject() |
23 | { | 23 | { |
24 | accounts.setAutoDelete( true ); ; | 24 | accounts.setAutoDelete( true ); ; |
25 | updateAccounts(); | 25 | updateAccounts(); |
26 | //qDebug("++++++++++++++++++new settings "); | 26 | //qDebug("++++++++++++++++++new settings "); |
27 | } | 27 | } |
28 | 28 | ||
29 | void Settings::checkDirectory() | 29 | void Settings::checkDirectory() |
30 | { | 30 | { |
31 | return; | 31 | return; |
32 | locateLocal("data", "kopiemail" ); | 32 | locateLocal("data", "kopiemail" ); |
33 | /* | 33 | /* |
34 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { | 34 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { |
35 | system( "mkdir -p $HOME/Applications/opiemail" ); | 35 | system( "mkdir -p $HOME/Applications/opiemail" ); |
36 | qDebug("$HOME/Applications/opiemail created "); | 36 | qDebug("$HOME/Applications/opiemail created "); |
37 | } | 37 | } |
38 | */ | 38 | */ |
39 | } | 39 | } |
40 | 40 | ||
41 | QList<Account> Settings::getAccounts() | 41 | QList<Account> Settings::getAccounts() |
42 | { | 42 | { |
43 | return accounts; | 43 | return accounts; |
44 | } | 44 | } |
45 | 45 | ||
46 | void Settings::addAccount( Account *account ) | 46 | void Settings::addAccount( Account *account ) |
47 | { | 47 | { |
48 | accounts.append( account ); | 48 | accounts.append( account ); |
49 | } | 49 | } |
50 | 50 | ||
51 | void Settings::delAccount( Account *account ) | 51 | void Settings::delAccount( Account *account ) |
52 | { | 52 | { |
53 | accounts.remove( account ); | ||
54 | account->remove(); | 53 | account->remove(); |
54 | accounts.remove( account ); | ||
55 | } | 55 | } |
56 | 56 | ||
57 | void Settings::updateAccounts() | 57 | void Settings::updateAccounts() |
58 | { | 58 | { |
59 | accounts.clear(); | 59 | accounts.clear(); |
60 | QDir dir( locateLocal("data", "kopiemail" ) ); | 60 | QDir dir( locateLocal("data", "kopiemail" ) ); |
61 | QStringList::Iterator it; | 61 | QStringList::Iterator it; |
62 | 62 | ||
63 | QStringList imap = dir.entryList( "imap-*" ); | 63 | QStringList imap = dir.entryList( "imap-*" ); |
64 | for ( it = imap.begin(); it != imap.end(); it++ ) { | 64 | for ( it = imap.begin(); it != imap.end(); it++ ) { |
65 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); | 65 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); |
66 | accounts.append( account ); | 66 | accounts.append( account ); |
67 | } | 67 | } |
68 | 68 | ||
69 | QStringList pop3 = dir.entryList( "pop3-*" ); | 69 | QStringList pop3 = dir.entryList( "pop3-*" ); |
70 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { | 70 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { |
71 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); | 71 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); |
72 | accounts.append( account ); | 72 | accounts.append( account ); |
73 | } | 73 | } |
74 | 74 | ||
75 | QStringList smtp = dir.entryList( "smtp-*" ); | 75 | QStringList smtp = dir.entryList( "smtp-*" ); |
76 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { | 76 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { |
77 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); | 77 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); |
78 | accounts.append( account ); | 78 | accounts.append( account ); |
79 | } | 79 | } |
80 | 80 | ||
81 | QStringList nntp = dir.entryList( "nntp-*" ); | 81 | QStringList nntp = dir.entryList( "nntp-*" ); |
82 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { | 82 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { |
83 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); | 83 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); |
84 | accounts.append( account ); | 84 | accounts.append( account ); |
85 | } | 85 | } |
86 | 86 | ||
87 | readAccounts(); | 87 | readAccounts(); |
88 | } | 88 | } |
89 | 89 | ||
90 | void Settings::saveAccounts() | 90 | void Settings::saveAccounts() |
91 | { | 91 | { |
92 | checkDirectory(); | 92 | checkDirectory(); |
93 | Account *it; | 93 | Account *it; |
94 | 94 | ||
95 | for ( it = accounts.first(); it; it = accounts.next() ) { | 95 | for ( it = accounts.first(); it; it = accounts.next() ) { |
96 | it->save(); | 96 | it->save(); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | void Settings::readAccounts() | 100 | void Settings::readAccounts() |
101 | { | 101 | { |
102 | checkDirectory(); | 102 | checkDirectory(); |
103 | Account *it; | 103 | Account *it; |
104 | 104 | ||
105 | for ( it = accounts.first(); it; it = accounts.next() ) { | 105 | for ( it = accounts.first(); it; it = accounts.next() ) { |
106 | it->read(); | 106 | it->read(); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||
110 | Account::Account() | 110 | Account::Account() |
111 | { | 111 | { |
112 | accountName = "changeMe"; | 112 | accountName = "changeMe"; |
113 | type = MAILLIB::A_UNDEFINED; | 113 | type = MAILLIB::A_UNDEFINED; |
114 | ssl = false; | 114 | ssl = false; |
115 | connectionType = 1; | 115 | connectionType = 1; |
116 | offline = false; | 116 | offline = false; |
117 | maxMailSize = 0; | 117 | maxMailSize = 0; |
118 | lastFetch; | 118 | lastFetch; |
119 | leaveOnServer = false; | 119 | leaveOnServer = false; |
120 | } | 120 | } |
121 | 121 | ||
122 | void Account::remove() | 122 | void Account::remove() |
123 | { | 123 | { |
124 | QFile file( getFileName() ); | 124 | QFile file( getFileName() ); |
125 | file.remove(); | 125 | file.remove(); |
126 | } | 126 | } |
127 | 127 | ||
128 | void Account::setPasswordList(const QStringList &str) | 128 | void Account::setPasswordList(const QStringList &str) |
129 | { | 129 | { |
130 | password = ""; | 130 | password = ""; |
131 | int i; | 131 | int i; |
132 | for ( i = 0; i < str.count() ; ++i ) { | 132 | for ( i = 0; i < str.count() ; ++i ) { |
133 | QChar c ( (str[i].toUInt()-131)/(str.count()- (i%3))); | 133 | QChar c ( (str[i].toUInt()-131)/(str.count()- (i%3))); |
134 | password.append( c ); | 134 | password.append( c ); |
135 | } | 135 | } |
136 | //qDebug("password %s ", password.latin1()); | 136 | //qDebug("password %s ", password.latin1()); |
137 | } | 137 | } |
138 | QStringList Account::getPasswordList() | 138 | QStringList Account::getPasswordList() |
139 | { | 139 | { |
140 | int i; | 140 | int i; |
141 | int len = password.length(); | 141 | int len = password.length(); |
142 | QStringList str; | 142 | QStringList str; |
143 | 143 | ||
144 | for ( i = 0; i < len ; ++i ) { | 144 | for ( i = 0; i < len ; ++i ) { |
145 | int val = password.at(i).unicode()*(len-(i%3))+131; | 145 | int val = password.at(i).unicode()*(len-(i%3))+131; |
146 | str.append( QString::number( val ) ); | 146 | str.append( QString::number( val ) ); |
147 | // qDebug("append %s ", str[i].latin1()); | 147 | // qDebug("append %s ", str[i].latin1()); |
148 | } | 148 | } |
149 | return str; | 149 | return str; |
150 | } | 150 | } |
151 | 151 | ||
152 | IMAPaccount::IMAPaccount() | 152 | IMAPaccount::IMAPaccount() |
153 | : Account() | 153 | : Account() |
154 | { | 154 | { |
155 | file = IMAPaccount::getUniqueFileName(); | 155 | file = IMAPaccount::getUniqueFileName(); |
156 | accountName = "New IMAP Account"; | 156 | accountName = "New IMAP Account"; |
157 | ssl = false; | 157 | ssl = false; |
158 | connectionType = 1; | 158 | connectionType = 1; |
159 | type = MAILLIB::A_IMAP; | 159 | type = MAILLIB::A_IMAP; |
160 | port = IMAP_PORT; | 160 | port = IMAP_PORT; |
161 | } | 161 | } |
162 | 162 | ||
163 | IMAPaccount::IMAPaccount( QString filename ) | 163 | IMAPaccount::IMAPaccount( QString filename ) |
164 | : Account() | 164 | : Account() |
165 | { | 165 | { |
166 | file = filename; | 166 | file = filename; |
167 | accountName = "New IMAP Account"; | 167 | accountName = "New IMAP Account"; |
168 | ssl = false; | 168 | ssl = false; |
169 | connectionType = 1; | 169 | connectionType = 1; |
170 | type = MAILLIB::A_IMAP; | 170 | type = MAILLIB::A_IMAP; |
171 | port = IMAP_PORT; | 171 | port = IMAP_PORT; |
172 | } | 172 | } |
173 | 173 | ||
174 | QString IMAPaccount::getUniqueFileName() | 174 | QString IMAPaccount::getUniqueFileName() |
175 | { | 175 | { |
176 | int num = 0; | 176 | int num = 0; |
177 | QString unique; | 177 | QString unique; |
178 | 178 | ||
179 | QDir dir( locateLocal("data", "kopiemail" ) ); | 179 | QDir dir( locateLocal("data", "kopiemail" ) ); |
180 | 180 | ||
181 | QStringList imap = dir.entryList( "imap-*" ); | 181 | QStringList imap = dir.entryList( "imap-*" ); |
182 | do { | 182 | do { |
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index ec192ea..915b3e8 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -174,286 +174,313 @@ void OpieMail::slotSendQueued() | |||
174 | { | 174 | { |
175 | SMTPaccount *smtp = 0; | 175 | SMTPaccount *smtp = 0; |
176 | 176 | ||
177 | QList<Account> list = settings->getAccounts(); | 177 | QList<Account> list = settings->getAccounts(); |
178 | QList<SMTPaccount> smtpList; | 178 | QList<SMTPaccount> smtpList; |
179 | smtpList.setAutoDelete(false); | 179 | smtpList.setAutoDelete(false); |
180 | Account *it; | 180 | Account *it; |
181 | for ( it = list.first(); it; it = list.next() ) | 181 | for ( it = list.first(); it; it = list.next() ) |
182 | { | 182 | { |
183 | if ( it->getType() == MAILLIB::A_SMTP ) | 183 | if ( it->getType() == MAILLIB::A_SMTP ) |
184 | { | 184 | { |
185 | smtp = static_cast<SMTPaccount *>(it); | 185 | smtp = static_cast<SMTPaccount *>(it); |
186 | smtpList.append(smtp); | 186 | smtpList.append(smtp); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | if (smtpList.count()==0) | 189 | if (smtpList.count()==0) |
190 | { | 190 | { |
191 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); | 191 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); |
192 | return; | 192 | return; |
193 | } | 193 | } |
194 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 194 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
195 | return; | 195 | return; |
196 | if (smtpList.count()==1) | 196 | if (smtpList.count()==1) |
197 | { | 197 | { |
198 | smtp = smtpList.at(0); | 198 | smtp = smtpList.at(0); |
199 | } | 199 | } |
200 | else | 200 | else |
201 | { | 201 | { |
202 | smtp = 0; | 202 | smtp = 0; |
203 | selectsmtp selsmtp; | 203 | selectsmtp selsmtp; |
204 | selsmtp.setSelectionlist(&smtpList); | 204 | selsmtp.setSelectionlist(&smtpList); |
205 | #ifndef DESKTOP_VERSION | 205 | #ifndef DESKTOP_VERSION |
206 | selsmtp.showMaximized(); | 206 | selsmtp.showMaximized(); |
207 | #endif | 207 | #endif |
208 | if ( selsmtp.exec() == QDialog::Accepted ) | 208 | if ( selsmtp.exec() == QDialog::Accepted ) |
209 | { | 209 | { |
210 | smtp = selsmtp.selected_smtp(); | 210 | smtp = selsmtp.selected_smtp(); |
211 | } | 211 | } |
212 | } | 212 | } |
213 | if (smtp) | 213 | if (smtp) |
214 | { | 214 | { |
215 | 215 | ||
216 | Global::statusMessage("Sending mails...!"); | 216 | Global::statusMessage("Sending mails...!"); |
217 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 217 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
218 | if ( wrap->flushOutbox() ) | 218 | if ( wrap->flushOutbox() ) |
219 | { | 219 | { |
220 | Global::statusMessage("Mails sent!"); | 220 | Global::statusMessage("Mails sent!"); |
221 | } | 221 | } |
222 | delete wrap; | 222 | delete wrap; |
223 | } | 223 | } |
224 | // pending refresh list view, if outgoing is displayed | 224 | // pending refresh list view, if outgoing is displayed |
225 | } | 225 | } |
226 | 226 | ||
227 | void OpieMail::slotSearchMails() | 227 | void OpieMail::slotSearchMails() |
228 | { | 228 | { |
229 | qDebug("OpieMail::slotSearchMails():not implemented "); | 229 | qDebug("OpieMail::slotSearchMails():not implemented "); |
230 | } | 230 | } |
231 | 231 | ||
232 | void OpieMail::slotEditSettings() | 232 | void OpieMail::slotEditSettings() |
233 | { | 233 | { |
234 | 234 | ||
235 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 235 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
236 | #ifndef DESKTOP_VERSION | 236 | #ifndef DESKTOP_VERSION |
237 | settingsDialog.showMaximized(); | 237 | settingsDialog.showMaximized(); |
238 | #endif | 238 | #endif |
239 | settingsDialog.exec(); | 239 | settingsDialog.exec(); |
240 | 240 | ||
241 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); | 241 | slotSetCodec( KOPrefs::instance()->mCurrentCodec ); |
242 | // KApplication::execDialog(settingsDialog); | 242 | // KApplication::execDialog(settingsDialog); |
243 | } | 243 | } |
244 | 244 | ||
245 | void OpieMail::slotEditAccounts() | 245 | void OpieMail::slotEditAccounts() |
246 | { | 246 | { |
247 | EditAccounts eaDialog( settings, this, 0, true ); | 247 | EditAccounts eaDialog( settings, this, 0, true ); |
248 | eaDialog.slotAdjustColumns(); | 248 | eaDialog.slotAdjustColumns(); |
249 | #ifndef DESKTOP_VERSION | 249 | #ifndef DESKTOP_VERSION |
250 | eaDialog.showMaximized(); | 250 | eaDialog.showMaximized(); |
251 | #endif | 251 | #endif |
252 | eaDialog.exec(); | 252 | eaDialog.exec(); |
253 | if ( settings ) delete settings; | 253 | if ( settings ) delete settings; |
254 | settings = new Settings(); | 254 | settings = new Settings(); |
255 | 255 | ||
256 | folderView->populate( settings->getAccounts() ); | 256 | folderView->populate( settings->getAccounts() ); |
257 | } | 257 | } |
258 | void OpieMail::replyMail() | 258 | void OpieMail::replyMail() |
259 | { | 259 | { |
260 | 260 | ||
261 | QListViewItem*item = mailView->currentItem(); | 261 | QListViewItem*item = mailView->currentItem(); |
262 | if (!item) return; | 262 | if (!item) return; |
263 | RecMailP mail = ((MailListViewItem*)item)->data(); | 263 | RecMailP mail = ((MailListViewItem*)item)->data(); |
264 | RecBodyP body = folderView->fetchBody(mail); | 264 | RecBodyP body = folderView->fetchBody(mail); |
265 | 265 | ||
266 | QString rtext; | 266 | QString rtext; |
267 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 267 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
268 | .arg( mail->getFrom()) | 268 | .arg( mail->getFrom()) |
269 | .arg( mail->getDate()); | 269 | .arg( mail->getDate()); |
270 | 270 | ||
271 | QString text = body->Bodytext(); | 271 | QString text = body->Bodytext(); |
272 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 272 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
273 | QStringList::Iterator it; | 273 | QStringList::Iterator it; |
274 | for (it = lines.begin(); it != lines.end(); it++) | 274 | for (it = lines.begin(); it != lines.end(); it++) |
275 | { | 275 | { |
276 | rtext += "> " + *it + "\n"; | 276 | rtext += "> " + *it + "\n"; |
277 | } | 277 | } |
278 | rtext += "\n"; | 278 | rtext += "\n"; |
279 | 279 | ||
280 | QString prefix; | 280 | QString prefix; |
281 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 281 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
282 | else prefix = "Re: "; // no i18n on purpose | 282 | else prefix = "Re: "; // no i18n on purpose |
283 | 283 | ||
284 | Settings *settings = new Settings(); | 284 | Settings *settings = new Settings(); |
285 | ComposeMail composer( settings ,this, 0, true); | 285 | ComposeMail composer( settings ,this, 0, true); |
286 | if (mail->Replyto().isEmpty()) { | 286 | if (mail->Replyto().isEmpty()) { |
287 | composer.setTo( mail->getFrom()); | 287 | composer.setTo( mail->getFrom()); |
288 | } else { | 288 | } else { |
289 | composer.setTo( mail->Replyto()); | 289 | composer.setTo( mail->Replyto()); |
290 | } | 290 | } |
291 | composer.setSubject( prefix + mail->getSubject()); | 291 | composer.setSubject( prefix + mail->getSubject()); |
292 | composer.setMessage( rtext ); | 292 | composer.setMessage( rtext ); |
293 | composer.setInReplyTo( mail->Msgid()); | 293 | composer.setInReplyTo( mail->Msgid()); |
294 | composer.setCharset( body->getCharset() ); | 294 | composer.setCharset( body->getCharset() ); |
295 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 295 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
296 | { | 296 | { |
297 | mail->Wrapper()->answeredMail(mail); | 297 | mail->Wrapper()->answeredMail(mail); |
298 | } | 298 | } |
299 | delete settings; | 299 | delete settings; |
300 | 300 | ||
301 | } | 301 | } |
302 | void OpieMail::closeViewMail(ViewMail * vm) | ||
303 | { | ||
304 | vm->hide(); | ||
305 | } | ||
306 | void OpieMail::deleteAndDisplayNextMail(ViewMail * vm) | ||
307 | { | ||
308 | QListViewItem*item = mailView->currentItem(); | ||
309 | if (!item ) { | ||
310 | closeViewMail(vm); | ||
311 | return; | ||
312 | } | ||
313 | RecMailP mail = ((MailListViewItem*)item)->data(); | ||
314 | mail->Wrapper()->deleteMail( mail ); | ||
315 | item = item->itemBelow(); | ||
316 | if (!item ) { | ||
317 | closeViewMail(vm); | ||
318 | return; | ||
319 | } | ||
320 | mailView->setCurrentItem(item); | ||
321 | mail = ((MailListViewItem*)item)->data(); | ||
322 | RecBodyP body = folderView->fetchBody(mail); | ||
323 | vm->setBody( body ); | ||
324 | vm->setMail( mail ); | ||
325 | } | ||
302 | void OpieMail::displayNextMail(ViewMail * vm) | 326 | void OpieMail::displayNextMail(ViewMail * vm) |
303 | { | 327 | { |
304 | QListViewItem*item = mailView->currentItem(); | 328 | QListViewItem*item = mailView->currentItem(); |
305 | if (!item) return; | 329 | if (!item) return; |
330 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | ||
306 | item = item->itemBelow(); | 331 | item = item->itemBelow(); |
307 | if (!item) { | 332 | if (!item) { |
308 | vm->setCaption(i18n("End of List" )); | 333 | vm->setCaption(i18n("End of List" )); |
309 | return; | 334 | return; |
310 | } | 335 | } |
311 | mailView->setCurrentItem(item); | 336 | mailView->setCurrentItem(item); |
312 | RecMailP mail = ((MailListViewItem*)item)->data(); | 337 | RecMailP mail = ((MailListViewItem*)item)->data(); |
313 | RecBodyP body = folderView->fetchBody(mail); | 338 | RecBodyP body = folderView->fetchBody(mail); |
314 | vm->setBody( body ); | 339 | vm->setBody( body ); |
315 | vm->setMail( mail ); | 340 | vm->setMail( mail ); |
316 | } | 341 | } |
317 | void OpieMail::displayMail() | 342 | void OpieMail::displayMail() |
318 | { | 343 | { |
319 | QListViewItem*item = mailView->currentItem(); | 344 | QListViewItem*item = mailView->currentItem(); |
320 | if (!item) return; | 345 | if (!item) return; |
321 | RecMailP mail = ((MailListViewItem*)item)->data(); | 346 | RecMailP mail = ((MailListViewItem*)item)->data(); |
322 | RecBodyP body = folderView->fetchBody(mail); | 347 | RecBodyP body = folderView->fetchBody(mail); |
323 | ViewMail readMail( this,"", Qt::WType_Modal ); | 348 | ViewMail readMail( this,"", Qt::WType_Modal ); |
324 | readMail.setBody( body ); | 349 | readMail.setBody( body ); |
325 | readMail.setMail( mail ); | 350 | readMail.setMail( mail ); |
326 | #ifndef DESKTOP_VERSION | 351 | #ifndef DESKTOP_VERSION |
327 | readMail.showMaximized(); | 352 | readMail.showMaximized(); |
328 | #else | 353 | #else |
329 | readMail.resize( 640, 480); | 354 | readMail.resize( 640, 480); |
330 | #endif | 355 | #endif |
331 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); | 356 | connect( &readMail,SIGNAL( showNextMail(ViewMail *) ), this, SLOT( displayNextMail(ViewMail *) ) ); |
357 | connect( &readMail,SIGNAL( deleteAndDisplayNextMail(ViewMail *) ), this, SLOT(deleteAndDisplayNextMail(ViewMail *) ) ); | ||
358 | |||
332 | readMail.exec(); | 359 | readMail.exec(); |
333 | 360 | ||
334 | if ( readMail.deleted ) | 361 | if ( readMail.deleted ) |
335 | { | 362 | { |
336 | folderView->refreshCurrent(); | 363 | folderView->refreshCurrent(); |
337 | } | 364 | } |
338 | else | 365 | else |
339 | { | 366 | { |
340 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); | 367 | ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); |
341 | } | 368 | } |
342 | } | 369 | } |
343 | void OpieMail::slotGetAllMail() | 370 | void OpieMail::slotGetAllMail() |
344 | { | 371 | { |
345 | QListViewItem * item = folderView->firstChild(); | 372 | QListViewItem * item = folderView->firstChild(); |
346 | while ( item ){ | 373 | while ( item ){ |
347 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 374 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
348 | item = item->nextSibling (); | 375 | item = item->nextSibling (); |
349 | } | 376 | } |
350 | } | 377 | } |
351 | void OpieMail::slotGetMail() | 378 | void OpieMail::slotGetMail() |
352 | { | 379 | { |
353 | QListViewItem * item = folderView->currentItem(); | 380 | QListViewItem * item = folderView->currentItem(); |
354 | if ( ! item ) return; | 381 | if ( ! item ) return; |
355 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); | 382 | ((AccountViewItem *)item)->contextMenuSelected( 101 ); |
356 | } | 383 | } |
357 | void OpieMail::slotDeleteMail() | 384 | void OpieMail::slotDeleteMail() |
358 | { | 385 | { |
359 | if (!mailView->currentItem()) return; | 386 | if (!mailView->currentItem()) return; |
360 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 387 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
361 | 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 ) | 388 | 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 ) |
362 | { | 389 | { |
363 | mail->Wrapper()->deleteMail( mail ); | 390 | mail->Wrapper()->deleteMail( mail ); |
364 | folderView->refreshCurrent(); | 391 | folderView->refreshCurrent(); |
365 | } | 392 | } |
366 | } | 393 | } |
367 | void OpieMail::slotDeleteAllMail() | 394 | void OpieMail::slotDeleteAllMail() |
368 | { | 395 | { |
369 | 396 | ||
370 | QValueList<RecMailP> t; | 397 | QValueList<RecMailP> t; |
371 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 398 | if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
372 | { | 399 | { |
373 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 400 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
374 | while ( item ) { | 401 | while ( item ) { |
375 | if ( item->isSelected() ) { | 402 | if ( item->isSelected() ) { |
376 | t.append( item->data() ); | 403 | t.append( item->data() ); |
377 | } | 404 | } |
378 | item = (MailListViewItem*)item->nextSibling(); | 405 | item = (MailListViewItem*)item->nextSibling(); |
379 | } | 406 | } |
380 | } | 407 | } |
381 | else | 408 | else |
382 | return; | 409 | return; |
383 | if ( t.count() == 0 ) | 410 | if ( t.count() == 0 ) |
384 | return; | 411 | return; |
385 | RecMailP mail = t.first(); | 412 | RecMailP mail = t.first(); |
386 | mail->Wrapper()->deleteMailList(t); | 413 | mail->Wrapper()->deleteMailList(t); |
387 | folderView->refreshCurrent(); | 414 | folderView->refreshCurrent(); |
388 | 415 | ||
389 | 416 | ||
390 | } | 417 | } |
391 | void OpieMail::clearSelection() | 418 | void OpieMail::clearSelection() |
392 | { | 419 | { |
393 | mailView->clearSelection(); | 420 | mailView->clearSelection(); |
394 | 421 | ||
395 | } | 422 | } |
396 | 423 | ||
397 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 424 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
398 | { | 425 | { |
399 | if (!mailView->currentItem()) return; | 426 | if (!mailView->currentItem()) return; |
400 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 427 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
401 | /* just the RIGHT button - or hold on pda */ | 428 | /* just the RIGHT button - or hold on pda */ |
402 | if (button!=2) {return;} | 429 | if (button!=2) {return;} |
403 | if (!item) return; | 430 | if (!item) return; |
404 | QPopupMenu *m = new QPopupMenu(0); | 431 | QPopupMenu *m = new QPopupMenu(0); |
405 | if (m) | 432 | if (m) |
406 | { | 433 | { |
407 | if (mailtype==MAILLIB::A_NNTP) { | 434 | if (mailtype==MAILLIB::A_NNTP) { |
408 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); | 435 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); |
409 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 436 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
410 | m->insertSeparator(); | 437 | m->insertSeparator(); |
411 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); | 438 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); |
412 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 439 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
413 | } else { | 440 | } else { |
414 | if (folderView->currentisDraft()) { | 441 | if (folderView->currentisDraft()) { |
415 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); | 442 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); |
416 | } | 443 | } |
417 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); | 444 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); |
418 | m->insertSeparator(); | 445 | m->insertSeparator(); |
419 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); | 446 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); |
420 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); | 447 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); |
421 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); | 448 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); |
422 | m->insertSeparator(); | 449 | m->insertSeparator(); |
423 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); | 450 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); |
424 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); | 451 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); |
425 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 452 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
426 | } | 453 | } |
427 | m->setFocus(); | 454 | m->setFocus(); |
428 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 455 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
429 | delete m; | 456 | delete m; |
430 | } | 457 | } |
431 | } | 458 | } |
432 | 459 | ||
433 | void OpieMail::slotShowFolders( bool show ) | 460 | void OpieMail::slotShowFolders( bool show ) |
434 | { | 461 | { |
435 | if ( show && folderView->isHidden() ) | 462 | if ( show && folderView->isHidden() ) |
436 | { | 463 | { |
437 | folderView->show(); | 464 | folderView->show(); |
438 | } | 465 | } |
439 | else if ( !show && !folderView->isHidden() ) | 466 | else if ( !show && !folderView->isHidden() ) |
440 | { | 467 | { |
441 | folderView->hide(); | 468 | folderView->hide(); |
442 | } | 469 | } |
443 | } | 470 | } |
444 | 471 | ||
445 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 472 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
446 | { | 473 | { |
447 | MailListViewItem*item = 0; | 474 | MailListViewItem*item = 0; |
448 | mailView->clear(); | 475 | mailView->clear(); |
449 | 476 | ||
450 | QValueList<RecMailP>::ConstIterator it; | 477 | QValueList<RecMailP>::ConstIterator it; |
451 | for (it = list.begin(); it != list.end();++it) | 478 | for (it = list.begin(); it != list.end();++it) |
452 | { | 479 | { |
453 | item = new MailListViewItem(mailView,item); | 480 | item = new MailListViewItem(mailView,item); |
454 | item->storeData((*it)); | 481 | item->storeData((*it)); |
455 | item->showEntry(); | 482 | item->showEntry(); |
456 | } | 483 | } |
457 | mailView->setSorting ( 4, false ); | 484 | mailView->setSorting ( 4, false ); |
458 | } | 485 | } |
459 | 486 | ||
diff --git a/kmicromail/opiemail.h b/kmicromail/opiemail.h index 30968a7..a81a34c 100644 --- a/kmicromail/opiemail.h +++ b/kmicromail/opiemail.h | |||
@@ -1,58 +1,60 @@ | |||
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 | 11 | ||
12 | class OpieMail : public MainWindow | 12 | class OpieMail : public MainWindow |
13 | { | 13 | { |
14 | Q_OBJECT | 14 | Q_OBJECT |
15 | 15 | ||
16 | public: | 16 | public: |
17 | OpieMail( QWidget *parent = 0, const char *name = 0 ); | 17 | OpieMail( QWidget *parent = 0, const char *name = 0 ); |
18 | virtual ~OpieMail(); | 18 | virtual ~OpieMail(); |
19 | static QString appName() { return QString::fromLatin1("kopiemail"); } | 19 | static QString appName() { return QString::fromLatin1("kopiemail"); } |
20 | 20 | ||
21 | public slots: | 21 | public slots: |
22 | virtual void slotwriteMail(const QString&name,const QString&email); | 22 | virtual void slotwriteMail(const QString&name,const QString&email); |
23 | virtual void slotwriteMail2(const QString&nameemail); | 23 | virtual void slotwriteMail2(const QString&nameemail); |
24 | virtual void slotComposeMail(); | 24 | virtual void slotComposeMail(); |
25 | virtual void slotExtAppHandler(); | 25 | virtual void slotExtAppHandler(); |
26 | virtual void appMessage(const QCString &msg, const QByteArray &data); | 26 | virtual void appMessage(const QCString &msg, const QByteArray &data); |
27 | virtual void message(const QCString &msg, const QByteArray &data); | 27 | virtual void message(const QCString &msg, const QByteArray &data); |
28 | protected slots: | 28 | protected slots: |
29 | virtual void deleteAndDisplayNextMail(ViewMail * vm); | ||
29 | virtual void displayNextMail(ViewMail * vm); | 30 | virtual void displayNextMail(ViewMail * vm); |
30 | virtual void slotSendQueued(); | 31 | virtual void slotSendQueued(); |
31 | virtual void slotSearchMails(); | 32 | virtual void slotSearchMails(); |
32 | virtual void slotEditSettings(); | 33 | virtual void slotEditSettings(); |
33 | virtual void slotEditAccounts(); | 34 | virtual void slotEditAccounts(); |
34 | virtual void displayMail(); | 35 | virtual void displayMail(); |
35 | virtual void replyMail(); | 36 | virtual void replyMail(); |
36 | virtual void slotDeleteMail(); | 37 | virtual void slotDeleteMail(); |
37 | virtual void slotGetMail(); | 38 | virtual void slotGetMail(); |
38 | virtual void slotGetAllMail(); | 39 | virtual void slotGetAllMail(); |
39 | virtual void slotDeleteAllMail(); | 40 | virtual void slotDeleteAllMail(); |
40 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); | 41 | virtual void mailHold(int, QListViewItem *,const QPoint&,int); |
41 | virtual void slotShowFolders( bool show ); | 42 | virtual void slotShowFolders( bool show ); |
42 | virtual void refreshMailView(const QValueList<RecMailP>&); | 43 | virtual void refreshMailView(const QValueList<RecMailP>&); |
43 | virtual void mailLeftClicked( QListViewItem * ); | 44 | virtual void mailLeftClicked( QListViewItem * ); |
44 | virtual void slotMoveCopyMail(); | 45 | virtual void slotMoveCopyMail(); |
45 | virtual void slotMoveCopyAllMail(); | 46 | virtual void slotMoveCopyAllMail(); |
46 | virtual void reEditMail(); | 47 | virtual void reEditMail(); |
47 | void clearSelection(); | 48 | void clearSelection(); |
48 | 49 | ||
49 | private: | 50 | private: |
51 | void closeViewMail(ViewMail * vm); | ||
50 | QString mPendingEmail; | 52 | QString mPendingEmail; |
51 | QString mPendingName; | 53 | QString mPendingName; |
52 | QByteArray mPendingData; | 54 | QByteArray mPendingData; |
53 | QCString mPendingMessage; | 55 | QCString mPendingMessage; |
54 | Settings *settings; | 56 | Settings *settings; |
55 | 57 | ||
56 | }; | 58 | }; |
57 | 59 | ||
58 | #endif | 60 | #endif |
diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index 60c764c..6d88cad 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp | |||
@@ -381,153 +381,154 @@ void ViewMail::setText() | |||
381 | } | 381 | } |
382 | 382 | ||
383 | 383 | ||
384 | ViewMail::~ViewMail() | 384 | ViewMail::~ViewMail() |
385 | { | 385 | { |
386 | m_recMail->Wrapper()->cleanMimeCache(); | 386 | m_recMail->Wrapper()->cleanMimeCache(); |
387 | hide(); | 387 | hide(); |
388 | } | 388 | } |
389 | 389 | ||
390 | void ViewMail::hide() | 390 | void ViewMail::hide() |
391 | { | 391 | { |
392 | QWidget::hide(); | 392 | QWidget::hide(); |
393 | 393 | ||
394 | if (_inLoop) | 394 | if (_inLoop) |
395 | { | 395 | { |
396 | _inLoop = false; | 396 | _inLoop = false; |
397 | qApp->exit_loop(); | 397 | qApp->exit_loop(); |
398 | 398 | ||
399 | } | 399 | } |
400 | 400 | ||
401 | } | 401 | } |
402 | 402 | ||
403 | void ViewMail::exec() | 403 | void ViewMail::exec() |
404 | { | 404 | { |
405 | show(); | 405 | show(); |
406 | 406 | ||
407 | if (!_inLoop) | 407 | if (!_inLoop) |
408 | { | 408 | { |
409 | _inLoop = true; | 409 | _inLoop = true; |
410 | qApp->enter_loop(); | 410 | qApp->enter_loop(); |
411 | } | 411 | } |
412 | 412 | ||
413 | } | 413 | } |
414 | 414 | ||
415 | QString ViewMail::deHtml(const QString &string) | 415 | QString ViewMail::deHtml(const QString &string) |
416 | { | 416 | { |
417 | QString string_ = string; | 417 | QString string_ = string; |
418 | string_.replace(QRegExp("&"), "&"); | 418 | string_.replace(QRegExp("&"), "&"); |
419 | string_.replace(QRegExp("<"), "<"); | 419 | string_.replace(QRegExp("<"), "<"); |
420 | string_.replace(QRegExp(">"), ">"); | 420 | string_.replace(QRegExp(">"), ">"); |
421 | string_.replace(QRegExp("\\n"), "<br>"); | 421 | string_.replace(QRegExp("\\n"), "<br>"); |
422 | return string_; | 422 | return string_; |
423 | } | 423 | } |
424 | 424 | ||
425 | void ViewMail::slotReply() | 425 | void ViewMail::slotReply() |
426 | { | 426 | { |
427 | if (!m_gotBody) | 427 | if (!m_gotBody) |
428 | { | 428 | { |
429 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); | 429 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); |
430 | return; | 430 | return; |
431 | } | 431 | } |
432 | 432 | ||
433 | QString rtext; | 433 | QString rtext; |
434 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 434 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
435 | .arg( m_mail[0] ) | 435 | .arg( m_mail[0] ) |
436 | .arg( m_mail[3] ); | 436 | .arg( m_mail[3] ); |
437 | 437 | ||
438 | QString text = m_mail[2]; | 438 | QString text = m_mail[2]; |
439 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 439 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
440 | QStringList::Iterator it; | 440 | QStringList::Iterator it; |
441 | for (it = lines.begin(); it != lines.end(); it++) | 441 | for (it = lines.begin(); it != lines.end(); it++) |
442 | { | 442 | { |
443 | rtext += "> " + *it + "\n"; | 443 | rtext += "> " + *it + "\n"; |
444 | } | 444 | } |
445 | rtext += "\n"; | 445 | rtext += "\n"; |
446 | 446 | ||
447 | QString prefix; | 447 | QString prefix; |
448 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 448 | if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
449 | else prefix = "Re: "; // no i18n on purpose | 449 | else prefix = "Re: "; // no i18n on purpose |
450 | 450 | ||
451 | Settings *settings = new Settings(); | 451 | Settings *settings = new Settings(); |
452 | ComposeMail composer( settings ,this, 0, true); | 452 | ComposeMail composer( settings ,this, 0, true); |
453 | if (m_recMail->Replyto().isEmpty()) { | 453 | if (m_recMail->Replyto().isEmpty()) { |
454 | composer.setTo(m_recMail->getFrom()); | 454 | composer.setTo(m_recMail->getFrom()); |
455 | } else { | 455 | } else { |
456 | composer.setTo(m_recMail->Replyto()); | 456 | composer.setTo(m_recMail->Replyto()); |
457 | } | 457 | } |
458 | composer.setSubject( prefix + m_mail[1] ); | 458 | composer.setSubject( prefix + m_mail[1] ); |
459 | composer.setMessage( rtext ); | 459 | composer.setMessage( rtext ); |
460 | composer.setInReplyTo(m_recMail->Msgid()); | 460 | composer.setInReplyTo(m_recMail->Msgid()); |
461 | composer.setCharset( m_body->getCharset() ); | 461 | composer.setCharset( m_body->getCharset() ); |
462 | 462 | ||
463 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) | 463 | if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) |
464 | { | 464 | { |
465 | m_recMail->Wrapper()->answeredMail(m_recMail); | 465 | m_recMail->Wrapper()->answeredMail(m_recMail); |
466 | } | 466 | } |
467 | delete settings; | 467 | delete settings; |
468 | } | 468 | } |
469 | 469 | ||
470 | void ViewMail::slotForward() | 470 | void ViewMail::slotForward() |
471 | { | 471 | { |
472 | if (!m_gotBody) | 472 | if (!m_gotBody) |
473 | { | 473 | { |
474 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); | 474 | QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); |
475 | return; | 475 | return; |
476 | } | 476 | } |
477 | 477 | ||
478 | QString ftext; | 478 | QString ftext; |
479 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 479 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
480 | .arg( m_mail[0] ); | 480 | .arg( m_mail[0] ); |
481 | if (!m_mail[3].isNull()) | 481 | if (!m_mail[3].isNull()) |
482 | ftext += QString("Date: %1\n") | 482 | ftext += QString("Date: %1\n") |
483 | .arg( m_mail[3] ); | 483 | .arg( m_mail[3] ); |
484 | if (!m_mail[0].isNull()) | 484 | if (!m_mail[0].isNull()) |
485 | ftext += QString("From: %1\n") | 485 | ftext += QString("From: %1\n") |
486 | .arg( m_mail[0] ); | 486 | .arg( m_mail[0] ); |
487 | if (!m_mail[1].isNull()) | 487 | if (!m_mail[1].isNull()) |
488 | ftext += QString("Subject: %1\n") | 488 | ftext += QString("Subject: %1\n") |
489 | .arg( m_mail[1] ); | 489 | .arg( m_mail[1] ); |
490 | 490 | ||
491 | ftext += QString("\n%1\n") | 491 | ftext += QString("\n%1\n") |
492 | .arg( m_mail[2]); | 492 | .arg( m_mail[2]); |
493 | 493 | ||
494 | ftext += QString("----- End forwarded message -----\n"); | 494 | ftext += QString("----- End forwarded message -----\n"); |
495 | 495 | ||
496 | Settings *settings = new Settings(); | 496 | Settings *settings = new Settings(); |
497 | ComposeMail composer( settings ,this, 0, true); | 497 | ComposeMail composer( settings ,this, 0, true); |
498 | composer.setSubject( "Fwd: " + m_mail[1] ); | 498 | composer.setSubject( "Fwd: " + m_mail[1] ); |
499 | composer.setMessage( ftext ); | 499 | composer.setMessage( ftext ); |
500 | if ( QDialog::Accepted == KApplication::execDialog( &composer )) | 500 | if ( QDialog::Accepted == KApplication::execDialog( &composer )) |
501 | { | 501 | { |
502 | } | 502 | } |
503 | } | 503 | } |
504 | 504 | ||
505 | void ViewMail::slotDeleteMail( ) | 505 | void ViewMail::slotDeleteMail( ) |
506 | { | 506 | { |
507 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 507 | if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
508 | { | 508 | { |
509 | m_recMail->Wrapper()->deleteMail( m_recMail ); | 509 | emit deleteAndDisplayNextMail( this); |
510 | hide(); | 510 | //m_recMail->Wrapper()->deleteMail( m_recMail ); |
511 | //hide(); | ||
511 | deleted = true; | 512 | deleted = true; |
512 | } | 513 | } |
513 | } | 514 | } |
514 | 515 | ||
515 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) | 516 | MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) |
516 | : QDialog(parent,name,modal) | 517 | : QDialog(parent,name,modal) |
517 | { | 518 | { |
518 | QVBoxLayout*dlglayout = new QVBoxLayout(this); | 519 | QVBoxLayout*dlglayout = new QVBoxLayout(this); |
519 | dlglayout->setSpacing(2); | 520 | dlglayout->setSpacing(2); |
520 | dlglayout->setMargin(1); | 521 | dlglayout->setMargin(1); |
521 | //m_imageview = new Opie::MM::OImageScrollView(this); | 522 | //m_imageview = new Opie::MM::OImageScrollView(this); |
522 | //dlglayout->addWidget(m_imageview); | 523 | //dlglayout->addWidget(m_imageview); |
523 | } | 524 | } |
524 | 525 | ||
525 | MailImageDlg::~MailImageDlg() | 526 | MailImageDlg::~MailImageDlg() |
526 | { | 527 | { |
527 | } | 528 | } |
528 | 529 | ||
529 | void MailImageDlg::setName(const QString&fname) | 530 | void MailImageDlg::setName(const QString&fname) |
530 | { | 531 | { |
531 | qDebug("viewmail.cpp: MailImageDlg::setName Pending"); | 532 | qDebug("viewmail.cpp: MailImageDlg::setName Pending"); |
532 | // m_imageview->setImage(fname); | 533 | // m_imageview->setImage(fname); |
533 | } | 534 | } |
diff --git a/kmicromail/viewmail.h b/kmicromail/viewmail.h index c2c2ce3..d85b8b2 100644 --- a/kmicromail/viewmail.h +++ b/kmicromail/viewmail.h | |||
@@ -1,88 +1,89 @@ | |||
1 | #ifndef VIEWMAIL_H | 1 | #ifndef VIEWMAIL_H |
2 | #define VIEWMAIL_H | 2 | #define VIEWMAIL_H |
3 | 3 | ||
4 | #include "viewmailbase.h" | 4 | #include "viewmailbase.h" |
5 | #include <libmailwrapper/mailtypes.h> | 5 | #include <libmailwrapper/mailtypes.h> |
6 | 6 | ||
7 | #include <qdialog.h> | 7 | #include <qdialog.h> |
8 | 8 | ||
9 | #include <qlistview.h> | 9 | #include <qlistview.h> |
10 | #include <qmap.h> | 10 | #include <qmap.h> |
11 | #include <qstringlist.h> | 11 | #include <qstringlist.h> |
12 | #include <qvaluelist.h> | 12 | #include <qvaluelist.h> |
13 | 13 | ||
14 | //namespace Opie { namespace MM { class OImageScrollView; } } | 14 | //namespace Opie { namespace MM { class OImageScrollView; } } |
15 | 15 | ||
16 | class AttachItem : public QListViewItem | 16 | class AttachItem : public QListViewItem |
17 | { | 17 | { |
18 | public: | 18 | public: |
19 | AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 19 | AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
20 | const QString&fsize,int num,const QValueList<int>&path); | 20 | const QString&fsize,int num,const QValueList<int>&path); |
21 | AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 21 | AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
22 | const QString&fsize,int num,const QValueList<int>&path); | 22 | const QString&fsize,int num,const QValueList<int>&path); |
23 | int Partnumber() { return _partNum; } | 23 | int Partnumber() { return _partNum; } |
24 | bool isParentof(const QValueList<int>&path); | 24 | bool isParentof(const QValueList<int>&path); |
25 | 25 | ||
26 | private: | 26 | private: |
27 | int _partNum; | 27 | int _partNum; |
28 | /* needed for a better display of attachments */ | 28 | /* needed for a better display of attachments */ |
29 | QValueList<int> _path; | 29 | QValueList<int> _path; |
30 | }; | 30 | }; |
31 | 31 | ||
32 | class ViewMail : public ViewMailBase | 32 | class ViewMail : public ViewMailBase |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | 35 | ||
36 | public: | 36 | public: |
37 | ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0); | 37 | ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = 0); |
38 | ~ViewMail(); | 38 | ~ViewMail(); |
39 | 39 | ||
40 | void hide(); | 40 | void hide(); |
41 | void exec(); | 41 | void exec(); |
42 | void setMail(const RecMailP&mail ); | 42 | void setMail(const RecMailP&mail ); |
43 | void setBody(const RecBodyP&body); | 43 | void setBody(const RecBodyP&body); |
44 | bool deleted; | 44 | bool deleted; |
45 | signals: | 45 | signals: |
46 | void showNextMail(ViewMail*); | 46 | void showNextMail(ViewMail*); |
47 | void deleteAndDisplayNextMail(ViewMail *); | ||
47 | protected: | 48 | protected: |
48 | QString deHtml(const QString &string); | 49 | QString deHtml(const QString &string); |
49 | AttachItem* searchParent(const QValueList<int>&path); | 50 | AttachItem* searchParent(const QValueList<int>&path); |
50 | AttachItem* lastChild(AttachItem*parent); | 51 | AttachItem* lastChild(AttachItem*parent); |
51 | 52 | ||
52 | protected slots: | 53 | protected slots: |
53 | void slotNextMail() { emit showNextMail(this); }; | 54 | void slotNextMail() { emit showNextMail(this); }; |
54 | void slotReply(); | 55 | void slotReply(); |
55 | void slotForward(); | 56 | void slotForward(); |
56 | void setText(); | 57 | void setText(); |
57 | void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); | 58 | void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); |
58 | void slotDeleteMail( ); | 59 | void slotDeleteMail( ); |
59 | void slotShowHtml( bool ); | 60 | void slotShowHtml( bool ); |
60 | 61 | ||
61 | private: | 62 | private: |
62 | void readConfig(); | 63 | void readConfig(); |
63 | 64 | ||
64 | bool _inLoop; | 65 | bool _inLoop; |
65 | QString m_mailHtml; | 66 | QString m_mailHtml; |
66 | bool m_gotBody; | 67 | bool m_gotBody; |
67 | RecBodyP m_body; | 68 | RecBodyP m_body; |
68 | RecMailP m_recMail; | 69 | RecMailP m_recMail; |
69 | bool m_showHtml; | 70 | bool m_showHtml; |
70 | 71 | ||
71 | // 0 from 1 subject 2 bodytext 3 date | 72 | // 0 from 1 subject 2 bodytext 3 date |
72 | QMap <int,QString> m_mail; | 73 | QMap <int,QString> m_mail; |
73 | // 0 to 1 cc 2 bcc | 74 | // 0 to 1 cc 2 bcc |
74 | QMap <int,QStringList> m_mail2; | 75 | QMap <int,QStringList> m_mail2; |
75 | }; | 76 | }; |
76 | 77 | ||
77 | class MailImageDlg:public QDialog | 78 | class MailImageDlg:public QDialog |
78 | { | 79 | { |
79 | Q_OBJECT | 80 | Q_OBJECT |
80 | public: | 81 | public: |
81 | MailImageDlg(const QString&,QWidget *parent = 0, const char *name = 0, bool modal = true, WFlags f = 0); | 82 | MailImageDlg(const QString&,QWidget *parent = 0, const char *name = 0, bool modal = true, WFlags f = 0); |
82 | ~MailImageDlg(); | 83 | ~MailImageDlg(); |
83 | void setName(const QString&); | 84 | void setName(const QString&); |
84 | protected: | 85 | protected: |
85 | //Opie::MM::OImageScrollView*m_imageview; | 86 | //Opie::MM::OImageScrollView*m_imageview; |
86 | }; | 87 | }; |
87 | 88 | ||
88 | #endif | 89 | #endif |