mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 00:54:20 +02:00
Dpointerize PeerInfo
This commit is contained in:
@@ -17,7 +17,8 @@
|
|||||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "PeerInfo.h"
|
#include "PeerInfo_p.h"
|
||||||
|
|
||||||
#include "SipPlugin.h"
|
#include "SipPlugin.h"
|
||||||
#include "utils/TomahawkCache.h"
|
#include "utils/TomahawkCache.h"
|
||||||
#include "utils/TomahawkUtilsGui.h"
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
@@ -112,10 +113,7 @@ PeerInfo::getAll()
|
|||||||
|
|
||||||
PeerInfo::PeerInfo( SipPlugin* parent, const QString& id )
|
PeerInfo::PeerInfo( SipPlugin* parent, const QString& id )
|
||||||
: QObject()
|
: QObject()
|
||||||
, m_parent( parent )
|
, d_ptr( new Tomahawk::PeerInfoPrivate ( this, parent, id ) )
|
||||||
, m_type( External )
|
|
||||||
, m_id( id )
|
|
||||||
, m_status( Offline )
|
|
||||||
, m_avatar( 0 )
|
, m_avatar( 0 )
|
||||||
, m_fancyAvatar( 0 )
|
, m_fancyAvatar( 0 )
|
||||||
{
|
{
|
||||||
@@ -128,6 +126,7 @@ PeerInfo::~PeerInfo()
|
|||||||
s_peersByCacheKey.remove( s_peersByCacheKey.key( weakRef() ) );
|
s_peersByCacheKey.remove( s_peersByCacheKey.key( weakRef() ) );
|
||||||
delete m_avatar;
|
delete m_avatar;
|
||||||
delete m_fancyAvatar;
|
delete m_fancyAvatar;
|
||||||
|
delete d_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -143,62 +142,62 @@ PeerInfo::announce()
|
|||||||
QWeakPointer< PeerInfo >
|
QWeakPointer< PeerInfo >
|
||||||
PeerInfo::weakRef()
|
PeerInfo::weakRef()
|
||||||
{
|
{
|
||||||
return m_ownRef;
|
return d_func()->ownRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PeerInfo::setWeakRef( QWeakPointer< PeerInfo > weakRef )
|
PeerInfo::setWeakRef( QWeakPointer< PeerInfo > weakRef )
|
||||||
{
|
{
|
||||||
m_ownRef = weakRef;
|
d_func()->ownRef = weakRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PeerInfo::setControlConnection( ControlConnection* controlConnection )
|
PeerInfo::setControlConnection( ControlConnection* controlConnection )
|
||||||
{
|
{
|
||||||
m_controlConnection = controlConnection;
|
d_func()->controlConnection = controlConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ControlConnection*
|
ControlConnection*
|
||||||
PeerInfo::controlConnection() const
|
PeerInfo::controlConnection() const
|
||||||
{
|
{
|
||||||
return m_controlConnection;
|
return d_func()->controlConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PeerInfo::hasControlConnection()
|
bool PeerInfo::hasControlConnection()
|
||||||
{
|
{
|
||||||
return !m_controlConnection.isNull();
|
return !d_func()->controlConnection.isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PeerInfo::setType( Tomahawk::PeerInfo::Type type )
|
PeerInfo::setType( Tomahawk::PeerInfo::Type type )
|
||||||
{
|
{
|
||||||
m_type = type;
|
d_func()->type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PeerInfo::Type
|
PeerInfo::Type
|
||||||
PeerInfo::type() const
|
PeerInfo::type() const
|
||||||
{
|
{
|
||||||
return m_type;
|
return d_func()->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
QString PeerInfo::id() const
|
QString PeerInfo::id() const
|
||||||
{
|
{
|
||||||
return m_id;
|
return d_func()->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SipPlugin*
|
SipPlugin*
|
||||||
PeerInfo::sipPlugin() const
|
PeerInfo::sipPlugin() const
|
||||||
{
|
{
|
||||||
return m_parent;
|
return d_func()->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -219,30 +218,30 @@ PeerInfo::debugName() const
|
|||||||
void
|
void
|
||||||
PeerInfo::setContactId ( const QString& contactId )
|
PeerInfo::setContactId ( const QString& contactId )
|
||||||
{
|
{
|
||||||
m_contactId = contactId;
|
d_func()->contactId = contactId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString
|
const QString
|
||||||
PeerInfo::contactId() const
|
PeerInfo::contactId() const
|
||||||
{
|
{
|
||||||
return m_contactId;
|
return d_func()->contactId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString
|
const QString
|
||||||
PeerInfo::nodeId() const
|
PeerInfo::nodeId() const
|
||||||
{
|
{
|
||||||
Q_ASSERT( !m_sipInfos.isEmpty() );
|
Q_ASSERT( !d_func()->sipInfos.isEmpty() );
|
||||||
// All sip infos share the same nodeId
|
// All sip infos share the same nodeId
|
||||||
return m_sipInfos.first().nodeId();
|
return d_func()->sipInfos.first().nodeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString
|
const QString
|
||||||
PeerInfo::key() const
|
PeerInfo::key() const
|
||||||
{
|
{
|
||||||
Q_ASSERT( !m_sipInfos.isEmpty() );
|
Q_ASSERT( !d_func()->sipInfos.isEmpty() );
|
||||||
// All sip infos share the same key
|
// All sip infos share the same key
|
||||||
return m_sipInfos.first().key();
|
return d_func()->sipInfos.first().key();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -250,7 +249,7 @@ PeerInfo::key() const
|
|||||||
void
|
void
|
||||||
PeerInfo::setStatus( PeerInfo::Status status )
|
PeerInfo::setStatus( PeerInfo::Status status )
|
||||||
{
|
{
|
||||||
m_status = status;
|
d_func()->status = status;
|
||||||
|
|
||||||
if ( status == Online )
|
if ( status == Online )
|
||||||
{
|
{
|
||||||
@@ -272,14 +271,14 @@ PeerInfo::setStatus( PeerInfo::Status status )
|
|||||||
PeerInfo::Status
|
PeerInfo::Status
|
||||||
PeerInfo::status() const
|
PeerInfo::status() const
|
||||||
{
|
{
|
||||||
return m_status;
|
return d_func()->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PeerInfo::setSipInfos( const QList<SipInfo>& sipInfos )
|
PeerInfo::setSipInfos( const QList<SipInfo>& sipInfos )
|
||||||
{
|
{
|
||||||
m_sipInfos = sipInfos;
|
d_func()->sipInfos = sipInfos;
|
||||||
|
|
||||||
tLog() << "id:" << id() << "info changed" << sipInfos;
|
tLog() << "id:" << id() << "info changed" << sipInfos;
|
||||||
emit sipInfoChanged();
|
emit sipInfoChanged();
|
||||||
@@ -289,21 +288,21 @@ PeerInfo::setSipInfos( const QList<SipInfo>& sipInfos )
|
|||||||
const QList<SipInfo>
|
const QList<SipInfo>
|
||||||
PeerInfo::sipInfos() const
|
PeerInfo::sipInfos() const
|
||||||
{
|
{
|
||||||
return m_sipInfos;
|
return d_func()->sipInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PeerInfo::setFriendlyName( const QString& friendlyName )
|
PeerInfo::setFriendlyName( const QString& friendlyName )
|
||||||
{
|
{
|
||||||
m_friendlyName = friendlyName;
|
d_func()->friendlyName = friendlyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString
|
const QString
|
||||||
PeerInfo::friendlyName() const
|
PeerInfo::friendlyName() const
|
||||||
{
|
{
|
||||||
return m_friendlyName;
|
return d_func()->friendlyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -387,27 +386,27 @@ PeerInfo::avatar( TomahawkUtils::ImageMode style, const QSize& size ) const
|
|||||||
void
|
void
|
||||||
PeerInfo::setVersionString( const QString& versionString )
|
PeerInfo::setVersionString( const QString& versionString )
|
||||||
{
|
{
|
||||||
m_versionString = versionString;
|
d_func()->versionString = versionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const QString
|
const QString
|
||||||
PeerInfo::versionString() const
|
PeerInfo::versionString() const
|
||||||
{
|
{
|
||||||
return m_versionString;
|
return d_func()->versionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PeerInfo::setData( const QVariant& data )
|
PeerInfo::setData( const QVariant& data )
|
||||||
{
|
{
|
||||||
m_data = data;
|
d_func()->data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const
|
const QVariant
|
||||||
QVariant PeerInfo::data() const
|
PeerInfo::data() const
|
||||||
{
|
{
|
||||||
return m_data;
|
return d_func()->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -19,26 +19,23 @@
|
|||||||
#ifndef PEERINFO_H
|
#ifndef PEERINFO_H
|
||||||
#define PEERINFO_H
|
#define PEERINFO_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
#include "SipInfo.h"
|
|
||||||
#include "accounts/Account.h"
|
|
||||||
#include "utils/TomahawkUtils.h"
|
#include "utils/TomahawkUtils.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
|
|
||||||
#define peerInfoDebug(peerInfo) tDebug() << "PEERINFO:" << ( !peerInfo.isNull() ? peerInfo->debugName() : "Invalid PeerInfo" ).toLatin1().constData()
|
#define peerInfoDebug(peerInfo) tDebug() << "PEERINFO:" << ( !peerInfo.isNull() ? peerInfo->debugName() : "Invalid PeerInfo" ).toLatin1().constData()
|
||||||
|
|
||||||
class SipPlugin;
|
|
||||||
class ControlConnection;
|
class ControlConnection;
|
||||||
|
class SipPlugin;
|
||||||
|
class SipInfo;
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class PeerInfoPrivate;
|
||||||
|
|
||||||
class DLLEXPORT PeerInfo : public QObject
|
class DLLEXPORT PeerInfo : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -129,23 +126,12 @@ private:
|
|||||||
PeerInfo( SipPlugin* parent, const QString& id );
|
PeerInfo( SipPlugin* parent, const QString& id );
|
||||||
void announce();
|
void announce();
|
||||||
|
|
||||||
|
Q_DECLARE_PRIVATE( Tomahawk::PeerInfo )
|
||||||
|
Tomahawk::PeerInfoPrivate* d_ptr;
|
||||||
|
|
||||||
static QHash< QString, peerinfo_wptr > s_peersByCacheKey;
|
static QHash< QString, peerinfo_wptr > s_peersByCacheKey;
|
||||||
static QHash< SipPlugin*, peerinfo_ptr > s_selfPeersBySipPlugin;
|
static QHash< SipPlugin*, peerinfo_ptr > s_selfPeersBySipPlugin;
|
||||||
|
|
||||||
QWeakPointer< Tomahawk::PeerInfo > m_ownRef;
|
|
||||||
QPointer< ControlConnection > m_controlConnection;
|
|
||||||
|
|
||||||
SipPlugin* m_parent;
|
|
||||||
PeerInfo::Type m_type;
|
|
||||||
|
|
||||||
QString m_id;
|
|
||||||
QString m_contactId;
|
|
||||||
Status m_status;
|
|
||||||
QList<SipInfo> m_sipInfos;
|
|
||||||
QString m_friendlyName;
|
|
||||||
QString m_versionString;
|
|
||||||
QVariant m_data;
|
|
||||||
|
|
||||||
mutable QPixmap* m_avatar;
|
mutable QPixmap* m_avatar;
|
||||||
mutable QPixmap* m_fancyAvatar;
|
mutable QPixmap* m_fancyAvatar;
|
||||||
|
|
||||||
|
61
src/libtomahawk/sip/PeerInfo_p.h
Normal file
61
src/libtomahawk/sip/PeerInfo_p.h
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2012, Dominik Schmidt <dev@dominik-schmidt.de>
|
||||||
|
* Copyright 2013, Uwe L. Korn <uwelk@xhochy.com>
|
||||||
|
*
|
||||||
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PEERINFO_P_H
|
||||||
|
#define PEERINFO_P_H
|
||||||
|
|
||||||
|
#include "PeerInfo.h"
|
||||||
|
|
||||||
|
namespace Tomahawk
|
||||||
|
{
|
||||||
|
|
||||||
|
class PeerInfoPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PeerInfoPrivate( PeerInfo* q, SipPlugin* parent, const QString& id )
|
||||||
|
: q_ptr ( q )
|
||||||
|
, parent( parent )
|
||||||
|
, type( PeerInfo::External )
|
||||||
|
, id( id )
|
||||||
|
, status( PeerInfo::Offline )
|
||||||
|
|
||||||
|
{
|
||||||
|
}
|
||||||
|
PeerInfo* q_ptr;
|
||||||
|
Q_DECLARE_PUBLIC ( PeerInfo )
|
||||||
|
|
||||||
|
private:
|
||||||
|
QWeakPointer< Tomahawk::PeerInfo > ownRef;
|
||||||
|
QPointer< ControlConnection > controlConnection;
|
||||||
|
|
||||||
|
SipPlugin* parent;
|
||||||
|
PeerInfo::Type type;
|
||||||
|
|
||||||
|
QString id;
|
||||||
|
QString contactId;
|
||||||
|
PeerInfo::Status status;
|
||||||
|
QList<SipInfo> sipInfos;
|
||||||
|
QString friendlyName;
|
||||||
|
QString versionString;
|
||||||
|
QVariant data;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PEERINFO_P_H
|
Reference in New Issue
Block a user