1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-16 11:04:01 +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:
Jeff Mitchell
2011-04-22 10:46:29 -04:00
parent 056efe2cd9
commit 41f1ac9713
8 changed files with 93 additions and 93 deletions

View File

@@ -12,7 +12,7 @@
#include <QCryptographicHash>
#include <QPixmap>
AvatarManager::AvatarManager(Jreen::Client *client) :
AvatarManager::AvatarManager(jreen::Client *client) :
m_cacheDir(TomahawkUtils::appDataDir().absolutePath().append("/jreen/"))
{
m_client = client;
@@ -20,8 +20,8 @@ AvatarManager::AvatarManager(Jreen::Client *client) :
m_cachedAvatars = m_cacheDir.entryList();
connect(m_client, SIGNAL(serverFeaturesReceived(QSet<QString>)), SLOT(onNewConnection()));
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(newPresence(jreen::Presence)), SLOT(onNewPresence(jreen::Presence)));
connect(m_client, SIGNAL(newIQ(jreen::IQ)), SLOT(onNewIq(jreen::IQ)));
connect(this, SIGNAL(newAvatar(QString)), SLOT(onNewAvatar(QString)));
}
@@ -40,14 +40,14 @@ void AvatarManager::fetchVCard(const QString &jid)
{
qDebug() << Q_FUNC_INFO;
Jreen::IQ iq(Jreen::IQ::Get, jid );
iq.addExtension(new Jreen::VCard());
m_client->send( iq, this, SLOT( onNewIq( Jreen::IQ, int ) ), 0 );
jreen::IQ iq(jreen::IQ::Get, jid );
iq.addExtension(new jreen::VCard());
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)
{
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)
{
iq.accept();
@@ -86,7 +86,7 @@ void AvatarManager::onNewIq(const Jreen::IQ& iq, int context)
QString id = iq.from().full();
QString avatarHash;
const Jreen::VCard::Photo &photo = vcard->photo();
const jreen::VCard::Photo &photo = vcard->photo();
if (!photo.data().isEmpty()) {
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";
Jreen::Presence presence = m_client->presence();
Jreen::VCardUpdate::Ptr update = presence.findExtension<Jreen::VCardUpdate>();
jreen::Presence presence = m_client->presence();
jreen::VCardUpdate::Ptr update = presence.findExtension<jreen::VCardUpdate>();
if (update->photoHash() != avatarHash)
{
qDebug() << Q_FUNC_INFO << "Updating own presence...";

View File

@@ -12,7 +12,7 @@ class AvatarManager : public QObject
Q_OBJECT
public:
AvatarManager(Jreen::Client *client);
AvatarManager(jreen::Client *client);
virtual ~AvatarManager();
QPixmap avatar(const QString &jid) const;
@@ -21,8 +21,8 @@ signals:
void newAvatar( const QString &jid );
private slots:
void onNewPresence( const Jreen::Presence& presence );
void onNewIq(const Jreen::IQ &iq, int context = 0 );
void onNewPresence( const jreen::Presence& presence );
void onNewIq(const jreen::IQ &iq, int context = 0 );
void onNewConnection();
void onNewAvatar( const QString &jid );
@@ -34,7 +34,7 @@ private:
QDir avatarDir(const QString &avatarHash) const;
bool isCached(const QString &avatarHash) const;
Jreen::Client *m_client;
jreen::Client *m_client;
QStringList m_cachedAvatars;
QDir m_cacheDir;
QMap<QString, QString> m_JidsAvatarHashes;

View File

@@ -162,18 +162,18 @@ JabberPlugin::onAuthError( int code, const QString& msg )
{
switch( code )
{
case Jreen::Client::AuthorizationError:
case jreen::Client::AuthorizationError:
emit error( SipPlugin::AuthError, msg );
break;
case Jreen::Client::HostUnknown:
case Jreen::Client::ItemNotFound:
case Jreen::Client::RemoteStreamError:
case Jreen::Client::RemoteConnectionFailed:
case Jreen::Client::InternalServerError:
case Jreen::Client::SystemShutdown:
case Jreen::Client::Conflict:
case Jreen::Client::Unknown:
case jreen::Client::HostUnknown:
case jreen::Client::ItemNotFound:
case jreen::Client::RemoteStreamError:
case jreen::Client::RemoteConnectionFailed:
case jreen::Client::InternalServerError:
case jreen::Client::SystemShutdown:
case jreen::Client::Conflict:
case jreen::Client::Unknown:
emit error( SipPlugin::ConnectionError, msg );
break;

View File

@@ -61,10 +61,10 @@ Jabber_p::Jabber_p( const QString& jid, const QString& password, const QString&
qsrand(QDateTime::currentDateTime().toTime_t());
// setup JID object
m_jid = Jreen::JID( jid );
m_jid = jreen::JID( jid );
// general client setup
m_client = new Jreen::Client( jid, password );
m_client = new jreen::Client( jid, password );
if ( !server.isEmpty() )
{
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 ) ) );
// add VCardUpdate extension to own presence
m_client->presence().addExtension( new Jreen::VCardUpdate() );
m_client->presence().addExtension( new jreen::VCardUpdate() );
// initialize the AvatarManager
m_avatarManager = new AvatarManager(m_client);
// setup disco
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 );
// 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 );
// 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 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
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(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(newMessage(Jreen::Message)), SLOT(onNewMessage(Jreen::Message)));
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(newMessage(jreen::Message)), SLOT(onNewMessage(jreen::Message)));
connect(m_client, SIGNAL(newPresence(jreen::Presence)), SLOT(onNewPresence(jreen::Presence)));
connect(m_client, SIGNAL(newIQ(jreen::IQ)), SLOT(onNewIq(jreen::IQ)));
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 ) )
{
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 );
return;
@@ -184,10 +184,10 @@ Jabber_p::sendMsg( const QString& to, const QString& msg )
qDebug() << "Send sip messsage to " << to;
Jreen::IQ iq( Jreen::IQ::Set, to );
jreen::IQ iq( jreen::IQ::Set, to );
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();
// 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)
m_client->setPingInterval(15000);
// load roster
m_roster = new Jreen::SimpleRoster( m_client );
m_roster = new jreen::SimpleRoster( m_client );
m_roster->load();
//FIXME: this implementation is totally broken atm, so it's disabled to avoid harm :P
// join MUC with bare jid as nickname
//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( "@", "-" ) );
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->join();
// treat muc participiants like contacts
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( 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 ) ) );
}
void
Jabber_p::onDisconnect( Jreen::Client::DisconnectReason reason )
Jabber_p::onDisconnect( jreen::Client::DisconnectReason reason )
{
QString error;
bool reconnect = false;
@@ -266,39 +266,39 @@ Jabber_p::onDisconnect( Jreen::Client::DisconnectReason reason )
switch( reason )
{
case Jreen::Client::User:
case jreen::Client::User:
error = "User Interaction";
break;
case Jreen::Client::HostUnknown:
case jreen::Client::HostUnknown:
error = "Host is unknown";
break;
case Jreen::Client::ItemNotFound:
case jreen::Client::ItemNotFound:
error = "Item not found";
break;
case Jreen::Client::AuthorizationError:
case jreen::Client::AuthorizationError:
error = "Authorization Error";
break;
case Jreen::Client::RemoteStreamError:
case jreen::Client::RemoteStreamError:
error = "Remote Stream Error";
reconnect = true;
break;
case Jreen::Client::RemoteConnectionFailed:
case jreen::Client::RemoteConnectionFailed:
error = "Remote Connection failed";
break;
case Jreen::Client::InternalServerError:
case jreen::Client::InternalServerError:
error = "Internal Server Error";
reconnect = true;
break;
case Jreen::Client::SystemShutdown:
case jreen::Client::SystemShutdown:
error = "System shutdown";
reconnect = true;
reconnectInSeconds = 60;
break;
case Jreen::Client::Conflict:
case jreen::Client::Conflict:
error = "Conflict";
break;
case Jreen::Client::Unknown:
case jreen::Client::Unknown:
error = "Unknown";
break;
@@ -309,7 +309,7 @@ Jabber_p::onDisconnect( Jreen::Client::DisconnectReason reason )
}
qDebug() << "Disconnected from server:" << error;
if( reason != Jreen::Client::User )
if( reason != jreen::Client::User )
{
emit authError( reason, error );
}
@@ -321,7 +321,7 @@ Jabber_p::onDisconnect( Jreen::Client::DisconnectReason reason )
}
void
Jabber_p::onNewMessage( const Jreen::Message& m )
Jabber_p::onNewMessage( const jreen::Message& m )
{
QString from = m.from().full();
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!") );
// 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;
}
@@ -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() );
@@ -367,7 +367,7 @@ void Jabber_p::onNewPresence( const Jreen::Presence& presence)
}
// 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 ) )
{
// 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
QString node = caps->node() + '#' + caps->ver();
Jreen::IQ iq( Jreen::IQ::Get, jid );
iq.addExtension( new Jreen::Disco::Info( node ) );
jreen::IQ iq( jreen::IQ::Get, jid );
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 )
{
@@ -394,25 +394,25 @@ void Jabber_p::onNewPresence( const Jreen::Presence& presence)
}
void
Jabber_p::onNewIq( const Jreen::IQ &iq, int context )
Jabber_p::onNewIq( const jreen::IQ &iq, int context )
{
if( context == RequestDisco )
{
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)
return;
iq.accept();
QString fulljid = iq.from().full();
Jreen::DataForm::Ptr form = discoInfo->form();
jreen::DataForm::Ptr form = discoInfo->form();
if(discoInfo->features().contains( TOMAHAWK_FEATURE ))
{
qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk/feature enabled: yes";
// the actual presence doesn't matter, it just needs to be "online"
handlePeerStatus( fulljid, Jreen::Presence::Available );
handlePeerStatus( fulljid, jreen::Presence::Available );
}
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
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
Jabber_p::presenceMeansOnline( Jreen::Presence::Type p )
Jabber_p::presenceMeansOnline( jreen::Presence::Type p )
{
switch(p)
{
case Jreen::Presence::Invalid:
case Jreen::Presence::Unavailable:
case Jreen::Presence::Error:
case jreen::Presence::Invalid:
case jreen::Presence::Unavailable:
case jreen::Presence::Error:
return false;
break;
default:
@@ -500,7 +500,7 @@ Jabber_p::presenceMeansOnline( Jreen::Presence::Type p )
}
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();

View File

@@ -75,13 +75,13 @@ public slots:
void addContact( const QString& jid, const QString& msg = QString() );
void disconnect();
void onDisconnect(Jreen::Client::DisconnectReason reason);
void onDisconnect(jreen::Client::DisconnectReason reason);
void onConnect();
private slots:
virtual void onNewPresence( const Jreen::Presence& presence );
virtual void onNewMessage( const Jreen::Message& msg );
virtual void onError( const Jreen::Connection::SocketError& e )
virtual void onNewPresence( const jreen::Presence& presence );
virtual void onNewMessage( const jreen::Message& msg );
virtual void onError( const jreen::Connection::SocketError& e )
{
qDebug() << e;
}
@@ -89,19 +89,19 @@ private slots:
{
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 );
private:
bool presenceMeansOnline( Jreen::Presence::Type p );
void handlePeerStatus( const Jreen::JID &jid, Jreen::Presence::Type presenceType );
bool presenceMeansOnline( jreen::Presence::Type p );
void handlePeerStatus( const jreen::JID &jid, jreen::Presence::Type presenceType );
Jreen::Client *m_client;
Jreen::MUCRoom *m_room;
Jreen::SimpleRoster *m_roster;
Jreen::JID m_jid;
QMap<Jreen::Presence::Type, QString> m_presences;
QMap<QString, Jreen::Presence::Type> m_peers;
jreen::Client *m_client;
jreen::MUCRoom *m_room;
jreen::SimpleRoster *m_roster;
jreen::JID m_jid;
QMap<jreen::Presence::Type, QString> m_presences;
QMap<QString, jreen::Presence::Type> m_peers;
QString m_server;
enum IqContext { NoContext, RequestDisco, RequestedDisco, SipMessageSent, RequestedVCard };

View File

@@ -6,7 +6,7 @@
#define TOMAHAWK_SIP_MESSAGE_NS QLatin1String("http://www.tomhawk-player.org/sip/transports")
class TomahawkSipMessagePrivate;
class TomahawkSipMessage : public Jreen::StanzaExtension
class TomahawkSipMessage : public jreen::StanzaExtension
{
J_EXTENSION(TomahawkSipMessage, "")
Q_DECLARE_PRIVATE(TomahawkSipMessage)

View File

@@ -5,7 +5,7 @@
#include <QDebug>
#include <QVariant>
using namespace Jreen;
using namespace jreen;
TomahawkSipMessageFactory::TomahawkSipMessageFactory()
{

View File

@@ -21,7 +21,7 @@
#include <jreen/stanzaextension.h>
class TomahawkSipMessageFactory : public Jreen::StanzaExtensionFactory<TomahawkSipMessage>
class TomahawkSipMessageFactory : public jreen::StanzaExtensionFactory<TomahawkSipMessage>
{
public:
TomahawkSipMessageFactory();
@@ -31,8 +31,8 @@ public:
void handleStartElement(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes);
void handleEndElement(const QStringRef &name, const QStringRef &uri);
void handleCharacterData(const QStringRef &text);
void serialize(Jreen::StanzaExtension *extension, QXmlStreamWriter *writer);
Jreen::StanzaExtension::Ptr createExtension();
void serialize(jreen::StanzaExtension *extension, QXmlStreamWriter *writer);
jreen::StanzaExtension::Ptr createExtension();
private:
enum State { AtNowhere, AtTransport, AtCandidate } m_state;
int m_depth;