1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
/*
KNode, the KDE newsreader
Copyright (c) 1999-2005 the KNode authors.
See file AUTHORS for details
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
*/
#include <ksimpleconfig.h>
#include <kstandarddirs.h>
#include <kdebug.h>
#include "utilities.h"
#include "kncollectionviewitem.h"
#include "knnntpaccount.h"
#include "knconfig.h"
#include "knconfigmanager.h"
#include "knconfigwidgets.h"
#include "kngroupmanager.h"
#include "knglobals.h"
KNNntpAccountIntervalChecking::KNNntpAccountIntervalChecking(KNNntpAccount* account) : t_imer(0) {
a_ccount = account;
}
KNNntpAccountIntervalChecking::~KNNntpAccountIntervalChecking()
{
if (t_imer) deinstallTimer();
a_ccount = 0;
}
void KNNntpAccountIntervalChecking::installTimer()
{
if (a_ccount->checkInterval() <= 0) return;
if(!t_imer)
{
t_imer = new TQTimer();
connect(t_imer,TQT_SIGNAL(timeout()),this,TQT_SLOT(slotCheckNews()));
}
else
{
t_imer->stop();
}
t_imer->start(a_ccount->checkInterval()*60000);
}
void KNNntpAccountIntervalChecking::deinstallTimer()
{
delete t_imer;
t_imer = 0;
}
void KNNntpAccountIntervalChecking::slotCheckNews()
{
knGlobals.groupManager()->checkAll(a_ccount, true);
}
KNNntpAccount::KNNntpAccount()
: KNCollection(0), KNServerInfo(), i_dentity(0), f_etchDescriptions(true), w_asOpen(false), i_ntervalChecking(false), c_heckInterval(10)
{
l_astNewFetch = TQDate::tqcurrentDate();
a_ccountIntervalChecking = new KNNntpAccountIntervalChecking(this);
mCleanupConf = new KNConfig::Cleanup( false );
}
KNNntpAccount::~KNNntpAccount()
{
delete a_ccountIntervalChecking;
delete i_dentity;
delete mCleanupConf;
}
// tries to read information, returns false if it fails to do so
bool KNNntpAccount::readInfo(const TQString &confPath)
{
KSimpleConfig conf(confPath);
n_ame = conf.readEntry("name");
//u_nsentCount = conf.readNumEntry("unsentCnt", 0);
f_etchDescriptions = conf.readBoolEntry("fetchDescriptions", true);
l_astNewFetch = conf.readDateTimeEntry("lastNewFetch").date();
w_asOpen = conf.readBoolEntry("listItemOpen", false);
u_seDiskCache = conf.readBoolEntry("useDiskCache", false);
i_ntervalChecking=conf.readBoolEntry("intervalChecking", false);
c_heckInterval=conf.readNumEntry("checkInterval", 10);
KNServerInfo::readConf(&conf);
startTimer();
i_dentity=new KNConfig::Identity(false);
i_dentity->loadConfig(&conf);
if(!i_dentity->isEmpty()) {
kdDebug(5003) << "KNGroup::readInfo(const TQString &confPath) : using alternative user for " << n_ame << endl;
} else {
delete i_dentity;
i_dentity=0;
}
mCleanupConf->loadConfig( &conf );
if (n_ame.isEmpty() || s_erver.isEmpty() || i_d == -1)
return false;
else
return true;
}
void KNNntpAccount::saveInfo()
{
TQString dir(path());
if (dir.isNull())
return;
KSimpleConfig conf(dir+"info");
conf.writeEntry("name", n_ame);
//conf.writeEntry("unsentCnt", u_nsentCount);
conf.writeEntry("fetchDescriptions", f_etchDescriptions);
conf.writeEntry("lastNewFetch", TQDateTime(l_astNewFetch));
if(l_istItem)
conf.writeEntry("listItemOpen", l_istItem->isOpen());
conf.writeEntry("useDiskCache", u_seDiskCache);
conf.writeEntry("intervalChecking", i_ntervalChecking);
conf.writeEntry("checkInterval", c_heckInterval);
KNServerInfo::saveConf(&conf); // save not KNNntpAccount specific settings
if(i_dentity)
i_dentity->saveConfig(&conf);
else if(conf.hasKey("Email")) {
conf.deleteEntry("Name", false);
conf.deleteEntry("Email", false);
conf.deleteEntry("Reply-To", false);
conf.deleteEntry("Mail-Copies-To", false);
conf.deleteEntry("Org", false);
conf.deleteEntry("UseSigFile", false);
conf.deleteEntry("UseSigGenerator", false);
conf.deleteEntry("sigFile", false);
conf.deleteEntry("sigText", false);
}
mCleanupConf->saveConfig( &conf );
}
/*void KNNntpAccount::syncInfo()
{
TQString dir(path());
if (dir.isNull())
return;
KSimpleConfig conf(dir+"info");
conf.writeEntry("unsentCnt", u_nsentCount);
}*/
TQString KNNntpAccount::path()
{
TQString dir(locateLocal("data","knode/")+TQString("nntp.%1/").tqarg(i_d));
if (dir.isNull())
KNHelper::displayInternalFileError();
return (dir);
}
bool KNNntpAccount::editProperties(TQWidget *tqparent)
{
if(!i_dentity) i_dentity=new KNConfig::Identity(false);
KNConfig::NntpAccountConfDialog *d = new KNConfig::NntpAccountConfDialog(this, tqparent);
bool ret=false;
if (d->exec()) {
updateListItem();
ret=true;
}
if(i_dentity->isEmpty()) {
delete i_dentity;
i_dentity=0;
}
delete d;
return ret;
}
void KNNntpAccount::startTimer()
{
if ( (i_ntervalChecking == true) && (c_heckInterval > 0) )
{
a_ccountIntervalChecking->installTimer();
}
else
{
a_ccountIntervalChecking->deinstallTimer();
}
}
void KNNntpAccount::setCheckInterval(int c)
{
c_heckInterval = c;
startTimer();
}
KNConfig::Cleanup *KNNntpAccount::activeCleanupConfig() const
{
if (cleanupConfig()->useDefault())
return knGlobals.configManager()->cleanup();
return cleanupConfig();
}
#include "knnntpaccount.moc"
|