本文整理汇总了C++中presence::ref类的典型用法代码示例。如果您正苦于以下问题:C++ ref类的具体用法?C++ ref怎么用?C++ ref使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ref类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertJIDtoContact
Contact::ref UserSearchController::convertJIDtoContact(const JID& jid) {
Contact::ref contact = std::make_shared<Contact>();
contact->jid = jid;
// name lookup
boost::optional<XMPPRosterItem> rosterItem = rosterController_->getItem(jid);
if (rosterItem && !rosterItem->getName().empty()) {
contact->name = rosterItem->getName();
} else {
VCard::ref vcard = vcardManager_->getVCard(jid);
if (vcard && !vcard->getFullName().empty()) {
contact->name = vcard->getFullName();
} else {
contact->name = jid.toString();
}
}
// presence lookup
Presence::ref presence = presenceOracle_->getAccountPresence(jid);
if (presence) {
contact->statusType = presence->getShow();
} else {
contact->statusType = StatusShow::None;
}
// avatar lookup
contact->avatarPath = avatarManager_->getAvatarPath(jid);
return contact;
}
示例2: handlePresenceReceived
void WhiteboardSessionManager::handlePresenceReceived(Presence::ref presence) {
if (!presence->isAvailable()) {
WhiteboardSession::ref session = getSession(presence->getFrom());
if (session) {
session->cancel();
}
}
}
示例3: createPresence
Presence::ref createPresence(const JID &jid, int priority, Presence::Type type, const StatusShow::Type& statusShow) {
Presence::ref presence = boost::make_shared<Presence>();
presence->setFrom(jid);
presence->setPriority(priority);
presence->setType(type);
presence->setShow(statusShow);
return presence;
}
示例4: handlePresenceReceived
void handlePresenceReceived(Presence::ref presence) {
// Automatically approve subscription requests
if (presence->getType() == Presence::Subscribe) {
Presence::ref response = Presence::create();
response->setTo(presence->getFrom());
response->setType(Presence::Subscribed);
client->sendPresence(response);
}
}
示例5: handleIncomingPresence
void SubscriptionManager::handleIncomingPresence(Presence::ref presence) {
JID bareJID(presence->getFrom().toBare());
if (presence->getType() == Presence::Subscribe) {
onPresenceSubscriptionRequest(bareJID, presence->getStatus(), presence);
}
else if (presence->getType() == Presence::Unsubscribe) {
onPresenceSubscriptionRevoked(bareJID, presence->getStatus());
}
}
示例6: handleJIDRemoved
void PresenceOracle::handleJIDRemoved(const JID& removedJID) {
/* 3921bis says that we don't follow up with an unavailable, so simulate this ourselves */
Presence::ref unavailablePresence = Presence::ref(new Presence());
unavailablePresence->setType(Presence::Unavailable);
unavailablePresence->setFrom(removedJID);
if (entries_.find(removedJID) != entries_.end()) {
entries_[removedJID].clear();
entries_[removedJID][removedJID] = unavailablePresence;
}
onPresenceChange(unavailablePresence);
}
示例7: sendPresence
void PayloadAddingPresenceSender::sendPresence(Presence::ref presence) {
if (presence->isAvailable()) {
if (!presence->getTo().isValid()) {
lastSentPresence = presence;
}
}
else {
lastSentPresence.reset();
}
if (payload) {
Presence::ref sentPresence = Presence::create(presence);
sentPresence->updatePayload(payload);
sender->sendPresence(sentPresence);
}
else {
sender->sendPresence(presence);
}
}
示例8: testUnavailablePresence
void testUnavailablePresence() {
std::vector<std::string> groups;
groups.push_back("testGroup1");
JID from("[email protected]");
xmppRoster_->addContact(from, "name", groups, RosterItemPayload::Both);
Presence::ref lowPresence(new Presence());
lowPresence->setFrom(withResource(from, "bob"));
lowPresence->setPriority(2);
lowPresence->setShow(StatusShow::Away);
lowPresence->setStatus("Not here");
Presence::ref lowPresenceOffline(new Presence());
lowPresenceOffline->setFrom(withResource(from, "bob"));
lowPresenceOffline->setStatus("Signing out");
lowPresenceOffline->setType(Presence::Unavailable);
Presence::ref highPresence(new Presence());
highPresence->setFrom(withResource(from, "bert"));
highPresence->setPriority(10);
highPresence->setStatus("So totally here");
Presence::ref highPresenceOffline(new Presence());
highPresenceOffline->setFrom(withResource(from, "bert"));
highPresenceOffline->setType(Presence::Unavailable);
stanzaChannel_->onPresenceReceived(lowPresence);
Presence::ref accountPresence = presenceOracle_->getAccountPresence(from);
CPPUNIT_ASSERT_EQUAL(StatusShow::Away, accountPresence->getShow());
stanzaChannel_->onPresenceReceived(highPresence);
accountPresence = presenceOracle_->getAccountPresence(from);
CPPUNIT_ASSERT_EQUAL(StatusShow::Online, accountPresence->getShow());
stanzaChannel_->onPresenceReceived(highPresenceOffline);
// After this, the roster should show the low presence.
ContactRosterItem* item = dynamic_cast<ContactRosterItem*>(dynamic_cast<GroupRosterItem*>(CHILDREN[0])->getChildren()[0]);
CPPUNIT_ASSERT(item);
Presence::ref low = presenceOracle_->getAccountPresence(from);
CPPUNIT_ASSERT_EQUAL(Presence::Available, low->getType());
CPPUNIT_ASSERT_EQUAL(lowPresence->getStatus(), low->getStatus());
CPPUNIT_ASSERT_EQUAL(lowPresence->getShow(), item->getStatusShow());
CPPUNIT_ASSERT_EQUAL(lowPresence->getStatus(), item->getStatusText());
stanzaChannel_->onPresenceReceived(lowPresenceOffline);
item = dynamic_cast<ContactRosterItem*>(dynamic_cast<GroupRosterItem*>(CHILDREN[0])->getChildren()[0]);
CPPUNIT_ASSERT(item);
/* A verification that if the test fails, it's the RosterController, not the PresenceOracle. */
low = presenceOracle_->getHighestPriorityPresence(from);
CPPUNIT_ASSERT_EQUAL(Presence::Unavailable, low->getType());
CPPUNIT_ASSERT_EQUAL(lowPresenceOffline->getStatus(), low->getStatus());
CPPUNIT_ASSERT_EQUAL(StatusShow::None, item->getStatusShow());
CPPUNIT_ASSERT_EQUAL(lowPresenceOffline->getStatus(), item->getStatusText());
}
示例9: operator
bool operator()(const Presence::ref& a, const Presence::ref& b) {
int aPreference = preferenceFromStatusShow(a->getShow());
int bPreference = preferenceFromStatusShow(b->getShow());
if (aPreference != bPreference) {
return aPreference < bPreference;
}
if (a->getPriority() != b->getPriority()) {
return a->getPriority() < b->getPriority();
}
return a->getFrom().getResource() < b->getFrom().getResource();
}
示例10: getHighestPriorityPresence
Presence::ref PresenceOracle::getHighestPriorityPresence(const JID& bareJID) const {
PresencesMap::const_iterator i = entries_.find(bareJID);
if (i == entries_.end()) {
return Presence::ref();
}
Presence::ref highest;
for (const auto& jidPresence : i->second) {
Presence::ref current = jidPresence.second;
if (!highest
|| current->getPriority() > highest->getPriority()
|| (current->getPriority() == highest->getPriority()
&& StatusShow::typeToAvailabilityOrdering(current->getShow()) > StatusShow::typeToAvailabilityOrdering(highest->getShow()))) {
highest = current;
}
}
return highest;
}
示例11: handleIncomingPresence
void PresenceOracle::handleIncomingPresence(Presence::ref presence) {
// ignore presences for some contact, we're checking only presences for the transport itself here.
// filter out login/logout presence spam
if (!presence->getTo().getNode().empty())
return;
JID bareJID(presence->getFrom().toBare());
if (presence->getType() == Presence::Subscribe || presence->getType() == Presence::Subscribed) {
}
else {
Presence::ref passedPresence = presence;
if (presence->getType() == Presence::Unsubscribe || presence->getType() == Presence::Unsubscribed) {
/* 3921bis says that we don't follow up with an unavailable, so simulate this ourselves */
passedPresence = Presence::ref(new Presence());
passedPresence->setType(Presence::Unavailable);
passedPresence->setFrom(bareJID);
passedPresence->setStatus(presence->getStatus());
}
std::map<JID, boost::shared_ptr<Presence> > jidMap = entries_[bareJID];
if (passedPresence->getFrom().isBare() && presence->getType() == Presence::Unavailable) {
/* Have a bare-JID only presence of offline */
jidMap.clear();
} else if (passedPresence->getType() == Presence::Available) {
/* Don't have a bare-JID only offline presence once there are available presences */
jidMap.erase(bareJID);
}
if (passedPresence->getType() == Presence::Unavailable && jidMap.size() > 1) {
jidMap.erase(passedPresence->getFrom());
} else {
jidMap[passedPresence->getFrom()] = passedPresence;
}
entries_[bareJID] = jidMap;
onPresenceChange(passedPresence);
}
}
示例12: handlePresenceChanged
void UserSearchController::handlePresenceChanged(Presence::ref presence) {
handleJIDUpdateRequested(std::vector<JID>(1, presence->getFrom().toBare()));
}
示例13: handleIncomingPresence
void PresenceOracle::handleIncomingPresence(Presence::ref presence) {
JID bareJID(presence->getFrom().toBare());
if (presence->getType() == Presence::Subscribe) {
}
else {
Presence::ref passedPresence = presence;
if (presence->getType() == Presence::Unsubscribe) {
/* 3921bis says that we don't follow up with an unavailable, so simulate this ourselves */
passedPresence = Presence::ref(new Presence());
passedPresence->setType(Presence::Unavailable);
passedPresence->setFrom(bareJID);
passedPresence->setStatus(presence->getStatus());
}
std::map<JID, boost::shared_ptr<Presence> > jidMap = entries_[bareJID];
if (passedPresence->getFrom().isBare() && presence->getType() == Presence::Unavailable) {
/* Have a bare-JID only presence of offline */
jidMap.clear();
} else if (passedPresence->getType() == Presence::Available) {
/* Don't have a bare-JID only offline presence once there are available presences */
jidMap.erase(bareJID);
}
if (passedPresence->getType() == Presence::Unavailable && jidMap.size() > 1) {
jidMap.erase(passedPresence->getFrom());
} else {
jidMap[passedPresence->getFrom()] = passedPresence;
}
entries_[bareJID] = jidMap;
onPresenceChange(passedPresence);
}
}