Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

FreedbRemote Class Reference

Class for remote access to a freedb-server via CDDBP. More...

#include <freedb/freedb.hxx>

Inheritance diagram for FreedbRemote:

Freedb List of all members.

Public Methods

 FreedbRemote (string servername="freedb.freedb.org")
 The class constructor.

 ~FreedbRemote ()
 The class destructor.

vector< SearchResultsearch () const
void doHandshake (string username, string clientname, string version) const
 Sends the handshake to the server.


Protected Methods

void connect (string servername="freedb.freedb.org")
 Attempts to connect to a freedb server.

void disconnect ()
 Disconnects a connection to a remote server if one exists.

void sendCommand (string command) const
 Helper function to send a CDDBP command to the server.

string getResponseLine (bool stripcr=true) const
 Helper function to get a line of response from the server.


Detailed Description

Class for remote access to a freedb-server via CDDBP.

Note that the constructor tries to connect to the specified server/the default server, as it is vital for an object of this class to have a connection.

Definition at line 190 of file freedb.hxx.


Constructor & Destructor Documentation

FreedbRemote::~FreedbRemote  
 

The class destructor.

The destructor will attempt to disconnect.

Definition at line 15 of file freedb_remote.cxx.

References disconnect().


Member Function Documentation

void FreedbRemote::connect string    servername = "freedb.freedb.org" [protected]
 

Attempts to connect to a freedb server.

You have to call this function to utilize a remote freedb server. All low-level C chores like socket initializiation, dns querying are done by this function.

Clean C++ exception throwing is employed to guarantee easy error handling. It is imperative that you enclose a call to this function in a try-block with a catch(const Error& err) following it. The reserved error codes 600-699 may be returned by this function. Other functions requiring a connection will test if one exists to prevent the programmer from trying things he shouldn't.

Parameters:
servername  The server to connect to, may be a hostname or an IP address. If no server is given, the main relay server is used.
Exceptions:
Error  Throws the Error struct if a part of the connection process fails.

Definition at line 86 of file freedb_remote.cxx.

References CDDBP_PORT, Error::errcode, Error::errmsg, Error::extinfo, getResponseLine(), and stoi().

Referenced by FreedbRemote().

void FreedbRemote::doHandshake string    username,
string    clientname,
string    version
const
 

Sends the handshake to the server.

A valid CDDBP handshake is created from the given parameters and sent to the server. The handshake must be done after connecting before other commands are issued. If a handshake was already performed, error code 402 "Already shook hands" is set and an exception thrown.

Parameters:
username  The name of the user; application developers should offer the user an opportunity to set this.
clientname  The name of the client software.
version  The version of the client software.

Definition at line 220 of file freedb_remote.cxx.

References Error::errcode, Error::errmsg, Error::extinfo, getResponseLine(), sendCommand(), and stoi().

string FreedbRemote::getResponseLine bool    stripcr = true const [protected]
 

Helper function to get a line of response from the server.

A line of response is a string of arbitrary data that is terminated by a newline, often consisting of a response code (e.g. 200), a space and additional information.

You cannot (and should not) use this function directly. If you really need to send a custom command to the server, derive your own class from class CDDB.

Parameters:
stripcr  Denotes whether carriage returns (\r) should be filtered out.
Returns:
A string containing the response line.

Definition at line 48 of file freedb_remote.cxx.

Referenced by connect(), and doHandshake().

void FreedbRemote::sendCommand string    command const [protected]
 

Helper function to send a CDDBP command to the server.

Note:
You cannot (and should not) use this function directly. If you really need to send a custom command to the server, derive your own class from class CDDB.
Parameters:
command  The command to send to the server without terminating newline.

Definition at line 28 of file freedb_remote.cxx.

Referenced by disconnect(), and doHandshake().


The documentation for this class was generated from the following files:
Generated on Wed Nov 6 17:32:02 2002 for libfreedb by doxygen1.2.18