Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

LServer Class Reference

Provides an interface to access news locally. More...

#include <NServer.h>

Inheritance diagram for LServer:

NServer CServer List of all members.

Public Member Functions

 LServer (const char *spooldir)
virtual ~LServer ()
virtual ActiveDBactive ()
 News retrieval function.

virtual GroupInfogroupinfo (const char *name)
virtual Newsgroupgetgroup (const char *name)
virtual int post (Article *article)

Protected Member Functions

 LServer ()
void init (const char *spooldir)

Protected Attributes

char _SpoolDirectory [MAXPATHLEN]
ArtSpoolerpSpool

Detailed Description

Provides an interface to access news locally.

Author:
Thomas Gschwind

Definition at line 145 of file NServer.h.


Constructor & Destructor Documentation

LServer::LServer  )  [inline, protected]
 

Definition at line 150 of file NServer.h.

References _SpoolDirectory, and pSpool.

00150                   :NServer(), pSpool(0) {
00151                 _SpoolDirectory[0] = '\0';
00152         } void init(const char *spooldir);

LServer::LServer const char *  spooldir  ) 
 

Construct an LServer class

Parameters:
spooldir Name of spool-directory

Definition at line 94 of file NServer.cc.

References init(), slog, and VERB.

00095 {
00096         VERB(slog.
00097              p(Logger::Debug) << "LServer::LServer(" << spooldir << ")\n");
00098         init(spooldir);
00099 }

LServer::~LServer  )  [virtual]
 

Definition at line 101 of file NServer.cc.

References Logger::p(), pSpool, slog, and VERB.

00102 {
00103         VERB(slog.p(Logger::Debug) << "LServer::~LServer()\n");
00104 
00105         delete pSpool;
00106         pSpool = NULL;
00107 }


Member Function Documentation

ActiveDB * LServer::active  )  [virtual]
 

News retrieval function.

Returns:
Pointer to the active database. The database pointed to by the return vlue is maintained by the LServer class. Hence, it should not be modified by the user and must not be deleted!

Implements NServer.

Reimplemented in CServer.

Definition at line 131 of file NServer.cc.

00132 {
00133         return _ActiveDB;
00134 }

Newsgroup * LServer::getgroup const char *  name  )  [virtual]
 

Return the newsgroup with name >name<. If the newsgroup does not exist, NULL will be returned.

Parameters:
name Name of the newsgroup
Returns:
Pointer to a Newsgroup structure. Free it by calling the freegroup method. The newsgroup must be destructed by the same Server-instance it was constructed from.
Exceptions:
NoSuchGroupError If the newsgroup does not exist

Implements NServer.

Reimplemented in CServer.

Definition at line 154 of file NServer.cc.

References _SpoolDirectory, ERROR_LOCATION, ActiveDB::hasgroup(), slog, and VERB.

00155 {
00156         VERB(slog.
00157              p(Logger::Debug) << "LServer::getgroup(" << name << ")\n");
00158         if (!_ActiveDB->hasgroup(name))
00159                 throw NoSuchGroupError("no such group", ERROR_LOCATION);
00160         return new NVNewsgroup(_OverviewFormat, _SpoolDirectory, name);
00161 }

GroupInfo * LServer::groupinfo const char *  name  )  [virtual]
 

Parameters:
name Name of the newsgroup
Returns:
Returns informations of the newsgrup in statically allocated GroupInfo structure.
Exceptions:
NoSuchGroupError If the group does not exist

Implements NServer.

Reimplemented in CServer.

Definition at line 136 of file NServer.cc.

References ASSERT, ERROR_LOCATION, ActiveDB::get(), slog, and VERB.

Referenced by CServer::groupinfo().

00137 {
00138         VERB(slog.
00139              p(Logger::Debug) << "LServer::groupinfo(" << name << ")\n");
00140         static GroupInfo agroup;
00141 
00142         ASSERT(if (strlen(name) > 512) {
00143                throw
00144                AssertionError
00145                ("LServer::groupinfo: name of newsgroup too long\n",
00146                 ERROR_LOCATION);}
00147         );
00148 
00149         if (_ActiveDB->get(name, &agroup) < 0)
00150                 throw NoSuchGroupError("no such group", ERROR_LOCATION);
00151         return &agroup;
00152 }

void LServer::init const char *  spooldir  )  [protected]
 

Definition at line 109 of file NServer.cc.

References _SpoolDirectory, ASSERT, ERROR_LOCATION, MAXGROUPNAMELEN, pSpool, slog, and VERB.

Referenced by CServer::CServer(), and LServer().

00110 {
00111         VERB(slog.
00112              p(Logger::Debug) << "LServer::init(" << spooldir << ")\n");
00113 
00114         ASSERT(if
00115                (strlen(spooldir) >
00116                 sizeof(_SpoolDirectory) - MAXGROUPNAMELEN - 16) {
00117                throw
00118                AssertionError
00119                ("name of spooldirectory too long. longest groupname+spooldirlength does not fit into maxpathlen",
00120                 ERROR_LOCATION);}
00121         );
00122         strcpy(_SpoolDirectory, spooldir);
00123         pSpool = new ArtSpooler(spooldir);
00124 
00125         if (!_OverviewFormat)
00126                 _OverviewFormat = new OverviewFmt();
00127         if (!_ActiveDB)
00128                 _ActiveDB = NULL;
00129 }

int LServer::post Article article  )  [virtual]
 

Post an article to the news server.

Parameters:
article The article to be posted.
Returns:
0 on success, otherwise <0
Bug:
Not yet supported

Todo:
implement this method

Implements NServer.

Reimplemented in CServer.

Definition at line 163 of file NServer.cc.

00164 {
00165 //   TRACE(ctrace << "LServer::post(Article*)\n");
00166 //   char fn[1024];
00167 //   fstream fs;
00168 //   int qnbr;
00169 
00170 //   sprintf(fn,".outgoing/.qnbr");
00171 //   fs.open(fn,ios::in|ios::out);
00172 //   fs >> qnbr;
00173 //   if(!fs.good()) {
00174 //     qnbr=0;
00175 //     fs.clear();
00176 //   }
00177 //   fs.seekp(0,ios::beg);
00178 //   fs << qnbr+1 << endl;
00179 //   if(!fs.good()) {
00180 //     DEBUG(cdbg << "Failure on .outgoing/.qnbr\n");
00181 //   }
00182 //   fs.close();
00183 
00184 //   DEBUG(cdbg << "LServer: qnbr=" << qnbr << endl << article << endl);
00185 
00186 //   sprintf(fn,".outgoing/a%d",qnbr);
00187 //   fs.open(fn,ios::out);
00188 //   fs.unsetf(ios::skipws);
00189 //   fs << article;
00190 //   fs.close();
00191         return -1;
00192 }


Member Data Documentation

char LServer::_SpoolDirectory[MAXPATHLEN] [protected]
 

Definition at line 147 of file NServer.h.

Referenced by getgroup(), init(), and LServer().

ArtSpooler* LServer::pSpool [protected]
 

Definition at line 148 of file NServer.h.

Referenced by init(), LServer(), and ~LServer().


The documentation for this class was generated from the following files:
Generated on Sun Oct 24 21:08:22 2004 for NewsCache by doxygen 1.3.6-20040222