summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/editaccounts.cpp17
-rw-r--r--kmicromail/libmailwrapper/settings.cpp85
-rw-r--r--kmicromail/libmailwrapper/settings.h3
3 files changed, 80 insertions, 25 deletions
diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp
index e7d2750..d43d23b 100644
--- a/kmicromail/editaccounts.cpp
+++ b/kmicromail/editaccounts.cpp
@@ -1,606 +1,621 @@
1 1
2#include "defines.h" 2#include "defines.h"
3#include "editaccounts.h" 3#include "editaccounts.h"
4#include "kapplication.h" 4#include "kapplication.h"
5/* OPIE */ 5/* OPIE */
6#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
7 7
8/* QT */ 8/* QT */
9#include <qstringlist.h> 9#include <qstringlist.h>
10 10
11#include <qcombobox.h> 11#include <qcombobox.h>
12#include <qcheckbox.h> 12#include <qcheckbox.h>
13#include <qmessagebox.h> 13#include <qmessagebox.h>
14#include <qpushbutton.h> 14#include <qpushbutton.h>
15#include <qlineedit.h> 15#include <qlineedit.h>
16#include <qlabel.h> 16#include <qlabel.h>
17#include <qtabwidget.h> 17#include <qtabwidget.h>
18#include <qlistview.h> 18#include <qlistview.h>
19#include <qspinbox.h> 19#include <qspinbox.h>
20 20
21#include <libmailwrapper/nntpwrapper.h> 21#include <libmailwrapper/nntpwrapper.h>
22 22
23using namespace Opie::Core; 23using namespace Opie::Core;
24 24
25AccountListItem::AccountListItem( QListView *parent, Account *a) 25AccountListItem::AccountListItem( QListView *parent, Account *a)
26 : QListViewItem( parent ) 26 : QListViewItem( parent )
27{ 27{
28 account = a; 28 account = a;
29 setText( 0, account->getAccountName() ); 29 setText( 0, account->getAccountName() );
30 QString ttext = ""; 30 QString ttext = "";
31 switch (account->getType()) { 31 switch (account->getType()) {
32 case MAILLIB::A_NNTP: 32 case MAILLIB::A_NNTP:
33 ttext="NNTP"; 33 ttext="NNTP";
34 break; 34 break;
35 case MAILLIB::A_POP3: 35 case MAILLIB::A_POP3:
36 ttext = "POP3"; 36 ttext = "POP3";
37 break; 37 break;
38 case MAILLIB::A_IMAP: 38 case MAILLIB::A_IMAP:
39 ttext = "IMAP"; 39 ttext = "IMAP";
40 break; 40 break;
41 case MAILLIB::A_SMTP: 41 case MAILLIB::A_SMTP:
42 ttext = "SMTP"; 42 ttext = "SMTP";
43 break; 43 break;
44 default: 44 default:
45 ttext = "UNKNOWN"; 45 ttext = "UNKNOWN";
46 break; 46 break;
47 } 47 }
48 setText( 1, ttext); 48 setText( 1, ttext);
49} 49}
50 50
51EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 51EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
52 : EditAccountsUI( parent, name, modal, flags ) 52 : EditAccountsUI( parent, name, modal, flags )
53{ 53{
54 settings = s; 54 settings = s;
55 55
56 mailList->addColumn( tr( "Account" ) ); 56 mailList->addColumn( tr( "Account" ) );
57 mailList->addColumn( tr( "Type" ) ); 57 mailList->addColumn( tr( "Type" ) );
58 58
59 newsList->addColumn( tr( "Account" ) ); 59 newsList->addColumn( tr( "Account" ) );
60 60
61 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); 61 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) );
62 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); 62 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) );
63 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); 63 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) );
64 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); 64 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) );
65 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); 65 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) );
66 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); 66 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) );
67 67
68 slotFillLists(); 68 slotFillLists();
69} 69}
70 70
71void EditAccounts::slotFillLists() 71void EditAccounts::slotFillLists()
72{ 72{
73 mailList->clear(); 73 mailList->clear();
74 newsList->clear(); 74 newsList->clear();
75 75
76 QList<Account> accounts = settings->getAccounts(); 76 QList<Account> accounts = settings->getAccounts();
77 Account *it; 77 Account *it;
78 for ( it = accounts.first(); it; it = accounts.next() ) 78 for ( it = accounts.first(); it; it = accounts.next() )
79 { 79 {
80 if ( it->getType()==MAILLIB::A_NNTP ) 80 if ( it->getType()==MAILLIB::A_NNTP )
81 { 81 {
82 (void) new AccountListItem( newsList, it ); 82 (void) new AccountListItem( newsList, it );
83 } 83 }
84 else 84 else
85 { 85 {
86 (void) new AccountListItem( mailList, it ); 86 (void) new AccountListItem( mailList, it );
87 } 87 }
88 } 88 }
89} 89}
90 90
91void EditAccounts::slotNewMail() 91void EditAccounts::slotNewMail()
92{ 92{
93 QString *selection = new QString(); 93 QString *selection = new QString();
94 SelectMailType selType( selection, this, 0, true ); 94 SelectMailType selType( selection, this, 0, true );
95 selType.show(); 95 selType.show();
96 if ( QDialog::Accepted == selType.exec() ) 96 if ( QDialog::Accepted == selType.exec() )
97 { 97 {
98 slotNewAccount( *selection ); 98 slotNewAccount( *selection );
99 } 99 }
100} 100}
101 101
102void EditAccounts::slotNewAccount( const QString &type ) 102void EditAccounts::slotNewAccount( const QString &type )
103{ 103{
104 if ( type.compare( "IMAP" ) == 0 ) 104 if ( type.compare( "IMAP" ) == 0 )
105 { 105 {
106 IMAPaccount *account = new IMAPaccount(); 106 IMAPaccount *account = new IMAPaccount();
107 IMAPconfig imap( account, this, 0, true ); 107 IMAPconfig imap( account, this, 0, true );
108 imap.showMaximized(); 108 imap.showMaximized();
109 if ( QDialog::Accepted == imap.exec() ) 109 if ( QDialog::Accepted == imap.exec() )
110 { 110 {
111 settings->addAccount( account ); 111 settings->addAccount( account );
112 account->save(); 112 account->save();
113 slotFillLists(); 113 slotFillLists();
114 } 114 }
115 else 115 else
116 { 116 {
117 account->remove(); 117 account->remove();
118 } 118 }
119 } 119 }
120 else if ( type.compare( "POP3" ) == 0 ) 120 else if ( type.compare( "POP3" ) == 0 )
121 { 121 {
122 POP3account *account = new POP3account(); 122 POP3account *account = new POP3account();
123 POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); 123 POP3config pop3( account, this, 0, true, WStyle_ContextHelp );
124 if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) 124 if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) )
125 { 125 {
126 settings->addAccount( account ); 126 settings->addAccount( account );
127 account->save(); 127 account->save();
128 slotFillLists(); 128 slotFillLists();
129 } 129 }
130 else 130 else
131 { 131 {
132 account->remove(); 132 account->remove();
133 } 133 }
134 } 134 }
135 else if ( type.compare( "SMTP" ) == 0 ) 135 else if ( type.compare( "SMTP" ) == 0 )
136 { 136 {
137 SMTPaccount *account = new SMTPaccount(); 137 SMTPaccount *account = new SMTPaccount();
138 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); 138 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp );
139 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) 139 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) )
140 { 140 {
141 settings->addAccount( account ); 141 settings->addAccount( account );
142 account->save(); 142 account->save();
143 slotFillLists(); 143 slotFillLists();
144 144
145 } 145 }
146 else 146 else
147 { 147 {
148 account->remove(); 148 account->remove();
149 } 149 }
150 } 150 }
151 else if ( type.compare( "NNTP" ) == 0 ) 151 else if ( type.compare( "NNTP" ) == 0 )
152 { 152 {
153 NNTPaccount *account = new NNTPaccount(); 153 NNTPaccount *account = new NNTPaccount();
154 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); 154 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp );
155 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) 155 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) )
156 { 156 {
157 settings->addAccount( account ); 157 settings->addAccount( account );
158 account->save(); 158 account->save();
159 slotFillLists(); 159 slotFillLists();
160 } 160 }
161 else 161 else
162 { 162 {
163 account->remove(); 163 account->remove();
164 } 164 }
165 } 165 }
166} 166}
167 167
168void EditAccounts::slotEditAccount( Account *account ) 168void EditAccounts::slotEditAccount( Account *account )
169{ 169{
170 if ( account->getType() == MAILLIB::A_IMAP ) 170 if ( account->getType() == MAILLIB::A_IMAP )
171 { 171 {
172 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); 172 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account);
173 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); 173 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp );
174 if ( QDialog::Accepted == KApplication::execDialog( &imap ) ) 174 if ( QDialog::Accepted == KApplication::execDialog( &imap ) )
175 { 175 {
176 slotFillLists(); 176 slotFillLists();
177 } 177 }
178 } 178 }
179 else if ( account->getType()==MAILLIB::A_POP3 ) 179 else if ( account->getType()==MAILLIB::A_POP3 )
180 { 180 {
181 POP3account *pop3Acc = static_cast<POP3account *>(account); 181 POP3account *pop3Acc = static_cast<POP3account *>(account);
182 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); 182 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp );
183 if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) ) 183 if ( QDialog::Accepted == KApplication::execDialog( &pop3 ) )
184 { 184 {
185 slotFillLists(); 185 slotFillLists();
186 } 186 }
187 } 187 }
188 else if ( account->getType()==MAILLIB::A_SMTP ) 188 else if ( account->getType()==MAILLIB::A_SMTP )
189 { 189 {
190 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); 190 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account);
191 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); 191 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp );
192 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) ) 192 if ( QDialog::Accepted == KApplication::execDialog( &smtp ) )
193 { 193 {
194 slotFillLists(); 194 slotFillLists();
195 } 195 }
196 } 196 }
197 else if ( account->getType()==MAILLIB::A_NNTP) 197 else if ( account->getType()==MAILLIB::A_NNTP)
198 { 198 {
199 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); 199 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account);
200 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); 200 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp );
201 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) ) 201 if ( QDialog::Accepted == KApplication::execDialog( &nntp ) )
202 { 202 {
203 slotFillLists(); 203 slotFillLists();
204 } 204 }
205 } 205 }
206} 206}
207 207
208void EditAccounts::slotDeleteAccount( Account *account ) 208void EditAccounts::slotDeleteAccount( Account *account )
209{ 209{
210 if ( QMessageBox::information( this, tr( "Question" ), 210 if ( QMessageBox::information( this, tr( "Question" ),
211 tr( "<p>Do you really want to delete the selected Account?</p>" ), 211 tr( "<p>Do you really want to delete the selected Account?</p>" ),
212 tr( "Yes" ), tr( "No" ) ) == 0 ) 212 tr( "Yes" ), tr( "No" ) ) == 0 )
213 { 213 {
214 settings->delAccount( account ); 214 settings->delAccount( account );
215 slotFillLists(); 215 slotFillLists();
216 } 216 }
217} 217}
218 218
219void EditAccounts::slotEditMail() 219void EditAccounts::slotEditMail()
220{ 220{
221 if ( !mailList->currentItem() ) 221 if ( !mailList->currentItem() )
222 { 222 {
223 QMessageBox::information( this, tr( "Error" ), 223 QMessageBox::information( this, tr( "Error" ),
224 tr( "<p>Please select an account.</p>" ), 224 tr( "<p>Please select an account.</p>" ),
225 tr( "Ok" ) ); 225 tr( "Ok" ) );
226 return; 226 return;
227 } 227 }
228 228
229 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 229 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
230 slotEditAccount( a ); 230 slotEditAccount( a );
231} 231}
232 232
233void EditAccounts::slotDeleteMail() 233void EditAccounts::slotDeleteMail()
234{ 234{
235 if ( !mailList->currentItem() ) 235 if ( !mailList->currentItem() )
236 { 236 {
237 QMessageBox::information( this, tr( "Error" ), 237 QMessageBox::information( this, tr( "Error" ),
238 tr( "<p>Please select an account.</p>" ), 238 tr( "<p>Please select an account.</p>" ),
239 tr( "Ok" ) ); 239 tr( "Ok" ) );
240 return; 240 return;
241 } 241 }
242 242
243 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 243 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
244 slotDeleteAccount( a ); 244 slotDeleteAccount( a );
245} 245}
246 246
247void EditAccounts::slotNewNews() 247void EditAccounts::slotNewNews()
248{ 248{
249 slotNewAccount( "NNTP" ); 249 slotNewAccount( "NNTP" );
250} 250}
251 251
252void EditAccounts::slotEditNews() 252void EditAccounts::slotEditNews()
253{ 253{
254 if ( !newsList->currentItem() ) 254 if ( !newsList->currentItem() )
255 { 255 {
256 QMessageBox::information( this, tr( "Error" ), 256 QMessageBox::information( this, tr( "Error" ),
257 tr( "<p>Please select an account.</p>" ), 257 tr( "<p>Please select an account.</p>" ),
258 tr( "Ok" ) ); 258 tr( "Ok" ) );
259 return; 259 return;
260 } 260 }
261 261
262 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 262 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
263 slotEditAccount( a ); 263 slotEditAccount( a );
264} 264}
265 265
266void EditAccounts::slotDeleteNews() 266void EditAccounts::slotDeleteNews()
267{ 267{
268 if ( !newsList->currentItem() ) 268 if ( !newsList->currentItem() )
269 { 269 {
270 QMessageBox::information( this, tr( "Error" ), 270 QMessageBox::information( this, tr( "Error" ),
271 tr( "<p>Please select an account.</p>" ), 271 tr( "<p>Please select an account.</p>" ),
272 tr( "Ok" ) ); 272 tr( "Ok" ) );
273 return; 273 return;
274 } 274 }
275 275
276 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 276 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
277 slotDeleteAccount( a ); 277 slotDeleteAccount( a );
278} 278}
279 279
280void EditAccounts::slotAdjustColumns() 280void EditAccounts::slotAdjustColumns()
281{ 281{
282 int currPage = configTab->currentPageIndex(); 282 int currPage = configTab->currentPageIndex();
283 283
284 configTab->showPage( mailTab ); 284 configTab->showPage( mailTab );
285 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); 285 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 );
286 mailList->setColumnWidth( 1, 50 ); 286 mailList->setColumnWidth( 1, 50 );
287 287
288 configTab->showPage( newsTab ); 288 configTab->showPage( newsTab );
289 newsList->setColumnWidth( 0, newsList->visibleWidth() ); 289 newsList->setColumnWidth( 0, newsList->visibleWidth() );
290 290
291 configTab->setCurrentPage( currPage ); 291 configTab->setCurrentPage( currPage );
292} 292}
293 293
294void EditAccounts::accept() 294void EditAccounts::accept()
295{ 295{
296 settings->saveAccounts(); 296 settings->saveAccounts();
297 297
298 QDialog::accept(); 298 QDialog::accept();
299} 299}
300 300
301/** 301/**
302 * SelectMailType 302 * SelectMailType
303 */ 303 */
304 304
305SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) 305SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags )
306 : SelectMailTypeUI( parent, name, modal, flags ) 306 : SelectMailTypeUI( parent, name, modal, flags )
307{ 307{
308 selected = selection; 308 selected = selection;
309 selected->replace( 0, selected->length(), typeBox->currentText() ); 309 selected->replace( 0, selected->length(), typeBox->currentText() );
310 connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); 310 connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) );
311} 311}
312 312
313void SelectMailType::slotSelection( const QString &sel ) 313void SelectMailType::slotSelection( const QString &sel )
314{ 314{
315 selected->replace( 0, selected->length(), sel ); 315 selected->replace( 0, selected->length(), sel );
316} 316}
317 317
318/** 318/**
319 * IMAPconfig 319 * IMAPconfig
320 */ 320 */
321 321
322IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 322IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
323 : IMAPconfigUI( parent, name, modal, flags ) 323 : IMAPconfigUI( parent, name, modal, flags )
324{ 324{
325 data = account; 325 data = account;
326 326
327 fillValues(); 327 fillValues();
328 328
329 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 329 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
330 ComboBox1->insertItem( "Only if available", 0 ); 330 ComboBox1->insertItem( "Only if available", 0 );
331 ComboBox1->insertItem( "Always, Negotiated", 1 ); 331 ComboBox1->insertItem( "Always, Negotiated", 1 );
332 ComboBox1->insertItem( "Connect on secure port", 2 ); 332 ComboBox1->insertItem( "Connect on secure port", 2 );
333 ComboBox1->insertItem( "Run command instead", 3 ); 333 ComboBox1->insertItem( "Run command instead", 3 );
334 CommandEdit->hide(); 334 CommandEdit->hide();
335 ComboBox1->setCurrentItem( data->ConnectionType() ); 335 ComboBox1->setCurrentItem( data->ConnectionType() );
336} 336}
337 337
338void IMAPconfig::slotConnectionToggle( int index ) 338void IMAPconfig::slotConnectionToggle( int index )
339{ 339{
340 if ( index == 2 ) 340 if ( index == 2 )
341 { 341 {
342 portLine->setText( IMAP_SSL_PORT ); 342 portLine->setText( IMAP_SSL_PORT );
343 } 343 }
344 else if ( index == 3 ) 344 else if ( index == 3 )
345 { 345 {
346 portLine->setText( IMAP_PORT ); 346 portLine->setText( IMAP_PORT );
347 CommandEdit->show(); 347 CommandEdit->show();
348 } 348 }
349 else 349 else
350 { 350 {
351 portLine->setText( IMAP_PORT ); 351 portLine->setText( IMAP_PORT );
352 } 352 }
353} 353}
354 354
355void IMAPconfig::fillValues() 355void IMAPconfig::fillValues()
356{ 356{
357 accountLine->setText( data->getAccountName() ); 357 accountLine->setText( data->getAccountName() );
358 serverLine->setText( data->getServer() ); 358 serverLine->setText( data->getServer() );
359 portLine->setText( data->getPort() ); 359 portLine->setText( data->getPort() );
360 ComboBox1->setCurrentItem( data->ConnectionType() ); 360 ComboBox1->setCurrentItem( data->ConnectionType() );
361 userLine->setText( data->getUser() ); 361 userLine->setText( data->getUser() );
362 passLine->setText( data->getPassword() ); 362 passLine->setText( data->getPassword() );
363 prefixLine->setText(data->getPrefix()); 363 prefixLine->setText(data->getPrefix());
364 localFolder->setText( data->getLocalFolder() );
365 int max = data->getMaxMailSize() ;
366 if ( max ) {
367 CheckBoxDown->setChecked( true );
368 SpinBoxDown->setValue ( max );
369 } else {
370 CheckBoxDown->setChecked( false );
371 SpinBoxDown->setValue ( 5 );
372 }
373 CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() );
364} 374}
365 375
366void IMAPconfig::accept() 376void IMAPconfig::accept()
367{ 377{
368 data->setAccountName( accountLine->text() ); 378 data->setAccountName( accountLine->text() );
369 data->setServer( serverLine->text() ); 379 data->setServer( serverLine->text() );
370 data->setPort( portLine->text() ); 380 data->setPort( portLine->text() );
371 data->setConnectionType( ComboBox1->currentItem() ); 381 data->setConnectionType( ComboBox1->currentItem() );
372 data->setUser( userLine->text() ); 382 data->setUser( userLine->text() );
373 data->setPassword( passLine->text() ); 383 data->setPassword( passLine->text() );
374 data->setPrefix(prefixLine->text()); 384 data->setPrefix(prefixLine->text());
385 data->setLocalFolder( localFolder->text() );
386 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ;
387 data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() );
375 388
376 QDialog::accept(); 389 QDialog::accept();
377} 390}
378 391
379/** 392/**
380 * POP3config 393 * POP3config
381 */ 394 */
382 395
383POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 396POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags )
384 : POP3configUI( parent, name, modal, flags ) 397 : POP3configUI( parent, name, modal, flags )
385{ 398{
386 data = account; 399 data = account;
387 fillValues(); 400 fillValues();
388 401
389 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 402 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
390 ComboBox1->insertItem( "Only if available", 0 ); 403 ComboBox1->insertItem( "Only if available", 0 );
391 ComboBox1->insertItem( "Always, Negotiated", 1 ); 404 ComboBox1->insertItem( "Always, Negotiated", 1 );
392 ComboBox1->insertItem( "Connect on secure port", 2 ); 405 ComboBox1->insertItem( "Connect on secure port", 2 );
393 ComboBox1->insertItem( "Run command instead", 3 ); 406 ComboBox1->insertItem( "Run command instead", 3 );
394 CommandEdit->hide(); 407 CommandEdit->hide();
395 ComboBox1->setCurrentItem( data->ConnectionType() ); 408 ComboBox1->setCurrentItem( data->ConnectionType() );
396} 409}
397 410
398void POP3config::slotConnectionToggle( int index ) 411void POP3config::slotConnectionToggle( int index )
399{ 412{
400 // 2 is ssl connection 413 // 2 is ssl connection
401 if ( index == 2 ) 414 if ( index == 2 )
402 { 415 {
403 portLine->setText( POP3_SSL_PORT ); 416 portLine->setText( POP3_SSL_PORT );
404 } 417 }
405 else if ( index == 3 ) 418 else if ( index == 3 )
406 { 419 {
407 portLine->setText( POP3_PORT ); 420 portLine->setText( POP3_PORT );
408 CommandEdit->show(); 421 CommandEdit->show();
409 } 422 }
410 else 423 else
411 { 424 {
412 portLine->setText( POP3_PORT ); 425 portLine->setText( POP3_PORT );
413 } 426 }
414} 427}
415 428
416void POP3config::fillValues() 429void POP3config::fillValues()
417{ 430{
418 accountLine->setText( data->getAccountName() ); 431 accountLine->setText( data->getAccountName() );
419 serverLine->setText( data->getServer() ); 432 serverLine->setText( data->getServer() );
420 portLine->setText( data->getPort() ); 433 portLine->setText( data->getPort() );
421 ComboBox1->setCurrentItem( data->ConnectionType() ); 434 ComboBox1->setCurrentItem( data->ConnectionType() );
422 userLine->setText( data->getUser() ); 435 userLine->setText( data->getUser() );
423 passLine->setText( data->getPassword() ); 436 passLine->setText( data->getPassword() );
424 localFolder->setText( data->getLocalFolder() ); 437 localFolder->setText( data->getLocalFolder() );
425 int max = data->getMaxMailSize() ; 438 int max = data->getMaxMailSize() ;
426 if ( max ) { 439 if ( max ) {
427 CheckBoxDown->setChecked( true ); 440 CheckBoxDown->setChecked( true );
428 SpinBoxDown->setValue ( max ); 441 SpinBoxDown->setValue ( max );
429 } else { 442 } else {
430 CheckBoxDown->setChecked( false ); 443 CheckBoxDown->setChecked( false );
431 SpinBoxDown->setValue ( 5 ); 444 SpinBoxDown->setValue ( 5 );
432 } 445 }
446 CheckBoxLeaveOn->setChecked( data->getLeaveOnServer() );
433} 447}
434 448
435void POP3config::accept() 449void POP3config::accept()
436{ 450{
437 data->setAccountName( accountLine->text() ); 451 data->setAccountName( accountLine->text() );
438 data->setServer( serverLine->text() ); 452 data->setServer( serverLine->text() );
439 data->setPort( portLine->text() ); 453 data->setPort( portLine->text() );
440 data->setConnectionType( ComboBox1->currentItem() ); 454 data->setConnectionType( ComboBox1->currentItem() );
441 data->setUser( userLine->text() ); 455 data->setUser( userLine->text() );
442 data->setPassword( passLine->text() ); 456 data->setPassword( passLine->text() );
443 data->setLocalFolder( localFolder->text() ); 457 data->setLocalFolder( localFolder->text() );
444 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ; 458 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ;
459 data->setLeaveOnServer( CheckBoxLeaveOn->isChecked() );
445 460
446 QDialog::accept(); 461 QDialog::accept();
447} 462}
448 463
449/** 464/**
450 * SMTPconfig 465 * SMTPconfig
451 */ 466 */
452 467
453SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 468SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
454 : SMTPconfigUI( parent, name, modal, flags ) 469 : SMTPconfigUI( parent, name, modal, flags )
455{ 470{
456 data = account; 471 data = account;
457 472
458 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 473 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
459 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 474 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
460 475
461 fillValues(); 476 fillValues();
462 477
463 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 478 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
464 ComboBox1->insertItem( "Only if available", 0 ); 479 ComboBox1->insertItem( "Only if available", 0 );
465 ComboBox1->insertItem( "Always, Negotiated", 1 ); 480 ComboBox1->insertItem( "Always, Negotiated", 1 );
466 ComboBox1->insertItem( "Connect on secure port", 2 ); 481 ComboBox1->insertItem( "Connect on secure port", 2 );
467 ComboBox1->insertItem( "Run command instead", 3 ); 482 ComboBox1->insertItem( "Run command instead", 3 );
468 CommandEdit->hide(); 483 CommandEdit->hide();
469 ComboBox1->setCurrentItem( data->ConnectionType() ); 484 ComboBox1->setCurrentItem( data->ConnectionType() );
470} 485}
471 486
472void SMTPconfig::slotConnectionToggle( int index ) 487void SMTPconfig::slotConnectionToggle( int index )
473{ 488{
474 // 2 is ssl connection 489 // 2 is ssl connection
475 if ( index == 2 ) 490 if ( index == 2 )
476 { 491 {
477 portLine->setText( SMTP_SSL_PORT ); 492 portLine->setText( SMTP_SSL_PORT );
478 } 493 }
479 else if ( index == 3 ) 494 else if ( index == 3 )
480 { 495 {
481 portLine->setText( SMTP_PORT ); 496 portLine->setText( SMTP_PORT );
482 CommandEdit->show(); 497 CommandEdit->show();
483 } 498 }
484 else 499 else
485 { 500 {
486 portLine->setText( SMTP_PORT ); 501 portLine->setText( SMTP_PORT );
487 } 502 }
488} 503}
489 504
490void SMTPconfig::fillValues() 505void SMTPconfig::fillValues()
491{ 506{
492 accountLine->setText( data->getAccountName() ); 507 accountLine->setText( data->getAccountName() );
493 serverLine->setText( data->getServer() ); 508 serverLine->setText( data->getServer() );
494 portLine->setText( data->getPort() ); 509 portLine->setText( data->getPort() );
495 ComboBox1->setCurrentItem( data->ConnectionType() ); 510 ComboBox1->setCurrentItem( data->ConnectionType() );
496 loginBox->setChecked( data->getLogin() ); 511 loginBox->setChecked( data->getLogin() );
497 userLine->setText( data->getUser() ); 512 userLine->setText( data->getUser() );
498 passLine->setText( data->getPassword() ); 513 passLine->setText( data->getPassword() );
499} 514}
500 515
501void SMTPconfig::accept() 516void SMTPconfig::accept()
502{ 517{
503 data->setAccountName( accountLine->text() ); 518 data->setAccountName( accountLine->text() );
504 data->setServer( serverLine->text() ); 519 data->setServer( serverLine->text() );
505 data->setPort( portLine->text() ); 520 data->setPort( portLine->text() );
506 data->setConnectionType( ComboBox1->currentItem() ); 521 data->setConnectionType( ComboBox1->currentItem() );
507 data->setLogin( loginBox->isChecked() ); 522 data->setLogin( loginBox->isChecked() );
508 data->setUser( userLine->text() ); 523 data->setUser( userLine->text() );
509 data->setPassword( passLine->text() ); 524 data->setPassword( passLine->text() );
510 525
511 QDialog::accept(); 526 QDialog::accept();
512} 527}
513 528
514/** 529/**
515 * NNTPconfig 530 * NNTPconfig
516 */ 531 */
517 532
518NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 533NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
519 : NNTPconfigUI( parent, name, modal, flags ) 534 : NNTPconfigUI( parent, name, modal, flags )
520{ 535{
521 data = account; 536 data = account;
522 537
523 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 538 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
524 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 539 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
525 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); 540 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) );
526 fillValues(); 541 fillValues();
527 542
528 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); 543 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) );
529} 544}
530 545
531void NNTPconfig::slotGetNG() { 546void NNTPconfig::slotGetNG() {
532 save(); 547 save();
533 data->save(); 548 data->save();
534 NNTPwrapper* tmp = new NNTPwrapper( data ); 549 NNTPwrapper* tmp = new NNTPwrapper( data );
535 QStringList list = tmp->listAllNewsgroups(); 550 QStringList list = tmp->listAllNewsgroups();
536 551
537 ListViewGroups->clear(); 552 ListViewGroups->clear();
538 553
539 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 554 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
540 QCheckListItem *item; 555 QCheckListItem *item;
541 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); 556 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
542 if ( subscribedGroups.contains( (*it) ) >= 1 ) { 557 if ( subscribedGroups.contains( (*it) ) >= 1 ) {
543 item->setOn( true ); 558 item->setOn( true );
544 } 559 }
545 } 560 }
546} 561}
547 562
548void NNTPconfig::slotSSL( bool enabled ) 563void NNTPconfig::slotSSL( bool enabled )
549{ 564{
550 if ( enabled ) 565 if ( enabled )
551 { 566 {
552 portLine->setText( NNTP_SSL_PORT ); 567 portLine->setText( NNTP_SSL_PORT );
553 } 568 }
554 else 569 else
555 { 570 {
556 portLine->setText( NNTP_PORT ); 571 portLine->setText( NNTP_PORT );
557 } 572 }
558} 573}
559 574
560void NNTPconfig::fillValues() 575void NNTPconfig::fillValues()
561{ 576{
562 accountLine->setText( data->getAccountName() ); 577 accountLine->setText( data->getAccountName() );
563 serverLine->setText( data->getServer() ); 578 serverLine->setText( data->getServer() );
564 portLine->setText( data->getPort() ); 579 portLine->setText( data->getPort() );
565 sslBox->setChecked( data->getSSL() ); 580 sslBox->setChecked( data->getSSL() );
566 loginBox->setChecked( data->getLogin() ); 581 loginBox->setChecked( data->getLogin() );
567 userLine->setText( data->getUser() ); 582 userLine->setText( data->getUser() );
568 passLine->setText( data->getPassword() ); 583 passLine->setText( data->getPassword() );
569 subscribedGroups = data->getGroups(); 584 subscribedGroups = data->getGroups();
570 /* don't forget that - you will overwrite values if user clicks cancel! */ 585 /* don't forget that - you will overwrite values if user clicks cancel! */
571 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { 586 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) {
572 QCheckListItem *item; 587 QCheckListItem *item;
573 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); 588 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
574 item->setOn( true ); 589 item->setOn( true );
575 } 590 }
576} 591}
577 592
578void NNTPconfig::save() 593void NNTPconfig::save()
579{ 594{
580 data->setAccountName( accountLine->text() ); 595 data->setAccountName( accountLine->text() );
581 data->setServer( serverLine->text() ); 596 data->setServer( serverLine->text() );
582 data->setPort( portLine->text() ); 597 data->setPort( portLine->text() );
583 data->setSSL( sslBox->isChecked() ); 598 data->setSSL( sslBox->isChecked() );
584 data->setLogin( loginBox->isChecked() ); 599 data->setLogin( loginBox->isChecked() );
585 data->setUser( userLine->text() ); 600 data->setUser( userLine->text() );
586 data->setPassword( passLine->text() ); 601 data->setPassword( passLine->text() );
587 602
588 QListViewItemIterator list_it( ListViewGroups ); 603 QListViewItemIterator list_it( ListViewGroups );
589 604
590 QStringList groupList; 605 QStringList groupList;
591 for ( ; list_it.current(); ++list_it ) { 606 for ( ; list_it.current(); ++list_it ) {
592 607
593 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { 608 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) {
594 groupList.append( list_it.current()->text(0) ); 609 groupList.append( list_it.current()->text(0) );
595 } 610 }
596 611
597 } 612 }
598 data->setGroups( groupList ); 613 data->setGroups( groupList );
599} 614}
600 615
601void NNTPconfig::accept() 616void NNTPconfig::accept()
602{ 617{
603 save(); 618 save();
604 QDialog::accept(); 619 QDialog::accept();
605} 620}
606 621
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,464 +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 <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 */
38} 38}
39 39
40QList<Account> Settings::getAccounts() 40QList<Account> Settings::getAccounts()
41{ 41{
42 return accounts; 42 return accounts;
43} 43}
44 44
45void Settings::addAccount( Account *account ) 45void Settings::addAccount( Account *account )
46{ 46{
47 accounts.append( account ); 47 accounts.append( account );
48} 48}
49 49
50void Settings::delAccount( Account *account ) 50void Settings::delAccount( Account *account )
51{ 51{
52 accounts.remove( account ); 52 accounts.remove( account );
53 account->remove(); 53 account->remove();
54} 54}
55 55
56void Settings::updateAccounts() 56void Settings::updateAccounts()
57{ 57{
58 accounts.clear(); 58 accounts.clear();
59 QDir dir( locateLocal("data", "kopiemail" ) ); 59 QDir dir( locateLocal("data", "kopiemail" ) );
60 QStringList::Iterator it; 60 QStringList::Iterator it;
61 61
62 QStringList imap = dir.entryList( "imap-*" ); 62 QStringList imap = dir.entryList( "imap-*" );
63 for ( it = imap.begin(); it != imap.end(); it++ ) { 63 for ( it = imap.begin(); it != imap.end(); it++ ) {
64 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); 64 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") );
65 accounts.append( account ); 65 accounts.append( account );
66 } 66 }
67 67
68 QStringList pop3 = dir.entryList( "pop3-*" ); 68 QStringList pop3 = dir.entryList( "pop3-*" );
69 for ( it = pop3.begin(); it != pop3.end(); it++ ) { 69 for ( it = pop3.begin(); it != pop3.end(); it++ ) {
70 POP3account *account = new POP3account( (*it).replace(0, 5, "") ); 70 POP3account *account = new POP3account( (*it).replace(0, 5, "") );
71 accounts.append( account ); 71 accounts.append( account );
72 } 72 }
73 73
74 QStringList smtp = dir.entryList( "smtp-*" ); 74 QStringList smtp = dir.entryList( "smtp-*" );
75 for ( it = smtp.begin(); it != smtp.end(); it++ ) { 75 for ( it = smtp.begin(); it != smtp.end(); it++ ) {
76 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); 76 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") );
77 accounts.append( account ); 77 accounts.append( account );
78 } 78 }
79 79
80 QStringList nntp = dir.entryList( "nntp-*" ); 80 QStringList nntp = dir.entryList( "nntp-*" );
81 for ( it = nntp.begin(); it != nntp.end(); it++ ) { 81 for ( it = nntp.begin(); it != nntp.end(); it++ ) {
82 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); 82 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") );
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
@@ -1,177 +1,180 @@
1#ifndef SETTINGS_H 1#ifndef SETTINGS_H
2#define SETTINGS_H 2#define SETTINGS_H
3 3
4#include "maildefines.h" 4#include "maildefines.h"
5 5
6/* OPIE */ 6/* OPIE */
7 7
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
72{ 75{
73 76
74public: 77public:
75 IMAPaccount(); 78 IMAPaccount();
76 IMAPaccount( QString filename ); 79 IMAPaccount( QString filename );
77 80
78 static QString getUniqueFileName(); 81 static QString getUniqueFileName();
79 82
80 virtual void read(); 83 virtual void read();
81 virtual void save(); 84 virtual void save();
82 virtual QString getFileName(); 85 virtual QString getFileName();
83 86
84 void setPrefix(const QString&str) {prefix=str;} 87 void setPrefix(const QString&str) {prefix=str;}
85 const QString&getPrefix()const{return prefix;} 88 const QString&getPrefix()const{return prefix;}
86 89
87private: 90private:
88 QString file,prefix; 91 QString file,prefix;
89 92
90}; 93};
91 94
92class POP3account : public Account 95class POP3account : public Account
93{ 96{
94 97
95public: 98public:
96 POP3account(); 99 POP3account();
97 POP3account( QString filename ); 100 POP3account( QString filename );
98 101
99 static QString getUniqueFileName(); 102 static QString getUniqueFileName();
100 103
101 virtual void read(); 104 virtual void read();
102 virtual void save(); 105 virtual void save();
103 virtual QString getFileName(); 106 virtual QString getFileName();
104 107
105private: 108private:
106 QString file; 109 QString file;
107 110
108}; 111};
109 112
110class SMTPaccount : public Account 113class SMTPaccount : public Account
111{ 114{
112 115
113public: 116public:
114 SMTPaccount(); 117 SMTPaccount();
115 SMTPaccount( QString filename ); 118 SMTPaccount( QString filename );
116 119
117 static QString getUniqueFileName(); 120 static QString getUniqueFileName();
118 121
119 virtual void read(); 122 virtual void read();
120 virtual void save(); 123 virtual void save();
121 virtual QString getFileName(); 124 virtual QString getFileName();
122 125
123 void setLogin( bool b ) { login = b; } 126 void setLogin( bool b ) { login = b; }
124 bool getLogin() { return login; } 127 bool getLogin() { return login; }
125 128
126private: 129private:
127 QString file, name, mail, org, cc, bcc, reply, signature; 130 QString file, name, mail, org, cc, bcc, reply, signature;
128 bool useCC, useBCC, useReply, login; 131 bool useCC, useBCC, useReply, login;
129 132
130}; 133};
131 134
132class NNTPaccount : public Account 135class NNTPaccount : public Account
133{ 136{
134 137
135public: 138public:
136 NNTPaccount(); 139 NNTPaccount();
137 NNTPaccount( QString filename ); 140 NNTPaccount( QString filename );
138 141
139 static QString getUniqueFileName(); 142 static QString getUniqueFileName();
140 143
141 virtual void read(); 144 virtual void read();
142 virtual void save(); 145 virtual void save();
143 virtual QString getFileName(); 146 virtual QString getFileName();
144 147
145 void setLogin( bool b ) { login = b; } 148 void setLogin( bool b ) { login = b; }
146 bool getLogin() { return login; } 149 bool getLogin() { return login; }
147 150
148 void setGroups( QStringList list ) { subscribedGroups = list; } 151 void setGroups( QStringList list ) { subscribedGroups = list; }
149 QStringList getGroups() { return subscribedGroups; } 152 QStringList getGroups() { return subscribedGroups; }
150 153
151private: 154private:
152 QString file; 155 QString file;
153 bool login; 156 bool login;
154 QStringList subscribedGroups; 157 QStringList subscribedGroups;
155 158
156}; 159};
157 160
158class Settings : public QObject 161class Settings : public QObject
159{ 162{
160 Q_OBJECT 163 Q_OBJECT
161 164
162public: 165public:
163 Settings(); 166 Settings();
164 QList<Account> getAccounts(); 167 QList<Account> getAccounts();
165 void addAccount(Account *account); 168 void addAccount(Account *account);
166 void delAccount(Account *account); 169 void delAccount(Account *account);
167 void saveAccounts(); 170 void saveAccounts();
168 void readAccounts(); 171 void readAccounts();
169 static void checkDirectory(); 172 static void checkDirectory();
170 173
171private: 174private:
172 void updateAccounts(); 175 void updateAccounts();
173 QList<Account> accounts; 176 QList<Account> accounts;
174 177
175}; 178};
176 179
177#endif 180#endif