A class for accessing an EchoLink directory server. More...
#include <EchoLinkDirectory.h>
A class for accessing an EchoLink directory server.
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> #include <EchoLinkDirectory.h> using namespace std; using namespace Async; using namespace EchoLink; class MyClass : public SigC::Object { public: MyClass(const string& mycall, const string& mypass) : mycall(mycall) { dir = new Directory("server1.echolink.org", mycall, mypass, "Testing..."); dir->statusChanged.connect(slot(*this, &MyClass::onStatusChanged)); dir->stationListUpdated.connect( slot(*this, &MyClass::onStationListUpdated)); dir->error.connect(slot(*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(); }
Definition at line 125 of file EchoLinkDirectory.h.
EchoLink::Directory::Directory | ( | const std::string & | server, | |
const std::string & | callsign, | |||
const std::string & | password, | |||
const std::string & | description = "" | |||
) |
Constructor.
server | The EchoLink directory server to connect to | |
callsign | The callsign to register in the server | |
password | The password for the given callsign | |
description | A description/location string |
EchoLink::Directory::~Directory | ( | void | ) |
Destructor.
const std::string& EchoLink::Directory::callsign | ( | void | ) | const [inline] |
Get the callsign that is used when logging in to the server.
Definition at line 225 of file EchoLinkDirectory.h.
const std::list<StationData>& EchoLink::Directory::conferences | ( | void | ) | const [inline] |
Get a list of all active conferences.
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 287 of file EchoLinkDirectory.h.
const std::string& EchoLink::Directory::description | ( | void | ) | const [inline] |
Get the description that is used when registering in the server.
Definition at line 253 of file EchoLinkDirectory.h.
const StationData* EchoLink::Directory::findCall | ( | const std::string & | call | ) |
Find a callsign in the station list.
call | The callsign to find |
const StationData* EchoLink::Directory::findStation | ( | int | id | ) |
Find a station in the station list given a station ID.
id | The ID to find |
void EchoLink::Directory::findStationsByCode | ( | std::vector< StationData > & | stns, | |
const std::string & | code, | |||
bool | exact = true | |||
) |
Find stations from their mapping code.
stns | This list is filled in by this function | |
code | The code to searh for | |
exact | true 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
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.
const std::list<StationData>& EchoLink::Directory::links | ( | void | ) | const [inline] |
Get a list of all active links.
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 263 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.
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.
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.
Definition at line 306 of file EchoLinkDirectory.h.
const std::string& EchoLink::Directory::password | ( | void | ) | const [inline] |
Get the password that is used when logging in to the server.
Definition at line 237 of file EchoLinkDirectory.h.
void EchoLink::Directory::refreshRegistration | ( | void | ) | [inline] |
Refresh the current registration in the directory server.
Definition at line 171 of file EchoLinkDirectory.h.
const std::list<StationData>& EchoLink::Directory::repeaters | ( | void | ) | const [inline] |
Get a list of all active repeasters.
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 273 of file EchoLinkDirectory.h.
const std::string& EchoLink::Directory::server | ( | void | ) | const [inline] |
Get the name of the remote host.
Definition at line 213 of file EchoLinkDirectory.h.
void EchoLink::Directory::setCallsign | ( | const std::string & | callsign | ) |
Set the callsign to use when logging in to the server.
callsign | The new callsign to use |
void EchoLink::Directory::setDescription | ( | const std::string & | description | ) |
Set the description to register in the server.
description | The 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.
void EchoLink::Directory::setPassword | ( | const std::string & | password | ) |
Set the password to use when logging in to the server.
password | The new password to use |
void EchoLink::Directory::setServer | ( | const std::string & | server | ) |
Set the hostname or IP-address of the EchoLink server to use.
server | The new server to use |
const std::list<StationData>& EchoLink::Directory::stations | ( | void | ) | const [inline] |
Get a list of all active "normal" stations.
Definition at line 296 of file EchoLinkDirectory.h.
StationData::Status EchoLink::Directory::status | ( | void | ) | const [inline] |
Return the current status of the registration.
Definition at line 177 of file EchoLinkDirectory.h.
std::string EchoLink::Directory::statusStr | ( | void | ) | const [inline] |
Return the current status of the registration in string representation.
Definition at line 184 of file EchoLinkDirectory.h.
SigC::Signal1<void, const std::string&> EchoLink::Directory::error |
A signal that is emitted when an error occurs.
msg | The error message |
Definition at line 352 of file EchoLinkDirectory.h.
const unsigned EchoLink::Directory::MAX_DESCRIPTION_SIZE = 27 [static] |
Definition at line 128 of file EchoLinkDirectory.h.
SigC::Signal0<void> EchoLink::Directory::stationListUpdated |
A signal that is emitted when the station list has been updated.
Definition at line 346 of file EchoLinkDirectory.h.
SigC::Signal1<void, StationData::Status> EchoLink::Directory::statusChanged |
A signal that is emitted when the registration status changes.
status | The new status |
Definition at line 341 of file EchoLinkDirectory.h.