/** * Returns the key to use in the presenceMap for a fully qualified xmpp ID. The roster * can contain any valid address format such us "domain/resource", "user@domain" or * "user@domain/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 fully qualified xmpp ID, e.g. jdoe@example.com/Work. * @return the key to use in the presenceMap for the fully qualified xmpp ID. */ private String getPresenceMapKey(String user) { if (user == null) { return null; } String key = user; if (!contains(user)) { key = StringUtils.parseBareAddress(user); } return key.toLowerCase(); }
/** * Returns the key to use in the presenceMap for a fully qualified XMPP ID. * The roster can contain any valid address format such us "domain/resource", * "user@domain" or "user@domain/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. jdoe@example.com or * jdoe@example.com/Work. * @return the key to use in the presenceMap for the fully qualified XMPP ID. */ private String getPresenceMapKey(String user) { if (user == null) { return null; } String key = user; if (!contains(user)) { key = StringUtils.parseBareAddress(user); } return key.toLowerCase(); }
/** * Returns the key to use in the presenceMap for a fully qualified XMPP ID. * The roster can contain any valid address format such us "domain/resource", * "user@domain" or "user@domain/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. jdoe@example.com or * jdoe@example.com/Work. * @return the key to use in the presenceMap for the fully qualified XMPP ID. */ private String getPresenceMapKey(String user) { if (user == null) { return null; } String key = user; if (!contains(user)) { key = StringUtils.parseBareAddress(user); } return key.toLowerCase(); }
/** * Returns the key to use in the presenceMap for a fully qualified XMPP ID. * The roster can contain any valid address format such us "domain/resource", * "user@domain" or "user@domain/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. jdoe@example.com or * jdoe@example.com/Work. * @return the key to use in the presenceMap for the fully qualified XMPP ID. */ private String getPresenceMapKey(String user) { if (user == null) { return null; } String key = user; if (!contains(user)) { key = StringUtils.parseBareAddress(user); } return key.toLowerCase(); }
public void addFriend(User usuario) { if (APDApplication.connection != null && APDApplication.connection.isConnected()) { try { Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual); Roster roster = Roster.getInstanceFor(APDApplication.connection); if (!roster.contains(usuario.getChatId())) { roster.createEntry(usuario.getChatId() + "@jabber/Smack", usuario.getName(), null); } else { logManager.error("Contacto ya existente en la libreta de direcciones"); } } catch (SmackException.NotLoggedInException e) { e.printStackTrace(); } catch (SmackException.NoResponseException e) { e.printStackTrace(); } catch (SmackException.NotConnectedException e) { e.printStackTrace(); } catch (XMPPException.XMPPErrorException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } }
public void processPacket(Packet packet) { if(packet instanceof Presence){ Presence presence = (Presence)packet; if(entityJID.equals(presence.getFrom()) && roster.contains(presence.getFrom()) && presence.getType().equals(Presence.Type.subscribe)){ Presence response = new Presence(Presence.Type.subscribed); response.setTo(presence.getFrom()); response.setFrom(StringUtils.parseBareAddress(connection.getUser())); connection.sendPacket(response); } } } }