use of org.jxmpp.jid.EntityJid in project Smack by igniterealtime.
the class MUCUserProvider method parseInvite.
private static MUCUser.Invite parseInvite(XmlPullParser parser) throws XmlPullParserException, IOException {
String reason = null;
EntityBareJid to = ParserUtils.getBareJidAttribute(parser, "to");
EntityJid from = ParserUtils.getEntityJidAttribute(parser, "from");
outerloop: while (true) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("reason")) {
reason = parser.nextText();
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("invite")) {
break outerloop;
}
}
}
return new MUCUser.Invite(reason, from, to);
}
use of org.jxmpp.jid.EntityJid in project Smack by igniterealtime.
the class ParserUtils method getEntityJidAttribute.
public static EntityJid getEntityJidAttribute(XmlPullParser parser, String name) throws XmppStringprepException {
final String jidString = parser.getAttributeValue("", name);
if (jidString == null) {
return null;
}
Jid jid = JidCreate.from(jidString);
if (!jid.hasLocalpart())
return null;
EntityFullJid fullJid = jid.asEntityFullJidIfPossible();
if (fullJid != null) {
return fullJid;
}
EntityBareJid bareJid = jid.asEntityBareJidIfPossible();
return bareJid;
}
use of org.jxmpp.jid.EntityJid in project Smack by igniterealtime.
the class ChatManager method createChat.
/**
* Creates a new {@link Chat} based on the message. May returns null if no chat could be
* created, e.g. because the message comes without from.
*
* @param message
* @return a Chat or null if none can be created
*/
private Chat createChat(Message message) {
Jid from = message.getFrom();
// are of no use in this case for ChatManager
if (from == null) {
return null;
}
EntityJid userJID = from.asEntityJidIfPossible();
if (userJID == null) {
LOGGER.warning("Message from JID without localpart: '" + message.toXML() + "'");
return null;
}
String threadID = message.getThread();
if (threadID == null) {
threadID = nextID();
}
return createChat(userJID, threadID, false);
}
use of org.jxmpp.jid.EntityJid in project Smack by igniterealtime.
the class ChatManager method closeChat.
void closeChat(Chat chat) {
threadChats.remove(chat.getThreadID());
EntityJid userJID = chat.getParticipant();
jidChats.remove(userJID);
baseJidChats.remove(userJID.asEntityBareJid());
}
Aggregations