summaryrefslogtreecommitdiff
authoralwin <alwin>2004-03-06 12:36:55 (UTC)
committer alwin <alwin>2004-03-06 12:36:55 (UTC)
commita66fd5afde517e9a61e74fc17df617297f134c96 (patch) (side-by-side diff)
tree7bb9819c087516f6b0f3399bdec6d5ce225201e5
parent5b49d47174925c1e2415641b77269b753688f5f1 (diff)
downloadopie-a66fd5afde517e9a61e74fc17df617297f134c96.zip
opie-a66fd5afde517e9a61e74fc17df617297f134c96.tar.gz
opie-a66fd5afde517e9a61e74fc17df617297f134c96.tar.bz2
standalone dlg for (un-)subscribing newsgroups.
May be integrated into the standard nntp-settings-dialog, too.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/.cvsignore3
-rw-r--r--noncore/net/mail/accountitem.cpp15
-rw-r--r--noncore/net/mail/accountitem.h1
-rw-r--r--noncore/net/mail/mail.pro11
-rw-r--r--noncore/net/mail/nntpgroups.cpp57
-rw-r--r--noncore/net/mail/nntpgroups.h33
-rw-r--r--noncore/net/mail/nntpgroupsdlg.cpp29
-rw-r--r--noncore/net/mail/nntpgroupsdlg.h24
-rw-r--r--noncore/net/mail/nntpgroupsui.ui88
9 files changed, 256 insertions, 5 deletions
diff --git a/noncore/net/mail/.cvsignore b/noncore/net/mail/.cvsignore
index 4957719..3819f80 100644
--- a/noncore/net/mail/.cvsignore
+++ b/noncore/net/mail/.cvsignore
@@ -7,25 +7,26 @@ composemailui.h
editaccountsui.cpp
editaccountsui.h
imapconfigui.cpp
imapconfigui.h
logindialogui.cpp
logindialogui.h
nntpconfigui.cpp
nntpconfigui.h
pop3configui.cpp
pop3configui.h
selectmailtypeui.cpp
selectmailtypeui.h
smtpconfigui.cpp
smtpconfigui.h
settingsdialogui.cpp
settingsdialogui.h
statuswidgetui.cpp
statuswidgetui.h
newmaildirui.cpp
newmaildirui.h
sendmailprogressui.cpp
sendmailprogressui.h
selectstoreui.cpp
selectstoreui.h
-
+nntpgroupsui.cpp
+nntpgroupsui.h
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp
index e925d8d..0d636a4 100644
--- a/noncore/net/mail/accountitem.cpp
+++ b/noncore/net/mail/accountitem.cpp
@@ -1,28 +1,29 @@
#include "accountitem.h"
#include "accountview.h"
#include "newmaildir.h"
+#include "nntpgroupsdlg.h"
#include "defines.h"
/* OPIE */
#include <libmailwrapper/mailtypes.h>
#include <libmailwrapper/abstractmail.h>
#include <libmailwrapper/mailwrapper.h>
#include <qpe/qpeapplication.h>
/* QT */
#include <qpopupmenu.h>
#include <qmessagebox.h>
#define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );}
/**
* POP3 Account stuff
*/
POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent )
: AccountViewItem( parent )
{
account = a;
wrapper = AbstractMail::getWrapper( account );
SETPIX(PIXMAP_POP3FOLDER);
#if 0
if (!account->getOffline())
@@ -263,132 +264,144 @@ void NNTPviewItem::refresh()
{
item = new NNTPfolderItem( it, this , item );
item->setSelectable(it->may_select());
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
folders->setAutoDelete(false);
delete folders;
}
RecBody NNTPviewItem::fetchBody( const RecMail &mail )
{
qDebug( "NNTP fetchBody" );
return wrapper->fetchBody( mail );
}
QPopupMenu * NNTPviewItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
{
if (!account->getOffline())
{
m->insertItem(QObject::tr("Disconnect",contextName),0);
m->insertItem(QObject::tr("Set offline",contextName),1);
+ m->insertItem(QObject::tr("(Un-)Subscribe groups",contextName),2);
}
else
{
m->insertItem(QObject::tr("Set online",contextName),1);
}
}
return m;
}
+void NNTPviewItem::subscribeGroups()
+{
+ NNTPGroupsDlg dlg(account);
+ if (QPEApplication::execDialog(&dlg)== QDialog::Accepted ){
+ refresh();
+ }
+}
+
void NNTPviewItem::disconnect()
{
QListViewItem *child = firstChild();
while ( child )
{
QListViewItem *tmp = child;
child = child->nextSibling();
delete tmp;
}
wrapper->logout();
}
void NNTPviewItem::setOnOffline()
{
if (!account->getOffline())
{
disconnect();
}
account->setOffline(!account->getOffline());
account->save();
//FIXME
SETPIX(PIXMAP_POP3FOLDER);
refresh();
}
void NNTPviewItem::contextMenuSelected(int which)
{
switch (which)
{
case 0:
disconnect();
break;
case 1:
setOnOffline();
break;
+ case 2:
+ subscribeGroups();
+ break;
}
}
NNTPfolderItem::~NNTPfolderItem()
{}
NNTPfolderItem::NNTPfolderItem( Folder *folderInit, NNTPviewItem *parent , QListViewItem*after )
: AccountViewItem( parent,after )
{
folder = folderInit;
nntp = parent;
if (folder->getDisplayName().lower()!="inbox")
{
setPixmap( 0, PIXMAP_POP3FOLDER );
}
else
{
setPixmap( 0, PIXMAP_INBOXFOLDER);
}
setText( 0, folder->getDisplayName() );
}
void NNTPfolderItem::refresh(QList<RecMail>&target)
{
if (folder->may_select())
nntp->getWrapper()->listMessages( folder->getName(),target );
}
RecBody NNTPfolderItem::fetchBody(const RecMail&aMail)
{
return nntp->getWrapper()->fetchBody(aMail);
}
QPopupMenu * NNTPfolderItem::getContextMenu()
{
QPopupMenu *m = new QPopupMenu(0);
if (m)
{
m->insertItem(QObject::tr("Refresh header list",contextName),0);
- m->insertItem(QObject::tr("Move/Copie all mails",contextName),1);
+ m->insertItem(QObject::tr("Copy all postings",contextName),1);
}
return m;
}
void NNTPfolderItem::downloadMails()
{
AccountView*bl = nntp->accountView();
if (!bl) return;
bl->downloadMails(folder,nntp->getWrapper());
}
void NNTPfolderItem::contextMenuSelected(int which)
{
AccountView * view = (AccountView*)listView();
switch (which)
{
case 0:
/* must be 'cause pop3 lists are cached */
nntp->getWrapper()->logout();
view->refreshCurrent();
break;
case 1:
downloadMails();
break;
diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h
index a138c9b..f3c0f5d 100644
--- a/noncore/net/mail/accountitem.h
+++ b/noncore/net/mail/accountitem.h
@@ -75,48 +75,49 @@ public:
protected:
void downloadMails();
POP3viewItem *pop3;
};
class NNTPviewItem : public AccountViewItem
{
public:
NNTPviewItem( NNTPaccount *a, AccountView *parent );
virtual ~NNTPviewItem();
virtual void refresh( QList<RecMail> &target );
virtual RecBody fetchBody( const RecMail &mail );
AbstractMail *getWrapper();
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
NNTPaccount *account;
virtual void refresh();
AbstractMail *wrapper;
void disconnect();
void setOnOffline();
+ void subscribeGroups();
};
class NNTPfolderItem : public AccountViewItem
{
public:
NNTPfolderItem( Folder *folder, NNTPviewItem *parent , QListViewItem*after );
virtual ~NNTPfolderItem();
virtual void refresh(QList<RecMail>&);
virtual RecBody fetchBody(const RecMail&);
virtual QPopupMenu * getContextMenu();
virtual void contextMenuSelected(int);
protected:
void downloadMails();
NNTPviewItem *nntp;
};
class IMAPviewItem : public AccountViewItem
{
friend class IMAPfolderItem;
public:
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro
index 7e0de2b..005a839 100644
--- a/noncore/net/mail/mail.pro
+++ b/noncore/net/mail/mail.pro
@@ -1,61 +1,66 @@
CONFIG += qt warn_on debug quick-app
HEADERS = defines.h \
editaccounts.h \
composemail.h \
accountview.h \
accountitem.h \
mainwindow.h \
viewmail.h \
viewmailbase.h \
opiemail.h \
mailistviewitem.h \
settingsdialog.h \
statuswidget.h \
newmaildir.h \
selectstore.h \
- selectsmtp.h
+ selectsmtp.h \
+ nntpgroups.h \
+ nntpgroupsdlg.h
SOURCES = main.cpp \
opiemail.cpp \
mainwindow.cpp \
accountview.cpp \
accountitem.cpp \
composemail.cpp \
addresspicker.cpp \
editaccounts.cpp \
viewmail.cpp \
viewmailbase.cpp \
mailistviewitem.cpp \
settingsdialog.cpp \
statuswidget.cpp \
newmaildir.cpp \
selectstore.cpp \
- selectsmtp.cpp
+ selectsmtp.cpp \
+ nntpgroups.cpp \
+ nntpgroupsdlg.cpp
INTERFACES = editaccountsui.ui \
selectmailtypeui.ui \
imapconfigui.ui \
pop3configui.ui \
nntpconfigui.ui \
smtpconfigui.ui \
addresspickerui.ui \
composemailui.ui \
settingsdialogui.ui \
statuswidgetui.ui \
newmaildirui.ui \
- selectstoreui.ui
+ selectstoreui.ui \
+ nntpgroupsui.ui
INCLUDEPATH += $(OPIEDIR)/include
CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
contains( CONFTEST, y ){
LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2 -lopiedb2 -lmailwrapper -liconv
}else{
LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2 -lopiedb2 -lmailwrapper
}
TARGET = opiemail
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/mail/nntpgroups.cpp b/noncore/net/mail/nntpgroups.cpp
new file mode 100644
index 0000000..97b1985
--- a/dev/null
+++ b/noncore/net/mail/nntpgroups.cpp
@@ -0,0 +1,57 @@
+#include "nntpgroups.h"
+
+#include <libmailwrapper/settings.h>
+
+#include <qlistview.h>
+
+NNTPGroups::NNTPGroups(NNTPaccount *account, QWidget* parent, const char* name, WFlags fl)
+ : NNTPGroupsUI(parent,name,fl),subscribedGroups()
+{
+ m_Account = account;
+ fillGroups();
+}
+
+NNTPGroups::~NNTPGroups()
+{
+
+}
+
+void NNTPGroups::slotGetNG()
+{
+ if (!m_Account) return;
+ GroupListView->clear();
+ NNTPwrapper tmp( m_Account );
+ QStringList list = tmp.listAllNewsgroups();
+ for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
+ QCheckListItem *item;
+ item = new QCheckListItem( GroupListView, (*it), QCheckListItem::CheckBox );
+ if ( subscribedGroups.contains( (*it) ) >= 1 ) {
+ item->setOn( true );
+ }
+ }
+}
+
+void NNTPGroups::fillGroups()
+{
+ if (!m_Account) return;
+ subscribedGroups = m_Account->getGroups();
+ for ( QStringList::Iterator it = subscribedGroups.begin(); it != subscribedGroups.end(); ++it ) {
+ QCheckListItem *item;
+ item = new QCheckListItem( GroupListView, (*it), QCheckListItem::CheckBox );
+ item->setOn( true );
+ }
+}
+
+void NNTPGroups::storeValues()
+{
+ if (!m_Account) return;
+ QListViewItemIterator list_it( GroupListView );
+ subscribedGroups.clear();
+ for ( ; list_it.current(); ++list_it ) {
+ if ( ( (QCheckListItem*)list_it.current() )->isOn() ) {
+ qDebug(list_it.current()->text(0) );
+ subscribedGroups.append( list_it.current()->text(0) );
+ }
+ }
+ m_Account->setGroups( subscribedGroups );
+}
diff --git a/noncore/net/mail/nntpgroups.h b/noncore/net/mail/nntpgroups.h
new file mode 100644
index 0000000..8cc2e8b
--- a/dev/null
+++ b/noncore/net/mail/nntpgroups.h
@@ -0,0 +1,33 @@
+#ifndef __NNTPGROUPS_WINDOW__
+#define __NNTPGROUPS_WINDOW__
+
+#include "nntpgroupsui.h"
+
+#include <libmailwrapper/nntpwrapper.h>
+
+class NNTPaccount;
+class QStringList;
+
+class NNTPGroups:public NNTPGroupsUI
+{
+ Q_OBJECT
+public:
+ NNTPGroups(NNTPaccount *account, QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
+ virtual ~NNTPGroups();
+ /* must be called from external.
+ * it will store the new subscription list into the account
+ * but don't save them, this must be done by the calling class.
+ */
+ void storeValues();
+
+protected slots:
+ virtual void slotGetNG();
+
+protected:
+ virtual void fillGroups();
+
+ NNTPaccount*m_Account;
+ QStringList subscribedGroups;
+};
+
+#endif
diff --git a/noncore/net/mail/nntpgroupsdlg.cpp b/noncore/net/mail/nntpgroupsdlg.cpp
new file mode 100644
index 0000000..752ce3c
--- a/dev/null
+++ b/noncore/net/mail/nntpgroupsdlg.cpp
@@ -0,0 +1,29 @@
+#include "nntpgroupsdlg.h"
+#include "nntpgroups.h"
+
+#include <libmailwrapper/settings.h>
+
+#include <qlayout.h>
+
+NNTPGroupsDlg::NNTPGroupsDlg(NNTPaccount *account,QWidget * parent, const char * name)
+ : QDialog(parent,name,true)
+{
+ setCaption(tr("Subscribed newsgroups"));
+ m_Account = account;
+ QVBoxLayout*dlglayout = new QVBoxLayout(this);
+ dlglayout->setSpacing(2);
+ dlglayout->setMargin(1);
+ groupsWidget = new NNTPGroups(account,this);
+ dlglayout->addWidget(groupsWidget);
+}
+
+NNTPGroupsDlg::~NNTPGroupsDlg()
+{
+}
+
+void NNTPGroupsDlg::accept()
+{
+ groupsWidget->storeValues();
+ m_Account->save();
+ QDialog::accept();
+}
diff --git a/noncore/net/mail/nntpgroupsdlg.h b/noncore/net/mail/nntpgroupsdlg.h
new file mode 100644
index 0000000..a21bac7
--- a/dev/null
+++ b/noncore/net/mail/nntpgroupsdlg.h
@@ -0,0 +1,24 @@
+#ifndef __NNTP_GROUP_DLG_H
+#define __NNTP_GROUP_DLG_H
+
+#include <qdialog.h>
+
+class NNTPGroups;
+class NNTPaccount;
+
+class NNTPGroupsDlg : public QDialog
+{
+ Q_OBJECT
+public:
+ NNTPGroupsDlg(NNTPaccount *account,QWidget * parent=0, const char * name=0);
+ virtual ~NNTPGroupsDlg();
+
+protected:
+ NNTPGroups*groupsWidget;
+ NNTPaccount*m_Account;
+
+protected slots:
+ virtual void accept ();
+};
+
+#endif
diff --git a/noncore/net/mail/nntpgroupsui.ui b/noncore/net/mail/nntpgroupsui.ui
new file mode 100644
index 0000000..93f487b
--- a/dev/null
+++ b/noncore/net/mail/nntpgroupsui.ui
@@ -0,0 +1,88 @@
+<!DOCTYPE UI><UI>
+<class>NNTPGroupsUI</class>
+<widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>NNTPGroupsUI</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>356</width>
+ <height>406</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>newsgroupslist</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>2</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>2</number>
+ </property>
+ <widget>
+ <class>QListView</class>
+ <column>
+ <property>
+ <name>text</name>
+ <string>Newsgroups</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>GroupListView</cstring>
+ </property>
+ <property>
+ <name>whatsThis</name>
+ <string>List of groups from the server. On start, only subscribed groups are listed.</string>
+ </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>
+ <property>
+ <name>whatsThis</name>
+ <string>Retrieve the list of groups from server</string>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>GetNGButton</sender>
+ <signal>clicked()</signal>
+ <receiver>NNTPGroupsUI</receiver>
+ <slot>slotGetNG()</slot>
+ </connection>
+ <slot access="protected">slotGetNG()</slot>
+</connections>
+</UI>