mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-25 18:30:20 +01:00
Merge pull request #31 from euroelessar/master
Changes due to modified Jreen API
This commit is contained in:
commit
95a335813d
@ -6,6 +6,7 @@
|
||||
#include <jreen/vcard.h>
|
||||
#include <jreen/vcardupdate.h>
|
||||
#include <jreen/presence.h>
|
||||
#include <jreen/iqreply.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
@ -20,8 +21,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(presenceReceived(Jreen::Presence)), SLOT(onNewPresence(Jreen::Presence)));
|
||||
connect(m_client, SIGNAL(iqReceived(Jreen::IQ)), SLOT(onNewIq(Jreen::IQ)));
|
||||
|
||||
connect(this, SIGNAL(newAvatar(QString)), SLOT(onNewAvatar(QString)));
|
||||
}
|
||||
@ -42,12 +43,13 @@ void AvatarManager::fetchVCard(const QString &jid)
|
||||
|
||||
Jreen::IQ iq(Jreen::IQ::Get, jid );
|
||||
iq.addExtension(new Jreen::VCard());
|
||||
m_client->send( iq, this, SLOT( onNewIq( Jreen::IQ, int ) ), 0 );
|
||||
Jreen::IQReply *reply = m_client->send(iq);
|
||||
connect(reply, SIGNAL(received(Jreen::IQ)), SLOT(onNewIq(Jreen::IQ)));
|
||||
}
|
||||
|
||||
void AvatarManager::onNewPresence(const Jreen::Presence& presence)
|
||||
{
|
||||
Jreen::VCardUpdate::Ptr update = presence.findExtension<Jreen::VCardUpdate>();
|
||||
Jreen::VCardUpdate::Ptr update = presence.payload<Jreen::VCardUpdate>();
|
||||
if(update)
|
||||
{
|
||||
// qDebug() << "vcard: found update for" << presence.from().full();
|
||||
@ -74,9 +76,9 @@ void AvatarManager::onNewPresence(const Jreen::Presence& presence)
|
||||
}
|
||||
}
|
||||
|
||||
void AvatarManager::onNewIq(const Jreen::IQ& iq, int context)
|
||||
void AvatarManager::onNewIq(const Jreen::IQ& iq)
|
||||
{
|
||||
Jreen::VCard *vcard = iq.findExtension<Jreen::VCard>().data();
|
||||
Jreen::VCard::Ptr vcard = iq.payload<Jreen::VCard>();
|
||||
if(vcard)
|
||||
{
|
||||
iq.accept();
|
||||
@ -119,7 +121,7 @@ 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::VCardUpdate::Ptr update = presence.payload<Jreen::VCardUpdate>();
|
||||
if (update->photoHash() != avatarHash)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "Updating own presence...";
|
||||
|
@ -23,7 +23,7 @@ signals:
|
||||
|
||||
private slots:
|
||||
void onNewPresence( const Jreen::Presence& presence );
|
||||
void onNewIq(const Jreen::IQ &iq, int context = 0 );
|
||||
void onNewIq(const Jreen::IQ &iq);
|
||||
void onNewConnection();
|
||||
void onNewAvatar( const QString &jid );
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <jreen/directconnection.h>
|
||||
#include <jreen/tcpconnection.h>
|
||||
#include <jreen/softwareversion.h>
|
||||
#include <jreen/iqreply.h>
|
||||
|
||||
#include <qjson/parser.h>
|
||||
#include <qjson/serializer.h>
|
||||
@ -91,7 +92,7 @@ JabberPlugin::JabberPlugin( const QString& pluginId )
|
||||
m_client = new Jreen::Client( jid, m_currentPassword );
|
||||
setupClientHelper();
|
||||
|
||||
m_client->registerStanzaExtension(new TomahawkSipMessageFactory);
|
||||
m_client->registerPayload(new TomahawkSipMessageFactory);
|
||||
m_currentResource = QString::fromAscii( "tomahawk%1" ).arg( QString::number( qrand() % 10000 ) );
|
||||
m_client->setResource( m_currentResource );
|
||||
|
||||
@ -117,7 +118,7 @@ JabberPlugin::JabberPlugin( const QString& pluginId )
|
||||
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().payload<Jreen::Capabilities>();
|
||||
caps->setNode( TOMAHAWK_CAP_NODE_NAME );
|
||||
//FIXME: caps->setVersion( TOMAHAWK_VERSION );
|
||||
|
||||
@ -129,9 +130,9 @@ JabberPlugin::JabberPlugin( const QString& pluginId )
|
||||
// setup slots
|
||||
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(newMessage(Jreen::Message)), SLOT(onNewMessage(Jreen::Message)));
|
||||
connect(m_client, SIGNAL(messageReceived(Jreen::Message)), SLOT(onNewMessage(Jreen::Message)));
|
||||
|
||||
connect(m_client, SIGNAL(newIQ(Jreen::IQ)), SLOT(onNewIq(Jreen::IQ)));
|
||||
connect(m_client, SIGNAL(iqReceived(Jreen::IQ)), SLOT(onNewIq(Jreen::IQ)));
|
||||
|
||||
connect(m_roster, SIGNAL(presenceReceived(Jreen::RosterItem::Ptr,Jreen::Presence)),
|
||||
SLOT(onPresenceReceived(Jreen::RosterItem::Ptr,Jreen::Presence)));
|
||||
@ -445,8 +446,9 @@ JabberPlugin::sendMsg(const QString& to, const QString& msg)
|
||||
qDebug() << "Send sip messsage to " << to;
|
||||
Jreen::IQ iq( Jreen::IQ::Set, to );
|
||||
iq.addExtension( sipMessage );
|
||||
|
||||
m_client->send( iq, this, SLOT( onNewIq( Jreen::IQ, int ) ), SipMessageSent );
|
||||
Jreen::IQReply *reply = m_client->send(iq);
|
||||
reply->setData(SipMessageSent);
|
||||
connect(reply, SIGNAL(received(Jreen::IQ)), SLOT(onNewIq(Jreen::IQ)));
|
||||
}
|
||||
|
||||
void
|
||||
@ -665,7 +667,7 @@ void JabberPlugin::onPresenceReceived( const Jreen::RosterItem::Ptr &item, const
|
||||
}
|
||||
|
||||
// ignore anyone not Running tomahawk:
|
||||
Jreen::Capabilities::Ptr caps = presence.findExtension<Jreen::Capabilities>();
|
||||
Jreen::Capabilities::Ptr caps = presence.payload<Jreen::Capabilities>();
|
||||
/* Disabled this, because it's somewhat ugly and we should rely on nothing but the features
|
||||
if ( caps && ( caps->node() == TOMAHAWK_CAP_NODE_NAME ) )
|
||||
{
|
||||
@ -683,8 +685,10 @@ void JabberPlugin::onPresenceReceived( const Jreen::RosterItem::Ptr &item, const
|
||||
|
||||
Jreen::IQ featuresIq( Jreen::IQ::Get, jid );
|
||||
featuresIq.addExtension( new Jreen::Disco::Info( node ) );
|
||||
|
||||
m_client->send( featuresIq, this, SLOT( onNewIq( Jreen::IQ, int ) ), RequestDisco );
|
||||
|
||||
Jreen::IQReply *reply = m_client->send(featuresIq);
|
||||
reply->setData(RequestDisco);
|
||||
connect(reply, SIGNAL(received(Jreen::IQ)), SLOT(onNewIq(Jreen::IQ)));
|
||||
}
|
||||
else if( !caps )
|
||||
{
|
||||
@ -778,15 +782,18 @@ JabberPlugin::onSubscriptionRequestConfirmed( int result )
|
||||
m_roster->allowSubscription( jid, allowSubscription == QMessageBox::Yes );
|
||||
}
|
||||
|
||||
void JabberPlugin::onNewIq(const Jreen::IQ& iq, int context)
|
||||
void JabberPlugin::onNewIq(const Jreen::IQ& iq)
|
||||
{
|
||||
if ( m_state != Connected )
|
||||
return;
|
||||
|
||||
Jreen::IQReply *reply = qobject_cast<Jreen::IQReply*>(sender());
|
||||
int context = reply ? reply->data().toInt() : NoContext;
|
||||
|
||||
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.payload<Jreen::Disco::Info>().data();
|
||||
if(!discoInfo)
|
||||
return;
|
||||
iq.accept();
|
||||
@ -820,7 +827,7 @@ void JabberPlugin::onNewIq(const Jreen::IQ& iq, int context)
|
||||
}
|
||||
else if(context == RequestVersion)
|
||||
{
|
||||
Jreen::SoftwareVersion* softwareVersion = iq.findExtension<Jreen::SoftwareVersion>().data();
|
||||
Jreen::SoftwareVersion::Ptr softwareVersion = iq.payload<Jreen::SoftwareVersion>();
|
||||
if( softwareVersion )
|
||||
{
|
||||
QString versionString = QString("%1 %2 %3").arg( softwareVersion->name(), softwareVersion->os(), softwareVersion->version() );
|
||||
@ -842,7 +849,7 @@ void JabberPlugin::onNewIq(const Jreen::IQ& iq, int context)
|
||||
}*/
|
||||
else
|
||||
{
|
||||
TomahawkSipMessage *sipMessage = iq.findExtension<TomahawkSipMessage>().data();
|
||||
TomahawkSipMessage::Ptr sipMessage = iq.payload<TomahawkSipMessage>();
|
||||
if(sipMessage)
|
||||
{
|
||||
iq.accept();
|
||||
@ -927,7 +934,9 @@ void JabberPlugin::handlePeerStatus(const Jreen::JID& jid, Jreen::Presence::Type
|
||||
// request software version
|
||||
Jreen::IQ versionIq( Jreen::IQ::Get, jid );
|
||||
versionIq.addExtension( new Jreen::SoftwareVersion() );
|
||||
m_client->send( versionIq, this, SLOT( onNewIq( Jreen::IQ, int ) ), RequestVersion );
|
||||
Jreen::IQReply *reply = m_client->send(versionIq);
|
||||
reply->setData(RequestVersion);
|
||||
connect(reply, SIGNAL(received(Jreen::IQ)), SLOT(onNewIq(Jreen::IQ)));
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ private slots:
|
||||
{
|
||||
qDebug() << e;
|
||||
}
|
||||
void onNewIq( const Jreen::IQ &iq, int context = NoContext );
|
||||
void onNewIq( const Jreen::IQ &iq );
|
||||
void onNewAvatar( const QString &jid );
|
||||
|
||||
private:
|
||||
|
@ -8,9 +8,9 @@
|
||||
#include "../sipdllmacro.h"
|
||||
|
||||
class TomahawkSipMessagePrivate;
|
||||
class SIPDLLEXPORT TomahawkSipMessage : public Jreen::StanzaExtension
|
||||
class SIPDLLEXPORT TomahawkSipMessage : public Jreen::Payload
|
||||
{
|
||||
J_EXTENSION(TomahawkSipMessage, "")
|
||||
J_PAYLOAD(TomahawkSipMessage)
|
||||
Q_DECLARE_PRIVATE(TomahawkSipMessage)
|
||||
public:
|
||||
// sets visible to true
|
||||
|
@ -86,7 +86,7 @@ void TomahawkSipMessageFactory::handleCharacterData(const QStringRef &text)
|
||||
Q_UNUSED(text);
|
||||
}
|
||||
|
||||
void TomahawkSipMessageFactory::serialize(StanzaExtension *extension, QXmlStreamWriter *writer)
|
||||
void TomahawkSipMessageFactory::serialize(Payload *extension, QXmlStreamWriter *writer)
|
||||
{
|
||||
TomahawkSipMessage *sipMessage = se_cast<TomahawkSipMessage*>(extension);
|
||||
|
||||
@ -118,10 +118,10 @@ void TomahawkSipMessageFactory::serialize(StanzaExtension *extension, QXmlStream
|
||||
writer->writeEndElement();
|
||||
}
|
||||
|
||||
StanzaExtension::Ptr TomahawkSipMessageFactory::createExtension()
|
||||
Payload::Ptr TomahawkSipMessageFactory::createPayload()
|
||||
{
|
||||
if(m_visible)
|
||||
return StanzaExtension::Ptr(new TomahawkSipMessage(m_ip, m_port, m_uniqname, m_key));
|
||||
return Payload::Ptr(new TomahawkSipMessage(m_ip, m_port, m_uniqname, m_key));
|
||||
else
|
||||
return StanzaExtension::Ptr(new TomahawkSipMessage());
|
||||
return Payload::Ptr(new TomahawkSipMessage());
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#include "../sipdllmacro.h"
|
||||
|
||||
class SIPDLLEXPORT TomahawkSipMessageFactory : public Jreen::StanzaExtensionFactory<TomahawkSipMessage>
|
||||
class SIPDLLEXPORT TomahawkSipMessageFactory : public Jreen::PayloadFactory<TomahawkSipMessage>
|
||||
{
|
||||
public:
|
||||
TomahawkSipMessageFactory();
|
||||
@ -33,8 +33,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::Payload *extension, QXmlStreamWriter *writer);
|
||||
Jreen::Payload::Ptr createPayload();
|
||||
private:
|
||||
enum State { AtNowhere, AtTransport, AtCandidate } m_state;
|
||||
int m_depth;
|
||||
|
Loading…
x
Reference in New Issue
Block a user