mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 00:09:47 +01: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:
parent
59a30573ee
commit
d7c03e03ce
@ -880,7 +880,7 @@ XmppSipPlugin::onNewIq( const Jreen::IQ& iq )
|
||||
handlePeerStatus( jid, Jreen::Presence::Available );
|
||||
}
|
||||
}
|
||||
else if ( context == RequestVersion)
|
||||
else if ( context == RequestVersion )
|
||||
{
|
||||
Jreen::SoftwareVersion::Ptr softwareVersion = iq.payload<Jreen::SoftwareVersion>();
|
||||
if ( softwareVersion )
|
||||
@ -932,7 +932,7 @@ XmppSipPlugin::onNewIq( const Jreen::IQ& iq )
|
||||
Tomahawk::peerinfo_ptr peerInfo = PeerInfo::get( this, iq.from().full() );
|
||||
if ( peerInfo.isNull() )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "no valid peerInfo for " << iq.from().full();
|
||||
tDebug() << Q_FUNC_INFO << "no valid peerInfo for" << iq.from().full();
|
||||
return;
|
||||
}
|
||||
peerInfo->setSipInfo( info );
|
||||
|
@ -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,17 +336,17 @@ Servent::registerPeer( const Tomahawk::peerinfo_ptr& peerInfo )
|
||||
else
|
||||
{
|
||||
SipInfo info;
|
||||
QString peerId = peerInfo->id();
|
||||
QString key = uuid();
|
||||
ControlConnection* conn = new ControlConnection( this );
|
||||
|
||||
const QString& nodeid = Database::instance()->impl()->dbid();
|
||||
conn->setName( peerInfo->contactId() );
|
||||
conn->setId( nodeid );
|
||||
conn->addPeerInfo( peerInfo );
|
||||
|
||||
if ( visibleExternally() )
|
||||
{
|
||||
QString peerId = peerInfo->id();
|
||||
QString key = uuid();
|
||||
ControlConnection* conn = new ControlConnection( this );
|
||||
|
||||
const QString& nodeid = Database::instance()->impl()->dbid();
|
||||
conn->setName( peerInfo->contactId() );
|
||||
conn->setId( nodeid );
|
||||
conn->addPeerInfo( peerInfo );
|
||||
|
||||
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 );
|
||||
@ -787,7 +791,7 @@ Servent::connectToPeer( const peerinfo_ptr& peerInfo )
|
||||
|
||||
|
||||
void
|
||||
Servent::connectToPeer( const QString& ha, int port, const QString &key, Connection* conn )
|
||||
Servent::connectToPeer( const QString& ha, int port, const QString& key, Connection* conn )
|
||||
{
|
||||
tDebug( LOGVERBOSE ) << "Servent::connectToPeer:" << ha << ":" << port
|
||||
<< thread() << QThread::currentThread();
|
||||
|
@ -118,8 +118,8 @@ public slots:
|
||||
|
||||
public:
|
||||
void connectToPeer( const Tomahawk::peerinfo_ptr& ha );
|
||||
void connectToPeer( const QString& ha, int port, const QString &key, Connection* conn );
|
||||
void reverseOfferRequest( ControlConnection* orig_conn, const QString &theirdbid, const QString& key, const QString& theirkey );
|
||||
void connectToPeer( const QString& ha, int port, const QString& key, Connection* conn );
|
||||
void reverseOfferRequest( ControlConnection* orig_conn, const QString& theirdbid, const QString& key, const QString& theirkey );
|
||||
|
||||
bool visibleExternally() const { return !m_externalHostname.isNull() || (m_externalPort > 0 && !m_externalAddress.isNull()); }
|
||||
QString externalAddress() const { return !m_externalHostname.isNull() ? m_externalHostname : m_externalAddress.toString(); }
|
||||
|
@ -263,7 +263,7 @@ PeerInfo::setSipInfo( const SipInfo& sipInfo )
|
||||
|
||||
m_sipInfo = sipInfo;
|
||||
|
||||
tLog() << "id: " << id() << " info changed" << sipInfo;
|
||||
tLog() << "id:" << id() << "info changed" << sipInfo;
|
||||
emit sipInfoChanged();
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ PeerInfo::setAvatar( const QPixmap& avatar )
|
||||
|
||||
m_avatarHash = hash;
|
||||
m_avatarBuffer = ba;
|
||||
|
||||
|
||||
delete m_avatar;
|
||||
delete m_fancyAvatar;
|
||||
m_avatar = 0;
|
||||
@ -331,7 +331,7 @@ PeerInfo::avatar( TomahawkUtils::ImageMode style, const QSize& size ) const
|
||||
delete m_avatar;
|
||||
m_avatar = 0;
|
||||
}
|
||||
|
||||
|
||||
m_avatarBuffer.clear();
|
||||
}
|
||||
|
||||
|
@ -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,10 +94,10 @@ SipInfo::clear()
|
||||
bool
|
||||
SipInfo::isValid() const
|
||||
{
|
||||
// qDebug() << Q_FUNC_INFO << d->visible << d->host.hostName() << d->port << d->nodeId << d->key;
|
||||
if( !d->visible.isNull() )
|
||||
// tDebug() << Q_FUNC_INFO << d->visible << d->host << d->port << d->nodeId << d->key;
|
||||
if ( !d->visible.isNull() )
|
||||
{
|
||||
if(
|
||||
if (
|
||||
// visible and all data available
|
||||
( d->visible.toBool() && !d->host.isEmpty() && ( d->port > 0 ) && !d->nodeId.isNull() && !d->key.isNull() )
|
||||
// invisible and no data available
|
||||
@ -112,7 +113,7 @@ SipInfo::isValid() const
|
||||
void
|
||||
SipInfo::setVisible( bool visible )
|
||||
{
|
||||
d->visible.setValue(visible);
|
||||
d->visible.setValue( visible );
|
||||
}
|
||||
|
||||
|
||||
@ -195,7 +196,7 @@ SipInfo::toJson() const
|
||||
// build variant map
|
||||
QVariantMap m;
|
||||
m["visible"] = isVisible();
|
||||
if( isVisible() )
|
||||
if ( isVisible() )
|
||||
{
|
||||
m["ip"] = host();
|
||||
m["port"] = port();
|
||||
@ -227,7 +228,7 @@ SipInfo::fromJson( QString json )
|
||||
QVariantMap m = v.toMap();
|
||||
|
||||
info.setVisible( m["visible"].toBool() );
|
||||
if( m["visible"].toBool() )
|
||||
if ( m["visible"].toBool() )
|
||||
{
|
||||
info.setHost( m["host"].toString() );
|
||||
info.setPort( m["port"].toInt() );
|
||||
@ -242,7 +243,7 @@ SipInfo::fromJson( QString json )
|
||||
QDebug
|
||||
operator<< ( QDebug dbg, const SipInfo& info )
|
||||
{
|
||||
if( !info.isValid() )
|
||||
if ( !info.isValid() )
|
||||
dbg.nospace() << "info is invalid";
|
||||
else
|
||||
dbg.nospace() << info.toJson();
|
||||
@ -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 );
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user