french -> French
[kdepim.git] / knode / kngroupmanager.h
blobe90d5b73ed25ebb5d62f8cf86eb137ad48b05396
1 /*
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
18 #include "kngroup.h"
19 #include "knjobdata.h"
20 #include "knnntpaccount.h"
22 #include <QObject>
23 #include <qlist.h>
25 class KNArticleManager;
26 class KNCleanUp;
29 //=================================================================================
31 /** Helper classes for the group selection dialog,
32 contains info about a newsgroup (name, description) */
34 class KNGroupInfo {
36 public:
38 KNGroupInfo();
39 KNGroupInfo(const QString &n_ame, const QString &d_escription, bool n_ewGroup=false, bool s_ubscribed=false, KNGroup::Status s_tatus=KNGroup::unknown );
40 ~KNGroupInfo();
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 {
55 public:
56 /**
57 Shared pointer to a KNGroupListData. To be used instead of raw KNGroupListData*.
59 typedef boost::shared_ptr<KNGroupListData> Ptr;
61 KNGroupListData();
62 ~KNGroupListData();
64 bool readIn(KNJobData *job=0);
65 bool writeOut();
66 void merge(QList<KNGroupInfo>* newGroups);
68 QList<KNGroupInfo>* extractList();
70 QStringList subscribed;
71 QString path;
72 QList<KNGroupInfo> *groups;
73 QDate fetchSince;
74 bool getDescriptions;
75 QTextCodec *codecForDescriptions;
79 //===============================================================================
82 /** Group manager. */
83 class KNGroupManager : public QObject , public KNJobConsumer {
85 Q_OBJECT
87 public:
89 explicit KNGroupManager( QObject * parent = 0 );
90 ~KNGroupManager();
92 // group access
93 void loadGroups( KNNntpAccount::Ptr a );
94 void getSubscribed( KNNntpAccount::Ptr a, QStringList &l );
95 /**
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 );
115 // group handling
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
130 * whose id is @p id.
132 void checkAll( int id, bool silent = false );
134 void expireAll(KNCleanUp *cup);
135 void expireAll( KNNntpAccount::Ptr a );
136 void syncGroups();
138 public slots:
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 );
146 protected:
147 /** Reimplemented from KNJobConsumer */
148 void processJob(KNJobData *j);
149 KNGroup::List mGroupList;
150 KNGroup::Ptr c_urrentGroup;
151 KNArticleManager *a_rticleMgr;
153 signals:
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 );
173 #endif