summaryrefslogtreecommitdiff
authorharlekin <harlekin>2004-03-06 00:20:22 (UTC)
committer harlekin <harlekin>2004-03-06 00:20:22 (UTC)
commit7b10be8e0ed88afe9e8964e6b5f1fe449cee3609 (patch) (unidiff)
tree149f8aecef57768cd4cf9e0c35778a711c5b6cf4
parent6afcd375a640d5c6888bc111cd1d80a08f554136 (diff)
downloadopie-7b10be8e0ed88afe9e8964e6b5f1fe449cee3609.zip
opie-7b10be8e0ed88afe9e8964e6b5f1fe449cee3609.tar.gz
opie-7b10be8e0ed88afe9e8964e6b5f1fe449cee3609.tar.bz2
save selected newsgroups
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/editaccounts.cpp16
-rw-r--r--noncore/net/mail/editaccounts.h1
-rw-r--r--noncore/net/mail/libmailwrapper/settings.cpp2
-rw-r--r--noncore/net/mail/libmailwrapper/settings.h4
4 files changed, 19 insertions, 4 deletions
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp
index 2a1acc0..215380d 100644
--- a/noncore/net/mail/editaccounts.cpp
+++ b/noncore/net/mail/editaccounts.cpp
@@ -1,567 +1,575 @@
1 1
2#include "defines.h" 2#include "defines.h"
3#include "editaccounts.h" 3#include "editaccounts.h"
4 4
5/* OPIE */ 5/* OPIE */
6#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
7 7
8/* QT */ 8/* QT */
9#include <qt.h> 9#include <qt.h>
10#include <qstringlist.h>
10 11
11#include <libmailwrapper/nntpwrapper.h> 12#include <libmailwrapper/nntpwrapper.h>
12 13
13#include <libetpan/nntpdriver.h> 14#include <libetpan/nntpdriver.h>
14 15
15AccountListItem::AccountListItem( QListView *parent, Account *a) 16AccountListItem::AccountListItem( QListView *parent, Account *a)
16 : QListViewItem( parent ) 17 : QListViewItem( parent )
17{ 18{
18 account = a; 19 account = a;
19 setText( 0, account->getAccountName() ); 20 setText( 0, account->getAccountName() );
20 setText( 1, account->getType() ); 21 setText( 1, account->getType() );
21} 22}
22 23
23EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 24EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
24 : EditAccountsUI( parent, name, modal, flags ) 25 : EditAccountsUI( parent, name, modal, flags )
25{ 26{
26 qDebug( "New Account Configuration Widget" ); 27 qDebug( "New Account Configuration Widget" );
27 settings = s; 28 settings = s;
28 29
29 mailList->addColumn( tr( "Account" ) ); 30 mailList->addColumn( tr( "Account" ) );
30 mailList->addColumn( tr( "Type" ) ); 31 mailList->addColumn( tr( "Type" ) );
31 32
32 newsList->addColumn( tr( "Account" ) ); 33 newsList->addColumn( tr( "Account" ) );
33 34
34 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); 35 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) );
35 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); 36 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) );
36 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); 37 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) );
37 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); 38 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) );
38 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); 39 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) );
39 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); 40 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) );
40 41
41 slotFillLists(); 42 slotFillLists();
42} 43}
43 44
44void EditAccounts::slotFillLists() 45void EditAccounts::slotFillLists()
45{ 46{
46 mailList->clear(); 47 mailList->clear();
47 newsList->clear(); 48 newsList->clear();
48 49
49 QList<Account> accounts = settings->getAccounts(); 50 QList<Account> accounts = settings->getAccounts();
50 Account *it; 51 Account *it;
51 for ( it = accounts.first(); it; it = accounts.next() ) 52 for ( it = accounts.first(); it; it = accounts.next() )
52 { 53 {
53 if ( it->getType().compare( "NNTP" ) == 0 ) 54 if ( it->getType().compare( "NNTP" ) == 0 )
54 { 55 {
55 (void) new AccountListItem( newsList, it ); 56 (void) new AccountListItem( newsList, it );
56 } 57 }
57 else 58 else
58 { 59 {
59 (void) new AccountListItem( mailList, it ); 60 (void) new AccountListItem( mailList, it );
60 } 61 }
61 } 62 }
62} 63}
63 64
64void EditAccounts::slotNewMail() 65void EditAccounts::slotNewMail()
65{ 66{
66 qDebug( "New Mail Account" ); 67 qDebug( "New Mail Account" );
67 QString *selection = new QString(); 68 QString *selection = new QString();
68 SelectMailType selType( selection, this, 0, true ); 69 SelectMailType selType( selection, this, 0, true );
69 selType.show(); 70 selType.show();
70 if ( QDialog::Accepted == selType.exec() ) 71 if ( QDialog::Accepted == selType.exec() )
71 { 72 {
72 slotNewAccount( *selection ); 73 slotNewAccount( *selection );
73 } 74 }
74} 75}
75 76
76void EditAccounts::slotNewAccount( const QString &type ) 77void EditAccounts::slotNewAccount( const QString &type )
77{ 78{
78 if ( type.compare( "IMAP" ) == 0 ) 79 if ( type.compare( "IMAP" ) == 0 )
79 { 80 {
80 qDebug( "-> config IMAP" ); 81 qDebug( "-> config IMAP" );
81 IMAPaccount *account = new IMAPaccount(); 82 IMAPaccount *account = new IMAPaccount();
82 IMAPconfig imap( account, this, 0, true ); 83 IMAPconfig imap( account, this, 0, true );
83 if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) 84 if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) )
84 { 85 {
85 settings->addAccount( account ); 86 settings->addAccount( account );
86 account->save(); 87 account->save();
87 slotFillLists(); 88 slotFillLists();
88 } 89 }
89 else 90 else
90 { 91 {
91 account->remove(); 92 account->remove();
92 } 93 }
93 } 94 }
94 else if ( type.compare( "POP3" ) == 0 ) 95 else if ( type.compare( "POP3" ) == 0 )
95 { 96 {
96 qDebug( "-> config POP3" ); 97 qDebug( "-> config POP3" );
97 POP3account *account = new POP3account(); 98 POP3account *account = new POP3account();
98 POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); 99 POP3config pop3( account, this, 0, true, WStyle_ContextHelp );
99 if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) 100 if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) )
100 { 101 {
101 settings->addAccount( account ); 102 settings->addAccount( account );
102 account->save(); 103 account->save();
103 slotFillLists(); 104 slotFillLists();
104 } 105 }
105 else 106 else
106 { 107 {
107 account->remove(); 108 account->remove();
108 } 109 }
109 } 110 }
110 else if ( type.compare( "SMTP" ) == 0 ) 111 else if ( type.compare( "SMTP" ) == 0 )
111 { 112 {
112 qDebug( "-> config SMTP" ); 113 qDebug( "-> config SMTP" );
113 SMTPaccount *account = new SMTPaccount(); 114 SMTPaccount *account = new SMTPaccount();
114 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); 115 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp );
115 if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) 116 if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) )
116 { 117 {
117 settings->addAccount( account ); 118 settings->addAccount( account );
118 account->save(); 119 account->save();
119 slotFillLists(); 120 slotFillLists();
120 121
121 } 122 }
122 else 123 else
123 { 124 {
124 account->remove(); 125 account->remove();
125 } 126 }
126 } 127 }
127 else if ( type.compare( "NNTP" ) == 0 ) 128 else if ( type.compare( "NNTP" ) == 0 )
128 { 129 {
129 qDebug( "-> config NNTP" ); 130 qDebug( "-> config NNTP" );
130 NNTPaccount *account = new NNTPaccount(); 131 NNTPaccount *account = new NNTPaccount();
131 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); 132 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp );
132 if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) 133 if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) )
133 { 134 {
134 settings->addAccount( account ); 135 settings->addAccount( account );
135 account->save(); 136 account->save();
136 slotFillLists(); 137 slotFillLists();
137 } 138 }
138 else 139 else
139 { 140 {
140 account->remove(); 141 account->remove();
141 } 142 }
142 } 143 }
143} 144}
144 145
145void EditAccounts::slotEditAccount( Account *account ) 146void EditAccounts::slotEditAccount( Account *account )
146{ 147{
147 if ( account->getType().compare( "IMAP" ) == 0 ) 148 if ( account->getType().compare( "IMAP" ) == 0 )
148 { 149 {
149 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); 150 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account);
150 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); 151 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp );
151 if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) ) 152 if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) )
152 { 153 {
153 slotFillLists(); 154 slotFillLists();
154 } 155 }
155 } 156 }
156 else if ( account->getType().compare( "POP3" ) == 0 ) 157 else if ( account->getType().compare( "POP3" ) == 0 )
157 { 158 {
158 POP3account *pop3Acc = static_cast<POP3account *>(account); 159 POP3account *pop3Acc = static_cast<POP3account *>(account);
159 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); 160 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp );
160 if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) ) 161 if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) )
161 { 162 {
162 slotFillLists(); 163 slotFillLists();
163 } 164 }
164 } 165 }
165 else if ( account->getType().compare( "SMTP" ) == 0 ) 166 else if ( account->getType().compare( "SMTP" ) == 0 )
166 { 167 {
167 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); 168 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account);
168 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); 169 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp );
169 if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) ) 170 if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) )
170 { 171 {
171 slotFillLists(); 172 slotFillLists();
172 } 173 }
173 } 174 }
174 else if ( account->getType().compare( "NNTP" ) == 0 ) 175 else if ( account->getType().compare( "NNTP" ) == 0 )
175 { 176 {
176 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); 177 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account);
177 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); 178 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp );
178 if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) ) 179 if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) )
179 { 180 {
180 slotFillLists(); 181 slotFillLists();
181 } 182 }
182 } 183 }
183} 184}
184 185
185void EditAccounts::slotDeleteAccount( Account *account ) 186void EditAccounts::slotDeleteAccount( Account *account )
186{ 187{
187 if ( QMessageBox::information( this, tr( "Question" ), 188 if ( QMessageBox::information( this, tr( "Question" ),
188 tr( "<p>Do you really want to delete the selected Account?</p>" ), 189 tr( "<p>Do you really want to delete the selected Account?</p>" ),
189 tr( "Yes" ), tr( "No" ) ) == 0 ) 190 tr( "Yes" ), tr( "No" ) ) == 0 )
190 { 191 {
191 settings->delAccount( account ); 192 settings->delAccount( account );
192 slotFillLists(); 193 slotFillLists();
193 } 194 }
194} 195}
195 196
196void EditAccounts::slotEditMail() 197void EditAccounts::slotEditMail()
197{ 198{
198 qDebug( "Edit Mail Account" ); 199 qDebug( "Edit Mail Account" );
199 if ( !mailList->currentItem() ) 200 if ( !mailList->currentItem() )
200 { 201 {
201 QMessageBox::information( this, tr( "Error" ), 202 QMessageBox::information( this, tr( "Error" ),
202 tr( "<p>Please select an account.</p>" ), 203 tr( "<p>Please select an account.</p>" ),
203 tr( "Ok" ) ); 204 tr( "Ok" ) );
204 return; 205 return;
205 } 206 }
206 207
207 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 208 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
208 slotEditAccount( a ); 209 slotEditAccount( a );
209} 210}
210 211
211void EditAccounts::slotDeleteMail() 212void EditAccounts::slotDeleteMail()
212{ 213{
213 if ( !mailList->currentItem() ) 214 if ( !mailList->currentItem() )
214 { 215 {
215 QMessageBox::information( this, tr( "Error" ), 216 QMessageBox::information( this, tr( "Error" ),
216 tr( "<p>Please select an account.</p>" ), 217 tr( "<p>Please select an account.</p>" ),
217 tr( "Ok" ) ); 218 tr( "Ok" ) );
218 return; 219 return;
219 } 220 }
220 221
221 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 222 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
222 slotDeleteAccount( a ); 223 slotDeleteAccount( a );
223} 224}
224 225
225void EditAccounts::slotNewNews() 226void EditAccounts::slotNewNews()
226{ 227{
227 qDebug( "New News Account" ); 228 qDebug( "New News Account" );
228 slotNewAccount( "NNTP" ); 229 slotNewAccount( "NNTP" );
229} 230}
230 231
231void EditAccounts::slotEditNews() 232void EditAccounts::slotEditNews()
232{ 233{
233 qDebug( "Edit News Account" ); 234 qDebug( "Edit News Account" );
234 if ( !newsList->currentItem() ) 235 if ( !newsList->currentItem() )
235 { 236 {
236 QMessageBox::information( this, tr( "Error" ), 237 QMessageBox::information( this, tr( "Error" ),
237 tr( "<p>Please select an account.</p>" ), 238 tr( "<p>Please select an account.</p>" ),
238 tr( "Ok" ) ); 239 tr( "Ok" ) );
239 return; 240 return;
240 } 241 }
241 242
242 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 243 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
243 slotEditAccount( a ); 244 slotEditAccount( a );
244} 245}
245 246
246void EditAccounts::slotDeleteNews() 247void EditAccounts::slotDeleteNews()
247{ 248{
248 qDebug( "Delete News Account" ); 249 qDebug( "Delete News Account" );
249 if ( !newsList->currentItem() ) 250 if ( !newsList->currentItem() )
250 { 251 {
251 QMessageBox::information( this, tr( "Error" ), 252 QMessageBox::information( this, tr( "Error" ),
252 tr( "<p>Please select an account.</p>" ), 253 tr( "<p>Please select an account.</p>" ),
253 tr( "Ok" ) ); 254 tr( "Ok" ) );
254 return; 255 return;
255 } 256 }
256 257
257 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 258 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
258 slotDeleteAccount( a ); 259 slotDeleteAccount( a );
259} 260}
260 261
261void EditAccounts::slotAdjustColumns() 262void EditAccounts::slotAdjustColumns()
262{ 263{
263 int currPage = configTab->currentPageIndex(); 264 int currPage = configTab->currentPageIndex();
264 265
265 configTab->showPage( mailTab ); 266 configTab->showPage( mailTab );
266 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); 267 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 );
267 mailList->setColumnWidth( 1, 50 ); 268 mailList->setColumnWidth( 1, 50 );
268 269
269 configTab->showPage( newsTab ); 270 configTab->showPage( newsTab );
270 newsList->setColumnWidth( 0, newsList->visibleWidth() ); 271 newsList->setColumnWidth( 0, newsList->visibleWidth() );
271 272
272 configTab->setCurrentPage( currPage ); 273 configTab->setCurrentPage( currPage );
273} 274}
274 275
275void EditAccounts::accept() 276void EditAccounts::accept()
276{ 277{
277 settings->saveAccounts(); 278 settings->saveAccounts();
278 279
279 QDialog::accept(); 280 QDialog::accept();
280} 281}
281 282
282/** 283/**
283 * SelectMailType 284 * SelectMailType
284 */ 285 */
285 286
286SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) 287SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags )
287 : SelectMailTypeUI( parent, name, modal, flags ) 288 : SelectMailTypeUI( parent, name, modal, flags )
288{ 289{
289 selected = selection; 290 selected = selection;
290 selected->replace( 0, selected->length(), typeBox->currentText() ); 291 selected->replace( 0, selected->length(), typeBox->currentText() );
291 connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) ); 292 connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) );
292} 293}
293 294
294void SelectMailType::slotSelection( const QString &sel ) 295void SelectMailType::slotSelection( const QString &sel )
295{ 296{
296 selected->replace( 0, selected->length(), sel ); 297 selected->replace( 0, selected->length(), sel );
297} 298}
298 299
299/** 300/**
300 * IMAPconfig 301 * IMAPconfig
301 */ 302 */
302 303
303IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 304IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
304 : IMAPconfigUI( parent, name, modal, flags ) 305 : IMAPconfigUI( parent, name, modal, flags )
305{ 306{
306 data = account; 307 data = account;
307 308
308 fillValues(); 309 fillValues();
309 310
310 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 311 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
311 ComboBox1->insertItem( "Only if available", 0 ); 312 ComboBox1->insertItem( "Only if available", 0 );
312 ComboBox1->insertItem( "Always, Negotiated", 1 ); 313 ComboBox1->insertItem( "Always, Negotiated", 1 );
313 ComboBox1->insertItem( "Connect on secure port", 2 ); 314 ComboBox1->insertItem( "Connect on secure port", 2 );
314 ComboBox1->insertItem( "Run command instead", 3 ); 315 ComboBox1->insertItem( "Run command instead", 3 );
315 CommandEdit->hide(); 316 CommandEdit->hide();
316 ComboBox1->setCurrentItem( data->ConnectionType() ); 317 ComboBox1->setCurrentItem( data->ConnectionType() );
317} 318}
318 319
319void IMAPconfig::slotConnectionToggle( int index ) 320void IMAPconfig::slotConnectionToggle( int index )
320{ 321{
321 if ( index == 2 ) 322 if ( index == 2 )
322 { 323 {
323 portLine->setText( IMAP_SSL_PORT ); 324 portLine->setText( IMAP_SSL_PORT );
324 } 325 }
325 else if ( index == 3 ) 326 else if ( index == 3 )
326 { 327 {
327 portLine->setText( IMAP_PORT ); 328 portLine->setText( IMAP_PORT );
328 CommandEdit->show(); 329 CommandEdit->show();
329 } 330 }
330 else 331 else
331 { 332 {
332 portLine->setText( IMAP_PORT ); 333 portLine->setText( IMAP_PORT );
333 } 334 }
334} 335}
335 336
336void IMAPconfig::fillValues() 337void IMAPconfig::fillValues()
337{ 338{
338 accountLine->setText( data->getAccountName() ); 339 accountLine->setText( data->getAccountName() );
339 serverLine->setText( data->getServer() ); 340 serverLine->setText( data->getServer() );
340 portLine->setText( data->getPort() ); 341 portLine->setText( data->getPort() );
341 ComboBox1->setCurrentItem( data->ConnectionType() ); 342 ComboBox1->setCurrentItem( data->ConnectionType() );
342 userLine->setText( data->getUser() ); 343 userLine->setText( data->getUser() );
343 passLine->setText( data->getPassword() ); 344 passLine->setText( data->getPassword() );
344 prefixLine->setText(data->getPrefix()); 345 prefixLine->setText(data->getPrefix());
345} 346}
346 347
347void IMAPconfig::accept() 348void IMAPconfig::accept()
348{ 349{
349 data->setAccountName( accountLine->text() ); 350 data->setAccountName( accountLine->text() );
350 data->setServer( serverLine->text() ); 351 data->setServer( serverLine->text() );
351 data->setPort( portLine->text() ); 352 data->setPort( portLine->text() );
352 data->setConnectionType( ComboBox1->currentItem() ); 353 data->setConnectionType( ComboBox1->currentItem() );
353 data->setUser( userLine->text() ); 354 data->setUser( userLine->text() );
354 data->setPassword( passLine->text() ); 355 data->setPassword( passLine->text() );
355 data->setPrefix(prefixLine->text()); 356 data->setPrefix(prefixLine->text());
356 357
357 QDialog::accept(); 358 QDialog::accept();
358} 359}
359 360
360/** 361/**
361 * POP3config 362 * POP3config
362 */ 363 */
363 364
364POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 365POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags )
365 : POP3configUI( parent, name, modal, flags ) 366 : POP3configUI( parent, name, modal, flags )
366{ 367{
367 data = account; 368 data = account;
368 fillValues(); 369 fillValues();
369 370
370 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 371 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
371 ComboBox1->insertItem( "Only if available", 0 ); 372 ComboBox1->insertItem( "Only if available", 0 );
372 ComboBox1->insertItem( "Always, Negotiated", 1 ); 373 ComboBox1->insertItem( "Always, Negotiated", 1 );
373 ComboBox1->insertItem( "Connect on secure port", 2 ); 374 ComboBox1->insertItem( "Connect on secure port", 2 );
374 ComboBox1->insertItem( "Run command instead", 3 ); 375 ComboBox1->insertItem( "Run command instead", 3 );
375 CommandEdit->hide(); 376 CommandEdit->hide();
376 ComboBox1->setCurrentItem( data->ConnectionType() ); 377 ComboBox1->setCurrentItem( data->ConnectionType() );
377} 378}
378 379
379void POP3config::slotConnectionToggle( int index ) 380void POP3config::slotConnectionToggle( int index )
380{ 381{
381 // 2 is ssl connection 382 // 2 is ssl connection
382 if ( index == 2 ) 383 if ( index == 2 )
383 { 384 {
384 portLine->setText( POP3_SSL_PORT ); 385 portLine->setText( POP3_SSL_PORT );
385 } 386 }
386 else if ( index == 3 ) 387 else if ( index == 3 )
387 { 388 {
388 portLine->setText( POP3_PORT ); 389 portLine->setText( POP3_PORT );
389 CommandEdit->show(); 390 CommandEdit->show();
390 } 391 }
391 else 392 else
392 { 393 {
393 portLine->setText( POP3_PORT ); 394 portLine->setText( POP3_PORT );
394 } 395 }
395} 396}
396 397
397void POP3config::fillValues() 398void POP3config::fillValues()
398{ 399{
399 accountLine->setText( data->getAccountName() ); 400 accountLine->setText( data->getAccountName() );
400 serverLine->setText( data->getServer() ); 401 serverLine->setText( data->getServer() );
401 portLine->setText( data->getPort() ); 402 portLine->setText( data->getPort() );
402 ComboBox1->setCurrentItem( data->ConnectionType() ); 403 ComboBox1->setCurrentItem( data->ConnectionType() );
403 userLine->setText( data->getUser() ); 404 userLine->setText( data->getUser() );
404 passLine->setText( data->getPassword() ); 405 passLine->setText( data->getPassword() );
405} 406}
406 407
407void POP3config::accept() 408void POP3config::accept()
408{ 409{
409 data->setAccountName( accountLine->text() ); 410 data->setAccountName( accountLine->text() );
410 data->setServer( serverLine->text() ); 411 data->setServer( serverLine->text() );
411 data->setPort( portLine->text() ); 412 data->setPort( portLine->text() );
412 data->setConnectionType( ComboBox1->currentItem() ); 413 data->setConnectionType( ComboBox1->currentItem() );
413 data->setUser( userLine->text() ); 414 data->setUser( userLine->text() );
414 data->setPassword( passLine->text() ); 415 data->setPassword( passLine->text() );
415 416
416 QDialog::accept(); 417 QDialog::accept();
417} 418}
418 419
419/** 420/**
420 * SMTPconfig 421 * SMTPconfig
421 */ 422 */
422 423
423SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 424SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
424 : SMTPconfigUI( parent, name, modal, flags ) 425 : SMTPconfigUI( parent, name, modal, flags )
425{ 426{
426 data = account; 427 data = account;
427 428
428 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 429 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
429 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 430 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
430 431
431 fillValues(); 432 fillValues();
432 433
433 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 434 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
434 ComboBox1->insertItem( "Only if available", 0 ); 435 ComboBox1->insertItem( "Only if available", 0 );
435 ComboBox1->insertItem( "Always, Negotiated", 1 ); 436 ComboBox1->insertItem( "Always, Negotiated", 1 );
436 ComboBox1->insertItem( "Connect on secure port", 2 ); 437 ComboBox1->insertItem( "Connect on secure port", 2 );
437 ComboBox1->insertItem( "Run command instead", 3 ); 438 ComboBox1->insertItem( "Run command instead", 3 );
438 CommandEdit->hide(); 439 CommandEdit->hide();
439 ComboBox1->setCurrentItem( data->ConnectionType() ); 440 ComboBox1->setCurrentItem( data->ConnectionType() );
440} 441}
441 442
442void SMTPconfig::slotConnectionToggle( int index ) 443void SMTPconfig::slotConnectionToggle( int index )
443{ 444{
444 // 2 is ssl connection 445 // 2 is ssl connection
445 if ( index == 2 ) 446 if ( index == 2 )
446 { 447 {
447 portLine->setText( SMTP_SSL_PORT ); 448 portLine->setText( SMTP_SSL_PORT );
448 } 449 }
449 else if ( index == 3 ) 450 else if ( index == 3 )
450 { 451 {
451 portLine->setText( SMTP_PORT ); 452 portLine->setText( SMTP_PORT );
452 CommandEdit->show(); 453 CommandEdit->show();
453 } 454 }
454 else 455 else
455 { 456 {
456 portLine->setText( SMTP_PORT ); 457 portLine->setText( SMTP_PORT );
457 } 458 }
458} 459}
459 460
460void SMTPconfig::fillValues() 461void SMTPconfig::fillValues()
461{ 462{
462 accountLine->setText( data->getAccountName() ); 463 accountLine->setText( data->getAccountName() );
463 serverLine->setText( data->getServer() ); 464 serverLine->setText( data->getServer() );
464 portLine->setText( data->getPort() ); 465 portLine->setText( data->getPort() );
465 ComboBox1->setCurrentItem( data->ConnectionType() ); 466 ComboBox1->setCurrentItem( data->ConnectionType() );
466 loginBox->setChecked( data->getLogin() ); 467 loginBox->setChecked( data->getLogin() );
467 userLine->setText( data->getUser() ); 468 userLine->setText( data->getUser() );
468 passLine->setText( data->getPassword() ); 469 passLine->setText( data->getPassword() );
469} 470}
470 471
471void SMTPconfig::accept() 472void SMTPconfig::accept()
472{ 473{
473 data->setAccountName( accountLine->text() ); 474 data->setAccountName( accountLine->text() );
474 data->setServer( serverLine->text() ); 475 data->setServer( serverLine->text() );
475 data->setPort( portLine->text() ); 476 data->setPort( portLine->text() );
476 data->setConnectionType( ComboBox1->currentItem() ); 477 data->setConnectionType( ComboBox1->currentItem() );
477 data->setLogin( loginBox->isChecked() ); 478 data->setLogin( loginBox->isChecked() );
478 data->setUser( userLine->text() ); 479 data->setUser( userLine->text() );
479 data->setPassword( passLine->text() ); 480 data->setPassword( passLine->text() );
480 481
481 QDialog::accept(); 482 QDialog::accept();
482} 483}
483 484
484/** 485/**
485 * NNTPconfig 486 * NNTPconfig
486 */ 487 */
487 488
488NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 489NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
489 : NNTPconfigUI( parent, name, modal, flags ) 490 : NNTPconfigUI( parent, name, modal, flags )
490{ 491{
491 data = account; 492 data = account;
492 493
493 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 494 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
494 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 495 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
495 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); 496 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) );
496 fillValues(); 497 fillValues();
497 498
498 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); 499 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) );
499} 500}
500 501
501void NNTPconfig::slotGetNG() { 502void NNTPconfig::slotGetNG() {
502 save(); 503 save();
503 data->save(); 504 data->save();
504 NNTPwrapper* tmp = new NNTPwrapper( data ); 505 NNTPwrapper* tmp = new NNTPwrapper( data );
505 clist* list = tmp->listAllNewsgroups(); 506 clist* list = tmp->listAllNewsgroups();
506 507
507 clistcell *current; 508 clistcell *current;
508 newsnntp_group_description *group; 509 newsnntp_group_description *group;
509 510
510 // FIXME - test if not empty 511 // FIXME - test if not empty
511 current = list->first; 512 current = list->first;
512 for ( current=clist_begin(list);current!=NULL;current=clist_next(current) ) { 513 for ( current=clist_begin(list);current!=NULL;current=clist_next(current) ) {
513 group = ( newsnntp_group_description* ) current->data; 514 group = ( newsnntp_group_description* ) current->data;
514 qDebug( group->grp_name ); 515 // qDebug( group->grp_name );
515 516
516 QCheckListItem *item; 517 QCheckListItem *item;
517 item = new QCheckListItem( ListViewGroups, ( QString )group->grp_name, QCheckListItem::CheckBox ); 518 item = new QCheckListItem( ListViewGroups, ( QString )group->grp_name, QCheckListItem::CheckBox );
519 if ( subscribedGroups.contains( ( QString )group->grp_name ) >= 1 ) {
520 item->setSelected( true );
521 }
518 } 522 }
519} 523}
520 524
521void NNTPconfig::slotSSL( bool enabled ) 525void NNTPconfig::slotSSL( bool enabled )
522{ 526{
523 if ( enabled ) 527 if ( enabled )
524 { 528 {
525 portLine->setText( NNTP_SSL_PORT ); 529 portLine->setText( NNTP_SSL_PORT );
526 } 530 }
527 else 531 else
528 { 532 {
529 portLine->setText( NNTP_PORT ); 533 portLine->setText( NNTP_PORT );
530 } 534 }
531} 535}
532 536
533void NNTPconfig::fillValues() 537void NNTPconfig::fillValues()
534{ 538{
535 accountLine->setText( data->getAccountName() ); 539 accountLine->setText( data->getAccountName() );
536 serverLine->setText( data->getServer() ); 540 serverLine->setText( data->getServer() );
537 portLine->setText( data->getPort() ); 541 portLine->setText( data->getPort() );
538 sslBox->setChecked( data->getSSL() ); 542 sslBox->setChecked( data->getSSL() );
539 loginBox->setChecked( data->getLogin() ); 543 loginBox->setChecked( data->getLogin() );
540 userLine->setText( data->getUser() ); 544 userLine->setText( data->getUser() );
541 passLine->setText( data->getPassword() ); 545 passLine->setText( data->getPassword() );
546 subscribedGroups = data->getGroups();
542} 547}
543 548
544void NNTPconfig::save() 549void NNTPconfig::save()
545{ 550{
546 data->setAccountName( accountLine->text() ); 551 data->setAccountName( accountLine->text() );
547 data->setServer( serverLine->text() ); 552 data->setServer( serverLine->text() );
548 data->setPort( portLine->text() ); 553 data->setPort( portLine->text() );
549 data->setSSL( sslBox->isChecked() ); 554 data->setSSL( sslBox->isChecked() );
550 data->setLogin( loginBox->isChecked() ); 555 data->setLogin( loginBox->isChecked() );
551 data->setUser( userLine->text() ); 556 data->setUser( userLine->text() );
552 data->setPassword( passLine->text() ); 557 data->setPassword( passLine->text() );
553 558
554 QListViewItemIterator list_it( ListViewGroups ); 559 QListViewItemIterator list_it( ListViewGroups );
555 for ( ; list_it.current(); ++list_it ) { 560 for ( ; list_it.current(); ++list_it ) {
561 QStringList groupList;
556 if ( list_it.current()->isSelected() ) { 562 if ( list_it.current()->isSelected() ) {
557 qDebug( list_it.current()->text(0) ); 563 qDebug(list_it.current()->text(0) );
564 groupList.append( list_it.current()->text(0) );
558 } 565 }
566 data->setGroups( groupList );
559 } 567 }
560} 568}
561 569
562void NNTPconfig::accept() 570void NNTPconfig::accept()
563{ 571{
564 save(); 572 save();
565 QDialog::accept(); 573 QDialog::accept();
566} 574}
567 575
diff --git a/noncore/net/mail/editaccounts.h b/noncore/net/mail/editaccounts.h
index 438a984..a9eb19f 100644
--- a/noncore/net/mail/editaccounts.h
+++ b/noncore/net/mail/editaccounts.h
@@ -1,152 +1,153 @@
1#ifndef EDITACCOUNTS_H 1#ifndef EDITACCOUNTS_H
2#define EDITACCOUNTS_H 2#define EDITACCOUNTS_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qlistview.h> 5#include <qlistview.h>
6 6
7#include "editaccountsui.h" 7#include "editaccountsui.h"
8#include "selectmailtypeui.h" 8#include "selectmailtypeui.h"
9#include "imapconfigui.h" 9#include "imapconfigui.h"
10#include "pop3configui.h" 10#include "pop3configui.h"
11#include "smtpconfigui.h" 11#include "smtpconfigui.h"
12#include "nntpconfigui.h" 12#include "nntpconfigui.h"
13 13
14#include <libetpan/clist.h> 14#include <libetpan/clist.h>
15#include <libmailwrapper/settings.h> 15#include <libmailwrapper/settings.h>
16 16
17 17
18class AccountListItem : public QListViewItem 18class AccountListItem : public QListViewItem
19{ 19{
20 20
21public: 21public:
22 AccountListItem( QListView *parent, Account *a); 22 AccountListItem( QListView *parent, Account *a);
23 Account *getAccount() { return account; } 23 Account *getAccount() { return account; }
24 24
25private: 25private:
26 Account *account; 26 Account *account;
27 27
28}; 28};
29 29
30class EditAccounts : public EditAccountsUI 30class EditAccounts : public EditAccountsUI
31{ 31{
32 Q_OBJECT 32 Q_OBJECT
33 33
34public: 34public:
35 EditAccounts( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); 35 EditAccounts( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
36 36
37public slots: 37public slots:
38 void slotNewAccount( const QString &type ); 38 void slotNewAccount( const QString &type );
39 void slotEditAccount( Account *account ); 39 void slotEditAccount( Account *account );
40 void slotDeleteAccount( Account * account ); 40 void slotDeleteAccount( Account * account );
41 void slotAdjustColumns(); 41 void slotAdjustColumns();
42 42
43protected slots: 43protected slots:
44 void slotFillLists(); 44 void slotFillLists();
45 void slotNewMail(); 45 void slotNewMail();
46 void slotEditMail(); 46 void slotEditMail();
47 void slotDeleteMail(); 47 void slotDeleteMail();
48 void slotNewNews(); 48 void slotNewNews();
49 void slotEditNews(); 49 void slotEditNews();
50 void slotDeleteNews(); 50 void slotDeleteNews();
51 void accept(); 51 void accept();
52 52
53private: 53private:
54 Settings *settings; 54 Settings *settings;
55 55
56}; 56};
57 57
58class SelectMailType : public SelectMailTypeUI 58class SelectMailType : public SelectMailTypeUI
59{ 59{
60 Q_OBJECT 60 Q_OBJECT
61 61
62public: 62public:
63 SelectMailType( QString *selection = 0, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); 63 SelectMailType( QString *selection = 0, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
64 64
65private slots: 65private slots:
66 void slotSelection( const QString &sel ); 66 void slotSelection( const QString &sel );
67 67
68private: 68private:
69 QString *selected; 69 QString *selected;
70 70
71}; 71};
72 72
73class IMAPconfig : public IMAPconfigUI 73class IMAPconfig : public IMAPconfigUI
74{ 74{
75 Q_OBJECT 75 Q_OBJECT
76 76
77public: 77public:
78 IMAPconfig( IMAPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); 78 IMAPconfig( IMAPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
79 79
80public slots: 80public slots:
81 void fillValues(); 81 void fillValues();
82 82
83protected slots: 83protected slots:
84 void slotConnectionToggle( int index ); 84 void slotConnectionToggle( int index );
85 void accept(); 85 void accept();
86 86
87private: 87private:
88 IMAPaccount *data; 88 IMAPaccount *data;
89 89
90}; 90};
91 91
92class POP3config : public POP3configUI 92class POP3config : public POP3configUI
93{ 93{
94 Q_OBJECT 94 Q_OBJECT
95 95
96public: 96public:
97 POP3config( POP3account *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); 97 POP3config( POP3account *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
98 98
99public slots: 99public slots:
100 void fillValues(); 100 void fillValues();
101 101
102protected slots: 102protected slots:
103 void slotConnectionToggle( int index ); 103 void slotConnectionToggle( int index );
104 void accept(); 104 void accept();
105 105
106private: 106private:
107 POP3account *data; 107 POP3account *data;
108 108
109}; 109};
110 110
111class SMTPconfig : public SMTPconfigUI 111class SMTPconfig : public SMTPconfigUI
112{ 112{
113 Q_OBJECT 113 Q_OBJECT
114 114
115public: 115public:
116 SMTPconfig( SMTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); 116 SMTPconfig( SMTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
117 117
118public slots: 118public slots:
119 void fillValues(); 119 void fillValues();
120 120
121protected slots: 121protected slots:
122 void slotConnectionToggle( int index ); 122 void slotConnectionToggle( int index );
123 void accept(); 123 void accept();
124 124
125private: 125private:
126 SMTPaccount *data; 126 SMTPaccount *data;
127 127
128}; 128};
129 129
130class NNTPconfig : public NNTPconfigUI 130class NNTPconfig : public NNTPconfigUI
131{ 131{
132 Q_OBJECT 132 Q_OBJECT
133 133
134public: 134public:
135 NNTPconfig( NNTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 ); 135 NNTPconfig( NNTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
136 136
137public slots: 137public slots:
138 void fillValues(); 138 void fillValues();
139 139
140protected slots: 140protected slots:
141 void slotSSL( bool enabled ); 141 void slotSSL( bool enabled );
142 void accept(); 142 void accept();
143 void slotGetNG(); 143 void slotGetNG();
144 144
145private: 145private:
146 QStringList subscribedGroups;
146 void save(); 147 void save();
147 NNTPaccount *data; 148 NNTPaccount *data;
148 clist* list; 149 clist* list;
149 150
150}; 151};
151 152
152#endif 153#endif
diff --git a/noncore/net/mail/libmailwrapper/settings.cpp b/noncore/net/mail/libmailwrapper/settings.cpp
index 65ca387..f64c17d 100644
--- a/noncore/net/mail/libmailwrapper/settings.cpp
+++ b/noncore/net/mail/libmailwrapper/settings.cpp
@@ -1,439 +1,441 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <qdir.h> 2#include <qdir.h>
3 3
4#include <qpe/config.h> 4#include <qpe/config.h>
5 5
6#include "settings.h" 6#include "settings.h"
7//#include "defines.h" 7//#include "defines.h"
8 8
9#define IMAP_PORT "143" 9#define IMAP_PORT "143"
10#define IMAP_SSL_PORT "993" 10#define IMAP_SSL_PORT "993"
11#define SMTP_PORT "25" 11#define SMTP_PORT "25"
12#define SMTP_SSL_PORT "465" 12#define SMTP_SSL_PORT "465"
13#define POP3_PORT "110" 13#define POP3_PORT "110"
14#define POP3_SSL_PORT "995" 14#define POP3_SSL_PORT "995"
15#define NNTP_PORT "119" 15#define NNTP_PORT "119"
16#define NNTP_SSL_PORT "563" 16#define NNTP_SSL_PORT "563"
17 17
18 18
19Settings::Settings() 19Settings::Settings()
20 : QObject() 20 : QObject()
21{ 21{
22 updateAccounts(); 22 updateAccounts();
23} 23}
24 24
25void Settings::checkDirectory() 25void Settings::checkDirectory()
26{ 26{
27 if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { 27 if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) {
28 system( "mkdir -p $HOME/Applications/opiemail" ); 28 system( "mkdir -p $HOME/Applications/opiemail" );
29 qDebug( "$HOME/Applications/opiemail created" ); 29 qDebug( "$HOME/Applications/opiemail created" );
30 } 30 }
31} 31}
32 32
33QList<Account> Settings::getAccounts() 33QList<Account> Settings::getAccounts()
34{ 34{
35 return accounts; 35 return accounts;
36} 36}
37 37
38void Settings::addAccount( Account *account ) 38void Settings::addAccount( Account *account )
39{ 39{
40 accounts.append( account ); 40 accounts.append( account );
41} 41}
42 42
43void Settings::delAccount( Account *account ) 43void Settings::delAccount( Account *account )
44{ 44{
45 accounts.remove( account ); 45 accounts.remove( account );
46 account->remove(); 46 account->remove();
47} 47}
48 48
49void Settings::updateAccounts() 49void Settings::updateAccounts()
50{ 50{
51 accounts.clear(); 51 accounts.clear();
52 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 52 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
53 QStringList::Iterator it; 53 QStringList::Iterator it;
54 54
55 QStringList imap = dir.entryList( "imap-*" ); 55 QStringList imap = dir.entryList( "imap-*" );
56 for ( it = imap.begin(); it != imap.end(); it++ ) { 56 for ( it = imap.begin(); it != imap.end(); it++ ) {
57 qDebug( "Added IMAP account" ); 57 qDebug( "Added IMAP account" );
58 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); 58 IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") );
59 accounts.append( account ); 59 accounts.append( account );
60 } 60 }
61 61
62 QStringList pop3 = dir.entryList( "pop3-*" ); 62 QStringList pop3 = dir.entryList( "pop3-*" );
63 for ( it = pop3.begin(); it != pop3.end(); it++ ) { 63 for ( it = pop3.begin(); it != pop3.end(); it++ ) {
64 qDebug( "Added POP account" ); 64 qDebug( "Added POP account" );
65 POP3account *account = new POP3account( (*it).replace(0, 5, "") ); 65 POP3account *account = new POP3account( (*it).replace(0, 5, "") );
66 accounts.append( account ); 66 accounts.append( account );
67 } 67 }
68 68
69 QStringList smtp = dir.entryList( "smtp-*" ); 69 QStringList smtp = dir.entryList( "smtp-*" );
70 for ( it = smtp.begin(); it != smtp.end(); it++ ) { 70 for ( it = smtp.begin(); it != smtp.end(); it++ ) {
71 qDebug( "Added SMTP account" ); 71 qDebug( "Added SMTP account" );
72 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); 72 SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") );
73 accounts.append( account ); 73 accounts.append( account );
74 } 74 }
75 75
76 QStringList nntp = dir.entryList( "nntp-*" ); 76 QStringList nntp = dir.entryList( "nntp-*" );
77 for ( it = nntp.begin(); it != nntp.end(); it++ ) { 77 for ( it = nntp.begin(); it != nntp.end(); it++ ) {
78 qDebug( "Added NNTP account" ); 78 qDebug( "Added NNTP account" );
79 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); 79 NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") );
80 accounts.append( account ); 80 accounts.append( account );
81 } 81 }
82 82
83 readAccounts(); 83 readAccounts();
84} 84}
85 85
86void Settings::saveAccounts() 86void Settings::saveAccounts()
87{ 87{
88 checkDirectory(); 88 checkDirectory();
89 Account *it; 89 Account *it;
90 90
91 for ( it = accounts.first(); it; it = accounts.next() ) { 91 for ( it = accounts.first(); it; it = accounts.next() ) {
92 it->save(); 92 it->save();
93 } 93 }
94} 94}
95 95
96void Settings::readAccounts() 96void Settings::readAccounts()
97{ 97{
98 checkDirectory(); 98 checkDirectory();
99 Account *it; 99 Account *it;
100 100
101 for ( it = accounts.first(); it; it = accounts.next() ) { 101 for ( it = accounts.first(); it; it = accounts.next() ) {
102 it->read(); 102 it->read();
103 } 103 }
104} 104}
105 105
106Account::Account() 106Account::Account()
107{ 107{
108 accountName = "changeMe"; 108 accountName = "changeMe";
109 type = "changeMe"; 109 type = "changeMe";
110 ssl = false; 110 ssl = false;
111 connectionType = 1; 111 connectionType = 1;
112 offline = false; 112 offline = false;
113} 113}
114 114
115void Account::remove() 115void Account::remove()
116{ 116{
117 QFile file( getFileName() ); 117 QFile file( getFileName() );
118 file.remove(); 118 file.remove();
119} 119}
120 120
121IMAPaccount::IMAPaccount() 121IMAPaccount::IMAPaccount()
122 : Account() 122 : Account()
123{ 123{
124 file = IMAPaccount::getUniqueFileName(); 124 file = IMAPaccount::getUniqueFileName();
125 accountName = "New IMAP Account"; 125 accountName = "New IMAP Account";
126 ssl = false; 126 ssl = false;
127 connectionType = 1; 127 connectionType = 1;
128 type = "IMAP"; 128 type = "IMAP";
129 port = IMAP_PORT; 129 port = IMAP_PORT;
130} 130}
131 131
132IMAPaccount::IMAPaccount( QString filename ) 132IMAPaccount::IMAPaccount( QString filename )
133 : Account() 133 : Account()
134{ 134{
135 file = filename; 135 file = filename;
136 accountName = "New IMAP Account"; 136 accountName = "New IMAP Account";
137 ssl = false; 137 ssl = false;
138 connectionType = 1; 138 connectionType = 1;
139 type = "IMAP"; 139 type = "IMAP";
140 port = IMAP_PORT; 140 port = IMAP_PORT;
141} 141}
142 142
143QString IMAPaccount::getUniqueFileName() 143QString IMAPaccount::getUniqueFileName()
144{ 144{
145 int num = 0; 145 int num = 0;
146 QString unique; 146 QString unique;
147 147
148 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 148 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
149 149
150 QStringList imap = dir.entryList( "imap-*" ); 150 QStringList imap = dir.entryList( "imap-*" );
151 do { 151 do {
152 unique.setNum( num++ ); 152 unique.setNum( num++ );
153 } while ( imap.contains( "imap-" + unique ) > 0 ); 153 } while ( imap.contains( "imap-" + unique ) > 0 );
154 154
155 return unique; 155 return unique;
156} 156}
157 157
158void IMAPaccount::read() 158void IMAPaccount::read()
159{ 159{
160 Config *conf = new Config( getFileName(), Config::File ); 160 Config *conf = new Config( getFileName(), Config::File );
161 conf->setGroup( "IMAP Account" ); 161 conf->setGroup( "IMAP Account" );
162 accountName = conf->readEntry( "Account","" ); 162 accountName = conf->readEntry( "Account","" );
163 if (accountName.isNull()) accountName = ""; 163 if (accountName.isNull()) accountName = "";
164 server = conf->readEntry( "Server","" ); 164 server = conf->readEntry( "Server","" );
165 if (server.isNull()) server=""; 165 if (server.isNull()) server="";
166 port = conf->readEntry( "Port","" ); 166 port = conf->readEntry( "Port","" );
167 if (port.isNull()) port="143"; 167 if (port.isNull()) port="143";
168 connectionType = conf->readNumEntry( "ConnectionType" ); 168 connectionType = conf->readNumEntry( "ConnectionType" );
169 ssl = conf->readBoolEntry( "SSL",false ); 169 ssl = conf->readBoolEntry( "SSL",false );
170 user = conf->readEntry( "User","" ); 170 user = conf->readEntry( "User","" );
171 if (user.isNull()) user = ""; 171 if (user.isNull()) user = "";
172 password = conf->readEntryCrypt( "Password","" ); 172 password = conf->readEntryCrypt( "Password","" );
173 if (password.isNull()) password = ""; 173 if (password.isNull()) password = "";
174 prefix = conf->readEntry("MailPrefix",""); 174 prefix = conf->readEntry("MailPrefix","");
175 if (prefix.isNull()) prefix = ""; 175 if (prefix.isNull()) prefix = "";
176 offline = conf->readBoolEntry("Offline",false); 176 offline = conf->readBoolEntry("Offline",false);
177 delete conf; 177 delete conf;
178} 178}
179 179
180void IMAPaccount::save() 180void IMAPaccount::save()
181{ 181{
182 qDebug( "saving " + getFileName() ); 182 qDebug( "saving " + getFileName() );
183 Settings::checkDirectory(); 183 Settings::checkDirectory();
184 184
185 Config *conf = new Config( getFileName(), Config::File ); 185 Config *conf = new Config( getFileName(), Config::File );
186 conf->setGroup( "IMAP Account" ); 186 conf->setGroup( "IMAP Account" );
187 conf->writeEntry( "Account", accountName ); 187 conf->writeEntry( "Account", accountName );
188 conf->writeEntry( "Server", server ); 188 conf->writeEntry( "Server", server );
189 conf->writeEntry( "Port", port ); 189 conf->writeEntry( "Port", port );
190 conf->writeEntry( "SSL", ssl ); 190 conf->writeEntry( "SSL", ssl );
191 conf->writeEntry( "ConnectionType", connectionType ); 191 conf->writeEntry( "ConnectionType", connectionType );
192 conf->writeEntry( "User", user ); 192 conf->writeEntry( "User", user );
193 conf->writeEntryCrypt( "Password", password ); 193 conf->writeEntryCrypt( "Password", password );
194 conf->writeEntry( "MailPrefix",prefix); 194 conf->writeEntry( "MailPrefix",prefix);
195 conf->writeEntry( "Offline",offline); 195 conf->writeEntry( "Offline",offline);
196 conf->write(); 196 conf->write();
197 delete conf; 197 delete conf;
198} 198}
199 199
200 200
201QString IMAPaccount::getFileName() 201QString IMAPaccount::getFileName()
202{ 202{
203 return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file; 203 return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file;
204} 204}
205 205
206POP3account::POP3account() 206POP3account::POP3account()
207 : Account() 207 : Account()
208{ 208{
209 file = POP3account::getUniqueFileName(); 209 file = POP3account::getUniqueFileName();
210 accountName = "New POP3 Account"; 210 accountName = "New POP3 Account";
211 ssl = false; 211 ssl = false;
212 connectionType = 1; 212 connectionType = 1;
213 type = "POP3"; 213 type = "POP3";
214 port = POP3_PORT; 214 port = POP3_PORT;
215} 215}
216 216
217POP3account::POP3account( QString filename ) 217POP3account::POP3account( QString filename )
218 : Account() 218 : Account()
219{ 219{
220 file = filename; 220 file = filename;
221 accountName = "New POP3 Account"; 221 accountName = "New POP3 Account";
222 ssl = false; 222 ssl = false;
223 connectionType = 1; 223 connectionType = 1;
224 type = "POP3"; 224 type = "POP3";
225 port = POP3_PORT; 225 port = POP3_PORT;
226} 226}
227 227
228QString POP3account::getUniqueFileName() 228QString POP3account::getUniqueFileName()
229{ 229{
230 int num = 0; 230 int num = 0;
231 QString unique; 231 QString unique;
232 232
233 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 233 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
234 234
235 QStringList imap = dir.entryList( "pop3-*" ); 235 QStringList imap = dir.entryList( "pop3-*" );
236 do { 236 do {
237 unique.setNum( num++ ); 237 unique.setNum( num++ );
238 } while ( imap.contains( "pop3-" + unique ) > 0 ); 238 } while ( imap.contains( "pop3-" + unique ) > 0 );
239 239
240 return unique; 240 return unique;
241} 241}
242 242
243void POP3account::read() 243void POP3account::read()
244{ 244{
245 Config *conf = new Config( getFileName(), Config::File ); 245 Config *conf = new Config( getFileName(), Config::File );
246 conf->setGroup( "POP3 Account" ); 246 conf->setGroup( "POP3 Account" );
247 accountName = conf->readEntry( "Account" ); 247 accountName = conf->readEntry( "Account" );
248 server = conf->readEntry( "Server" ); 248 server = conf->readEntry( "Server" );
249 port = conf->readEntry( "Port" ); 249 port = conf->readEntry( "Port" );
250 ssl = conf->readBoolEntry( "SSL" ); 250 ssl = conf->readBoolEntry( "SSL" );
251 connectionType = conf->readNumEntry( "ConnectionType" ); 251 connectionType = conf->readNumEntry( "ConnectionType" );
252 user = conf->readEntry( "User" ); 252 user = conf->readEntry( "User" );
253 password = conf->readEntryCrypt( "Password" ); 253 password = conf->readEntryCrypt( "Password" );
254 offline = conf->readBoolEntry("Offline",false); 254 offline = conf->readBoolEntry("Offline",false);
255 delete conf; 255 delete conf;
256} 256}
257 257
258void POP3account::save() 258void POP3account::save()
259{ 259{
260 qDebug( "saving " + getFileName() ); 260 qDebug( "saving " + getFileName() );
261 Settings::checkDirectory(); 261 Settings::checkDirectory();
262 262
263 Config *conf = new Config( getFileName(), Config::File ); 263 Config *conf = new Config( getFileName(), Config::File );
264 conf->setGroup( "POP3 Account" ); 264 conf->setGroup( "POP3 Account" );
265 conf->writeEntry( "Account", accountName ); 265 conf->writeEntry( "Account", accountName );
266 conf->writeEntry( "Server", server ); 266 conf->writeEntry( "Server", server );
267 conf->writeEntry( "Port", port ); 267 conf->writeEntry( "Port", port );
268 conf->writeEntry( "SSL", ssl ); 268 conf->writeEntry( "SSL", ssl );
269 conf->writeEntry( "ConnectionType", connectionType ); 269 conf->writeEntry( "ConnectionType", connectionType );
270 conf->writeEntry( "User", user ); 270 conf->writeEntry( "User", user );
271 conf->writeEntryCrypt( "Password", password ); 271 conf->writeEntryCrypt( "Password", password );
272 conf->writeEntry( "Offline",offline); 272 conf->writeEntry( "Offline",offline);
273 conf->write(); 273 conf->write();
274 delete conf; 274 delete conf;
275} 275}
276 276
277 277
278QString POP3account::getFileName() 278QString POP3account::getFileName()
279{ 279{
280 return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file; 280 return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file;
281} 281}
282 282
283SMTPaccount::SMTPaccount() 283SMTPaccount::SMTPaccount()
284 : Account() 284 : Account()
285{ 285{
286 file = SMTPaccount::getUniqueFileName(); 286 file = SMTPaccount::getUniqueFileName();
287 accountName = "New SMTP Account"; 287 accountName = "New SMTP Account";
288 ssl = false; 288 ssl = false;
289 connectionType = 1; 289 connectionType = 1;
290 login = false; 290 login = false;
291 useCC = false; 291 useCC = false;
292 useBCC = false; 292 useBCC = false;
293 useReply = false; 293 useReply = false;
294 type = "SMTP"; 294 type = "SMTP";
295 port = SMTP_PORT; 295 port = SMTP_PORT;
296} 296}
297 297
298SMTPaccount::SMTPaccount( QString filename ) 298SMTPaccount::SMTPaccount( QString filename )
299 : Account() 299 : Account()
300{ 300{
301 file = filename; 301 file = filename;
302 accountName = "New SMTP Account"; 302 accountName = "New SMTP Account";
303 ssl = false; 303 ssl = false;
304 connectionType = 1; 304 connectionType = 1;
305 login = false; 305 login = false;
306 type = "SMTP"; 306 type = "SMTP";
307 port = SMTP_PORT; 307 port = SMTP_PORT;
308} 308}
309 309
310QString SMTPaccount::getUniqueFileName() 310QString SMTPaccount::getUniqueFileName()
311{ 311{
312 int num = 0; 312 int num = 0;
313 QString unique; 313 QString unique;
314 314
315 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 315 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
316 316
317 QStringList imap = dir.entryList( "smtp-*" ); 317 QStringList imap = dir.entryList( "smtp-*" );
318 do { 318 do {
319 unique.setNum( num++ ); 319 unique.setNum( num++ );
320 } while ( imap.contains( "smtp-" + unique ) > 0 ); 320 } while ( imap.contains( "smtp-" + unique ) > 0 );
321 321
322 return unique; 322 return unique;
323} 323}
324 324
325void SMTPaccount::read() 325void SMTPaccount::read()
326{ 326{
327 Config *conf = new Config( getFileName(), Config::File ); 327 Config *conf = new Config( getFileName(), Config::File );
328 conf->setGroup( "SMTP Account" ); 328 conf->setGroup( "SMTP Account" );
329 accountName = conf->readEntry( "Account" ); 329 accountName = conf->readEntry( "Account" );
330 server = conf->readEntry( "Server" ); 330 server = conf->readEntry( "Server" );
331 port = conf->readEntry( "Port" ); 331 port = conf->readEntry( "Port" );
332 ssl = conf->readBoolEntry( "SSL" ); 332 ssl = conf->readBoolEntry( "SSL" );
333 connectionType = conf->readNumEntry( "ConnectionType" ); 333 connectionType = conf->readNumEntry( "ConnectionType" );
334 login = conf->readBoolEntry( "Login" ); 334 login = conf->readBoolEntry( "Login" );
335 user = conf->readEntry( "User" ); 335 user = conf->readEntry( "User" );
336 password = conf->readEntryCrypt( "Password" ); 336 password = conf->readEntryCrypt( "Password" );
337 delete conf; 337 delete conf;
338} 338}
339 339
340void SMTPaccount::save() 340void SMTPaccount::save()
341{ 341{
342 qDebug( "saving " + getFileName() ); 342 qDebug( "saving " + getFileName() );
343 Settings::checkDirectory(); 343 Settings::checkDirectory();
344 344
345 Config *conf = new Config( getFileName(), Config::File ); 345 Config *conf = new Config( getFileName(), Config::File );
346 conf->setGroup( "SMTP Account" ); 346 conf->setGroup( "SMTP Account" );
347 conf->writeEntry( "Account", accountName ); 347 conf->writeEntry( "Account", accountName );
348 conf->writeEntry( "Server", server ); 348 conf->writeEntry( "Server", server );
349 conf->writeEntry( "Port", port ); 349 conf->writeEntry( "Port", port );
350 conf->writeEntry( "SSL", ssl ); 350 conf->writeEntry( "SSL", ssl );
351 conf->writeEntry( "ConnectionType", connectionType ); 351 conf->writeEntry( "ConnectionType", connectionType );
352 conf->writeEntry( "Login", login ); 352 conf->writeEntry( "Login", login );
353 conf->writeEntry( "User", user ); 353 conf->writeEntry( "User", user );
354 conf->writeEntryCrypt( "Password", password ); 354 conf->writeEntryCrypt( "Password", password );
355 conf->write(); 355 conf->write();
356 delete conf; 356 delete conf;
357} 357}
358 358
359 359
360QString SMTPaccount::getFileName() 360QString SMTPaccount::getFileName()
361{ 361{
362 return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file; 362 return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file;
363} 363}
364 364
365NNTPaccount::NNTPaccount() 365NNTPaccount::NNTPaccount()
366 : Account() 366 : Account()
367{ 367{
368 file = NNTPaccount::getUniqueFileName(); 368 file = NNTPaccount::getUniqueFileName();
369 accountName = "New NNTP Account"; 369 accountName = "New NNTP Account";
370 ssl = false; 370 ssl = false;
371 login = false; 371 login = false;
372 type = "NNTP"; 372 type = "NNTP";
373 port = NNTP_PORT; 373 port = NNTP_PORT;
374} 374}
375 375
376NNTPaccount::NNTPaccount( QString filename ) 376NNTPaccount::NNTPaccount( QString filename )
377 : Account() 377 : Account()
378{ 378{
379 file = filename; 379 file = filename;
380 accountName = "New NNTP Account"; 380 accountName = "New NNTP Account";
381 ssl = false; 381 ssl = false;
382 login = false; 382 login = false;
383 type = "NNTP"; 383 type = "NNTP";
384 port = NNTP_PORT; 384 port = NNTP_PORT;
385} 385}
386 386
387QString NNTPaccount::getUniqueFileName() 387QString NNTPaccount::getUniqueFileName()
388{ 388{
389 int num = 0; 389 int num = 0;
390 QString unique; 390 QString unique;
391 391
392 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" ); 392 QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
393 393
394 QStringList imap = dir.entryList( "nntp-*" ); 394 QStringList imap = dir.entryList( "nntp-*" );
395 do { 395 do {
396 unique.setNum( num++ ); 396 unique.setNum( num++ );
397 } while ( imap.contains( "nntp-" + unique ) > 0 ); 397 } while ( imap.contains( "nntp-" + unique ) > 0 );
398 398
399 return unique; 399 return unique;
400} 400}
401 401
402void NNTPaccount::read() 402void NNTPaccount::read()
403{ 403{
404 Config *conf = new Config( getFileName(), Config::File ); 404 Config *conf = new Config( getFileName(), Config::File );
405 conf->setGroup( "NNTP Account" ); 405 conf->setGroup( "NNTP Account" );
406 accountName = conf->readEntry( "Account" ); 406 accountName = conf->readEntry( "Account" );
407 server = conf->readEntry( "Server" ); 407 server = conf->readEntry( "Server" );
408 port = conf->readEntry( "Port" ); 408 port = conf->readEntry( "Port" );
409 ssl = conf->readBoolEntry( "SSL" ); 409 ssl = conf->readBoolEntry( "SSL" );
410 login = conf->readBoolEntry( "Login" ); 410 login = conf->readBoolEntry( "Login" );
411 user = conf->readEntry( "User" ); 411 user = conf->readEntry( "User" );
412 password = conf->readEntryCrypt( "Password" ); 412 password = conf->readEntryCrypt( "Password" );
413 subscribedGroups = conf->readListEntry( "Subscribed", ',' );
413 delete conf; 414 delete conf;
414} 415}
415 416
416void NNTPaccount::save() 417void NNTPaccount::save()
417{ 418{
418 qDebug( "saving " + getFileName() ); 419 qDebug( "saving " + getFileName() );
419 Settings::checkDirectory(); 420 Settings::checkDirectory();
420 421
421 Config *conf = new Config( getFileName(), Config::File ); 422 Config *conf = new Config( getFileName(), Config::File );
422 conf->setGroup( "NNTP Account" ); 423 conf->setGroup( "NNTP Account" );
423 conf->writeEntry( "Account", accountName ); 424 conf->writeEntry( "Account", accountName );
424 conf->writeEntry( "Server", server ); 425 conf->writeEntry( "Server", server );
425 conf->writeEntry( "Port", port ); 426 conf->writeEntry( "Port", port );
426 conf->writeEntry( "SSL", ssl ); 427 conf->writeEntry( "SSL", ssl );
427 conf->writeEntry( "Login", login ); 428 conf->writeEntry( "Login", login );
428 conf->writeEntry( "User", user ); 429 conf->writeEntry( "User", user );
429 conf->writeEntryCrypt( "Password", password ); 430 conf->writeEntryCrypt( "Password", password );
431 conf->writeEntry( "Subscribed" , subscribedGroups, ',' );
430 conf->write(); 432 conf->write();
431 delete conf; 433 delete conf;
432} 434}
433 435
434 436
435QString NNTPaccount::getFileName() 437QString NNTPaccount::getFileName()
436{ 438{
437 return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file; 439 return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file;
438} 440}
439 441
diff --git a/noncore/net/mail/libmailwrapper/settings.h b/noncore/net/mail/libmailwrapper/settings.h
index 8d7df92..1feedbf 100644
--- a/noncore/net/mail/libmailwrapper/settings.h
+++ b/noncore/net/mail/libmailwrapper/settings.h
@@ -1,154 +1,158 @@
1#ifndef SETTINGS_H 1#ifndef SETTINGS_H
2#define SETTINGS_H 2#define SETTINGS_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include <qlist.h> 5#include <qlist.h>
6 6
7class Account 7class Account
8{ 8{
9 9
10public: 10public:
11 Account(); 11 Account();
12 virtual ~Account() {} 12 virtual ~Account() {}
13 13
14 void remove(); 14 void remove();
15 void setAccountName( QString name ) { accountName = name; } 15 void setAccountName( QString name ) { accountName = name; }
16 const QString&getAccountName()const{ return accountName; } 16 const QString&getAccountName()const{ return accountName; }
17 const QString&getType()const{ return type; } 17 const QString&getType()const{ return type; }
18 18
19 void setServer(const QString&str){ server = str; } 19 void setServer(const QString&str){ server = str; }
20 const QString&getServer()const{ return server; } 20 const QString&getServer()const{ return server; }
21 21
22 void setPort(const QString&str) { port = str; } 22 void setPort(const QString&str) { port = str; }
23 const QString&getPort()const{ return port; } 23 const QString&getPort()const{ return port; }
24 24
25 void setUser(const QString&str){ user = str; } 25 void setUser(const QString&str){ user = str; }
26 const QString&getUser()const{ return user; } 26 const QString&getUser()const{ return user; }
27 27
28 void setPassword(const QString&str) { password = str; } 28 void setPassword(const QString&str) { password = str; }
29 const QString&getPassword()const { return password; } 29 const QString&getPassword()const { return password; }
30 30
31 void setSSL( bool b ) { ssl = b; } 31 void setSSL( bool b ) { ssl = b; }
32 bool getSSL() { return ssl; } 32 bool getSSL() { return ssl; }
33 33
34 void setConnectionType( int x ) { connectionType = x; } 34 void setConnectionType( int x ) { connectionType = x; }
35 int ConnectionType() { return connectionType; } 35 int ConnectionType() { return connectionType; }
36 36
37 37
38 void setOffline(bool b) {offline = b;} 38 void setOffline(bool b) {offline = b;}
39 bool getOffline()const{return offline;} 39 bool getOffline()const{return offline;}
40 40
41 virtual QString getFileName() { return accountName; } 41 virtual QString getFileName() { return accountName; }
42 virtual void read() { qDebug( "base reading..." ); } 42 virtual void read() { qDebug( "base reading..." ); }
43 virtual void save() { qDebug( "base saving..." ); } 43 virtual void save() { qDebug( "base saving..." ); }
44 44
45protected: 45protected:
46 QString accountName, type, server, port, user, password; 46 QString accountName, type, server, port, user, password;
47 bool ssl; 47 bool ssl;
48 int connectionType; 48 int connectionType;
49 bool offline; 49 bool offline;
50}; 50};
51 51
52class IMAPaccount : public Account 52class IMAPaccount : public Account
53{ 53{
54 54
55public: 55public:
56 IMAPaccount(); 56 IMAPaccount();
57 IMAPaccount( QString filename ); 57 IMAPaccount( QString filename );
58 58
59 static QString getUniqueFileName(); 59 static QString getUniqueFileName();
60 60
61 virtual void read(); 61 virtual void read();
62 virtual void save(); 62 virtual void save();
63 virtual QString getFileName(); 63 virtual QString getFileName();
64 64
65 void setPrefix(const QString&str) {prefix=str;} 65 void setPrefix(const QString&str) {prefix=str;}
66 const QString&getPrefix()const{return prefix;} 66 const QString&getPrefix()const{return prefix;}
67 67
68private: 68private:
69 QString file,prefix; 69 QString file,prefix;
70 70
71}; 71};
72 72
73class POP3account : public Account 73class POP3account : public Account
74{ 74{
75 75
76public: 76public:
77 POP3account(); 77 POP3account();
78 POP3account( QString filename ); 78 POP3account( QString filename );
79 79
80 static QString getUniqueFileName(); 80 static QString getUniqueFileName();
81 81
82 virtual void read(); 82 virtual void read();
83 virtual void save(); 83 virtual void save();
84 virtual QString getFileName(); 84 virtual QString getFileName();
85 85
86private: 86private:
87 QString file; 87 QString file;
88 88
89}; 89};
90 90
91class SMTPaccount : public Account 91class SMTPaccount : public Account
92{ 92{
93 93
94public: 94public:
95 SMTPaccount(); 95 SMTPaccount();
96 SMTPaccount( QString filename ); 96 SMTPaccount( QString filename );
97 97
98 static QString getUniqueFileName(); 98 static QString getUniqueFileName();
99 99
100 virtual void read(); 100 virtual void read();
101 virtual void save(); 101 virtual void save();
102 virtual QString getFileName(); 102 virtual QString getFileName();
103 103
104 void setLogin( bool b ) { login = b; } 104 void setLogin( bool b ) { login = b; }
105 bool getLogin() { return login; } 105 bool getLogin() { return login; }
106 106
107private: 107private:
108 QString file, name, mail, org, cc, bcc, reply, signature; 108 QString file, name, mail, org, cc, bcc, reply, signature;
109 bool useCC, useBCC, useReply, login; 109 bool useCC, useBCC, useReply, login;
110 110
111}; 111};
112 112
113class NNTPaccount : public Account 113class NNTPaccount : public Account
114{ 114{
115 115
116public: 116public:
117 NNTPaccount(); 117 NNTPaccount();
118 NNTPaccount( QString filename ); 118 NNTPaccount( QString filename );
119 119
120 static QString getUniqueFileName(); 120 static QString getUniqueFileName();
121 121
122 virtual void read(); 122 virtual void read();
123 virtual void save(); 123 virtual void save();
124 virtual QString getFileName(); 124 virtual QString getFileName();
125 125
126 void setLogin( bool b ) { login = b; } 126 void setLogin( bool b ) { login = b; }
127 bool getLogin() { return login; } 127 bool getLogin() { return login; }
128 128
129 void setGroups( QStringList list ) { subscribedGroups = list; }
130 QStringList getGroups() { return subscribedGroups; }
131
129private: 132private:
130 QString file; 133 QString file;
131 bool login; 134 bool login;
135 QStringList subscribedGroups;
132 136
133}; 137};
134 138
135class Settings : public QObject 139class Settings : public QObject
136{ 140{
137 Q_OBJECT 141 Q_OBJECT
138 142
139public: 143public:
140 Settings(); 144 Settings();
141 QList<Account> getAccounts(); 145 QList<Account> getAccounts();
142 void addAccount(Account *account); 146 void addAccount(Account *account);
143 void delAccount(Account *account); 147 void delAccount(Account *account);
144 void saveAccounts(); 148 void saveAccounts();
145 void readAccounts(); 149 void readAccounts();
146 static void checkDirectory(); 150 static void checkDirectory();
147 151
148private: 152private:
149 void updateAccounts(); 153 void updateAccounts();
150 QList<Account> accounts; 154 QList<Account> accounts;
151 155
152}; 156};
153 157
154#endif 158#endif