Search in sources :

Example 1 with EntityJid

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);
}
Also used : EntityBareJid(org.jxmpp.jid.EntityBareJid) EntityJid(org.jxmpp.jid.EntityJid)

Example 2 with EntityJid

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;
}
Also used : Jid(org.jxmpp.jid.Jid) EntityJid(org.jxmpp.jid.EntityJid) EntityFullJid(org.jxmpp.jid.EntityFullJid) EntityBareJid(org.jxmpp.jid.EntityBareJid) EntityFullJid(org.jxmpp.jid.EntityFullJid) EntityBareJid(org.jxmpp.jid.EntityBareJid)

Example 3 with EntityJid

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);
}
Also used : EntityJid(org.jxmpp.jid.EntityJid) EntityBareJid(org.jxmpp.jid.EntityBareJid) Jid(org.jxmpp.jid.Jid) EntityJid(org.jxmpp.jid.EntityJid)

Example 4 with EntityJid

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());
}
Also used : EntityJid(org.jxmpp.jid.EntityJid)

Aggregations

EntityJid (org.jxmpp.jid.EntityJid)4 EntityBareJid (org.jxmpp.jid.EntityBareJid)3 Jid (org.jxmpp.jid.Jid)2 EntityFullJid (org.jxmpp.jid.EntityFullJid)1