summaryrefslogtreecommitdiffabout
path: root/kmicromail/libmailwrapper
authorzautrix <zautrix>2004-12-13 12:35:00 (UTC)
committer zautrix <zautrix>2004-12-13 12:35:00 (UTC)
commit7ac6c21e832b7d16bd0888d0b66252b6e152005a (patch) (unidiff)
treec7610e0e25020f19af82ac6257c2debab2638316 /kmicromail/libmailwrapper
parent17b25691f0332e648dd1d800e89ccf4e1da8955d (diff)
downloadkdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.zip
kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.tar.gz
kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.tar.bz2
many bugfixes
Diffstat (limited to 'kmicromail/libmailwrapper') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libmailwrapper/settings.cpp2
1 files changed, 1 insertions, 1 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}