EchoLink::Directory Class Reference

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

#include <EchoLinkDirectory.h>

List of all members.

Public Member Functions

Public Attributes

Static Public Attributes


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>
#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();
}
Examples:

EchoLinkDirectory_demo.cpp.

Definition at line 125 of file EchoLinkDirectory.h.


Constructor & Destructor Documentation

EchoLink::Directory::Directory ( const std::string &  server,
const std::string &  callsign,
const std::string &  password,
const std::string &  description = "" 
)

Constructor.

Parameters:
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.


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 225 of file EchoLinkDirectory.h.

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 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.

Returns:
Return the description

Definition at line 253 of file EchoLinkDirectory.h.

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

Find a callsign in the station list.

Parameters:
call The callsign to find
Returns:
Returns a pointer to a StationData object if the callsign was found. Otherwise a NULL-pointer is returned.
const StationData* EchoLink::Directory::findStation ( int  id  ) 

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

Parameters:
id The ID to find
Returns:
Returns a pointer to a StationData object if the ID was found. Otherwise a NULL-pointer is returned.
void EchoLink::Directory::findStationsByCode ( std::vector< StationData > &  stns,
const std::string &  code,
bool  exact = true 
)

Find stations from their mapping code.

Parameters:
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

See also:
EchoLink::StationData::code.
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.

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 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.

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.

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.

Returns:
Return the password

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.

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 273 of file EchoLinkDirectory.h.

const std::string& EchoLink::Directory::server ( void   )  const [inline]

Get the name of the remote host.

Returns:
Returns 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.

Parameters:
callsign The new callsign to use
void EchoLink::Directory::setDescription ( const std::string &  description  ) 

Set the description to register in the server.

Parameters:
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.

Parameters:
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.

Parameters:
server The new server to use
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

Definition at line 296 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 177 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 184 of file EchoLinkDirectory.h.


Member Data Documentation

SigC::Signal1<void, const std::string&> EchoLink::Directory::error

A signal that is emitted when an error occurs.

Parameters:
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.

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

Definition at line 346 of file EchoLinkDirectory.h.

A signal that is emitted when the registration status changes.

Parameters:
status The new status

Definition at line 341 of file EchoLinkDirectory.h.


The documentation for this class was generated from the following file:
Generated by  doxygen 1.6.2-20100208