当前位置: 首页>>代码示例>>Java>>正文


Java XmppStringUtils.parseBareJid方法代码示例

本文整理汇总了Java中org.jxmpp.util.XmppStringUtils.parseBareJid方法的典型用法代码示例。如果您正苦于以下问题:Java XmppStringUtils.parseBareJid方法的具体用法?Java XmppStringUtils.parseBareJid怎么用?Java XmppStringUtils.parseBareJid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jxmpp.util.XmppStringUtils的用法示例。


在下文中一共展示了XmppStringUtils.parseBareJid方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEntry

import org.jxmpp.util.XmppStringUtils; //导入方法依赖的package包/类
/**
 * Returns the roster entry associated with the given XMPP address or
 * <tt>null</tt> if the user is not an entry in the group.
 *
 * @param user the XMPP address of the user (eg "[email protected]").
 * @return the roster entry or <tt>null</tt> if it does not exist in the group.
 */
public RosterEntry getEntry(String user) {
    if (user == null) {
        return null;
    }
    // Roster entries never include a resource so remove the resource
    // if it's a part of the XMPP address.
    user = XmppStringUtils.parseBareJid(user);
    String userLowerCase = user.toLowerCase(Locale.US);
    synchronized (entries) {
        for (RosterEntry entry : entries) {
            if (entry.getUser().equals(userLowerCase)) {
                return entry;
            }
        }
    }
    return null;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:25,代码来源:RosterGroup.java

示例2: createRxMessage

import org.jxmpp.util.XmppStringUtils; //导入方法依赖的package包/类
public static XmppRxMessage createRxMessage(org.jivesoftware.smack.packet.Message xmppMessage){
    MessageContent content = new DefaultMessageContent(xmppMessage.getBody());
    Resource resource;

    if(xmppMessage.getType().equals(org.jivesoftware.smack.packet.Message.Type.groupchat)){
        resource =
                new DefaultResource(
                        XmppStringUtils.parseBareJid(xmppMessage.getFrom()),
                        XmppStringUtils.parseResource(xmppMessage.getFrom()),
                        Resource.Type.ROOM
                );
    }else{
        resource = new DefaultResource(xmppMessage.getFrom(),xmppMessage.getFrom(), Resource.Type.USER);
    }

    XmppRxMessage msg = new XmppRxMessage(resource,content);
    msg.setId(xmppMessage.getStanzaId());
    msg.setThread(xmppMessage.getThread());
    return msg;
}
 
开发者ID:midoricorp,项目名称:jabbot,代码行数:21,代码来源:MessageHelper.java

示例3: accept

import org.jxmpp.util.XmppStringUtils; //导入方法依赖的package包/类
public boolean accept(Stanza packet) {
    String from = packet.getFrom();
    if (from == null) {
        return address == null;
    }
    // Simplest form of NAMEPREP/STRINGPREP
    from = from.toLowerCase(Locale.US);
    if (matchBareJID) {
        from = XmppStringUtils.parseBareJid(from);
    }
    return from.equals(address);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:13,代码来源:FromMatchesFilter.java

示例4: userHasLogged

import org.jxmpp.util.XmppStringUtils; //导入方法依赖的package包/类
public void userHasLogged(String user) {
    boolean isAnonymous = "".equals(XmppStringUtils.parseLocalpart(user));
    String title =
        "Smack Debug Window -- "
            + (isAnonymous ? "" : XmppStringUtils.parseBareJid(user))
            + "@"
            + connection.getServiceName()
            + ":"
            + connection.getPort();
    title += "/" + XmppStringUtils.parseResource(user);
    frame.setTitle(title);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:13,代码来源:LiteDebugger.java

示例5: handleIQRequest

import org.jxmpp.util.XmppStringUtils; //导入方法依赖的package包/类
@Override
public IQ handleIQRequest(IQ iqRequest) {
    final XMPPConnection connection = connection();
    RosterPacket rosterPacket = (RosterPacket) iqRequest;

    // Roster push (RFC 6121, 2.1.6)
    // A roster push with a non-empty from not matching our address MUST be ignored
    String jid = XmppStringUtils.parseBareJid(connection.getUser());
    String from = rosterPacket.getFrom();
    if (from != null && !from.equals(jid)) {
        LOGGER.warning("Ignoring roster push with a non matching 'from' ourJid='" + jid + "' from='" + from
                        + "'");
        return IQ.createErrorResponse(iqRequest, new XMPPError(Condition.service_unavailable));
    }

    // A roster push must contain exactly one entry
    Collection<Item> items = rosterPacket.getRosterItems();
    if (items.size() != 1) {
        LOGGER.warning("Ignoring roster push with not exaclty one entry. size=" + items.size());
        return IQ.createErrorResponse(iqRequest, new XMPPError(Condition.bad_request));
    }

    Collection<String> addedEntries = new ArrayList<String>();
    Collection<String> updatedEntries = new ArrayList<String>();
    Collection<String> deletedEntries = new ArrayList<String>();
    Collection<String> unchangedEntries = new ArrayList<String>();

    // We assured above that the size of items is exaclty 1, therefore we are able to
    // safely retrieve this single item here.
    Item item = items.iterator().next();
    RosterEntry entry = new RosterEntry(item.getUser(), item.getName(),
                    item.getItemType(), item.getItemStatus(), Roster.this, connection);
    String version = rosterPacket.getVersion();

    if (item.getItemType().equals(RosterPacket.ItemType.remove)) {
        deleteEntry(deletedEntries, entry);
        if (rosterStore != null) {
            rosterStore.removeEntry(entry.getUser(), version);
        }
    }
    else if (hasValidSubscriptionType(item)) {
        addUpdateEntry(addedEntries, updatedEntries, unchangedEntries, item, entry);
        if (rosterStore != null) {
            rosterStore.addEntry(item, version);
        }
    }

    removeEmptyGroups();

    // Fire event for roster listeners.
    fireRosterChangedEvent(addedEntries, updatedEntries, deletedEntries);

    return IQ.createResultIQ(rosterPacket);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:55,代码来源:Roster.java

示例6: getSender

import org.jxmpp.util.XmppStringUtils; //导入方法依赖的package包/类
public String getSender(boolean generic) {
    return generic && XmppStringUtils.isFullJID(mSender) ?
        XmppStringUtils.parseBareJid(mSender) : mSender;
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:5,代码来源:CompositeMessage.java

示例7: onPresence

import org.jxmpp.util.XmppStringUtils; //导入方法依赖的package包/类
@Override
protected void onPresence(String jid, Presence.Type type, boolean removed, Presence.Mode mode, String fingerprint) {
    Context context = getContext();
    if (context == null)
        return;

    if (Log.isDebug()) {
        Log.d(TAG, "group member presence from " + jid + " (type=" + type + ", fingerprint=" + fingerprint + ")");
    }

    // handle null type - meaning no subscription (warn user)
    if (type == null) {
        // some users are missing subscription - disable sending
        // FIXME a toast isn't the right way to warn about this (discussion going on in #179)
        Toast.makeText(context,
            "You can't chat with some of the group members because you haven't been authorized yet. Open a private chat with unknown users first.",
            Toast.LENGTH_LONG).show();
        mComposer.setSendEnabled(false);
    }

    else if (type == Presence.Type.available || type == Presence.Type.unavailable) {
        // no encryption - pointless to verify keys
        if (!Preferences.getEncryptionEnabled(context))
            return;

        String bareJid = XmppStringUtils.parseBareJid(jid);

        Contact contact = Contact.findByUserId(context, bareJid);
        if (contact != null) {
            // if this is null, we are accepting the key for the first time
            PGPPublicKeyRing trustedPublicKey = contact.getTrustedPublicKeyRing();

            // request the key if we don't have a trusted one and of course if the user has a key
            boolean unknownKey = (trustedPublicKey == null && contact.getFingerprint() != null);
            boolean changedKey = false;
            // check if fingerprint changed
            if (trustedPublicKey != null && fingerprint != null) {
                String oldFingerprint = PGP.getFingerprint(PGP.getMasterKey(trustedPublicKey));
                if (!fingerprint.equalsIgnoreCase(oldFingerprint)) {
                    // fingerprint has changed since last time
                    changedKey = true;
                }
            }

            if (changedKey || unknownKey) {
                showKeyWarning();
            }
        }
    }
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:51,代码来源:GroupMessageFragment.java

示例8: getMapKey

import org.jxmpp.util.XmppStringUtils; //导入方法依赖的package包/类
/**
 * Returns the key to use in the presenceMap and entries Map for a fully qualified XMPP ID.
 * The roster can contain any valid address format such us "domain/resource",
 * "[email protected]" or "[email protected]/resource". If the roster contains an entry
 * associated with the fully qualified XMPP ID then use the fully qualified XMPP
 * ID as the key in presenceMap, otherwise use the bare address. Note: When the
 * key in presenceMap is a fully qualified XMPP ID, the userPresences is useless
 * since it will always contain one entry for the user.
 *
 * @param user the bare or fully qualified XMPP ID, e.g. [email protected] or
 *             [email protected]/Work.
 * @return the key to use in the presenceMap and entries Map for the fully qualified XMPP ID.
 */
private String getMapKey(String user) {
    if (user == null) {
        return null;
    }
    if (entries.containsKey(user)) {
        return user;
    }
    String key = XmppStringUtils.parseBareJid(user);
    return key.toLowerCase(Locale.US);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:24,代码来源:Roster.java

示例9: createBare

import org.jxmpp.util.XmppStringUtils; //导入方法依赖的package包/类
/**
 * Creates a filter matching on the "from" field. Compares the bare version of from and filter
 * address.
 *
 * @param address The address to filter for. If <code>null</code> is given, the stanza(/packet) must not
 *        have a from address.
 */
public static FromMatchesFilter createBare(String address) {
    address = (address == null) ? null : XmppStringUtils.parseBareJid(address);
    return new FromMatchesFilter(address, true);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:FromMatchesFilter.java


注:本文中的org.jxmpp.util.XmppStringUtils.parseBareJid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。