Added a textual disconnect reason - usefull for building proper messages.
git-svn-id: http://yate.null.ro/svn/yate/trunk@104 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
b132a0e030
commit
b64dd554e4
|
@ -343,7 +343,7 @@ bool DataEndpoint::connect(DataEndpoint *peer)
|
|||
return true;
|
||||
}
|
||||
|
||||
void DataEndpoint::disconnect()
|
||||
void DataEndpoint::disconnect(const char *reason)
|
||||
{
|
||||
if (!m_peer)
|
||||
return;
|
||||
|
@ -360,19 +360,19 @@ void DataEndpoint::disconnect()
|
|||
|
||||
DataEndpoint *temp = m_peer;
|
||||
m_peer = 0;
|
||||
temp->setPeer(0);
|
||||
temp->setPeer(0,reason);
|
||||
temp->deref();
|
||||
disconnected();
|
||||
disconnected(reason);
|
||||
deref();
|
||||
}
|
||||
|
||||
void DataEndpoint::setPeer(DataEndpoint *peer)
|
||||
void DataEndpoint::setPeer(DataEndpoint *peer, const char *reason)
|
||||
{
|
||||
m_peer = peer;
|
||||
if (m_peer)
|
||||
connected();
|
||||
else
|
||||
disconnected();
|
||||
disconnected(reason);
|
||||
}
|
||||
|
||||
void DataEndpoint::setSource(DataSource *source)
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
};
|
||||
static ExtModChan* build(const char *file, const char *args, int type);
|
||||
~ExtModChan();
|
||||
virtual void disconnected();
|
||||
virtual void disconnected(const char *reason);
|
||||
inline ExtModReceiver* receiver() const
|
||||
{ return m_recv; }
|
||||
inline void setRecv(ExtModReceiver* recv)
|
||||
|
@ -288,9 +288,9 @@ ExtModChan::~ExtModChan()
|
|||
m_recv->die(false);
|
||||
}
|
||||
|
||||
void ExtModChan::disconnected()
|
||||
void ExtModChan::disconnected(const char *reason)
|
||||
{
|
||||
Debugger debug("ExtModChan::disconnected()"," [%p]",this);
|
||||
Debugger debug("ExtModChan::disconnected()"," '%s' [%p]",reason,this);
|
||||
}
|
||||
|
||||
MsgHolder::MsgHolder(Message &msg)
|
||||
|
|
|
@ -217,7 +217,7 @@ public:
|
|||
BOOL OnCreateLogicalChannel(const H323Capability & capability, H323Channel::Directions dir, unsigned & errorCode ) ;
|
||||
BOOL StartExternalRTP(const char* remoteIP, WORD remotePort, H323Channel::Directions dir, YateH323_ExternalRTPChannel* chan);
|
||||
void OnStoppedExternal(H323Channel::Directions dir);
|
||||
virtual void disconnected();
|
||||
virtual void disconnected(const char *reason);
|
||||
inline const String &id() const
|
||||
{ return m_id; }
|
||||
inline const String &status() const
|
||||
|
@ -735,9 +735,9 @@ BOOL YateH323Connection::OpenAudioChannel(BOOL isEncoding, unsigned bufferSize,
|
|||
return false;
|
||||
}
|
||||
|
||||
void YateH323Connection::disconnected()
|
||||
void YateH323Connection::disconnected(const char *reason)
|
||||
{
|
||||
Debugger debug("YateH323Connection::disconnected()"," [%p]",this);
|
||||
Debugger debug("YateH323Connection::disconnected()"," '%s' [%p]",reason,this);
|
||||
setStatus("disconnected");
|
||||
// we must bypass the normal Yate refcounted destruction as OpenH323 will destroy the object
|
||||
ref();
|
||||
|
|
|
@ -111,7 +111,7 @@ class YateIAXConnection : public DataEndpoint
|
|||
public:
|
||||
YateIAXConnection(iax_session *session = 0);
|
||||
~YateIAXConnection();
|
||||
void disconnected(void);
|
||||
virtual void disconnected(const char *reason);
|
||||
void abort();
|
||||
int makeCall(char *cidnum, char *cidname, char *target = 0, char *lang = 0);
|
||||
void hangup(char *reason = "Unexpected problem");
|
||||
|
@ -772,13 +772,15 @@ void YateIAXConnection::sourceAudio(void *buffer, int len, int format)
|
|||
}
|
||||
}
|
||||
|
||||
void YateIAXConnection::disconnected()
|
||||
void YateIAXConnection::disconnected(const char *reason)
|
||||
{
|
||||
Debug(DebugAll,"YateIAXConnection::disconnected()");
|
||||
Debug(DebugAll,"YateIAXConnection::disconnected() '%s'",reason);
|
||||
// If we still have a connection this is the last chance to get transferred
|
||||
if (!m_final) {
|
||||
Message m("disconnected");
|
||||
m.addParam("ourcallid",ourcallid.c_str());
|
||||
if (reason)
|
||||
m.addParam("reason",reason);
|
||||
if (partycallid) {
|
||||
// Announce our old party but at this point it may be destroyed
|
||||
m.addParam("partycallid",partycallid.c_str());
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
bool init();
|
||||
~OssChan();
|
||||
int setformat();
|
||||
virtual void disconnected();
|
||||
virtual void disconnected(const char *reason);
|
||||
int soundcard_setinput(bool force);
|
||||
int soundcard_setoutput(bool force);
|
||||
int time_has_passed(void);
|
||||
|
@ -369,9 +369,9 @@ int OssChan::soundcard_setoutput(bool force)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void OssChan::disconnected()
|
||||
void OssChan::disconnected(const char *reason)
|
||||
{
|
||||
Debugger debug("OssChan::disconnected()"," [%p]",this);
|
||||
Debugger debug("OssChan::disconnected()"," '%s' [%p]",reason,this);
|
||||
destruct();
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class ToneChan : public DataEndpoint
|
|||
public:
|
||||
ToneChan(const String &tone);
|
||||
~ToneChan();
|
||||
virtual void disconnected();
|
||||
virtual void disconnected(const char *reason);
|
||||
};
|
||||
|
||||
class ToneHandler : public MessageHandler
|
||||
|
@ -218,9 +218,9 @@ ToneChan::~ToneChan()
|
|||
mutex.unlock();
|
||||
}
|
||||
|
||||
void ToneChan::disconnected()
|
||||
void ToneChan::disconnected(const char *reason)
|
||||
{
|
||||
Debugger debug("ToneChan::disconnected()"," [%p]",this);
|
||||
Debugger debug("ToneChan::disconnected()"," '%s' [%p]",reason,this);
|
||||
}
|
||||
|
||||
bool ToneHandler::received(Message &msg)
|
||||
|
@ -322,7 +322,7 @@ ToneGenPlugin::~ToneGenPlugin()
|
|||
while (l) {
|
||||
ToneChan *t = static_cast<ToneChan *>(l->get());
|
||||
if (t)
|
||||
t->disconnect();
|
||||
t->disconnect("shutdown");
|
||||
if (l->get() == t)
|
||||
l = l->next();
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class WaveChan : public DataEndpoint
|
|||
public:
|
||||
WaveChan(const String& file, bool record, unsigned maxlen = 0);
|
||||
~WaveChan();
|
||||
virtual void disconnected();
|
||||
virtual void disconnected(const char *reason);
|
||||
};
|
||||
|
||||
class WaveHandler : public MessageHandler
|
||||
|
@ -167,7 +167,7 @@ void WaveSource::cleanup()
|
|||
{
|
||||
Debug(DebugAll,"WaveSource [%p] cleanup, total=%u",this,m_total);
|
||||
if (m_chan && m_autoclose)
|
||||
m_chan->disconnect();
|
||||
m_chan->disconnect("eof");
|
||||
}
|
||||
|
||||
WaveConsumer::WaveConsumer(const String& file, DataEndpoint *chan, unsigned maxlen)
|
||||
|
@ -253,9 +253,9 @@ WaveChan::~WaveChan()
|
|||
Debug(DebugAll,"WaveChan::~WaveChan() [%p]",this);
|
||||
}
|
||||
|
||||
void WaveChan::disconnected()
|
||||
void WaveChan::disconnected(const char *reason)
|
||||
{
|
||||
Debugger debug("WaveChan::disconnected()"," [%p]",this);
|
||||
Debugger debug("WaveChan::disconnected()"," '%s' [%p]",reason,this);
|
||||
}
|
||||
|
||||
bool WaveHandler::received(Message &msg)
|
||||
|
|
|
@ -366,7 +366,7 @@ class ZapChan : public DataEndpoint
|
|||
public:
|
||||
ZapChan(PriSpan *parent, int chan, unsigned int bufsize);
|
||||
virtual ~ZapChan();
|
||||
virtual void disconnected();
|
||||
virtual void disconnected(const char *reason);
|
||||
virtual bool nativeConnect(DataEndpoint *peer);
|
||||
inline PriSpan *span() const
|
||||
{ return m_span; }
|
||||
|
@ -950,9 +950,9 @@ ZapChan::~ZapChan()
|
|||
hangup(PRI_CAUSE_NORMAL_UNSPECIFIED);
|
||||
}
|
||||
|
||||
void ZapChan::disconnected()
|
||||
void ZapChan::disconnected(const char *reason)
|
||||
{
|
||||
Debugger debug("ZapChan::disconnected()");
|
||||
Debugger debug("ZapChan::disconnected() '%s' [%p]",reason,this);
|
||||
// FIXME: we can't know from which thread we got disconnected
|
||||
bool gotLock = zplugin.mutex.lock(1000);
|
||||
hangup(PRI_CAUSE_NORMAL_CLEARING);
|
||||
|
@ -999,7 +999,7 @@ void ZapChan::idle()
|
|||
|
||||
void ZapChan::restart(bool outgoing)
|
||||
{
|
||||
disconnect();
|
||||
disconnect("restart");
|
||||
close();
|
||||
if (outgoing)
|
||||
::pri_reset(m_span->pri(),m_chan);
|
||||
|
@ -1069,11 +1069,12 @@ bool ZapChan::answer()
|
|||
|
||||
void ZapChan::hangup(int cause)
|
||||
{
|
||||
const char *reason = pri_cause2str(cause);
|
||||
if (inUse())
|
||||
Debug(DebugInfo,"Hanging up zap/%d in state %s: %s (%d)",
|
||||
m_abschan,status(),pri_cause2str(cause),cause);
|
||||
m_abschan,status(),reason,cause);
|
||||
m_timeout = 0;
|
||||
disconnect();
|
||||
disconnect(reason);
|
||||
close();
|
||||
m_ring = false;
|
||||
if (m_call) {
|
||||
|
|
|
@ -380,8 +380,9 @@ public:
|
|||
|
||||
/**
|
||||
* Disconnect from the connected endpoint
|
||||
* @param reason Text that describes disconnect reason
|
||||
*/
|
||||
void disconnect();
|
||||
void disconnect(const char *reason = 0);
|
||||
|
||||
/**
|
||||
* Set the data source of this object
|
||||
|
@ -431,8 +432,9 @@ protected:
|
|||
|
||||
/**
|
||||
* Disconnect notification method
|
||||
* @param reason Text that describes disconnect reason
|
||||
*/
|
||||
virtual void disconnected() { }
|
||||
virtual void disconnected(const char *reason) { }
|
||||
|
||||
/**
|
||||
* Attempt to connect the endpoint to a peer of the same type
|
||||
|
@ -445,8 +447,9 @@ protected:
|
|||
/*
|
||||
* Set the peer endpoint pointer
|
||||
* @param peer A pointer to the new peer or NULL
|
||||
* @param reason Text describing the reason in case of disconnect
|
||||
*/
|
||||
void setPeer(DataEndpoint *peer);
|
||||
void setPeer(DataEndpoint *peer, const char *reason = 0);
|
||||
|
||||
private:
|
||||
String m_name;
|
||||
|
|
Loading…
Reference in New Issue