mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Lazily create ControlConnection for offers
This commit is contained in:
@@ -308,7 +308,12 @@ Servent::isValidExternalIP( const QHostAddress& addr )
|
|||||||
void
|
void
|
||||||
Servent::registerOffer( const QString& key, Connection* conn )
|
Servent::registerOffer( const QString& key, Connection* conn )
|
||||||
{
|
{
|
||||||
m_offers[key] = QPointer<Connection>(conn);
|
m_offers[key] = QPointer<Connection>(conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Servent::registerLazyOffer(const QString &key, const peerinfo_ptr &peerInfo, const QString &nodeid )
|
||||||
|
{
|
||||||
|
m_lazyoffers[key] = QPair< peerinfo_ptr, QString >( peerInfo, nodeid );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -430,12 +435,12 @@ Servent::registerPeer( const Tomahawk::peerinfo_ptr& peerInfo )
|
|||||||
QString key = uuid();
|
QString key = uuid();
|
||||||
const QString& nodeid = Database::instance()->impl()->dbid();
|
const QString& nodeid = Database::instance()->impl()->dbid();
|
||||||
|
|
||||||
ControlConnection* conn = new ControlConnection( this );
|
/*ControlConnection* conn = new ControlConnection( this );
|
||||||
conn->setName( peerInfo->contactId() );
|
conn->setName( peerInfo->contactId() );
|
||||||
conn->setId( nodeid );
|
conn->setId( nodeid );
|
||||||
conn->addPeerInfo( peerInfo );
|
conn->addPeerInfo( peerInfo );*/
|
||||||
|
|
||||||
registerOffer( key, conn );
|
registerLazyOffer( key, peerInfo, nodeid );
|
||||||
QList<SipInfo> sipInfos = getLocalSipInfos( nodeid, key );
|
QList<SipInfo> sipInfos = getLocalSipInfos( nodeid, key );
|
||||||
|
|
||||||
peerInfo->sendLocalSipInfos( sipInfos );
|
peerInfo->sendLocalSipInfos( sipInfos );
|
||||||
@@ -1044,7 +1049,20 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_offers.contains( key ) )
|
if ( m_lazyoffers.contains( key ) )
|
||||||
|
{
|
||||||
|
ControlConnection* conn = new ControlConnection( this );
|
||||||
|
conn->setName( m_lazyoffers.value( key ).first->contactId() );
|
||||||
|
conn->addPeerInfo( m_lazyoffers.value( key ).first );
|
||||||
|
conn->setId( m_lazyoffers.value( key ).second );
|
||||||
|
|
||||||
|
// Register as non-lazy offer
|
||||||
|
m_lazyoffers.remove( key );
|
||||||
|
registerOffer( key, conn );
|
||||||
|
|
||||||
|
return conn;
|
||||||
|
}
|
||||||
|
else if ( m_offers.contains( key ) )
|
||||||
{
|
{
|
||||||
QPointer<Connection> conn = m_offers.value( key );
|
QPointer<Connection> conn = m_offers.value( key );
|
||||||
if ( conn.isNull() )
|
if ( conn.isNull() )
|
||||||
|
@@ -76,6 +76,7 @@ public:
|
|||||||
QString createConnectionKey( const QString& name = "", const QString &nodeid = "", const QString &key = "", bool onceOnly = true );
|
QString createConnectionKey( const QString& name = "", const QString &nodeid = "", const QString &key = "", bool onceOnly = true );
|
||||||
|
|
||||||
void registerOffer( const QString& key, Connection* conn );
|
void registerOffer( const QString& key, Connection* conn );
|
||||||
|
void registerLazyOffer( const QString& key, const Tomahawk::peerinfo_ptr& peerInfo, const QString &nodeid );
|
||||||
|
|
||||||
void registerControlConnection( ControlConnection* conn );
|
void registerControlConnection( ControlConnection* conn );
|
||||||
void unregisterControlConnection( ControlConnection* conn );
|
void unregisterControlConnection( ControlConnection* conn );
|
||||||
@@ -166,6 +167,7 @@ private:
|
|||||||
QJson::Parser parser;
|
QJson::Parser parser;
|
||||||
QList< ControlConnection* > m_controlconnections; // canonical list of authed peers
|
QList< ControlConnection* > m_controlconnections; // canonical list of authed peers
|
||||||
QMap< QString, QPointer< Connection > > m_offers;
|
QMap< QString, QPointer< Connection > > m_offers;
|
||||||
|
QMap< QString, QPair< Tomahawk::peerinfo_ptr, QString > > m_lazyoffers;
|
||||||
QStringList m_connectedNodes;
|
QStringList m_connectedNodes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user