36 #ifndef ECHOLINK_DIRECTORY_INCLUDED
37 #define ECHOLINK_DIRECTORY_INCLUDED
46 #include <sigc++/sigc++.h>
60 #include <AsyncTcpClient.h>
61 #include <AsyncTimer.h>
213 const std::string&
server(
void)
const {
return the_server; }
225 const std::string&
callsign(
void)
const {
return the_callsign; }
237 const std::string&
password(
void)
const {
return the_password; }
253 const std::string&
description(
void)
const {
return the_description; }
263 const std::list<StationData>&
links(
void)
const {
return the_links; }
275 return the_repeaters;
289 return the_conferences;
296 const std::list<StationData>&
stations(
void)
const {
return the_stations; }
306 const std::string&
message(
void)
const {
return the_message; }
335 const std::string& code,
bool exact=
true);
352 SigC::Signal1<void, const std::string&>
error;
359 CS_WAITING_FOR_START, CS_WAITING_FOR_COUNT, CS_WAITING_FOR_CALL,
360 CS_WAITING_FOR_DATA, CS_WAITING_FOR_ID, CS_WAITING_FOR_IP,
361 CS_WAITING_FOR_END, CS_IDLE, CS_WAITING_FOR_OK
364 static const int DIRECTORY_SERVER_PORT = 5200;
365 static const int REGISTRATION_REFRESH_TIME = 5 * 60 * 1000;
366 static const int CMD_TIMEOUT = 120 * 1000;
369 std::string the_server;
370 std::string the_callsign;
371 std::string the_password;
372 std::string the_description;
373 std::list<StationData> the_links;
374 std::list<StationData> the_repeaters;
375 std::list<StationData> the_stations;
376 std::list<StationData> the_conferences;
377 std::string the_message;
378 std::string error_str;
382 std::list<StationData> get_call_list;
384 Async::TcpClient * ctrl_con;
385 std::list<Cmd> cmd_queue;
387 Async::Timer * reg_refresh_timer;
390 Async::Timer * cmd_timer;
395 void printBuf(
const unsigned char *buf,
int len);
396 int handleCallList(
char *buf,
int len);
398 void ctrlSockConnected(
void);
399 void ctrlSockDisconnected(Async::TcpConnection *con,
400 Async::TcpClient::DisconnectReason reason);
401 int ctrlSockDataReceived(Async::TcpConnection *con,
void *ptr,
int len);
402 void sendNextCmd(
void);
403 void addCmdToQueue(Cmd cmd);
405 void createClientObject(
void);
406 void onRefreshRegistration(Async::Timer *timer);
407 void onCmdTimeout(Async::Timer *timer);
408 bool stationCodeEq(
const StationData& stn, std::string code,
bool exact);
413 std::ostream&
operator<<(std::ostream& os,
const StationData& station);
void getCalls(void)
Get the station list from the directory server.
Directory(const std::string &server, const std::string &callsign, const std::string &password, const std::string &description="")
Constructor.
static const unsigned MAX_DESCRIPTION_SIZE
const std::string & description(void) const
Get the description that is used when registering in the server.
std::ostream & operator<<(std::ostream &os, const StationData &station)
std::string statusStr(void) const
Return the string representation of the status.
void makeBusy(void)
Login to the directory server and set status to busy.
std::string statusStr(void) const
Return the current status of the registration in string representation.
A class for accessing an EchoLink directory server.
A class for representing data for a station.
const std::string & server(void) const
Get the name of the remote host.
StationData::Status status(void) const
Return the current status of the registration.
Contains a class that represent station data.
void makeOffline(void)
Logout from the directory server.
SigC::Signal1< void, StationData::Status > statusChanged
A signal that is emitted when the registration status changes.
~Directory(void)
Destructor.
SigC::Signal0< void > stationListUpdated
A signal that is emitted when the station list has been updated.
const std::string & callsign(void) const
Get the callsign that is used when logging in to the server.
void setServer(const std::string &server)
Set the hostname or IP-address of the EchoLink server to use.
const StationData * findCall(const std::string &call)
Find a callsign in the station list.
void refreshRegistration(void)
Refresh the current registration in the directory server.
const std::list< StationData > & stations(void) const
Get a list of all active "normal" stations.
const std::string & password(void) const
Get the password that is used when logging in to the server.
const std::list< StationData > & repeaters(void) const
Get a list of all active repeasters.
const std::list< StationData > & conferences(void) const
Get a list of all active conferences.
void setCallsign(const std::string &callsign)
Set the callsign to use when logging in to the server.
SigC::Signal1< void, const std::string & > error
A signal that is emitted when an error occurs.
void setDescription(const std::string &description)
Set the description to register in the server.
void setPassword(const std::string &password)
Set the password to use when logging in to the server.
void findStationsByCode(std::vector< StationData > &stns, const std::string &code, bool exact=true)
Find stations from their mapping code.
void makeOnline(void)
Login to the directory server and set status to online.
const std::list< StationData > & links(void) const
Get a list of all active links.
const std::string & message(void) const
Get the message returned by the directory server.
const StationData * findStation(int id)
Find a station in the station list given a station ID.