EchoLib  1.3.3
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
EchoLink::Directory Class Reference

A class for accessing an EchoLink directory server. More...

#include <EchoLinkDirectory.h>

Inheritance diagram for EchoLink::Directory:

Public Member Functions

 Directory (const std::vector< std::string > &servers, const std::string &callsign, const std::string &password, const std::string &description="", const Async::IpAddress &bind_ip=Async::IpAddress())
 Constructor. More...
 
 ~Directory (void)
 Destructor. More...
 
void makeOnline (void)
 Login to the directory server and set status to online. More...
 
void makeBusy (void)
 Login to the directory server and set status to busy. More...
 
void makeOffline (void)
 Logout from the directory server. More...
 
void refreshRegistration (void)
 Refresh the current registration in the directory server. More...
 
StationData::Status status (void) const
 Return the current status of the registration. More...
 
std::string statusStr (void) const
 Return the current status of the registration in string representation. More...
 
void getCalls (void)
 Get the station list from the directory server. More...
 
void setServers (const std::vector< std::string > &servers)
 Set the hostname or IP-address of the EchoLink servers to use. More...
 
const std::vector< std::string > & servers (void) const
 Get the name of the remote host. More...
 
void setCallsign (const std::string &callsign)
 Set the callsign to use when logging in to the server. More...
 
const std::string & callsign (void) const
 Get the callsign that is used when logging in to the server. More...
 
void setPassword (const std::string &password)
 Set the password to use when logging in to the server. More...
 
const std::string & password (void) const
 Get the password that is used when logging in to the server. More...
 
void setDescription (const std::string &description)
 Set the description to register in the server. More...
 
const std::string & description (void) const
 Get the description that is used when registering in the server. More...
 
const std::list< StationData > & links (void) const
 Get a list of all active links. More...
 
const std::list< StationData > & repeaters (void) const
 Get a list of all active repeasters. More...
 
const std::list< StationData > & conferences (void) const
 Get a list of all active conferences. More...
 
const std::list< StationData > & stations (void) const
 Get a list of all active "normal" stations. More...
 
const std::string & message (void) const
 Get the message returned by the directory server. More...
 
const StationDatafindCall (const std::string &call)
 Find a callsign in the station list. More...
 
const StationDatafindStation (int id)
 Find a station in the station list given a station ID. More...
 
void findStationsByCode (std::vector< StationData > &stns, const std::string &code, bool exact=true)
 Find stations from their mapping code. More...
 

Public Attributes

sigc::signal< void, StationData::StatusstatusChanged
 A signal that is emitted when the registration status changes. More...
 
sigc::signal< void > stationListUpdated
 A signal that is emitted when the station list has been updated. More...
 
sigc::signal< void, const std::string & > error
 A signal that is emitted when an error occurs. More...
 

Static Public Attributes

static const unsigned MAX_DESCRIPTION_SIZE = 27
 

Detailed Description

A class for accessing an EchoLink directory server.

Author
Tobias Blomberg
Date
2003-03-08

Use this class to access an EchoLink directory server. The primary purpose of the EchoLink directory server is to map between callsigns and IP-addresses. It is also used to see which stations are online. An example usage that lists all connected stations is shown below.

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <AsyncCppApplication.h>
using namespace std;
using namespace Async;
using namespace EchoLink;
class MyClass : public sigc::trackable
{
public:
MyClass(const string& mycall, const string& mypass) : mycall(mycall)
{
vector<string> servers;
servers.push_back("servers.echolink.org");
dir = new Directory(servers, mycall, mypass, "Testing...");
dir->statusChanged.connect(mem_fun(*this, &MyClass::onStatusChanged));
dir->stationListUpdated.connect(
mem_fun(*this, &MyClass::onStationListUpdated));
dir->error.connect(mem_fun(*this, &MyClass::onError));
dir->makeBusy(); // Set status busy so noone think we are really online
}
~MyClass(void)
{
delete dir;
}
private:
string mycall;
Directory * dir;
void onStatusChanged(StationData::Status status)
{
cerr << "Status changed to " << StationData::statusStr(status) << endl;
if (status == StationData::STAT_BUSY)
{
dir->getCalls();
}
else
{
Application::app().quit();
}
}
void onStationListUpdated(void)
{
const list<StationData>& stations = dir->stations();
list<StationData>::const_iterator it;
for (it = stations.begin(); it != stations.end(); ++it)
{
cerr << *it << endl;
}
cerr << endl << "Message:" << endl;
cerr << dir->message() << endl;
const StationData *mydata = dir->findCall(mycall);
cerr << endl << "My station data:" << endl << *mydata << endl;
dir->makeOffline();
}
void onError(const string& msg)
{
cerr << "ERROR: " << msg << endl;
Application::app().quit();
}
};
int main(int argc, char **argv)
{
CppApplication app; // or QtApplication
if (argc < 3)
{
cerr << "Usage: EchoLinkDispatcher_demo <callsign> <password>\n";
exit(1);
}
MyClass my_class(argv[1], argv[2]);
app.exec();
}
Examples:
EchoLinkDirectory_demo.cpp.

