本文整理汇总了C++中swift::presence::ref::setFrom方法的典型用法代码示例。如果您正苦于以下问题:C++ ref::setFrom方法的具体用法?C++ ref::setFrom怎么用?C++ ref::setFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类swift::presence::ref
的用法示例。
在下文中一共展示了ref::setFrom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unregisterUser
bool UserRegistration::unregisterUser(const std::string &barejid) {
UserInfo userInfo;
bool registered = m_storageBackend->getUser(barejid, userInfo);
// This user is not registered
if (!registered)
return false;
onUserUnregistered(userInfo);
Swift::Presence::ref response;
User *user = m_userManager->getUser(barejid);
// roster contains already escaped jids
std::list <std::string> roster;
m_storageBackend->getBuddies(userInfo.id, roster);
for(std::list<std::string>::iterator u = roster.begin(); u != roster.end() ; u++){
std::string name = *u;
response = Swift::Presence::create();
response->setTo(Swift::JID(barejid));
response->setFrom(Swift::JID(name + "@" + m_component->getJID().toString()));
response->setType(Swift::Presence::Unsubscribe);
m_component->m_component->sendPresence(response);
response = Swift::Presence::create();
response->setTo(Swift::JID(barejid));
response->setFrom(Swift::JID(name + "@" + m_component->getJID().toString()));
response->setType(Swift::Presence::Unsubscribed);
m_component->m_component->sendPresence(response);
}
// Remove user from database
m_storageBackend->removeUser(userInfo.id);
// Disconnect the user
if (user) {
m_userManager->removeUser(user);
}
response = Swift::Presence::create();
response->setTo(Swift::JID(barejid));
response->setFrom(m_component->getJID());
response->setType(Swift::Presence::Unsubscribe);
m_component->m_component->sendPresence(response);
response = Swift::Presence::create();
response->setTo(Swift::JID(barejid));
response->setFrom(m_component->getJID());
response->setType(Swift::Presence::Unsubscribed);
m_component->m_component->sendPresence(response);
return true;
}
示例2: sendBuddyUnsubscribePresence
void RosterManager::sendBuddyUnsubscribePresence(Buddy *buddy) {
Swift::Presence::ref response = Swift::Presence::create();
response->setTo(m_user->getJID());
response->setFrom(buddy->getJID());
response->setType(Swift::Presence::Unsubscribe);
m_component->getFrontend()->sendPresence(response);
response = Swift::Presence::create();
response->setTo(m_user->getJID());
response->setFrom(buddy->getJID());
response->setType(Swift::Presence::Unsubscribed);
m_component->getFrontend()->sendPresence(response);
}
示例3: handleSubscriptionRevoked
void handleSubscriptionRevoked(const std::string &user, const Swift::JID& jid, const std::string& message) {
Swift::Presence::ref presence = Swift::Presence::create();
presence->setTo(user);
presence->setFrom(jid);
presence->setType(Swift::Presence::Unsubscribe);
handleSwiftPresenceChanged(user, presence);
}
示例4: 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);
}
示例5: 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);
}
示例6: finishSession
void ServerStanzaChannel::finishSession(const JID& to, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ToplevelElement> element, bool last) {
#else
void ServerStanzaChannel::finishSession(const JID& to, SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Element> element, bool last) {
#endif
std::vector<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> > candidateSessions;
for (std::list<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> >::const_iterator i = sessions[to.toBare().toString()].begin(); i != sessions[to.toBare().toString()].end(); ++i) {
candidateSessions.push_back(*i);
}
for (std::vector<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> >::const_iterator i = candidateSessions.begin(); i != candidateSessions.end(); ++i) {
removeSession(*i);
if (element) {
(*i)->sendElement(element);
}
if (last && (*i)->getRemoteJID().isValid()) {
Swift::Presence::ref presence = Swift::Presence::create();
presence->setFrom((*i)->getRemoteJID());
presence->setType(Swift::Presence::Unavailable);
onPresenceReceived(presence);
}
(*i)->finishSession();
// std::cout << "FINISH SESSION " << sessions[to.toBare().toString()].size() << "\n";
if (last) {
break;
}
}
}
示例7: connectSecondResource
void BasicTest::connectSecondResource() {
serverFromClientSession2 = boost::shared_ptr<Swift::ServerFromClientSession>(new Swift::ServerFromClientSession("id", factories->getConnectionFactory()->createConnection(),
payloadParserFactories, payloadSerializers, userRegistry, factories->getXMLParserFactory(), Swift::JID("[email protected]/resource2")));
serverFromClientSession2->startSession();
serverFromClientSession2->onDataWritten.connect(boost::bind(&BasicTest::handleDataReceived2, this, _1));
dynamic_cast<Swift::ServerStanzaChannel *>(component->getStanzaChannel())->addSession(serverFromClientSession2);
userRegistry->isValidUserPassword(Swift::JID("[email protected]/resource2"), serverFromClientSession2.get(), Swift::createSafeByteArray("password"));
userRegistry->onPasswordValid(Swift::JID("[email protected]/resource2"));
loop->processEvents();
Swift::Presence::ref response = Swift::Presence::create();
response->setTo("localhost");
response->setFrom("[email protected]/resource2");
injectPresence(response);
loop->processEvents();
CPPUNIT_ASSERT_EQUAL(1, userManager->getUserCount());
User *user = userManager->getUser("[email protected]");
CPPUNIT_ASSERT(user);
CPPUNIT_ASSERT_EQUAL(2, user->getResourceCount());
CPPUNIT_ASSERT(getStanza(received2[1])->getPayload<Swift::DiscoInfo>());
}
示例8: destroyRoom
void Conversation::destroyRoom() {
if (m_muc) {
Swift::Presence::ref presence = Swift::Presence::create();
std::string legacyName = m_legacyName;
if (!m_mucEscaping && legacyName.find_last_of("@") != std::string::npos) {
legacyName.replace(legacyName.find_last_of("@"), 1, "%"); // OK
}
legacyName = Swift::JID::getEscapedNode(legacyName);
presence->setFrom(Swift::JID(legacyName, m_conversationManager->getComponent()->getJID().toBare(), m_nickname));
presence->setType(Swift::Presence::Unavailable);
Swift::MUCItem item;
item.affiliation = Swift::MUCOccupant::NoAffiliation;
item.role = Swift::MUCOccupant::NoRole;
item.actor = "Transport";
item.reason = "Spectrum 2 transport is being shut down.";
Swift::MUCUserPayload *p = new Swift::MUCUserPayload ();
p->addItem(item);
Swift::MUCUserPayload::StatusCode c;
c.code = 332;
p->addStatusCode(c);
Swift::MUCUserPayload::StatusCode c2;
c2.code = 307;
p->addStatusCode(c2);
presence->addPayload(boost::shared_ptr<Swift::Payload>(p));
BOOST_FOREACH(const Swift::JID &jid, m_jids) {
presence->setTo(jid);
m_conversationManager->getComponent()->getFrontend()->sendPresence(presence);
}
}
示例9: handleSwiftConnected
void handleSwiftConnected(const std::string &user) {
LOG4CXX_INFO(logger, user << ": Connected to XMPP server.");
handleConnected(user);
m_users[user]->requestRoster();
Swift::Presence::ref response = Swift::Presence::create();
response->setFrom(m_users[user]->getJID());
m_users[user]->sendPresence(response);
}
示例10: handleDataRead
void ServerStanzaChannel::handleDataRead(const SafeByteArray &data, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> &session) {
if (safeByteArrayToString(data).find("</stream:stream>") != std::string::npos) {
Swift::Presence::ref presence = Swift::Presence::create();
presence->setFrom(session->getRemoteJID());
presence->setType(Swift::Presence::Unavailable);
onPresenceReceived(presence);
}
}
示例11: handlePresenceWithNode
void handlePresenceWithNode() {
Swift::Presence::ref response = Swift::Presence::create();
response->setTo("[email protected]");
response->setFrom("[email protected]/resource");
dynamic_cast<Swift::ServerStanzaChannel *>(component->getStanzaChannel())->onPresenceReceived(response);
loop->processEvents();
CPPUNIT_ASSERT_EQUAL(0, (int) received.size());
}
示例12: handleSessionFinished
void ServerStanzaChannel::handleSessionFinished(const boost::optional<Session::SessionError>&, const SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession>& session) {
removeSession(session);
// if (!session->initiatedFinish()) {
Swift::Presence::ref presence = Swift::Presence::create();
presence->setFrom(session->getRemoteJID());
presence->setType(Swift::Presence::Unavailable);
onPresenceReceived(presence);
// }
}
示例13: sendBuddySubscribePresence
void RosterManager::sendBuddySubscribePresence(Buddy *buddy) {
Swift::Presence::ref response = Swift::Presence::create();
response->setTo(m_user->getJID());
response->setFrom(buddy->getJID().toBare());
response->setType(Swift::Presence::Subscribe);
if (!buddy->getAlias().empty()) {
response->addPayload(boost::make_shared<Swift::Nickname>(buddy->getAlias()));
}
m_component->getFrontend()->sendPresence(response);
}
示例14: handleErrorPresence
// Error presence should be ignored
void handleErrorPresence() {
Swift::Presence::ref response = Swift::Presence::create();
response->setTo("localhost");
response->setFrom("[email protected]/resource");
response->setType(Swift::Presence::Error);
dynamic_cast<Swift::ServerStanzaChannel *>(static_cast<XMPPFrontend *>(component->getFrontend())->getStanzaChannel())->onPresenceReceived(response);
loop->processEvents();
CPPUNIT_ASSERT_EQUAL(0, (int) received.size());
}
示例15: handlePresenceWithoutNode
void handlePresenceWithoutNode() {
Swift::Presence::ref response = Swift::Presence::create();
response->setTo("localhost");
response->setFrom("[email protected]/resource");
dynamic_cast<Swift::ServerStanzaChannel *>(component->getStanzaChannel())->onPresenceReceived(response);
loop->processEvents();
CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::DiscoInfo>());
CPPUNIT_ASSERT(onUserPresenceReceived);
}