mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Add Boost_INCLUDE_DIR and make less usage of boost in headers
* Make Servent member more private
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
include_directories(${ECHONEST_INCLUDE_DIR})
|
include_directories(
|
||||||
|
${ECHONEST_INCLUDE_DIR}
|
||||||
|
${Boost_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
list(APPEND simple_plugins
|
list(APPEND simple_plugins
|
||||||
Echonest
|
Echonest
|
||||||
|
@@ -391,6 +391,7 @@ include_directories(
|
|||||||
${ECHONEST_INCLUDE_DIR}
|
${ECHONEST_INCLUDE_DIR}
|
||||||
${CLUCENE_INCLUDE_DIRS}
|
${CLUCENE_INCLUDE_DIRS}
|
||||||
${PHONON_INCLUDES}
|
${PHONON_INCLUDES}
|
||||||
|
${Boost_INCLUDE_DIR}
|
||||||
|
|
||||||
${LIBPORTFWD_INCLUDE_DIR}
|
${LIBPORTFWD_INCLUDE_DIR}
|
||||||
${QuaZip_INCLUDE_DIR}
|
${QuaZip_INCLUDE_DIR}
|
||||||
|
@@ -22,12 +22,13 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
#include "boost/function.hpp"
|
#include <boost/function.hpp>
|
||||||
#include "boost/bind.hpp"
|
|
||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
I want to do:
|
I want to do:
|
||||||
QTimer::singleShot(1000, this, SLOT(doSomething(x)));
|
QTimer::singleShot(1000, this, SLOT(doSomething(x)));
|
||||||
instead, I'm doing:
|
instead, I'm doing:
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
#include "utils/ResultUrlChecker.h"
|
#include "utils/ResultUrlChecker.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
#include "boost/bind.hpp"
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
#define DEFAULT_CONCURRENT_QUERIES 4
|
#define DEFAULT_CONCURRENT_QUERIES 4
|
||||||
#define MAX_CONCURRENT_QUERIES 16
|
#define MAX_CONCURRENT_QUERIES 16
|
||||||
|
@@ -33,7 +33,6 @@
|
|||||||
#include "PlaylistInterface.h"
|
#include "PlaylistInterface.h"
|
||||||
#include "playlist/PlaylistUpdaterInterface.h"
|
#include "playlist/PlaylistUpdaterInterface.h"
|
||||||
#include "Query.h"
|
#include "Query.h"
|
||||||
#include "utils/Closure.h"
|
|
||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
@@ -44,6 +43,11 @@ class DatabaseCommand_SetPlaylistRevision;
|
|||||||
class DatabaseCommand_CreatePlaylist;
|
class DatabaseCommand_CreatePlaylist;
|
||||||
class PlaylistModel;
|
class PlaylistModel;
|
||||||
|
|
||||||
|
namespace _detail
|
||||||
|
{
|
||||||
|
class Closure;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@@ -26,8 +26,6 @@
|
|||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QPersistentModelIndex>
|
#include <QPersistentModelIndex>
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
|
|
||||||
//template <typename T> class QSharedPointer;
|
//template <typename T> class QSharedPointer;
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
@@ -100,7 +98,6 @@ namespace Tomahawk
|
|||||||
};
|
};
|
||||||
|
|
||||||
class ExternalResolver;
|
class ExternalResolver;
|
||||||
typedef boost::function<Tomahawk::ExternalResolver*( QString, QStringList )> ResolverFactoryFunc;
|
|
||||||
|
|
||||||
namespace PlaylistModes {
|
namespace PlaylistModes {
|
||||||
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
|
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "sip/SipStatusMessage.h"
|
#include "sip/SipStatusMessage.h"
|
||||||
#include "jobview/JobStatusView.h"
|
#include "jobview/JobStatusView.h"
|
||||||
#include "jobview/JobStatusModel.h"
|
#include "jobview/JobStatusModel.h"
|
||||||
|
#include "utils/Closure.h"
|
||||||
|
|
||||||
#include <QtCore/QLibrary>
|
#include <QtCore/QLibrary>
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
#include <phonon/AudioOutput>
|
#include <phonon/AudioOutput>
|
||||||
#include <phonon/BackendCapabilities>
|
#include <phonon/BackendCapabilities>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
@@ -46,7 +48,7 @@ private:
|
|||||||
QQueue< AudioState > stateQueue;
|
QQueue< AudioState > stateQueue;
|
||||||
QTimer stateQueueTimer;
|
QTimer stateQueueTimer;
|
||||||
|
|
||||||
uint_fast8_t underrunCount;
|
quint8 underrunCount;
|
||||||
bool underrunNotified;
|
bool underrunNotified;
|
||||||
|
|
||||||
QTemporaryFile* coverTempFile;
|
QTemporaryFile* coverTempFile;
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#include "playlist/PlaylistUpdaterInterface.h"
|
#include "playlist/PlaylistUpdaterInterface.h"
|
||||||
#include "utils/ImageRegistry.h"
|
#include "utils/ImageRegistry.h"
|
||||||
#include "accounts/AccountManager.h"
|
#include "accounts/AccountManager.h"
|
||||||
|
#include "utils/Closure.h"
|
||||||
|
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
#include <QGenericArgument>
|
#include <QGenericArgument>
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "Connection.h"
|
#include "Connection.h"
|
||||||
|
|
||||||
|
#include "QTcpSocketExtra.h"
|
||||||
#include "network/Servent.h"
|
#include "network/Servent.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "ConnectionManager.h"
|
#include "ConnectionManager.h"
|
||||||
#include "ControlConnection.h"
|
#include "ControlConnection.h"
|
||||||
|
#include "QTcpSocketExtra.h"
|
||||||
#include "Servent.h"
|
#include "Servent.h"
|
||||||
|
|
||||||
#include "database/Database.h"
|
#include "database/Database.h"
|
||||||
|
@@ -19,13 +19,14 @@
|
|||||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Servent.h"
|
#include "Servent_p.h"
|
||||||
|
|
||||||
#include "Result.h"
|
#include "Result.h"
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
#include "BufferIoDevice.h"
|
#include "BufferIoDevice.h"
|
||||||
#include "Connection.h"
|
#include "Connection.h"
|
||||||
#include "ControlConnection.h"
|
#include "ControlConnection.h"
|
||||||
|
#include "QTcpSocketExtra.h"
|
||||||
#include "database/Database.h"
|
#include "database/Database.h"
|
||||||
#include "database/DatabaseImpl.h"
|
#include "database/DatabaseImpl.h"
|
||||||
#include "network/ConnectionManager.h"
|
#include "network/ConnectionManager.h"
|
||||||
@@ -74,14 +75,12 @@ Servent::instance()
|
|||||||
|
|
||||||
|
|
||||||
Servent::Servent( QObject* parent )
|
Servent::Servent( QObject* parent )
|
||||||
: QTcpServer( parent )
|
: QTcpServer( parent ),
|
||||||
, m_port( 0 )
|
d_ptr( new ServentPrivate( this ) )
|
||||||
, m_externalPort( 0 )
|
|
||||||
, m_ready( false )
|
|
||||||
{
|
{
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
|
|
||||||
m_noAuth = qApp->arguments().contains( "--noauth" );
|
d_func()->noAuth = qApp->arguments().contains( "--noauth" );
|
||||||
|
|
||||||
setProxy( QNetworkProxy::NoProxy );
|
setProxy( QNetworkProxy::NoProxy );
|
||||||
|
|
||||||
@@ -108,14 +107,14 @@ Servent::~Servent()
|
|||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO;
|
tDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
foreach ( ControlConnection* cc, m_controlconnections )
|
foreach ( ControlConnection* cc, d_func()->controlconnections )
|
||||||
delete cc;
|
delete cc;
|
||||||
|
|
||||||
if ( m_portfwd )
|
if ( d_func()->portfwd )
|
||||||
{
|
{
|
||||||
m_portfwd.data()->quit();
|
d_func()->portfwd.data()->quit();
|
||||||
m_portfwd.data()->wait( 60000 );
|
d_func()->portfwd.data()->wait( 60000 );
|
||||||
delete m_portfwd.data();
|
delete d_func()->portfwd.data();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,25 +122,25 @@ Servent::~Servent()
|
|||||||
bool
|
bool
|
||||||
Servent::startListening( QHostAddress ha, bool upnp, int port )
|
Servent::startListening( QHostAddress ha, bool upnp, int port )
|
||||||
{
|
{
|
||||||
m_externalAddresses = QList<QHostAddress>();
|
d_func()->externalAddresses = QList<QHostAddress>();
|
||||||
m_port = port;
|
d_func()->port = port;
|
||||||
int defPort = TomahawkSettings::instance()->defaultPort();
|
int defPort = TomahawkSettings::instance()->defaultPort();
|
||||||
|
|
||||||
// Listen on both the selected port and, if not the same, the default port -- the latter sometimes necessary for zeroconf
|
// Listen on both the selected port and, if not the same, the default port -- the latter sometimes necessary for zeroconf
|
||||||
// TODO: only listen on both when zeroconf sip is enabled
|
// TODO: only listen on both when zeroconf sip is enabled
|
||||||
// TODO: use a real zeroconf system instead of a simple UDP broadcast?
|
// TODO: use a real zeroconf system instead of a simple UDP broadcast?
|
||||||
if ( !listen( ha, m_port ) )
|
if ( !listen( ha, d_func()->port ) )
|
||||||
{
|
{
|
||||||
if ( m_port != defPort )
|
if ( d_func()->port != defPort )
|
||||||
{
|
{
|
||||||
if ( !listen( ha, defPort ) )
|
if ( !listen( ha, defPort ) )
|
||||||
{
|
{
|
||||||
tLog() << Q_FUNC_INFO << "Failed to listen on both port" << m_port << "and port" << defPort;
|
tLog() << Q_FUNC_INFO << "Failed to listen on both port" << d_func()->port << "and port" << defPort;
|
||||||
tLog() << Q_FUNC_INFO << "Error string is:" << errorString();
|
tLog() << Q_FUNC_INFO << "Error string is:" << errorString();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_port = defPort;
|
d_func()->port = defPort;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,34 +158,34 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
|
|||||||
if ( addr.isInSubnet( QHostAddress::parseSubnet( "fe80::/10" ) ) )
|
if ( addr.isInSubnet( QHostAddress::parseSubnet( "fe80::/10" ) ) )
|
||||||
continue; // Skip link local addresses
|
continue; // Skip link local addresses
|
||||||
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Listening to " << addr.toString();
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Listening to " << addr.toString();
|
||||||
m_externalAddresses.append( addr );
|
d_func()->externalAddresses.append( addr );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if ( ( ha.toString() != "127.0.0.1" ) && ( ha.toString() != "::1" ) && ( ha.toString() != "::7F00:1" ) )
|
else if ( ( ha.toString() != "127.0.0.1" ) && ( ha.toString() != "::1" ) && ( ha.toString() != "::7F00:1" ) )
|
||||||
{
|
{
|
||||||
// We listen only to one specific Address, only announce this.
|
// We listen only to one specific Address, only announce this.
|
||||||
m_externalAddresses.append( ha );
|
d_func()->externalAddresses.append( ha );
|
||||||
}
|
}
|
||||||
// If we only accept connections via localhost, we'll announce nothing.
|
// If we only accept connections via localhost, we'll announce nothing.
|
||||||
|
|
||||||
TomahawkSettings::ExternalAddressMode mode = TomahawkSettings::instance()->externalAddressMode();
|
TomahawkSettings::ExternalAddressMode mode = TomahawkSettings::instance()->externalAddressMode();
|
||||||
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Servent listening on port" << m_port << "- servent thread:" << thread()
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Servent listening on port" << d_func()->port << "- servent thread:" << thread()
|
||||||
<< "- address mode:" << (int)( mode );
|
<< "- address mode:" << (int)( mode );
|
||||||
|
|
||||||
switch ( mode )
|
switch ( mode )
|
||||||
{
|
{
|
||||||
case TomahawkSettings::Static:
|
case TomahawkSettings::Static:
|
||||||
m_externalHostname = TomahawkSettings::instance()->externalHostname();
|
d_func()->externalHostname = TomahawkSettings::instance()->externalHostname();
|
||||||
m_externalPort = TomahawkSettings::instance()->externalPort();
|
d_func()->externalPort = TomahawkSettings::instance()->externalPort();
|
||||||
m_ready = true;
|
d_func()->ready = true;
|
||||||
// All setup is made, were done.
|
// All setup is made, were done.
|
||||||
emit ready();
|
emit ready();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TomahawkSettings::Lan:
|
case TomahawkSettings::Lan:
|
||||||
// Nothing has to be done here.
|
// Nothing has to be done here.
|
||||||
m_ready = true;
|
d_func()->ready = true;
|
||||||
emit ready();
|
emit ready();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -195,15 +194,15 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
|
|||||||
{
|
{
|
||||||
// upnp could be turned of on the cli with --noupnp
|
// upnp could be turned of on the cli with --noupnp
|
||||||
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "External address mode set to upnp...";
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "External address mode set to upnp...";
|
||||||
m_portfwd = QPointer< PortFwdThread >( new PortFwdThread( m_port ) );
|
d_func()->portfwd = QPointer< PortFwdThread >( new PortFwdThread( d_func()->port ) );
|
||||||
Q_ASSERT( m_portfwd );
|
Q_ASSERT( d_func()->portfwd );
|
||||||
connect( m_portfwd.data(), SIGNAL( externalAddressDetected( QHostAddress, unsigned int ) ),
|
connect( d_func()->portfwd.data(), SIGNAL( externalAddressDetected( QHostAddress, unsigned int ) ),
|
||||||
SLOT( setExternalAddress( QHostAddress, unsigned int ) ) );
|
SLOT( setExternalAddress( QHostAddress, unsigned int ) ) );
|
||||||
m_portfwd.data()->start();
|
d_func()->portfwd.data()->start();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_ready = true;
|
d_func()->ready = true;
|
||||||
emit ready();
|
emit ready();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -218,16 +217,16 @@ Servent::setExternalAddress( QHostAddress ha, unsigned int port )
|
|||||||
{
|
{
|
||||||
if ( isValidExternalIP( ha ) )
|
if ( isValidExternalIP( ha ) )
|
||||||
{
|
{
|
||||||
m_externalHostname = ha.toString();
|
d_func()->externalHostname = ha.toString();
|
||||||
m_externalPort = port;
|
d_func()->externalPort = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_externalPort == 0 || !isValidExternalIP( ha ) )
|
if ( d_func()->externalPort == 0 || !isValidExternalIP( ha ) )
|
||||||
tLog() << Q_FUNC_INFO << "UPnP failed, no further external address could be acquired!";
|
tLog() << Q_FUNC_INFO << "UPnP failed, no further external address could be acquired!";
|
||||||
else
|
else
|
||||||
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "UPnP setup successful";
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "UPnP setup successful";
|
||||||
|
|
||||||
m_ready = true;
|
d_func()->ready = true;
|
||||||
emit ready();
|
emit ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,13 +308,13 @@ Servent::isValidExternalIP( const QHostAddress& addr )
|
|||||||
void
|
void
|
||||||
Servent::registerOffer( const QString& key, Connection* conn )
|
Servent::registerOffer( const QString& key, Connection* conn )
|
||||||
{
|
{
|
||||||
m_offers[key] = QPointer<Connection>(conn);
|
d_func()->offers[key] = QPointer<Connection>(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Servent::registerLazyOffer(const QString &key, const peerinfo_ptr &peerInfo, const QString &nodeid, const int timeout )
|
Servent::registerLazyOffer(const QString &key, const peerinfo_ptr &peerInfo, const QString &nodeid, const int timeout )
|
||||||
{
|
{
|
||||||
m_lazyoffers[key] = QPair< peerinfo_ptr, QString >( peerInfo, nodeid );
|
d_func()->lazyoffers[key] = QPair< peerinfo_ptr, QString >( peerInfo, nodeid );
|
||||||
QTimer* timer = new QTimer( this );
|
QTimer* timer = new QTimer( this );
|
||||||
timer->setInterval( timeout );
|
timer->setInterval( timeout );
|
||||||
timer->setSingleShot( true );
|
timer->setSingleShot( true );
|
||||||
@@ -326,7 +325,7 @@ Servent::registerLazyOffer(const QString &key, const peerinfo_ptr &peerInfo, con
|
|||||||
void
|
void
|
||||||
Servent::deleteLazyOffer( const QString& key )
|
Servent::deleteLazyOffer( const QString& key )
|
||||||
{
|
{
|
||||||
m_lazyoffers.remove( key );
|
d_func()->lazyoffers.remove( key );
|
||||||
|
|
||||||
// Cleanup.
|
// Cleanup.
|
||||||
QTimer* timer = (QTimer*)sender();
|
QTimer* timer = (QTimer*)sender();
|
||||||
@@ -341,8 +340,8 @@ Servent::registerControlConnection( ControlConnection* conn )
|
|||||||
{
|
{
|
||||||
Q_ASSERT( conn );
|
Q_ASSERT( conn );
|
||||||
tLog( LOGVERBOSE ) << Q_FUNC_INFO << conn->name();
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO << conn->name();
|
||||||
m_controlconnections << conn;
|
d_func()->controlconnections << conn;
|
||||||
m_connectedNodes << conn->id();
|
d_func()->connectedNodes << conn->id();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -352,15 +351,15 @@ Servent::unregisterControlConnection( ControlConnection* conn )
|
|||||||
Q_ASSERT( conn );
|
Q_ASSERT( conn );
|
||||||
|
|
||||||
tLog( LOGVERBOSE ) << Q_FUNC_INFO << conn->name();
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO << conn->name();
|
||||||
m_connectedNodes.removeAll( conn->id() );
|
d_func()->connectedNodes.removeAll( conn->id() );
|
||||||
m_controlconnections.removeAll( conn );
|
d_func()->controlconnections.removeAll( conn );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ControlConnection*
|
ControlConnection*
|
||||||
Servent::lookupControlConnection( const SipInfo& sipInfo )
|
Servent::lookupControlConnection( const SipInfo& sipInfo )
|
||||||
{
|
{
|
||||||
foreach ( ControlConnection* c, m_controlconnections )
|
foreach ( ControlConnection* c, d_func()->controlconnections )
|
||||||
{
|
{
|
||||||
tLog() << sipInfo.port() << c->peerPort() << sipInfo.host() << c->peerIpAddress().toString();
|
tLog() << sipInfo.port() << c->peerPort() << sipInfo.host() << c->peerIpAddress().toString();
|
||||||
if ( sipInfo.port() == c->peerPort() && sipInfo.host() == c->peerIpAddress().toString() )
|
if ( sipInfo.port() == c->peerPort() && sipInfo.host() == c->peerIpAddress().toString() )
|
||||||
@@ -373,7 +372,7 @@ Servent::lookupControlConnection( const SipInfo& sipInfo )
|
|||||||
ControlConnection*
|
ControlConnection*
|
||||||
Servent::lookupControlConnection( const QString& nodeid )
|
Servent::lookupControlConnection( const QString& nodeid )
|
||||||
{
|
{
|
||||||
foreach ( ControlConnection* c, m_controlconnections )
|
foreach ( ControlConnection* c, d_func()->controlconnections )
|
||||||
{
|
{
|
||||||
if ( c->id() == nodeid )
|
if ( c->id() == nodeid )
|
||||||
return c;
|
return c;
|
||||||
@@ -386,21 +385,21 @@ QList<SipInfo>
|
|||||||
Servent::getLocalSipInfos( const QString& nodeid, const QString& key )
|
Servent::getLocalSipInfos( const QString& nodeid, const QString& key )
|
||||||
{
|
{
|
||||||
QList<SipInfo> sipInfos = QList<SipInfo>();
|
QList<SipInfo> sipInfos = QList<SipInfo>();
|
||||||
foreach ( QHostAddress ha, m_externalAddresses )
|
foreach ( QHostAddress ha, d_func()->externalAddresses )
|
||||||
{
|
{
|
||||||
SipInfo info = SipInfo();
|
SipInfo info = SipInfo();
|
||||||
info.setHost( ha.toString() );
|
info.setHost( ha.toString() );
|
||||||
info.setPort( m_port );
|
info.setPort( d_func()->port );
|
||||||
info.setKey( key );
|
info.setKey( key );
|
||||||
info.setVisible( true );
|
info.setVisible( true );
|
||||||
info.setNodeId( nodeid );
|
info.setNodeId( nodeid );
|
||||||
sipInfos.append( info );
|
sipInfos.append( info );
|
||||||
}
|
}
|
||||||
if ( m_externalHostname.length() > 0)
|
if ( d_func()->externalHostname.length() > 0)
|
||||||
{
|
{
|
||||||
SipInfo info = SipInfo();
|
SipInfo info = SipInfo();
|
||||||
info.setHost( m_externalHostname );
|
info.setHost( d_func()->externalHostname );
|
||||||
info.setPort( m_externalPort );
|
info.setPort( d_func()->externalPort );
|
||||||
info.setKey( key );
|
info.setKey( key );
|
||||||
info.setVisible( true );
|
info.setVisible( true );
|
||||||
info.setNodeId( nodeid );
|
info.setNodeId( nodeid );
|
||||||
@@ -585,7 +584,7 @@ Servent::readyRead()
|
|||||||
ControlConnection* cc = 0;
|
ControlConnection* cc = 0;
|
||||||
bool ok;
|
bool ok;
|
||||||
QString key, conntype, nodeid, controlid;
|
QString key, conntype, nodeid, controlid;
|
||||||
QVariantMap m = parser.parse( sock.data()->_msg->payload(), &ok ).toMap();
|
QVariantMap m = d_func()->parser.parse( sock.data()->_msg->payload(), &ok ).toMap();
|
||||||
if ( !ok )
|
if ( !ok )
|
||||||
{
|
{
|
||||||
tDebug() << "Invalid JSON on new connection, aborting";
|
tDebug() << "Invalid JSON on new connection, aborting";
|
||||||
@@ -601,13 +600,13 @@ Servent::readyRead()
|
|||||||
if ( !nodeid.isEmpty() ) // only control connections send nodeid
|
if ( !nodeid.isEmpty() ) // only control connections send nodeid
|
||||||
{
|
{
|
||||||
bool dupe = false;
|
bool dupe = false;
|
||||||
if ( m_connectedNodes.contains( nodeid ) )
|
if ( d_func()->connectedNodes.contains( nodeid ) )
|
||||||
{
|
{
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Connected nodes contains it.";
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Connected nodes contains it.";
|
||||||
dupe = true;
|
dupe = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( ControlConnection* con, m_controlconnections )
|
foreach ( ControlConnection* con, d_func()->controlconnections )
|
||||||
{
|
{
|
||||||
Q_ASSERT( con );
|
Q_ASSERT( con );
|
||||||
|
|
||||||
@@ -620,7 +619,7 @@ Servent::readyRead()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for zeroconf there might be no offer, that case is handled later
|
// for zeroconf there might be no offer, that case is handled later
|
||||||
ControlConnection* ccMatch = qobject_cast< ControlConnection* >( m_offers.value( key ).data() );
|
ControlConnection* ccMatch = qobject_cast< ControlConnection* >( d_func()->offers.value( key ).data() );
|
||||||
if ( dupe && ccMatch )
|
if ( dupe && ccMatch )
|
||||||
{
|
{
|
||||||
tLog() << "Duplicate control connection detected, dropping:" << nodeid << conntype;
|
tLog() << "Duplicate control connection detected, dropping:" << nodeid << conntype;
|
||||||
@@ -631,7 +630,7 @@ Servent::readyRead()
|
|||||||
peerInfoDebug( currentPeerInfo );
|
peerInfoDebug( currentPeerInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( ControlConnection* keepConnection, m_controlconnections )
|
foreach ( ControlConnection* keepConnection, d_func()->controlconnections )
|
||||||
{
|
{
|
||||||
Q_ASSERT( keepConnection );
|
Q_ASSERT( keepConnection );
|
||||||
|
|
||||||
@@ -654,7 +653,7 @@ Servent::readyRead()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( ControlConnection* con, m_controlconnections )
|
foreach ( ControlConnection* con, d_func()->controlconnections )
|
||||||
{
|
{
|
||||||
Q_ASSERT( con );
|
Q_ASSERT( con );
|
||||||
|
|
||||||
@@ -810,7 +809,7 @@ Servent::initiateConnection( const SipInfo& sipInfo, Connection* conn )
|
|||||||
Q_ASSERT( conn );
|
Q_ASSERT( conn );
|
||||||
|
|
||||||
// Check that we are not connecting to ourselves
|
// Check that we are not connecting to ourselves
|
||||||
foreach( QHostAddress ha, m_externalAddresses )
|
foreach( QHostAddress ha, d_func()->externalAddresses )
|
||||||
{
|
{
|
||||||
if ( sipInfo.host() == ha.toString() )
|
if ( sipInfo.host() == ha.toString() )
|
||||||
{
|
{
|
||||||
@@ -818,7 +817,7 @@ Servent::initiateConnection( const SipInfo& sipInfo, Connection* conn )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( sipInfo.host() == m_externalHostname )
|
if ( sipInfo.host() == d_func()->externalHostname )
|
||||||
{
|
{
|
||||||
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Tomahawk won't try to connect to" << sipInfo.host() << ":" << sipInfo.port() << ": same IP as ourselves.";
|
tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Tomahawk won't try to connect to" << sipInfo.host() << ":" << sipInfo.port() << ": same IP as ourselves.";
|
||||||
return;
|
return;
|
||||||
@@ -901,6 +900,36 @@ Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString& their
|
|||||||
createParallelConnection( orig_conn, new_conn, theirkey );
|
createParallelConnection( orig_conn, new_conn, theirkey );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Servent::visibleExternally() const
|
||||||
|
{
|
||||||
|
return (!d_func()->externalHostname.isNull()) || (d_func()->externalAddresses.length() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Servent::port() const
|
||||||
|
{
|
||||||
|
return d_func()->port;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QHostAddress>
|
||||||
|
Servent::addresses() const
|
||||||
|
{
|
||||||
|
return d_func()->externalAddresses;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
Servent::additionalAddress() const
|
||||||
|
{
|
||||||
|
return d_func()->externalHostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Servent::additionalPort() const
|
||||||
|
{
|
||||||
|
return d_func()->externalPort;
|
||||||
|
}
|
||||||
|
|
||||||
// return the appropriate connection for a given offer key, or NULL if invalid
|
// return the appropriate connection for a given offer key, or NULL if invalid
|
||||||
Connection*
|
Connection*
|
||||||
Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer )
|
Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer )
|
||||||
@@ -909,10 +938,10 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
|
|||||||
if ( key.startsWith( "FILE_REQUEST_KEY:" ) )
|
if ( key.startsWith( "FILE_REQUEST_KEY:" ) )
|
||||||
{
|
{
|
||||||
// check if the source IP matches an existing, authenticated connection
|
// check if the source IP matches an existing, authenticated connection
|
||||||
if ( !m_noAuth && peer != QHostAddress::Any && !isIPWhitelisted( peer ) )
|
if ( !d_func()->noAuth && peer != QHostAddress::Any && !isIPWhitelisted( peer ) )
|
||||||
{
|
{
|
||||||
bool authed = false;
|
bool authed = false;
|
||||||
foreach ( ControlConnection* cc, m_controlconnections )
|
foreach ( ControlConnection* cc, d_func()->controlconnections )
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO << "Probing:" << cc->name();
|
tDebug() << Q_FUNC_INFO << "Probing:" << cc->name();
|
||||||
if ( cc->socket() && cc->socket()->peerAddress() == peer )
|
if ( cc->socket() && cc->socket()->peerAddress() == peer )
|
||||||
@@ -962,22 +991,22 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_lazyoffers.contains( key ) )
|
if ( d_func()->lazyoffers.contains( key ) )
|
||||||
{
|
{
|
||||||
ControlConnection* conn = new ControlConnection( this );
|
ControlConnection* conn = new ControlConnection( this );
|
||||||
conn->setName( m_lazyoffers.value( key ).first->contactId() );
|
conn->setName( d_func()->lazyoffers.value( key ).first->contactId() );
|
||||||
conn->addPeerInfo( m_lazyoffers.value( key ).first );
|
conn->addPeerInfo( d_func()->lazyoffers.value( key ).first );
|
||||||
conn->setId( m_lazyoffers.value( key ).second );
|
conn->setId( d_func()->lazyoffers.value( key ).second );
|
||||||
|
|
||||||
// Register as non-lazy offer
|
// Register as non-lazy offer
|
||||||
m_lazyoffers.remove( key );
|
d_func()->lazyoffers.remove( key );
|
||||||
registerOffer( key, conn );
|
registerOffer( key, conn );
|
||||||
|
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
else if ( m_offers.contains( key ) )
|
else if ( d_func()->offers.contains( key ) )
|
||||||
{
|
{
|
||||||
QPointer<Connection> conn = m_offers.value( key );
|
QPointer<Connection> conn = d_func()->offers.value( key );
|
||||||
if ( conn.isNull() )
|
if ( conn.isNull() )
|
||||||
{
|
{
|
||||||
// This can happen if it's a streamconnection, but the audioengine has
|
// This can happen if it's a streamconnection, but the audioengine has
|
||||||
@@ -997,7 +1026,7 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
|
|||||||
|
|
||||||
if ( conn.data()->onceOnly() )
|
if ( conn.data()->onceOnly() )
|
||||||
{
|
{
|
||||||
m_offers.remove( key );
|
d_func()->offers.remove( key );
|
||||||
return conn.data();
|
return conn.data();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1005,7 +1034,7 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
|
|||||||
return conn.data()->clone();
|
return conn.data()->clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( m_noAuth )
|
else if ( d_func()->noAuth )
|
||||||
{
|
{
|
||||||
Connection* conn;
|
Connection* conn;
|
||||||
conn = new ControlConnection( this );
|
conn = new ControlConnection( this );
|
||||||
@@ -1049,11 +1078,11 @@ Servent::remoteIODeviceFactory( const Tomahawk::result_ptr& result,
|
|||||||
void
|
void
|
||||||
Servent::registerStreamConnection( StreamConnection* sc )
|
Servent::registerStreamConnection( StreamConnection* sc )
|
||||||
{
|
{
|
||||||
Q_ASSERT( !m_scsessions.contains( sc ) );
|
Q_ASSERT( !d_func()->scsessions.contains( sc ) );
|
||||||
tDebug( LOGVERBOSE ) << "Registering Stream" << m_scsessions.length() + 1;
|
tDebug( LOGVERBOSE ) << "Registering Stream" << d_func()->scsessions.length() + 1;
|
||||||
|
|
||||||
QMutexLocker lock( &m_ftsession_mut );
|
QMutexLocker lock( &d_func()->ftsession_mut );
|
||||||
m_scsessions.append( sc );
|
d_func()->scsessions.append( sc );
|
||||||
|
|
||||||
printCurrentTransfers();
|
printCurrentTransfers();
|
||||||
emit streamStarted( sc );
|
emit streamStarted( sc );
|
||||||
@@ -1066,8 +1095,8 @@ Servent::onStreamFinished( StreamConnection* sc )
|
|||||||
Q_ASSERT( sc );
|
Q_ASSERT( sc );
|
||||||
tDebug( LOGVERBOSE ) << "Stream Finished, unregistering" << sc->id();
|
tDebug( LOGVERBOSE ) << "Stream Finished, unregistering" << sc->id();
|
||||||
|
|
||||||
QMutexLocker lock( &m_ftsession_mut );
|
QMutexLocker lock( &d_func()->ftsession_mut );
|
||||||
m_scsessions.removeAll( sc );
|
d_func()->scsessions.removeAll( sc );
|
||||||
|
|
||||||
printCurrentTransfers();
|
printCurrentTransfers();
|
||||||
emit streamFinished( sc );
|
emit streamFinished( sc );
|
||||||
@@ -1080,7 +1109,7 @@ Servent::printCurrentTransfers()
|
|||||||
{
|
{
|
||||||
int k = 1;
|
int k = 1;
|
||||||
// qDebug() << "~~~ Active file transfer connections:" << m_scsessions.length();
|
// qDebug() << "~~~ Active file transfer connections:" << m_scsessions.length();
|
||||||
foreach ( StreamConnection* i, m_scsessions )
|
foreach ( StreamConnection* i, d_func()->scsessions )
|
||||||
{
|
{
|
||||||
qDebug() << k << ") " << i->id();
|
qDebug() << k << ") " << i->id();
|
||||||
}
|
}
|
||||||
@@ -1118,7 +1147,7 @@ Servent::isIPWhitelisted( QHostAddress ip )
|
|||||||
bool
|
bool
|
||||||
Servent::connectedToSession( const QString& session )
|
Servent::connectedToSession( const QString& session )
|
||||||
{
|
{
|
||||||
foreach ( ControlConnection* cc, m_controlconnections )
|
foreach ( ControlConnection* cc, d_func()->controlconnections )
|
||||||
{
|
{
|
||||||
Q_ASSERT( cc );
|
Q_ASSERT( cc );
|
||||||
|
|
||||||
@@ -1129,6 +1158,18 @@ Servent::connectedToSession( const QString& session )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
Servent::numConnectedPeers() const
|
||||||
|
{
|
||||||
|
return d_func()->controlconnections.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<StreamConnection *>
|
||||||
|
Servent::streams() const
|
||||||
|
{
|
||||||
|
return d_func()->scsessions;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Servent::triggerDBSync()
|
Servent::triggerDBSync()
|
||||||
@@ -1152,7 +1193,7 @@ void
|
|||||||
Servent::registerIODeviceFactory( const QString &proto,
|
Servent::registerIODeviceFactory( const QString &proto,
|
||||||
IODeviceFactoryFunc fac )
|
IODeviceFactoryFunc fac )
|
||||||
{
|
{
|
||||||
m_iofactories.insert( proto, fac );
|
d_func()->iofactories.insert( proto, fac );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1170,14 +1211,14 @@ Servent::getIODeviceForUrl( const Tomahawk::result_ptr& result,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const QString proto = rx.cap( 1 );
|
const QString proto = rx.cap( 1 );
|
||||||
if ( !m_iofactories.contains( proto ) )
|
if ( !d_func()->iofactories.contains( proto ) )
|
||||||
{
|
{
|
||||||
callback( sp );
|
callback( sp );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//JSResolverHelper::customIODeviceFactory is async!
|
//JSResolverHelper::customIODeviceFactory is async!
|
||||||
m_iofactories.value( proto )( result, callback );
|
d_func()->iofactories.value( proto )( result, callback );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1207,3 +1248,9 @@ Servent::httpIODeviceFactory( const Tomahawk::result_ptr& result,
|
|||||||
QSharedPointer< QIODevice > sp = QSharedPointer< QIODevice >( reply, &QObject::deleteLater );
|
QSharedPointer< QIODevice > sp = QSharedPointer< QIODevice >( reply, &QObject::deleteLater );
|
||||||
callback( sp );
|
callback( sp );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Servent::isReady() const
|
||||||
|
{
|
||||||
|
return d_func()->ready;
|
||||||
|
}
|
||||||
|
@@ -32,18 +32,10 @@
|
|||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
#include <QtCore/QPointer>
|
#include <QtCore/QPointer>
|
||||||
#include <QtNetwork/QTcpServer>
|
#include <QtNetwork/QTcpServer>
|
||||||
#include <QtNetwork/QTcpSocket>
|
|
||||||
#include <QtNetwork/QHostInfo>
|
#include <QtNetwork/QHostInfo>
|
||||||
|
|
||||||
#include <qjson/parser.h>
|
|
||||||
#include <qjson/serializer.h>
|
|
||||||
#include <qjson/qobjecthelper.h>
|
|
||||||
|
|
||||||
#include "Typedefs.h"
|
#include "Typedefs.h"
|
||||||
#include "Msg.h"
|
#include "Msg.h"
|
||||||
#include "network/QTcpSocketExtra.h"
|
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
|
||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
@@ -52,14 +44,22 @@ class Connector;
|
|||||||
class ControlConnection;
|
class ControlConnection;
|
||||||
class StreamConnection;
|
class StreamConnection;
|
||||||
class ProxyConnection;
|
class ProxyConnection;
|
||||||
|
class QTcpSocketExtra;
|
||||||
class RemoteCollectionConnection;
|
class RemoteCollectionConnection;
|
||||||
class PortFwdThread;
|
class PortFwdThread;
|
||||||
class PeerInfo;
|
class PeerInfo;
|
||||||
class SipInfo;
|
class SipInfo;
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
template <class T> class function;
|
||||||
|
} // boost
|
||||||
|
|
||||||
typedef boost::function< void( const Tomahawk::result_ptr&,
|
typedef boost::function< void( const Tomahawk::result_ptr&,
|
||||||
boost::function< void( QSharedPointer< QIODevice >& ) > )> IODeviceFactoryFunc;
|
boost::function< void( QSharedPointer< QIODevice >& ) > )> IODeviceFactoryFunc;
|
||||||
|
|
||||||
|
class ServentPrivate;
|
||||||
|
|
||||||
class DLLEXPORT Servent : public QTcpServer
|
class DLLEXPORT Servent : public QTcpServer
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -96,34 +96,34 @@ public:
|
|||||||
void initiateConnection( const SipInfo& sipInfo, Connection* conn );
|
void initiateConnection( const SipInfo& sipInfo, Connection* conn );
|
||||||
void reverseOfferRequest( ControlConnection* orig_conn, const QString &theirdbid, const QString& key, const QString& theirkey );
|
void reverseOfferRequest( ControlConnection* orig_conn, const QString &theirdbid, const QString& key, const QString& theirkey );
|
||||||
|
|
||||||
bool visibleExternally() const { return (!m_externalHostname.isNull()) || (m_externalAddresses.length() > 0); }
|
bool visibleExternally() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The port this Peer listens directly (per default)
|
* The port this Peer listens directly (per default)
|
||||||
*/
|
*/
|
||||||
int port() const { return m_port; }
|
int port() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The IP addresses this Peer listens directly (per default)
|
* The IP addresses this Peer listens directly (per default)
|
||||||
*/
|
*/
|
||||||
QList< QHostAddress > addresses() const { return m_externalAddresses; }
|
QList< QHostAddress > addresses() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An additional address this peer listens to, e.g. via UPnP.
|
* An additional address this peer listens to, e.g. via UPnP.
|
||||||
*/
|
*/
|
||||||
QString additionalAddress() const { return m_externalHostname; }
|
QString additionalAddress() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An additional port this peer listens to, e.g. via UPnP (only in combination with additionalAddress.
|
* An additional port this peer listens to, e.g. via UPnP (only in combination with additionalAddress.
|
||||||
*/
|
*/
|
||||||
int additionalPort() const { return m_externalPort; }
|
int additionalPort() const;
|
||||||
|
|
||||||
static bool isIPWhitelisted( QHostAddress ip );
|
static bool isIPWhitelisted( QHostAddress ip );
|
||||||
|
|
||||||
bool connectedToSession( const QString& session );
|
bool connectedToSession( const QString& session );
|
||||||
unsigned int numConnectedPeers() const { return m_controlconnections.length(); }
|
unsigned int numConnectedPeers() const;
|
||||||
|
|
||||||
QList< StreamConnection* > streams() const { return m_scsessions; }
|
QList< StreamConnection* > streams() const;
|
||||||
|
|
||||||
void getIODeviceForUrl( const Tomahawk::result_ptr& result, boost::function< void ( QSharedPointer< QIODevice >& ) > callback );
|
void getIODeviceForUrl( const Tomahawk::result_ptr& result, boost::function< void ( QSharedPointer< QIODevice >& ) > callback );
|
||||||
void registerIODeviceFactory( const QString &proto, IODeviceFactoryFunc fac );
|
void registerIODeviceFactory( const QString &proto, IODeviceFactoryFunc fac );
|
||||||
@@ -131,7 +131,7 @@ public:
|
|||||||
void localFileIODeviceFactory( const Tomahawk::result_ptr& result, boost::function< void ( QSharedPointer< QIODevice >& ) > callback );
|
void localFileIODeviceFactory( const Tomahawk::result_ptr& result, boost::function< void ( QSharedPointer< QIODevice >& ) > callback );
|
||||||
void httpIODeviceFactory( const Tomahawk::result_ptr& result, boost::function< void ( QSharedPointer< QIODevice >& ) > callback );
|
void httpIODeviceFactory( const Tomahawk::result_ptr& result, boost::function< void ( QSharedPointer< QIODevice >& ) > callback );
|
||||||
|
|
||||||
bool isReady() const { return m_ready; }
|
bool isReady() const;
|
||||||
|
|
||||||
QList<SipInfo> getLocalSipInfos(const QString& nodeid, const QString &key);
|
QList<SipInfo> getLocalSipInfos(const QString& nodeid, const QString &key);
|
||||||
signals:
|
signals:
|
||||||
@@ -162,46 +162,13 @@ private slots:
|
|||||||
Connection* claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer = QHostAddress::Any );
|
Connection* claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer = QHostAddress::Any );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Q_DECLARE_PRIVATE( Servent )
|
||||||
|
ServentPrivate* d_ptr;
|
||||||
|
|
||||||
void handoverSocket( Connection* conn, QTcpSocketExtra* sock );
|
void handoverSocket( Connection* conn, QTcpSocketExtra* sock );
|
||||||
void cleanupSocket( QTcpSocketExtra* sock );
|
void cleanupSocket( QTcpSocketExtra* sock );
|
||||||
void printCurrentTransfers();
|
void printCurrentTransfers();
|
||||||
|
|
||||||
QJson::Parser parser;
|
|
||||||
QList< ControlConnection* > m_controlconnections; // canonical list of authed peers
|
|
||||||
QMap< QString, QPointer< Connection > > m_offers;
|
|
||||||
QMap< QString, QPair< Tomahawk::peerinfo_ptr, QString > > m_lazyoffers;
|
|
||||||
QStringList m_connectedNodes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The external port used by all address except those obtained via UPnP or the static configuration option
|
|
||||||
*/
|
|
||||||
int m_port;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Either the static set or the UPnP set external port
|
|
||||||
*/
|
|
||||||
int m_externalPort;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* All available external IPs
|
|
||||||
*/
|
|
||||||
QList<QHostAddress> m_externalAddresses;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Either the static set or the UPnP set external host
|
|
||||||
*/
|
|
||||||
QString m_externalHostname;
|
|
||||||
|
|
||||||
bool m_ready;
|
|
||||||
bool m_noAuth;
|
|
||||||
|
|
||||||
// currently active file transfers:
|
|
||||||
QList< StreamConnection* > m_scsessions;
|
|
||||||
QMutex m_ftsession_mut;
|
|
||||||
|
|
||||||
QMap< QString, IODeviceFactoryFunc > m_iofactories;
|
|
||||||
|
|
||||||
QPointer< PortFwdThread > m_portfwd;
|
|
||||||
static Servent* s_instance;
|
static Servent* s_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
90
src/libtomahawk/network/Servent_p.h
Normal file
90
src/libtomahawk/network/Servent_p.h
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
|
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
|
||||||
|
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2013, Uwe L. Korn <uwelk@xhochy.com>
|
||||||
|
*
|
||||||
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SERVENT_P_H
|
||||||
|
#define SERVENT_P_H
|
||||||
|
|
||||||
|
#include "Servent.h"
|
||||||
|
|
||||||
|
#include <qjson/parser.h>
|
||||||
|
#include <qjson/serializer.h>
|
||||||
|
#include <qjson/qobjecthelper.h>
|
||||||
|
|
||||||
|
#include <boost/function.hpp>
|
||||||
|
|
||||||
|
class ServentPrivate : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ServentPrivate( Servent* q )
|
||||||
|
: q_ptr ( q )
|
||||||
|
, port( 0 )
|
||||||
|
, externalPort( 0 )
|
||||||
|
, ready( false )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
Servent* q_ptr;
|
||||||
|
Q_DECLARE_PUBLIC ( Servent )
|
||||||
|
|
||||||
|
private:
|
||||||
|
QMap< QString, IODeviceFactoryFunc > iofactories;
|
||||||
|
QMap< QString, QPointer< Connection > > offers;
|
||||||
|
QMap< QString, QPair< Tomahawk::peerinfo_ptr, QString > > lazyoffers;
|
||||||
|
QStringList connectedNodes;
|
||||||
|
QJson::Parser parser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* canonical list of authed peers
|
||||||
|
*/
|
||||||
|
QList< ControlConnection* > controlconnections;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The external port used by all address except those obtained via UPnP or the static configuration option
|
||||||
|
*/
|
||||||
|
int port;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Either the static set or the UPnP set external port
|
||||||
|
*/
|
||||||
|
int externalPort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All available external IPs
|
||||||
|
*/
|
||||||
|
QList<QHostAddress> externalAddresses;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Either the static set or the UPnP set external host
|
||||||
|
*/
|
||||||
|
QString externalHostname;
|
||||||
|
|
||||||
|
bool ready;
|
||||||
|
bool noAuth;
|
||||||
|
|
||||||
|
// currently active file transfers:
|
||||||
|
QList< StreamConnection* > scsessions;
|
||||||
|
QMutex ftsession_mut;
|
||||||
|
|
||||||
|
QPointer< PortFwdThread > portfwd;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SERVENT_P_H
|
@@ -30,6 +30,7 @@
|
|||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
#include <boost/function.hpp>
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
@@ -109,6 +109,7 @@ INCLUDE_DIRECTORIES(
|
|||||||
${LIBATTICA_INCLUDE_DIR}
|
${LIBATTICA_INCLUDE_DIR}
|
||||||
${ECHONEST_INCLUDE_DIR}
|
${ECHONEST_INCLUDE_DIR}
|
||||||
${LIBLASTFM_INCLUDE_DIRS}
|
${LIBLASTFM_INCLUDE_DIRS}
|
||||||
|
${Boost_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
IF( QXTWEB_FOUND )
|
IF( QXTWEB_FOUND )
|
||||||
|
Reference in New Issue
Block a user