Definition at line 130 of file EchoLinkDirectory.h.

Constructor & Destructor Documentation

EchoLink::Directory::Directory ( const std::vector< std::string > &  servers,
const std::string &  callsign,
const std::string &  password,
const std::string &  description = "",
const Async::IpAddress &  bind_ip = Async::IpAddress() 
)

Constructor.

Parameters
serversThe EchoLink directory servers to connect to
callsignThe callsign to register in the server
passwordThe password for the given callsign
descriptionA description/location string
bind_ipThe source IP address to use
EchoLink::Directory::~Directory ( void  )

Destructor.

Member Function Documentation

const std::string& EchoLink::Directory::callsign ( void  ) const
inline

Get the callsign that is used when logging in to the server.

Returns
Return the callsign

Definition at line 233 of file EchoLinkDirectory.h.

References setPassword().

const std::list<StationData>& EchoLink::Directory::conferences ( void  ) const
inline

Get a list of all active conferences.

Returns
Returns a reference to a list of StationData objects

Use this function to get a list of all active conferences. Conferences are stations where the callsign is surrounded with "*". For this function to return anything, a previous call to Directory::getCalls must have been made.

Definition at line 295 of file EchoLinkDirectory.h.

const std::string& EchoLink::Directory::description ( void  ) const
inline

Get the description that is used when registering in the server.

Returns
Return the description

Definition at line 261 of file EchoLinkDirectory.h.

Referenced by password().

const StationData* EchoLink::Directory::findCall ( const std::string &  call)

Find a callsign in the station list.

Parameters
callThe callsign to find
Returns
Returns a pointer to a StationData object if the callsign was found. Otherwise a NULL-pointer is returned.
Examples:
EchoLinkDirectory_demo.cpp.

Referenced by message().

const StationData* EchoLink::Directory::findStation ( int  id)

Find a station in the station list given a station ID.

Parameters
idThe ID to find
Returns
Returns a pointer to a StationData object if the ID was found. Otherwise a NULL-pointer is returned.

Referenced by message().

void EchoLink::Directory::findStationsByCode ( std::vector< StationData > &  stns,
const std::string &  code,
bool  exact = true 
)

Find stations from their mapping code.

Parameters
stnsThis list is filled in by this function
codeThe code to searh for
exacttrue if it should be an exact match or else false

Find stations matching the given code. For a description of how the callsign to code mapping is done see

See also
EchoLink::StationData::code.

Referenced by message().

void EchoLink::Directory::getCalls ( void  )

Get the station list from the directory server.

Use this function to initiate a transfer of the station list from the directory server. When the list has been completely transfered the Directory::stationListUpdated signal will be emitted. If this function is called while a previous getCalls is in progress, the request will be ignored.

After the transfer is done. There may be a server message to read. Get this message by using the Directory::message function.

Examples:
EchoLinkDirectory_demo.cpp.

Referenced by statusStr().

const std::list<StationData>& EchoLink::Directory::links ( void  ) const
inline

Get a list of all active links.

Returns
Returns a reference to a list of StationData objects

Use this function to get a list of all active links. Links are stations where the callsign end with "-L". For this function to return anything, a previous call to Directory::getCalls must have been made.

Definition at line 271 of file EchoLinkDirectory.h.

void EchoLink::Directory::makeBusy ( void  )

Login to the directory server and set status to busy.

