-rw-r--r-- | noncore/net/mail/editaccounts.cpp | 36 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/nntpwrapper.cpp | 35 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/nntpwrapper.h | 2 |
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 @@ #include "defines.h" #include "editaccounts.h" /* OPIE */ #include <qpe/qpeapplication.h> /* QT */ #include <qt.h> #include <qstringlist.h> #include <libmailwrapper/nntpwrapper.h> -#include <libetpan/nntpdriver.h> - AccountListItem::AccountListItem( QListView *parent, Account *a) : QListViewItem( parent ) { account = a; setText( 0, account->getAccountName() ); setText( 1, account->getType() ); } EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) : EditAccountsUI( parent, name, modal, flags ) { qDebug( "New Account Configuration Widget" ); settings = s; mailList->addColumn( tr( "Account" ) ); mailList->addColumn( tr( "Type" ) ); newsList->addColumn( tr( "Account" ) ); connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); slotFillLists(); } void EditAccounts::slotFillLists() { mailList->clear(); @@ -474,105 +472,105 @@ void SMTPconfig::accept() data->setAccountName( accountLine->text() ); data->setServer( serverLine->text() ); data->setPort( portLine->text() ); data->setConnectionType( ComboBox1->currentItem() ); data->setLogin( loginBox->isChecked() ); data->setUser( userLine->text() ); data->setPassword( passLine->text() ); QDialog::accept(); } /** * NNTPconfig */ NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) : NNTPconfigUI( parent, name, modal, flags ) { data = account; connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) ); connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) ); connect( GetNGButton, SIGNAL( clicked() ), this, SLOT( slotGetNG() ) ); fillValues(); connect( sslBox, SIGNAL( toggled(bool) ), SLOT( slotSSL(bool) ) ); } void NNTPconfig::slotGetNG() { save(); data->save(); NNTPwrapper* tmp = new NNTPwrapper( data ); - clist* list = tmp->listAllNewsgroups(); - - clistcell *current; - newsnntp_group_description *group; - - // FIXME - test if not empty - current = list->first; - for ( current=clist_begin(list);current!=NULL;current=clist_next(current) ) { - group = ( newsnntp_group_description* ) current->data; - // qDebug( group->grp_name ); - - QCheckListItem *item; - item = new QCheckListItem( ListViewGroups, ( QString )group->grp_name, QCheckListItem::CheckBox ); - if ( subscribedGroups.contains( ( QString )group->grp_name ) >= 1 ) { - item->setOn( true ); - } - } + QStringList list = tmp->listAllNewsgroups(); + + ListViewGroups->clear(); + + for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { + QCheckListItem *item; + item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); + if ( subscribedGroups.contains( (*it) ) >= 1 ) { + item->setOn( true ); + } + } } void NNTPconfig::slotSSL( bool enabled ) { if ( enabled ) { portLine->setText( NNTP_SSL_PORT ); } else { portLine->setText( NNTP_PORT ); } } void NNTPconfig::fillValues() { accountLine->setText( data->getAccountName() ); serverLine->setText( data->getServer() ); portLine->setText( data->getPort() ); sslBox->setChecked( data->getSSL() ); loginBox->setChecked( data->getLogin() ); userLine->setText( data->getUser() ); passLine->setText( data->getPassword() ); subscribedGroups = data->getGroups(); + /* don't forget that - you will overwrite values if user clicks cancel! */ + for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) { + QCheckListItem *item; + item = new QCheckListItem( ListViewGroups, (*it), QCheckListItem::CheckBox ); + item->setOn( true ); + } } void NNTPconfig::save() { data->setAccountName( accountLine->text() ); data->setServer( serverLine->text() ); data->setPort( portLine->text() ); data->setSSL( sslBox->isChecked() ); data->setLogin( loginBox->isChecked() ); data->setUser( userLine->text() ); data->setPassword( passLine->text() ); QListViewItemIterator list_it( ListViewGroups ); QStringList groupList; for ( ; list_it.current(); ++list_it ) { if ( ( (QCheckListItem*)list_it.current() )->isOn() ) { qDebug(list_it.current()->text(0) ); groupList.append( list_it.current()->text(0) ); } } data->setGroups( groupList ); } void NNTPconfig::accept() { save(); QDialog::accept(); } 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() qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); // Global::statusMessage(tr("Error initializing folder")); mailstorage_free(m_nntp); m_nntp = 0; } } void NNTPwrapper::logout() { int err = NEWSNNTP_NO_ERROR; if ( m_nntp == NULL ) return; mailstorage_free(m_nntp); m_nntp = 0; } QList<Folder>* NNTPwrapper::listFolders() { QList<Folder> * folders = new QList<Folder>(); folders->setAutoDelete( false ); QStringList groups; if (account) { groups = account->getGroups(); } for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { folders->append(new Folder((*it),".")); } return folders; } - clist * NNTPwrapper::listAllNewsgroups() { - login(); +QStringList NNTPwrapper::listAllNewsgroups() { + login(); + QStringList res; clist *result = 0; - clistcell *current; - newsnntp_group_description *list; - if ( m_nntp ) { - mailsession * session = m_nntp->sto_session; - newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; - int err = newsnntp_list_newsgroups(news, NULL, &result); - - if ( err == NEWSNNTP_NO_ERROR ) { - return result; - } - } + clistcell *current = 0; + newsnntp_group_description *group; + + if ( m_nntp ) { + mailsession * session = m_nntp->sto_session; + newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; + int err = newsnntp_list_newsgroups(news, NULL, &result); + if ( err == NEWSNNTP_NO_ERROR && result) { + for ( current=clist_begin(result);current!=NULL;current=clist_next(current) ) { + group = ( newsnntp_group_description* ) current->data; + if (!group||!group->grp_name||strlen(group->grp_name)==0) continue; + res.append(group->grp_name); + } + } + } + if (result) { + clist_free(result); + } + return res; } void NNTPwrapper::answeredMail(const RecMail&) {} void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { login(); target_stat.message_count = 0; target_stat.message_unseen = 0; target_stat.message_recent = 0; if (!m_nntp) return; int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, &target_stat.message_recent,&target_stat.message_unseen); } encodedString* NNTPwrapper::fetchRawBody(const RecMail&mail) { char*target=0; size_t length=0; encodedString*res = 0; mailmessage * mailmsg = 0; int err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg); err = mailmessage_fetch(mailmsg,&target,&length); if (mailmsg) mailmessage_free(mailmsg); if (target) { res = new encodedString(target,length); } return res; } const 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 @@ #ifndef __NNTPWRAPPER #define __NNTPWRAPPER #include "mailwrapper.h" #include "genericwrapper.h" #include <qstring.h> #include <libetpan/clist.h> class encodedString; struct mailstorage; struct mailfolder; class NNTPwrapper : public Genericwrapper { Q_OBJECT public: NNTPwrapper( NNTPaccount *a ); virtual ~NNTPwrapper(); /* mailbox will be ignored */ virtual void listMessages(const QString & mailbox, QList<RecMail> &target ); /* should only get the subscribed one */ virtual QList<Folder>* listFolders(); /* mailbox will be ignored */ virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); - clist * listAllNewsgroups(); + QStringList listAllNewsgroups(); virtual void deleteMail(const RecMail&mail); virtual void answeredMail(const RecMail&mail); virtual int deleteAllMail(const Folder*); virtual RecBody fetchBody( const RecMail &mail ); virtual encodedString* fetchRawBody(const RecMail&mail); virtual void logout(); virtual const QString&getType()const; virtual const QString&getName()const; static void nntp_progress( size_t current, size_t maximum ); protected: void login(); NNTPaccount *account; mailstorage* m_nntp; }; #endif |