diff --git a/src/sip/SipHandler.cpp b/src/sip/SipHandler.cpp index 1a214c5c2..061720a5e 100644 --- a/src/sip/SipHandler.cpp +++ b/src/sip/SipHandler.cpp @@ -27,6 +27,7 @@ SipHandler::~SipHandler() disconnectPlugins(); } + QList< SipPlugin* > SipHandler::plugins() const { diff --git a/src/sip/zeroconf/tomahawkzeroconf.h b/src/sip/zeroconf/tomahawkzeroconf.h index 6630b865d..d80f1103a 100644 --- a/src/sip/zeroconf/tomahawkzeroconf.h +++ b/src/sip/zeroconf/tomahawkzeroconf.h @@ -61,10 +61,16 @@ public: TomahawkZeroconf( int port, QObject* parent = 0 ) : QObject( parent ), m_sock( this ), m_port( port ) { + qDebug() << Q_FUNC_INFO; m_sock.bind( ZCONF_PORT, QUdpSocket::ShareAddress ); connect( &m_sock, SIGNAL( readyRead() ), this, SLOT( readPacket() ) ); } + virtual ~TomahawkZeroconf() + { + qDebug() << Q_FUNC_INFO; + } + public slots: void advertise() { @@ -107,8 +113,8 @@ private slots: { qDebug() << "ADVERT received:" << sender << port; Node *n = new Node( sender.toString(), parts.at( 2 ), port ); - connect( n, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ), - this, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ) ); + connect( n, SIGNAL( tomahawkHostFound( QString, int, QString, QString ) ), + this, SIGNAL( tomahawkHostFound( QString, int, QString, QString ) ) ); n->resolve(); } } diff --git a/src/sip/zeroconf/zeroconf.cpp b/src/sip/zeroconf/zeroconf.cpp index b4c8fccba..3a567ea48 100644 --- a/src/sip/zeroconf/zeroconf.cpp +++ b/src/sip/zeroconf/zeroconf.cpp @@ -25,12 +25,21 @@ ZeroconfPlugin::connectPlugin( bool /*startup*/ ) { delete m_zeroconf; m_zeroconf = new TomahawkZeroconf( Servent::instance()->port(), this ); - QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ), - SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) ); + QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( QString, int, QString, QString ) ), + SLOT( lanHostFound( QString, int, QString, 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; + } + return true; } @@ -39,8 +48,6 @@ ZeroconfPlugin::disconnectPlugin() { m_isOnline = false; - - delete m_zeroconf; m_zeroconf = 0; } @@ -52,6 +59,15 @@ ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name return; 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 ); diff --git a/src/sip/zeroconf/zeroconf.h b/src/sip/zeroconf/zeroconf.h index 9f1620092..aa4926908 100644 --- a/src/sip/zeroconf/zeroconf.h +++ b/src/sip/zeroconf/zeroconf.h @@ -17,6 +17,7 @@ public: ZeroconfPlugin() : m_zeroconf( 0 ) , m_isOnline( false ) + , m_cachedNodes() { qDebug() << Q_FUNC_INFO; } @@ -54,6 +55,7 @@ private slots: private: TomahawkZeroconf* m_zeroconf; bool m_isOnline; + QSet< QStringList* > m_cachedNodes; }; #endif