本文整理汇总了C++中swift::RosterItemPayload类的典型用法代码示例。如果您正苦于以下问题:C++ RosterItemPayload类的具体用法?C++ RosterItemPayload怎么用?C++ RosterItemPayload使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RosterItemPayload类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setBuddy
void setBuddy() {
add2Buddies();
CPPUNIT_ASSERT_EQUAL(4, (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(std::string("Buddy 1"), item.getName());
Swift::RosterPayload::ref payload2 = getStanza(received[2])->getPayload<Swift::RosterPayload>();
CPPUNIT_ASSERT(payload2);
CPPUNIT_ASSERT_EQUAL(1, (int) payload2->getItems().size());
item = payload2->getItems()[0];
CPPUNIT_ASSERT_EQUAL(std::string("buddy2"), Buddy::JIDToLegacyName(item.getJID()));
CPPUNIT_ASSERT_EQUAL(std::string("Buddy 2"), item.getName());
// send responses back
injectIQ(Swift::IQ::createResult(getStanza(received[0])->getFrom(), getStanza(received[0])->getTo(), getStanza(received[0])->getID()));
injectIQ(Swift::IQ::createResult(getStanza(received[2])->getFrom(), getStanza(received[2])->getTo(), getStanza(received[2])->getID()));
// we should get presences
CPPUNIT_ASSERT_EQUAL(6, (int) received.size());
CPPUNIT_ASSERT(dynamic_cast<Swift::Presence *>(getStanza(received[4])));
CPPUNIT_ASSERT_EQUAL(Swift::StatusShow::Away, dynamic_cast<Swift::Presence *>(getStanza(received[4]))->getShow());
CPPUNIT_ASSERT_EQUAL(std::string("status1"), dynamic_cast<Swift::Presence *>(getStanza(received[4]))->getStatus());
CPPUNIT_ASSERT(dynamic_cast<Swift::Presence *>(getStanza(received[5])));
CPPUNIT_ASSERT_EQUAL(Swift::StatusShow::Away, dynamic_cast<Swift::Presence *>(getStanza(received[5]))->getShow());
CPPUNIT_ASSERT_EQUAL(std::string("status2"), dynamic_cast<Swift::Presence *>(getStanza(received[5]))->getStatus());
}
示例2: unsubscribeExistingBuddy
void unsubscribeExistingBuddy() {
add2Buddies();
received.clear();
Swift::Presence::ref response = Swift::Presence::create();
response->setTo("[email protected]");
response->setFrom("[email protected]/resource");
response->setType(Swift::Presence::Unsubscribe);
injectPresence(response);
loop->processEvents();
CPPUNIT_ASSERT_EQUAL(2, (int) received.size());
Swift::RosterPayload::ref payload1 = getStanza(received[0])->getPayload<Swift::RosterPayload>();
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(dynamic_cast<Swift::Presence *>(getStanza(received[1])));
CPPUNIT_ASSERT_EQUAL(Swift::Presence::Unsubscribed, dynamic_cast<Swift::Presence *>(getStanza(received[1]))->getType());
CPPUNIT_ASSERT_EQUAL(std::string("buddy1"), m_buddy);
}
示例3: handleRegisterRemoteRosterResponse
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 ¬ify_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);
}
示例4: handleBuddyUpdatedRequest
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();
}
}
}
示例5: 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());
}
示例6: handleBuddyChangedPayload
void handleBuddyChangedPayload() {
User *user = userManager->getUser("[email protected]");
pbnetwork::Buddy buddy;
buddy.set_username("[email protected]");
buddy.set_buddyname("[email protected]");
buddy.set_status(pbnetwork::STATUS_NONE);
std::string message;
buddy.SerializeToString(&message);
serv->handleBuddyChangedPayload(message);
CPPUNIT_ASSERT_EQUAL(1, (int) received.size());
Swift::RosterPayload::ref payload1 = getStanza(received[0])->getPayload<Swift::RosterPayload>();
CPPUNIT_ASSERT_EQUAL(1, (int) payload1->getItems().size());
Swift::RosterItemPayload item = payload1->getItems()[0];
CPPUNIT_ASSERT_EQUAL(std::string("buddy1\\[email protected]"), item.getJID().toString());
}
示例7: setBuddyNoAlias
void setBuddyNoAlias() {
User *user = userManager->getUser("[email protected]");
CPPUNIT_ASSERT(user);
std::vector<std::string> grp;
grp.push_back("group1");
LocalBuddy *buddy = new LocalBuddy(user->getRosterManager(), -1, "buddy1", "", grp, BUDDY_JID_ESCAPING);
user->getRosterManager()->setBuddy(buddy);
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(std::string(""), item.getName());
}
示例8: addEmptyBuddy
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, "[email protected]", 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("[email protected]");
iq->addPayload(p);
iq->setID("123");
injectIQ(iq);
CPPUNIT_ASSERT_EQUAL(std::string("none"), m_buddy);
}
示例9: 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;
}
示例10: handleBuddyChangedPayloadNoEscaping
void handleBuddyChangedPayloadNoEscaping() {
std::istringstream ifs("service.server_mode = 1\nservice.jid_escaping=0\nservice.jid=localhost\nservice.more_resources=1\n");
cfg->load(ifs);
User *user = userManager->getUser("[email protected]");
pbnetwork::Buddy buddy;
buddy.set_username("[email protected]");
buddy.set_buddyname("[email protected]");
buddy.set_status(pbnetwork::STATUS_NONE);
std::string message;
buddy.SerializeToString(&message);
serv->handleBuddyChangedPayload(message);
CPPUNIT_ASSERT_EQUAL(1, (int) received.size());
Swift::RosterPayload::ref payload1 = getStanza(received[0])->getPayload<Swift::RosterPayload>();
CPPUNIT_ASSERT_EQUAL(1, (int) payload1->getItems().size());
Swift::RosterItemPayload item = payload1->getItems()[0];
CPPUNIT_ASSERT_EQUAL(std::string("buddy1%[email protected]"), item.getJID().toString());
std::istringstream ifs2("service.server_mode = 1\nservice.jid_escaping=1\nservice.jid=localhost\nservice.more_resources=1\n");
cfg->load(ifs2);
}