mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-17 19:37:09 +02:00
The Jreen guys went and changed capitalization of their namespace, which
is why build was failing. Jreen-- or, I guess, jreen++
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