Ejemplo n.º 1
0
Swift::Presence::ref Buddy::generatePresenceStanza(int features, bool only_new) {
	std::string alias = getAlias();
	std::string name = getSafeName();

	Swift::StatusShow s;
	std::string statusMessage;
	if (!getStatus(s, statusMessage))
		return Swift::Presence::ref();

	if (m_jid.getNode().empty()) {
		generateJID();
	}

	Swift::Presence::ref presence = Swift::Presence::create();
 	presence->setFrom(m_jid);
	presence->setTo(m_rosterManager->getUser()->getJID().toBare());
	presence->setType(Swift::Presence::Available);

	if (!statusMessage.empty())
		presence->setStatus(statusMessage);

	if (s.getType() == Swift::StatusShow::None)
		presence->setType(Swift::Presence::Unavailable);
	presence->setShow(s.getType());

	if (presence->getType() != Swift::Presence::Unavailable) {
		// caps
		
		presence->addPayload(boost::shared_ptr<Swift::Payload>(new Swift::CapsInfo(m_rosterManager->getUser()->getComponent()->getBuddyCapsInfo())));

// 		if (features & 0/*TRANSPORT_FEATURE_AVATARS*/) {
			presence->addPayload(boost::shared_ptr<Swift::Payload>(new Swift::VCardUpdate (getIconHash())));
// 		}
		if (isBlocked()) {
			presence->addPayload(boost::shared_ptr<Swift::Payload>(new Transport::BlockPayload ()));
		}
	}

// 	if (only_new) {
// 		if (m_lastPresence)
// 			m_lastPresence->setTo(Swift::JID(""));
// 		if (m_lastPresence == presence) {
// 			return Swift::Presence::ref();
// 		}
// 		m_lastPresence = presence;
// 	}

	return presence;
}
Ejemplo n.º 2
0
void SlackRosterManager::sendOnlineBuddies() {
	std::string onlineBuddies = "Online users: ";
	Swift::StatusShow s;
	std::string statusMessage;

	const RosterManager::BuddiesMap &roster = getBuddies();
	for(RosterManager::BuddiesMap::const_iterator bt = roster.begin(); bt != roster.end(); bt++) {
		Buddy *b = (*bt).second;
		if (!b) {
			continue;
		}

		if (!(b->getStatus(s, statusMessage))) {
			continue;
		}

		if (s.getType() == Swift::StatusShow::None) {
			continue;
		}

		onlineBuddies += b->getAlias() + ", ";
	}

	if (m_onlineBuddies != onlineBuddies) {
		m_onlineBuddies = onlineBuddies;
		SlackSession *session = static_cast<SlackUser *>(m_user)->getSession();
		if (session) {
			session->setPurpose(m_onlineBuddies);
		}
	}

	m_onlineBuddiesTimer->start();
}
Ejemplo n.º 3
0
void LocalBuddy::setStatus(const Swift::StatusShow &status, const std::string &statusMessage) {
	bool changed = ((m_status.getType() != status.getType()) || (m_statusMessage != statusMessage));
	if (changed) {
		m_status = status;
		m_statusMessage = statusMessage;
		sendPresence();
	}
}