21 #include "servicebase.h"
28 const TQString& host,
unsigned short port) :
29 m_serviceName(name), m_type(type), m_domain(domain), m_hostName(host), m_port(port)
32 ServiceBase::~ServiceBase()
37 return m_serviceName.replace(
".",
"\\.").replace(
"\\",
"\\\\") + TQString(
".") + m_type +
38 TQString(
".") + m_domain;
52 TQString decoded_name=name;
53 decoded_name=decoded_name.replace(
"\\\\",
"\\");
54 int i = decoded_name.find(TQRegExp(
"[^\\\\]\\."));
56 rest = decoded_name.mid(i+2);
57 m_serviceName=decoded_name.left(i+1).replace(
"\\.",
".");
59 m_type = rest.section(
'.',0,1);
61 if (m_type[0]==
'_' && m_type[m_type.find(
'.')+1]==
'_')
62 m_domain = rest.section(
'.',2,-1,TQString::SectionIncludeTrailingSep);
98 void ServiceBase::virtual_hook(
int,
void*)
101 TQDataStream & operator<< (TQDataStream & s,
const ServiceBase & a)
103 s << a.m_serviceName << a.m_type << a.m_domain << a.m_hostName << TQ_INT16(a.m_port) << a.m_textData;
107 TQDataStream & operator>> (TQDataStream & s, ServiceBase & a)
110 s >> a.m_serviceName >> a.m_type >> a.m_domain >> a.m_hostName >> port >> a.m_textData;
const TQString & domain() const
Returns domain that given service belongs to.
TQMap< TQString, TQString > m_textData
Map of TXT properties.
const TQString & type() const
Returns type of service.
const TQMap< TQString, TQString > & textData() const
Returns read only map of text properties.
const TQString & hostName() const
Returns hostname.
unsigned short port() const
Returns port number.
ServiceBase(const TQString &name=TQString::null, const TQString &type=TQString::null, const TQString &domain=TQString::null, const TQString &host=TQString::null, unsigned short port=0)
void decode(const TQString &name)
Decode PTR label returned by DNS resolver into service name, type and domain.
const TQString & serviceName() const
Returns name of service.
TQString encode()
Encode service name, type and domain into string that can be used as DNS-SD PTR label.