36 #ifndef ECHOLINK_DIRECTORY_INCLUDED 37 #define ECHOLINK_DIRECTORY_INCLUDED 46 #include <sigc++/sigc++.h> 60 #include <AsyncTcpClient.h> 61 #include <AsyncTimer.h> 146 const Async::IpAddress &bind_ip=Async::IpAddress());
215 void setServers(
const std::vector<std::string>& servers);
221 const std::vector<std::string>&
servers(
void)
const {
return the_servers; }
233 const std::string&
callsign(
void)
const {
return the_callsign; }
245 const std::string&
password(
void)
const {
return the_password; }
261 const std::string&
description(
void)
const {
return the_description; }
271 const std::list<StationData>&
links(
void)
const {
return the_links; }
283 return the_repeaters;
297 return the_conferences;
304 const std::list<StationData>&
stations(
void)
const {
return the_stations; }
314 const std::string&
message(
void)
const {
return the_message; }
343 const std::string& code,
bool exact=
true);
360 sigc::signal<void, const std::string&>
error;
367 CS_WAITING_FOR_START, CS_WAITING_FOR_COUNT, CS_WAITING_FOR_CALL,
368 CS_WAITING_FOR_DATA, CS_WAITING_FOR_ID, CS_WAITING_FOR_IP,
369 CS_WAITING_FOR_END, CS_IDLE, CS_WAITING_FOR_OK
372 static const int DIRECTORY_SERVER_PORT = 5200;
373 static const int REGISTRATION_REFRESH_TIME = 5 * 60 * 1000;
374 static const int CMD_TIMEOUT = 120 * 1000;
377 std::vector<std::string> the_servers;
378 std::string the_callsign;
379 std::string the_password;
380 std::string the_description;
381 std::list<StationData> the_links;
382 std::list<StationData> the_repeaters;
383 std::list<StationData> the_stations;
384 std::list<StationData> the_conferences;
385 std::string the_message;
386 std::string error_str;
390 std::list<StationData> get_call_list;
392 DirectoryCon * ctrl_con;
393 std::list<Cmd> cmd_queue;
395 Async::Timer * reg_refresh_timer;
398 Async::Timer * cmd_timer;
399 Async::IpAddress bind_ip;
404 void printBuf(
const unsigned char *buf,
int len);
405 int handleCallList(
char *buf,
int len);
407 void ctrlSockReady(
bool is_ready);
408 void ctrlSockConnected(
void);
409 void ctrlSockDisconnected(
void);
410 int ctrlSockDataReceived(
void *ptr,
unsigned len);
411 void sendNextCmd(
void);
412 void addCmdToQueue(Cmd cmd);
414 void createClientObject(
void);
415 void onRefreshRegistration(Async::Timer *timer);
416 void onCmdTimeout(Async::Timer *timer);
417 bool stationCodeEq(
const StationData& stn, std::string code,
bool exact);
void getCalls(void)
Get the station list from the directory server.
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.
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.
~Directory(void)
Destructor.
const std::string & callsign(void) const
Get the callsign that is used when logging in to the server.
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.
sigc::signal< void > stationListUpdated
A signal that is emitted when the station list has been updated.
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::vector< std::string > & servers(void) const
Get the name of the remote host.
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.
sigc::signal< void, StationData::Status > statusChanged
A signal that is emitted when the registration status changes.
void setCallsign(const std::string &callsign)
Set the callsign to use when logging in to the server.
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.
Namespace to encapsulate EchoLink communication classes.
void setServers(const std::vector< std::string > &servers)
Set the hostname or IP-address of the EchoLink servers to use.
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.
sigc::signal< void, const std::string & > error
A signal that is emitted when an error occurs.