use of org.jivesoftware.smack.roster.RosterEntry in project xabber-android by redsolution.
the class RosterManager method removeGroup.
/**
* Requests to remove group from all contacts in account.
*/
public void removeGroup(String account, String groupName) throws NetworkException {
final Roster roster = getRoster(account);
if (roster == null) {
return;
}
final org.jivesoftware.smack.roster.RosterGroup group = roster.getGroup(groupName);
if (group == null) {
return;
}
Application.getInstance().runInBackground(new Runnable() {
@Override
public void run() {
for (RosterEntry entry : group.getEntries()) {
try {
group.removeEntry(entry);
} catch (SmackException.NoResponseException e) {
Application.getInstance().onError(R.string.CONNECTION_FAILED);
} catch (SmackException.NotConnectedException e) {
Application.getInstance().onError(R.string.NOT_CONNECTED);
} catch (XMPPException.XMPPErrorException e) {
Application.getInstance().onError(R.string.XMPP_EXCEPTION);
}
}
}
});
}
use of org.jivesoftware.smack.roster.RosterEntry in project xabber-android by redsolution.
the class RosterManager method getRosterContact.
/**
* @param account
* @param user
* @return <code>null</code> can be returned.
*/
public RosterContact getRosterContact(String account, String user) {
final Roster roster = getRoster(account);
if (roster == null) {
return null;
}
final RosterEntry entry = roster.getEntry(user);
if (entry == null) {
return null;
} else {
return convertRosterEntryToRosterContact(account, roster, entry);
}
}
use of org.jivesoftware.smack.roster.RosterEntry in project xabber-android by redsolution.
the class RosterManager method setGroups.
public void setGroups(String account, String bareAddress, Collection<String> groups) throws NetworkException {
final Roster roster = getRoster(account);
if (roster == null) {
return;
}
final RosterEntry entry = roster.getEntry(bareAddress);
if (entry == null) {
return;
}
RosterPacket packet = new RosterPacket();
packet.setType(IQ.Type.set);
RosterPacket.Item item = new RosterPacket.Item(bareAddress, entry.getName());
for (String group : groups) {
item.addGroupName(group);
}
packet.addRosterItem(item);
ConnectionManager.getInstance().sendStanza(account, packet);
}
Aggregations