summaryrefslogtreecommitdiffabout
path: root/kmicromail
Unidiff
Diffstat (limited to 'kmicromail') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/settings.cpp2
-rw-r--r--kmicromail/opiemail.cpp27
-rw-r--r--kmicromail/opiemail.h2
-rw-r--r--kmicromail/viewmail.cpp5
-rw-r--r--kmicromail/viewmail.h1
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,501 +1,501 @@
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
21Settings::Settings() 21Settings::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
29void Settings::checkDirectory() 29void 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
41QList<Account> Settings::getAccounts() 41QList<Account> Settings::getAccounts()
42{ 42{
43 return accounts; 43 return accounts;
44} 44}
45 45
46void Settings::addAccount( Account *account ) 46void Settings::addAccount( Account *account )
47{ 47{
48 accounts.append( account ); 48 accounts.append( account );
49} 49}
50 50
51void Settings::delAccount( Account *account ) 51void Settings::delAccount( Account *account )
52{ 52{
53 accounts.remove( account );
54 account->remove(); 53 account->remove();
54 accounts.remove( account );
55} 55}
56 56
57void Settings::updateAccounts() 57void 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
90void Settings::saveAccounts() 90void 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
100void Settings::readAccounts() 100void 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
110Account::Account() 110Account::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
122void Account::remove() 122void Account::remove()
123{ 123{
124 QFile file( getFileName() ); 124 QFile file( getFileName() );
125 file.remove(); 125 file.remove();
126} 126}
127 127
128void Account::setPasswordList(const QStringList &str) 128void 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}
138QStringList Account::getPasswordList() 138QStringList 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
152IMAPaccount::IMAPaccount() 152IMAPaccount::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
163IMAPaccount::IMAPaccount( QString filename ) 163IMAPaccount::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
174QString IMAPaccount::getUniqueFileName() 174QString 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 {
183 unique.setNum( num++ ); 183 unique.setNum( num++ );
184 } while ( imap.contains( "imap-" + unique ) > 0 ); 184 } while ( imap.contains( "imap-" + unique ) > 0 );
185 185
186 return unique; 186 return unique;
187} 187}
188 188
189void IMAPaccount::read() 189void IMAPaccount::read()
190{ 190{
191 KConfig *conf = new KConfig( getFileName() ); 191 KConfig *conf = new KConfig( getFileName() );
192 conf->setGroup( "IMAP Account" ); 192 conf->setGroup( "IMAP Account" );
193 accountName = conf->readEntry( "Account","" ); 193 accountName = conf->readEntry( "Account","" );
194 if (accountName.isNull()) accountName = ""; 194 if (accountName.isNull()) accountName = "";
195 server = conf->readEntry( "Server","" ); 195 server = conf->readEntry( "Server","" );
196 if (server.isNull()) server=""; 196 if (server.isNull()) server="";
197 port = conf->readEntry( "Port","" ); 197 port = conf->readEntry( "Port","" );
198 if (port.isNull()) port="143"; 198 if (port.isNull()) port="143";
199 connectionType = conf->readNumEntry( "ConnectionType" ); 199 connectionType = conf->readNumEntry( "ConnectionType" );
200 ssl = conf->readBoolEntry( "SSL",false ); 200 ssl = conf->readBoolEntry( "SSL",false );
201 user = conf->readEntry( "User","" ); 201 user = conf->readEntry( "User","" );
202 if (user.isNull()) user = ""; 202 if (user.isNull()) user = "";
203 //password = conf->readEntryCrypt( "Password","" ); 203 //password = conf->readEntryCrypt( "Password","" );
204 setPasswordList( conf->readListEntry( "FolderHistory")); 204 setPasswordList( conf->readListEntry( "FolderHistory"));
205 if (password.isNull()) password = ""; 205 if (password.isNull()) password = "";
206 prefix = conf->readEntry("MailPrefix",""); 206 prefix = conf->readEntry("MailPrefix","");
207 if (prefix.isNull()) prefix = ""; 207 if (prefix.isNull()) prefix = "";
208 offline = conf->readBoolEntry("Offline",false); 208 offline = conf->readBoolEntry("Offline",false);
209 localFolder = conf->readEntry( "LocalFolder" ); 209 localFolder = conf->readEntry( "LocalFolder" );
210 maxMailSize = conf->readNumEntry( "MaxSize",0 ); 210 maxMailSize = conf->readNumEntry( "MaxSize",0 );
211 int lf = conf->readNumEntry( "LastFetch",0 ); 211 int lf = conf->readNumEntry( "LastFetch",0 );
212 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 212 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
213 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); 213 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false);
214 if ( lf < 0 ) lf = 0; 214 if ( lf < 0 ) lf = 0;
215 lastFetch = dt.addSecs( lf ); 215 lastFetch = dt.addSecs( lf );
216 delete conf; 216 delete conf;
217} 217}
218 218
219void IMAPaccount::save() 219void IMAPaccount::save()
220{ 220{
221 221
222 Settings::checkDirectory(); 222 Settings::checkDirectory();
223 223
224 KConfig *conf = new KConfig( getFileName() ); 224 KConfig *conf = new KConfig( getFileName() );
225 conf->setGroup( "IMAP Account" ); 225 conf->setGroup( "IMAP Account" );
226 conf->writeEntry( "Account", accountName ); 226 conf->writeEntry( "Account", accountName );
227 conf->writeEntry( "Server", server ); 227 conf->writeEntry( "Server", server );
228 conf->writeEntry( "Port", port ); 228 conf->writeEntry( "Port", port );
229 conf->writeEntry( "SSL", ssl ); 229 conf->writeEntry( "SSL", ssl );
230 conf->writeEntry( "ConnectionType", connectionType ); 230 conf->writeEntry( "ConnectionType", connectionType );
231 conf->writeEntry( "User", user ); 231 conf->writeEntry( "User", user );
232 //conf->writeEntryCrypt( "Password", password ); 232 //conf->writeEntryCrypt( "Password", password );
233 conf->writeEntry( "FolderHistory",getPasswordList() ); 233 conf->writeEntry( "FolderHistory",getPasswordList() );
234 conf->writeEntry( "MailPrefix",prefix); 234 conf->writeEntry( "MailPrefix",prefix);
235 conf->writeEntry( "Offline",offline); 235 conf->writeEntry( "Offline",offline);
236 conf->writeEntry( "LocalFolder", localFolder ); 236 conf->writeEntry( "LocalFolder", localFolder );
237 conf->writeEntry( "MaxSize", maxMailSize ); 237 conf->writeEntry( "MaxSize", maxMailSize );
238 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 238 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
239 int lf = dt.secsTo ( lastFetch ); 239 int lf = dt.secsTo ( lastFetch );
240 conf->writeEntry( "LastFetch", lf ); 240 conf->writeEntry( "LastFetch", lf );
241 conf->writeEntry( "LeaveOnServer", leaveOnServer); 241 conf->writeEntry( "LeaveOnServer", leaveOnServer);
242 conf->sync(); 242 conf->sync();
243 delete conf; 243 delete conf;
244} 244}
245 245
246 246
247QString IMAPaccount::getFileName() 247QString IMAPaccount::getFileName()
248{ 248{
249 return locateLocal("data", "kopiemail" ) +"/imap-" + file; 249 return locateLocal("data", "kopiemail" ) +"/imap-" + file;
250} 250}
251 251
252POP3account::POP3account() 252POP3account::POP3account()
253 : Account() 253 : Account()
254{ 254{
255 file = POP3account::getUniqueFileName(); 255 file = POP3account::getUniqueFileName();
256 accountName = "New POP3 Account"; 256 accountName = "New POP3 Account";
257 ssl = false; 257 ssl = false;
258 connectionType = 1; 258 connectionType = 1;
259 type = MAILLIB::A_POP3; 259 type = MAILLIB::A_POP3;
260 port = POP3_PORT; 260 port = POP3_PORT;
261} 261}
262 262
263POP3account::POP3account( QString filename ) 263POP3account::POP3account( QString filename )
264 : Account() 264 : Account()
265{ 265{
266 file = filename; 266 file = filename;
267 accountName = "New POP3 Account"; 267 accountName = "New POP3 Account";
268 ssl = false; 268 ssl = false;
269 connectionType = 1; 269 connectionType = 1;
270 type = MAILLIB::A_POP3; 270 type = MAILLIB::A_POP3;
271 port = POP3_PORT; 271 port = POP3_PORT;
272} 272}
273 273
274QString POP3account::getUniqueFileName() 274QString POP3account::getUniqueFileName()
275{ 275{
276 int num = 0; 276 int num = 0;
277 QString unique; 277 QString unique;
278 278
279 QDir dir( locateLocal("data", "kopiemail" ) ); 279 QDir dir( locateLocal("data", "kopiemail" ) );
280 280
281 QStringList imap = dir.entryList( "pop3-*" ); 281 QStringList imap = dir.entryList( "pop3-*" );
282 do { 282 do {
283 unique.setNum( num++ ); 283 unique.setNum( num++ );
284 } while ( imap.contains( "pop3-" + unique ) > 0 ); 284 } while ( imap.contains( "pop3-" + unique ) > 0 );
285 285
286 return unique; 286 return unique;
287} 287}
288 288
289void POP3account::read() 289void POP3account::read()
290{ 290{
291 KConfig *conf = new KConfig( getFileName()); 291 KConfig *conf = new KConfig( getFileName());
292 conf->setGroup( "POP3 Account" ); 292 conf->setGroup( "POP3 Account" );
293 accountName = conf->readEntry( "Account" ); 293 accountName = conf->readEntry( "Account" );
294 server = conf->readEntry( "Server" ); 294 server = conf->readEntry( "Server" );
295 port = conf->readEntry( "Port" ); 295 port = conf->readEntry( "Port" );
296 ssl = conf->readBoolEntry( "SSL" ); 296 ssl = conf->readBoolEntry( "SSL" );
297 connectionType = conf->readNumEntry( "ConnectionType" ); 297 connectionType = conf->readNumEntry( "ConnectionType" );
298 user = conf->readEntry( "User" ); 298 user = conf->readEntry( "User" );
299 //password = conf->readEntryCrypt( "Password" ); 299 //password = conf->readEntryCrypt( "Password" );
300 setPasswordList( conf->readListEntry( "FolderHistory")); 300 setPasswordList( conf->readListEntry( "FolderHistory"));
301 offline = conf->readBoolEntry("Offline",false); 301 offline = conf->readBoolEntry("Offline",false);
302 localFolder = conf->readEntry( "LocalFolder" ); 302 localFolder = conf->readEntry( "LocalFolder" );
303 maxMailSize = conf->readNumEntry( "MaxSize",0 ); 303 maxMailSize = conf->readNumEntry( "MaxSize",0 );
304 int lf = conf->readNumEntry( "LastFetch",0 ); 304 int lf = conf->readNumEntry( "LastFetch",0 );
305 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 305 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
306 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); 306 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false);
307 lastFetch = dt.addSecs( lf ); 307 lastFetch = dt.addSecs( lf );
308 delete conf; 308 delete conf;
309} 309}
310 310
311void POP3account::save() 311void POP3account::save()
312{ 312{
313 Settings::checkDirectory(); 313 Settings::checkDirectory();
314 314
315 KConfig *conf = new KConfig( getFileName() ); 315 KConfig *conf = new KConfig( getFileName() );
316 conf->setGroup( "POP3 Account" ); 316 conf->setGroup( "POP3 Account" );
317 conf->writeEntry( "Account", accountName ); 317 conf->writeEntry( "Account", accountName );
318 conf->writeEntry( "Server", server ); 318 conf->writeEntry( "Server", server );
319 conf->writeEntry( "Port", port ); 319 conf->writeEntry( "Port", port );
320 conf->writeEntry( "SSL", ssl ); 320 conf->writeEntry( "SSL", ssl );
321 conf->writeEntry( "ConnectionType", connectionType ); 321 conf->writeEntry( "ConnectionType", connectionType );
322 conf->writeEntry( "User", user ); 322 conf->writeEntry( "User", user );
323 //conf->writeEntryCrypt( "Password", password ); 323 //conf->writeEntryCrypt( "Password", password );
324 conf->writeEntry( "FolderHistory",getPasswordList() ); 324 conf->writeEntry( "FolderHistory",getPasswordList() );
325 conf->writeEntry( "Offline",offline); 325 conf->writeEntry( "Offline",offline);
326 conf->writeEntry( "LocalFolder", localFolder ); 326 conf->writeEntry( "LocalFolder", localFolder );
327 conf->writeEntry( "MaxSize", maxMailSize ); 327 conf->writeEntry( "MaxSize", maxMailSize );
328 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 328 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
329 int lf = dt.secsTo ( lastFetch ); 329 int lf = dt.secsTo ( lastFetch );
330 conf->writeEntry( "LastFetch", lf ); 330 conf->writeEntry( "LastFetch", lf );
331 conf->writeEntry( "LeaveOnServer", leaveOnServer); 331 conf->writeEntry( "LeaveOnServer", leaveOnServer);
332 conf->sync(); 332 conf->sync();
333 delete conf; 333 delete conf;
334} 334}
335 335
336 336
337QString POP3account::getFileName() 337QString POP3account::getFileName()
338{ 338{
339 return locateLocal("data", "kopiemail" ) +"/pop3-" + file; 339 return locateLocal("data", "kopiemail" ) +"/pop3-" + file;
340} 340}
341 341
342SMTPaccount::SMTPaccount() 342SMTPaccount::SMTPaccount()
343 : Account() 343 : Account()
344{ 344{
345 file = SMTPaccount::getUniqueFileName(); 345 file = SMTPaccount::getUniqueFileName();
346 accountName = "New SMTP Account"; 346 accountName = "New SMTP Account";
347 ssl = false; 347 ssl = false;
348 connectionType = 1; 348 connectionType = 1;
349 login = false; 349 login = false;
350 useCC = false; 350 useCC = false;
351 useBCC = false; 351 useBCC = false;
352 useReply = false; 352 useReply = false;
353 type = MAILLIB::A_SMTP; 353 type = MAILLIB::A_SMTP;
354 port = SMTP_PORT; 354 port = SMTP_PORT;
355} 355}
356 356
357SMTPaccount::SMTPaccount( QString filename ) 357SMTPaccount::SMTPaccount( QString filename )
358 : Account() 358 : Account()
359{ 359{
360 file = filename; 360 file = filename;
361 accountName = "New SMTP Account"; 361 accountName = "New SMTP Account";
362 ssl = false; 362 ssl = false;
363 connectionType = 1; 363 connectionType = 1;
364 login = false; 364 login = false;
365 type = MAILLIB::A_SMTP; 365 type = MAILLIB::A_SMTP;
366 port = SMTP_PORT; 366 port = SMTP_PORT;
367} 367}
368 368
369QString SMTPaccount::getUniqueFileName() 369QString SMTPaccount::getUniqueFileName()
370{ 370{
371 int num = 0; 371 int num = 0;
372 QString unique; 372 QString unique;
373 373
374 QDir dir( locateLocal("data", "kopiemail" ) ); 374 QDir dir( locateLocal("data", "kopiemail" ) );
375 375
376 QStringList imap = dir.entryList( "smtp-*" ); 376 QStringList imap = dir.entryList( "smtp-*" );
377 do { 377 do {
378 unique.setNum( num++ ); 378 unique.setNum( num++ );
379 } while ( imap.contains( "smtp-" + unique ) > 0 ); 379 } while ( imap.contains( "smtp-" + unique ) > 0 );
380 380
381 return unique; 381 return unique;
382} 382}
383 383
384void SMTPaccount::read() 384void SMTPaccount::read()
385{ 385{
386 KConfig *conf = new KConfig( getFileName() ); 386 KConfig *conf = new KConfig( getFileName() );
387 conf->setGroup( "SMTP Account" ); 387 conf->setGroup( "SMTP Account" );
388 accountName = conf->readEntry( "Account" ); 388 accountName = conf->readEntry( "Account" );
389 server = conf->readEntry( "Server" ); 389 server = conf->readEntry( "Server" );
390 port = conf->readEntry( "Port" ); 390 port = conf->readEntry( "Port" );
391 ssl = conf->readBoolEntry( "SSL" ); 391 ssl = conf->readBoolEntry( "SSL" );
392 connectionType = conf->readNumEntry( "ConnectionType" ); 392 connectionType = conf->readNumEntry( "ConnectionType" );
393 login = conf->readBoolEntry( "Login" ); 393 login = conf->readBoolEntry( "Login" );
394 user = conf->readEntry( "User" ); 394 user = conf->readEntry( "User" );
395 //password = conf->readEntryCrypt( "Password" ); 395 //password = conf->readEntryCrypt( "Password" );
396 setPasswordList( conf->readListEntry( "FolderHistory")); 396 setPasswordList( conf->readListEntry( "FolderHistory"));
397 delete conf; 397 delete conf;
398} 398}
399 399
400void SMTPaccount::save() 400void SMTPaccount::save()
401{ 401{
402 Settings::checkDirectory(); 402 Settings::checkDirectory();
403 403
404 KConfig *conf = new KConfig( getFileName() ); 404 KConfig *conf = new KConfig( getFileName() );
405 conf->setGroup( "SMTP Account" ); 405 conf->setGroup( "SMTP Account" );
406 conf->writeEntry( "Account", accountName ); 406 conf->writeEntry( "Account", accountName );
407 conf->writeEntry( "Server", server ); 407 conf->writeEntry( "Server", server );
408 conf->writeEntry( "Port", port ); 408 conf->writeEntry( "Port", port );
409 conf->writeEntry( "SSL", ssl ); 409 conf->writeEntry( "SSL", ssl );
410 conf->writeEntry( "ConnectionType", connectionType ); 410 conf->writeEntry( "ConnectionType", connectionType );
411 conf->writeEntry( "Login", login ); 411 conf->writeEntry( "Login", login );
412 conf->writeEntry( "User", user ); 412 conf->writeEntry( "User", user );
413 //conf->writeEntryCrypt( "Password", password ); 413 //conf->writeEntryCrypt( "Password", password );
414 conf->writeEntry( "FolderHistory",getPasswordList() ); 414 conf->writeEntry( "FolderHistory",getPasswordList() );
415 conf->sync(); 415 conf->sync();
416 delete conf; 416 delete conf;
417} 417}
418 418
419 419
420QString SMTPaccount::getFileName() 420QString SMTPaccount::getFileName()
421{ 421{
422 return locateLocal("data", "kopiemail" ) +"/smtp-" + file; 422 return locateLocal("data", "kopiemail" ) +"/smtp-" + file;
423} 423}
424 424
425NNTPaccount::NNTPaccount() 425NNTPaccount::NNTPaccount()
426 : Account() 426 : Account()
427{ 427{
428 file = NNTPaccount::getUniqueFileName(); 428 file = NNTPaccount::getUniqueFileName();
429 accountName = "New NNTP Account"; 429 accountName = "New NNTP Account";
430 ssl = false; 430 ssl = false;
431 login = false; 431 login = false;
432 type = MAILLIB::A_NNTP; 432 type = MAILLIB::A_NNTP;
433 port = NNTP_PORT; 433 port = NNTP_PORT;
434} 434}
435 435
436NNTPaccount::NNTPaccount( QString filename ) 436NNTPaccount::NNTPaccount( QString filename )
437 : Account() 437 : Account()
438{ 438{
439 file = filename; 439 file = filename;
440 accountName = "New NNTP Account"; 440 accountName = "New NNTP Account";
441 ssl = false; 441 ssl = false;
442 login = false; 442 login = false;
443 type = MAILLIB::A_NNTP; 443 type = MAILLIB::A_NNTP;
444 port = NNTP_PORT; 444 port = NNTP_PORT;
445} 445}
446 446
447QString NNTPaccount::getUniqueFileName() 447QString NNTPaccount::getUniqueFileName()
448{ 448{
449 int num = 0; 449 int num = 0;
450 QString unique; 450 QString unique;
451 451
452 QDir dir( locateLocal("data", "kopiemail" ) ); 452 QDir dir( locateLocal("data", "kopiemail" ) );
453 453
454 QStringList imap = dir.entryList( "nntp-*" ); 454 QStringList imap = dir.entryList( "nntp-*" );
455 do { 455 do {
456 unique.setNum( num++ ); 456 unique.setNum( num++ );
457 } while ( imap.contains( "nntp-" + unique ) > 0 ); 457 } while ( imap.contains( "nntp-" + unique ) > 0 );
458 458
459 return unique; 459 return unique;
460} 460}
461 461
462void NNTPaccount::read() 462void NNTPaccount::read()
463{ 463{
464 KConfig *conf = new KConfig( getFileName() ); 464 KConfig *conf = new KConfig( getFileName() );
465 conf->setGroup( "NNTP Account" ); 465 conf->setGroup( "NNTP Account" );
466 accountName = conf->readEntry( "Account" ); 466 accountName = conf->readEntry( "Account" );
467 server = conf->readEntry( "Server" ); 467 server = conf->readEntry( "Server" );
468 port = conf->readEntry( "Port" ); 468 port = conf->readEntry( "Port" );
469 ssl = conf->readBoolEntry( "SSL" ); 469 ssl = conf->readBoolEntry( "SSL" );
470 login = conf->readBoolEntry( "Login" ); 470 login = conf->readBoolEntry( "Login" );
471 user = conf->readEntry( "User" ); 471 user = conf->readEntry( "User" );
472 //password = conf->readEntryCrypt( "Password" ); 472 //password = conf->readEntryCrypt( "Password" );
473 setPasswordList( conf->readListEntry( "FolderHistory")); 473 setPasswordList( conf->readListEntry( "FolderHistory"));
474 subscribedGroups = conf->readListEntry( "Subscribed"); 474 subscribedGroups = conf->readListEntry( "Subscribed");
475 delete conf; 475 delete conf;
476} 476}
477 477
478void NNTPaccount::save() 478void NNTPaccount::save()
479{ 479{
480 Settings::checkDirectory(); 480 Settings::checkDirectory();
481 481
482 KConfig *conf = new KConfig( getFileName() ); 482 KConfig *conf = new KConfig( getFileName() );
483 conf->setGroup( "NNTP Account" ); 483 conf->setGroup( "NNTP Account" );
484 conf->writeEntry( "Account", accountName ); 484 conf->writeEntry( "Account", accountName );
485 conf->writeEntry( "Server", server ); 485 conf->writeEntry( "Server", server );
486 conf->writeEntry( "Port", port ); 486 conf->writeEntry( "Port", port );
487 conf->writeEntry( "SSL", ssl ); 487 conf->writeEntry( "SSL", ssl );
488 conf->writeEntry( "Login", login ); 488 conf->writeEntry( "Login", login );
489 conf->writeEntry( "User", user ); 489 conf->writeEntry( "User", user );
490 //conf->writeEntryCrypt( "Password", password ); 490 //conf->writeEntryCrypt( "Password", password );
491 conf->writeEntry( "FolderHistory",getPasswordList() ); 491 conf->writeEntry( "FolderHistory",getPasswordList() );
492 conf->writeEntry( "Subscribed" , subscribedGroups ); 492 conf->writeEntry( "Subscribed" , subscribedGroups );
493 conf->sync(); 493 conf->sync();
494 delete conf; 494 delete conf;
495} 495}
496 496
497 497
498QString NNTPaccount::getFileName() 498QString NNTPaccount::getFileName()
499{ 499{
500 return locateLocal("data", "kopiemail" ) +"/nntp-" + file; 500 return locateLocal("data", "kopiemail" ) +"/nntp-" + file;
501} 501}
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp
index ec192ea..915b3e8 100644
--- a/kmicromail/opiemail.cpp
+++ b/kmicromail/opiemail.cpp
@@ -1,560 +1,587 @@
1// CHANGED 2004-09-31 Lutz Rogowski 1// CHANGED 2004-09-31 Lutz Rogowski
2// CHANGED 2004-08-06 Lutz Rogowski 2// CHANGED 2004-08-06 Lutz Rogowski
3 3
4#include "koprefsdialog.h" 4#include "koprefsdialog.h"
5#include <kapplication.h> 5#include <kapplication.h>
6#include <libkdepim/externalapphandler.h> 6#include <libkdepim/externalapphandler.h>
7#include <libkdepim/kpimglobalprefs.h> 7#include <libkdepim/kpimglobalprefs.h>
8#ifdef MINIKDE_KDIALOG_H 8#ifdef MINIKDE_KDIALOG_H
9#undef MINIKDE_KDIALOG_H 9#undef MINIKDE_KDIALOG_H
10#endif 10#endif
11#include "settingsdialog.h" 11#include "settingsdialog.h"
12#include "opiemail.h" 12#include "opiemail.h"
13#include "editaccounts.h" 13#include "editaccounts.h"
14#include "composemail.h" 14#include "composemail.h"
15#include "mailistviewitem.h" 15#include "mailistviewitem.h"
16#include "viewmail.h" 16#include "viewmail.h"
17#include "selectstore.h" 17#include "selectstore.h"
18#include "selectsmtp.h" 18#include "selectsmtp.h"
19#include "accountitem.h" 19#include "accountitem.h"
20#include "klocale.h" 20#include "klocale.h"
21 21
22#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qtimer.h> 23#include <qtimer.h>
24#include <qcursor.h> 24#include <qcursor.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qpe/global.h> 26#include <qpe/global.h>
27 27
28#ifdef DESKTOP_VERSION 28#ifdef DESKTOP_VERSION
29#include <qapplication.h> 29#include <qapplication.h>
30#else 30#else
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#endif 32#endif
33#include <libmailwrapper/smtpwrapper.h> 33#include <libmailwrapper/smtpwrapper.h>
34#include <libmailwrapper/mailtypes.h> 34#include <libmailwrapper/mailtypes.h>
35#include <libmailwrapper/abstractmail.h> 35#include <libmailwrapper/abstractmail.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38//using namespace Opie::Core; 38//using namespace Opie::Core;
39 39
40OpieMail::OpieMail( QWidget *parent, const char *name ) 40OpieMail::OpieMail( QWidget *parent, const char *name )
41 : MainWindow( parent, name) //, WStyle_ContextHelp ) 41 : MainWindow( parent, name) //, WStyle_ContextHelp )
42{ 42{
43 settings = new Settings(); 43 settings = new Settings();
44 44
45 setIcon(SmallIcon( "kmicromail" ) ); 45 setIcon(SmallIcon( "kmicromail" ) );
46 folderView->populate( settings->getAccounts() ); 46 folderView->populate( settings->getAccounts() );
47 47
48} 48}
49 49
50OpieMail::~OpieMail() 50OpieMail::~OpieMail()
51{ 51{
52 if (settings) delete settings; 52 if (settings) delete settings;
53} 53}
54 54
55void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 55void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
56{ 56{
57 57
58} 58}
59#include <stdlib.h> 59#include <stdlib.h>
60void OpieMail::message(const QCString &msg, const QByteArray &data) 60void OpieMail::message(const QCString &msg, const QByteArray &data)
61{ 61{
62 // copied from old mail2 62 // copied from old mail2
63 static int ii = 0; 63 static int ii = 0;
64 //qDebug("QCOP CALL ############################# %d ", ii); 64 //qDebug("QCOP CALL ############################# %d ", ii);
65 //QString mess ( msg ); 65 //QString mess ( msg );
66 //qDebug("Message = %s ",mess.latin1()); 66 //qDebug("Message = %s ",mess.latin1());
67 ++ii; 67 ++ii;
68 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); 68 //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this);
69 69
70 mPendingEmail = QString::null; 70 mPendingEmail = QString::null;
71 mPendingName = QString::null; 71 mPendingName = QString::null;
72 if (msg == "writeMail(QString,QString)") 72 if (msg == "writeMail(QString,QString)")
73 { 73 {
74 //qDebug("writeMail(QString,QString) "); 74 //qDebug("writeMail(QString,QString) ");
75 QDataStream stream(data,IO_ReadOnly); 75 QDataStream stream(data,IO_ReadOnly);
76 stream >> mPendingName >> mPendingEmail; 76 stream >> mPendingName >> mPendingEmail;
77 // removing the whitespaces at beginning and end is needed! 77 // removing the whitespaces at beginning and end is needed!
78 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 78 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
79 } 79 }
80 else if (msg == "newMail()") 80 else if (msg == "newMail()")
81 { 81 {
82 //qDebug("slotComposeMail() "); 82 //qDebug("slotComposeMail() ");
83 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call 83 // we cannot call slotComposeMail(); directly, because may be executing a QCOP call
84 // and a QCOP call does not like a processevents in his execution 84 // and a QCOP call does not like a processevents in his execution
85 // with the Qtimer we call slotComposeMail() after we reached the main event loop 85 // with the Qtimer we call slotComposeMail() after we reached the main event loop
86 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 86 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
87 // slotComposeMail(); 87 // slotComposeMail();
88 } 88 }
89 else if (msg == "newMail(QString)") 89 else if (msg == "newMail(QString)")
90 { 90 {
91 //qDebug(" newMail(QString)"); 91 //qDebug(" newMail(QString)");
92 QDataStream stream(data,IO_ReadOnly); 92 QDataStream stream(data,IO_ReadOnly);
93 stream >> mPendingName; 93 stream >> mPendingName;
94 // the format is 94 // the format is
95 // NAME <EMAIL>:SUBJECT 95 // NAME <EMAIL>:SUBJECT
96 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); 96 QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) );
97 } else { 97 } else {
98 mPendingData = data; 98 mPendingData = data;
99 mPendingMessage = msg; 99 mPendingMessage = msg;
100 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); 100 QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) );
101 } 101 }
102 102
103 //qDebug("END OpieMail::message "); 103 //qDebug("END OpieMail::message ");
104} 104}
105void OpieMail::slotExtAppHandler() 105void OpieMail::slotExtAppHandler()
106{ 106{
107 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); 107 ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData );
108} 108}
109void OpieMail::slotwriteMail2(const QString& namemail ) 109void OpieMail::slotwriteMail2(const QString& namemail )
110{ 110{
111 //qDebug("OpieMail::slotwriteMail2 "); 111 //qDebug("OpieMail::slotwriteMail2 ");
112 //qApp->processEvents(); 112 //qApp->processEvents();
113 ComposeMail compose( settings, this, 0, true ); 113 ComposeMail compose( settings, this, 0, true );
114 if ( !namemail.isEmpty() ) { 114 if ( !namemail.isEmpty() ) {
115 QString to = namemail; 115 QString to = namemail;
116 if ( namemail.find( " <") > 1 ) { 116 if ( namemail.find( " <") > 1 ) {
117 to = "\"" +to.replace( QRegExp( " <"), "\" <") ; 117 to = "\"" +to.replace( QRegExp( " <"), "\" <") ;
118 } else 118 } else
119 if ( namemail.find( "<") > 1 ) { 119 if ( namemail.find( "<") > 1 ) {
120 to = "\"" +to.replace( QRegExp( "<"), "\" <") ; 120 to = "\"" +to.replace( QRegExp( "<"), "\" <") ;
121 } 121 }
122 int sub = to.find( ">:"); 122 int sub = to.find( ">:");
123 if ( sub > 0 ) { 123 if ( sub > 0 ) {
124 compose.setTo( to.left(sub+1) ); 124 compose.setTo( to.left(sub+1) );
125 compose.setSubject( to.mid(sub+2) ); 125 compose.setSubject( to.mid(sub+2) );
126 } else 126 } else
127 compose.setTo( to ); 127 compose.setTo( to );
128 } 128 }
129 compose.slotAdjustColumns(); 129 compose.slotAdjustColumns();
130#ifndef DESKTOP_VERSION 130#ifndef DESKTOP_VERSION
131 compose.showMaximized(); 131 compose.showMaximized();
132#endif 132#endif
133 compose.exec(); 133 compose.exec();
134 raise(); 134 raise();
135 //qDebug("retttich "); 135 //qDebug("retttich ");
136} 136}
137void OpieMail::slotwriteMail(const QString&name,const QString&email) 137void OpieMail::slotwriteMail(const QString&name,const QString&email)
138{ 138{
139 // qDebug("OpieMail::slotwriteMail "); 139 // qDebug("OpieMail::slotwriteMail ");
140 ComposeMail compose( settings, this, 0, true ); 140 ComposeMail compose( settings, this, 0, true );
141 if (!email.isEmpty()) 141 if (!email.isEmpty())
142 { 142 {
143 if (!name.isEmpty()) 143 if (!name.isEmpty())
144 { 144 {
145 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 145 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
146 } 146 }
147 else 147 else
148 { 148 {
149 compose.setTo(email); 149 compose.setTo(email);
150 } 150 }
151 } 151 }
152 compose.slotAdjustColumns(); 152 compose.slotAdjustColumns();
153#ifndef DESKTOP_VERSION 153#ifndef DESKTOP_VERSION
154 compose.showMaximized(); 154 compose.showMaximized();
155#endif 155#endif
156 compose.exec(); 156 compose.exec();
157 raise(); 157 raise();
158} 158}
159 159
160void OpieMail::slotComposeMail() 160void OpieMail::slotComposeMail()
161{ 161{
162 if ( mPendingEmail == QString::null && mPendingName == QString::null) 162 if ( mPendingEmail == QString::null && mPendingName == QString::null)
163 slotwriteMail2( QString () ); 163 slotwriteMail2( QString () );
164 else { 164 else {
165 if ( mPendingEmail == QString::null ) 165 if ( mPendingEmail == QString::null )
166 slotwriteMail2( mPendingName ); 166 slotwriteMail2( mPendingName );
167 else 167 else
168 slotwriteMail( mPendingName, mPendingEmail ); 168 slotwriteMail( mPendingName, mPendingEmail );
169 } 169 }
170 //slotwriteMail(0l,0l); 170 //slotwriteMail(0l,0l);
171} 171}
172 172
173void OpieMail::slotSendQueued() 173void 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
227void OpieMail::slotSearchMails() 227void OpieMail::slotSearchMails()
228{ 228{
229 qDebug("OpieMail::slotSearchMails():not implemented "); 229 qDebug("OpieMail::slotSearchMails():not implemented ");
230} 230}
231 231
232void OpieMail::slotEditSettings() 232void 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
245void OpieMail::slotEditAccounts() 245void 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}
258void OpieMail::replyMail() 258void 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}
302void OpieMail::closeViewMail(ViewMail * vm)
303{
304 vm->hide();
305}
306void 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}
302void OpieMail::displayNextMail(ViewMail * vm) 326void 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}
317void OpieMail::displayMail() 342void 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}
343void OpieMail::slotGetAllMail() 370void 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}
351void OpieMail::slotGetMail() 378void 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}
357void OpieMail::slotDeleteMail() 384void 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}
367void OpieMail::slotDeleteAllMail() 394void 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}
391void OpieMail::clearSelection() 418void OpieMail::clearSelection()
392{ 419{
393 mailView->clearSelection(); 420 mailView->clearSelection();
394 421
395} 422}
396 423
397void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 424void 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
433void OpieMail::slotShowFolders( bool show ) 460void 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
445void OpieMail::refreshMailView(const QValueList<RecMailP>&list) 472void 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
460void OpieMail::mailLeftClicked( QListViewItem *item ) 487void OpieMail::mailLeftClicked( QListViewItem *item )
461{ 488{
462 mailView->clearSelection(); 489 mailView->clearSelection();
463 /* just LEFT button - or tap with stylus on pda */ 490 /* just LEFT button - or tap with stylus on pda */
464 //if (button!=1) return; 491 //if (button!=1) return;
465 if (!item) return; 492 if (!item) return;
466 if (folderView->currentisDraft()) { 493 if (folderView->currentisDraft()) {
467 reEditMail(); 494 reEditMail();
468 } else { 495 } else {
469 displayMail(); 496 displayMail();
470 } 497 }
471} 498}
472 499
473void OpieMail::slotMoveCopyMail() 500void OpieMail::slotMoveCopyMail()
474{ 501{
475 if (!mailView->currentItem()) return; 502 if (!mailView->currentItem()) return;
476 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); 503 RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data();
477 AbstractMail*targetMail = 0; 504 AbstractMail*targetMail = 0;
478 QString targetFolder = ""; 505 QString targetFolder = "";
479 Selectstore sels; 506 Selectstore sels;
480 folderView->setupFolderselect(&sels); 507 folderView->setupFolderselect(&sels);
481 if (!sels.exec()) return; 508 if (!sels.exec()) return;
482 targetMail = sels.currentMail(); 509 targetMail = sels.currentMail();
483 targetFolder = sels.currentFolder(); 510 targetFolder = sels.currentFolder();
484 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 511 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
485 targetFolder.isEmpty()) 512 targetFolder.isEmpty())
486 { 513 {
487 return; 514 return;
488 } 515 }
489 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 516 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
490 { 517 {
491 QMessageBox::critical(0,i18n("Error creating new Folder"), 518 QMessageBox::critical(0,i18n("Error creating new Folder"),
492 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 519 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
493 return; 520 return;
494 } 521 }
495 sels.hide(); 522 sels.hide();
496 qApp->processEvents(); 523 qApp->processEvents();
497 // qDebug("hiding sels "); 524 // qDebug("hiding sels ");
498 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 525 mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
499 folderView->refreshCurrent(); 526 folderView->refreshCurrent();
500} 527}
501 528
502void OpieMail::slotMoveCopyAllMail() 529void OpieMail::slotMoveCopyAllMail()
503{ 530{
504 531
505 if (!mailView->currentItem()) return; 532 if (!mailView->currentItem()) return;
506 QValueList<RecMailP> t; 533 QValueList<RecMailP> t;
507 // 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 ) 534 // 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 )
508 { 535 {
509 MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); 536 MailListViewItem* item = (MailListViewItem*)mailView->firstChild ();
510 while ( item ) { 537 while ( item ) {
511 if ( item->isSelected() ) { 538 if ( item->isSelected() ) {
512 t.append( item->data() ); 539 t.append( item->data() );
513 } 540 }
514 item = (MailListViewItem*)item->nextSibling(); 541 item = (MailListViewItem*)item->nextSibling();
515 } 542 }
516 } 543 }
517 // else 544 // else
518 // return; 545 // return;
519 if ( t.count() == 0 ) 546 if ( t.count() == 0 )
520 return; 547 return;
521 RecMailP mail = t.first(); 548 RecMailP mail = t.first();
522 AbstractMail*targetMail = 0; 549 AbstractMail*targetMail = 0;
523 QString targetFolder = ""; 550 QString targetFolder = "";
524 Selectstore sels; 551 Selectstore sels;
525 folderView->setupFolderselect(&sels); 552 folderView->setupFolderselect(&sels);
526 if (!sels.exec()) return; 553 if (!sels.exec()) return;
527 targetMail = sels.currentMail(); 554 targetMail = sels.currentMail();
528 targetFolder = sels.currentFolder(); 555 targetFolder = sels.currentFolder();
529 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || 556 if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) ||
530 targetFolder.isEmpty()) 557 targetFolder.isEmpty())
531 { 558 {
532 return; 559 return;
533 } 560 }
534 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 561 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
535 { 562 {
536 QMessageBox::critical(0,i18n("Error creating new Folder"), 563 QMessageBox::critical(0,i18n("Error creating new Folder"),
537 i18n("<center>Error while creating<br>new folder - breaking.</center>")); 564 i18n("<center>Error while creating<br>new folder - breaking.</center>"));
538 return; 565 return;
539 } 566 }
540 sels.hide(); 567 sels.hide();
541 qApp->processEvents(); 568 qApp->processEvents();
542 //qDebug("hiding sels "); 569 //qDebug("hiding sels ");
543 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails()); 570 mail->Wrapper()->mvcpMailList(t,targetFolder,targetMail,sels.moveMails());
544 folderView->refreshCurrent(); 571 folderView->refreshCurrent();
545} 572}
546 573
547void OpieMail::reEditMail() 574void OpieMail::reEditMail()
548{ 575{
549 if (!mailView->currentItem()) return; 576 if (!mailView->currentItem()) return;
550 577
551 ComposeMail compose( settings, this, 0, true ); 578 ComposeMail compose( settings, this, 0, true );
552 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data()); 579 compose.reEditMail(((MailListViewItem*)mailView->currentItem() )->data());
553 compose.slotAdjustColumns(); 580 compose.slotAdjustColumns();
554#ifndef DESKTOP_VERSION 581#ifndef DESKTOP_VERSION
555 compose.showMaximized(); 582 compose.showMaximized();
556#else 583#else
557 compose.resize(640,480); 584 compose.resize(640,480);
558#endif 585#endif
559 compose.exec(); 586 compose.exec();
560} 587}
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
12class OpieMail : public MainWindow 12class OpieMail : public MainWindow
13{ 13{
14 Q_OBJECT 14 Q_OBJECT
15 15
16public: 16public:
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
21public slots: 21public 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);
28protected slots: 28protected 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
49private: 50private:
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
@@ -1,533 +1,534 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2 2
3 3
4 4
5#include <kfiledialog.h> 5#include <kfiledialog.h>
6#include "koprefs.h" 6#include "koprefs.h"
7#include <klocale.h> 7#include <klocale.h>
8#include <kglobal.h> 8#include <kglobal.h>
9#include <kapplication.h> 9#include <kapplication.h>
10 10
11#ifdef MINIKDE_KDIALOG_H 11#ifdef MINIKDE_KDIALOG_H
12#undef MINIKDE_KDIALOG_H 12#undef MINIKDE_KDIALOG_H
13#endif 13#endif
14 14
15#include "composemail.h" 15#include "composemail.h"
16#include "viewmail.h" 16#include "viewmail.h"
17 17
18#include <libmailwrapper/settings.h> 18#include <libmailwrapper/settings.h>
19#include <libmailwrapper/abstractmail.h> 19#include <libmailwrapper/abstractmail.h>
20#include <libmailwrapper/mailtypes.h> 20#include <libmailwrapper/mailtypes.h>
21 21
22#include <qdialog.h> 22#include <qdialog.h>
23 23
24#include <qpe/qpeapplication.h> 24#include <qpe/qpeapplication.h>
25 25
26/* QT */ 26/* QT */
27#include <qtextbrowser.h> 27#include <qtextbrowser.h>
28#include <qmessagebox.h> 28#include <qmessagebox.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qaction.h> 30#include <qaction.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qlayout.h> 33#include <qlayout.h>
34 34
35//using namespace Opie::Ui; 35//using namespace Opie::Ui;
36//using namespace Opie::Core; 36//using namespace Opie::Core;
37 37
38AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 38AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
39 const QString&fsize,int num,const QValueList<int>&path) 39 const QString&fsize,int num,const QValueList<int>&path)
40 : QListViewItem(parent,after),_partNum(num) 40 : QListViewItem(parent,after),_partNum(num)
41{ 41{
42 _path=path; 42 _path=path;
43 setText(0, mime); 43 setText(0, mime);
44 setText(1, desc); 44 setText(1, desc);
45 setText(2, file); 45 setText(2, file);
46 setText(3, fsize); 46 setText(3, fsize);
47} 47}
48 48
49AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 49AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
50 const QString&fsize,int num,const QValueList<int>&path) 50 const QString&fsize,int num,const QValueList<int>&path)
51 : QListViewItem(parent,after),_partNum(num) 51 : QListViewItem(parent,after),_partNum(num)
52{ 52{
53 _path=path; 53 _path=path;
54 setText(0, mime); 54 setText(0, mime);
55 setText(1, desc); 55 setText(1, desc);
56 setText(2, file); 56 setText(2, file);
57 setText(3, fsize); 57 setText(3, fsize);
58} 58}
59 59
60bool AttachItem::isParentof(const QValueList<int>&path) 60bool AttachItem::isParentof(const QValueList<int>&path)
61{ 61{
62 /* if not set, then no parent */ 62 /* if not set, then no parent */
63 if (path.count()==0||_path.count()==0) return false; 63 if (path.count()==0||_path.count()==0) return false;
64 /* the parent must have one digit less then a child */ 64 /* the parent must have one digit less then a child */
65 if (path.count()!=_path.count()+1) return false; 65 if (path.count()!=_path.count()+1) return false;
66 for (unsigned int i=0; i < _path.count();++i) 66 for (unsigned int i=0; i < _path.count();++i)
67 { 67 {
68 if (_path[i]!=path[i]) return false; 68 if (_path[i]!=path[i]) return false;
69 } 69 }
70 return true; 70 return true;
71} 71}
72 72
73AttachItem* ViewMail::searchParent(const QValueList<int>&path) 73AttachItem* ViewMail::searchParent(const QValueList<int>&path)
74{ 74{
75 QListViewItemIterator it( attachments ); 75 QListViewItemIterator it( attachments );
76 for ( ; it.current(); ++it ) 76 for ( ; it.current(); ++it )
77 { 77 {
78 AttachItem*ati = (AttachItem*)it.current(); 78 AttachItem*ati = (AttachItem*)it.current();
79 if (ati->isParentof(path)) return ati; 79 if (ati->isParentof(path)) return ati;
80 } 80 }
81 return 0; 81 return 0;
82} 82}
83 83
84AttachItem* ViewMail::lastChild(AttachItem*parent) 84AttachItem* ViewMail::lastChild(AttachItem*parent)
85{ 85{
86 if (!parent) return 0; 86 if (!parent) return 0;
87 AttachItem* item = (AttachItem*)parent->firstChild(); 87 AttachItem* item = (AttachItem*)parent->firstChild();
88 if (!item) return item; 88 if (!item) return item;
89 AttachItem*temp=0; 89 AttachItem*temp=0;
90 while( (temp=(AttachItem*)item->nextSibling())) 90 while( (temp=(AttachItem*)item->nextSibling()))
91 { 91 {
92 item = temp; 92 item = temp;
93 } 93 }
94 return item; 94 return item;
95} 95}
96 96
97void ViewMail::setBody(const RecBodyP&body ) 97void ViewMail::setBody(const RecBodyP&body )
98{ 98{
99 99
100 m_body = body; 100 m_body = body;
101 m_mail[2] = body->Bodytext(); 101 m_mail[2] = body->Bodytext();
102 // qDebug("********text %s ",m_mail[2].latin1() ); 102 // qDebug("********text %s ",m_mail[2].latin1() );
103 attachbutton->setEnabled(body->Parts().count()>0); 103 attachbutton->setEnabled(body->Parts().count()>0);
104 attachments->setEnabled(body->Parts().count()>0); 104 attachments->setEnabled(body->Parts().count()>0);
105 if (body->Parts().count()==0) 105 if (body->Parts().count()==0)
106 { 106 {
107 return; 107 return;
108 } 108 }
109 AttachItem * curItem=0; 109 AttachItem * curItem=0;
110 AttachItem * parentItem = 0; 110 AttachItem * parentItem = 0;
111 QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); 111 QString type=body->Description()->Type()+"/"+body->Description()->Subtype();
112 QString desc,fsize; 112 QString desc,fsize;
113 double s = body->Description()->Size(); 113 double s = body->Description()->Size();
114 int w; 114 int w;
115 w=0; 115 w=0;
116 116
117 while (s>1024) 117 while (s>1024)
118 { 118 {
119 s/=1024; 119 s/=1024;
120 ++w; 120 ++w;
121 if (w>=2) break; 121 if (w>=2) break;
122 } 122 }
123 123
124 QString q=""; 124 QString q="";
125 switch(w) 125 switch(w)
126 { 126 {
127 case 1: 127 case 1:
128 q="k"; 128 q="k";
129 break; 129 break;
130 case 2: 130 case 2:
131 q="M"; 131 q="M";
132 break; 132 break;
133 default: 133 default:
134 break; 134 break;
135 } 135 }
136 136
137 { 137 {
138 /* I did not found a method to make a CONTENT reset on a QTextStream 138 /* I did not found a method to make a CONTENT reset on a QTextStream
139 so I use this construct that the stream will re-constructed in each 139 so I use this construct that the stream will re-constructed in each
140 loop. To let it work, the textstream is packed into a own area of 140 loop. To let it work, the textstream is packed into a own area of
141 code is it will be destructed after finishing its small job. 141 code is it will be destructed after finishing its small job.
142 */ 142 */
143 QTextOStream o(&fsize); 143 QTextOStream o(&fsize);
144 if (w>0) o.precision(2); else o.precision(0); 144 if (w>0) o.precision(2); else o.precision(0);
145 o.setf(QTextStream::fixed); 145 o.setf(QTextStream::fixed);
146 o << s << " " << q << "Byte"; 146 o << s << " " << q << "Byte";
147 } 147 }
148 148
149 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); 149 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist());
150 QString filename = ""; 150 QString filename = "";
151 151
152 for (unsigned int i = 0; i < body->Parts().count();++i) 152 for (unsigned int i = 0; i < body->Parts().count();++i)
153 { 153 {
154 filename = ""; 154 filename = "";
155 type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype(); 155 type = body->Parts()[i]->Type()+"/"+body->Parts()[i]->Subtype();
156 part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin(); 156 part_plist_t::ConstIterator it = body->Parts()[i]->Parameters().begin();
157 for (;it!=body->Parts()[i]->Parameters().end();++it) 157 for (;it!=body->Parts()[i]->Parameters().end();++it)
158 { 158 {
159 if (it.key().lower()=="name") 159 if (it.key().lower()=="name")
160 { 160 {
161 filename=it.data(); 161 filename=it.data();
162 } 162 }
163 } 163 }
164 s = body->Parts()[i]->Size(); 164 s = body->Parts()[i]->Size();
165 w = 0; 165 w = 0;
166 while (s>1024) 166 while (s>1024)
167 { 167 {
168 s/=1024; 168 s/=1024;
169 ++w; 169 ++w;
170 if (w>=2) break; 170 if (w>=2) break;
171 } 171 }
172 switch(w) 172 switch(w)
173 { 173 {
174 case 1: 174 case 1:
175 q="k"; 175 q="k";
176 break; 176 break;
177 case 2: 177 case 2:
178 q="M"; 178 q="M";
179 break; 179 break;
180 default: 180 default:
181 q=""; 181 q="";
182 break; 182 break;
183 } 183 }
184 QTextOStream o(&fsize); 184 QTextOStream o(&fsize);
185 if (w>0) o.precision(2); else o.precision(0); 185 if (w>0) o.precision(2); else o.precision(0);
186 o.setf(QTextStream::fixed); 186 o.setf(QTextStream::fixed);
187 o << s << " " << q << "Byte"; 187 o << s << " " << q << "Byte";
188 desc = body->Parts()[i]->Description(); 188 desc = body->Parts()[i]->Description();
189 parentItem = searchParent(body->Parts()[i]->Positionlist()); 189 parentItem = searchParent(body->Parts()[i]->Positionlist());
190 if (parentItem) 190 if (parentItem)
191 { 191 {
192 AttachItem*temp = lastChild(parentItem); 192 AttachItem*temp = lastChild(parentItem);
193 if (temp) curItem = temp; 193 if (temp) curItem = temp;
194 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 194 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
195 attachments->setRootIsDecorated(true); 195 attachments->setRootIsDecorated(true);
196 curItem = parentItem; 196 curItem = parentItem;
197 } 197 }
198 else 198 else
199 { 199 {
200 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist()); 200 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body->Parts()[i]->Positionlist());
201 } 201 }
202 } 202 }
203} 203}
204 204
205 205
206void ViewMail::slotShowHtml( bool state ) 206void ViewMail::slotShowHtml( bool state )
207{ 207{
208 m_showHtml = state; 208 m_showHtml = state;
209 setText(); 209 setText();
210} 210}
211 211
212void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) 212void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
213{ 213{
214 if (!item ) 214 if (!item )
215 return; 215 return;
216 216
217 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 217 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
218 { 218 {
219 setText(); 219 setText();
220 return; 220 return;
221 } 221 }
222 QPopupMenu *menu = new QPopupMenu(); 222 QPopupMenu *menu = new QPopupMenu();
223 int ret=0; 223 int ret=0;
224 224
225 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) 225 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
226 { 226 {
227 menu->insertItem( i18n( "Show Text" ), 1 ); 227 menu->insertItem( i18n( "Show Text" ), 1 );
228 } 228 }
229 if (item->text(0).left(6)=="image/") { 229 if (item->text(0).left(6)=="image/") {
230 menu->insertItem(i18n("Display image preview"),2); 230 menu->insertItem(i18n("Display image preview"),2);
231 } 231 }
232 menu->insertItem( i18n( "Save Attachment" ), 0 ); 232 menu->insertItem( i18n( "Save Attachment" ), 0 );
233 menu->insertSeparator(1); 233 menu->insertSeparator(1);
234 234
235 ret = menu->exec( point, 0 ); 235 ret = menu->exec( point, 0 );
236 236
237 switch(ret) 237 switch(ret)
238 { 238 {
239 case 0: 239 case 0:
240 { 240 {
241 //MimeTypes types; 241 //MimeTypes types;
242 //types.insert( "all", "*" ); 242 //types.insert( "all", "*" );
243 QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this ); 243 QString str = KFileDialog::getSaveFileName( "/", item->text( 2 ), this );
244 244
245 if( !str.isEmpty() ) 245 if( !str.isEmpty() )
246 { 246 {
247 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 247 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
248 if (content) 248 if (content)
249 { 249 {
250 QFile output(str); 250 QFile output(str);
251 output.open(IO_WriteOnly); 251 output.open(IO_WriteOnly);
252 output.writeBlock(content->Content(),content->Length()); 252 output.writeBlock(content->Content(),content->Length());
253 output.close(); 253 output.close();
254 delete content; 254 delete content;
255 } 255 }
256 } 256 }
257 } 257 }
258 break ; 258 break ;
259 259
260 case 2: 260 case 2:
261 { 261 {
262#ifdef DESKTOP_VERSION 262#ifdef DESKTOP_VERSION
263 QString tmpfile = locateLocal( "tmp", "opiemail-image"); 263 QString tmpfile = locateLocal( "tmp", "opiemail-image");
264#else 264#else
265 QString tmpfile = "/tmp/opiemail-image"; 265 QString tmpfile = "/tmp/opiemail-image";
266#endif 266#endif
267 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 267 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
268 if (content) { 268 if (content) {
269 QFile output(tmpfile); 269 QFile output(tmpfile);
270 output.open(IO_WriteOnly); 270 output.open(IO_WriteOnly);
271 output.writeBlock(content->Content(),content->Length()); 271 output.writeBlock(content->Content(),content->Length());
272 output.close(); 272 output.close();
273 delete content; 273 delete content;
274 MailImageDlg iview(""); 274 MailImageDlg iview("");
275 iview.setName(tmpfile); 275 iview.setName(tmpfile);
276 KApplication::execDialog(&iview); 276 KApplication::execDialog(&iview);
277 output.remove(); 277 output.remove();
278 } 278 }
279 } 279 }
280 break; 280 break;
281 case 1: 281 case 1:
282 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 282 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
283 { 283 {
284 setText(); 284 setText();
285 } 285 }
286 else 286 else
287 { 287 {
288 if ( m_recMail->Wrapper() != 0l ) 288 if ( m_recMail->Wrapper() != 0l )
289 { // make sure that there is a wrapper , even after delete or simular actions 289 { // make sure that there is a wrapper , even after delete or simular actions
290 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 290 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
291 } 291 }
292 } 292 }
293 break; 293 break;
294 } 294 }
295 delete menu; 295 delete menu;
296} 296}
297 297
298 298
299void ViewMail::setMail(const RecMailP&mail ) 299void ViewMail::setMail(const RecMailP&mail )
300{ 300{
301 301
302 m_recMail = mail; 302 m_recMail = mail;
303 303
304 m_mail[0] = mail->getFrom(); 304 m_mail[0] = mail->getFrom();
305 m_mail[1] = mail->getSubject(); 305 m_mail[1] = mail->getSubject();
306 m_mail[3] = mail->getDate(); 306 m_mail[3] = mail->getDate();
307 m_mail[4] = mail->Msgid(); 307 m_mail[4] = mail->Msgid();
308 308
309 m_mail2[0] = mail->To(); 309 m_mail2[0] = mail->To();
310 m_mail2[1] = mail->CC(); 310 m_mail2[1] = mail->CC();
311 m_mail2[2] = mail->Bcc(); 311 m_mail2[2] = mail->Bcc();
312 312
313 setText(); 313 setText();
314} 314}
315 315
316 316
317 317
318ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 318ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
319 : ViewMailBase(parent, name, fl), _inLoop(false) 319 : ViewMailBase(parent, name, fl), _inLoop(false)
320{ 320{
321 m_gotBody = false; 321 m_gotBody = false;
322 deleted = false; 322 deleted = false;
323 323
324 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 324 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
325 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 325 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
326 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 326 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
327 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 327 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
328 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); 328 connect( closeMail, SIGNAL( activated() ), SLOT( close() ) );
329 connect( nextMail, SIGNAL( activated() ), SLOT( slotNextMail() ) ); 329 connect( nextMail, SIGNAL( activated() ), SLOT( slotNextMail() ) );
330 330
331 attachments->setEnabled(m_gotBody); 331 attachments->setEnabled(m_gotBody);
332 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 332 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
333 333
334 readConfig(); 334 readConfig();
335 attachments->setSorting(-1); 335 attachments->setSorting(-1);
336} 336}
337 337
338void ViewMail::readConfig() 338void ViewMail::readConfig()
339{ 339{
340 340
341 setFont ( KOPrefs::instance()->mReadFont ); 341 setFont ( KOPrefs::instance()->mReadFont );
342 m_showHtml = KOPrefs::instance()->mViewAsHtml; 342 m_showHtml = KOPrefs::instance()->mViewAsHtml;
343 showHtml->setOn( m_showHtml ); 343 showHtml->setOn( m_showHtml );
344} 344}
345 345
346void ViewMail::setText() 346void ViewMail::setText()
347{ 347{
348 348
349 QString toString; 349 QString toString;
350 QString ccString; 350 QString ccString;
351 QString bccString; 351 QString bccString;
352 352
353 353
354 toString = m_mail2[0].join(","); 354 toString = m_mail2[0].join(",");
355 ccString = m_mail2[1].join(","); 355 ccString = m_mail2[1].join(",");
356 bccString = m_mail2[2].join(","); 356 bccString = m_mail2[2].join(",");
357 357
358 358
359 setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); 359 setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) );
360 360
361 m_mailHtml = "<html><body>" 361 m_mailHtml = "<html><body>"
362 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 362 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
363 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 363 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>"
364 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 364 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
365 "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 365 "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
366 "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 366 "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
367 i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 367 i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
368 "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + 368 "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] +
369 "</td></tr></table><font>"; 369 "</td></tr></table><font>";
370 370
371 if ( !m_showHtml ) 371 if ( !m_showHtml )
372 { 372 {
373 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 373 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
374 } 374 }
375 else 375 else
376 { 376 {
377 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); 377 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
378 } 378 }
379 // remove later in favor of a real handling 379 // remove later in favor of a real handling
380 m_gotBody = true; 380 m_gotBody = true;
381} 381}
382 382
383 383
384ViewMail::~ViewMail() 384ViewMail::~ViewMail()
385{ 385{
386 m_recMail->Wrapper()->cleanMimeCache(); 386 m_recMail->Wrapper()->cleanMimeCache();
387 hide(); 387 hide();
388} 388}
389 389
390void ViewMail::hide() 390void 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
403void ViewMail::exec() 403void 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
415QString ViewMail::deHtml(const QString &string) 415QString ViewMail::deHtml(const QString &string)
416{ 416{
417 QString string_ = string; 417 QString string_ = string;
418 string_.replace(QRegExp("&"), "&amp;"); 418 string_.replace(QRegExp("&"), "&amp;");
419 string_.replace(QRegExp("<"), "&lt;"); 419 string_.replace(QRegExp("<"), "&lt;");
420 string_.replace(QRegExp(">"), "&gt;"); 420 string_.replace(QRegExp(">"), "&gt;");
421 string_.replace(QRegExp("\\n"), "<br>"); 421 string_.replace(QRegExp("\\n"), "<br>");
422 return string_; 422 return string_;
423} 423}
424 424
425void ViewMail::slotReply() 425void 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
470void ViewMail::slotForward() 470void 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
505void ViewMail::slotDeleteMail( ) 505void 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
515MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) 516MailImageDlg::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
525MailImageDlg::~MailImageDlg() 526MailImageDlg::~MailImageDlg()
526{ 527{
527} 528}
528 529
529void MailImageDlg::setName(const QString&fname) 530void 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
16class AttachItem : public QListViewItem 16class AttachItem : public QListViewItem
17{ 17{
18public: 18public:
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
26private: 26private:
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
32class ViewMail : public ViewMailBase 32class ViewMail : public ViewMailBase
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35 35
36public: 36public:
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 *);
47protected: 48protected:
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
52protected slots: 53protected 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
61private: 62private:
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
77class MailImageDlg:public QDialog 78class MailImageDlg:public QDialog
78{ 79{
79 Q_OBJECT 80 Q_OBJECT
80public: 81public:
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&);
84protected: 85protected:
85 //Opie::MM::OImageScrollView*m_imageview; 86 //Opie::MM::OImageScrollView*m_imageview;
86}; 87};
87 88
88#endif 89#endif