本文整理汇总了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);
}
示例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);
}
示例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();
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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!");
}
}