コード例 #1
0
ファイル: PresenceOracle.cpp プロジェクト: HazWard/spectrum2
void PresenceOracle::handleIncomingPresence(Presence::ref presence) {
	// ignore presences for some contact, we're checking only presences for the transport itself here.
	// filter out login/logout presence spam
	if (!presence->getTo().getNode().empty())
		return;

	JID bareJID(presence->getFrom().toBare());
	if (presence->getType() == Presence::Subscribe || presence->getType() == Presence::Subscribed) {
	}
	else {
		Presence::ref passedPresence = presence;
		if (presence->getType() == Presence::Unsubscribe || presence->getType() == Presence::Unsubscribed) {
			/* 3921bis says that we don't follow up with an unavailable, so simulate this ourselves */
			passedPresence = Presence::ref(new Presence());
			passedPresence->setType(Presence::Unavailable);
			passedPresence->setFrom(bareJID);
			passedPresence->setStatus(presence->getStatus());
		}
		std::map<JID, boost::shared_ptr<Presence> > jidMap = entries_[bareJID];
		if (passedPresence->getFrom().isBare() && presence->getType() == Presence::Unavailable) {
			/* Have a bare-JID only presence of offline */
			jidMap.clear();
		} else if (passedPresence->getType() == Presence::Available) {
			/* Don't have a bare-JID only offline presence once there are available presences */
			jidMap.erase(bareJID);
		}
		if (passedPresence->getType() == Presence::Unavailable && jidMap.size() > 1) {
			jidMap.erase(passedPresence->getFrom());
		} else {
			jidMap[passedPresence->getFrom()] = passedPresence;
		}
		entries_[bareJID] = jidMap;
		onPresenceChange(passedPresence);
	}
}
コード例 #2
0
ファイル: PresenceOracle.cpp プロジェクト: pedrosorren/swift
void PresenceOracle::handleIncomingPresence(Presence::ref presence) {
	JID bareJID(presence->getFrom().toBare());
	if (presence->getType() == Presence::Subscribe) {
	}
	else {
		Presence::ref passedPresence = presence;
		if (presence->getType() == Presence::Unsubscribe) {
			/* 3921bis says that we don't follow up with an unavailable, so simulate this ourselves */
			passedPresence = Presence::ref(new Presence());
			passedPresence->setType(Presence::Unavailable);
			passedPresence->setFrom(bareJID);
			passedPresence->setStatus(presence->getStatus());
		}
		std::map<JID, boost::shared_ptr<Presence> > jidMap = entries_[bareJID];
		if (passedPresence->getFrom().isBare() && presence->getType() == Presence::Unavailable) {
			/* Have a bare-JID only presence of offline */
			jidMap.clear();
		} else if (passedPresence->getType() == Presence::Available) {
			/* Don't have a bare-JID only offline presence once there are available presences */
			jidMap.erase(bareJID);
		}
		if (passedPresence->getType() == Presence::Unavailable && jidMap.size() > 1) {
			jidMap.erase(passedPresence->getFrom());
		} else {
			jidMap[passedPresence->getFrom()] = passedPresence;
		}
		entries_[bareJID] = jidMap;
		onPresenceChange(passedPresence);
	}
}
コード例 #3
0
ファイル: PresenceOracle.cpp プロジェクト: swift/swift
    bool operator()(const Presence::ref& a, const Presence::ref& b) {
        int aPreference = preferenceFromStatusShow(a->getShow());
        int bPreference = preferenceFromStatusShow(b->getShow());

        if (aPreference != bPreference) {
            return aPreference < bPreference;
        }
        if (a->getPriority() != b->getPriority()) {
            return a->getPriority() < b->getPriority();
        }
        return a->getFrom().getResource() < b->getFrom().getResource();
    }
コード例 #4
0
void WhiteboardSessionManager::handlePresenceReceived(Presence::ref presence) {
    if (!presence->isAvailable()) {
        WhiteboardSession::ref session = getSession(presence->getFrom());
        if (session) {
            session->cancel();
        }
    }
}
コード例 #5
0
ファイル: EchoBot6.cpp プロジェクト: bessey/picnic-doc-server
		void handlePresenceReceived(Presence::ref presence) {
			// Automatically approve subscription requests
			if (presence->getType() == Presence::Subscribe) {
				Presence::ref response = Presence::create();
				response->setTo(presence->getFrom());
				response->setType(Presence::Subscribed);
				client->sendPresence(response);
			}
		}
コード例 #6
0
void SubscriptionManager::handleIncomingPresence(Presence::ref presence) {
	JID bareJID(presence->getFrom().toBare());
	if (presence->getType() == Presence::Subscribe) {
		onPresenceSubscriptionRequest(bareJID, presence->getStatus(), presence);
	}
	else if (presence->getType() == Presence::Unsubscribe) {
		onPresenceSubscriptionRevoked(bareJID, presence->getStatus());
	}
}
コード例 #7
0
ファイル: UserSearchController.cpp プロジェクト: swift/swift
void UserSearchController::handlePresenceChanged(Presence::ref presence) {
    handleJIDUpdateRequested(std::vector<JID>(1, presence->getFrom().toBare()));
}