summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper
Unidiff
Diffstat (limited to 'kmicromail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/settings.cpp85
-rw-r--r--kmicromail/libmailwrapper/settings.h3
2 files changed, 64 insertions, 24 deletions
diff --git a/kmicromail/libmailwrapper/settings.cpp b/kmicromail/libmailwrapper/settings.cpp
index f996d9c..766eba0 100644
--- a/kmicromail/libmailwrapper/settings.cpp
+++ b/kmicromail/libmailwrapper/settings.cpp
@@ -1,37 +1,37 @@
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 <qpe/config.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 updateAccounts(); 24 updateAccounts();
25} 25}
26 26
27void Settings::checkDirectory() 27void Settings::checkDirectory()
28{ 28{
29 qDebug("Settings::checkDirectory() "); 29 qDebug("Settings::checkDirectory() ");
30 return; 30 return;
31 locateLocal("data", "kopiemail" ); 31 locateLocal("data", "kopiemail" );
32 /* 32 /*
33 if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { 33 if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) {
34 system( "mkdir -p $HOME/Applications/opiemail" ); 34 system( "mkdir -p $HOME/Applications/opiemail" );
35 qDebug("$HOME/Applications/opiemail created "); 35 qDebug("$HOME/Applications/opiemail created ");
36 } 36 }
37 */ 37 */
@@ -83,382 +83,419 @@ void Settings::updateAccounts()
83 accounts.append( account ); 83 accounts.append( account );
84 } 84 }
85 85
86 readAccounts(); 86 readAccounts();
87} 87}
88 88
89void Settings::saveAccounts() 89void Settings::saveAccounts()
90{ 90{
91 checkDirectory(); 91 checkDirectory();
92 Account *it; 92 Account *it;
93 93
94 for ( it = accounts.first(); it; it = accounts.next() ) { 94 for ( it = accounts.first(); it; it = accounts.next() ) {
95 it->save(); 95 it->save();
96 } 96 }
97} 97}
98 98
99void Settings::readAccounts() 99void Settings::readAccounts()
100{ 100{
101 checkDirectory(); 101 checkDirectory();
102 Account *it; 102 Account *it;
103 103
104 for ( it = accounts.first(); it; it = accounts.next() ) { 104 for ( it = accounts.first(); it; it = accounts.next() ) {
105 it->read(); 105 it->read();
106 } 106 }
107} 107}
108 108
109Account::Account() 109Account::Account()
110{ 110{
111 accountName = "changeMe"; 111 accountName = "changeMe";
112 type = MAILLIB::A_UNDEFINED; 112 type = MAILLIB::A_UNDEFINED;
113 ssl = false; 113 ssl = false;
114 connectionType = 1; 114 connectionType = 1;
115 offline = false; 115 offline = false;
116 maxMailSize = 0;
117 lastFetch;
118 leaveOnServer = false;
116} 119}
117 120
118void Account::remove() 121void Account::remove()
119{ 122{
120 QFile file( getFileName() ); 123 QFile file( getFileName() );
121 file.remove(); 124 file.remove();
122} 125}
123 126
127void Account::setPasswordList(const QStringList &str)
128{
129 password = "";
130 int i;
131 for ( i = 0; i < str.count() ; ++i ) {
132 QChar c ( (str[i].toUInt()-131)/(str.count()- (i%3)));
133 password.append( c );
134 }
135 //qDebug("password %s ", password.latin1());
136}
137QStringList Account::getPasswordList()
138{
139 int i;
140 int len = password.length();
141 QStringList str;
142
143 for ( i = 0; i < len ; ++i ) {
144 int val = password.at(i).unicode()*(len-(i%3))+131;
145 str.append( QString::number( val ) );
146 // qDebug("append %s ", str[i].latin1());
147 }
148 return str;
149}
150
124IMAPaccount::IMAPaccount() 151IMAPaccount::IMAPaccount()
125 : Account() 152 : Account()
126{ 153{
127 file = IMAPaccount::getUniqueFileName(); 154 file = IMAPaccount::getUniqueFileName();
128 accountName = "New IMAP Account"; 155 accountName = "New IMAP Account";
129 ssl = false; 156 ssl = false;
130 connectionType = 1; 157 connectionType = 1;
131 type = MAILLIB::A_IMAP; 158 type = MAILLIB::A_IMAP;
132 port = IMAP_PORT; 159 port = IMAP_PORT;
133} 160}
134 161
135IMAPaccount::IMAPaccount( QString filename ) 162IMAPaccount::IMAPaccount( QString filename )
136 : Account() 163 : Account()
137{ 164{
138 file = filename; 165 file = filename;
139 accountName = "New IMAP Account"; 166 accountName = "New IMAP Account";
140 ssl = false; 167 ssl = false;
141 connectionType = 1; 168 connectionType = 1;
142 type = MAILLIB::A_IMAP; 169 type = MAILLIB::A_IMAP;
143 port = IMAP_PORT; 170 port = IMAP_PORT;
144} 171}
145 172
146QString IMAPaccount::getUniqueFileName() 173QString IMAPaccount::getUniqueFileName()
147{ 174{
148 int num = 0; 175 int num = 0;
149 QString unique; 176 QString unique;
150 177
151 QDir dir( locateLocal("data", "kopiemail" ) ); 178 QDir dir( locateLocal("data", "kopiemail" ) );
152 179
153 QStringList imap = dir.entryList( "imap-*" ); 180 QStringList imap = dir.entryList( "imap-*" );
154 do { 181 do {
155 unique.setNum( num++ ); 182 unique.setNum( num++ );
156 } while ( imap.contains( "imap-" + unique ) > 0 ); 183 } while ( imap.contains( "imap-" + unique ) > 0 );
157 184
158 return unique; 185 return unique;
159} 186}
160 187
161void IMAPaccount::read() 188void IMAPaccount::read()
162{ 189{
163 Config *conf = new Config( getFileName(), Config::File ); 190 KConfig *conf = new KConfig( getFileName() );
164 conf->setGroup( "IMAP Account" ); 191 conf->setGroup( "IMAP Account" );
165 accountName = conf->readEntry( "Account","" ); 192 accountName = conf->readEntry( "Account","" );
166 if (accountName.isNull()) accountName = ""; 193 if (accountName.isNull()) accountName = "";
167 server = conf->readEntry( "Server","" ); 194 server = conf->readEntry( "Server","" );
168 if (server.isNull()) server=""; 195 if (server.isNull()) server="";
169 port = conf->readEntry( "Port","" ); 196 port = conf->readEntry( "Port","" );
170 if (port.isNull()) port="143"; 197 if (port.isNull()) port="143";
171 connectionType = conf->readNumEntry( "ConnectionType" ); 198 connectionType = conf->readNumEntry( "ConnectionType" );
172 ssl = conf->readBoolEntry( "SSL",false ); 199 ssl = conf->readBoolEntry( "SSL",false );
173 user = conf->readEntry( "User","" ); 200 user = conf->readEntry( "User","" );
174 if (user.isNull()) user = ""; 201 if (user.isNull()) user = "";
175 password = conf->readEntryCrypt( "Password","" ); 202 //password = conf->readEntryCrypt( "Password","" );
203 setPasswordList( conf->readListEntry( "FolderHistory"));
176 if (password.isNull()) password = ""; 204 if (password.isNull()) password = "";
177 prefix = conf->readEntry("MailPrefix",""); 205 prefix = conf->readEntry("MailPrefix","");
178 if (prefix.isNull()) prefix = ""; 206 if (prefix.isNull()) prefix = "";
179 offline = conf->readBoolEntry("Offline",false); 207 offline = conf->readBoolEntry("Offline",false);
180 localFolder = conf->readEntry( "LocalFolder" ); 208 localFolder = conf->readEntry( "LocalFolder" );
181 maxMailSize = conf->readNumEntry( "MaxSize",0 ); 209 maxMailSize = conf->readNumEntry( "MaxSize",0 );
182 int lf = conf->readNumEntry( "LastFetch",0 ); 210 int lf = conf->readNumEntry( "LastFetch",0 );
183 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 211 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
184 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); 212 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false);
213 qDebug("reading last fetch: %d ", lf);
214 if ( lf < 0 ) lf = 0;
185 lastFetch = dt.addSecs( lf ); 215 lastFetch = dt.addSecs( lf );
186 delete conf; 216 delete conf;
187} 217}
188 218
189void IMAPaccount::save() 219void IMAPaccount::save()
190{ 220{
191 qDebug("saving %s ",getFileName().latin1() ); 221 qDebug("saving %s ",getFileName().latin1() );
192 Settings::checkDirectory(); 222 Settings::checkDirectory();
193 223
194 Config *conf = new Config( getFileName(), Config::File ); 224 KConfig *conf = new KConfig( getFileName() );
195 conf->setGroup( "IMAP Account" ); 225 conf->setGroup( "IMAP Account" );
196 conf->writeEntry( "Account", accountName ); 226 conf->writeEntry( "Account", accountName );
197 conf->writeEntry( "Server", server ); 227 conf->writeEntry( "Server", server );
198 conf->writeEntry( "Port", port ); 228 conf->writeEntry( "Port", port );
199 conf->writeEntry( "SSL", ssl ); 229 conf->writeEntry( "SSL", ssl );
200 conf->writeEntry( "ConnectionType", connectionType ); 230 conf->writeEntry( "ConnectionType", connectionType );
201 conf->writeEntry( "User", user ); 231 conf->writeEntry( "User", user );
202 conf->writeEntryCrypt( "Password", password ); 232 //conf->writeEntryCrypt( "Password", password );
233 conf->writeEntry( "FolderHistory",getPasswordList() );
203 conf->writeEntry( "MailPrefix",prefix); 234 conf->writeEntry( "MailPrefix",prefix);
204 conf->writeEntry( "Offline",offline); 235 conf->writeEntry( "Offline",offline);
205 conf->writeEntry( "LocalFolder", localFolder ); 236 conf->writeEntry( "LocalFolder", localFolder );
206 conf->writeEntry( "MaxSize", maxMailSize ); 237 conf->writeEntry( "MaxSize", maxMailSize );
207 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 238 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
208 int lf = dt.secsTo ( lastFetch ); 239 int lf = dt.secsTo ( lastFetch );
209 conf->writeEntry( "LastFetch", lf ); 240 conf->writeEntry( "LastFetch", lf );
210 conf->writeEntry( "LeaveOnServer", leaveOnServer); 241 conf->writeEntry( "LeaveOnServer", leaveOnServer);
211 conf->write(); 242 conf->sync();
212 delete conf; 243 delete conf;
213} 244}
214 245
215 246
216QString IMAPaccount::getFileName() 247QString IMAPaccount::getFileName()
217{ 248{
218 return locateLocal("data", "kopiemail" ) +"/imap-" + file; 249 return locateLocal("data", "kopiemail" ) +"/imap-" + file;
219} 250}
220 251
221POP3account::POP3account() 252POP3account::POP3account()
222 : Account() 253 : Account()
223{ 254{
224 file = POP3account::getUniqueFileName(); 255 file = POP3account::getUniqueFileName();
225 accountName = "New POP3 Account"; 256 accountName = "New POP3 Account";
226 ssl = false; 257 ssl = false;
227 connectionType = 1; 258 connectionType = 1;
228 type = MAILLIB::A_POP3; 259 type = MAILLIB::A_POP3;
229 port = POP3_PORT; 260 port = POP3_PORT;
230} 261}
231 262
232POP3account::POP3account( QString filename ) 263POP3account::POP3account( QString filename )
233 : Account() 264 : Account()
234{ 265{
235 file = filename; 266 file = filename;
236 accountName = "New POP3 Account"; 267 accountName = "New POP3 Account";
237 ssl = false; 268 ssl = false;
238 connectionType = 1; 269 connectionType = 1;
239 type = MAILLIB::A_POP3; 270 type = MAILLIB::A_POP3;
240 port = POP3_PORT; 271 port = POP3_PORT;
241} 272}
242 273
243QString POP3account::getUniqueFileName() 274QString POP3account::getUniqueFileName()
244{ 275{
245 int num = 0; 276 int num = 0;
246 QString unique; 277 QString unique;
247 278
248 QDir dir( locateLocal("data", "kopiemail" ) ); 279 QDir dir( locateLocal("data", "kopiemail" ) );
249 280
250 QStringList imap = dir.entryList( "pop3-*" ); 281 QStringList imap = dir.entryList( "pop3-*" );
251 do { 282 do {
252 unique.setNum( num++ ); 283 unique.setNum( num++ );
253 } while ( imap.contains( "pop3-" + unique ) > 0 ); 284 } while ( imap.contains( "pop3-" + unique ) > 0 );
254 285
255 return unique; 286 return unique;
256} 287}
257 288
258void POP3account::read() 289void POP3account::read()
259{ 290{
260 Config *conf = new Config( getFileName(), Config::File ); 291 KConfig *conf = new KConfig( getFileName());
261 conf->setGroup( "POP3 Account" ); 292 conf->setGroup( "POP3 Account" );
262 accountName = conf->readEntry( "Account" ); 293 accountName = conf->readEntry( "Account" );
263 server = conf->readEntry( "Server" ); 294 server = conf->readEntry( "Server" );
264 port = conf->readEntry( "Port" ); 295 port = conf->readEntry( "Port" );
265 ssl = conf->readBoolEntry( "SSL" ); 296 ssl = conf->readBoolEntry( "SSL" );
266 connectionType = conf->readNumEntry( "ConnectionType" ); 297 connectionType = conf->readNumEntry( "ConnectionType" );
267 user = conf->readEntry( "User" ); 298 user = conf->readEntry( "User" );
268 password = conf->readEntryCrypt( "Password" ); 299 //password = conf->readEntryCrypt( "Password" );
300 setPasswordList( conf->readListEntry( "FolderHistory"));
269 offline = conf->readBoolEntry("Offline",false); 301 offline = conf->readBoolEntry("Offline",false);
270 localFolder = conf->readEntry( "LocalFolder" ); 302 localFolder = conf->readEntry( "LocalFolder" );
271 maxMailSize = conf->readNumEntry( "MaxSize",0 ); 303 maxMailSize = conf->readNumEntry( "MaxSize",0 );
272 int lf = conf->readNumEntry( "LastFetch",0 ); 304 int lf = conf->readNumEntry( "LastFetch",0 );
273 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 305 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
274 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false); 306 leaveOnServer = conf->readBoolEntry("LeaveOnServer",false);
275 lastFetch = dt.addSecs( lf ); 307 lastFetch = dt.addSecs( lf );
276 delete conf; 308 delete conf;
277} 309}
278 310
279void POP3account::save() 311void POP3account::save()
280{ 312{
281 Settings::checkDirectory(); 313 Settings::checkDirectory();
282 314
283 Config *conf = new Config( getFileName(), Config::File ); 315 KConfig *conf = new KConfig( getFileName() );
284 conf->setGroup( "POP3 Account" ); 316 conf->setGroup( "POP3 Account" );
285 conf->writeEntry( "Account", accountName ); 317 conf->writeEntry( "Account", accountName );
286 conf->writeEntry( "Server", server ); 318 conf->writeEntry( "Server", server );
287 conf->writeEntry( "Port", port ); 319 conf->writeEntry( "Port", port );
288 conf->writeEntry( "SSL", ssl ); 320 conf->writeEntry( "SSL", ssl );
289 conf->writeEntry( "ConnectionType", connectionType ); 321 conf->writeEntry( "ConnectionType", connectionType );
290 conf->writeEntry( "User", user ); 322 conf->writeEntry( "User", user );
291 conf->writeEntryCrypt( "Password", password ); 323 //conf->writeEntryCrypt( "Password", password );
324 conf->writeEntry( "FolderHistory",getPasswordList() );
292 conf->writeEntry( "Offline",offline); 325 conf->writeEntry( "Offline",offline);
293 conf->writeEntry( "LocalFolder", localFolder ); 326 conf->writeEntry( "LocalFolder", localFolder );
294 conf->writeEntry( "MaxSize", maxMailSize ); 327 conf->writeEntry( "MaxSize", maxMailSize );
295 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) ); 328 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
296 int lf = dt.secsTo ( lastFetch ); 329 int lf = dt.secsTo ( lastFetch );
297 conf->writeEntry( "LastFetch", lf ); 330 conf->writeEntry( "LastFetch", lf );
298 conf->writeEntry( "LeaveOnServer", leaveOnServer); 331 conf->writeEntry( "LeaveOnServer", leaveOnServer);
299 conf->write(); 332 conf->sync();
300 delete conf; 333 delete conf;
301} 334}
302 335
303 336
304QString POP3account::getFileName() 337QString POP3account::getFileName()
305{ 338{
306 return locateLocal("data", "kopiemail" ) +"/pop3-" + file; 339 return locateLocal("data", "kopiemail" ) +"/pop3-" + file;
307} 340}
308 341
309SMTPaccount::SMTPaccount() 342SMTPaccount::SMTPaccount()
310 : Account() 343 : Account()
311{ 344{
312 file = SMTPaccount::getUniqueFileName(); 345 file = SMTPaccount::getUniqueFileName();
313 accountName = "New SMTP Account"; 346 accountName = "New SMTP Account";
314 ssl = false; 347 ssl = false;
315 connectionType = 1; 348 connectionType = 1;
316 login = false; 349 login = false;
317 useCC = false; 350 useCC = false;
318 useBCC = false; 351 useBCC = false;
319 useReply = false; 352 useReply = false;
320 type = MAILLIB::A_SMTP; 353 type = MAILLIB::A_SMTP;
321 port = SMTP_PORT; 354 port = SMTP_PORT;
322} 355}
323 356
324SMTPaccount::SMTPaccount( QString filename ) 357SMTPaccount::SMTPaccount( QString filename )
325 : Account() 358 : Account()
326{ 359{
327 file = filename; 360 file = filename;
328 accountName = "New SMTP Account"; 361 accountName = "New SMTP Account";
329 ssl = false; 362 ssl = false;
330 connectionType = 1; 363 connectionType = 1;
331 login = false; 364 login = false;
332 type = MAILLIB::A_SMTP; 365 type = MAILLIB::A_SMTP;
333 port = SMTP_PORT; 366 port = SMTP_PORT;
334} 367}
335 368
336QString SMTPaccount::getUniqueFileName() 369QString SMTPaccount::getUniqueFileName()
337{ 370{
338 int num = 0; 371 int num = 0;
339 QString unique; 372 QString unique;
340 373
341 QDir dir( locateLocal("data", "kopiemail" ) ); 374 QDir dir( locateLocal("data", "kopiemail" ) );
342 375
343 QStringList imap = dir.entryList( "smtp-*" ); 376 QStringList imap = dir.entryList( "smtp-*" );
344 do { 377 do {
345 unique.setNum( num++ ); 378 unique.setNum( num++ );
346 } while ( imap.contains( "smtp-" + unique ) > 0 ); 379 } while ( imap.contains( "smtp-" + unique ) > 0 );
347 380
348 return unique; 381 return unique;
349} 382}
350 383
351void SMTPaccount::read() 384void SMTPaccount::read()
352{ 385{
353 Config *conf = new Config( getFileName(), Config::File ); 386 KConfig *conf = new KConfig( getFileName() );
354 conf->setGroup( "SMTP Account" ); 387 conf->setGroup( "SMTP Account" );
355 accountName = conf->readEntry( "Account" ); 388 accountName = conf->readEntry( "Account" );
356 server = conf->readEntry( "Server" ); 389 server = conf->readEntry( "Server" );
357 port = conf->readEntry( "Port" ); 390 port = conf->readEntry( "Port" );
358 ssl = conf->readBoolEntry( "SSL" ); 391 ssl = conf->readBoolEntry( "SSL" );
359 connectionType = conf->readNumEntry( "ConnectionType" ); 392 connectionType = conf->readNumEntry( "ConnectionType" );
360 login = conf->readBoolEntry( "Login" ); 393 login = conf->readBoolEntry( "Login" );
361 user = conf->readEntry( "User" ); 394 user = conf->readEntry( "User" );
362 password = conf->readEntryCrypt( "Password" ); 395 //password = conf->readEntryCrypt( "Password" );
396 setPasswordList( conf->readListEntry( "FolderHistory"));
363 delete conf; 397 delete conf;
364} 398}
365 399
366void SMTPaccount::save() 400void SMTPaccount::save()
367{ 401{
368 Settings::checkDirectory(); 402 Settings::checkDirectory();
369 403
370 Config *conf = new Config( getFileName(), Config::File ); 404 KConfig *conf = new KConfig( getFileName() );
371 conf->setGroup( "SMTP Account" ); 405 conf->setGroup( "SMTP Account" );
372 conf->writeEntry( "Account", accountName ); 406 conf->writeEntry( "Account", accountName );
373 conf->writeEntry( "Server", server ); 407 conf->writeEntry( "Server", server );
374 conf->writeEntry( "Port", port ); 408 conf->writeEntry( "Port", port );
375 conf->writeEntry( "SSL", ssl ); 409 conf->writeEntry( "SSL", ssl );
376 conf->writeEntry( "ConnectionType", connectionType ); 410 conf->writeEntry( "ConnectionType", connectionType );
377 conf->writeEntry( "Login", login ); 411 conf->writeEntry( "Login", login );
378 conf->writeEntry( "User", user ); 412 conf->writeEntry( "User", user );
379 conf->writeEntryCrypt( "Password", password ); 413 //conf->writeEntryCrypt( "Password", password );
380 conf->write(); 414 conf->writeEntry( "FolderHistory",getPasswordList() );
415 conf->sync();
381 delete conf; 416 delete conf;
382} 417}
383 418
384 419
385QString SMTPaccount::getFileName() 420QString SMTPaccount::getFileName()
386{ 421{
387 return locateLocal("data", "kopiemail" ) +"/smtp-" + file; 422 return locateLocal("data", "kopiemail" ) +"/smtp-" + file;
388} 423}
389 424
390NNTPaccount::NNTPaccount() 425NNTPaccount::NNTPaccount()
391 : Account() 426 : Account()
392{ 427{
393 file = NNTPaccount::getUniqueFileName(); 428 file = NNTPaccount::getUniqueFileName();
394 accountName = "New NNTP Account"; 429 accountName = "New NNTP Account";
395 ssl = false; 430 ssl = false;
396 login = false; 431 login = false;
397 type = MAILLIB::A_NNTP; 432 type = MAILLIB::A_NNTP;
398 port = NNTP_PORT; 433 port = NNTP_PORT;
399} 434}
400 435
401NNTPaccount::NNTPaccount( QString filename ) 436NNTPaccount::NNTPaccount( QString filename )
402 : Account() 437 : Account()
403{ 438{
404 file = filename; 439 file = filename;
405 accountName = "New NNTP Account"; 440 accountName = "New NNTP Account";
406 ssl = false; 441 ssl = false;
407 login = false; 442 login = false;
408 type = MAILLIB::A_NNTP; 443 type = MAILLIB::A_NNTP;
409 port = NNTP_PORT; 444 port = NNTP_PORT;
410} 445}
411 446
412QString NNTPaccount::getUniqueFileName() 447QString NNTPaccount::getUniqueFileName()
413{ 448{
414 int num = 0; 449 int num = 0;
415 QString unique; 450 QString unique;
416 451
417 QDir dir( locateLocal("data", "kopiemail" ) ); 452 QDir dir( locateLocal("data", "kopiemail" ) );
418 453
419 QStringList imap = dir.entryList( "nntp-*" ); 454 QStringList imap = dir.entryList( "nntp-*" );
420 do { 455 do {
421 unique.setNum( num++ ); 456 unique.setNum( num++ );
422 } while ( imap.contains( "nntp-" + unique ) > 0 ); 457 } while ( imap.contains( "nntp-" + unique ) > 0 );
423 458
424 return unique; 459 return unique;
425} 460}
426 461
427void NNTPaccount::read() 462void NNTPaccount::read()
428{ 463{
429 Config *conf = new Config( getFileName(), Config::File ); 464 KConfig *conf = new KConfig( getFileName() );
430 conf->setGroup( "NNTP Account" ); 465 conf->setGroup( "NNTP Account" );
431 accountName = conf->readEntry( "Account" ); 466 accountName = conf->readEntry( "Account" );
432 server = conf->readEntry( "Server" ); 467 server = conf->readEntry( "Server" );
433 port = conf->readEntry( "Port" ); 468 port = conf->readEntry( "Port" );
434 ssl = conf->readBoolEntry( "SSL" ); 469 ssl = conf->readBoolEntry( "SSL" );
435 login = conf->readBoolEntry( "Login" ); 470 login = conf->readBoolEntry( "Login" );
436 user = conf->readEntry( "User" ); 471 user = conf->readEntry( "User" );
437 password = conf->readEntryCrypt( "Password" ); 472 //password = conf->readEntryCrypt( "Password" );
438 subscribedGroups = conf->readListEntry( "Subscribed", ',' ); 473 setPasswordList( conf->readListEntry( "FolderHistory"));
474 subscribedGroups = conf->readListEntry( "Subscribed");
439 delete conf; 475 delete conf;
440} 476}
441 477
442void NNTPaccount::save() 478void NNTPaccount::save()
443{ 479{
444 Settings::checkDirectory(); 480 Settings::checkDirectory();
445 481
446 Config *conf = new Config( getFileName(), Config::File ); 482 KConfig *conf = new KConfig( getFileName() );
447 conf->setGroup( "NNTP Account" ); 483 conf->setGroup( "NNTP Account" );
448 conf->writeEntry( "Account", accountName ); 484 conf->writeEntry( "Account", accountName );
449 conf->writeEntry( "Server", server ); 485 conf->writeEntry( "Server", server );
450 conf->writeEntry( "Port", port ); 486 conf->writeEntry( "Port", port );
451 conf->writeEntry( "SSL", ssl ); 487 conf->writeEntry( "SSL", ssl );
452 conf->writeEntry( "Login", login ); 488 conf->writeEntry( "Login", login );
453 conf->writeEntry( "User", user ); 489 conf->writeEntry( "User", user );
454 conf->writeEntryCrypt( "Password", password ); 490 //conf->writeEntryCrypt( "Password", password );
455 conf->writeEntry( "Subscribed" , subscribedGroups, ',' ); 491 conf->writeEntry( "FolderHistory",getPasswordList() );
456 conf->write(); 492 conf->writeEntry( "Subscribed" , subscribedGroups );
493 conf->sync();
457 delete conf; 494 delete conf;
458} 495}
459 496
460 497
461QString NNTPaccount::getFileName() 498QString NNTPaccount::getFileName()
462{ 499{
463 return locateLocal("data", "kopiemail" ) +"/nntp-" + file; 500 return locateLocal("data", "kopiemail" ) +"/nntp-" + file;
464} 501}
diff --git a/kmicromail/libmailwrapper/settings.h b/kmicromail/libmailwrapper/settings.h
index 85b817c..61051dd 100644
--- a/kmicromail/libmailwrapper/settings.h
+++ b/kmicromail/libmailwrapper/settings.h
@@ -8,64 +8,67 @@
8/* QT */ 8/* QT */
9#include <qobject.h> 9#include <qobject.h>
10#include <qlist.h> 10#include <qlist.h>
11#include <qdatetime.h> 11#include <qdatetime.h>
12 12
13class Account 13class Account
14{ 14{
15 15
16public: 16public:
17 Account(); 17 Account();
18 virtual ~Account() {} 18 virtual ~Account() {}
19 19
20 void remove(); 20 void remove();
21 void setAccountName( QString name ) { accountName = name; } 21 void setAccountName( QString name ) { accountName = name; }
22 const QString&getAccountName()const{ return accountName; } 22 const QString&getAccountName()const{ return accountName; }
23 MAILLIB::ATYPE getType()const{ return type; } 23 MAILLIB::ATYPE getType()const{ return type; }
24 24
25 void setServer(const QString&str){ server = str; } 25 void setServer(const QString&str){ server = str; }
26 const QString&getServer()const{ return server; } 26 const QString&getServer()const{ return server; }
27 27
28 void setLocalFolder( QString name ) { localFolder = name; } 28 void setLocalFolder( QString name ) { localFolder = name; }
29 const QString& getLocalFolder()const{ return localFolder; } 29 const QString& getLocalFolder()const{ return localFolder; }
30 30
31 void setPort(const QString&str) { port = str; } 31 void setPort(const QString&str) { port = str; }
32 const QString&getPort()const{ return port; } 32 const QString&getPort()const{ return port; }
33 33
34 void setUser(const QString&str){ user = str; } 34 void setUser(const QString&str){ user = str; }
35 const QString&getUser()const{ return user; } 35 const QString&getUser()const{ return user; }
36 36
37 void setPassword(const QString&str) { password = str; } 37 void setPassword(const QString&str) { password = str; }
38 const QString&getPassword()const { return password; } 38 const QString&getPassword()const { return password; }
39 39
40 void setPasswordList(const QStringList &str);
41 QStringList getPasswordList();
42
40 void setSSL( bool b ) { ssl = b; } 43 void setSSL( bool b ) { ssl = b; }
41 bool getSSL() { return ssl; } 44 bool getSSL() { return ssl; }
42 45
43 void setConnectionType( int x ) { connectionType = x; } 46 void setConnectionType( int x ) { connectionType = x; }
44 int ConnectionType() { return connectionType; } 47 int ConnectionType() { return connectionType; }
45 48
46 void setMaxMailSize( int x ) { maxMailSize = x; } 49 void setMaxMailSize( int x ) { maxMailSize = x; }
47 int getMaxMailSize() { return maxMailSize; } 50 int getMaxMailSize() { return maxMailSize; }
48 51
49 void setOffline(bool b) {offline = b;} 52 void setOffline(bool b) {offline = b;}
50 bool getOffline()const{return offline;} 53 bool getOffline()const{return offline;}
51 54
52 bool getLeaveOnServer(){ return leaveOnServer;} 55 bool getLeaveOnServer(){ return leaveOnServer;}
53 void setLeaveOnServer(bool b){ leaveOnServer = b;} 56 void setLeaveOnServer(bool b){ leaveOnServer = b;}
54 57
55 virtual QString getFileName() { return accountName; } 58 virtual QString getFileName() { return accountName; }
56 virtual void read() { ; } 59 virtual void read() { ; }
57 virtual void save() { ; } 60 virtual void save() { ; }
58 61
59protected: 62protected:
60 QString accountName, server, port, user, password; 63 QString accountName, server, port, user, password;
61 bool ssl; 64 bool ssl;
62 int connectionType; 65 int connectionType;
63 bool offline; 66 bool offline;
64 MAILLIB::ATYPE type; 67 MAILLIB::ATYPE type;
65 QString localFolder; 68 QString localFolder;
66 int maxMailSize; 69 int maxMailSize;
67 QDateTime lastFetch; 70 QDateTime lastFetch;
68 bool leaveOnServer; 71 bool leaveOnServer;
69}; 72};
70 73
71class IMAPaccount : public Account 74class IMAPaccount : public Account