mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Use the AvatarManager and show avatars in the MainWindow.
This commit is contained in:
@@ -110,6 +110,7 @@ JabberPlugin::connectPlugin( bool startup )
|
|||||||
QObject::connect( p, SIGNAL( disconnected() ), SLOT( onDisconnected() ) );
|
QObject::connect( p, SIGNAL( disconnected() ), SLOT( onDisconnected() ) );
|
||||||
|
|
||||||
QObject::connect( p, SIGNAL( authError( int, QString ) ), SLOT( onAuthError( int, QString ) ) );
|
QObject::connect( p, SIGNAL( authError( int, QString ) ), SLOT( onAuthError( int, QString ) ) );
|
||||||
|
QObject::connect( p, SIGNAL( avatarReceived( QString, QPixmap ) ), SIGNAL( avatarReceived( QString, QPixmap ) ) );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -70,8 +70,8 @@ Jabber_p::Jabber_p( const QString& jid, const QString& password, const QString&
|
|||||||
// 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() );
|
||||||
|
|
||||||
// read cached avatars
|
// initialize the AvatarManager
|
||||||
m_photoHashes = QDir("/home/domme/jreen/").entryList();
|
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 );
|
||||||
@@ -96,6 +96,8 @@ Jabber_p::Jabber_p( const QString& jid, const QString& password, const QString&
|
|||||||
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
|
// connect
|
||||||
qDebug() << "Connecting to the XMPP server...";
|
qDebug() << "Connecting to the XMPP server...";
|
||||||
@@ -226,9 +228,6 @@ Jabber_p::onConnect()
|
|||||||
// 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);
|
||||||
|
|
||||||
// request own vcard
|
|
||||||
fetchVCard( m_jid.bare() );
|
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
||||||
@@ -351,16 +350,6 @@ void Jabber_p::onNewPresence( const Jreen::Presence& presence)
|
|||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << "* New presence: " << fulljid << presence.subtype();
|
qDebug() << Q_FUNC_INFO << "* New presence: " << fulljid << presence.subtype();
|
||||||
|
|
||||||
Jreen::VCardUpdate::Ptr update = presence.findExtension<Jreen::VCardUpdate>();
|
|
||||||
if(update)
|
|
||||||
{
|
|
||||||
qDebug() << "vcard: found update for " << fulljid;
|
|
||||||
if(!m_photoHashes.contains(update->photoHash()))
|
|
||||||
{
|
|
||||||
fetchVCard( jid.bare() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( jid == m_jid )
|
if( jid == m_jid )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -536,10 +525,33 @@ Jabber_p::handlePeerStatus( const Jreen::JID& jid, Jreen::Presence::Type presenc
|
|||||||
{
|
{
|
||||||
m_peers[ fulljid ] = presenceType;
|
m_peers[ fulljid ] = presenceType;
|
||||||
qDebug() << Q_FUNC_INFO << "* Peer goes online:" << fulljid;
|
qDebug() << Q_FUNC_INFO << "* Peer goes online:" << fulljid;
|
||||||
|
|
||||||
emit peerOnline( fulljid );
|
emit peerOnline( fulljid );
|
||||||
|
|
||||||
|
if(!m_avatarManager->avatar(jid.bare()).isNull())
|
||||||
|
onNewAvatar( jid.bare() );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//qDebug() << "Updating presence data for" << fulljid;
|
//qDebug() << "Updating presence data for" << fulljid;
|
||||||
m_peers[ fulljid ] = presenceType;
|
m_peers[ fulljid ] = presenceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Jabber_p::onNewAvatar(const QString& jid)
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << jid;
|
||||||
|
Q_ASSERT(!m_avatarManager->avatar( jid ).isNull());
|
||||||
|
|
||||||
|
// find peers for the jid
|
||||||
|
QStringList peers = m_peers.keys();
|
||||||
|
foreach(const QString &peer, peers)
|
||||||
|
{
|
||||||
|
if( peer.startsWith(jid) )
|
||||||
|
{
|
||||||
|
emit avatarReceived ( peer, m_avatarManager->avatar( jid ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit avatarReceived ( jid, m_avatarManager->avatar( jid ) );
|
||||||
|
}
|
||||||
|
@@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include "../sipdllmacro.h"
|
#include "../sipdllmacro.h"
|
||||||
|
|
||||||
|
#include "avatarmanager.h"
|
||||||
|
|
||||||
#include <jreen/client.h>
|
#include <jreen/client.h>
|
||||||
#include <jreen/disco.h>
|
#include <jreen/disco.h>
|
||||||
#include <jreen/message.h>
|
#include <jreen/message.h>
|
||||||
@@ -63,6 +65,7 @@ signals:
|
|||||||
void connected();
|
void connected();
|
||||||
void disconnected();
|
void disconnected();
|
||||||
void jidChanged( const QString& );
|
void jidChanged( const QString& );
|
||||||
|
void avatarReceived( const QString&, const QPixmap& avatar );
|
||||||
void authError( int, const QString& );
|
void authError( int, const QString& );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -82,6 +85,7 @@ private slots:
|
|||||||
qDebug() << e;
|
qDebug() << e;
|
||||||
}
|
}
|
||||||
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:
|
private:
|
||||||
bool presenceMeansOnline( Jreen::Presence::Type p );
|
bool presenceMeansOnline( Jreen::Presence::Type p );
|
||||||
@@ -99,10 +103,7 @@ private:
|
|||||||
|
|
||||||
QStringList m_legacy_peers;
|
QStringList m_legacy_peers;
|
||||||
|
|
||||||
|
AvatarManager *m_avatarManager;
|
||||||
//sort out
|
|
||||||
//QHash<Jreen::JID, QString> m_contactsPhotoHashes;
|
|
||||||
QStringList m_photoHashes;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // JABBER_H
|
#endif // JABBER_H
|
||||||
|
Reference in New Issue
Block a user