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


Java BareJid类代码示例

本文整理汇总了Java中org.jxmpp.jid.BareJid的典型用法代码示例。如果您正苦于以下问题:Java BareJid类的具体用法?Java BareJid怎么用?Java BareJid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: removeContact

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
public void removeContact(String jidString)
        throws SmackException.NotLoggedInException, InterruptedException,
        SmackException.NotConnectedException, XMPPException.XMPPErrorException,
        SmackException.NoResponseException, XmppStringprepException {
    Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
    if (!roster.isLoaded()) {
        roster.reloadAndWait();
    }

    BareJid jid = JidCreate.bareFrom(jidString);
    roster.removeEntry(roster.getEntry(jid));

    Presence presence = new Presence(Presence.Type.unsubscribe);
    presence.setTo(JidCreate.from(jidString));
    XMPPSession.getInstance().sendStanza(presence);
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:17,代码来源:RosterManager.java

示例2: addContact

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
public void addContact(String jidString)
        throws SmackException.NotLoggedInException, InterruptedException,
        SmackException.NotConnectedException, XMPPException.XMPPErrorException,
        SmackException.NoResponseException, XmppStringprepException {
    Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
    if (!roster.isLoaded()) {
        roster.reloadAndWait();
    }

    BareJid jid = JidCreate.bareFrom(jidString);
    String name = XMPPUtils.fromJIDToUserName(jidString);
    String[] groups = new String[]{"Buddies"};

    roster.createEntry(jid, name, groups);
    roster.sendSubscriptionRequest(jid);
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:17,代码来源:RosterManager.java

示例3: removeAllRawSessionsOf

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
@Override
public void removeAllRawSessionsOf(OmemoManager omemoManager, BareJid contact) {
    File contactsDirectory = hierarchy.getContactsDir(omemoManager, contact);
    String[] devices = contactsDirectory.list();

    for (String deviceId : devices != null ? devices : new String[0]) {
        int id;
        try {
            id = Integer.parseInt(deviceId);
        } catch (NumberFormatException e) {
            continue;
        }
        OmemoDevice device = new OmemoDevice(contact, id);
        File session = hierarchy.getContactsSessionPath(omemoManager, device);
        session.delete();
    }
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:18,代码来源:IOCipherOmemoStore.java

示例4: initOMemoManager

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
private OmemoManager initOMemoManager(XMPPTCPConnection conn, BareJid altUser) {
    BareJid user;

    if (conn.getUser() != null) {
        user = conn.getUser().asBareJid();
    } else {
        user = altUser;
    }

    mOmemoStore = OmemoService.getInstance().getOmemoStoreBackend();
    int defaultDeviceId = mOmemoStore.getDefaultDeviceId(user);

    if (defaultDeviceId < 1) {
        defaultDeviceId = OmemoManager.randomDeviceId();
        mOmemoStore.setDefaultDeviceId(user, defaultDeviceId);
    }

    return OmemoManager.getInstanceFor(conn, defaultDeviceId);
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:20,代码来源:Omemo.java

示例5: broadcastPresence

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
private void broadcastPresence(Roster roster, RosterEntry entry, BareJid jid, String id) {
    // this method might be called async
    final LocalBroadcastManager lbm = mLocalBroadcastManager;
    if (lbm == null)
        return;

    Intent i;
    // entry present and not pending subscription
    if (isRosterEntrySubscribed(entry) || Authenticator.isSelfJID(this, jid)) {
        // roster entry found, look for presence
        Presence presence = roster.getPresence(jid);
        i = PresenceListener.createIntent(this, presence, entry);
    }
    else {
        // null type indicates no roster entry found or not authorized
        i = new Intent(ACTION_PRESENCE);
        i.putExtra(EXTRA_FROM, jid.toString());
    }

    // to keep track of request-reply
    i.putExtra(EXTRA_PACKET_ID, id);
    lbm.sendBroadcast(i);
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:24,代码来源:MessageCenterService.java

示例6: bareFrom

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
/**
 * Get a {@link BareJid} representing the given String.
 *
 * @param jid the input String.
 * @return a bare JID representing the given String.
 * @throws XmppStringprepException if an error occurs.
 */
public static BareJid bareFrom(String jid) throws XmppStringprepException {
	BareJid bareJid = BAREJID_CACHE.lookup(jid);
	if (bareJid != null) {
		return bareJid;
	}

	String localpart = XmppStringUtils.parseLocalpart(jid);
	String domainpart = XmppStringUtils.parseDomain(jid);
	try {
		if (localpart.length() != 0) {
			bareJid = new LocalAndDomainpartJid(localpart, domainpart);
		} else {
			bareJid = new DomainpartJid(domainpart);
		}
	} catch (XmppStringprepException e) {
		throw new XmppStringprepException(jid, e);
	}
	BAREJID_CACHE.put(jid, bareJid);
	return bareJid;
}
 
开发者ID:igniterealtime,项目名称:jxmpp,代码行数:28,代码来源:JidCreate.java

示例7: checkMasterJids

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
private void checkMasterJids() {
	boolean masterJidAvailable = false;
	for (BareJid jid : mSettings.getMasterJids()) {
		Presence presence = mRoster.getPresence(jid);
		if (presence.isAvailable()) {
			if (mSettings.isExcludedResource(presence.getFrom().getResourceOrNull())) {
				// Skip excluded resources
				continue;
			}
			masterJidAvailable = true;
			// we found at least one available master JID, break here
			break;
		}
	}

	if (mMasterJidAvailable == false && masterJidAvailable == true) {
		for (MasterJidListener listener : mMasterJidListeners)
			listener.masterJidAvailable();
	}

	mMasterJidAvailable = masterJidAvailable;
}
 
开发者ID:ProjectMAXS,项目名称:maxs,代码行数:23,代码来源:XMPPRoster.java

示例8: setJidPresenceGui

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
private void setJidPresenceGui(ImageView imageView, BareJid bareJid) {
	if (bareJid == null) return;

	Presence presence = roster.getPresence(bareJid);
	final Drawable drawable;
	if (presence != null && presence.isAvailable()) {
		drawable = mOnlineDrawable;
	} else {
		drawable = mOfflineDrawable;
	}
	imageView.setImageDrawable(drawable);
}
 
开发者ID:Flowdalic,项目名称:android-xmpp-iot-demo,代码行数:13,代码来源:XmppManager.java

示例9: getContacts

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
public HashMap<Jid, Presence.Type> getContacts()
        throws SmackException.NotLoggedInException, InterruptedException,
        SmackException.NotConnectedException {
    Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
    if (!roster.isLoaded()) {
        roster.reloadAndWait();
    }

    String groupName = "Buddies";

    RosterGroup group = roster.getGroup(groupName);

    if (group == null) {
        roster.createGroup(groupName);
        group = roster.getGroup(groupName);
    }

    HashMap<Jid, Presence.Type> buddies = new HashMap<>();

    List<RosterEntry> entries = group.getEntries();
    for (RosterEntry entry : entries) {
        BareJid jid = entry.getJid();
        Presence.Type status = roster.getPresence(jid).getType();
        buddies.put(jid, status);
    }

    return buddies;
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:29,代码来源:RosterManager.java

示例10: getContactsWithSubscriptionPending

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
public HashMap<Jid, Presence.Type> getContactsWithSubscriptionPending()
        throws SmackException.NotLoggedInException, InterruptedException,
        SmackException.NotConnectedException {
    Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection());
    if (!roster.isLoaded()) {
        roster.reloadAndWait();
    }

    String groupName = "Buddies";

    RosterGroup group = roster.getGroup(groupName);

    if (group == null) {
        roster.createGroup(groupName);
        group = roster.getGroup(groupName);
    }

    HashMap<Jid, Presence.Type> buddiesPending = new HashMap<>();

    List<RosterEntry> entries = group.getEntries();
    for (RosterEntry entry : entries) {
        if (entry.isSubscriptionPending()) {
            BareJid jid = entry.getJid();
            Presence.Type status = roster.getPresence(jid).getType();
            buddiesPending.put(jid, status);
        }
    }

    return buddiesPending;
}
 
开发者ID:esl,项目名称:mangosta-android,代码行数:31,代码来源:RosterManager.java

示例11: findOrCreateSession

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
private ChatSession findOrCreateSession(String address, boolean groupChat) {

        try {

            if (mConnection == null || (!mConnection.isConnected()))
                return null;

            ChatSession session = mSessionManager.findSession(JidCreate.bareFrom(address));
            BareJid bareJid = JidCreate.bareFrom(address);

            //create a session if this it not groupchat
            if (session == null && (!groupChat)) {
                ImEntity participant = findOrCreateParticipant(address, groupChat);

                if (participant != null) {
                    session = mSessionManager.createChatSession(participant, false);
                    mContactListManager.refreshPresence(address);

                    qAvatar.put(bareJid.toString(),"");

                    if (getOmemo().getManager().contactSupportsOmemo(bareJid)) {
                        getOmemo().getManager().requestDeviceListUpdateFor(bareJid);
                        getOmemo().getManager().buildSessionsWith(bareJid);
                    }


                }

            }


            return session;
        }
        catch (Exception e)
        {
            debug(ImApp.LOG_TAG,"error findOrCreateSession",e);
            return null;
        }
    }
 
开发者ID:zom,项目名称:Zom-Android,代码行数:40,代码来源:XmppConnection.java

示例12: getDefaultDeviceId

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
@Override
public int getDefaultDeviceId(BareJid user) {
    try {
        return readInt(hierarchy.getDefaultDeviceIdPath(user));
    } catch (IOException e) {
        return -1;
    }
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:9,代码来源:IOCipherOmemoStore.java

示例13: setDefaultDeviceId

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
@Override
public void setDefaultDeviceId(BareJid user, int defaultDeviceId) {
    File defaultDeviceIdPath = hierarchy.getDefaultDeviceIdPath(user);

    if (defaultDeviceIdPath == null) {
        LOGGER.log(Level.SEVERE, "defaultDeviceIdPath is null!");
    }

    try {
        writeInt(defaultDeviceIdPath, defaultDeviceId);
    } catch (IOException e) {
        LOGGER.log(Level.SEVERE, "Could not write defaultDeviceId: " + e, e);
    }
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:15,代码来源:IOCipherOmemoStore.java

示例14: getFingerprints

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
public ArrayList<String> getFingerprints (BareJid jid, boolean autoload) throws CorruptedOmemoKeyException, SmackException, XMPPException.XMPPErrorException, InterruptedException
{

    try {
        mOmemoManager.buildSessionsWith(jid);
    }
    catch (CannotEstablishOmemoSessionException e)
    {
        debug(TAG,"couldn't establish omemo session: " + e);
    }


    CachedDeviceList list = mOmemoStore.loadCachedDeviceList(mOmemoManager, jid);
    if(list == null) {
        list = new CachedDeviceList();
    }
    ArrayList<String> fps = new ArrayList<>();
    for(int id : list.getActiveDevices()) {
        OmemoDevice d = new OmemoDevice(jid, id);
        IdentityKey idk = (IdentityKey)mOmemoStore.loadOmemoIdentityKey(mOmemoManager, d);
        if(idk == null) {
            System.out.println("No identityKey for "+d);
        } else {
            fps.add(mOmemoStore.keyUtil().getFingerprint(idk).toString());
        }
    }

    return fps;
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:30,代码来源:Omemo.java

示例15: toBareSmack

import org.jxmpp.jid.BareJid; //导入依赖的package包/类
public BareJid toBareSmack() {
    try {
        return JidCreate.bareFrom(this.string());
    } catch (XmppStringprepException ex) {
        LOGGER.log(Level.WARNING, "could not convert to smack", ex);
        throw new RuntimeException("You didn't check isValid(), idiot!");
    }
}
 
开发者ID:kontalk,项目名称:desktopclient-java,代码行数:9,代码来源:JID.java


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