french -> French
[kdepim.git] / knode / kngroup.h
blob5fc5db6566d3bf859d46867f2ad9a7ef25e6da14
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 KNGROUP_H
16 #define KNGROUP_H
18 #include "configuration/settings_container_interface.h"
19 #include "knarticle.h"
20 #include "knarticlecollection.h"
21 #include "knjobdata.h"
22 #include "knglobals.h"
23 #include "knnntpaccount.h"
25 #include <kio/job.h>
26 #include <KPIMIdentities/Identity>
27 #include <QByteArray>
28 #include <QList>
30 namespace KNode {
31 class Cleanup;
35 /** Representation of a news group. This class contains:
36 * - Static information about a news group (eg. the name and account)
37 * - Dynamic information about a news group (eg. article serial numbers)
38 * - Group specific settings (eg. identities or cleanup settings)
39 * - Load and store methods for the header list of this group
41 class KNGroup : public KNArticleCollection , public KNJobItem, public KNode::SettingsContainerInterface
43 public:
44 /**
45 Shared pointer to a KNGroup. To be used instead of raw KNGroup*.
47 typedef boost::shared_ptr<KNGroup> Ptr;
49 /** The posting rights status of this group. */
50 enum Status { unknown=0, readOnly=1, postingAllowed=2, moderated=3 };
52 explicit KNGroup( KNCollection::Ptr p = KNCollection::Ptr() );
53 ~KNGroup();
55 /// List of groups.
56 typedef QList<KNGroup::Ptr> List;
58 /** type */
59 collectionType type() { return CTgroup; }
61 /** list-item handling */
62 void updateListItem();
64 /** info */
65 QString path();
66 bool readInfo(const QString &confPath);
67 void writeConfig();
69 /** name */
70 bool hasName() const { return (!n_ame.isEmpty()); }
71 const QString& name();
72 const QString& groupname() { return g_roupname; }
73 void setGroupname(const QString &s) { g_roupname=s; }
74 /** Returns the group description. */
75 QString description() const { return d_escription; }
76 /** Sets the group description.
77 * @param s The group description.
79 void setDescription( const QString &s ) { d_escription = s; }
81 /** count + numbers */
82 int newCount() const { return n_ewCount; }
83 void setNewCount(int i) { n_ewCount=i; }
84 void incNewCount(int i=1) { n_ewCount+=i; }
85 void decNewCount(int i=1) { n_ewCount-=i; }
86 int firstNewIndex() const { return f_irstNew; }
87 void setFirstNewIndex(int i) { f_irstNew=i; }
89 int lastFetchCount() const { return l_astFetchCount; }
90 void setLastFetchCount(int i) { l_astFetchCount=i; }
92 int readCount()const { return r_eadCount; }
93 void setReadCount(int i) { r_eadCount=i; }
94 void incReadCount(int i=1) { r_eadCount+=i; }
95 void decReadCount(int i=1) { r_eadCount-=i; }
97 /** Returns the smallest available article serial number in this group. */
98 int firstNr() const { return f_irstNr; }
99 /** Sets the smallest available serial number.
100 * @param i The serial number.
102 void setFirstNr( int i ) { f_irstNr = i; }
103 /** Returns the largest used article serial number in this group. */
104 int lastNr() const { return l_astNr; }
105 /** Sets the largest used serial number.
106 * @param i The serial number.
108 void setLastNr( int i ) { l_astNr = i; }
109 /** Returns the maximal number of articles to download from the server. */
110 int maxFetch() const { return m_axFetch; }
111 /** Sets the maximal number of articles to download from the server.
112 * @param i The maximal number of articles to download.
114 void setMaxFetch( int i ) { m_axFetch = i; }
116 int statThrWithNew();
117 int statThrWithUnread();
119 // article access
120 KNRemoteArticle::Ptr at( int i )
121 { return boost::static_pointer_cast<KNRemoteArticle>( KNArticleCollection::at( i ) ); }
122 KNRemoteArticle::Ptr byId( int id )
123 { return boost::static_pointer_cast<KNRemoteArticle>( KNArticleCollection::byId( id ) ); }
124 KNRemoteArticle::Ptr byMessageId( const QByteArray &mId )
125 { return boost::static_pointer_cast<KNRemoteArticle>( KNArticleCollection::byMessageId( mId ) ); }
127 /** Load the stored headers from disk. */
128 bool loadHdrs();
129 bool unloadHdrs(bool force=true);
130 /** Insert headers of new articles into this group, and then sort */
131 void insortNewHeaders( const KIO::UDSEntryList &list, KNJobData *job = 0 );
132 int saveStaticData(int cnt,bool ovr=false);
133 void saveDynamicData(int cnt,bool ovr=false);
134 void syncDynamicData();
136 /** mark articles with this id as read when we later load the headers / fetch new articles */
137 void appendXPostID(const QString &id);
138 void processXPostBuffer(bool deleteAfterwards);
140 /** article handling */
141 void updateThreadInfo();
142 void reorganize();
143 void scoreArticles(bool onlynew=true);
145 /** locking */
146 bool isLocked() { return l_ocked; }
147 void setLocked(bool l) { l_ocked=l; }
149 QString prepareForExecution();
151 /** Returns the default charset for this group. */
152 const QByteArray defaultCharset() { return d_efaultChSet; }
153 /** Sets the default charset for this group.
154 * @param s The new default charset.
156 void setDefaultCharset( const QByteArray &s ) { d_efaultChSet = s; }
157 bool useCharset() { return ( u_seCharset && !d_efaultChSet.isEmpty() ); }
158 void setUseCharset(bool b) { u_seCharset=b; }
160 /** Returns the account this group belongs to. */
161 KNNntpAccount::Ptr account();
164 Returns the identity configured for this group.
165 It is the null identity if there is none.
167 virtual const KPIMIdentities::Identity & identity() const;
168 /** Sets the identity for this group.
169 * @param i The identity or a null Identity to unset it.
171 virtual void setIdentity( const KPIMIdentities::Identity &i )
172 { mIdentityUoid = ( i.isNull() ? -1 : i.uoid() ); }
174 /** Returns the posting rights of this group.
176 Status status() const { return s_tatus; }
177 /** Sets the posting rights for this group.
178 * @param s The new posting rights.
180 void setStatus(Status s) { s_tatus = s; }
181 /** Shows the group properties dialog.
182 * @see KNGroupPropDlg
184 void showProperties();
186 /** Returns the cleanup configuration of this group (might be empty). */
187 KNode::Cleanup *cleanupConfig() const { return mCleanupConf; }
188 /** Returns the active cleanup configuration of this group, ie. the
189 * "lowest" available cleanup configuration.
191 KNode::Cleanup *activeCleanupConfig();
194 protected:
195 void buildThreads(int cnt, KNJobData *parent=0);
197 Returns the first message that appears in the References header of @p a
198 and which exists in this group.
200 KNRemoteArticle::Ptr findReference( KNRemoteArticle::Ptr a );
202 int n_ewCount,
203 l_astFetchCount,
204 r_eadCount,
205 i_gnoreCount,
206 f_irstNr,
207 l_astNr,
208 m_axFetch,
209 d_ynDataFormat,
210 f_irstNew;
212 /// The default charset of this group.
213 QByteArray d_efaultChSet;
214 QString g_roupname,
215 d_escription;
217 bool l_ocked,
218 u_seCharset;
220 Status s_tatus;
222 QStringList c_rosspostIDBuffer;
224 /** Optional headers provided by the XOVER command.
225 * These headers will be saved within the static data.
227 QList<QByteArray> mOptionalHeaders;
230 Unique object identifier of the identity of this group.
231 -1 means there is no specific identity for this group
232 (because KPIMIdentities::Identity::uoid() returns an unsigned int.
234 int mIdentityUoid;
236 KNode::Cleanup *mCleanupConf;
238 class dynDataVer0 {
240 public:
241 dynDataVer0() { id=-1; idRef=-1; read=0; thrLevel=0; score=50; }
242 ~dynDataVer0() {}
243 void setData( KNRemoteArticle::Ptr a );
244 void getData( KNRemoteArticle::Ptr a );
246 int id;
247 int idRef;
248 bool read;
249 short thrLevel, score;
252 class dynDataVer1 {
254 public:
255 dynDataVer1() { id=-1; idRef=-1; read=0; thrLevel=0; score=0, ignoredWatched=0; }
256 void setData( KNRemoteArticle::Ptr a );
257 void getData( KNRemoteArticle::Ptr a );
259 int id;
260 int idRef;
261 bool read;
262 short thrLevel, score;
263 char ignoredWatched;
267 * Returns a shared pointer pointing to this group.
269 KNGroup::Ptr thisGroupPtr();
272 * Reimplemented from KNArticleCollection::selfPtr().
274 virtual KNCollection::Ptr selfPtr()
276 return thisGroupPtr();
281 #endif
283 // kate: space-indent on; indent-width 2;