Beispiel #1
0
void VCardManagerPrivate::_q_received(const Jreen::Presence &presence)
{
	if (presence.error())
		return;
	if (VCardUpdate::Ptr update = presence.payload<VCardUpdate>())
		emit q_ptr->vCardUpdateDetected(presence.from(), update);
}
Beispiel #2
0
void JSoftwareDetection::handlePresence(const Jreen::Presence &presence)
{
	QString jid = presence.from().full();
	ChatUnit *unit = m_account->getUnit(jid, false);

	if (JContactResource *resource = qobject_cast<JContactResource *>(unit)) {
		if (!resource->features().isEmpty())
			return;
		setClientInfo(resource, "", "unknown-client");

		QString node;
		if (Jreen::Capabilities::Ptr caps = presence.payload<Jreen::Capabilities>()) {
//			qDebug() << "handle caps" << caps->node();
			QString capsNode = caps->node();
			if(capsNode == QLatin1String("http://www.android.com/gtalk/client/caps")) {
				QString software = "GTalk (Android)";
				QString softwareVersion = caps->ver();
				QString client = getClientDescription(software, softwareVersion, QString());
				updateClientData(resource, client, software, softwareVersion, QString(), "gtalk-android");
				return;
			}
			static const QRegExp regExp("^http://.*google.com/.*client/caps$");
			Q_ASSERT(regExp.isValid());
			if(regExp.exactMatch(capsNode))	{
				QString software = "GTalk";
				if(capsNode.startsWith("http://mail."))
					software += " (GMail)";
				else if(capsNode.startsWith("http://talkgadget."))
					software += " (Gadget)";
				QString softwareVersion = caps->ver();
				QString client = getClientDescription(software, softwareVersion, QString());
				updateClientData(resource, client, software, softwareVersion, QString(), "gtalk");
				return;
			} else {
				node = caps->node() + '#' + caps->ver();
				unit->setProperty("node", node);
				SoftwareInfoHash::iterator it = m_hash.find(node);
//				qDebug() << "find from hash" << m_hash.count();
				if (it != m_hash.end()) {
					SoftwareInfo &info = *it;
					resource->setFeatures(info.features);
//					qDebug() << info.name;
					if (!info.finished) {
//						qDebug() << "Send software version request";
						requestSoftware(presence.from());
					} else {
						updateClientData(resource, info.description, info.name, info.version, info.os, info.icon);
					}
					return;
				}
			}
		}

		setClientInfo(resource, "", "unknown-client");
		Jreen::Disco::Item discoItem(presence.from(), node, QString());
		Jreen::DiscoReply *reply = m_account->client()->disco()->requestInfo(discoItem);
		connect(reply, SIGNAL(finished()), SLOT(onInfoRequestFinished()));
	}
}
Beispiel #3
0
void JAccountPrivate::setPresence(Jreen::Presence presence)
{
	Q_Q(JAccount);
	Status now = JStatus::presenceToStatus(presence.subtype());
	now.setText(presence.status());
	q->setAccountStatus(now);
	if(presence.subtype() == Jreen::Presence::Unavailable)
		client->disconnectFromServer(false);
}
Beispiel #4
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() );
            }
        }
    }