mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
* Store PeerInfos in a temporary ControlConnection while the SIP is pending, so they don't get deleted again immediately.
This commit is contained in:
@@ -311,7 +311,7 @@ Servent::registerPeer( const Tomahawk::peerinfo_ptr& peerInfo )
|
||||
|
||||
if ( peerInfo->type() == Tomahawk::PeerInfo::Local )
|
||||
{
|
||||
peerInfoDebug(peerInfo) << "YAY, we need to establish the connection now.. thinking";
|
||||
peerInfoDebug(peerInfo) << "we need to establish the connection now... thinking";
|
||||
if ( !connectedToSession( peerInfo->sipInfo().nodeId() ) )
|
||||
{
|
||||
connectToPeer( peerInfo );
|
||||
@@ -336,8 +336,6 @@ Servent::registerPeer( const Tomahawk::peerinfo_ptr& peerInfo )
|
||||
else
|
||||
{
|
||||
SipInfo info;
|
||||
if ( visibleExternally() )
|
||||
{
|
||||
QString peerId = peerInfo->id();
|
||||
QString key = uuid();
|
||||
ControlConnection* conn = new ControlConnection( this );
|
||||
@@ -347,6 +345,8 @@ Servent::registerPeer( const Tomahawk::peerinfo_ptr& peerInfo )
|
||||
conn->setId( nodeid );
|
||||
conn->addPeerInfo( peerInfo );
|
||||
|
||||
if ( visibleExternally() )
|
||||
{
|
||||
registerOffer( key, conn );
|
||||
info.setVisible( true );
|
||||
info.setHost( externalAddress() );
|
||||
@@ -414,6 +414,8 @@ void Servent::handleSipInfo( const Tomahawk::peerinfo_ptr& peerInfo )
|
||||
else
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "They are not visible, doing nothing atm";
|
||||
if ( peerInfo->controlConnection() )
|
||||
delete peerInfo->controlConnection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -714,10 +716,13 @@ Servent::connectToPeer( const peerinfo_ptr& peerInfo )
|
||||
SipInfo sipInfo = peerInfo->sipInfo();
|
||||
|
||||
peerInfoDebug( peerInfo ) << "connectToPeer: search for already established connections to the same nodeid:" << m_controlconnections.count() << "connections";
|
||||
if ( peerInfo->controlConnection() )
|
||||
delete peerInfo->controlConnection();
|
||||
|
||||
bool isDupe = false;
|
||||
ControlConnection* conn = 0;
|
||||
// try to find a ControlConnection with the same SipInfo, then we dont need to try to connect again
|
||||
|
||||
foreach ( ControlConnection* c, m_controlconnections )
|
||||
{
|
||||
Q_ASSERT( c );
|
||||
@@ -769,7 +774,6 @@ Servent::connectToPeer( const peerinfo_ptr& peerInfo )
|
||||
m["nodeid"] = Database::instance()->impl()->dbid();
|
||||
|
||||
peerInfoDebug(peerInfo) << "No match found, creating a new ControlConnection...";
|
||||
|
||||
conn = new ControlConnection( this );
|
||||
conn->addPeerInfo( peerInfo );
|
||||
conn->setFirstMessage( m );
|
||||
|
@@ -35,12 +35,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
SipInfoPrivate( const SipInfoPrivate& other ) : QSharedData( other ),
|
||||
visible(other.visible),
|
||||
host(other.host),
|
||||
port(other.port),
|
||||
nodeId(other.nodeId),
|
||||
key(other.key)
|
||||
SipInfoPrivate( const SipInfoPrivate& other )
|
||||
: QSharedData( other )
|
||||
, visible( other.visible )
|
||||
, host( other.host )
|
||||
, port( other.port )
|
||||
, nodeId( other.nodeId )
|
||||
, key( other.key )
|
||||
{
|
||||
}
|
||||
~SipInfoPrivate() { }
|
||||
@@ -93,7 +94,7 @@ SipInfo::clear()
|
||||
bool
|
||||
SipInfo::isValid() const
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO << d->visible << d->host.hostName() << d->port << d->nodeId << d->key;
|
||||
// tDebug() << Q_FUNC_INFO << d->visible << d->host << d->port << d->nodeId << d->key;
|
||||
if ( !d->visible.isNull() )
|
||||
{
|
||||
if (
|
||||
@@ -250,7 +251,9 @@ operator<< ( QDebug dbg, const SipInfo& info )
|
||||
return dbg.maybeSpace();
|
||||
}
|
||||
|
||||
bool operator==( const SipInfo& one, const SipInfo& two )
|
||||
|
||||
bool
|
||||
operator==( const SipInfo& one, const SipInfo& two )
|
||||
{
|
||||
// check valid/invalid combinations first, so we don't try to access any invalid sipInfos (->assert)
|
||||
if ( ( one.isValid() && !two.isValid() ) || ( !one.isValid() && two.isValid() ) )
|
||||
@@ -272,6 +275,7 @@ bool operator==( const SipInfo& one, const SipInfo& two )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const QString
|
||||
SipInfo::debugString() const
|
||||
{
|
||||
@@ -281,6 +285,5 @@ SipInfo::debugString() const
|
||||
.arg( d->port )
|
||||
.arg( d->nodeId )
|
||||
.arg( d->key );
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user