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
16 #include <kstandarddirs.h>
19 #include "utilities.h"
20 #include "kncollectionviewitem.h"
21 #include "knnntpaccount.h"
23 #include "knconfigmanager.h"
24 #include "knconfigwidgets.h"
25 #include "kngroupmanager.h"
26 #include "knglobals.h"
29 KNNntpAccountIntervalChecking::KNNntpAccountIntervalChecking(KNNntpAccount
* account
) : t_imer(0) {
35 KNNntpAccountIntervalChecking::~KNNntpAccountIntervalChecking()
37 if (t_imer
) deinstallTimer();
43 void KNNntpAccountIntervalChecking::installTimer()
45 if (a_ccount
->checkInterval() <= 0) return;
48 t_imer
= new QTimer();
49 connect(t_imer
,SIGNAL(timeout()),this,SLOT(slotCheckNews()));
55 t_imer
->start(a_ccount
->checkInterval()*60000);
60 void KNNntpAccountIntervalChecking::deinstallTimer()
68 void KNNntpAccountIntervalChecking::slotCheckNews()
70 knGlobals
.groupManager()->checkAll(a_ccount
, true);
75 KNNntpAccount::KNNntpAccount()
76 : KNCollection(0), KNServerInfo(), i_dentity(0), f_etchDescriptions(true), w_asOpen(false), i_ntervalChecking(false), c_heckInterval(10)
78 l_astNewFetch
= QDate::currentDate();
79 a_ccountIntervalChecking
= new KNNntpAccountIntervalChecking(this);
80 mCleanupConf
= new KNode::Cleanup( false );
84 KNNntpAccount::~KNNntpAccount()
86 delete a_ccountIntervalChecking
;
92 // tries to read information, returns false if it fails to do so
93 bool KNNntpAccount::readInfo(const QString
&confPath
)
95 KConfigGroup
conf( KSharedConfig::openConfig(confPath
, KConfig::SimpleConfig
), QString() );
97 n_ame
= conf
.readEntry("name");
98 //u_nsentCount = conf.readEntry("unsentCnt", 0);
99 f_etchDescriptions
= conf
.readEntry("fetchDescriptions", true);
100 l_astNewFetch
= conf
.readEntry("lastNewFetch", QDateTime() ).date();
101 w_asOpen
= conf
.readEntry("listItemOpen", false);
102 u_seDiskCache
= conf
.readEntry("useDiskCache", false);
103 i_ntervalChecking
=conf
.readEntry("intervalChecking", false);
104 c_heckInterval
=conf
.readEntry("checkInterval", 10);
105 KNServerInfo::readConf(conf
);
109 i_dentity
=new KNode::Identity(false);
110 i_dentity
->loadConfig(conf
);
111 if(!i_dentity
->isEmpty()) {
112 kDebug(5003) <<"KNGroup::readInfo(const QString &confPath) : using alternative user for" << n_ame
;
118 mCleanupConf
->loadConfig( conf
);
120 if (n_ame
.isEmpty() || s_erver
.isEmpty() || i_d
== -1)
127 void KNNntpAccount::saveInfo()
133 KConfigGroup
conf(KSharedConfig::openConfig( dir
+"info", KConfig::SimpleConfig
), QString() );
135 conf
.writeEntry("name", n_ame
);
136 //conf.writeEntry("unsentCnt", u_nsentCount);
137 conf
.writeEntry("fetchDescriptions", f_etchDescriptions
);
138 conf
.writeEntry("lastNewFetch", QDateTime(l_astNewFetch
));
140 conf
.writeEntry("listItemOpen", l_istItem
->isExpanded());
141 conf
.writeEntry("useDiskCache", u_seDiskCache
);
142 conf
.writeEntry("intervalChecking", i_ntervalChecking
);
143 conf
.writeEntry("checkInterval", c_heckInterval
);
145 KNServerInfo::saveConf(conf
); // save not KNNntpAccount specific settings
148 i_dentity
->saveConfig(conf
);
149 else if(conf
.hasKey("Email")) {
150 conf
.deleteEntry("Name", false);
151 conf
.deleteEntry("Email", false);
152 conf
.deleteEntry("Reply-To", false);
153 conf
.deleteEntry("Mail-Copies-To", false);
154 conf
.deleteEntry("Org", false);
155 conf
.deleteEntry("UseSigFile", false);
156 conf
.deleteEntry("UseSigGenerator", false);
157 conf
.deleteEntry("sigFile", false);
158 conf
.deleteEntry("sigText", false);
161 mCleanupConf
->saveConfig( conf
);
165 /*void KNNntpAccount::syncInfo()
170 KSimpleConfig conf(dir+"info");
171 conf.writeEntry("unsentCnt", u_nsentCount);
175 QString
KNNntpAccount::path()
177 QString
dir( KStandardDirs::locateLocal( "data", QString( "knode/nntp.%1/" ).arg( i_d
) ) );
179 KNHelper::displayInternalFileError();
184 bool KNNntpAccount::editProperties(QWidget
*parent
)
186 if(!i_dentity
) i_dentity
=new KNode::Identity(false);
187 KNode::NntpAccountConfDialog
*d
= new KNode::NntpAccountConfDialog(this, parent
);
195 if(i_dentity
->isEmpty()) {
204 void KNNntpAccount::startTimer()
206 if ( (i_ntervalChecking
== true) && (c_heckInterval
> 0) )
208 a_ccountIntervalChecking
->installTimer();
212 a_ccountIntervalChecking
->deinstallTimer();
216 void KNNntpAccount::setCheckInterval(int c
)
222 KNode::Cleanup
*KNNntpAccount::activeCleanupConfig() const
224 if (cleanupConfig()->useDefault())
225 return knGlobals
.configManager()->cleanup();
226 return cleanupConfig();
229 #include "knnntpaccount.moc"