1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 06:07:37 +02:00

Code cleanup, mainly to differentiate during connect between startup and non-startup

This commit is contained in:
Jeff Mitchell
2011-02-10 14:32:36 -05:00
parent d18236afb4
commit 5016d05093
12 changed files with 30 additions and 18 deletions

View File

@@ -16,7 +16,7 @@ public:
virtual ~SipPlugin() {} virtual ~SipPlugin() {}
public slots: public slots:
virtual bool connect() = 0; virtual bool connect( bool startup = false ) = 0;
virtual void disconnect() = 0; virtual void disconnect() = 0;
virtual void addContact( const QString &jid, const QString& msg = QString() ) = 0; virtual void addContact( const QString &jid, const QString& msg = QString() ) = 0;

View File

@@ -241,16 +241,18 @@ TomahawkSettings::setJabberAutoConnect( bool autoconnect )
} }
int unsigned int
TomahawkSettings::jabberPort() const TomahawkSettings::jabberPort() const
{ {
return value( "jabber/port", 5222 ).toInt(); return value( "jabber/port", 5222 ).toUInt();
} }
void void
TomahawkSettings::setJabberPort( int port ) TomahawkSettings::setJabberPort( int port )
{ {
if ( port < 0 )
return;
setValue( "jabber/port", port ); setValue( "jabber/port", port );
} }

View File

@@ -51,7 +51,7 @@ public:
QString jabberServer() const; QString jabberServer() const;
void setJabberServer( const QString& server ); void setJabberServer( const QString& server );
int jabberPort() const; // default is 5222 unsigned int jabberPort() const; // default is 5222
void setJabberPort( int port ); void setJabberPort( int port );
/// Network settings /// Network settings

View File

@@ -337,7 +337,11 @@ DNSResolver::resolve( QString &host, QString &type )
if( type == "SRV" ) if( type == "SRV" )
{ {
// For the moment, assume we are looking for XMPP... // For the moment, assume we are looking for XMPP...
m_dnsSharedRequest->query( "_xmpp-client._tcp." + host.toUtf8(), QJDns::Srv ); QString fullHost( "_xmpp-client._tcp." + host );
qDebug() << "Looking up SRV record for " << fullHost.toUtf8();
m_dnsSharedRequest->query( fullHost.toUtf8(), QJDns::Srv );
} }
else else
{ {
@@ -354,6 +358,7 @@ DNSResolver::resultsReady()
QList<QJDns::Record> results = m_dnsSharedRequest->results(); QList<QJDns::Record> results = m_dnsSharedRequest->results();
foreach( QJDns::Record r, results ) foreach( QJDns::Record r, results )
{ {
qDebug() << "Found result (of some type): " << QString( r.name );
if( r.type == QJDns::Srv ) if( r.type == QJDns::Srv )
{ {
QString foundResult( r.name ); QString foundResult( r.name );

View File

@@ -18,6 +18,11 @@ class JDnsSharedRequest;
namespace TomahawkUtils namespace TomahawkUtils
{ {
//NOTE: The JDnsShared system is supposed to allow you to make multiple requests
//at once, but either I'm a dumbass, or it's a broken paradigm, or both,
//because there's no way that I can see to tell what result is for what query.
//Be aware of this if ever we want to do parallel connections/lookups; turn it into
//a non-static non-singleton normal utility class then.
class DLLEXPORT DNSResolver : public QObject class DLLEXPORT DNSResolver : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@@ -114,10 +114,10 @@ SipHandler::loadPlugin( QObject* plugin )
void void
SipHandler::connect() SipHandler::connect( bool startup )
{ {
foreach( SipPlugin* sip, m_plugins ) foreach( SipPlugin* sip, m_plugins )
sip->connect(); sip->connect( startup );
m_connected = true; m_connected = true;
} }

View File

@@ -19,7 +19,7 @@ public:
public slots: public slots:
void addContact( const QString& id ) { qDebug() << Q_FUNC_INFO << id; } void addContact( const QString& id ) { qDebug() << Q_FUNC_INFO << id; }
void connect(); void connect( bool startup = false );
void disconnect(); void disconnect();
void toggleConnect(); void toggleConnect();

View File

@@ -13,15 +13,15 @@ JabberPlugin::setProxy( QNetworkProxy* proxy )
bool bool
JabberPlugin::connect() JabberPlugin::connect( bool startup )
{ {
if ( !TomahawkSettings::instance()->value( "jabber/autoconnect", true ).toBool() ) if ( startup && !TomahawkSettings::instance()->jabberAutoConnect() )
return false; return false;
QString jid = TomahawkSettings::instance()->value( "jabber/username" ).toString(); QString jid = TomahawkSettings::instance()->jabberUsername();
QString server = TomahawkSettings::instance()->value( "jabber/server" ).toString(); QString server = TomahawkSettings::instance()->jabberServer();
QString password = TomahawkSettings::instance()->value( "jabber/password" ).toString(); QString password = TomahawkSettings::instance()->jabberPassword();
unsigned int port = TomahawkSettings::instance()->value( "jabber/port", 5222 ).toUInt(); unsigned int port = TomahawkSettings::instance()->jabberPort();
// gtalk check // gtalk check
if( server.isEmpty() && ( jid.contains( "@gmail.com" ) || jid.contains( "@googlemail.com" ) ) ) if( server.isEmpty() && ( jid.contains( "@gmail.com" ) || jid.contains( "@googlemail.com" ) ) )

View File

@@ -21,7 +21,7 @@ public:
void setProxy( QNetworkProxy* proxy ); void setProxy( QNetworkProxy* proxy );
public slots: public slots:
virtual bool connect(); virtual bool connect( bool startup );
void disconnect() void disconnect()
{ {

View File

@@ -4,7 +4,7 @@
bool bool
ZeroconfPlugin::connect() ZeroconfPlugin::connect( bool /*startup*/ )
{ {
delete m_zeroconf; delete m_zeroconf;
m_zeroconf = new TomahawkZeroconf( Servent::instance()->port(), this ); m_zeroconf = new TomahawkZeroconf( Servent::instance()->port(), this );

View File

@@ -19,7 +19,7 @@ public:
virtual ~ZeroconfPlugin() {} virtual ~ZeroconfPlugin() {}
public slots: public slots:
virtual bool connect(); virtual bool connect( bool startup );
void disconnect() void disconnect()
{ {

View File

@@ -409,7 +409,7 @@ TomahawkApp::setupSIP()
{ {
m_xmppBot = new XMPPBot( this ); m_xmppBot = new XMPPBot( this );
m_sipHandler->connect(); m_sipHandler->connect( true );
// m_sipHandler->setProxy( *TomahawkUtils::proxy() ); // m_sipHandler->setProxy( *TomahawkUtils::proxy() );
} }
} }