예제 #1
0
		void handleBuddyUpdatedRequest(const std::string &user, const std::string &buddyName, const std::string &alias, const std::vector<std::string> &groups) {
			boost::shared_ptr<Swift::Client> client = m_users[user];
			if (client) {
				LOG4CXX_INFO(logger, user << ": Added/Updated buddy " << buddyName << ".");
				if (!client->getRoster()->containsJID(buddyName) || client->getRoster()->getSubscriptionStateForJID(buddyName) != Swift::RosterItemPayload::Both) {
					Swift::RosterItemPayload item;
					item.setName(alias);
					item.setJID(buddyName);
					item.setGroups(groups);
					boost::shared_ptr<Swift::RosterPayload> roster(new Swift::RosterPayload());
					roster->addItem(item);
					Swift::SetRosterRequest::ref request = Swift::SetRosterRequest::create(roster, client->getIQRouter());
// 					request->onResponse.connect(boost::bind(&RosterController::handleRosterSetError, this, _1, roster));
					request->send();
					client->getSubscriptionManager()->requestSubscription(buddyName);
				}
				else {
					Swift::JID contact(buddyName);
					Swift::RosterItemPayload item(contact, alias, client->getRoster()->getSubscriptionStateForJID(contact));
					item.setGroups(groups);
					boost::shared_ptr<Swift::RosterPayload> roster(new Swift::RosterPayload());
					roster->addItem(item);
					Swift::SetRosterRequest::ref request = Swift::SetRosterRequest::create(roster, client->getIQRouter());
// 					request->onResponse.connect(boost::bind(&RosterController::handleRosterSetError, this, _1, roster));
					request->send();
				}

			}
		}
예제 #2
0
void XMPPUserRegistration::handleRegisterRemoteRosterResponse(boost::shared_ptr<Swift::RosterPayload> payload, Swift::ErrorPayload::ref remoteRosterNotSupported, const UserInfo &row){
	if (remoteRosterNotSupported || !payload) {
		// Remote roster is not support, so send normal Subscribe presence to add transport.
		Swift::Presence::ref response = Swift::Presence::create();
		response->setFrom(m_component->getJID());
		response->setTo(Swift::JID(row.jid));
		response->setType(Swift::Presence::Subscribe);
		m_component->getFrontend()->sendPresence(response);
	}
	else {
		// Remote roster is support, so use remoteroster XEP to add transport.
		Swift::RosterPayload::ref payload = Swift::RosterPayload::ref(new Swift::RosterPayload());
		Swift::RosterItemPayload item;
		item.setJID(m_component->getJID());
		item.setSubscription(Swift::RosterItemPayload::Both);
		payload->addItem(item);
		Swift::SetRosterRequest::ref request = Swift::SetRosterRequest::create(payload, row.jid, static_cast<XMPPFrontend *>(m_component->getFrontend())->getIQRouter());
		request->send();
	}

	onUserRegistered(row);

	// If the JID for registration notification is configured, send the notification message.
	std::vector<std::string> const &x = CONFIG_VECTOR(m_component->getConfig(),"registration.notify_jid");
	BOOST_FOREACH(const std::string &notify_jid, x) {
		boost::shared_ptr<Swift::Message> msg(new Swift::Message());
		msg->setBody(std::string("registered: ") + row.jid);
		msg->setTo(notify_jid);
		msg->setFrom(m_component->getJID());
		m_component->getFrontend()->sendMessage(msg);
	}
예제 #3
0
	void addEmptyBuddy() {
		Swift::RosterPayload::ref p = Swift::RosterPayload::ref(new Swift::RosterPayload());
		Swift::RosterItemPayload item;
		item.setJID("icq.localhost");
		item.setSubscription(Swift::RosterItemPayload::Both);

		p->addItem(item);
		Swift::SetRosterRequest::ref request = Swift::SetRosterRequest::create(p, "user@localhost", static_cast<XMPPFrontend *>(component->getFrontend())->getIQRouter());

		SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Swift::IQ> iq(new Swift::IQ(Swift::IQ::Set));
		iq->setTo("icq.localhost");
		iq->setFrom("user@localhost");
		iq->addPayload(p);
		iq->setID("123");
		injectIQ(iq);

		CPPUNIT_ASSERT_EQUAL(std::string("none"), m_buddy);
	}