Example #1
0
void
XmppSipPlugin::onPresenceReceived( const Jreen::RosterItem::Ptr& item, const Jreen::Presence& presence )
{
    Q_UNUSED(item);
    if ( m_state != Account::Connected )
        return;

    Jreen::JID jid = presence.from();
    QString fulljid( jid.full() );

    tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "New presence:" << fulljid << presence.subtype();

    if ( jid == m_client->jid() )
        return;

    if ( presence.error() )
    {
        //qDebug() << Q_FUNC_INFO << fulljid << "Running tomahawk: no" << "presence error";
        return;
    }

    // cache name
    if( !item.isNull() && item->name() != jid.bare() && m_jidsNames.value( jid.bare() ) != item->name() )
    {
        tLog( LOGVERBOSE ) << Q_FUNC_INFO << "Cache name" << item->name() << "for" << jid.bare() << item << presence.subtype();
        m_jidsNames.insert( jid.bare(), item->name() );

        // find peers for the jid and update their friendlyName
        foreach ( const Jreen::JID& peer, m_peers.keys() )
        {
            if ( peer.bare() == jid.bare() )
            {
                Tomahawk::peerinfo_ptr peerInfo = PeerInfo::get( this, peer.full() );
                if( !peerInfo.isNull() )
                    peerInfo->setFriendlyName( item->name() );
            }
        }
    }
Example #2
0
void
XmppSipPlugin::sendSipInfos( const Tomahawk::peerinfo_ptr& receiver, const QList<SipInfo>& info )
{
    tDebug( LOGVERBOSE ) << Q_FUNC_INFO << receiver << info;

    if ( !m_client )
        return;

    TomahawkXmppMessage* sipMessage = new TomahawkXmppMessage( info );
    tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Send sip messsage to" << receiver;
    Jreen::IQ iq( Jreen::IQ::Set, receiver->id() );
    iq.addExtension( sipMessage );
    Jreen::IQReply *reply = m_client->send( iq );
    reply->setData( SipMessageSent );
    connect( reply, SIGNAL( received( Jreen::IQ ) ), SLOT( onNewIq( Jreen::IQ ) ) );
}
Example #3
0
void
XmppSipPlugin::sendSipInfo( const Tomahawk::peerinfo_ptr& receiver, const SipInfo& info )
{
    tDebug( LOGVERBOSE ) << Q_FUNC_INFO << receiver << info;

    if ( !m_client )
        return;

    TomahawkXmppMessage *sipMessage;
    if ( info.isVisible() )
    {
        sipMessage = new TomahawkXmppMessage( info.host(), info.port(), info.nodeId(), info.key() );
    }
    else
        sipMessage = new TomahawkXmppMessage();

    qDebug() << "Send sip messsage to" << receiver;
    Jreen::IQ iq( Jreen::IQ::Set, receiver->id() );
    iq.addExtension( sipMessage );
    Jreen::IQReply *reply = m_client->send( iq );
    reply->setData( SipMessageSent );
    connect( reply, SIGNAL( received( Jreen::IQ ) ), SLOT( onNewIq( Jreen::IQ ) ) );
}