Use this function to login to the directory server and set the status to busy. The registration will automatically be refreshed to keep the registration from timing out.

void EchoLink::Directory::makeOffline ( void  )

Logout from the directory server.

Examples:
EchoLinkDirectory_demo.cpp.
void EchoLink::Directory::makeOnline ( void  )

Login to the directory server and set status to online.

Use this function to login to the directory server and set the status to online. The registration will automatically be refreshed to keep the registration from timing out.

const std::string& EchoLink::Directory::message ( void  ) const
inline

Get the message returned by the directory server.

Returns
Returns the message string (may be empty)

This function is used to get the message returned by the directory server after getting the station list. It is valid until a getCalls function call is made again.

Examples:
EchoLinkDirectory_demo.cpp.

Definition at line 314 of file EchoLinkDirectory.h.

References findCall(), findStation(), and findStationsByCode().

const std::string& EchoLink::Directory::password ( void  ) const
inline

Get the password that is used when logging in to the server.

Returns
Return the password

Definition at line 245 of file EchoLinkDirectory.h.

References description(), and setDescription().

void EchoLink::Directory::refreshRegistration ( void  )
inline

Refresh the current registration in the directory server.

Definition at line 179 of file EchoLinkDirectory.h.

const std::list<StationData>& EchoLink::Directory::repeaters ( void  ) const
inline

Get a list of all active repeasters.

Returns
Returns a reference to a list of StationData objects

Use this function to get a list of all active repeaters. Repeaters are stations where the callsign end with "-R". For this function to return anything, a previous call to Directory::getCalls must have been made.

Definition at line 281 of file EchoLinkDirectory.h.

const std::vector<std::string>& EchoLink::Directory::servers ( void  ) const
inline

Get the name of the remote host.

Returns
Returns the name of the remote host

Definition at line 221 of file EchoLinkDirectory.h.

References setCallsign().

void EchoLink::Directory::setCallsign ( const std::string &  callsign)

Set the callsign to use when logging in to the server.

Parameters
callsignThe new callsign to use

Referenced by servers().

void EchoLink::Directory::setDescription ( const std::string &  description)

Set the description to register in the server.

Parameters
descriptionThe new description to use

Use this function to set the description used when registering in the directory server. The description will not be updated in the directory server until makeOnline, makeBusy or refreshRegistration is called.

Referenced by password().

void EchoLink::Directory::setPassword ( const std::string &  password)

Set the password to use when logging in to the server.

Parameters
passwordThe new password to use

Referenced by callsign().

void EchoLink::Directory::setServers ( const std::vector< std::string > &  servers)

Set the hostname or IP-address of the EchoLink servers to use.

Parameters
serversThe new servers to use

Referenced by statusStr().

const std::list<StationData>& EchoLink::Directory::stations ( void  ) const
inline

Get a list of all active "normal" stations.

Returns
Returns a reference to a list of StationData objects
Examples:
EchoLinkDirectory_demo.cpp.

Definition at line 304 of file EchoLinkDirectory.h.

StationData::Status EchoLink::Directory::status ( void  ) const
inline

Return the current status of the registration.

Returns
Returns the status

Definition at line 185 of file EchoLinkDirectory.h.

std::string EchoLink::Directory::statusStr ( void  ) const
inline

Return the current status of the registration in string representation.

Returns
Returns a string representing the current status

Definition at line 192 of file EchoLinkDirectory.h.

References getCalls(), setServers(), and EchoLink::StationData::statusStr().

Member Data Documentation

sigc::signal<void, const std::string&> EchoLink::Directory::error

A signal that is emitted when an error occurs.

Parameters
msgThe error message

Definition at line 360 of file EchoLinkDirectory.h.

const unsigned EchoLink::Directory::MAX_DESCRIPTION_SIZE = 27
static

Definition at line 133 of file EchoLinkDirectory.h.

sigc::signal<void> EchoLink::Directory::stationListUpdated

A signal that is emitted when the station list has been updated.

Definition at line 354 of file EchoLinkDirectory.h.

sigc::signal<void, StationData::Status> EchoLink::Directory::statusChanged

A signal that is emitted when the registration status changes.

Parameters
statusThe new status

Definition at line 349 of file EchoLinkDirectory.h.


The documentation for this class was generated from the following file: