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

Potentially solve the 4-is-not-JSON bug

This commit is contained in:
Jeff Mitchell
2012-07-10 19:23:12 -04:00
parent 97ff1100d1
commit 8dcf7d0db2
5 changed files with 18 additions and 21 deletions

View File

@@ -241,7 +241,7 @@ DiagnosticsDialog::updateAccountLabel( Tomahawk::Accounts::Account* account )
accountInfo.append( accountInfo.append(
QString(" %1: %2:%3 %4" /*" (%5)"*/ "\n") QString(" %1: %2:%3 %4" /*" (%5)"*/ "\n")
.arg( peerId ) .arg( peerId )
.arg( sipInfo.host().hostName() ) .arg( sipInfo.host() )
.arg( sipInfo.port() ) .arg( sipInfo.port() )
.arg( versionString ) .arg( versionString )
// .arg( connected ? "connected" : "not connected") // .arg( connected ? "connected" : "not connected")

View File

@@ -435,7 +435,7 @@ XmppSipPlugin::sendMsg( const QString& to, const SipInfo& info )
TomahawkXmppMessage *sipMessage; TomahawkXmppMessage *sipMessage;
if ( info.isVisible() ) if ( info.isVisible() )
{ {
sipMessage = new TomahawkXmppMessage( info.host().hostName(), info.port(), info.uniqname(), info.key() ); sipMessage = new TomahawkXmppMessage( info.host(), info.port(), info.uniqname(), info.key() );
} }
else else
sipMessage = new TomahawkXmppMessage(); sipMessage = new TomahawkXmppMessage();
@@ -892,9 +892,7 @@ XmppSipPlugin::onNewIq( const Jreen::IQ& iq )
info.setVisible( sipMessage->visible() ); info.setVisible( sipMessage->visible() );
if ( sipMessage->visible() ) if ( sipMessage->visible() )
{ {
QHostInfo hi; info.setHost( sipMessage->ip() );
hi.setHostName( sipMessage->ip() );
info.setHost( hi );
info.setPort( sipMessage->port() ); info.setPort( sipMessage->port() );
info.setUniqname( sipMessage->uniqname() ); info.setUniqname( sipMessage->uniqname() );
info.setKey( sipMessage->key() ); info.setKey( sipMessage->key() );

View File

@@ -137,7 +137,7 @@ SipHandler::onPeerOnline( const QString& peerId )
Servent::instance()->registerOffer( key, conn ); Servent::instance()->registerOffer( key, conn );
info.setVisible( true ); info.setVisible( true );
info.setHost( QHostInfo::fromName( Servent::instance()->externalAddress() ) ); info.setHost( Servent::instance()->externalAddress() );
info.setPort( Servent::instance()->externalPort() ); info.setPort( Servent::instance()->externalPort() );
info.setKey( key ); info.setKey( key );
info.setUniqname( nodeid ); info.setUniqname( nodeid );
@@ -180,10 +180,11 @@ SipHandler::onSipInfo( const QString& peerId, const SipInfo& info )
if ( info.isVisible() ) if ( info.isVisible() )
{ {
if( !Servent::instance()->visibleExternally() || if( !Servent::instance()->visibleExternally() ||
Servent::instance()->externalAddress() <= info.host().hostName() ) Servent::instance()->externalAddress() < info.host() ||
( Servent::instance()->externalAddress() == info.host() && Servent::instance()->externalPort() < info.port() ) )
{ {
tDebug() << "Initiate connection to" << peerId << Servent::instance()->externalAddress() << info.host().hostName() << ( Servent::instance()->externalAddress() <= info.host().hostName() ); tDebug() << "Initiate connection to" << peerId << "at" << info.host();
Servent::instance()->connectToPeer( info.host().hostName(), Servent::instance()->connectToPeer( info.host(),
info.port(), info.port(),
info.key(), info.key(),
peerId, peerId,

View File

@@ -44,7 +44,7 @@ public:
~SipInfoPrivate() { } ~SipInfoPrivate() { }
QVariant visible; QVariant visible;
QHostInfo host; QString host;
int port; int port;
QString uniqname; QString uniqname;
QString key; QString key;
@@ -81,7 +81,7 @@ void
SipInfo::clear() SipInfo::clear()
{ {
d->visible.clear(); d->visible.clear();
d->host = QHostInfo(); d->host = QString();
d->port = -1; d->port = -1;
d->uniqname = QString(); d->uniqname = QString();
d->key = QString(); d->key = QString();
@@ -96,9 +96,9 @@ SipInfo::isValid() const
{ {
if( if(
// visible and all data available // visible and all data available
( d->visible.toBool() && !d->host.hostName().isNull() && ( d->port > 0 ) && !d->uniqname.isNull() && !d->key.isNull() ) ( d->visible.toBool() && !d->host.isEmpty() && ( d->port > 0 ) && !d->uniqname.isNull() && !d->key.isNull() )
// invisible and no data available // invisible and no data available
|| ( !d->visible.toBool() && d->host.hostName().isNull() && ( d->port < 0 ) && d->uniqname.isNull() && d->key.isNull() ) || ( !d->visible.toBool() && d->host.isEmpty() && ( d->port < 0 ) && d->uniqname.isNull() && d->key.isNull() )
) )
return true; return true;
} }
@@ -124,13 +124,13 @@ SipInfo::isVisible() const
void void
SipInfo::setHost( const QHostInfo& host ) SipInfo::setHost( const QString& host )
{ {
d->host = host; d->host = host;
} }
const QHostInfo const QString
SipInfo::host() const SipInfo::host() const
{ {
Q_ASSERT( isValid() ); Q_ASSERT( isValid() );
@@ -195,7 +195,7 @@ SipInfo::toJson() const
m["visible"] = isVisible(); m["visible"] = isVisible();
if( isVisible() ) if( isVisible() )
{ {
m["ip"] = host().hostName(); m["ip"] = host();
m["port"] = port(); m["port"] = port();
m["key"] = key(); m["key"] = key();
m["uniqname"] = uniqname(); m["uniqname"] = uniqname();
@@ -227,9 +227,7 @@ SipInfo::fromJson( QString json )
info.setVisible( m["visible"].toBool() ); info.setVisible( m["visible"].toBool() );
if( m["visible"].toBool() ) if( m["visible"].toBool() )
{ {
QHostInfo hostInfo; info.setHost( m["host"].toString() );
hostInfo.setHostName( m["host"].toString() );
info.setHost( hostInfo );
info.setPort( m["port"].toInt() ); info.setPort( m["port"].toInt() );
info.setUniqname( m["uniqname"].toString() ); info.setUniqname( m["uniqname"].toString() );
info.setKey( m["key"].toString() ); info.setKey( m["key"].toString() );

View File

@@ -43,8 +43,8 @@ public:
void setVisible( bool visible ); void setVisible( bool visible );
bool isVisible() const; bool isVisible() const;
void setHost( const QHostInfo& host ); void setHost( const QString& host );
const QHostInfo host() const; const QString host() const;
void setPort( int port ); void setPort( int port );
int port() const; int port() const;