• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

knode

  • sources
  • kde-4.12
  • kdepim
  • knode
knnntpaccount.cpp
Go to the documentation of this file.
1 /*
2  KNode, the KDE newsreader
3  Copyright (c) 1999-2005 the KNode authors.
4  See file AUTHORS for details
5 
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
13 */
14 
15 #include "knnntpaccount.h"
16 
17 #include "utilities.h"
18 #include "kncollectionviewitem.h"
19 #include "knconfigmanager.h"
20 #include "knconfigwidgets.h"
21 #include "kngroupmanager.h"
22 #include "knglobals.h"
23 #include "knaccountmanager.h"
24 
25 #include <QTimer>
26 #include <kconfig.h>
27 #include <kdebug.h>
28 #include <KPIMIdentities/Identity>
29 #include <KPIMIdentities/IdentityManager>
30 #include <kstandarddirs.h>
31 
32 
33 KNNntpAccountIntervalChecking::KNNntpAccountIntervalChecking(KNNntpAccount* account) : t_imer(0) {
34  a_ccount = account;
35 }
36 
37 
38 
39 KNNntpAccountIntervalChecking::~KNNntpAccountIntervalChecking()
40 {
41  if (t_imer) deinstallTimer();
42  a_ccount = 0;
43 }
44 
45 
46 
47 void KNNntpAccountIntervalChecking::installTimer()
48 {
49  if (a_ccount->checkInterval() <= 0) return;
50  if(!t_imer)
51  {
52  t_imer = new QTimer();
53  connect(t_imer,SIGNAL(timeout()),this,SLOT(slotCheckNews()));
54  }
55  else
56  {
57  t_imer->stop();
58  }
59  t_imer->start(a_ccount->checkInterval()*60000);
60 }
61 
62 
63 
64 void KNNntpAccountIntervalChecking::deinstallTimer()
65 {
66  delete t_imer;
67  t_imer = 0;
68 }
69 
70 
71 
72 void KNNntpAccountIntervalChecking::slotCheckNews()
73 {
74  knGlobals.groupManager()->checkAll( a_ccount->id(), true );
75 }
76 
77 
78 
79 KNNntpAccount::KNNntpAccount()
80  : KNCollection( KNCollection::Ptr() ), KNServerInfo(),
81  mIdentityUoid( -1 ),
82  f_etchDescriptions(true), w_asOpen(false), i_ntervalChecking(false), c_heckInterval(10)
83 {
84  l_astNewFetch = QDate::currentDate();
85  a_ccountIntervalChecking = new KNNntpAccountIntervalChecking(this);
86  mCleanupConf = new KNode::Cleanup( false );
87 }
88 
89 
90 KNNntpAccount::~KNNntpAccount()
91 {
92  delete a_ccountIntervalChecking;
93  delete mCleanupConf;
94 }
95 
96 
97 // tries to read information, returns false if it fails to do so
98 bool KNNntpAccount::readInfo(const QString &confPath)
99 {
100  KConfigGroup conf( KSharedConfig::openConfig(confPath, KConfig::SimpleConfig), QString() );
101 
102  n_ame = conf.readEntry("name");
103  //u_nsentCount = conf.readEntry("unsentCnt", 0);
104  f_etchDescriptions = conf.readEntry("fetchDescriptions", true);
105  l_astNewFetch = conf.readEntry("lastNewFetch", QDateTime() ).date();
106  w_asOpen = conf.readEntry("listItemOpen", false);
107  u_seDiskCache = conf.readEntry("useDiskCache", false);
108  i_ntervalChecking=conf.readEntry("intervalChecking", false);
109  c_heckInterval=conf.readEntry("checkInterval", 10);
110  KNServerInfo::readConf(conf);
111 
112  mIdentityUoid = conf.readEntry( "identity", -1 );
113 
114  startTimer();
115 
116  mCleanupConf->loadConfig( conf );
117 
118  if (n_ame.isEmpty() || s_erver.isEmpty() || i_d == -1)
119  return false;
120  else
121  return true;
122 }
123 
124 
125 void KNNntpAccount::writeConfig()
126 {
127  QString dir(path());
128  if (dir.isNull())
129  return;
130 
131  KConfigGroup conf(KSharedConfig::openConfig( dir+"info", KConfig::SimpleConfig), QString() );
132 
133  conf.writeEntry("name", n_ame);
134  //conf.writeEntry("unsentCnt", u_nsentCount);
135  conf.writeEntry("fetchDescriptions", f_etchDescriptions);
136  conf.writeEntry("lastNewFetch", QDateTime(l_astNewFetch));
137  if(l_istItem)
138  conf.writeEntry("listItemOpen", l_istItem->isExpanded());
139  conf.writeEntry("useDiskCache", u_seDiskCache);
140  conf.writeEntry("intervalChecking", i_ntervalChecking);
141  conf.writeEntry("checkInterval", c_heckInterval);
142  conf.writeEntry( "identity", mIdentityUoid );
143 
144  KNServerInfo::saveConf(conf); // save not KNNntpAccount specific settings
145 
146  mCleanupConf->saveConfig( conf );
147 }
148 
149 
150 /*void KNNntpAccount::syncInfo()
151 {
152  QString dir(path());
153  if (dir.isNull())
154  return;
155  KSimpleConfig conf(dir+"info");
156  conf.writeEntry("unsentCnt", u_nsentCount);
157 }*/
158 
159 
160 QString KNNntpAccount::path()
161 {
162  if ( i_d == -1 ) {
163  return QString();
164  }
165 
166  QString dir( KStandardDirs::locateLocal( "data", QString( "knode/nntp.%1/" ).arg( i_d ) ) );
167  if (dir.isNull())
168  KNHelper::displayInternalFileError();
169  return (dir);
170 }
171 
172 
173 bool KNNntpAccount::editProperties(QWidget *parent)
174 {
175  KNode::NntpAccountConfDialog *d = new KNode::NntpAccountConfDialog(this, parent);
176 
177  bool ret=false;
178  if (d->exec()) {
179  updateListItem();
180  ret=true;
181  }
182 
183  delete d;
184  return ret;
185 }
186 
187 void KNNntpAccount::startTimer()
188 {
189  if ( (i_ntervalChecking == true) && (c_heckInterval > 0) )
190  {
191  a_ccountIntervalChecking->installTimer();
192  }
193  else
194  {
195  a_ccountIntervalChecking->deinstallTimer();
196  }
197 }
198 
199 void KNNntpAccount::setCheckInterval(int c)
200 {
201  c_heckInterval = c;
202  startTimer();
203 }
204 
205 KNode::Cleanup *KNNntpAccount::activeCleanupConfig() const
206 {
207  if (cleanupConfig()->useDefault())
208  return knGlobals.configManager()->cleanup();
209  return cleanupConfig();
210 }
211 
212 
213 const KPIMIdentities::Identity & KNNntpAccount::identity() const
214 {
215  if ( mIdentityUoid < 0 ) {
216  return KPIMIdentities::Identity::null();
217  }
218  return KNGlobals::self()->identityManager()->identityForUoid( mIdentityUoid );
219 }
220 
221 void KNNntpAccount::setIdentity( const KPIMIdentities::Identity &identity )
222 {
223  mIdentityUoid = ( identity.isNull() ? -1 : identity.uoid() );
224 }
225 
226 
227 KNCollection::Ptr KNNntpAccount::selfPtr()
228 {
229  return KNGlobals::self()->accountManager()->account( id() );
230 }
231 
232 
233 #include "knnntpaccount.moc"
KNNntpAccount
Represents an account on a news server.
Definition: knnntpaccount.h:56
KNServerInfo::readConf
void readConf(KConfigGroup &conf)
Definition: knserverinfo.cpp:45
KNNntpAccountIntervalChecking::KNNntpAccountIntervalChecking
KNNntpAccountIntervalChecking(KNNntpAccount *account)
Definition: knnntpaccount.cpp:33
utilities.h
KNNntpAccount::activeCleanupConfig
KNode::Cleanup * activeCleanupConfig() const
Returns the cleanup configuration that should be used for this account.
Definition: knnntpaccount.cpp:205
KNode::Cleanup::saveConfig
void saveConfig(KConfigGroup &conf)
Definition: knconfig.cpp:252
KNNntpAccount::c_heckInterval
int c_heckInterval
Definition: knnntpaccount.h:134
QWidget
knconfigwidgets.h
KNNntpAccount::w_asOpen
bool w_asOpen
was the server open in the listview on the last shutdown?
Definition: knnntpaccount.h:129
knaccountmanager.h
KNNntpAccountIntervalChecking::~KNNntpAccountIntervalChecking
~KNNntpAccountIntervalChecking()
Definition: knnntpaccount.cpp:39
KNNntpAccount::writeConfig
void writeConfig()
Save the configuration to disk.
Definition: knnntpaccount.cpp:125
KNGlobals::self
static KNGlobals * self()
Return the KNGlobals instance.
Definition: knglobals.cpp:72
kngroupmanager.h
KNode::Cleanup
Expirery/cleaup settings (globally or per account/group/folder).
Definition: knconfig.h:132
KNNntpAccount::path
QString path()
Definition: knnntpaccount.cpp:160
KNode::NntpAccountConfDialog
News server configuration dialog.
Definition: knconfigwidgets.h:116
KNCollection::updateListItem
virtual void updateListItem()
Updates the listview item after the collection has changed.
Definition: kncollection.cpp:45
knnntpaccount.h
KNNntpAccount::l_astNewFetch
QDate l_astNewFetch
last use of "newgroups"
Definition: knnntpaccount.h:127
KNServerInfo::i_d
int i_d
Definition: knserverinfo.h:75
KNNntpAccount::i_ntervalChecking
bool i_ntervalChecking
is interval checking enabled
Definition: knnntpaccount.h:133
KNServerInfo::s_erver
QString s_erver
Definition: knserverinfo.h:71
KNNntpAccountIntervalChecking::a_ccount
KNNntpAccount * a_ccount
Definition: knnntpaccount.h:47
KNCollection::n_ame
QString n_ame
The name of this collection.
Definition: kncollection.h:97
KNGlobals::identityManager
KPIMIdentities::IdentityManager * identityManager()
Returns the identity manager.
Definition: knglobals.cpp:167
KNNntpAccountIntervalChecking
Handles the interval checking of an news server account.
Definition: knnntpaccount.h:35
KNNntpAccount::mIdentityUoid
int mIdentityUoid
Unique object identifier of the identity of this server.
Definition: knnntpaccount.h:121
KNHelper::displayInternalFileError
static void displayInternalFileError(QWidget *w=0)
use this for all internal files
Definition: utilities.cpp:344
KNNntpAccountIntervalChecking::installTimer
void installTimer()
Definition: knnntpaccount.cpp:47
KNCollection
Abstract base class for everything that is visible in the folder tree.
Definition: kncollection.h:30
KNNntpAccount::identity
virtual const KPIMIdentities::Identity & identity() const
Returns this server's specific identity or the null identity if there is none.
Definition: knnntpaccount.cpp:213
KNNntpAccount::checkInterval
int checkInterval() const
Definition: knnntpaccount.h:102
KNNntpAccountIntervalChecking::slotCheckNews
void slotCheckNews()
Definition: knnntpaccount.cpp:72
KNServerInfo::id
int id() const
Definition: knserverinfo.h:46
KNNntpAccount::mCleanupConf
KNode::Cleanup * mCleanupConf
account specific cleanup configuration
Definition: knnntpaccount.h:123
KNCollection::l_istItem
KNCollectionViewItem * l_istItem
The list view item representing this collection in the folder tree.
Definition: kncollection.h:95
KNNntpAccount::editProperties
bool editProperties(QWidget *parent)
returns true when the user accepted
Definition: knnntpaccount.cpp:173
KNNntpAccount::a_ccountIntervalChecking
KNNntpAccountIntervalChecking * a_ccountIntervalChecking
helper class for news interval checking, manages the QTimer
Definition: knnntpaccount.h:137
kncollectionviewitem.h
KNServerInfo
Represents an account on a news server.
Definition: knserverinfo.h:29
KNNntpAccount::setIdentity
virtual void setIdentity(const KPIMIdentities::Identity &identity)
Sets this server's specific identity.
Definition: knnntpaccount.cpp:221
knglobals.h
KNNntpAccount::readInfo
bool readInfo(const QString &confPath)
tries to read information, returns false if it fails to do so
Definition: knnntpaccount.cpp:98
KNNntpAccount::KNNntpAccount
KNNntpAccount()
Definition: knnntpaccount.cpp:79
KNCollection::Ptr
boost::shared_ptr< KNCollection > Ptr
Shared pointer to a KNCollection.
Definition: kncollection.h:40
KNNntpAccountIntervalChecking::t_imer
QTimer * t_imer
Definition: knnntpaccount.h:46
KNNntpAccountIntervalChecking::deinstallTimer
void deinstallTimer()
Definition: knnntpaccount.cpp:64
KNNntpAccount::cleanupConfig
KNode::Cleanup * cleanupConfig() const
Definition: knnntpaccount.h:103
KNNntpAccount::setCheckInterval
void setCheckInterval(int c)
Definition: knnntpaccount.cpp:199
knconfigmanager.h
KNNntpAccount::~KNNntpAccount
~KNNntpAccount()
Definition: knnntpaccount.cpp:90
KNServerInfo::saveConf
void saveConf(KConfigGroup &conf)
Definition: knserverinfo.cpp:78
KNNntpAccount::startTimer
void startTimer()
Definition: knnntpaccount.cpp:187
KNNntpAccount::f_etchDescriptions
bool f_etchDescriptions
use an additional "list newsgroups" command to fetch the newsgroup descriptions
Definition: knnntpaccount.h:125
KNode::Cleanup::loadConfig
void loadConfig(const KConfigGroup &conf)
Definition: knconfig.cpp:229
knGlobals
#define knGlobals
Keep compatibility with the old way.
Definition: knglobals.h:28
KNGlobals::accountManager
KNAccountManager * accountManager()
Returns the account manager.
Definition: knglobals.cpp:110
KNNntpAccount::u_seDiskCache
bool u_seDiskCache
cache fetched articles on disk
Definition: knnntpaccount.h:131
KNAccountManager::account
KNNntpAccount::Ptr account(int id)
Returns the account with the given id.
Definition: knaccountmanager.cpp:84
KNNntpAccount::selfPtr
virtual KNCollection::Ptr selfPtr()
Reimplemented from KNArticleCollection::selfPtr().
Definition: knnntpaccount.cpp:227
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:36 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

knode

Skip menu "knode"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal