本文整理汇总了C++中swift::JID::getDomain方法的典型用法代码示例。如果您正苦于以下问题:C++ JID::getDomain方法的具体用法?C++ JID::getDomain怎么用?C++ JID::getDomain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类swift::JID
的用法示例。
在下文中一共展示了JID::getDomain方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleSetRequest
bool UserRegistration::handleSetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::InBandRegistrationPayload> payload) {
if (CONFIG_STRING(m_config, "service.protocol") == "irc") {
Swift::GetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify);
return true;
}
std::string barejid = from.toBare().toString();
// AbstractUser *user = m_component->userManager()->getUserByJID(barejid);
if (!CONFIG_BOOL(m_config,"registration.enable_public_registration")) {
std::list<std::string> const &x = CONFIG_LIST(m_config,"service.allowed_servers");
if (std::find(x.begin(), x.end(), from.getDomain()) == x.end()) {
// Log("UserRegistration", "This user has no permissions to register an account");
Swift::SetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify);
return true;
}
}
UserInfo res;
bool registered = m_storageBackend->getUser(barejid, res);
std::string encoding;
std::string language;
Form::ref form = payload->getForm();
if (form) {
const std::vector<FormField::ref> fields = form->getFields();
for (std::vector<FormField::ref>::const_iterator it = fields.begin(); it != fields.end(); it++) {
TextSingleFormField::ref textSingle = boost::dynamic_pointer_cast<TextSingleFormField>(*it);
if (textSingle) {
if (textSingle->getName() == "username") {
payload->setUsername(textSingle->getValue());
}
else if (textSingle->getName() == "encoding") {
encoding = textSingle->getValue();
}
continue;
}
TextPrivateFormField::ref textPrivate = boost::dynamic_pointer_cast<TextPrivateFormField>(*it);
if (textPrivate) {
if (textPrivate->getName() == "password") {
payload->setPassword(textPrivate->getValue());
}
continue;
}
ListSingleFormField::ref listSingle = boost::dynamic_pointer_cast<ListSingleFormField>(*it);
if (listSingle) {
if (listSingle->getName() == "language") {
language = listSingle->getValue();
}
continue;
}
BooleanFormField::ref boolean = boost::dynamic_pointer_cast<BooleanFormField>(*it);
if (boolean) {
if (boolean->getName() == "unregister") {
if (boolean->getValue()) {
payload->setRemove(true);
}
}
continue;
}
}
}
if (payload->isRemove()) {
unregisterUser(barejid);
Swift::SetResponder<Swift::InBandRegistrationPayload>::sendResponse(from, id, InBandRegistrationPayload::ref());
return true;
}
if (!payload->getUsername() || !payload->getPassword()) {
Swift::SetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify);
return true;
}
// Register or change password
if (payload->getUsername()->empty() ||
(payload->getPassword()->empty() && CONFIG_STRING(m_config, "service.protocol") != "twitter" && CONFIG_STRING(m_config, "service.protocol") != "bonjour")
// || localization.getLanguages().find(language) == localization.getLanguages().end()
)
{
Swift::SetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify);
return true;
}
if (CONFIG_STRING(m_config, "service.protocol") == "xmpp") {
// User tries to register himself.
if ((Swift::JID(*payload->getUsername()).toBare() == from.toBare())) {
Swift::SetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify);
return true;
}
// User tries to register someone who's already registered.
UserInfo user_row;
bool registered = m_storageBackend->getUser(Swift::JID(*payload->getUsername()).toBare().toString(), user_row);
if (registered) {
Swift::SetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::NotAcceptable, ErrorPayload::Modify);
//.........这里部分代码省略.........
示例2: handleGetRequest
bool UserRegistration::handleGetRequest(const Swift::JID& from, const Swift::JID& to, const std::string& id, boost::shared_ptr<Swift::InBandRegistrationPayload> payload) {
if (CONFIG_STRING(m_config, "service.protocol") == "irc") {
Swift::GetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify);
return true;
}
std::string barejid = from.toBare().toString();
// User *user = m_userManager->getUserByJID(barejid);
if (!CONFIG_BOOL(m_config,"registration.enable_public_registration")) {
std::list<std::string> const &x = CONFIG_LIST(m_config,"service.allowed_servers");
if (std::find(x.begin(), x.end(), from.getDomain()) == x.end()) {
// Log("UserRegistration", "This user has no permissions to register an account");
Swift::GetResponder<Swift::InBandRegistrationPayload>::sendError(from, id, ErrorPayload::BadRequest, ErrorPayload::Modify);
return true;
}
}
// const char *_language = user ? user->getLang() : CONFIG_STRING(m_config, "registration.language").c_str();
boost::shared_ptr<InBandRegistrationPayload> reg(new InBandRegistrationPayload());
UserInfo res;
bool registered = m_storageBackend->getUser(barejid, res);
std::string instructions = CONFIG_STRING(m_config, "registration.instructions");
reg->setInstructions(instructions);
reg->setRegistered(registered);
reg->setUsername(res.uin);
if (CONFIG_STRING(m_config, "service.protocol") != "twitter" && CONFIG_STRING(m_config, "service.protocol") != "bonjour")
reg->setPassword(res.password);
std::string usernameField = CONFIG_STRING(m_config, "registration.username_field");
Form::ref form(new Form(Form::FormType));
form->setTitle(tr(_language, _("Registration")));
form->setInstructions(tr(_language, instructions));
HiddenFormField::ref type = HiddenFormField::create();
type->setName("FORM_TYPE");
type->setValue("jabber:iq:register");
form->addField(type);
TextSingleFormField::ref username = TextSingleFormField::create();
username->setName("username");
username->setLabel(tr(_language, usernameField));
username->setValue(res.uin);
username->setRequired(true);
form->addField(username);
if (CONFIG_STRING(m_config, "service.protocol") != "twitter" && CONFIG_STRING(m_config, "service.protocol") != "bonjour") {
TextPrivateFormField::ref password = TextPrivateFormField::create();
password->setName("password");
password->setLabel(tr(_language, _("Password")));
password->setRequired(true);
form->addField(password);
}
ListSingleFormField::ref language = ListSingleFormField::create();
language->setName("language");
language->setLabel(tr(_language, _("Language")));
if (registered)
language->setValue(res.language);
else
language->setValue(CONFIG_STRING(m_config, "registration.language"));
// std::map <std::string, std::string> languages = localization.getLanguages();
// for (std::map <std::string, std::string>::iterator it = languages.begin(); it != languages.end(); it++) {
// language->addOption(FormField::Option((*it).second, (*it).first));
// }
form->addField(language);
TextSingleFormField::ref encoding = TextSingleFormField::create();
encoding->setName("encoding");
encoding->setLabel(tr(_language, _("Encoding")));
if (registered)
encoding->setValue(res.encoding);
else
encoding->setValue(CONFIG_STRING(m_config, "registration.encoding"));
form->addField(encoding);
if (registered) {
BooleanFormField::ref boolean = BooleanFormField::create();
boolean->setName("unregister");
boolean->setLabel(tr(_language, _("Remove your registration")));
boolean->setValue(0);
form->addField(boolean);
}
reg->setForm(form);
Swift::GetResponder<Swift::InBandRegistrationPayload>::sendResponse(from, id, reg);
return true;
}