summaryrefslogtreecommitdiffabout
path: root/kmicromail
authorzautrix <zautrix>2004-09-10 22:52:50 (UTC)
committer zautrix <zautrix>2004-09-10 22:52:50 (UTC)
commit1b41a0e3bf63364940daf132446939e3570c57ad (patch) (unidiff)
tree81db8e427beadcf3bbd5356962b5d08b970a87e4 /kmicromail
parentc280882f788b31f874f928e23fc29c2aaca991eb (diff)
downloadkdepimpi-1b41a0e3bf63364940daf132446939e3570c57ad.zip
kdepimpi-1b41a0e3bf63364940daf132446939e3570c57ad.tar.gz
kdepimpi-1b41a0e3bf63364940daf132446939e3570c57ad.tar.bz2
Added pop3 settings
Diffstat (limited to 'kmicromail') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/editaccounts.cpp12
-rw-r--r--kmicromail/libmailwrapper/pop3wrapper.cpp2
-rw-r--r--kmicromail/libmailwrapper/settings.cpp10
-rw-r--r--kmicromail/libmailwrapper/settings.h9
-rw-r--r--kmicromail/pop3configui.ui94
5 files changed, 122 insertions, 5 deletions
diff --git a/kmicromail/editaccounts.cpp b/kmicromail/editaccounts.cpp
index d272c3b..e7d2750 100644
--- a/kmicromail/editaccounts.cpp
+++ b/kmicromail/editaccounts.cpp
@@ -1,66 +1,67 @@
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 20
20#include <libmailwrapper/nntpwrapper.h> 21#include <libmailwrapper/nntpwrapper.h>
21 22
22using namespace Opie::Core; 23using namespace Opie::Core;
23 24
24AccountListItem::AccountListItem( QListView *parent, Account *a) 25AccountListItem::AccountListItem( QListView *parent, Account *a)
25 : QListViewItem( parent ) 26 : QListViewItem( parent )
26{ 27{
27 account = a; 28 account = a;
28 setText( 0, account->getAccountName() ); 29 setText( 0, account->getAccountName() );
29 QString ttext = ""; 30 QString ttext = "";
30 switch (account->getType()) { 31 switch (account->getType()) {
31 case MAILLIB::A_NNTP: 32 case MAILLIB::A_NNTP:
32 ttext="NNTP"; 33 ttext="NNTP";
33 break; 34 break;
34 case MAILLIB::A_POP3: 35 case MAILLIB::A_POP3:
35 ttext = "POP3"; 36 ttext = "POP3";
36 break; 37 break;
37 case MAILLIB::A_IMAP: 38 case MAILLIB::A_IMAP:
38 ttext = "IMAP"; 39 ttext = "IMAP";
39 break; 40 break;
40 case MAILLIB::A_SMTP: 41 case MAILLIB::A_SMTP:
41 ttext = "SMTP"; 42 ttext = "SMTP";
42 break; 43 break;
43 default: 44 default:
44 ttext = "UNKNOWN"; 45 ttext = "UNKNOWN";
45 break; 46 break;
46 } 47 }
47 setText( 1, ttext); 48 setText( 1, ttext);
48} 49}
49 50
50EditAccounts::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 )
51 : EditAccountsUI( parent, name, modal, flags ) 52 : EditAccountsUI( parent, name, modal, flags )
52{ 53{
53 settings = s; 54 settings = s;
54 55
55 mailList->addColumn( tr( "Account" ) ); 56 mailList->addColumn( tr( "Account" ) );
56 mailList->addColumn( tr( "Type" ) ); 57 mailList->addColumn( tr( "Type" ) );
57 58
58 newsList->addColumn( tr( "Account" ) ); 59 newsList->addColumn( tr( "Account" ) );
59 60
60 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); 61 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) );
61 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); 62 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) );
62 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); 63 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) );
63 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); 64 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) );
64 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); 65 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) );
65 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); 66 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) );
66 67
@@ -375,106 +376,117 @@ void IMAPconfig::accept()
375 QDialog::accept(); 376 QDialog::accept();
376} 377}
377 378
378/** 379/**
379 * POP3config 380 * POP3config
380 */ 381 */
381 382
382POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 383POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags )
383 : POP3configUI( parent, name, modal, flags ) 384 : POP3configUI( parent, name, modal, flags )
384{ 385{
385 data = account; 386 data = account;
386 fillValues(); 387 fillValues();
387 388
388 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 389 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
389 ComboBox1->insertItem( "Only if available", 0 ); 390 ComboBox1->insertItem( "Only if available", 0 );
390 ComboBox1->insertItem( "Always, Negotiated", 1 ); 391 ComboBox1->insertItem( "Always, Negotiated", 1 );
391 ComboBox1->insertItem( "Connect on secure port", 2 ); 392 ComboBox1->insertItem( "Connect on secure port", 2 );
392 ComboBox1->insertItem( "Run command instead", 3 ); 393 ComboBox1->insertItem( "Run command instead", 3 );
393 CommandEdit->hide(); 394 CommandEdit->hide();
394 ComboBox1->setCurrentItem( data->ConnectionType() ); 395 ComboBox1->setCurrentItem( data->ConnectionType() );
395} 396}
396 397
397void POP3config::slotConnectionToggle( int index ) 398void POP3config::slotConnectionToggle( int index )
398{ 399{
399 // 2 is ssl connection 400 // 2 is ssl connection
400 if ( index == 2 ) 401 if ( index == 2 )
401 { 402 {
402 portLine->setText( POP3_SSL_PORT ); 403 portLine->setText( POP3_SSL_PORT );
403 } 404 }
404 else if ( index == 3 ) 405 else if ( index == 3 )
405 { 406 {
406 portLine->setText( POP3_PORT ); 407 portLine->setText( POP3_PORT );
407 CommandEdit->show(); 408 CommandEdit->show();
408 } 409 }
409 else 410 else
410 { 411 {
411 portLine->setText( POP3_PORT ); 412 portLine->setText( POP3_PORT );
412 } 413 }
413} 414}
414 415
415void POP3config::fillValues() 416void POP3config::fillValues()
416{ 417{
417 accountLine->setText( data->getAccountName() ); 418 accountLine->setText( data->getAccountName() );
418 serverLine->setText( data->getServer() ); 419 serverLine->setText( data->getServer() );
419 portLine->setText( data->getPort() ); 420 portLine->setText( data->getPort() );
420 ComboBox1->setCurrentItem( data->ConnectionType() ); 421 ComboBox1->setCurrentItem( data->ConnectionType() );
421 userLine->setText( data->getUser() ); 422 userLine->setText( data->getUser() );
422 passLine->setText( data->getPassword() ); 423 passLine->setText( data->getPassword() );
424 localFolder->setText( data->getLocalFolder() );
425 int max = data->getMaxMailSize() ;
426 if ( max ) {
427 CheckBoxDown->setChecked( true );
428 SpinBoxDown->setValue ( max );
429 } else {
430 CheckBoxDown->setChecked( false );
431 SpinBoxDown->setValue ( 5 );
432 }
423} 433}
424 434
425void POP3config::accept() 435void POP3config::accept()
426{ 436{
427 data->setAccountName( accountLine->text() ); 437 data->setAccountName( accountLine->text() );
428 data->setServer( serverLine->text() ); 438 data->setServer( serverLine->text() );
429 data->setPort( portLine->text() ); 439 data->setPort( portLine->text() );
430 data->setConnectionType( ComboBox1->currentItem() ); 440 data->setConnectionType( ComboBox1->currentItem() );
431 data->setUser( userLine->text() ); 441 data->setUser( userLine->text() );
432 data->setPassword( passLine->text() ); 442 data->setPassword( passLine->text() );
443 data->setLocalFolder( localFolder->text() );
444 data->setMaxMailSize( CheckBoxDown->isChecked()?SpinBoxDown->value():0 ) ;
433 445
434 QDialog::accept(); 446 QDialog::accept();
435} 447}
436 448
437/** 449/**
438 * SMTPconfig 450 * SMTPconfig
439 */ 451 */
440 452
441SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 453SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
442 : SMTPconfigUI( parent, name, modal, flags ) 454 : SMTPconfigUI( parent, name, modal, flags )
443{ 455{
444 data = account; 456 data = account;
445 457
446 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 458 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
447 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 459 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
448 460
449 fillValues(); 461 fillValues();
450 462
451 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) ); 463 connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
452 ComboBox1->insertItem( "Only if available", 0 ); 464 ComboBox1->insertItem( "Only if available", 0 );
453 ComboBox1->insertItem( "Always, Negotiated", 1 ); 465 ComboBox1->insertItem( "Always, Negotiated", 1 );
454 ComboBox1->insertItem( "Connect on secure port", 2 ); 466 ComboBox1->insertItem( "Connect on secure port", 2 );
455 ComboBox1->insertItem( "Run command instead", 3 ); 467 ComboBox1->insertItem( "Run command instead", 3 );
456 CommandEdit->hide(); 468 CommandEdit->hide();
457 ComboBox1->setCurrentItem( data->ConnectionType() ); 469 ComboBox1->setCurrentItem( data->ConnectionType() );
458} 470}
459 471
460void SMTPconfig::slotConnectionToggle( int index ) 472void SMTPconfig::slotConnectionToggle( int index )
461{ 473{
462 // 2 is ssl connection 474 // 2 is ssl connection
463 if ( index == 2 ) 475 if ( index == 2 )
464 { 476 {
465 portLine->setText( SMTP_SSL_PORT ); 477 portLine->setText( SMTP_SSL_PORT );
466 } 478 }
467 else if ( index == 3 ) 479 else if ( index == 3 )
468 { 480 {
469 portLine->setText( SMTP_PORT ); 481 portLine->setText( SMTP_PORT );
470 CommandEdit->show(); 482 CommandEdit->show();
471 } 483 }
472 else 484 else
473 { 485 {
474 portLine->setText( SMTP_PORT ); 486 portLine->setText( SMTP_PORT );
475 } 487 }
476} 488}
477 489
478void SMTPconfig::fillValues() 490void SMTPconfig::fillValues()
479{ 491{
480 accountLine->setText( data->getAccountName() ); 492 accountLine->setText( data->getAccountName() );
diff --git a/kmicromail/libmailwrapper/pop3wrapper.cpp b/kmicromail/libmailwrapper/pop3wrapper.cpp
index 8d2f778..1edec9e 100644
--- a/kmicromail/libmailwrapper/pop3wrapper.cpp
+++ b/kmicromail/libmailwrapper/pop3wrapper.cpp
@@ -77,97 +77,97 @@ RecBodyP POP3wrapper::fetchBody( const RecMailP &mail ) {
77 } 77 }
78 delete message; 78 delete message;
79 message = (char*)malloc(msg.length()+1*sizeof(char)); 79 message = (char*)malloc(msg.length()+1*sizeof(char));
80 memset(message,0,msg.length()+1); 80 memset(message,0,msg.length()+1);
81 memcpy(message,msg.latin1(),msg.length()); 81 memcpy(message,msg.latin1(),msg.length());
82 /* transform to libetpan stuff */ 82 /* transform to libetpan stuff */
83 mailmsg = mailmessage_new(); 83 mailmsg = mailmessage_new();
84 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); 84 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message));
85 generic_message_t * msg_data; 85 generic_message_t * msg_data;
86 msg_data = (generic_message_t *)mailmsg->msg_data; 86 msg_data = (generic_message_t *)mailmsg->msg_data;
87 msg_data->msg_fetched = 1; 87 msg_data->msg_fetched = 1;
88 msg_data->msg_message = message; 88 msg_data->msg_message = message;
89 msg_data->msg_length = strlen(message); 89 msg_data->msg_length = strlen(message);
90 } 90 }
91 body = parseMail(mailmsg); 91 body = parseMail(mailmsg);
92 92
93 /* clean up */ 93 /* clean up */
94 if (mailmsg) 94 if (mailmsg)
95 mailmessage_free(mailmsg); 95 mailmessage_free(mailmsg);
96 if (message) 96 if (message)
97 free(message); 97 free(message);
98 98
99 return body; 99 return body;
100} 100}
101 101
102void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb ) 102void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target, int maxSizeInKb )
103{ 103{
104 login(); 104 login();
105 if (!m_pop3) 105 if (!m_pop3)
106 return; 106 return;
107 uint32_t res_messages,res_recent,res_unseen; 107 uint32_t res_messages,res_recent,res_unseen;
108 mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); 108 mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen);
109 parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb); 109 parseList(target,m_pop3->sto_session,"INBOX", false, maxSizeInKb);
110 Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); 110 Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages));
111} 111}
112 112
113void POP3wrapper::login() 113void POP3wrapper::login()
114{ 114{
115 if (account->getOffline()) 115 if (account->getOffline())
116 return; 116 return;
117 /* we'll hold the line */ 117 /* we'll hold the line */
118 if ( m_pop3 != NULL ) 118 if ( m_pop3 != NULL )
119 return; 119 return;
120 120
121 QString server,user, pass; 121 QString server,user, pass;
122 uint16_t port; 122 uint16_t port;
123 int err = MAILPOP3_NO_ERROR; 123 int err = MAILPOP3_NO_ERROR;
124 124
125 server = account->getServer().latin1(); 125 server = account->getServer();
126 port = account->getPort().toUInt(); 126 port = account->getPort().toUInt();
127 127
128 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 128 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
129 qApp->processEvents(); 129 qApp->processEvents();
130 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 130 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
131 login.show(); 131 login.show();
132 if ( QDialog::Accepted == login.exec() ) { 132 if ( QDialog::Accepted == login.exec() ) {
133 // ok 133 // ok
134 user = login.getUser(); 134 user = login.getUser();
135 pass = login.getPassword(); 135 pass = login.getPassword();
136 } else { 136 } else {
137 // cancel 137 // cancel
138 ; // odebug << "POP3: Login canceled" << oendl; 138 ; // odebug << "POP3: Login canceled" << oendl;
139 return; 139 return;
140 } 140 }
141 } else { 141 } else {
142 user = account->getUser(); 142 user = account->getUser();
143 pass = account->getPassword(); 143 pass = account->getPassword();
144 } 144 }
145 // bool ssl = account->getSSL(); 145 // bool ssl = account->getSSL();
146 146
147 m_pop3=mailstorage_new(NULL); 147 m_pop3=mailstorage_new(NULL);
148 int conntypeset = account->ConnectionType(); 148 int conntypeset = account->ConnectionType();
149 int conntype = 0; 149 int conntype = 0;
150 if ( conntypeset == 3 ) { 150 if ( conntypeset == 3 ) {
151 conntype = CONNECTION_TYPE_COMMAND; 151 conntype = CONNECTION_TYPE_COMMAND;
152 } else if ( conntypeset == 2 ) { 152 } else if ( conntypeset == 2 ) {
153 conntype = CONNECTION_TYPE_TLS; 153 conntype = CONNECTION_TYPE_TLS;
154 } else if ( conntypeset == 1 ) { 154 } else if ( conntypeset == 1 ) {
155 conntype = CONNECTION_TYPE_STARTTLS; 155 conntype = CONNECTION_TYPE_STARTTLS;
156 } else if ( conntypeset == 0 ) { 156 } else if ( conntypeset == 0 ) {
157 conntype = CONNECTION_TYPE_TRY_STARTTLS; 157 conntype = CONNECTION_TYPE_TRY_STARTTLS;
158 } 158 }
159 159
160 //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); 160 //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN);
161 161
162 pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, 162 pop3_mailstorage_init(m_pop3,(char*)server.latin1(), port, NULL, conntype, POP3_AUTH_TYPE_PLAIN,
163 (char*)user.latin1(),(char*)pass.latin1(),0,0,0); 163 (char*)user.latin1(),(char*)pass.latin1(),0,0,0);
164 164
165 err = mailstorage_connect(m_pop3); 165 err = mailstorage_connect(m_pop3);
166 if (err != MAIL_NO_ERROR) { 166 if (err != MAIL_NO_ERROR) {
167 ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl; 167 ; // odebug << QString( "FEHLERNUMMER %1" ).arg( err ) << oendl;
168 Global::statusMessage(tr("Error %1 initializing folder").arg( err )); 168 Global::statusMessage(tr("Error %1 initializing folder").arg( err ));
169 mailstorage_free(m_pop3); 169 mailstorage_free(m_pop3);
170 m_pop3 = 0; 170 m_pop3 = 0;
171 } else { 171 } else {
172 mailsession * session = m_pop3->sto_session; 172 mailsession * session = m_pop3->sto_session;
173 mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session; 173 mailpop3 * mail = ( ( pop3_session_state_data * )session->sess_data )->pop3_session;
diff --git a/kmicromail/libmailwrapper/settings.cpp b/kmicromail/libmailwrapper/settings.cpp
index b0a539e..90e32fa 100644
--- a/kmicromail/libmailwrapper/settings.cpp
+++ b/kmicromail/libmailwrapper/settings.cpp
@@ -210,113 +210,123 @@ POP3account::POP3account()
210 : Account() 210 : Account()
211{ 211{
212 file = POP3account::getUniqueFileName(); 212 file = POP3account::getUniqueFileName();
213 accountName = "New POP3 Account"; 213 accountName = "New POP3 Account";
214 ssl = false; 214 ssl = false;
215 connectionType = 1; 215 connectionType = 1;
216 type = MAILLIB::A_POP3; 216 type = MAILLIB::A_POP3;
217 port = POP3_PORT; 217 port = POP3_PORT;
218} 218}
219 219
220POP3account::POP3account( QString filename ) 220POP3account::POP3account( QString filename )
221 : Account() 221 : Account()
222{ 222{
223 file = filename; 223 file = filename;
224 accountName = "New POP3 Account"; 224 accountName = "New POP3 Account";
225 ssl = false; 225 ssl = false;
226 connectionType = 1; 226 connectionType = 1;
227 type = MAILLIB::A_POP3; 227 type = MAILLIB::A_POP3;
228 port = POP3_PORT; 228 port = POP3_PORT;
229} 229}
230 230
231QString POP3account::getUniqueFileName() 231QString POP3account::getUniqueFileName()
232{ 232{
233 int num = 0; 233 int num = 0;
234 QString unique; 234 QString unique;
235 235
236 QDir dir( locateLocal("data", "kopiemail" ) ); 236 QDir dir( locateLocal("data", "kopiemail" ) );
237 237
238 QStringList imap = dir.entryList( "pop3-*" ); 238 QStringList imap = dir.entryList( "pop3-*" );
239 do { 239 do {
240 unique.setNum( num++ ); 240 unique.setNum( num++ );
241 } while ( imap.contains( "pop3-" + unique ) > 0 ); 241 } while ( imap.contains( "pop3-" + unique ) > 0 );
242 242
243 return unique; 243 return unique;
244} 244}
245 245
246void POP3account::read() 246void POP3account::read()
247{ 247{
248 Config *conf = new Config( getFileName(), Config::File ); 248 Config *conf = new Config( getFileName(), Config::File );
249 conf->setGroup( "POP3 Account" ); 249 conf->setGroup( "POP3 Account" );
250 accountName = conf->readEntry( "Account" ); 250 accountName = conf->readEntry( "Account" );
251 server = conf->readEntry( "Server" ); 251 server = conf->readEntry( "Server" );
252 port = conf->readEntry( "Port" ); 252 port = conf->readEntry( "Port" );
253 ssl = conf->readBoolEntry( "SSL" ); 253 ssl = conf->readBoolEntry( "SSL" );
254 connectionType = conf->readNumEntry( "ConnectionType" ); 254 connectionType = conf->readNumEntry( "ConnectionType" );
255 user = conf->readEntry( "User" ); 255 user = conf->readEntry( "User" );
256 password = conf->readEntryCrypt( "Password" ); 256 password = conf->readEntryCrypt( "Password" );
257 offline = conf->readBoolEntry("Offline",false); 257 offline = conf->readBoolEntry("Offline",false);
258 localFolder = conf->readEntry( "LocalFolder" );
259 maxMailSize = conf->readNumEntry( "MaxSize",0 );
260 int lf = conf->readNumEntry( "LastFetch",0 );
261 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
262 lastFetch = dt.addSecs( lf );
258 delete conf; 263 delete conf;
259} 264}
260 265
261void POP3account::save() 266void POP3account::save()
262{ 267{
263 Settings::checkDirectory(); 268 Settings::checkDirectory();
264 269
265 Config *conf = new Config( getFileName(), Config::File ); 270 Config *conf = new Config( getFileName(), Config::File );
266 conf->setGroup( "POP3 Account" ); 271 conf->setGroup( "POP3 Account" );
267 conf->writeEntry( "Account", accountName ); 272 conf->writeEntry( "Account", accountName );
268 conf->writeEntry( "Server", server ); 273 conf->writeEntry( "Server", server );
269 conf->writeEntry( "Port", port ); 274 conf->writeEntry( "Port", port );
270 conf->writeEntry( "SSL", ssl ); 275 conf->writeEntry( "SSL", ssl );
271 conf->writeEntry( "ConnectionType", connectionType ); 276 conf->writeEntry( "ConnectionType", connectionType );
272 conf->writeEntry( "User", user ); 277 conf->writeEntry( "User", user );
273 conf->writeEntryCrypt( "Password", password ); 278 conf->writeEntryCrypt( "Password", password );
274 conf->writeEntry( "Offline",offline); 279 conf->writeEntry( "Offline",offline);
280 conf->writeEntry( "LocalFolder", localFolder );
281 conf->writeEntry( "MaxSize", maxMailSize );
282 QDateTime dt ( QDate ( 2004, 1, 1 ), QTime( 0,0,0) );
283 int lf = dt.secsTo ( lastFetch );
284 conf->writeEntry( "LastFetch", lf );
275 conf->write(); 285 conf->write();
276 delete conf; 286 delete conf;
277} 287}
278 288
279 289
280QString POP3account::getFileName() 290QString POP3account::getFileName()
281{ 291{
282 return locateLocal("data", "kopiemail" ) +"/pop3-" + file; 292 return locateLocal("data", "kopiemail" ) +"/pop3-" + file;
283} 293}
284 294
285SMTPaccount::SMTPaccount() 295SMTPaccount::SMTPaccount()
286 : Account() 296 : Account()
287{ 297{
288 file = SMTPaccount::getUniqueFileName(); 298 file = SMTPaccount::getUniqueFileName();
289 accountName = "New SMTP Account"; 299 accountName = "New SMTP Account";
290 ssl = false; 300 ssl = false;
291 connectionType = 1; 301 connectionType = 1;
292 login = false; 302 login = false;
293 useCC = false; 303 useCC = false;
294 useBCC = false; 304 useBCC = false;
295 useReply = false; 305 useReply = false;
296 type = MAILLIB::A_SMTP; 306 type = MAILLIB::A_SMTP;
297 port = SMTP_PORT; 307 port = SMTP_PORT;
298} 308}
299 309
300SMTPaccount::SMTPaccount( QString filename ) 310SMTPaccount::SMTPaccount( QString filename )
301 : Account() 311 : Account()
302{ 312{
303 file = filename; 313 file = filename;
304 accountName = "New SMTP Account"; 314 accountName = "New SMTP Account";
305 ssl = false; 315 ssl = false;
306 connectionType = 1; 316 connectionType = 1;
307 login = false; 317 login = false;
308 type = MAILLIB::A_SMTP; 318 type = MAILLIB::A_SMTP;
309 port = SMTP_PORT; 319 port = SMTP_PORT;
310} 320}
311 321
312QString SMTPaccount::getUniqueFileName() 322QString SMTPaccount::getUniqueFileName()
313{ 323{
314 int num = 0; 324 int num = 0;
315 QString unique; 325 QString unique;
316 326
317 QDir dir( locateLocal("data", "kopiemail" ) ); 327 QDir dir( locateLocal("data", "kopiemail" ) );
318 328
319 QStringList imap = dir.entryList( "smtp-*" ); 329 QStringList imap = dir.entryList( "smtp-*" );
320 do { 330 do {
321 unique.setNum( num++ ); 331 unique.setNum( num++ );
322 } while ( imap.contains( "smtp-" + unique ) > 0 ); 332 } while ( imap.contains( "smtp-" + unique ) > 0 );
diff --git a/kmicromail/libmailwrapper/settings.h b/kmicromail/libmailwrapper/settings.h
index ba3ec89..c33c403 100644
--- a/kmicromail/libmailwrapper/settings.h
+++ b/kmicromail/libmailwrapper/settings.h
@@ -1,103 +1,112 @@
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 12
12class Account 13class Account
13{ 14{
14 15
15public: 16public:
16 Account(); 17 Account();
17 virtual ~Account() {} 18 virtual ~Account() {}
18 19
19 void remove(); 20 void remove();
20 void setAccountName( QString name ) { accountName = name; } 21 void setAccountName( QString name ) { accountName = name; }
21 const QString&getAccountName()const{ return accountName; } 22 const QString&getAccountName()const{ return accountName; }
22 MAILLIB::ATYPE getType()const{ return type; } 23 MAILLIB::ATYPE getType()const{ return type; }
23 24
24 void setServer(const QString&str){ server = str; } 25 void setServer(const QString&str){ server = str; }
25 const QString&getServer()const{ return server; } 26 const QString&getServer()const{ return server; }
26 27
28 void setLocalFolder( QString name ) { localFolder = name; }
29 const QString& getLocalFolder()const{ return localFolder; }
30
27 void setPort(const QString&str) { port = str; } 31 void setPort(const QString&str) { port = str; }
28 const QString&getPort()const{ return port; } 32 const QString&getPort()const{ return port; }
29 33
30 void setUser(const QString&str){ user = str; } 34 void setUser(const QString&str){ user = str; }
31 const QString&getUser()const{ return user; } 35 const QString&getUser()const{ return user; }
32 36
33 void setPassword(const QString&str) { password = str; } 37 void setPassword(const QString&str) { password = str; }
34 const QString&getPassword()const { return password; } 38 const QString&getPassword()const { return password; }
35 39
36 void setSSL( bool b ) { ssl = b; } 40 void setSSL( bool b ) { ssl = b; }
37 bool getSSL() { return ssl; } 41 bool getSSL() { return ssl; }
38 42
39 void setConnectionType( int x ) { connectionType = x; } 43 void setConnectionType( int x ) { connectionType = x; }
40 int ConnectionType() { return connectionType; } 44 int ConnectionType() { return connectionType; }
41 45
46 void setMaxMailSize( int x ) { maxMailSize = x; }
47 int getMaxMailSize() { return maxMailSize; }
42 48
43 void setOffline(bool b) {offline = b;} 49 void setOffline(bool b) {offline = b;}
44 bool getOffline()const{return offline;} 50 bool getOffline()const{return offline;}
45 51
46 virtual QString getFileName() { return accountName; } 52 virtual QString getFileName() { return accountName; }
47 virtual void read() { ; } 53 virtual void read() { ; }
48 virtual void save() { ; } 54 virtual void save() { ; }
49 55
50protected: 56protected:
51 QString accountName, server, port, user, password; 57 QString accountName, server, port, user, password;
52 bool ssl; 58 bool ssl;
53 int connectionType; 59 int connectionType;
54 bool offline; 60 bool offline;
55 MAILLIB::ATYPE type; 61 MAILLIB::ATYPE type;
62 QString localFolder;
63 int maxMailSize;
64 QDateTime lastFetch;
56}; 65};
57 66
58class IMAPaccount : public Account 67class IMAPaccount : public Account
59{ 68{
60 69
61public: 70public:
62 IMAPaccount(); 71 IMAPaccount();
63 IMAPaccount( QString filename ); 72 IMAPaccount( QString filename );
64 73
65 static QString getUniqueFileName(); 74 static QString getUniqueFileName();
66 75
67 virtual void read(); 76 virtual void read();
68 virtual void save(); 77 virtual void save();
69 virtual QString getFileName(); 78 virtual QString getFileName();
70 79
71 void setPrefix(const QString&str) {prefix=str;} 80 void setPrefix(const QString&str) {prefix=str;}
72 const QString&getPrefix()const{return prefix;} 81 const QString&getPrefix()const{return prefix;}
73 82
74private: 83private:
75 QString file,prefix; 84 QString file,prefix;
76 85
77}; 86};
78 87
79class POP3account : public Account 88class POP3account : public Account
80{ 89{
81 90
82public: 91public:
83 POP3account(); 92 POP3account();
84 POP3account( QString filename ); 93 POP3account( QString filename );
85 94
86 static QString getUniqueFileName(); 95 static QString getUniqueFileName();
87 96
88 virtual void read(); 97 virtual void read();
89 virtual void save(); 98 virtual void save();
90 virtual QString getFileName(); 99 virtual QString getFileName();
91 100
92private: 101private:
93 QString file; 102 QString file;
94 103
95}; 104};
96 105
97class SMTPaccount : public Account 106class SMTPaccount : public Account
98{ 107{
99 108
100public: 109public:
101 SMTPaccount(); 110 SMTPaccount();
102 SMTPaccount( QString filename ); 111 SMTPaccount( QString filename );
103 112
diff --git a/kmicromail/pop3configui.ui b/kmicromail/pop3configui.ui
index 1014ef4..a2d43bd 100644
--- a/kmicromail/pop3configui.ui
+++ b/kmicromail/pop3configui.ui
@@ -1,83 +1,83 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>POP3configUI</class> 2<class>POP3configUI</class>
3<widget> 3<widget>
4 <class>QDialog</class> 4 <class>QDialog</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>POP3configUI</cstring> 7 <cstring>POP3configUI</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>314</width> 14 <width>322</width>
15 <height>410</height> 15 <height>404</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Configure POP3</string> 20 <string>Configure POP3</string>
21 </property> 21 </property>
22 <property> 22 <property>
23 <name>layoutMargin</name> 23 <name>layoutMargin</name>
24 </property> 24 </property>
25 <property> 25 <property>
26 <name>layoutSpacing</name> 26 <name>layoutSpacing</name>
27 </property> 27 </property>
28 <vbox> 28 <vbox>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>3</number> 31 <number>11</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>3</number> 35 <number>6</number>
36 </property> 36 </property>
37 <widget> 37 <widget>
38 <class>QLayoutWidget</class> 38 <class>QLayoutWidget</class>
39 <property stdset="1"> 39 <property stdset="1">
40 <name>name</name> 40 <name>name</name>
41 <cstring>Layout12</cstring> 41 <cstring>Layout12</cstring>
42 </property> 42 </property>
43 <hbox> 43 <hbox>
44 <property stdset="1"> 44 <property stdset="1">
45 <name>margin</name> 45 <name>margin</name>
46 <number>0</number> 46 <number>0</number>
47 </property> 47 </property>
48 <property stdset="1"> 48 <property stdset="1">
49 <name>spacing</name> 49 <name>spacing</name>
50 <number>6</number> 50 <number>6</number>
51 </property> 51 </property>
52 <widget> 52 <widget>
53 <class>QLabel</class> 53 <class>QLabel</class>
54 <property stdset="1"> 54 <property stdset="1">
55 <name>name</name> 55 <name>name</name>
56 <cstring>accountLabel</cstring> 56 <cstring>accountLabel</cstring>
57 </property> 57 </property>
58 <property stdset="1"> 58 <property stdset="1">
59 <name>text</name> 59 <name>text</name>
60 <string>Account</string> 60 <string>Account</string>
61 </property> 61 </property>
62 </widget> 62 </widget>
63 <widget> 63 <widget>
64 <class>QLineEdit</class> 64 <class>QLineEdit</class>
65 <property stdset="1"> 65 <property stdset="1">
66 <name>name</name> 66 <name>name</name>
67 <cstring>accountLine</cstring> 67 <cstring>accountLine</cstring>
68 </property> 68 </property>
69 <property> 69 <property>
70 <name>toolTip</name> 70 <name>toolTip</name>
71 <string>Name of the Account</string> 71 <string>Name of the Account</string>
72 </property> 72 </property>
73 </widget> 73 </widget>
74 </hbox> 74 </hbox>
75 </widget> 75 </widget>
76 <widget> 76 <widget>
77 <class>Line</class> 77 <class>Line</class>
78 <property stdset="1"> 78 <property stdset="1">
79 <name>name</name> 79 <name>name</name>
80 <cstring>line1</cstring> 80 <cstring>line1</cstring>
81 </property> 81 </property>
82 <property stdset="1"> 82 <property stdset="1">
83 <name>orientation</name> 83 <name>orientation</name>
@@ -274,79 +274,165 @@
274 <property stdset="1"> 274 <property stdset="1">
275 <name>name</name> 275 <name>name</name>
276 <cstring>passLabel</cstring> 276 <cstring>passLabel</cstring>
277 </property> 277 </property>
278 <property stdset="1"> 278 <property stdset="1">
279 <name>text</name> 279 <name>text</name>
280 <string>Password</string> 280 <string>Password</string>
281 </property> 281 </property>
282 </widget> 282 </widget>
283 </vbox> 283 </vbox>
284 </widget> 284 </widget>
285 <widget> 285 <widget>
286 <class>QLayoutWidget</class> 286 <class>QLayoutWidget</class>
287 <property stdset="1"> 287 <property stdset="1">
288 <name>name</name> 288 <name>name</name>
289 <cstring>Layout5</cstring> 289 <cstring>Layout5</cstring>
290 </property> 290 </property>
291 <vbox> 291 <vbox>
292 <property stdset="1"> 292 <property stdset="1">
293 <name>margin</name> 293 <name>margin</name>
294 <number>0</number> 294 <number>0</number>
295 </property> 295 </property>
296 <property stdset="1"> 296 <property stdset="1">
297 <name>spacing</name> 297 <name>spacing</name>
298 <number>6</number> 298 <number>6</number>
299 </property> 299 </property>
300 <widget> 300 <widget>
301 <class>QLineEdit</class> 301 <class>QLineEdit</class>
302 <property stdset="1"> 302 <property stdset="1">
303 <name>name</name> 303 <name>name</name>
304 <cstring>userLine</cstring> 304 <cstring>userLine</cstring>
305 </property> 305 </property>
306 </widget> 306 </widget>
307 <widget> 307 <widget>
308 <class>QLineEdit</class> 308 <class>QLineEdit</class>
309 <property stdset="1"> 309 <property stdset="1">
310 <name>name</name> 310 <name>name</name>
311 <cstring>passLine</cstring> 311 <cstring>passLine</cstring>
312 </property> 312 </property>
313 <property stdset="1"> 313 <property stdset="1">
314 <name>echoMode</name> 314 <name>echoMode</name>
315 <enum>Password</enum> 315 <enum>Password</enum>
316 </property> 316 </property>
317 </widget> 317 </widget>
318 </vbox> 318 </vbox>
319 </widget> 319 </widget>
320 </hbox> 320 </hbox>
321 </widget> 321 </widget>
322 <widget>
323 <class>QLayoutWidget</class>
324 <property stdset="1">
325 <name>name</name>
326 <cstring>Layout9</cstring>
327 </property>
328 <hbox>
329 <property stdset="1">
330 <name>margin</name>
331 <number>0</number>
332 </property>
333 <property stdset="1">
334 <name>spacing</name>
335 <number>6</number>
336 </property>
337 <widget>
338 <class>QLabel</class>
339 <property stdset="1">
340 <name>name</name>
341 <cstring>TextLabel1_2</cstring>
342 </property>
343 <property stdset="1">
344 <name>text</name>
345 <string>Local storage folder:</string>
346 </property>
347 </widget>
348 <widget>
349 <class>QLineEdit</class>
350 <property stdset="1">
351 <name>name</name>
352 <cstring>localFolder</cstring>
353 </property>
354 <property stdset="1">
355 <name>text</name>
356 <string></string>
357 </property>
358 </widget>
359 </hbox>
360 </widget>
361 <widget>
362 <class>QLayoutWidget</class>
363 <property stdset="1">
364 <name>name</name>
365 <cstring>Layout10</cstring>
366 </property>
367 <hbox>
368 <property stdset="1">
369 <name>margin</name>
370 <number>0</number>
371 </property>
372 <property stdset="1">
373 <name>spacing</name>
374 <number>6</number>
375 </property>
376 <widget>
377 <class>QCheckBox</class>
378 <property stdset="1">
379 <name>name</name>
380 <cstring>CheckBoxDown</cstring>
381 </property>
382 <property stdset="1">
383 <name>text</name>
384 <string>Download only messages smaller</string>
385 </property>
386 </widget>
387 <widget>
388 <class>QSpinBox</class>
389 <property stdset="1">
390 <name>name</name>
391 <cstring>SpinBoxDown</cstring>
392 </property>
393 <property stdset="1">
394 <name>suffix</name>
395 <string>kB</string>
396 </property>
397 <property stdset="1">
398 <name>maxValue</name>
399 <number>99999</number>
400 </property>
401 <property stdset="1">
402 <name>minValue</name>
403 <number>1</number>
404 </property>
405 </widget>
406 </hbox>
407 </widget>
322 <spacer> 408 <spacer>
323 <property> 409 <property>
324 <name>name</name> 410 <name>name</name>
325 <cstring>spacer</cstring> 411 <cstring>spacer</cstring>
326 </property> 412 </property>
327 <property stdset="1"> 413 <property stdset="1">
328 <name>orientation</name> 414 <name>orientation</name>
329 <enum>Vertical</enum> 415 <enum>Vertical</enum>
330 </property> 416 </property>
331 <property stdset="1"> 417 <property stdset="1">
332 <name>sizeType</name> 418 <name>sizeType</name>
333 <enum>Expanding</enum> 419 <enum>Expanding</enum>
334 </property> 420 </property>
335 <property> 421 <property>
336 <name>sizeHint</name> 422 <name>sizeHint</name>
337 <size> 423 <size>
338 <width>20</width> 424 <width>20</width>
339 <height>20</height> 425 <height>20</height>
340 </size> 426 </size>
341 </property> 427 </property>
342 </spacer> 428 </spacer>
343 </vbox> 429 </vbox>
344</widget> 430</widget>
345<tabstops> 431<tabstops>
346 <tabstop>accountLine</tabstop> 432 <tabstop>accountLine</tabstop>
347 <tabstop>serverLine</tabstop> 433 <tabstop>serverLine</tabstop>
348 <tabstop>portLine</tabstop> 434 <tabstop>portLine</tabstop>
349 <tabstop>userLine</tabstop> 435 <tabstop>userLine</tabstop>
350 <tabstop>passLine</tabstop> 436 <tabstop>passLine</tabstop>
351</tabstops> 437</tabstops>
352</UI> 438</UI>