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() {}
public slots:
virtual bool connect() = 0;
virtual bool connect( bool startup = false ) = 0;
virtual void disconnect() = 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
{
return value( "jabber/port", 5222 ).toInt();
return value( "jabber/port", 5222 ).toUInt();
}
void
TomahawkSettings::setJabberPort( int port )
{
if ( port < 0 )
return;
setValue( "jabber/port", port );
}

View File

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

View File

@@ -337,7 +337,11 @@ DNSResolver::resolve( QString &host, QString &type )
if( type == "SRV" )
{
// 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
{
@@ -354,6 +358,7 @@ DNSResolver::resultsReady()
QList<QJDns::Record> results = m_dnsSharedRequest->results();
foreach( QJDns::Record r, results )
{
qDebug() << "Found result (of some type): " << QString( r.name );
if( r.type == QJDns::Srv )
{
QString foundResult( r.name );

View File

@@ -18,6 +18,11 @@ class JDnsSharedRequest;
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
{
Q_OBJECT

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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