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 )
|
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() ) )
|
if ( !connectedToSession( peerInfo->sipInfo().nodeId() ) )
|
||||||
{
|
{
|
||||||
connectToPeer( peerInfo );
|
connectToPeer( peerInfo );
|
||||||
@@ -336,8 +336,6 @@ Servent::registerPeer( const Tomahawk::peerinfo_ptr& peerInfo )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SipInfo info;
|
SipInfo info;
|
||||||
if ( visibleExternally() )
|
|
||||||
{
|
|
||||||
QString peerId = peerInfo->id();
|
QString peerId = peerInfo->id();
|
||||||
QString key = uuid();
|
QString key = uuid();
|
||||||
ControlConnection* conn = new ControlConnection( this );
|
ControlConnection* conn = new ControlConnection( this );
|
||||||
@@ -347,6 +345,8 @@ Servent::registerPeer( const Tomahawk::peerinfo_ptr& peerInfo )
|
|||||||
conn->setId( nodeid );
|
conn->setId( nodeid );
|
||||||
conn->addPeerInfo( peerInfo );
|
conn->addPeerInfo( peerInfo );
|
||||||
|
|
||||||
|
if ( visibleExternally() )
|
||||||
|
{
|
||||||
registerOffer( key, conn );
|
registerOffer( key, conn );
|
||||||
info.setVisible( true );
|
info.setVisible( true );
|
||||||
info.setHost( externalAddress() );
|
info.setHost( externalAddress() );
|
||||||
@@ -414,6 +414,8 @@ void Servent::handleSipInfo( const Tomahawk::peerinfo_ptr& peerInfo )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO << "They are not visible, doing nothing atm";
|
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();
|
SipInfo sipInfo = peerInfo->sipInfo();
|
||||||
|
|
||||||
peerInfoDebug( peerInfo ) << "connectToPeer: search for already established connections to the same nodeid:" << m_controlconnections.count() << "connections";
|
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;
|
bool isDupe = false;
|
||||||
ControlConnection* conn = 0;
|
ControlConnection* conn = 0;
|
||||||
// try to find a ControlConnection with the same SipInfo, then we dont need to try to connect again
|
// try to find a ControlConnection with the same SipInfo, then we dont need to try to connect again
|
||||||
|
|
||||||
foreach ( ControlConnection* c, m_controlconnections )
|
foreach ( ControlConnection* c, m_controlconnections )
|
||||||
{
|
{
|
||||||
Q_ASSERT( c );
|
Q_ASSERT( c );
|
||||||
@@ -769,7 +774,6 @@ Servent::connectToPeer( const peerinfo_ptr& peerInfo )
|
|||||||
m["nodeid"] = Database::instance()->impl()->dbid();
|
m["nodeid"] = Database::instance()->impl()->dbid();
|
||||||
|
|
||||||
peerInfoDebug(peerInfo) << "No match found, creating a new ControlConnection...";
|
peerInfoDebug(peerInfo) << "No match found, creating a new ControlConnection...";
|
||||||
|
|
||||||
conn = new ControlConnection( this );
|
conn = new ControlConnection( this );
|
||||||
conn->addPeerInfo( peerInfo );
|
conn->addPeerInfo( peerInfo );
|
||||||
conn->setFirstMessage( m );
|
conn->setFirstMessage( m );
|
||||||
|
@@ -35,12 +35,13 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SipInfoPrivate( const SipInfoPrivate& other ) : QSharedData( other ),
|
SipInfoPrivate( const SipInfoPrivate& other )
|
||||||
visible(other.visible),
|
: QSharedData( other )
|
||||||
host(other.host),
|
, visible( other.visible )
|
||||||
port(other.port),
|
, host( other.host )
|
||||||
nodeId(other.nodeId),
|
, port( other.port )
|
||||||
key(other.key)
|
, nodeId( other.nodeId )
|
||||||
|
, key( other.key )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
~SipInfoPrivate() { }
|
~SipInfoPrivate() { }
|
||||||
@@ -93,7 +94,7 @@ SipInfo::clear()
|
|||||||
bool
|
bool
|
||||||
SipInfo::isValid() const
|
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 ( !d->visible.isNull() )
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
@@ -250,7 +251,9 @@ operator<< ( QDebug dbg, const SipInfo& info )
|
|||||||
return dbg.maybeSpace();
|
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)
|
// 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() ) )
|
if ( ( one.isValid() && !two.isValid() ) || ( !one.isValid() && two.isValid() ) )
|
||||||
@@ -272,6 +275,7 @@ bool operator==( const SipInfo& one, const SipInfo& two )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString
|
const QString
|
||||||
SipInfo::debugString() const
|
SipInfo::debugString() const
|
||||||
{
|
{
|
||||||
@@ -281,6 +285,5 @@ SipInfo::debugString() const
|
|||||||
.arg( d->port )
|
.arg( d->port )
|
||||||
.arg( d->nodeId )
|
.arg( d->nodeId )
|
||||||
.arg( d->key );
|
.arg( d->key );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user