2 KNode, the KDE newsreader
3 Copyright (c) 1999-2005 the KNode authors.
4 See file AUTHORS for details
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 You should have received a copy of the GNU General Public License
11 along with this program; if not, write to the Free Software Foundation,
12 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
15 #ifndef KNGROUPMANAGER_H
16 #define KNGROUPMANAGER_H
19 #include "knjobdata.h"
20 #include "knnntpaccount.h"
25 class KNArticleManager
;
29 //=================================================================================
31 /** Helper classes for the group selection dialog,
32 contains info about a newsgroup (name, description) */
39 KNGroupInfo(const QString
&n_ame
, const QString
&d_escription
, bool n_ewGroup
=false, bool s_ubscribed
=false, KNGroup::Status s_tatus
=KNGroup::unknown
);
42 /** group names will be utf-8 encoded in the future... */
43 QString name
,description
;
44 bool newGroup
, subscribed
;
45 KNGroup::Status status
;
47 bool operator== (const KNGroupInfo
&gi2
) const;
48 bool operator< (const KNGroupInfo
&gi2
) const;
52 /** Data of group list jobs. */
53 class KNGroupListData
: public KNJobItem
{
57 Shared pointer to a KNGroupListData. To be used instead of raw KNGroupListData*.
59 typedef boost::shared_ptr
<KNGroupListData
> Ptr
;
64 bool readIn(KNJobData
*job
=0);
66 void merge(QList
<KNGroupInfo
>* newGroups
);
68 QList
<KNGroupInfo
>* extractList();
70 QStringList subscribed
;
72 QList
<KNGroupInfo
> *groups
;
75 QTextCodec
*codecForDescriptions
;
79 //===============================================================================
83 class KNGroupManager
: public QObject
, public KNJobConsumer
{
89 explicit KNGroupManager( QObject
* parent
= 0 );
93 void loadGroups( KNNntpAccount::Ptr a
);
94 void getSubscribed( KNNntpAccount::Ptr a
, QStringList
&l
);
96 * Returns the list of (subscribed) groups in the account @p a.
98 KNGroup::List
groupsOfAccount( KNNntpAccount::Ptr a
);
100 bool loadHeaders( KNGroup::Ptr g
);
101 bool unloadHeaders( KNGroup::Ptr g
, bool force
= true );
104 * Returns a group named @p gName in the server @p s, or null if none is found.
106 KNGroup::Ptr
group( const QString
&gName
, const KNServerInfo::Ptr s
);
108 * Returns the first group in the server @p s, or null if it is empty.
110 KNGroup::Ptr
firstGroupOfAccount( const KNServerInfo::Ptr s
);
111 KNGroup::Ptr
currentGroup() const { return c_urrentGroup
; }
112 bool hasCurrentGroup() const { return (c_urrentGroup
!=0); }
113 void setCurrentGroup( KNGroup::Ptr g
);
116 void showGroupDialog( KNNntpAccount::Ptr a
, QWidget
*parent
= 0 );
117 void subscribeGroup( const KNGroupInfo
*gi
, KNNntpAccount::Ptr a
);
118 bool unsubscribeGroup( KNGroup::Ptr g
= KNGroup::Ptr() );
120 * Shows the property dialog of @p g or if null, the properties of the currentGroup().
122 void showGroupProperties( KNGroup::Ptr g
= KNGroup::Ptr() );
123 void expireGroupNow( KNGroup::Ptr g
= KNGroup::Ptr() );
124 void reorganizeGroup( KNGroup::Ptr g
= KNGroup::Ptr() );
126 void checkGroupForNewHeaders( KNGroup::Ptr g
= KNGroup::Ptr() );
127 void checkAll( KNNntpAccount::Ptr a
, bool silent
= false );
129 * Convenient method to call checkAll(KNNntpAccount::Ptr,bool) with the account
132 void checkAll( int id
, bool silent
= false );
134 void expireAll(KNCleanUp
*cup
);
135 void expireAll( KNNntpAccount::Ptr a
);
139 /** load group list from disk (if this fails: ask user if we should fetch the list) */
140 void slotLoadGroupList( KNNntpAccount::Ptr a
);
141 /** fetch group list from server */
142 void slotFetchGroupList( KNNntpAccount::Ptr a
);
143 /** check for new groups (created after the given date) */
144 void slotCheckForNewGroups( KNNntpAccount::Ptr a
, QDate date
);
147 /** Reimplemented from KNJobConsumer */
148 void processJob(KNJobData
*j
);
149 KNGroup::List mGroupList
;
150 KNGroup::Ptr c_urrentGroup
;
151 KNArticleManager
*a_rticleMgr
;
154 void newListReady( KNGroupListData::Ptr d
);
157 * Emitted when a group is added.
159 void groupAdded( KNGroup::Ptr g
);
161 * Emitted when a group is removed.
163 void groupRemoved( KNGroup::Ptr g
);
165 * Emitted when a group is updated.
167 void groupUpdated( KNGroup::Ptr g
);