Presence response = new Presence.Type.subscribed); response.setTo(address); sendPacket(response); Roster roster = mConnection.getRoster(); roster.createEntry(address, name, groups);
protected void doAddContactToListAsync(String address, String name, ContactList list) throws ImException { debug(TAG, "add contact to " + list.getName()); Presence response = new Presence.Type.subscribed); response.setTo(address); sendPacket(response); Roster roster = mConnection.getRoster(); String[] groups = new String[] { list.getName() }; if (name == null) { name = parseAddressName(address); } try { // final String name = parseAddressName(address); // Log.v(tag, msg) roster.createEntry(address, name, groups); // If contact exists locally, don't create another copy Contact contact = makeContact(name, address); if (!containsContact(contact)) notifyContactListUpdated(list, ContactListListener.LIST_CONTACT_ADDED, contact); else debug(TAG, "skip adding existing contact locally " + name); } catch (XMPPException e) { throw new RuntimeException(e); } }
//Setting up connection ConnectionConfiguration config = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com"); connection = new XMPPConnection(config); connection.connect(); //login connection.login(userName, password); //get your roster Roster roster = connection.getRoster(); //add a new roster entry aka SEND INVITATION roster.createEntry(address, name, groups);
/** * @param user * @param name */ public void createEntry(String user, String name) throws Exception { LOGGER.fine(String.format("Creating entry for buddy '%1$s' with name %2$s", user, name)); Roster roster = connection.getRoster(); roster.createEntry(user, name, null); }
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(); } } }
roster.createEntry("ravi", "ravi", urlArray); Collection<RosterEntry> entries = roster.getEntries();
connection .getRoster() .createEntry( StringUtils.parseBareAddress(userId), name,
@Override public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception { Action action = Action.valueOf(sampler.getPropertyAsString(ACTION, Action.get_roster.toString())); Roster roster = sampler.getXMPPConnection().getRoster(); String entry = sampler.getPropertyAsString(ENTRY); res.setSamplerData(action.toString() + ": " + entry); if (action == Action.get_roster) { res.setResponseData(rosterToString(roster).getBytes()); } else if (action == Action.add_item) { roster.createEntry(entry, entry, new String[0]); } else if (action == Action.delete_item) { RosterEntry rosterEntry = roster.getEntry(entry); if (rosterEntry != null) { roster.removeEntry(rosterEntry); } } return res; }
roster.createEntry(entityJID, getIdentity().getName(), new String[]{});