本文整理汇总了C++中JID::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ JID::isValid方法的具体用法?C++ JID::isValid怎么用?C++ JID::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JID
的用法示例。
在下文中一共展示了JID::isValid方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: routeStanza
bool ServerStanzaRouter::routeStanza(boost::shared_ptr<Stanza> stanza) {
JID to = stanza->getTo();
assert(to.isValid());
// For a full JID, first try to route to a session with the full JID
if (!to.isBare()) {
std::vector<ServerSession*>::const_iterator i = std::find_if(clientSessions_.begin(), clientSessions_.end(), HasJID(to));
if (i != clientSessions_.end()) {
(*i)->sendStanza(stanza);
return true;
}
}
// Look for candidate sessions
to = to.toBare();
std::vector<ServerSession*> candidateSessions;
for (std::vector<ServerSession*>::const_iterator i = clientSessions_.begin(); i != clientSessions_.end(); ++i) {
if ((*i)->getJID().equals(to, JID::WithoutResource) && (*i)->getPriority() >= 0) {
candidateSessions.push_back(*i);
}
}
if (candidateSessions.empty()) {
return false;
}
// Find the session with the highest priority
std::vector<ServerSession*>::const_iterator i = std::max_element(clientSessions_.begin(), clientSessions_.end(), PriorityLessThan());
(*i)->sendStanza(stanza);
return true;
}
示例2: send
void ServerStanzaChannel::send(SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Stanza> stanza) {
JID to = stanza->getTo();
assert(to.isValid());
if (!stanza->getFrom().isValid()) {
stanza->setFrom(m_jid);
}
// For a full JID, first try to route to a session with the full JID
if (!to.isBare()) {
std::list<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> >::const_iterator i = std::find_if(sessions[stanza->getTo().toBare().toString()].begin(), sessions[stanza->getTo().toBare().toString()].end(), HasJID(to));
if (i != sessions[stanza->getTo().toBare().toString()].end()) {
(*i)->sendElement(stanza);
return;
}
}
// Look for candidate sessions
to = to.toBare();
std::vector<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> > candidateSessions;
for (std::list<SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<ServerFromClientSession> >::const_iterator i = sessions[stanza->getTo().toBare().toString()].begin(); i != sessions[stanza->getTo().toBare().toString()].end(); ++i) {
if ((*i)->getRemoteJID().equals(to, JID::WithoutResource)) {
candidateSessions.push_back(*i);
(*i)->sendElement(stanza);
}
}
if (candidateSessions.empty()) {
return;
}
// Find the session with the highest priority
// std::vector<ServerSession*>::const_iterator i = std::max_element(sessions.begin(), sessions.end(), PriorityLessThan());
// (*i)->sendStanza(stanza);
return;
}
示例3: handleVCardReceived
void VCardManager::handleVCardReceived(const JID& actualJID, VCard::ref vcard, ErrorPayload::ref error) {
requestedVCards.erase(actualJID);
if (!error) {
if (!vcard) {
vcard = VCard::ref(new VCard());
}
JID jid = actualJID.isValid() ? actualJID : ownJID.toBare();
setVCard(jid, vcard);
}
}
示例4: jidFromIndex
JID QtTreeWidget::jidFromIndex(const QModelIndex& index) const {
JID target;
if (messageTarget_ == MessageDisplayJID) {
target = JID(Q2PSTRING(index.data(DisplayJIDRole).toString()));
target = target.toBare();
}
if (!target.isValid()) {
target = JID(Q2PSTRING(index.data(JIDRole).toString()));
}
return target;
}
示例5:
std::shared_ptr<IQ> IQ::createRequest(
Type type, const JID& to, const std::string& id, std::shared_ptr<Payload> payload) {
std::shared_ptr<IQ> iq = std::make_shared<IQ>(type);
if (to.isValid()) {
iq->setTo(to);
}
iq->setID(id);
if (payload) {
iq->addPayload(payload);
}
return iq;
}
示例6: isCorrectSender
bool Request::isCorrectSender(const JID& jid) {
if (router_->isAccountJID(receiver_)) {
if (jid.isValid() && jid.equals(router_->getJID(), JID::WithResource)) {
// This unspecified behavior seems to happen in ejabberd versions (e.g. 2.0.5)
SWIFT_LOG(warning) << "Server responded to an account request with a full JID, which is not allowed. Handling it anyway.";
return true;
}
return router_->isAccountJID(jid);
}
else {
return jid.equals(receiver_, JID::WithResource);
}
}
示例7: IBBResponder
IBBReceiveSession::IBBReceiveSession(
const std::string& id,
const JID& from,
const JID& to,
size_t size,
IQRouter* router) :
id(id),
from(from),
to(to),
size(size),
router(router),
active(false) {
assert(!id.empty());
assert(from.isValid());
responder = new IBBResponder(this, router);
}
示例8: handleJIDEditingFinished
void UserSearchController::handleJIDEditingFinished(const JID& jid) {
if (jid.isValid()) {
if (rosterController_->getItem(jid)) {
window_->setWarning(QT_TRANSLATE_NOOP("", "This contact is already on your contact list."));
}
else if (jid.getNode().empty()) {
window_->setWarning(QT_TRANSLATE_NOOP("", "Part of the address you have entered is missing. An address has a structure of '[email protected]'."));
}
else {
window_->setWarning(boost::optional<std::string>());
}
}
else {
window_->setWarning(QT_TRANSLATE_NOOP("", "The address you have entered is invalid."));
}
}
示例9: id
IBBReceiveSession::IBBReceiveSession(
const std::string& id,
const JID& from,
const JID& to,
unsigned long long size,
std::shared_ptr<WriteBytestream> bytestream,
IQRouter* router) :
id(id),
from(from),
to(to),
size(size),
bytestream(bytestream),
router(router),
active(false) {
assert(!id.empty());
assert(from.isValid());
responder = new IBBResponder(this, router);
}
示例10: getContactJID
JID QtUserSearchWindow::getContactJID() const {
JID jid;
bool useSearchResult;
if (type_ == AddContact) {
useSearchResult = !firstPage_->byJID_->isChecked();
} else {
useSearchResult = true;
}
if (useSearchResult) {
if (dynamic_cast<UserSearchModel*>(model_)) {
UserSearchResult* userItem = static_cast<UserSearchResult*>(resultsPage_->results_->currentIndex().internalPointer());
if (userItem) { /* Remember to leave this if we change to dynamic cast */
jid = userItem->getJID();
}
} else if (dynamic_cast<QtFormResultItemModel*>(model_)) {
int row = resultsPage_->results_->currentIndex().row();
Form::FormItem item = dynamic_cast<QtFormResultItemModel*>(model_)->getForm()->getItems().at(row);
JID fallbackJid;
for (FormField::ref field : item) {
if (field->getType() == FormField::JIDSingleType) {
jid = JID(field->getJIDSingleValue());
break;
}
if (field->getName() == "jid") {
fallbackJid = field->getValues()[0];
}
}
if (!jid.isValid()) {
jid = fallbackJid;
}
}
}
else {
jid = JID(Q2PSTRING(firstPage_->jid_->text().trimmed()));
}
return jid;
}
示例11: addToSavedDirectories
void UserSearchController::addToSavedDirectories(const JID& jid) {
if (!jid.isValid()) {
return;
}
savedDirectories_.erase(std::remove(savedDirectories_.begin(), savedDirectories_.end(), jid), savedDirectories_.end());
savedDirectories_.insert(savedDirectories_.begin(), jid);
std::string collapsed;
int i = 0;
for (const auto& jidItem : savedDirectories_) {
if (i >= 15) {
break;
}
if (!collapsed.empty()) {
collapsed += "\n";
}
collapsed += jidItem.toString();
++i;
}
settings_->storeString(SEARCHED_DIRECTORIES, collapsed);
window_->addSavedServices(savedDirectories_);
}
示例12: handleItemActivated
void QtTreeWidget::handleItemActivated(const QModelIndex& index) {
JID target = jidFromIndex(index);
if (target.isValid()) {
eventStream_->send(std::make_shared<RequestChatUIEvent>(target));
}
}