本文整理汇总了C++中swift::RosterItemPayload::getSubscription方法的典型用法代码示例。如果您正苦于以下问题:C++ RosterItemPayload::getSubscription方法的具体用法?C++ RosterItemPayload::getSubscription怎么用?C++ RosterItemPayload::getSubscription使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类swift::RosterItemPayload
的用法示例。
在下文中一共展示了RosterItemPayload::getSubscription方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleSetRequest
bool RosterResponder::handleSetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::RosterPayload> payload) {
sendResponse(from, id, boost::shared_ptr<RosterPayload>(new RosterPayload()));
User *user = m_userManager->getUser(from.toBare().toString());
if (!user) {
LOG4CXX_WARN(logger, from.toBare().toString() << ": User is not logged in");
return true;
}
if (payload->getItems().size() == 0) {
LOG4CXX_WARN(logger, from.toBare().toString() << ": Roster push with no item");
return true;
}
Swift::RosterItemPayload item = payload->getItems()[0];
if (item.getJID().getNode().empty()) {
return true;
}
Buddy *buddy = user->getRosterManager()->getBuddy(Buddy::JIDToLegacyName(item.getJID()));
if (buddy) {
if (item.getSubscription() == Swift::RosterItemPayload::Remove) {
LOG4CXX_INFO(logger, from.toBare().toString() << ": Removing buddy " << buddy->getName());
onBuddyRemoved(buddy);
// send roster push here
Swift::SetRosterRequest::ref request = Swift::SetRosterRequest::create(payload, user->getJID().toBare(), user->getComponent()->getIQRouter());
request->send();
}
else {
LOG4CXX_INFO(logger, from.toBare().toString() << ": Updating buddy " << buddy->getName());
onBuddyUpdated(buddy, item);
}
}
else if (item.getSubscription() != Swift::RosterItemPayload::Remove) {
// Roster push for this new buddy is sent by RosterManager
BuddyInfo buddyInfo;
buddyInfo.id = -1;
buddyInfo.alias = item.getName();
buddyInfo.legacyName = Buddy::JIDToLegacyName(item.getJID());
buddyInfo.subscription = "both";
buddyInfo.flags = Buddy::buddyFlagsFromJID(item.getJID());
LOG4CXX_INFO(logger, from.toBare().toString() << ": Adding buddy " << buddyInfo.legacyName);
buddy = user->getComponent()->getFactory()->createBuddy(user->getRosterManager(), buddyInfo);
user->getRosterManager()->setBuddy(buddy);
onBuddyAdded(buddy, item);
}
return true;
}
示例2: removeBuddy
void removeBuddy() {
add2Buddies();
CPPUNIT_ASSERT_EQUAL(4, (int) received.size());
received.clear();
User *user = userManager->getUser("[email protected]");
user->getRosterManager()->removeBuddy("buddy1");
CPPUNIT_ASSERT_EQUAL(1, (int) received.size());
Swift::RosterPayload::ref payload1 = getStanza(received[0])->getPayload<Swift::RosterPayload>();
CPPUNIT_ASSERT(payload1);
CPPUNIT_ASSERT_EQUAL(1, (int) payload1->getItems().size());
Swift::RosterItemPayload item = payload1->getItems()[0];
CPPUNIT_ASSERT_EQUAL(std::string("buddy1"), Buddy::JIDToLegacyName(item.getJID()));
CPPUNIT_ASSERT_EQUAL(Swift::RosterItemPayload::Remove, item.getSubscription());
}