mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
Revert change of jreen namespace, as we were tracking Jreen trunk correctly but
our submodule was behind on clean checkouts. Updated now.
Revert "The Jreen guys went and changed capitalization of their namespace, which"
This reverts commit 41f1ac9713
.
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
AvatarManager::AvatarManager(jreen::Client *client) :
|
AvatarManager::AvatarManager(Jreen::Client *client) :
|
||||||
m_cacheDir(TomahawkUtils::appDataDir().absolutePath().append("/jreen/"))
|
m_cacheDir(TomahawkUtils::appDataDir().absolutePath().append("/jreen/"))
|
||||||
{
|
{
|
||||||
m_client = client;
|
m_client = client;
|
||||||
@@ -20,8 +20,8 @@ AvatarManager::AvatarManager(jreen::Client *client) :
|
|||||||
m_cachedAvatars = m_cacheDir.entryList();
|
m_cachedAvatars = m_cacheDir.entryList();
|
||||||
|
|
||||||
connect(m_client, SIGNAL(serverFeaturesReceived(QSet<QString>)), SLOT(onNewConnection()));
|
connect(m_client, SIGNAL(serverFeaturesReceived(QSet<QString>)), SLOT(onNewConnection()));
|
||||||
connect(m_client, SIGNAL(newPresence(jreen::Presence)), SLOT(onNewPresence(jreen::Presence)));
|
connect(m_client, SIGNAL(newPresence(Jreen::Presence)), SLOT(onNewPresence(Jreen::Presence)));
|
||||||
connect(m_client, SIGNAL(newIQ(jreen::IQ)), SLOT(onNewIq(jreen::IQ)));
|
connect(m_client, SIGNAL(newIQ(Jreen::IQ)), SLOT(onNewIq(Jreen::IQ)));
|
||||||
|
|
||||||
connect(this, SIGNAL(newAvatar(QString)), SLOT(onNewAvatar(QString)));
|
connect(this, SIGNAL(newAvatar(QString)), SLOT(onNewAvatar(QString)));
|
||||||
}
|
}
|
||||||
@@ -40,14 +40,14 @@ void AvatarManager::fetchVCard(const QString &jid)
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
jreen::IQ iq(jreen::IQ::Get, jid );
|
Jreen::IQ iq(Jreen::IQ::Get, jid );
|
||||||
iq.addExtension(new jreen::VCard());
|
iq.addExtension(new Jreen::VCard());
|
||||||
m_client->send( iq, this, SLOT( onNewIq( jreen::IQ, int ) ), 0 );
|
m_client->send( iq, this, SLOT( onNewIq( Jreen::IQ, int ) ), 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarManager::onNewPresence(const jreen::Presence& presence)
|
void AvatarManager::onNewPresence(const Jreen::Presence& presence)
|
||||||
{
|
{
|
||||||
jreen::VCardUpdate::Ptr update = presence.findExtension<jreen::VCardUpdate>();
|
Jreen::VCardUpdate::Ptr update = presence.findExtension<Jreen::VCardUpdate>();
|
||||||
if(update)
|
if(update)
|
||||||
{
|
{
|
||||||
qDebug() << "vcard: found update for " << presence.from().full();
|
qDebug() << "vcard: found update for " << presence.from().full();
|
||||||
@@ -74,9 +74,9 @@ void AvatarManager::onNewPresence(const jreen::Presence& presence)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarManager::onNewIq(const jreen::IQ& iq, int context)
|
void AvatarManager::onNewIq(const Jreen::IQ& iq, int context)
|
||||||
{
|
{
|
||||||
jreen::VCard *vcard = iq.findExtension<jreen::VCard>().data();
|
Jreen::VCard *vcard = iq.findExtension<Jreen::VCard>().data();
|
||||||
if(vcard)
|
if(vcard)
|
||||||
{
|
{
|
||||||
iq.accept();
|
iq.accept();
|
||||||
@@ -86,7 +86,7 @@ void AvatarManager::onNewIq(const jreen::IQ& iq, int context)
|
|||||||
QString id = iq.from().full();
|
QString id = iq.from().full();
|
||||||
QString avatarHash;
|
QString avatarHash;
|
||||||
|
|
||||||
const jreen::VCard::Photo &photo = vcard->photo();
|
const Jreen::VCard::Photo &photo = vcard->photo();
|
||||||
if (!photo.data().isEmpty()) {
|
if (!photo.data().isEmpty()) {
|
||||||
qDebug() << "vcard: got photo data" << id;
|
qDebug() << "vcard: got photo data" << id;
|
||||||
|
|
||||||
@@ -118,8 +118,8 @@ void AvatarManager::onNewIq(const jreen::IQ& iq, int context)
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "got own vcard";
|
qDebug() << Q_FUNC_INFO << "got own vcard";
|
||||||
|
|
||||||
jreen::Presence presence = m_client->presence();
|
Jreen::Presence presence = m_client->presence();
|
||||||
jreen::VCardUpdate::Ptr update = presence.findExtension<jreen::VCardUpdate>();
|
Jreen::VCardUpdate::Ptr update = presence.findExtension<Jreen::VCardUpdate>();
|
||||||
if (update->photoHash() != avatarHash)
|
if (update->photoHash() != avatarHash)
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Updating own presence...";
|
qDebug() << Q_FUNC_INFO << "Updating own presence...";
|
||||||
|
@@ -12,7 +12,7 @@ class AvatarManager : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AvatarManager(jreen::Client *client);
|
AvatarManager(Jreen::Client *client);
|
||||||
virtual ~AvatarManager();
|
virtual ~AvatarManager();
|
||||||
|
|
||||||
QPixmap avatar(const QString &jid) const;
|
QPixmap avatar(const QString &jid) const;
|
||||||
@@ -21,8 +21,8 @@ signals:
|
|||||||
void newAvatar( const QString &jid );
|
void newAvatar( const QString &jid );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onNewPresence( const jreen::Presence& presence );
|
void onNewPresence( const Jreen::Presence& presence );
|
||||||
void onNewIq(const jreen::IQ &iq, int context = 0 );
|
void onNewIq(const Jreen::IQ &iq, int context = 0 );
|
||||||
void onNewConnection();
|
void onNewConnection();
|
||||||
void onNewAvatar( const QString &jid );
|
void onNewAvatar( const QString &jid );
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ private:
|
|||||||
QDir avatarDir(const QString &avatarHash) const;
|
QDir avatarDir(const QString &avatarHash) const;
|
||||||
bool isCached(const QString &avatarHash) const;
|
bool isCached(const QString &avatarHash) const;
|
||||||
|
|
||||||
jreen::Client *m_client;
|
Jreen::Client *m_client;
|
||||||
QStringList m_cachedAvatars;
|
QStringList m_cachedAvatars;
|
||||||
QDir m_cacheDir;
|
QDir m_cacheDir;
|
||||||
QMap<QString, QString> m_JidsAvatarHashes;
|
QMap<QString, QString> m_JidsAvatarHashes;
|
||||||
|
@@ -162,18 +162,18 @@ JabberPlugin::onAuthError( int code, const QString& msg )
|
|||||||
{
|
{
|
||||||
switch( code )
|
switch( code )
|
||||||
{
|
{
|
||||||
case jreen::Client::AuthorizationError:
|
case Jreen::Client::AuthorizationError:
|
||||||
emit error( SipPlugin::AuthError, msg );
|
emit error( SipPlugin::AuthError, msg );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case jreen::Client::HostUnknown:
|
case Jreen::Client::HostUnknown:
|
||||||
case jreen::Client::ItemNotFound:
|
case Jreen::Client::ItemNotFound:
|
||||||
case jreen::Client::RemoteStreamError:
|
case Jreen::Client::RemoteStreamError:
|
||||||
case jreen::Client::RemoteConnectionFailed:
|
case Jreen::Client::RemoteConnectionFailed:
|
||||||
case jreen::Client::InternalServerError:
|
case Jreen::Client::InternalServerError:
|
||||||
case jreen::Client::SystemShutdown:
|
case Jreen::Client::SystemShutdown:
|
||||||
case jreen::Client::Conflict:
|
case Jreen::Client::Conflict:
|
||||||
case jreen::Client::Unknown:
|
case Jreen::Client::Unknown:
|
||||||
emit error( SipPlugin::ConnectionError, msg );
|
emit error( SipPlugin::ConnectionError, msg );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -61,10 +61,10 @@ Jabber_p::Jabber_p( const QString& jid, const QString& password, const QString&
|
|||||||
qsrand(QDateTime::currentDateTime().toTime_t());
|
qsrand(QDateTime::currentDateTime().toTime_t());
|
||||||
|
|
||||||
// setup JID object
|
// setup JID object
|
||||||
m_jid = jreen::JID( jid );
|
m_jid = Jreen::JID( jid );
|
||||||
|
|
||||||
// general client setup
|
// general client setup
|
||||||
m_client = new jreen::Client( jid, password );
|
m_client = new Jreen::Client( jid, password );
|
||||||
if ( !server.isEmpty() )
|
if ( !server.isEmpty() )
|
||||||
{
|
{
|
||||||
m_client->setServer( server );
|
m_client->setServer( server );
|
||||||
@@ -74,18 +74,18 @@ Jabber_p::Jabber_p( const QString& jid, const QString& password, const QString&
|
|||||||
m_client->setResource( QString( "tomahawk%1" ).arg( QString::number( qrand() % 10000 ) ) );
|
m_client->setResource( QString( "tomahawk%1" ).arg( QString::number( qrand() % 10000 ) ) );
|
||||||
|
|
||||||
// add VCardUpdate extension to own presence
|
// add VCardUpdate extension to own presence
|
||||||
m_client->presence().addExtension( new jreen::VCardUpdate() );
|
m_client->presence().addExtension( new Jreen::VCardUpdate() );
|
||||||
|
|
||||||
// initialize the AvatarManager
|
// initialize the AvatarManager
|
||||||
m_avatarManager = new AvatarManager(m_client);
|
m_avatarManager = new AvatarManager(m_client);
|
||||||
|
|
||||||
// setup disco
|
// setup disco
|
||||||
m_client->disco()->setSoftwareVersion( "Tomahawk Player", TOMAHAWK_VERSION, CMAKE_SYSTEM );
|
m_client->disco()->setSoftwareVersion( "Tomahawk Player", TOMAHAWK_VERSION, CMAKE_SYSTEM );
|
||||||
m_client->disco()->addIdentity( jreen::Disco::Identity( "client", "type", "tomahawk", "en" ) );
|
m_client->disco()->addIdentity( Jreen::Disco::Identity( "client", "type", "tomahawk", "en" ) );
|
||||||
m_client->disco()->addFeature( TOMAHAWK_FEATURE );
|
m_client->disco()->addFeature( TOMAHAWK_FEATURE );
|
||||||
|
|
||||||
// setup caps node, legacy peer detection - used before 0.1
|
// setup caps node, legacy peer detection - used before 0.1
|
||||||
jreen::Capabilities::Ptr caps = m_client->presence().findExtension<jreen::Capabilities>();
|
Jreen::Capabilities::Ptr caps = m_client->presence().findExtension<Jreen::Capabilities>();
|
||||||
caps->setNode( TOMAHAWK_CAP_NODE_NAME );
|
caps->setNode( TOMAHAWK_CAP_NODE_NAME );
|
||||||
|
|
||||||
// print connection parameters
|
// print connection parameters
|
||||||
@@ -93,16 +93,16 @@ Jabber_p::Jabber_p( const QString& jid, const QString& password, const QString&
|
|||||||
qDebug() << "Our Server set to:" << m_client->server();
|
qDebug() << "Our Server set to:" << m_client->server();
|
||||||
qDebug() << "Our Port set to" << m_client->port();
|
qDebug() << "Our Port set to" << m_client->port();
|
||||||
|
|
||||||
m_client->setConnectionImpl( new jreen::TcpConnection( m_client->server(), m_client->port() ) );
|
m_client->setConnectionImpl( new Jreen::TcpConnection( m_client->server(), m_client->port() ) );
|
||||||
|
|
||||||
// setup slots
|
// setup slots
|
||||||
connect(qobject_cast<jreen::Connection*>(m_client->connection()), SIGNAL(error(const jreen::Connection::SocketError&)), SLOT(onError(const jreen::Connection::SocketError&)));
|
connect(qobject_cast<Jreen::Connection*>(m_client->connection()), SIGNAL(error(const Jreen::Connection::SocketError&)), SLOT(onError(const Jreen::Connection::SocketError&)));
|
||||||
connect(m_client, SIGNAL(serverFeaturesReceived(QSet<QString>)), SLOT(onConnect()));
|
connect(m_client, SIGNAL(serverFeaturesReceived(QSet<QString>)), SLOT(onConnect()));
|
||||||
connect(m_client, SIGNAL(disconnected(jreen::Client::DisconnectReason)), SLOT(onDisconnect(jreen::Client::DisconnectReason)));
|
connect(m_client, SIGNAL(disconnected(Jreen::Client::DisconnectReason)), SLOT(onDisconnect(Jreen::Client::DisconnectReason)));
|
||||||
connect(m_client, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroy(QObject*)));
|
connect(m_client, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroy(QObject*)));
|
||||||
connect(m_client, SIGNAL(newMessage(jreen::Message)), SLOT(onNewMessage(jreen::Message)));
|
connect(m_client, SIGNAL(newMessage(Jreen::Message)), SLOT(onNewMessage(Jreen::Message)));
|
||||||
connect(m_client, SIGNAL(newPresence(jreen::Presence)), SLOT(onNewPresence(jreen::Presence)));
|
connect(m_client, SIGNAL(newPresence(Jreen::Presence)), SLOT(onNewPresence(Jreen::Presence)));
|
||||||
connect(m_client, SIGNAL(newIQ(jreen::IQ)), SLOT(onNewIq(jreen::IQ)));
|
connect(m_client, SIGNAL(newIQ(Jreen::IQ)), SLOT(onNewIq(Jreen::IQ)));
|
||||||
|
|
||||||
connect(m_avatarManager, SIGNAL(newAvatar(QString)), SLOT(onNewAvatar(QString)));
|
connect(m_avatarManager, SIGNAL(newAvatar(QString)), SLOT(onNewAvatar(QString)));
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ Jabber_p::sendMsg( const QString& to, const QString& msg )
|
|||||||
if( m_legacy_peers.contains( to ) )
|
if( m_legacy_peers.contains( to ) )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << to << "Send legacy message" << msg;
|
qDebug() << Q_FUNC_INFO << to << "Send legacy message" << msg;
|
||||||
jreen::Message m( jreen::Message::Chat, jreen::JID(to), msg);
|
Jreen::Message m( Jreen::Message::Chat, Jreen::JID(to), msg);
|
||||||
m_client->send( m );
|
m_client->send( m );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -184,10 +184,10 @@ Jabber_p::sendMsg( const QString& to, const QString& msg )
|
|||||||
|
|
||||||
|
|
||||||
qDebug() << "Send sip messsage to " << to;
|
qDebug() << "Send sip messsage to " << to;
|
||||||
jreen::IQ iq( jreen::IQ::Set, to );
|
Jreen::IQ iq( Jreen::IQ::Set, to );
|
||||||
iq.addExtension( sipMessage );
|
iq.addExtension( sipMessage );
|
||||||
|
|
||||||
m_client->send( iq, this, SLOT( onNewIq( jreen::IQ, int ) ), SipMessageSent );
|
m_client->send( iq, this, SLOT( onNewIq( Jreen::IQ, int ) ), SipMessageSent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -234,31 +234,31 @@ Jabber_p::onConnect()
|
|||||||
qDebug() << "Connected as:" << m_jid.full();
|
qDebug() << "Connected as:" << m_jid.full();
|
||||||
|
|
||||||
// set presence to least valid value
|
// set presence to least valid value
|
||||||
m_client->setPresence(jreen::Presence::XA, "Got Tomahawk? http://gettomahawk.com", -127);
|
m_client->setPresence(Jreen::Presence::XA, "Got Tomahawk? http://gettomahawk.com", -127);
|
||||||
|
|
||||||
// set ping timeout to 15 secs (TODO: verify if this works)
|
// set ping timeout to 15 secs (TODO: verify if this works)
|
||||||
m_client->setPingInterval(15000);
|
m_client->setPingInterval(15000);
|
||||||
|
|
||||||
// load roster
|
// load roster
|
||||||
m_roster = new jreen::SimpleRoster( m_client );
|
m_roster = new Jreen::SimpleRoster( m_client );
|
||||||
m_roster->load();
|
m_roster->load();
|
||||||
|
|
||||||
//FIXME: this implementation is totally broken atm, so it's disabled to avoid harm :P
|
//FIXME: this implementation is totally broken atm, so it's disabled to avoid harm :P
|
||||||
// join MUC with bare jid as nickname
|
// join MUC with bare jid as nickname
|
||||||
//TODO: make the room a list of rooms and make that configurable
|
//TODO: make the room a list of rooms and make that configurable
|
||||||
QString mucNickname = QString( "tomahawk@conference.qutim.org/" ).append( QString( m_jid.bare() ).replace( "@", "-" ) );
|
QString mucNickname = QString( "tomahawk@conference.qutim.org/" ).append( QString( m_jid.bare() ).replace( "@", "-" ) );
|
||||||
m_room = new jreen::MUCRoom(m_client, jreen::JID( mucNickname ) );
|
m_room = new Jreen::MUCRoom(m_client, Jreen::JID( mucNickname ) );
|
||||||
//m_room->setHistorySeconds(0);
|
//m_room->setHistorySeconds(0);
|
||||||
//m_room->join();
|
//m_room->join();
|
||||||
|
|
||||||
// treat muc participiants like contacts
|
// treat muc participiants like contacts
|
||||||
connect( m_room, SIGNAL( messageReceived( jreen::Message, bool ) ), this, SLOT( onNewMessage( jreen::Message ) ) );
|
connect( m_room, SIGNAL( messageReceived( Jreen::Message, bool ) ), this, SLOT( onNewMessage( Jreen::Message ) ) );
|
||||||
connect( m_room, SIGNAL( presenceReceived( jreen::Presence, const jreen::MUCRoom::Participant* ) ), this, SLOT( onNewPresence( jreen::Presence ) ) );
|
connect( m_room, SIGNAL( presenceReceived( Jreen::Presence, const Jreen::MUCRoom::Participant* ) ), this, SLOT( onNewPresence( Jreen::Presence ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Jabber_p::onDisconnect( jreen::Client::DisconnectReason reason )
|
Jabber_p::onDisconnect( Jreen::Client::DisconnectReason reason )
|
||||||
{
|
{
|
||||||
QString error;
|
QString error;
|
||||||
bool reconnect = false;
|
bool reconnect = false;
|
||||||
@@ -266,39 +266,39 @@ Jabber_p::onDisconnect( jreen::Client::DisconnectReason reason )
|
|||||||
|
|
||||||
switch( reason )
|
switch( reason )
|
||||||
{
|
{
|
||||||
case jreen::Client::User:
|
case Jreen::Client::User:
|
||||||
error = "User Interaction";
|
error = "User Interaction";
|
||||||
break;
|
break;
|
||||||
case jreen::Client::HostUnknown:
|
case Jreen::Client::HostUnknown:
|
||||||
error = "Host is unknown";
|
error = "Host is unknown";
|
||||||
break;
|
break;
|
||||||
case jreen::Client::ItemNotFound:
|
case Jreen::Client::ItemNotFound:
|
||||||
error = "Item not found";
|
error = "Item not found";
|
||||||
break;
|
break;
|
||||||
case jreen::Client::AuthorizationError:
|
case Jreen::Client::AuthorizationError:
|
||||||
error = "Authorization Error";
|
error = "Authorization Error";
|
||||||
break;
|
break;
|
||||||
case jreen::Client::RemoteStreamError:
|
case Jreen::Client::RemoteStreamError:
|
||||||
error = "Remote Stream Error";
|
error = "Remote Stream Error";
|
||||||
reconnect = true;
|
reconnect = true;
|
||||||
break;
|
break;
|
||||||
case jreen::Client::RemoteConnectionFailed:
|
case Jreen::Client::RemoteConnectionFailed:
|
||||||
error = "Remote Connection failed";
|
error = "Remote Connection failed";
|
||||||
break;
|
break;
|
||||||
case jreen::Client::InternalServerError:
|
case Jreen::Client::InternalServerError:
|
||||||
error = "Internal Server Error";
|
error = "Internal Server Error";
|
||||||
reconnect = true;
|
reconnect = true;
|
||||||
break;
|
break;
|
||||||
case jreen::Client::SystemShutdown:
|
case Jreen::Client::SystemShutdown:
|
||||||
error = "System shutdown";
|
error = "System shutdown";
|
||||||
reconnect = true;
|
reconnect = true;
|
||||||
reconnectInSeconds = 60;
|
reconnectInSeconds = 60;
|
||||||
break;
|
break;
|
||||||
case jreen::Client::Conflict:
|
case Jreen::Client::Conflict:
|
||||||
error = "Conflict";
|
error = "Conflict";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case jreen::Client::Unknown:
|
case Jreen::Client::Unknown:
|
||||||
error = "Unknown";
|
error = "Unknown";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -309,7 +309,7 @@ Jabber_p::onDisconnect( jreen::Client::DisconnectReason reason )
|
|||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "Disconnected from server:" << error;
|
qDebug() << "Disconnected from server:" << error;
|
||||||
if( reason != jreen::Client::User )
|
if( reason != Jreen::Client::User )
|
||||||
{
|
{
|
||||||
emit authError( reason, error );
|
emit authError( reason, error );
|
||||||
}
|
}
|
||||||
@@ -321,7 +321,7 @@ Jabber_p::onDisconnect( jreen::Client::DisconnectReason reason )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Jabber_p::onNewMessage( const jreen::Message& m )
|
Jabber_p::onNewMessage( const Jreen::Message& m )
|
||||||
{
|
{
|
||||||
QString from = m.from().full();
|
QString from = m.from().full();
|
||||||
QString msg = m.body();
|
QString msg = m.body();
|
||||||
@@ -340,7 +340,7 @@ Jabber_p::onNewMessage( const jreen::Message& m )
|
|||||||
" are trying to reach is probably not signed on, so please try again later!") );
|
" are trying to reach is probably not signed on, so please try again later!") );
|
||||||
|
|
||||||
// this is not a sip message, so we send it directly through the client
|
// this is not a sip message, so we send it directly through the client
|
||||||
m_client->send( jreen::Message ( jreen::Message::Chat, jreen::JID(to), response) );
|
m_client->send( Jreen::Message ( Jreen::Message::Chat, Jreen::JID(to), response) );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -350,9 +350,9 @@ Jabber_p::onNewMessage( const jreen::Message& m )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Jabber_p::onNewPresence( const jreen::Presence& presence)
|
void Jabber_p::onNewPresence( const Jreen::Presence& presence)
|
||||||
{
|
{
|
||||||
jreen::JID jid = presence.from();
|
Jreen::JID jid = presence.from();
|
||||||
QString fulljid( jid.full() );
|
QString fulljid( jid.full() );
|
||||||
|
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ void Jabber_p::onNewPresence( const jreen::Presence& presence)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ignore anyone not Running tomahawk:
|
// ignore anyone not Running tomahawk:
|
||||||
jreen::Capabilities::Ptr caps = presence.findExtension<jreen::Capabilities>();
|
Jreen::Capabilities::Ptr caps = presence.findExtension<Jreen::Capabilities>();
|
||||||
if ( caps && ( caps->node() == TOMAHAWK_CAP_NODE_NAME ) )
|
if ( caps && ( caps->node() == TOMAHAWK_CAP_NODE_NAME ) )
|
||||||
{
|
{
|
||||||
// must be a jreen resource, implementation in gloox was broken
|
// must be a jreen resource, implementation in gloox was broken
|
||||||
@@ -382,10 +382,10 @@ void Jabber_p::onNewPresence( const jreen::Presence& presence)
|
|||||||
// request disco features
|
// request disco features
|
||||||
QString node = caps->node() + '#' + caps->ver();
|
QString node = caps->node() + '#' + caps->ver();
|
||||||
|
|
||||||
jreen::IQ iq( jreen::IQ::Get, jid );
|
Jreen::IQ iq( Jreen::IQ::Get, jid );
|
||||||
iq.addExtension( new jreen::Disco::Info( node ) );
|
iq.addExtension( new Jreen::Disco::Info( node ) );
|
||||||
|
|
||||||
m_client->send( iq, this, SLOT( onNewIq( jreen::IQ, int ) ), RequestDisco );
|
m_client->send( iq, this, SLOT( onNewIq( Jreen::IQ, int ) ), RequestDisco );
|
||||||
}
|
}
|
||||||
else if( !caps )
|
else if( !caps )
|
||||||
{
|
{
|
||||||
@@ -394,25 +394,25 @@ void Jabber_p::onNewPresence( const jreen::Presence& presence)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Jabber_p::onNewIq( const jreen::IQ &iq, int context )
|
Jabber_p::onNewIq( const Jreen::IQ &iq, int context )
|
||||||
{
|
{
|
||||||
if( context == RequestDisco )
|
if( context == RequestDisco )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Received disco IQ...";
|
qDebug() << Q_FUNC_INFO << "Received disco IQ...";
|
||||||
jreen::Disco::Info *discoInfo = iq.findExtension<jreen::Disco::Info>().data();
|
Jreen::Disco::Info *discoInfo = iq.findExtension<Jreen::Disco::Info>().data();
|
||||||
if(!discoInfo)
|
if(!discoInfo)
|
||||||
return;
|
return;
|
||||||
iq.accept();
|
iq.accept();
|
||||||
|
|
||||||
QString fulljid = iq.from().full();
|
QString fulljid = iq.from().full();
|
||||||
jreen::DataForm::Ptr form = discoInfo->form();
|
Jreen::DataForm::Ptr form = discoInfo->form();
|
||||||
|
|
||||||
if(discoInfo->features().contains( TOMAHAWK_FEATURE ))
|
if(discoInfo->features().contains( TOMAHAWK_FEATURE ))
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk/feature enabled: yes";
|
qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk/feature enabled: yes";
|
||||||
|
|
||||||
// the actual presence doesn't matter, it just needs to be "online"
|
// the actual presence doesn't matter, it just needs to be "online"
|
||||||
handlePeerStatus( fulljid, jreen::Presence::Available );
|
handlePeerStatus( fulljid, Jreen::Presence::Available );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -426,7 +426,7 @@ Jabber_p::onNewIq( const jreen::IQ &iq, int context )
|
|||||||
// add to legacy peers, so we can send text messages instead of iqs
|
// add to legacy peers, so we can send text messages instead of iqs
|
||||||
m_legacy_peers.append( fulljid );
|
m_legacy_peers.append( fulljid );
|
||||||
|
|
||||||
handlePeerStatus( fulljid, jreen::Presence::Available );
|
handlePeerStatus( fulljid, Jreen::Presence::Available );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -485,13 +485,13 @@ Jabber_p::onNewIq( const jreen::IQ &iq, int context )
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Jabber_p::presenceMeansOnline( jreen::Presence::Type p )
|
Jabber_p::presenceMeansOnline( Jreen::Presence::Type p )
|
||||||
{
|
{
|
||||||
switch(p)
|
switch(p)
|
||||||
{
|
{
|
||||||
case jreen::Presence::Invalid:
|
case Jreen::Presence::Invalid:
|
||||||
case jreen::Presence::Unavailable:
|
case Jreen::Presence::Unavailable:
|
||||||
case jreen::Presence::Error:
|
case Jreen::Presence::Error:
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -500,7 +500,7 @@ Jabber_p::presenceMeansOnline( jreen::Presence::Type p )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Jabber_p::handlePeerStatus( const jreen::JID& jid, jreen::Presence::Type presenceType )
|
Jabber_p::handlePeerStatus( const Jreen::JID& jid, Jreen::Presence::Type presenceType )
|
||||||
{
|
{
|
||||||
QString fulljid = jid.full();
|
QString fulljid = jid.full();
|
||||||
|
|
||||||
|
@@ -75,13 +75,13 @@ public slots:
|
|||||||
void addContact( const QString& jid, const QString& msg = QString() );
|
void addContact( const QString& jid, const QString& msg = QString() );
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
|
||||||
void onDisconnect(jreen::Client::DisconnectReason reason);
|
void onDisconnect(Jreen::Client::DisconnectReason reason);
|
||||||
void onConnect();
|
void onConnect();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
virtual void onNewPresence( const jreen::Presence& presence );
|
virtual void onNewPresence( const Jreen::Presence& presence );
|
||||||
virtual void onNewMessage( const jreen::Message& msg );
|
virtual void onNewMessage( const Jreen::Message& msg );
|
||||||
virtual void onError( const jreen::Connection::SocketError& e )
|
virtual void onError( const Jreen::Connection::SocketError& e )
|
||||||
{
|
{
|
||||||
qDebug() << e;
|
qDebug() << e;
|
||||||
}
|
}
|
||||||
@@ -89,19 +89,19 @@ private slots:
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
}
|
}
|
||||||
virtual void onNewIq( const jreen::IQ &iq, int context = NoContext );
|
virtual void onNewIq( const Jreen::IQ &iq, int context = NoContext );
|
||||||
virtual void onNewAvatar( const QString &jid );
|
virtual void onNewAvatar( const QString &jid );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool presenceMeansOnline( jreen::Presence::Type p );
|
bool presenceMeansOnline( Jreen::Presence::Type p );
|
||||||
void handlePeerStatus( const jreen::JID &jid, jreen::Presence::Type presenceType );
|
void handlePeerStatus( const Jreen::JID &jid, Jreen::Presence::Type presenceType );
|
||||||
|
|
||||||
jreen::Client *m_client;
|
Jreen::Client *m_client;
|
||||||
jreen::MUCRoom *m_room;
|
Jreen::MUCRoom *m_room;
|
||||||
jreen::SimpleRoster *m_roster;
|
Jreen::SimpleRoster *m_roster;
|
||||||
jreen::JID m_jid;
|
Jreen::JID m_jid;
|
||||||
QMap<jreen::Presence::Type, QString> m_presences;
|
QMap<Jreen::Presence::Type, QString> m_presences;
|
||||||
QMap<QString, jreen::Presence::Type> m_peers;
|
QMap<QString, Jreen::Presence::Type> m_peers;
|
||||||
QString m_server;
|
QString m_server;
|
||||||
|
|
||||||
enum IqContext { NoContext, RequestDisco, RequestedDisco, SipMessageSent, RequestedVCard };
|
enum IqContext { NoContext, RequestDisco, RequestedDisco, SipMessageSent, RequestedVCard };
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
#define TOMAHAWK_SIP_MESSAGE_NS QLatin1String("http://www.tomhawk-player.org/sip/transports")
|
#define TOMAHAWK_SIP_MESSAGE_NS QLatin1String("http://www.tomhawk-player.org/sip/transports")
|
||||||
|
|
||||||
class TomahawkSipMessagePrivate;
|
class TomahawkSipMessagePrivate;
|
||||||
class TomahawkSipMessage : public jreen::StanzaExtension
|
class TomahawkSipMessage : public Jreen::StanzaExtension
|
||||||
{
|
{
|
||||||
J_EXTENSION(TomahawkSipMessage, "")
|
J_EXTENSION(TomahawkSipMessage, "")
|
||||||
Q_DECLARE_PRIVATE(TomahawkSipMessage)
|
Q_DECLARE_PRIVATE(TomahawkSipMessage)
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
using namespace jreen;
|
using namespace Jreen;
|
||||||
|
|
||||||
TomahawkSipMessageFactory::TomahawkSipMessageFactory()
|
TomahawkSipMessageFactory::TomahawkSipMessageFactory()
|
||||||
{
|
{
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <jreen/stanzaextension.h>
|
#include <jreen/stanzaextension.h>
|
||||||
|
|
||||||
class TomahawkSipMessageFactory : public jreen::StanzaExtensionFactory<TomahawkSipMessage>
|
class TomahawkSipMessageFactory : public Jreen::StanzaExtensionFactory<TomahawkSipMessage>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TomahawkSipMessageFactory();
|
TomahawkSipMessageFactory();
|
||||||
@@ -31,8 +31,8 @@ public:
|
|||||||
void handleStartElement(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes);
|
void handleStartElement(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes);
|
||||||
void handleEndElement(const QStringRef &name, const QStringRef &uri);
|
void handleEndElement(const QStringRef &name, const QStringRef &uri);
|
||||||
void handleCharacterData(const QStringRef &text);
|
void handleCharacterData(const QStringRef &text);
|
||||||
void serialize(jreen::StanzaExtension *extension, QXmlStreamWriter *writer);
|
void serialize(Jreen::StanzaExtension *extension, QXmlStreamWriter *writer);
|
||||||
jreen::StanzaExtension::Ptr createExtension();
|
Jreen::StanzaExtension::Ptr createExtension();
|
||||||
private:
|
private:
|
||||||
enum State { AtNowhere, AtTransport, AtCandidate } m_state;
|
enum State { AtNowhere, AtTransport, AtCandidate } m_state;
|
||||||
int m_depth;
|
int m_depth;
|
||||||
|
Reference in New Issue
Block a user