mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Moved zeroconf code into a separate sip plugin (we might want to re-think the SipPlugin interface).
This commit is contained in:
@@ -30,7 +30,6 @@
|
|||||||
class AudioEngine;
|
class AudioEngine;
|
||||||
class Database;
|
class Database;
|
||||||
class SipHandler;
|
class SipHandler;
|
||||||
class TomahawkZeroconf;
|
|
||||||
class TomahawkSettings;
|
class TomahawkSettings;
|
||||||
class XMPPBot;
|
class XMPPBot;
|
||||||
|
|
||||||
@@ -97,9 +96,6 @@ signals:
|
|||||||
public slots:
|
public slots:
|
||||||
QSharedPointer<QIODevice> getIODeviceForUrl( const Tomahawk::result_ptr& result );
|
QSharedPointer<QIODevice> getIODeviceForUrl( const Tomahawk::result_ptr& result );
|
||||||
|
|
||||||
private slots:
|
|
||||||
void lanHostFound( const QString&, int, const QString&, const QString& );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initLocalCollection();
|
void initLocalCollection();
|
||||||
void loadPlugins();
|
void loadPlugins();
|
||||||
@@ -118,7 +114,6 @@ private:
|
|||||||
Database* m_db;
|
Database* m_db;
|
||||||
Servent m_servent;
|
Servent m_servent;
|
||||||
SourceList m_sources;
|
SourceList m_sources;
|
||||||
TomahawkZeroconf* m_zeroconf;
|
|
||||||
SipHandler* m_sipHandler;
|
SipHandler* m_sipHandler;
|
||||||
XMPPBot* m_xmppBot;
|
XMPPBot* m_xmppBot;
|
||||||
|
|
||||||
|
@@ -225,7 +225,6 @@ SET( tomahawkHeaders ${tomahawkHeaders}
|
|||||||
musicscanner.h
|
musicscanner.h
|
||||||
scriptresolver.h
|
scriptresolver.h
|
||||||
tomahawksettings.h
|
tomahawksettings.h
|
||||||
tomahawkzeroconf.h
|
|
||||||
|
|
||||||
scrobbler.h
|
scrobbler.h
|
||||||
xmppbot/xmppbot.h
|
xmppbot/xmppbot.h
|
||||||
@@ -332,6 +331,7 @@ IF( UNIX )
|
|||||||
ENDIF( UNIX )
|
ENDIF( UNIX )
|
||||||
|
|
||||||
ADD_SUBDIRECTORY( sip/jabber )
|
ADD_SUBDIRECTORY( sip/jabber )
|
||||||
|
ADD_SUBDIRECTORY( sip/zeroconf )
|
||||||
|
|
||||||
kde4_add_app_icon( tomahawkSources "${CMAKE_CURRENT_SOURCE_DIR}/../data/icons/tomahawk-icon-*.png" )
|
kde4_add_app_icon( tomahawkSources "${CMAKE_CURRENT_SOURCE_DIR}/../data/icons/tomahawk-icon-*.png" )
|
||||||
qt4_add_resources( RC_SRCS "../resources.qrc" )
|
qt4_add_resources( RC_SRCS "../resources.qrc" )
|
||||||
|
@@ -30,16 +30,17 @@ SipHandler::loadPlugins()
|
|||||||
QDir pluginsDir( TomahawkApp::instance()->applicationDirPath() );
|
QDir pluginsDir( TomahawkApp::instance()->applicationDirPath() );
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
if (pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release")
|
if ( pluginsDir.dirName().toLower() == "debug" || pluginsDir.dirName().toLower() == "release" )
|
||||||
pluginsDir.cdUp();
|
pluginsDir.cdUp();
|
||||||
#elif defined(Q_OS_MAC)
|
#elif defined(Q_OS_MAC)
|
||||||
if (pluginsDir.dirName() == "MacOS") {
|
if ( pluginsDir.dirName() == "MacOS" )
|
||||||
|
{
|
||||||
pluginsDir.cdUp();
|
pluginsDir.cdUp();
|
||||||
pluginsDir.cdUp();
|
pluginsDir.cdUp();
|
||||||
pluginsDir.cdUp();
|
pluginsDir.cdUp();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
pluginsDir.cd("plugins");
|
pluginsDir.cd( "plugins" );
|
||||||
|
|
||||||
foreach ( QString fileName, pluginsDir.entryList( QDir::Files ) )
|
foreach ( QString fileName, pluginsDir.entryList( QDir::Files ) )
|
||||||
{
|
{
|
||||||
@@ -122,14 +123,6 @@ SipHandler::onPeerOnline( const QString& jid )
|
|||||||
conn->setName( jid.left( jid.indexOf( "/" ) ) );
|
conn->setName( jid.left( jid.indexOf( "/" ) ) );
|
||||||
conn->setId( nodeid );
|
conn->setId( nodeid );
|
||||||
|
|
||||||
// FIXME strip /resource, but we should use a UID per database install
|
|
||||||
//QString uniqname = jid.left( jid.indexOf("/") );
|
|
||||||
//conn->setName( uniqname ); //FIXME
|
|
||||||
|
|
||||||
// FIXME:
|
|
||||||
//QString ouruniqname = m_settings->value( "jabber/username" ).toString()
|
|
||||||
// .left( m_settings->value( "jabber/username" ).toString().indexOf("/") );
|
|
||||||
|
|
||||||
APP->servent().registerOffer( key, conn );
|
APP->servent().registerOffer( key, conn );
|
||||||
m["visible"] = true;
|
m["visible"] = true;
|
||||||
m["ip"] = APP->servent().externalAddress().toString();
|
m["ip"] = APP->servent().externalAddress().toString();
|
||||||
@@ -187,11 +180,11 @@ SipHandler::onMessage( const QString& from, const QString& msg )
|
|||||||
APP->servent().externalAddress().toString() <= m.value( "ip" ).toString() )
|
APP->servent().externalAddress().toString() <= m.value( "ip" ).toString() )
|
||||||
{
|
{
|
||||||
qDebug() << "Initiate connection to" << from;
|
qDebug() << "Initiate connection to" << from;
|
||||||
APP->servent().connectToPeer( m.value( "ip" ).toString(),
|
APP->servent().connectToPeer( m.value( "ip" ).toString(),
|
||||||
m.value( "port" ).toInt(),
|
m.value( "port" ).toInt(),
|
||||||
m.value( "key" ).toString(),
|
m.value( "key" ).toString(),
|
||||||
from,
|
from,
|
||||||
m.value( "uniqname" ).toString() );
|
m.value( "uniqname" ).toString() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -201,8 +194,6 @@ SipHandler::onMessage( const QString& from, const QString& msg )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "They are not visible, doing nothing atm";
|
qDebug() << Q_FUNC_INFO << "They are not visible, doing nothing atm";
|
||||||
// if ( m_servent.visibleExternally() )
|
|
||||||
// jabberPeerOnline( from ); // HACK FIXME
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@ signals:
|
|||||||
|
|
||||||
void peerOnline( const QString& );
|
void peerOnline( const QString& );
|
||||||
void peerOffline( const QString& );
|
void peerOffline( const QString& );
|
||||||
void msgReceived( const QString&, const QString& );
|
void msgReceived( const QString& from, const QString& msg );
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_INTERFACE( SipPlugin, "tomahawk.Sip/1.0" )
|
Q_DECLARE_INTERFACE( SipPlugin, "tomahawk.Sip/1.0" )
|
||||||
|
33
src/sip/zeroconf/CMakeLists.txt
Normal file
33
src/sip/zeroconf/CMakeLists.txt
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
project( tomahawk )
|
||||||
|
|
||||||
|
include( ${QT_USE_FILE} )
|
||||||
|
add_definitions( ${QT_DEFINITIONS} )
|
||||||
|
add_definitions( -DQT_PLUGIN )
|
||||||
|
add_definitions( -DQT_SHARED )
|
||||||
|
|
||||||
|
set( zeroconfSources
|
||||||
|
zeroconf.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set( zeroconfHeaders
|
||||||
|
zeroconf.h
|
||||||
|
tomahawkzeroconf.h
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ..
|
||||||
|
${QT_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
qt4_wrap_cpp( zeroconfMoc ${zeroconfHeaders} )
|
||||||
|
add_library( sip_zeroconf SHARED ${zeroconfSources} ${zeroconfMoc} )
|
||||||
|
|
||||||
|
target_link_libraries( sip_zeroconf
|
||||||
|
${QT_LIBRARIES}
|
||||||
|
${GLOOX_LIBS}
|
||||||
|
)
|
||||||
|
|
||||||
|
IF( APPLE )
|
||||||
|
SET( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-undefined dynamic_lookup" )
|
||||||
|
ENDIF( APPLE )
|
||||||
|
|
||||||
|
install( TARGETS sip_zeroconf DESTINATION . )
|
30
src/sip/zeroconf/zeroconf.cpp
Normal file
30
src/sip/zeroconf/zeroconf.cpp
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#include "zeroconf.h"
|
||||||
|
|
||||||
|
#include "tomahawk/tomahawkapp.h"
|
||||||
|
#include "tomahawksettings.h"
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
ZeroconfPlugin::connect()
|
||||||
|
{
|
||||||
|
delete m_zeroconf;
|
||||||
|
m_zeroconf = new TomahawkZeroconf( APP->servent().port(), this );
|
||||||
|
QObject::connect( m_zeroconf, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ),
|
||||||
|
SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) );
|
||||||
|
|
||||||
|
m_zeroconf->advertise();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ZeroconfPlugin::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid )
|
||||||
|
{
|
||||||
|
qDebug() << "Found LAN host:" << host << port << nodeid;
|
||||||
|
|
||||||
|
if ( !APP->servent().connectedToSession( nodeid ) )
|
||||||
|
APP->servent().connectToPeer( host, port, "whitelist", name, nodeid );
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_EXPORT_PLUGIN2( sip, ZeroconfPlugin )
|
45
src/sip/zeroconf/zeroconf.h
Normal file
45
src/sip/zeroconf/zeroconf.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#ifndef ZEROCONF_H
|
||||||
|
#define ZEROCONF_H
|
||||||
|
|
||||||
|
#include "SipPlugin.h"
|
||||||
|
#include "tomahawkzeroconf.h"
|
||||||
|
|
||||||
|
class ZeroconfPlugin : public SipPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_INTERFACES( SipPlugin )
|
||||||
|
|
||||||
|
public:
|
||||||
|
ZeroconfPlugin()
|
||||||
|
: m_zeroconf( 0 )
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual ~ZeroconfPlugin() {}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
virtual bool connect();
|
||||||
|
|
||||||
|
void disconnect()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void sendMsg( const QString& to, const QString& msg )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void broadcastMsg( const QString &msg )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void addContact( const QString &jid, const QString& msg = QString() )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid );
|
||||||
|
|
||||||
|
private:
|
||||||
|
TomahawkZeroconf* m_zeroconf;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@@ -21,7 +21,6 @@
|
|||||||
#include "scriptresolver.h"
|
#include "scriptresolver.h"
|
||||||
|
|
||||||
#include "audioengine.h"
|
#include "audioengine.h"
|
||||||
#include "tomahawkzeroconf.h"
|
|
||||||
|
|
||||||
#ifndef TOMAHAWK_HEADLESS
|
#ifndef TOMAHAWK_HEADLESS
|
||||||
#include "tomahawkwindow.h"
|
#include "tomahawkwindow.h"
|
||||||
@@ -102,7 +101,6 @@ using namespace Tomahawk;
|
|||||||
TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
||||||
: TOMAHAWK_APPLICATION( argc, argv )
|
: TOMAHAWK_APPLICATION( argc, argv )
|
||||||
, m_audioEngine( 0 )
|
, m_audioEngine( 0 )
|
||||||
, m_zeroconf( 0 )
|
|
||||||
, m_settings( 0 )
|
, m_settings( 0 )
|
||||||
, m_nam( 0 )
|
, m_nam( 0 )
|
||||||
, m_proxy( 0 )
|
, m_proxy( 0 )
|
||||||
@@ -198,15 +196,6 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
|||||||
if( arguments().contains( "--http" ) || settings()->value( "network/http", true ).toBool() )
|
if( arguments().contains( "--http" ) || settings()->value( "network/http", true ).toBool() )
|
||||||
startHTTP();
|
startHTTP();
|
||||||
|
|
||||||
if ( !arguments().contains( "--nozeroconf" ) )
|
|
||||||
{
|
|
||||||
// advertise our servent on the LAN
|
|
||||||
m_zeroconf = new TomahawkZeroconf( m_servent.port(), this );
|
|
||||||
connect( m_zeroconf, SIGNAL( tomahawkHostFound( const QString&, int, const QString&, const QString& ) ),
|
|
||||||
SLOT( lanHostFound( const QString&, int, const QString&, const QString& ) ) );
|
|
||||||
m_zeroconf->advertise();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_sipHandler->connect();
|
m_sipHandler->connect();
|
||||||
|
|
||||||
#ifndef TOMAHAWK_HEADLESS
|
#ifndef TOMAHAWK_HEADLESS
|
||||||
@@ -229,7 +218,6 @@ TomahawkApp::~TomahawkApp()
|
|||||||
delete m_audioEngine;
|
delete m_audioEngine;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete m_zeroconf;
|
|
||||||
delete m_db;
|
delete m_db;
|
||||||
m_db = 0;
|
m_db = 0;
|
||||||
|
|
||||||
@@ -316,16 +304,6 @@ TomahawkApp::setupDatabase()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TomahawkApp::lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid )
|
|
||||||
{
|
|
||||||
qDebug() << "Found LAN host:" << host << port << nodeid;
|
|
||||||
|
|
||||||
if ( !m_servent.connectedToSession( nodeid ) )
|
|
||||||
m_servent.connectToPeer( host, port, "whitelist", name, nodeid );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkApp::startHTTP()
|
TomahawkApp::startHTTP()
|
||||||
{
|
{
|
||||||
|
@@ -170,7 +170,7 @@ TomahawkWindow::setupSignals()
|
|||||||
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
|
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
|
||||||
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
|
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
|
||||||
connect( ui->actionExit, SIGNAL( triggered() ), APP, SLOT( quit() ) );
|
connect( ui->actionExit, SIGNAL( triggered() ), APP, SLOT( quit() ) );
|
||||||
connect( ui->statusButton, SIGNAL( clicked() ), APP->sipHandler(), SLOT(toggleConnect() ) );
|
connect( ui->statusButton, SIGNAL( clicked() ), APP->sipHandler(), SLOT( toggleConnect() ) );
|
||||||
|
|
||||||
// <SipHandler>
|
// <SipHandler>
|
||||||
connect( APP->sipHandler(), SIGNAL( connected() ), SLOT( onSipConnected() ) );
|
connect( APP->sipHandler(), SIGNAL( connected() ), SLOT( onSipConnected() ) );
|
||||||
|
Reference in New Issue
Block a user