summaryrefslogtreecommitdiff
authorharlekin <harlekin>2004-03-05 23:08:46 (UTC)
committer harlekin <harlekin>2004-03-05 23:08:46 (UTC)
commit6afcd375a640d5c6888bc111cd1d80a08f554136 (patch) (side-by-side diff)
tree520b12836ea13ee6e58f36a8851994fcfbe16051
parentb4ec902435df4e3c834b7790c1dc70a235157477 (diff)
downloadopie-6afcd375a640d5c6888bc111cd1d80a08f554136.zip
opie-6afcd375a640d5c6888bc111cd1d80a08f554136.tar.gz
opie-6afcd375a640d5c6888bc111cd1d80a08f554136.tar.bz2
list newsgroups in nntp config
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/editaccounts.cpp39
-rw-r--r--noncore/net/mail/editaccounts.h7
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.cpp24
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.h2
-rw-r--r--noncore/net/mail/nntpconfigui.ui38
5 files changed, 67 insertions, 43 deletions
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp
index edeb1de..2a1acc0 100644
--- a/noncore/net/mail/editaccounts.cpp
+++ b/noncore/net/mail/editaccounts.cpp
@@ -1,532 +1,567 @@
#include "defines.h"
#include "editaccounts.h"
/* OPIE */
#include <qpe/qpeapplication.h>
/* QT */
#include <qt.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();
newsList->clear();
QList<Account> accounts = settings->getAccounts();
Account *it;
for ( it = accounts.first(); it; it = accounts.next() )
{
if ( it->getType().compare( "NNTP" ) == 0 )
{
(void) new AccountListItem( newsList, it );
}
else
{
(void) new AccountListItem( mailList, it );
}
}
}
void EditAccounts::slotNewMail()
{
qDebug( "New Mail Account" );
QString *selection = new QString();
SelectMailType selType( selection, this, 0, true );
selType.show();
if ( QDialog::Accepted == selType.exec() )
{
slotNewAccount( *selection );
}
}
void EditAccounts::slotNewAccount( const QString &type )
{
if ( type.compare( "IMAP" ) == 0 )
{
qDebug( "-> config IMAP" );
IMAPaccount *account = new IMAPaccount();
IMAPconfig imap( account, this, 0, true );
if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) )
{
settings->addAccount( account );
account->save();
slotFillLists();
}
else
{
account->remove();
}
}
else if ( type.compare( "POP3" ) == 0 )
{
qDebug( "-> config POP3" );
POP3account *account = new POP3account();
POP3config pop3( account, this, 0, true, WStyle_ContextHelp );
if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) )
{
settings->addAccount( account );
account->save();
slotFillLists();
}
else
{
account->remove();
}
}
else if ( type.compare( "SMTP" ) == 0 )
{
qDebug( "-> config SMTP" );
SMTPaccount *account = new SMTPaccount();
SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp );
if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) )
{
settings->addAccount( account );
account->save();
slotFillLists();
}
else
{
account->remove();
}
}
else if ( type.compare( "NNTP" ) == 0 )
{
qDebug( "-> config NNTP" );
NNTPaccount *account = new NNTPaccount();
NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp );
if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) )
{
settings->addAccount( account );
account->save();
slotFillLists();
}
else
{
account->remove();
}
}
}
void EditAccounts::slotEditAccount( Account *account )
{
if ( account->getType().compare( "IMAP" ) == 0 )
{
IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account);
IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp );
if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) )
{
slotFillLists();
}
}
else if ( account->getType().compare( "POP3" ) == 0 )
{
POP3account *pop3Acc = static_cast<POP3account *>(account);
POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp );
if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) )
{
slotFillLists();
}
}
else if ( account->getType().compare( "SMTP" ) == 0 )
{
SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account);
SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp );
if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) )
{
slotFillLists();
}
}
else if ( account->getType().compare( "NNTP" ) == 0 )
{
NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account);
NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp );
if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) )
{
slotFillLists();
}
}
}
void EditAccounts::slotDeleteAccount( Account *account )
{
if ( QMessageBox::information( this, tr( "Question" ),
tr( "<p>Do you really want to delete the selected Account?</p>" ),
tr( "Yes" ), tr( "No" ) ) == 0 )
{
settings->delAccount( account );
slotFillLists();
}
}
void EditAccounts::slotEditMail()
{
qDebug( "Edit Mail Account" );
if ( !mailList->currentItem() )
{
QMessageBox::information( this, tr( "Error" ),
tr( "<p>Please select an account.</p>" ),
tr( "Ok" ) );
return;
}
Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
slotEditAccount( a );
}
void EditAccounts::slotDeleteMail()
{
if ( !mailList->currentItem() )
{
QMessageBox::information( this, tr( "Error" ),
tr( "<p>Please select an account.</p>" ),
tr( "Ok" ) );
return;
}
Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
slotDeleteAccount( a );
}
void EditAccounts::slotNewNews()
{
qDebug( "New News Account" );
slotNewAccount( "NNTP" );
}
void EditAccounts::slotEditNews()
{
qDebug( "Edit News Account" );
if ( !newsList->currentItem() )
{
QMessageBox::information( this, tr( "Error" ),
tr( "<p>Please select an account.</p>" ),
tr( "Ok" ) );
return;
}
Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
slotEditAccount( a );
}
void EditAccounts::slotDeleteNews()
{
qDebug( "Delete News Account" );
if ( !newsList->currentItem() )
{
QMessageBox::information( this, tr( "Error" ),
tr( "<p>Please select an account.</p>" ),
tr( "Ok" ) );
return;
}
Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
slotDeleteAccount( a );
}
void EditAccounts::slotAdjustColumns()
{
int currPage = configTab->currentPageIndex();
configTab->showPage( mailTab );
mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 );
mailList->setColumnWidth( 1, 50 );
configTab->showPage( newsTab );
newsList->setColumnWidth( 0, newsList->visibleWidth() );
configTab->setCurrentPage( currPage );
}
void EditAccounts::accept()
{
settings->saveAccounts();
QDialog::accept();
}
/**
* SelectMailType
*/
SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags )
: SelectMailTypeUI( parent, name, modal, flags )
{
selected = selection;
selected->replace( 0, selected->length(), typeBox->currentText() );
connect( typeBox, SIGNAL( activated(const QString&) ), SLOT( slotSelection(const QString&) ) );
}
void SelectMailType::slotSelection( const QString &sel )
{
selected->replace( 0, selected->length(), sel );
}
/**
* IMAPconfig
*/
IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
: IMAPconfigUI( parent, name, modal, flags )
{
data = account;
fillValues();
connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
ComboBox1->insertItem( "Only if available", 0 );
ComboBox1->insertItem( "Always, Negotiated", 1 );
ComboBox1->insertItem( "Connect on secure port", 2 );
ComboBox1->insertItem( "Run command instead", 3 );
CommandEdit->hide();
ComboBox1->setCurrentItem( data->ConnectionType() );
}
void IMAPconfig::slotConnectionToggle( int index )
{
if ( index == 2 )
{
portLine->setText( IMAP_SSL_PORT );
}
else if ( index == 3 )
{
portLine->setText( IMAP_PORT );
CommandEdit->show();
}
else
{
portLine->setText( IMAP_PORT );
}
}
void IMAPconfig::fillValues()
{
accountLine->setText( data->getAccountName() );
serverLine->setText( data->getServer() );
portLine->setText( data->getPort() );
ComboBox1->setCurrentItem( data->ConnectionType() );
userLine->setText( data->getUser() );
passLine->setText( data->getPassword() );
prefixLine->setText(data->getPrefix());
}
void IMAPconfig::accept()
{
data->setAccountName( accountLine->text() );
data->setServer( serverLine->text() );
data->setPort( portLine->text() );
data->setConnectionType( ComboBox1->currentItem() );
data->setUser( userLine->text() );
data->setPassword( passLine->text() );
data->setPrefix(prefixLine->text());
QDialog::accept();
}
/**
* POP3config
*/
POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags )
: POP3configUI( parent, name, modal, flags )
{
data = account;
fillValues();
connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
ComboBox1->insertItem( "Only if available", 0 );
ComboBox1->insertItem( "Always, Negotiated", 1 );
ComboBox1->insertItem( "Connect on secure port", 2 );
ComboBox1->insertItem( "Run command instead", 3 );
CommandEdit->hide();
ComboBox1->setCurrentItem( data->ConnectionType() );
}
void POP3config::slotConnectionToggle( int index )
{
// 2 is ssl connection
if ( index == 2 )
{
portLine->setText( POP3_SSL_PORT );
}
else if ( index == 3 )
{
portLine->setText( POP3_PORT );
CommandEdit->show();
}
else
{
portLine->setText( POP3_PORT );
}
}
void POP3config::fillValues()
{
accountLine->setText( data->getAccountName() );
serverLine->setText( data->getServer() );
portLine->setText( data->getPort() );
ComboBox1->setCurrentItem( data->ConnectionType() );
userLine->setText( data->getUser() );
passLine->setText( data->getPassword() );
}
void POP3config::accept()
{
data->setAccountName( accountLine->text() );
data->setServer( serverLine->text() );
data->setPort( portLine->text() );
data->setConnectionType( ComboBox1->currentItem() );
data->setUser( userLine->text() );
data->setPassword( passLine->text() );
QDialog::accept();
}
/**
* SMTPconfig
*/
SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
: SMTPconfigUI( parent, name, modal, flags )
{
data = account;
connect( loginBox, SIGNAL( toggled(bool) ), userLine, SLOT( setEnabled(bool) ) );
connect( loginBox, SIGNAL( toggled(bool) ), passLine, SLOT( setEnabled(bool) ) );
fillValues();
connect( ComboBox1, SIGNAL( activated(int) ), SLOT( slotConnectionToggle(int) ) );
ComboBox1->insertItem( "Only if available", 0 );
ComboBox1->insertItem( "Always, Negotiated", 1 );
ComboBox1->insertItem( "Connect on secure port", 2 );
ComboBox1->insertItem( "Run command instead", 3 );
CommandEdit->hide();
ComboBox1->setCurrentItem( data->ConnectionType() );
}
void SMTPconfig::slotConnectionToggle( int index )
{
// 2 is ssl connection
if ( index == 2 )
{
portLine->setText( SMTP_SSL_PORT );
}
else if ( index == 3 )
{
portLine->setText( SMTP_PORT );
CommandEdit->show();
}
else
{
portLine->setText( SMTP_PORT );
}
}
void SMTPconfig::fillValues()
{
accountLine->setText( data->getAccountName() );
serverLine->setText( data->getServer() );
portLine->setText( data->getPort() );
ComboBox1->setCurrentItem( data->ConnectionType() );
loginBox->setChecked( data->getLogin() );
userLine->setText( data->getUser() );
passLine->setText( data->getPassword() );
}
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 );
+ }
+}
+
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() );
}
-void NNTPconfig::accept()
+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 );
+ for ( ; list_it.current(); ++list_it ) {
+ if ( list_it.current()->isSelected() ) {
+ qDebug( list_it.current()->text(0) );
+ }
+ }
+}
+
+void NNTPconfig::accept()
+{
+ save();
QDialog::accept();
}
diff --git a/noncore/net/mail/editaccounts.h b/noncore/net/mail/editaccounts.h
index d8e1219..438a984 100644
--- a/noncore/net/mail/editaccounts.h
+++ b/noncore/net/mail/editaccounts.h
@@ -1,147 +1,152 @@
#ifndef EDITACCOUNTS_H
#define EDITACCOUNTS_H
#include <qstring.h>
#include <qlistview.h>
#include "editaccountsui.h"
#include "selectmailtypeui.h"
#include "imapconfigui.h"
#include "pop3configui.h"
#include "smtpconfigui.h"
#include "nntpconfigui.h"
+
+#include <libetpan/clist.h>
#include <libmailwrapper/settings.h>
class AccountListItem : public QListViewItem
{
public:
AccountListItem( QListView *parent, Account *a);
Account *getAccount() { return account; }
private:
Account *account;
};
class EditAccounts : public EditAccountsUI
{
Q_OBJECT
public:
EditAccounts( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
public slots:
void slotNewAccount( const QString &type );
void slotEditAccount( Account *account );
void slotDeleteAccount( Account * account );
void slotAdjustColumns();
protected slots:
void slotFillLists();
void slotNewMail();
void slotEditMail();
void slotDeleteMail();
void slotNewNews();
void slotEditNews();
void slotDeleteNews();
void accept();
private:
Settings *settings;
};
class SelectMailType : public SelectMailTypeUI
{
Q_OBJECT
public:
SelectMailType( QString *selection = 0, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
private slots:
void slotSelection( const QString &sel );
private:
QString *selected;
};
class IMAPconfig : public IMAPconfigUI
{
Q_OBJECT
public:
IMAPconfig( IMAPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
public slots:
void fillValues();
protected slots:
void slotConnectionToggle( int index );
void accept();
-
+
private:
IMAPaccount *data;
};
class POP3config : public POP3configUI
{
Q_OBJECT
public:
POP3config( POP3account *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
public slots:
void fillValues();
protected slots:
void slotConnectionToggle( int index );
void accept();
private:
POP3account *data;
};
class SMTPconfig : public SMTPconfigUI
{
Q_OBJECT
public:
SMTPconfig( SMTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
public slots:
void fillValues();
protected slots:
void slotConnectionToggle( int index );
void accept();
private:
SMTPaccount *data;
};
class NNTPconfig : public NNTPconfigUI
{
Q_OBJECT
public:
NNTPconfig( NNTPaccount *account, QWidget *parent = 0, const char *name = 0, bool modal = 0, WFlags flags = 0 );
public slots:
void fillValues();
protected slots:
void slotSSL( bool enabled );
void accept();
+ void slotGetNG();
private:
+ void save();
NNTPaccount *data;
+ clist* list;
};
#endif
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
index 54e0ed4..2d6f9a3 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
@@ -1,265 +1,257 @@
#include "nntpwrapper.h"
#include "logindialog.h"
#include "mailtypes.h"
#include <qfile.h>
#include <stdlib.h>
#include <libetpan/libetpan.h>
-#include <libetpan/nntpdriver.h>
-
#define HARD_MSG_SIZE_LIMIT 5242880
NNTPwrapper::NNTPwrapper( NNTPaccount *a )
: Genericwrapper() {
account = a;
m_nntp = NULL;
msgTempName = a->getFileName()+"_msg_cache";
last_msg_id = 0;
}
NNTPwrapper::~NNTPwrapper() {
logout();
QFile msg_cache(msgTempName);
if (msg_cache.exists()) {
msg_cache.remove();
}
}
void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) {
qDebug( "NNTP: %i of %i", current, maximum );
}
RecBody NNTPwrapper::fetchBody( const RecMail &mail ) {
int err = NEWSNNTP_NO_ERROR;
char *message = 0;
size_t length = 0;
login();
if ( !m_nntp ) {
return RecBody();
}
RecBody body;
mailmessage * mailmsg;
if (mail.Msgsize()>HARD_MSG_SIZE_LIMIT) {
qDebug("Message to large: %i",mail.Msgsize());
return body;
}
QFile msg_cache(msgTempName);
cleanMimeCache();
if (mail.getNumber()!=last_msg_id) {
if (msg_cache.exists()) {
msg_cache.remove();
}
msg_cache.open(IO_ReadWrite|IO_Truncate);
last_msg_id = mail.getNumber();
err = mailsession_get_message(m_nntp->sto_session, mail.getNumber(), &mailmsg);
err = mailmessage_fetch(mailmsg,&message,&length);
msg_cache.writeBlock(message,length);
} else {
QString msg="";
msg_cache.open(IO_ReadOnly);
message = new char[4096];
memset(message,0,4096);
while (msg_cache.readBlock(message,4095)>0) {
msg+=message;
memset(message,0,4096);
}
delete message;
message = (char*)malloc(msg.length()+1*sizeof(char));
memset(message,0,msg.length()+1);
memcpy(message,msg.latin1(),msg.length());
/* transform to libetpan stuff */
mailmsg = mailmessage_new();
mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message));
generic_message_t * msg_data;
msg_data = (generic_message_t *)mailmsg->msg_data;
msg_data->msg_fetched = 1;
msg_data->msg_message = message;
msg_data->msg_length = strlen(message);
}
body = parseMail(mailmsg);
/* clean up */
if (mailmsg)
mailmessage_free(mailmsg);
if (message)
free(message);
return body;
}
void NNTPwrapper::listMessages(const QString &, QList<RecMail> &target )
{
login();
if (!m_nntp)
return;
uint32_t res_messages,res_recent,res_unseen;
mailsession_status_folder(m_nntp->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen);
parseList(target,m_nntp->sto_session,"INBOX");
}
void NNTPwrapper::login()
{
if (account->getOffline())
return;
/* we'll hold the line */
if ( m_nntp != NULL )
return;
const char *server, *user, *pass;
QString User,Pass;
uint16_t port;
int err = NEWSNNTP_NO_ERROR;
server = account->getServer().latin1();
port = account->getPort().toUInt();
user = pass = 0;
if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
login.show();
if ( QDialog::Accepted == login.exec() ) {
// ok
User = login.getUser().latin1();
Pass = login.getPassword().latin1();
} else {
// cancel
qDebug( "NNTP: Login canceled" );
return;
}
} else {
User = account->getUser().latin1();
Pass = account->getPassword().latin1();
}
if (User.isEmpty()) {
user=0;
pass = 0;
} else {
user=User.latin1();
pass=Pass.latin1();
}
// bool ssl = account->getSSL();
m_nntp=mailstorage_new(NULL);
int conntypeset = account->ConnectionType();
int conntype = 0;
if ( conntypeset == 3 ) {
conntype = CONNECTION_TYPE_COMMAND;
} else if ( conntypeset == 2 ) {
conntype = CONNECTION_TYPE_TLS;
} else if ( conntypeset == 1 ) {
conntype = CONNECTION_TYPE_STARTTLS;
} else if ( conntypeset == 0 ) {
conntype = CONNECTION_TYPE_TRY_STARTTLS;
}
nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN,
(char*)user,(char*)pass,0,0,0);
err = mailstorage_connect( m_nntp );
if (err != NEWSNNTP_NO_ERROR) {
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 );
+
+// folders->append(inb);
+ return folders;
+}
+
+ clist * NNTPwrapper::listAllNewsgroups() {
+ login();
clist *result = 0;
clistcell *current;
newsnntp_group_description *list;
-
- login();
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 ) {
- current = result->first;
- for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) {
- list = ( newsnntp_group_description* ) current->data;
- qDebug( list->grp_name );
- }
-// Folder*inb=new Folder("INBOX","/");
+ return result;
}
}
-// folders->append(inb);
- return folders;
}
-
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 {
return account->getType();
}
const QString&NNTPwrapper::getName()const{
return account->getAccountName();
}
void NNTPwrapper::deleteMail(const RecMail&mail) {
}
int NNTPwrapper::deleteAllMail(const Folder*) {
}
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h
index e47e68f..e4d4a37 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();
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
diff --git a/noncore/net/mail/nntpconfigui.ui b/noncore/net/mail/nntpconfigui.ui
index 7769804..25d564e 100644
--- a/noncore/net/mail/nntpconfigui.ui
+++ b/noncore/net/mail/nntpconfigui.ui
@@ -1,352 +1,344 @@
<!DOCTYPE UI><UI>
<class>NNTPconfigUI</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>NNTPconfigUI</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>413</width>
+ <width>409</width>
<height>520</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Configure NNTP</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<vbox>
<property stdset="1">
<name>margin</name>
<number>3</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>3</number>
</property>
<widget>
<class>QTabWidget</class>
<property stdset="1">
<name>name</name>
<cstring>TabWidget2</cstring>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>Account</string>
</attribute>
<grid>
<property stdset="1">
<name>margin</name>
<number>3</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>3</number>
</property>
<widget row="2" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>serverLine</cstring>
</property>
</widget>
<widget row="3" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>portLabel</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Port</string>
</property>
</widget>
<widget row="3" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>portLine</cstring>
</property>
</widget>
<widget row="0" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>accountLine</cstring>
</property>
<property>
<name>toolTip</name>
<string>Name of the Account</string>
</property>
</widget>
<widget row="0" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>accountLabel</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Account</string>
</property>
</widget>
<widget row="2" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>serverLabel</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>true</bool>
</property>
<property stdset="1">
<name>caption</name>
<string></string>
</property>
<property stdset="1">
<name>text</name>
<string>Server</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
</widget>
<widget row="1" column="0" rowspan="1" colspan="2" >
<class>Line</class>
<property stdset="1">
<name>name</name>
<cstring>line1</cstring>
</property>
<property stdset="1">
<name>caption</name>
<string></string>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
</widget>
<widget row="4" column="1" >
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>sslBox</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Use SSL</string>
</property>
</widget>
<widget row="5" column="0" rowspan="2" colspan="2" >
<class>Line</class>
<property stdset="1">
<name>name</name>
<cstring>line2</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>true</bool>
</property>
<property stdset="1">
<name>caption</name>
<string></string>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</enum>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
</widget>
<widget row="7" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>userLabel</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>User</string>
</property>
</widget>
<widget row="8" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>passLabel</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Password</string>
</property>
</widget>
<spacer row="9" column="1" >
<property>
<name>name</name>
<cstring>spacer</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
</property>
<property stdset="1">
<name>sizeType</name>
<enum>Expanding</enum>
</property>
<property>
<name>sizeHint</name>
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget row="6" column="1" >
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>loginBox</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Use Login</string>
</property>
</widget>
<widget row="7" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>userLine</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>false</bool>
</property>
</widget>
<widget row="8" column="1" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>passLine</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>false</bool>
</property>
<property stdset="1">
<name>echoMode</name>
<enum>Password</enum>
</property>
</widget>
</grid>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>Groups</string>
</attribute>
<vbox>
<property stdset="1">
<name>margin</name>
<number>3</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>3</number>
</property>
<widget>
<class>QListView</class>
+ <column>
+ <property>
+ <name>text</name>
+ <string>Newsgroup</string>
+ </property>
+ <property>
+ <name>clickable</name>
+ <bool>true</bool>
+ </property>
+ <property>
+ <name>resizeable</name>
+ <bool>true</bool>
+ </property>
+ </column>
<property stdset="1">
<name>name</name>
<cstring>ListViewGroups</cstring>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>GetNGButton</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Get newsgroup list from server</string>
</property>
</widget>
</vbox>
</widget>
</widget>
</vbox>
</widget>
-<customwidgets>
- <customwidget>
- <class>QListView</class>
- <header location="global">qlistview.h</header>
- <sizehint>
- <width>-1</width>
- <height>-1</height>
- </sizehint>
- <container>0</container>
- <sizepolicy>
- <hordata>5</hordata>
- <verdata>5</verdata>
- </sizepolicy>
- <pixmap>image0</pixmap>
- </customwidget>
-</customwidgets>
-<images>
- <image>
- <name>image0</name>
- <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
- </image>
-</images>
<tabstops>
<tabstop>accountLine</tabstop>
<tabstop>serverLine</tabstop>
<tabstop>portLine</tabstop>
<tabstop>sslBox</tabstop>
<tabstop>loginBox</tabstop>
<tabstop>userLine</tabstop>
<tabstop>passLine</tabstop>
</tabstops>
</UI>