Added debug info

git-svn-id: http://voip.null.ro/svn/yate@1102 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
marian 2006-11-03 16:47:12 +00:00
parent 6f32500571
commit fc5c9a49ce
3 changed files with 67 additions and 29 deletions

View File

@ -98,7 +98,7 @@ void JBComponentStream::connect()
}
m_state = WaitToConnect;
// Check restart counters: If both of them are 0 destroy the stream
Debug(m_engine,DebugAll,
Debug(m_engine,DebugInfo,
"Stream::connect. Remaining attempts: Partial: %d. Total: %d. [%p]",
m_partialRestart,m_totalRestart,this);
if (!(m_partialRestart && m_totalRestart)) {
@ -144,7 +144,7 @@ void JBComponentStream::connect()
m_socket->setBlocking(false);
lock.drop();
// Start
DDebug(m_engine,DebugAll,"Stream::connect. Starting stream. [%p]",this);
DDebug(m_engine,DebugInfo,"Stream::connect. Starting stream. [%p]",this);
XMLElement* start = XMPPUtils::createElement(XMLElement::StreamStart,
XMPPNamespace::ComponentAccept);
start->setAttribute("xmlns:stream",s_ns[XMPPNamespace::Stream]);
@ -181,7 +181,7 @@ void JBComponentStream::terminate(bool destroy, bool sendEnd,
addEvent(JBEvent::Terminated,eventError);
m_state = Terminated;
}
Debug(m_engine,DebugAll,"Stream. %s. [%p]",destroy?"Destroy":"Terminate",this);
Debug(m_engine,DebugInfo,"Stream. %s. [%p]",destroy?"Destroy":"Terminate",this);
}
bool JBComponentStream::receive()
@ -265,7 +265,9 @@ void JBComponentStream::cancelPending(bool raise, const String* id)
// Cancel elements with id. Raise event if requested
// Don't cancel the first element if partial data was sent:
// The remote parser will fail
if (id && *id) {
if (id) {
XDebug(m_engine,DebugAll,
"Stream. Cancel pending elements with id '%s'. [%p]",id->c_str(),this);
ListIterator iter(m_outXML);
GenObject* obj;
bool first = true;
@ -286,6 +288,7 @@ void JBComponentStream::cancelPending(bool raise, const String* id)
return;
}
// Cancel all pending elements without id
XDebug(m_engine,DebugAll,"Stream. Cancel pending elements without id. [%p]",this);
ListIterator iter(m_outXML);
GenObject* obj;
for (; (obj = iter.get());) {
@ -312,7 +315,7 @@ void JBComponentStream::cleanup(bool endStream, XMLElement* e)
delete e;
return;
}
DDebug(m_engine,DebugAll,"Stream::cleanup(%s, %p) [%p]",
DDebug(m_engine,DebugAll,"Stream::cleanup(%s, %p). [%p]",
String::boolText(endStream),e,this);
bool partialData = false;
// Remove first element from queue if partial data was sent
@ -354,7 +357,7 @@ JBComponentStream::Error JBComponentStream::postXML(XMLElementOut* element)
element->deref();
return ErrorContext;
}
DDebug(m_engine,DebugAll,"Stream::postXML((%p): '%s'). [%p]",
DDebug(m_engine,DebugInfo,"Stream::postXML((%p): '%s'). [%p]",
element->element(),element->element()->name(),this);
// List not empty: the return value will be ErrorPending
// Else: element will be sent
@ -377,11 +380,11 @@ JBComponentStream::Error JBComponentStream::sendXML()
if (m_engine->debugAt(DebugAll)) {
String eStr;
XMPPUtils::print(eStr,e->element());
Debug(m_engine,DebugAll,"Stream::sendXML(%p). [%p]%s",
Debug(m_engine,DebugInfo,"Stream::sendXML(%p). [%p]%s",
e->element(),this,eStr.c_str());
}
else
Debug(m_engine,DebugAll,"Stream::sendXML((%p): '%s'). [%p]",
Debug(m_engine,DebugInfo,"Stream::sendXML((%p): '%s'). [%p]",
e->element(),e->element()->name(),this);
// Prepare & send
u_int32_t len;
@ -413,11 +416,11 @@ bool JBComponentStream::sendStreamXML(XMLElement* element, State newState,
if (before)
XMPPUtils::print(eStr,before);
XMPPUtils::print(eStr,element);
Debug(m_engine,DebugAll,"Stream::sendStreamXML. [%p]%s",
Debug(m_engine,DebugInfo,"Stream::sendStreamXML. [%p]%s",
this,eStr.c_str());
}
else
Debug(m_engine,DebugAll,"Stream::sendStreamXML('%s'). [%p]",
Debug(m_engine,DebugInfo,"Stream::sendStreamXML('%s'). [%p]",
element->name(),this);
String tmp, buff;
switch (element->type()) {
@ -476,11 +479,11 @@ bool JBComponentStream::processIncomingXML()
if (m_engine->debugAt(DebugAll)) {
String eStr;
XMPPUtils::print(eStr,element);
Debug(m_engine,DebugAll,"Stream::processIncomingXML(%p) [%p]. %s",
Debug(m_engine,DebugInfo,"Stream::processIncomingXML(%p) [%p]. %s",
element,this,eStr.c_str());
}
else
Debug(m_engine,DebugAll,"Stream::processIncomingXML((%p): '%s'). [%p].",
Debug(m_engine,DebugInfo,"Stream::processIncomingXML((%p): '%s'). [%p].",
element,element->name(),this);
// Check if we received a stream end or stream error
if (isStreamEnd(element))
@ -516,7 +519,8 @@ bool JBComponentStream::processStateStarted(XMLElement* e)
if (!e->hasAttribute("xmlns",s_ns[XMPPNamespace::ComponentAccept]))
return invalidElement(e,XMPPError::InvalidNamespace);
if (!e->hasAttribute("from",m_localName))
// if (!(e->hasAttribute("from",m_localName) || e->hasAttribute("from",m_remoteName)))
//TODO: Possible ejabberd support: check if we received remoteName
// if (!(e->hasAttribute("from",m_localName) || e->hasAttribute("from",m_remoteName)))
return invalidElement(e,XMPPError::HostUnknown);
m_id = e->getAttribute("id");
if (!m_id.length() || m_engine->remoteIdExists(this))

View File

@ -172,6 +172,31 @@ void JabberID::parse()
m_bare << m_domain;
}
/**
* JIDIdentity
*/
TokenDict JIDIdentity::s_category[] = {
{"account", Account},
{"client", Client},
{"component", Component},
{"gateway", Gateway},
{0,0},
};
TokenDict JIDIdentity::s_type[] = {
{"registered", AccountRegistered},
{"phone", ClientPhone},
{"generic", ComponentGeneric},
{"presence", ComponentPresence},
{"generic", GatewayGeneric},
{0,0},
};
XMLElement* JIDIdentity::toXML()
{
return XMPPUtils::createIdentity(categoryText(m_category),typeText(m_type),m_name);
}
/**
* JIDFeatures
*/

View File

@ -285,22 +285,22 @@ class YJINGLE_API JIDIdentity : public RefObject
{
public:
enum Category {
Account = 1, // account
Client = 2, // client
Component = 3, // component
Gateway = 4, // gateway
Count = 5,
Account, // account
Client, // client
Component, // component
Gateway, // gateway
CategoryUnknown
};
enum Type {
AccountRegistered = Count, // registered
AccountRegistered, // registered
ClientPhone, // phone
ComponentGeneric, // generic
ComponentPresence, // presence
GatewayGeneric, // generic
TypeUnknown
};
inline JIDIdentity(Category c, Type t, const char* name = 0)
: m_category(c), m_type(t), m_name(name)
{}
@ -312,12 +312,21 @@ public:
bool fromXML(const XMLElement* element);
static const char* categoryText(Category c);
static inline const char* categoryText(Category c)
{ return lookup(c,s_category); }
static const char* typeText(Category c);
static inline Category categoryValue(const char* c)
{ return (Category)lookup(c,s_category,CategoryUnknown); }
static inline const char* typeText(Type t)
{ return lookup(t,s_type); }
static inline Type typeValue(const char* t)
{ return (Type)lookup(t,s_category,TypeUnknown); }
private:
static TokenDict m_strings;
static TokenDict s_category[];
static TokenDict s_type[];
Category m_category; // Category
Type m_type; // Type
@ -532,10 +541,10 @@ class YJINGLE_API XMPPUser : public RefObject, public Mutex
{
public:
enum Subscription {
SubNone = 0,
SubTo = 1,
SubFrom = 2,
SubBoth = 3,
None = 0,
To = 1,
From = 2,
Both = 3,
};
XMPPUser(const char* node, const char* domain, Subscription sub);
@ -549,10 +558,10 @@ public:
{ return m_resource; }
inline bool subscribedTo() const
{ return (m_subscription & SubTo); }
{ return (m_subscription & To); }
inline bool subscribedFrom() const
{ return (m_subscription & SubFrom); }
{ return (m_subscription & From); }
private:
JabberID m_jid; // User's JID