1
0
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:
Jeff Mitchell
2011-02-13 00:22:53 -05:00
parent f097bc067d
commit 0a39139703
2 changed files with 30 additions and 3 deletions

View File

@@ -17,15 +17,40 @@ ZeroconfPlugin::connectPlugin( bool /*startup*/ )
SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) );
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;
}
void
ZeroconfPlugin::disconnectPlugin()
{
m_isOnline = false;
}
void
ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& 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 ) )
Servent::instance()->connectToPeer( host, port, "whitelist", name, nodeid );

View File

@@ -16,6 +16,8 @@ class SIPDLLEXPORT ZeroconfPlugin : public SipPlugin
public:
ZeroconfPlugin()
: m_zeroconf( 0 )
, m_isOnline( false )
, m_cachedNodes()
{}
virtual ~ZeroconfPlugin() {}
@@ -26,9 +28,7 @@ public:
public slots:
virtual bool connectPlugin( bool startup );
void disconnectPlugin()
{
}
void disconnectPlugin();
void sendMsg( const QString& to, const QString& msg )
{
@@ -47,6 +47,8 @@ private slots:
private:
TomahawkZeroconf* m_zeroconf;
bool m_isOnline;
QSet< QStringList* > m_cachedNodes;
};
#endif