summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/editaccounts.cpp36
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.cpp35
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.h2
3 files changed, 40 insertions, 33 deletions
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp
index b8aad11..28d531b 100644
--- a/noncore/net/mail/editaccounts.cpp
+++ b/noncore/net/mail/editaccounts.cpp
@@ -1,47 +1,45 @@
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#include <qstringlist.h>
11 11
12#include <libmailwrapper/nntpwrapper.h> 12#include <libmailwrapper/nntpwrapper.h>
13 13
14#include <libetpan/nntpdriver.h>
15
16AccountListItem::AccountListItem( QListView *parent, Account *a) 14AccountListItem::AccountListItem( QListView *parent, Account *a)
17 : QListViewItem( parent ) 15 : QListViewItem( parent )
18{ 16{
19 account = a; 17 account = a;
20 setText( 0, account->getAccountName() ); 18 setText( 0, account->getAccountName() );
21 setText( 1, account->getType() ); 19 setText( 1, account->getType() );
22} 20}
23 21
24EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 22EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
25 : EditAccountsUI( parent, name, modal, flags ) 23 : EditAccountsUI( parent, name, modal, flags )
26{ 24{
27 qDebug( "New Account Configuration Widget" ); 25 qDebug( "New Account Configuration Widget" );
28 settings = s; 26 settings = s;
29 27
30 mailList->addColumn( tr( "Account" ) ); 28 mailList->addColumn( tr( "Account" ) );
31 mailList->addColumn( tr( "Type" ) ); 29 mailList->addColumn( tr( "Type" ) );
32 30
33 newsList->addColumn( tr( "Account" ) ); 31 newsList->addColumn( tr( "Account" ) );
34 32
35 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); 33 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) );
36 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); 34 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) );
37 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); 35 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) );
38 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); 36 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) );
39 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); 37 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) );
40 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); 38 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) );
41 39
42 slotFillLists(); 40 slotFillLists();
43} 41}
44 42
45void EditAccounts::slotFillLists() 43void EditAccounts::slotFillLists()
46{ 44{
47 mailList->clear(); 45 mailList->clear();
@@ -474,105 +472,105 @@ void SMTPconfig::accept()
474 data->setAccountName( accountLine->text() ); 472 data->setAccountName( accountLine->text() );
475 data->setServer( serverLine->text() ); 473 data->setServer( serverLine->text() );
476 data->setPort( portLine->text() ); 474 data->setPort( portLine->text() );
477 data->setConnectionType( ComboBox1->currentItem() ); 475 data->setConnectionType( ComboBox1->currentItem() );
478 data->setLogin( loginBox->isChecked() ); 476 data->setLogin( loginBox->isChecked() );
479 data->setUser( userLine->text() ); 477 data->setUser( userLine->text() );
480 data->setPassword( passLine->text() ); 478 data->setPassword( passLine->text() );
481 479
482 QDialog::accept(); 480 QDialog::accept();
483} 481}
484 482
485/** 483/**
486 * NNTPconfig 484 * NNTPconfig
487 */ 485 */
488 486
489NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 487NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
490 : NNTPconfigUI( parent, name, modal, flags ) 488 : NNTPconfigUI( parent, name, modal, flags )
491{ 489{
492 data = account; 490 data = account;
493 491
494 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); 492 connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
495 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); 493 connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
496 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); 494 connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) );
497 fillValues(); 495 fillValues();
498 496
499 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); 497 connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) );
500} 498}
501 499
502void NNTPconfig::slotGetNG() { 500void NNTPconfig::slotGetNG() {
503 save(); 501 save();
504 data->save(); 502 data->save();
505 NNTPwrapper* tmp = new NNTPwrapper( data ); 503 NNTPwrapper* tmp = new NNTPwrapper( data );
506 clist* list = tmp->listAllNewsgroups(); 504 QStringList list = tmp->listAllNewsgroups();
507 505
508 clistcell *current; 506 ListViewGroups->clear();
509 newsnntp_group_description *group; 507
510 508 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
511 // FIXME - test if not empty 509 QCheckListItem *item;
512 current = list->first; 510 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
513 for ( current=clist_begin(list);current!=NULL;current=clist_next(current) ) { 511 if ( subscribedGroups.contains( (*it) ) >= 1 ) {
514 group = ( newsnntp_group_description* ) current->data; 512 item->setOn( true );
515 // qDebug( group->grp_name ); 513 }
516 514 }
517 QCheckListItem *item;
518 item = new QCheckListItem( ListViewGroups, ( QString )group->grp_name, QCheckListItem::CheckBox );
519 if ( subscribedGroups.contains( ( QString )group->grp_name ) >= 1 ) {
520 item->setOn( true );
521 }
522 }
523} 515}
524 516
525void NNTPconfig::slotSSL( bool enabled ) 517void NNTPconfig::slotSSL( bool enabled )
526{ 518{
527 if ( enabled ) 519 if ( enabled )
528 { 520 {
529 portLine->setText( NNTP_SSL_PORT ); 521 portLine->setText( NNTP_SSL_PORT );
530 } 522 }
531 else 523 else
532 { 524 {
533 portLine->setText( NNTP_PORT ); 525 portLine->setText( NNTP_PORT );
534 } 526 }
535} 527}
536 528
537void NNTPconfig::fillValues() 529void NNTPconfig::fillValues()
538{ 530{
539 accountLine->setText( data->getAccountName() ); 531 accountLine->setText( data->getAccountName() );
540 serverLine->setText( data->getServer() ); 532 serverLine->setText( data->getServer() );
541 portLine->setText( data->getPort() ); 533 portLine->setText( data->getPort() );
542 sslBox->setChecked( data->getSSL() ); 534 sslBox->setChecked( data->getSSL() );
543 loginBox->setChecked( data->getLogin() ); 535 loginBox->setChecked( data->getLogin() );
544 userLine->setText( data->getUser() ); 536 userLine->setText( data->getUser() );
545 passLine->setText( data->getPassword() ); 537 passLine->setText( data->getPassword() );
546 subscribedGroups = data->getGroups(); 538 subscribedGroups = data->getGroups();
539 /* don't forget that - you will overwrite values if user clicks cancel! */
540 for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) {
541 QCheckListItem *item;
542 item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox );
543 item->setOn( true );
544 }
547} 545}
548 546
549void NNTPconfig::save() 547void NNTPconfig::save()
550{ 548{
551 data->setAccountName( accountLine->text() ); 549 data->setAccountName( accountLine->text() );
552 data->setServer( serverLine->text() ); 550 data->setServer( serverLine->text() );
553 data->setPort( portLine->text() ); 551 data->setPort( portLine->text() );
554 data->setSSL( sslBox->isChecked() ); 552 data->setSSL( sslBox->isChecked() );
555 data->setLogin( loginBox->isChecked() ); 553 data->setLogin( loginBox->isChecked() );
556 data->setUser( userLine->text() ); 554 data->setUser( userLine->text() );
557 data->setPassword( passLine->text() ); 555 data->setPassword( passLine->text() );
558 556
559 QListViewItemIterator list_it( ListViewGroups ); 557 QListViewItemIterator list_it( ListViewGroups );
560 558
561 QStringList groupList; 559 QStringList groupList;
562 for ( ; list_it.current(); ++list_it ) { 560 for ( ; list_it.current(); ++list_it ) {
563 561
564 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { 562 if ( ( (QCheckListItem*)list_it.current() )->isOn() ) {
565 qDebug(list_it.current()->text(0) ); 563 qDebug(list_it.current()->text(0) );
566 groupList.append( list_it.current()->text(0) ); 564 groupList.append( list_it.current()->text(0) );
567 } 565 }
568 566
569 } 567 }
570 data->setGroups( groupList ); 568 data->setGroups( groupList );
571} 569}
572 570
573void NNTPconfig::accept() 571void NNTPconfig::accept()
574{ 572{
575 save(); 573 save();
576 QDialog::accept(); 574 QDialog::accept();
577} 575}
578 576
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
index 798879d..a766a59 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
@@ -173,78 +173,87 @@ void NNTPwrapper::login()
173 qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); 173 qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) );
174 // Global::statusMessage(tr("Error initializing folder")); 174 // Global::statusMessage(tr("Error initializing folder"));
175 mailstorage_free(m_nntp); 175 mailstorage_free(m_nntp);
176 m_nntp = 0; 176 m_nntp = 0;
177 177
178 } 178 }
179 179
180} 180}
181 181
182void NNTPwrapper::logout() 182void NNTPwrapper::logout()
183{ 183{
184 int err = NEWSNNTP_NO_ERROR; 184 int err = NEWSNNTP_NO_ERROR;
185 if ( m_nntp == NULL ) 185 if ( m_nntp == NULL )
186 return; 186 return;
187 mailstorage_free(m_nntp); 187 mailstorage_free(m_nntp);
188 m_nntp = 0; 188 m_nntp = 0;
189} 189}
190 190
191QList<Folder>* NNTPwrapper::listFolders() { 191QList<Folder>* NNTPwrapper::listFolders() {
192 192
193 QList<Folder> * folders = new QList<Folder>(); 193 QList<Folder> * folders = new QList<Folder>();
194 folders->setAutoDelete( false ); 194 folders->setAutoDelete( false );
195 QStringList groups; 195 QStringList groups;
196 if (account) { 196 if (account) {
197 groups = account->getGroups(); 197 groups = account->getGroups();
198 } 198 }
199 for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { 199 for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) {
200 folders->append(new Folder((*it),".")); 200 folders->append(new Folder((*it),"."));
201 } 201 }
202 return folders; 202 return folders;
203} 203}
204 204
205 clist * NNTPwrapper::listAllNewsgroups() { 205QStringList NNTPwrapper::listAllNewsgroups() {
206 login(); 206 login();
207 QStringList res;
207 clist *result = 0; 208 clist *result = 0;
208 clistcell *current; 209 clistcell *current = 0;
209 newsnntp_group_description *list; 210 newsnntp_group_description *group;
210 if ( m_nntp ) { 211
211 mailsession * session = m_nntp->sto_session; 212 if ( m_nntp ) {
212 newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; 213 mailsession * session = m_nntp->sto_session;
213 int err = newsnntp_list_newsgroups(news, NULL, &result); 214 newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session;
214 215 int err = newsnntp_list_newsgroups(news, NULL, &result);
215 if ( err == NEWSNNTP_NO_ERROR ) { 216 if ( err == NEWSNNTP_NO_ERROR && result) {
216 return result; 217 for ( current=clist_begin(result);current!=NULL;current=clist_next(current) ) {
217 } 218 group = ( newsnntp_group_description* ) current->data;
218 } 219 if (!group||!group->grp_name||strlen(group->grp_name)==0) continue;
220 res.append(group->grp_name);
221 }
222 }
223 }
224 if (result) {
225 clist_free(result);
226 }
227 return res;
219} 228}
220 229
221void NNTPwrapper::answeredMail(const RecMail&) {} 230void NNTPwrapper::answeredMail(const RecMail&) {}
222 231
223void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { 232void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) {
224 login(); 233 login();
225 target_stat.message_count = 0; 234 target_stat.message_count = 0;
226 target_stat.message_unseen = 0; 235 target_stat.message_unseen = 0;
227 target_stat.message_recent = 0; 236 target_stat.message_recent = 0;
228 if (!m_nntp) 237 if (!m_nntp)
229 return; 238 return;
230 int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, 239 int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count,
231 &target_stat.message_recent,&target_stat.message_unseen); 240 &target_stat.message_recent,&target_stat.message_unseen);
232} 241}
233 242
234 243
235encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) { 244encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) {
236 char*target=0; 245 char*target=0;
237 size_t length=0; 246 size_t length=0;
238 encodedString*res = 0; 247 encodedString*res = 0;
239 mailmessage * mailmsg = 0; 248 mailmessage * mailmsg = 0;
240 int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); 249 int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg);
241 err = mailmessage_fetch(mailmsg,&target,&length); 250 err = mailmessage_fetch(mailmsg,&target,&length);
242 if (mailmsg) 251 if (mailmsg)
243 mailmessage_free(mailmsg); 252 mailmessage_free(mailmsg);
244 if (target) { 253 if (target) {
245 res = new encodedString(target,length); 254 res = new encodedString(target,length);
246 } 255 }
247 return res; 256 return res;
248} 257}
249 258
250const QString&NNTPwrapper::getType()const { 259const QString&NNTPwrapper::getType()const {
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h
index e8e2cf4..4d03754 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.h
@@ -1,48 +1,48 @@
1#ifndef __NNTPWRAPPER 1#ifndef __NNTPWRAPPER
2#define __NNTPWRAPPER 2#define __NNTPWRAPPER
3 3
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5#include "genericwrapper.h" 5#include "genericwrapper.h"
6#include <qstring.h> 6#include <qstring.h>
7#include <libetpan/clist.h> 7#include <libetpan/clist.h>
8 8
9class encodedString; 9class encodedString;
10struct mailstorage; 10struct mailstorage;
11struct mailfolder; 11struct mailfolder;
12 12
13class NNTPwrapper : public Genericwrapper 13class NNTPwrapper : public Genericwrapper
14{ 14{
15 15
16 Q_OBJECT 16 Q_OBJECT
17 17
18public: 18public:
19 NNTPwrapper( NNTPaccount *a ); 19 NNTPwrapper( NNTPaccount *a );
20 virtual ~NNTPwrapper(); 20 virtual ~NNTPwrapper();
21 21
22 /* mailbox will be ignored */ 22 /* mailbox will be ignored */
23 virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); 23 virtual void listMessages(const QString & mailbox, QList<RecMail> &target );
24 /* should only get the subscribed one */ 24 /* should only get the subscribed one */
25 virtual QList<Folder>* listFolders(); 25 virtual QList<Folder>* listFolders();
26 /* mailbox will be ignored */ 26 /* mailbox will be ignored */
27 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 27 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
28 clist * listAllNewsgroups(); 28 QStringList listAllNewsgroups();
29 virtual void deleteMail(const RecMail&mail); 29 virtual void deleteMail(const RecMail&mail);
30 virtual void answeredMail(const RecMail&mail); 30 virtual void answeredMail(const RecMail&mail);
31 virtual int deleteAllMail(const Folder*); 31 virtual int deleteAllMail(const Folder*);
32 32
33 virtual RecBody fetchBody( const RecMail &mail ); 33 virtual RecBody fetchBody( const RecMail &mail );
34 virtual encodedString* fetchRawBody(const RecMail&mail); 34 virtual encodedString* fetchRawBody(const RecMail&mail);
35 virtual void logout(); 35 virtual void logout();
36 virtual const QString&getType()const; 36 virtual const QString&getType()const;
37 virtual const QString&getName()const; 37 virtual const QString&getName()const;
38 static void nntp_progress( size_t current, size_t maximum ); 38 static void nntp_progress( size_t current, size_t maximum );
39 39
40protected: 40protected:
41 void login(); 41 void login();
42 NNTPaccount *account; 42 NNTPaccount *account;
43 mailstorage* m_nntp; 43 mailstorage* m_nntp;
44 44
45 45
46}; 46};
47 47
48#endif 48#endif