mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-15 02:24:50 +02:00
* Moved zeroconf cache back in place.
This commit is contained in:
@@ -27,6 +27,7 @@ SipHandler::~SipHandler()
|
|||||||
disconnectPlugins();
|
disconnectPlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList< SipPlugin* >
|
QList< SipPlugin* >
|
||||||
SipHandler::plugins() const
|
SipHandler::plugins() const
|
||||||
{
|
{
|
||||||
|
@@ -61,10 +61,16 @@ public:
|
|||||||
TomahawkZeroconf( int port, QObject* parent = 0 )
|
TomahawkZeroconf( int port, QObject* parent = 0 )
|
||||||
: QObject( parent ), m_sock( this ), m_port( port )
|
: QObject( parent ), m_sock( this ), m_port( port )
|
||||||
{
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
m_sock.bind( ZCONF_PORT, QUdpSocket::ShareAddress );
|
m_sock.bind( ZCONF_PORT, QUdpSocket::ShareAddress );
|
||||||
connect( &m_sock, SIGNAL( readyRead() ), this, SLOT( readPacket() ) );
|
connect( &m_sock, SIGNAL( readyRead() ), this, SLOT( readPacket() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ~TomahawkZeroconf()
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void advertise()
|
void advertise()
|
||||||
{
|
{
|
||||||
@@ -107,8 +113,8 @@ private slots:
|
|||||||
{
|
{
|
||||||
qDebug() << "ADVERT received:" << sender << port;
|
qDebug() << "ADVERT received:" << sender << port;
|
||||||
Node *n = new Node( sender.toString(), parts.at( 2 ), port );
|
Node *n = new Node( sender.toString(), parts.at( 2 ), port );
|
||||||
connect( n, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ),
|
connect( n, SIGNAL( tomahawkHostFound( QString, int, QString, QString ) ),
|
||||||
this, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ) );
|
this, SIGNAL( tomahawkHostFound( QString, int, QString, QString ) ) );
|
||||||
n->resolve();
|
n->resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,12 +25,21 @@ ZeroconfPlugin::connectPlugin( bool /*startup*/ )
|
|||||||
{
|
{
|
||||||
delete m_zeroconf;
|
delete m_zeroconf;
|
||||||
m_zeroconf = new TomahawkZeroconf( Servent::instance()->port(), this );
|
m_zeroconf = new TomahawkZeroconf( Servent::instance()->port(), this );
|
||||||
QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ),
|
QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( QString, int, QString, QString ) ),
|
||||||
SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) );
|
SLOT( lanHostFound( QString, int, QString, QString ) ) );
|
||||||
|
|
||||||
m_zeroconf->advertise();
|
m_zeroconf->advertise();
|
||||||
m_isOnline = true;
|
m_isOnline = true;
|
||||||
|
|
||||||
|
foreach( QStringList *currNode, m_cachedNodes )
|
||||||
|
{
|
||||||
|
QStringList nodeSet = *currNode;
|
||||||
|
if ( !Servent::instance()->connectedToSession( nodeSet[3] ) )
|
||||||
|
Servent::instance()->connectToPeer( nodeSet[0], nodeSet[1].toInt(), "whitelist", nodeSet[2], nodeSet[3] );
|
||||||
|
|
||||||
|
delete currNode;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,8 +48,6 @@ ZeroconfPlugin::disconnectPlugin()
|
|||||||
{
|
{
|
||||||
m_isOnline = false;
|
m_isOnline = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
delete m_zeroconf;
|
delete m_zeroconf;
|
||||||
m_zeroconf = 0;
|
m_zeroconf = 0;
|
||||||
}
|
}
|
||||||
@@ -52,6 +59,15 @@ ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
qDebug() << "Found LAN host:" << host << port << nodeid;
|
qDebug() << "Found LAN host:" << host << port << nodeid;
|
||||||
|
|
||||||
|
if ( !m_isOnline )
|
||||||
|
{
|
||||||
|
qDebug() << "Not online, so not connecting.";
|
||||||
|
QStringList *nodeSet = new QStringList();
|
||||||
|
*nodeSet << host << QString::number( port ) << name << nodeid;
|
||||||
|
m_cachedNodes.insert( nodeSet );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !Servent::instance()->connectedToSession( nodeid ) )
|
if ( !Servent::instance()->connectedToSession( nodeid ) )
|
||||||
Servent::instance()->connectToPeer( host, port, "whitelist", name, nodeid );
|
Servent::instance()->connectToPeer( host, port, "whitelist", name, nodeid );
|
||||||
|
@@ -17,6 +17,7 @@ public:
|
|||||||
ZeroconfPlugin()
|
ZeroconfPlugin()
|
||||||
: m_zeroconf( 0 )
|
: m_zeroconf( 0 )
|
||||||
, m_isOnline( false )
|
, m_isOnline( false )
|
||||||
|
, m_cachedNodes()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
}
|
}
|
||||||
@@ -54,6 +55,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
TomahawkZeroconf* m_zeroconf;
|
TomahawkZeroconf* m_zeroconf;
|
||||||
bool m_isOnline;
|
bool m_isOnline;
|
||||||
|
QSet< QStringList* > m_cachedNodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user