mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 07:36:48 +02:00
Wait for versionString in Xmpp until telling Servent SipInfos
This commit is contained in:
@@ -879,12 +879,22 @@ XmppSipPlugin::onNewIq( const Jreen::IQ& iq )
|
|||||||
Jreen::SoftwareVersion::Ptr softwareVersion = iq.payload<Jreen::SoftwareVersion>();
|
Jreen::SoftwareVersion::Ptr softwareVersion = iq.payload<Jreen::SoftwareVersion>();
|
||||||
if ( softwareVersion )
|
if ( softwareVersion )
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker( &peerQueueMutex );
|
||||||
QString versionString = QString( "%1 %2 %3" ).arg( softwareVersion->name(), softwareVersion->os(), softwareVersion->version() );
|
QString versionString = QString( "%1 %2 %3" ).arg( softwareVersion->name(), softwareVersion->os(), softwareVersion->version() );
|
||||||
qDebug() << Q_FUNC_INFO << "Received software version for" << iq.from().full() << ":" << versionString;
|
qDebug() << Q_FUNC_INFO << "Received software version for" << iq.from().full() << ":" << versionString;
|
||||||
Tomahawk::peerinfo_ptr peerInfo = PeerInfo::get( this, iq.from().full() );
|
Tomahawk::peerinfo_ptr peerInfo = PeerInfo::get( this, iq.from().full() );
|
||||||
if ( !peerInfo.isNull() )
|
if ( !peerInfo.isNull() )
|
||||||
{
|
{
|
||||||
peerInfo->setVersionString( versionString );
|
peerInfo->setVersionString( versionString );
|
||||||
|
if ( sipinfosQueue.contains( iq.from().full() ) )
|
||||||
|
{
|
||||||
|
peerInfo->setSipInfos( sipinfosQueue.value( iq.from().full() ) );
|
||||||
|
sipinfosQueue.remove( iq.from().full() );
|
||||||
|
}
|
||||||
|
if ( peersWaitingForVersionString.contains( iq.from().full() ) )
|
||||||
|
{
|
||||||
|
peersWaitingForVersionString.remove( iq.from().full() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -905,6 +915,7 @@ XmppSipPlugin::onNewIq( const Jreen::IQ& iq )
|
|||||||
TomahawkXmppMessage::Ptr sipMessage = iq.payload< TomahawkXmppMessage >();
|
TomahawkXmppMessage::Ptr sipMessage = iq.payload< TomahawkXmppMessage >();
|
||||||
if ( sipMessage )
|
if ( sipMessage )
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker( &peerQueueMutex );
|
||||||
iq.accept();
|
iq.accept();
|
||||||
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Received Sip Information from:" << iq.from().full();
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Received Sip Information from:" << iq.from().full();
|
||||||
|
|
||||||
@@ -921,7 +932,15 @@ XmppSipPlugin::onNewIq( const Jreen::IQ& iq )
|
|||||||
tDebug() << Q_FUNC_INFO << "no valid peerInfo for" << iq.from().full();
|
tDebug() << Q_FUNC_INFO << "no valid peerInfo for" << iq.from().full();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ( peerInfo->versionString().isEmpty() )
|
||||||
|
{
|
||||||
|
// If we do not have a version string, this peerInfo is still queued. So we queue its SipInfo until we have a valid version string.
|
||||||
|
sipinfosQueue[iq.from().full()] = sipMessage->sipInfos();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
peerInfo->setSipInfos( sipMessage->sipInfos() );
|
peerInfo->setSipInfos( sipMessage->sipInfos() );
|
||||||
|
}
|
||||||
// If we stored a reference for this peer in our sip-waiting-queue, remove it.
|
// If we stored a reference for this peer in our sip-waiting-queue, remove it.
|
||||||
if ( peersWaitingForSip.contains( iq.from().full() ) )
|
if ( peersWaitingForSip.contains( iq.from().full() ) )
|
||||||
{
|
{
|
||||||
@@ -968,12 +987,21 @@ XmppSipPlugin::handlePeerStatus( const Jreen::JID& jid, Jreen::Presence::Type pr
|
|||||||
Tomahawk::peerinfo_ptr peerInfo = PeerInfo::get( this, fulljid );
|
Tomahawk::peerinfo_ptr peerInfo = PeerInfo::get( this, fulljid );
|
||||||
if ( !peerInfo.isNull() )
|
if ( !peerInfo.isNull() )
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker( &peerQueueMutex );
|
||||||
peerInfo->setStatus( PeerInfo::Offline );
|
peerInfo->setStatus( PeerInfo::Offline );
|
||||||
// If we stored a reference for this peer in our sip-waiting-queue, remove it.
|
// If we stored a reference for this peer in our sip-waiting-queue, remove it.
|
||||||
if ( peersWaitingForSip.contains( fulljid ) )
|
if ( peersWaitingForSip.contains( fulljid ) )
|
||||||
{
|
{
|
||||||
peersWaitingForSip.remove( fulljid );
|
peersWaitingForSip.remove( fulljid );
|
||||||
}
|
}
|
||||||
|
if ( peersWaitingForVersionString.contains( fulljid ) )
|
||||||
|
{
|
||||||
|
peersWaitingForVersionString.remove( fulljid );
|
||||||
|
}
|
||||||
|
if ( sipinfosQueue.contains( fulljid ) )
|
||||||
|
{
|
||||||
|
sipinfosQueue.remove( fulljid );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -985,6 +1013,7 @@ XmppSipPlugin::handlePeerStatus( const Jreen::JID& jid, Jreen::Presence::Type pr
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "* Peer goes online:" << fulljid;
|
qDebug() << Q_FUNC_INFO << "* Peer goes online:" << fulljid;
|
||||||
|
|
||||||
|
QMutexLocker locker( &peerQueueMutex );
|
||||||
m_peers[ jid ] = presenceType;
|
m_peers[ jid ] = presenceType;
|
||||||
|
|
||||||
Tomahawk::peerinfo_ptr peerInfo = PeerInfo::get( this, fulljid, PeerInfo::AutoCreate );
|
Tomahawk::peerinfo_ptr peerInfo = PeerInfo::get( this, fulljid, PeerInfo::AutoCreate );
|
||||||
@@ -992,6 +1021,7 @@ XmppSipPlugin::handlePeerStatus( const Jreen::JID& jid, Jreen::Presence::Type pr
|
|||||||
peerInfo->setStatus( PeerInfo::Online );
|
peerInfo->setStatus( PeerInfo::Online );
|
||||||
peerInfo->setFriendlyName( m_jidsNames.value( jid.bare() ) );
|
peerInfo->setFriendlyName( m_jidsNames.value( jid.bare() ) );
|
||||||
peersWaitingForSip[fulljid] = peerInfo;
|
peersWaitingForSip[fulljid] = peerInfo;
|
||||||
|
peersWaitingForVersionString[fulljid] = peerInfo;
|
||||||
|
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
if ( !m_avatarManager->avatar( jid.bare() ).isNull() )
|
if ( !m_avatarManager->avatar( jid.bare() ).isNull() )
|
||||||
|
@@ -154,6 +154,9 @@ private:
|
|||||||
AvatarManager* m_avatarManager;
|
AvatarManager* m_avatarManager;
|
||||||
Jreen::PubSub::Manager* m_pubSubManager;
|
Jreen::PubSub::Manager* m_pubSubManager;
|
||||||
QMap< QString, Tomahawk::peerinfo_ptr > peersWaitingForSip;
|
QMap< QString, Tomahawk::peerinfo_ptr > peersWaitingForSip;
|
||||||
|
QMap< QString, Tomahawk::peerinfo_ptr > peersWaitingForVersionString;
|
||||||
|
QMap< QString, QList< SipInfo > > sipinfosQueue;
|
||||||
|
QMutex peerQueueMutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -46,10 +46,11 @@ ConnectionManager::handleSipInfoPrivate( const Tomahawk::peerinfo_ptr &peerInfo
|
|||||||
{
|
{
|
||||||
m_mutex.lock();
|
m_mutex.lock();
|
||||||
// Respect different behaviour before 0.7.99
|
// Respect different behaviour before 0.7.99
|
||||||
if ( !peerInfo->versionString().isEmpty() && TomahawkUtils::compareVersionStrings( peerInfo->versionString(), "Tomahawk Player EmptyOS 0.7.99" ) < 0)
|
peerInfoDebug( peerInfo ) << Q_FUNC_INFO << "Trying to connect to client with version " << peerInfo->versionString().split(' ').last() << TomahawkUtils::compareVersionStrings( peerInfo->versionString().split(' ').last(), "0.7.99" );
|
||||||
|
if ( !peerInfo->versionString().isEmpty() && TomahawkUtils::compareVersionStrings( peerInfo->versionString().split(' ').last(), "0.7.99" ) < 0)
|
||||||
{
|
{
|
||||||
peerInfoDebug( peerInfo ) << Q_FUNC_INFO << "Using old-style (<0.7.99) connection order.";
|
peerInfoDebug( peerInfo ) << Q_FUNC_INFO << "Using old-style (<0.7.99) connection order.";
|
||||||
SipInfo we = Servent::getSipInfoForOldVersions( Servent::instance()->getLocalSipInfos( QString(), QString() ) );
|
SipInfo we = Servent::getSipInfoForOldVersions( Servent::instance()->getLocalSipInfos( QString( "default" ), QString( "default" ) ) );
|
||||||
SipInfo they = peerInfo->sipInfos().first();
|
SipInfo they = peerInfo->sipInfos().first();
|
||||||
if ( they.isVisible() )
|
if ( they.isVisible() )
|
||||||
{
|
{
|
||||||
|
@@ -485,7 +485,7 @@ Servent::registerPeer( const Tomahawk::peerinfo_ptr& peerInfo )
|
|||||||
// The offer should be removed after some time or we will build up a heap of unused PeerInfos
|
// The offer should be removed after some time or we will build up a heap of unused PeerInfos
|
||||||
registerLazyOffer( key, peerInfo, nodeid, sipInfos.length() * 1.5 * CONNECT_TIMEOUT );
|
registerLazyOffer( key, peerInfo, nodeid, sipInfos.length() * 1.5 * CONNECT_TIMEOUT );
|
||||||
// SipInfos were single-value before 0.7.999
|
// SipInfos were single-value before 0.7.999
|
||||||
if ( !peerInfo->versionString().isEmpty() && TomahawkUtils::compareVersionStrings( peerInfo->versionString(), "Tomahawk Player EmptyOS 0.7.99" ) < 0)
|
if ( !peerInfo->versionString().isEmpty() && TomahawkUtils::compareVersionStrings( peerInfo->versionString().split(' ').last(), "0.7.99" ) < 0)
|
||||||
{
|
{
|
||||||
SipInfo info = getSipInfoForOldVersions( sipInfos );
|
SipInfo info = getSipInfoForOldVersions( sipInfos );
|
||||||
peerInfo->sendLocalSipInfos( QList<SipInfo>() << info );
|
peerInfo->sendLocalSipInfos( QList<SipInfo>() << info );
|
||||||
|
Reference in New Issue
Block a user