mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Now zeroconf doesn't connect when offline either
This commit is contained in:
@@ -17,15 +17,40 @@ ZeroconfPlugin::connectPlugin( bool /*startup*/ )
|
|||||||
SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) );
|
SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) );
|
||||||
|
|
||||||
m_zeroconf->advertise();
|
m_zeroconf->advertise();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
m_cachedNodes.empty();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ZeroconfPlugin::disconnectPlugin()
|
||||||
|
{
|
||||||
|
m_isOnline = false;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid )
|
ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid )
|
||||||
{
|
{
|
||||||
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 );
|
||||||
|
@@ -16,6 +16,8 @@ class SIPDLLEXPORT ZeroconfPlugin : public SipPlugin
|
|||||||
public:
|
public:
|
||||||
ZeroconfPlugin()
|
ZeroconfPlugin()
|
||||||
: m_zeroconf( 0 )
|
: m_zeroconf( 0 )
|
||||||
|
, m_isOnline( false )
|
||||||
|
, m_cachedNodes()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual ~ZeroconfPlugin() {}
|
virtual ~ZeroconfPlugin() {}
|
||||||
@@ -26,9 +28,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
virtual bool connectPlugin( bool startup );
|
virtual bool connectPlugin( bool startup );
|
||||||
|
|
||||||
void disconnectPlugin()
|
void disconnectPlugin();
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void sendMsg( const QString& to, const QString& msg )
|
void sendMsg( const QString& to, const QString& msg )
|
||||||
{
|
{
|
||||||
@@ -47,6 +47,8 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
TomahawkZeroconf* m_zeroconf;
|
TomahawkZeroconf* m_zeroconf;
|
||||||
|
bool m_isOnline;
|
||||||
|
QSet< QStringList* > m_cachedNodes;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user