mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 05:07:27 +02:00
Fix setting of own avatar in sip plugins
This commit is contained in:
@@ -1019,8 +1019,7 @@ XmppSipPlugin::onNewAvatar( const QString& jid )
|
|||||||
|
|
||||||
if ( jid == m_client->jid().bare() )
|
if ( jid == m_client->jid().bare() )
|
||||||
{
|
{
|
||||||
// own avatar
|
PeerInfo::getSelf( this, PeerInfo::AutoCreate )->setAvatar( m_avatarManager->avatar( jid ) );
|
||||||
emit avatarReceived( m_avatarManager->avatar( jid ) );
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -88,8 +88,15 @@ Source::setControlConnection( ControlConnection* cc )
|
|||||||
const QSet<peerinfo_ptr>
|
const QSet<peerinfo_ptr>
|
||||||
Source::peerInfos() const
|
Source::peerInfos() const
|
||||||
{
|
{
|
||||||
if( controlConnection() )
|
if ( controlConnection() )
|
||||||
|
{
|
||||||
return controlConnection()->peerInfos();
|
return controlConnection()->peerInfos();
|
||||||
|
}
|
||||||
|
else if ( this == SourceList::instance()->getLocal().data() )
|
||||||
|
{
|
||||||
|
return PeerInfo::getAllSelf().toSet();
|
||||||
|
|
||||||
|
}
|
||||||
return QSet< Tomahawk::peerinfo_ptr >();
|
return QSet< Tomahawk::peerinfo_ptr >();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,24 +142,20 @@ Source::friendlyName() const
|
|||||||
QPixmap
|
QPixmap
|
||||||
Source::avatar( TomahawkUtils::ImageMode style, const QSize& size )
|
Source::avatar( TomahawkUtils::ImageMode style, const QSize& size )
|
||||||
{
|
{
|
||||||
if( controlConnection() )
|
|
||||||
{
|
|
||||||
// tLog() << "****************************************************************************************";
|
// tLog() << "****************************************************************************************";
|
||||||
// tLog() << controlConnection()->peerInfos().count() << "PEERS FOR " << friendlyName();
|
// tLog() << peerInfos().count() << "PEERS FOR " << friendlyName();
|
||||||
QPixmap result;
|
QPixmap result;
|
||||||
foreach( const peerinfo_ptr& peerInfo, controlConnection()->peerInfos() )
|
foreach( const peerinfo_ptr& peerInfo, peerInfos() )
|
||||||
{
|
{
|
||||||
// peerInfoDebug(peerInfo);
|
// peerInfoDebug(peerInfo) << !peerInfo->avatar().isNull();
|
||||||
if( !peerInfo.isNull() && !peerInfo->avatar( style, size ).isNull() )
|
if( !peerInfo.isNull() && !peerInfo->avatar( style, size ).isNull() )
|
||||||
{
|
{
|
||||||
result = peerInfo->avatar( style, size );
|
result = peerInfo->avatar( style, size );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// tLog() << "****************************************************************************************";
|
// tLog() << "****************************************************************************************";
|
||||||
return result;
|
return result;
|
||||||
}
|
|
||||||
|
|
||||||
return QPixmap();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -31,6 +31,7 @@ namespace Tomahawk
|
|||||||
{
|
{
|
||||||
|
|
||||||
QHash< QString, peerinfo_ptr > PeerInfo::s_peersByCacheKey = QHash< QString, peerinfo_ptr >();
|
QHash< QString, peerinfo_ptr > PeerInfo::s_peersByCacheKey = QHash< QString, peerinfo_ptr >();
|
||||||
|
QHash< SipPlugin*, peerinfo_ptr > PeerInfo::s_selfPeersBySipPlugin = QHash< SipPlugin*, peerinfo_ptr >();
|
||||||
|
|
||||||
inline QString
|
inline QString
|
||||||
peerCacheKey( SipPlugin* plugin, const QString& peerId )
|
peerCacheKey( SipPlugin* plugin, const QString& peerId )
|
||||||
@@ -38,9 +39,39 @@ peerCacheKey( SipPlugin* plugin, const QString& peerId )
|
|||||||
return QString( "%1\t\t%2" ).arg( (quintptr) plugin ).arg( peerId );
|
return QString( "%1\t\t%2" ).arg( (quintptr) plugin ).arg( peerId );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tomahawk::peerinfo_ptr
|
||||||
|
PeerInfo::getSelf( SipPlugin* parent, PeerInfo::GetOptions options )
|
||||||
|
{
|
||||||
|
if ( s_selfPeersBySipPlugin.keys().contains( parent ) )
|
||||||
|
{
|
||||||
|
return s_selfPeersBySipPlugin.value( parent );
|
||||||
|
}
|
||||||
|
|
||||||
|
// if AutoCreate isn't enabled nothing to do here
|
||||||
|
if( ! ( options & AutoCreate ) )
|
||||||
|
{
|
||||||
|
return peerinfo_ptr();
|
||||||
|
}
|
||||||
|
|
||||||
|
peerinfo_ptr selfPeer( new PeerInfo( parent, "local peerinfo don't use this id for anything" ) );
|
||||||
|
selfPeer->setWeakRef( selfPeer.toWeakRef() );
|
||||||
|
|
||||||
|
// parent->setSelfPeer( selfPeer );
|
||||||
|
s_selfPeersBySipPlugin.insert( parent, selfPeer );
|
||||||
|
|
||||||
|
return selfPeer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList< Tomahawk::peerinfo_ptr >
|
||||||
|
PeerInfo::getAllSelf()
|
||||||
|
{
|
||||||
|
return s_selfPeersBySipPlugin.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Tomahawk::peerinfo_ptr
|
Tomahawk::peerinfo_ptr
|
||||||
PeerInfo::get(SipPlugin* parent, const QString& id, GetOptions options )
|
PeerInfo::get( SipPlugin* parent, const QString& id, GetOptions options )
|
||||||
{
|
{
|
||||||
const QString key = peerCacheKey( parent, id );
|
const QString key = peerCacheKey( parent, id );
|
||||||
if ( s_peersByCacheKey.contains( key ) )
|
if ( s_peersByCacheKey.contains( key ) )
|
||||||
|
@@ -63,7 +63,10 @@ public:
|
|||||||
Local
|
Local
|
||||||
};
|
};
|
||||||
|
|
||||||
static Tomahawk::peerinfo_ptr get( SipPlugin* parent, const QString& id, GetOptions options = None);
|
static Tomahawk::peerinfo_ptr getSelf( SipPlugin* parent, GetOptions options = None );
|
||||||
|
static QList< Tomahawk::peerinfo_ptr > getAllSelf();
|
||||||
|
|
||||||
|
static Tomahawk::peerinfo_ptr get( SipPlugin* parent, const QString& id, GetOptions options = None );
|
||||||
static QList< Tomahawk::peerinfo_ptr > getAll();
|
static QList< Tomahawk::peerinfo_ptr > getAll();
|
||||||
|
|
||||||
virtual ~PeerInfo();
|
virtual ~PeerInfo();
|
||||||
@@ -111,6 +114,8 @@ private:
|
|||||||
void announce();
|
void announce();
|
||||||
|
|
||||||
static QHash< QString, peerinfo_ptr > s_peersByCacheKey;
|
static QHash< QString, peerinfo_ptr > s_peersByCacheKey;
|
||||||
|
static QHash< SipPlugin*, peerinfo_ptr > s_selfPeersBySipPlugin;
|
||||||
|
|
||||||
QWeakPointer< Tomahawk::PeerInfo > m_ownRef;
|
QWeakPointer< Tomahawk::PeerInfo > m_ownRef;
|
||||||
QPointer< ControlConnection > m_controlConnection;
|
QPointer< ControlConnection > m_controlConnection;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user