Java 类org.jivesoftware.smack.RosterGroup 实例源码

项目:xmpp    文件:FriendFragment.java   
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    GroupHolder holder;
    if (convertView == null) {
        holder = new GroupHolder();
        convertView = LayoutInflater.from(getActivity()).inflate(R.layout.friend_group_layout, parent, false);
        holder.tv = (TextView) convertView.findViewById(R.id.textView);
        holder.iv = (ImageView) convertView.findViewById(R.id.imageView);
        convertView.setTag(holder);

    } else {
        holder = (GroupHolder) convertView.getTag();
    }

    if (isExpanded) {
        holder.iv.setImageResource(R.mipmap.friend_group_point_xia);
    } else {
        holder.iv.setImageResource(R.mipmap.friend_group_point);
    }
    RosterGroup group = (RosterGroup) getGroup(groupPosition);
    holder.tv.setText(group.getName() + "[" + childs.get(groups.get(groupPosition)).size() + "]");


    return convertView;

}
项目:xmpp    文件:XmppTool.java   
/**
 * 添加到分组
 *
 * @param
 * @param userName
 * @param groupName
 */
public void addUserToGroup(String userName, String groupName) {
    Roster roster = con.getRoster();
    RosterGroup group = roster.getGroup(groupName);
    if (null == group) {
        group = roster.createGroup(groupName);
    }
    RosterEntry entry = roster.getEntry(userName);
    if (entry != null) {
        try {
            group.addEntry(entry);
        } catch (XMPPException e) {
            SLog.e(tag, Log.getStackTraceString(e));
        }
    }

}
项目:xmpp    文件:XmppTool.java   
/**
 * 获取某一个分组的成员
 *
 * @param
 * @param groupName
 * @return
 */
public List<RosterEntry> getEntrysByGroup(String groupName) {

    Roster roster = getCon().getRoster();
    List<RosterEntry> list = new ArrayList<RosterEntry>();
    RosterGroup group = roster.getGroup(groupName);
    Collection<RosterEntry> rosterEntiry = group.getEntries();
    Iterator<RosterEntry> iter = rosterEntiry.iterator();
    while (iter.hasNext()) {
        RosterEntry entry = iter.next();
        SLog.i("xmpptool", entry.getUser() + "\t" + entry.getName() + entry.getType().toString());
        if (entry.getType().toString().equals("both")) {
            list.add(entry);
        }

    }
    return list;

}
项目:AyoSunny    文件:ConstactFragment.java   
public void findFriends() {
    try {
        listGroup=new ArrayList<Group>();
        XMPPConnection conn = QQApplication.xmppConnection;
        Roster roster = conn.getRoster();
        Collection<RosterGroup> groups = roster.getGroups();
        for (RosterGroup group : groups) {
            Group mygroup=new Group();
            mygroup.setGroupName(group.getName());
            Collection<RosterEntry> entries = group.getEntries();
            List<Child> childList=new ArrayList<Child>();
            for (RosterEntry entry : entries) {
                if(entry.getType().name().equals("both")){
                    Child child=new Child();
                    child.setUsername(entry.getUser().split("@")[0]);
                    childList.add(child);
                }
            }
            mygroup.setChildList(childList);
            listGroup.add(mygroup);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:AyoSunny    文件:XmppUtil.java   
/**
 * 把一个好友添加到一个组中
 * @param userJid
 * @param groupName
 */
public static void addUserToGroup(final String userJid, final String groupName,
        final XMPPConnection connection) {
            RosterGroup group = connection.getRoster().getGroup(groupName);
            // 这个组已经存在就添加到这个组,不存在创建一个组
            RosterEntry entry = connection.getRoster().getEntry(userJid);
            try {
                if (group != null) {
                    if (entry != null)
                        group.addEntry(entry);
                } else {
                    RosterGroup newGroup = connection.getRoster().createGroup("我的好友");
                    if (entry != null)
                        newGroup.addEntry(entry);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
}
项目:EIM    文件:RosterExchange.java   
/**
   * Adds a roster entry to the packet.
   *
   * @param rosterEntry a roster entry to add.
   */
  public void addRosterEntry(RosterEntry rosterEntry) {
// Obtain a String[] from the roster entry groups name 
List<String> groupNamesList = new ArrayList<String>();
String[] groupNames;
for (RosterGroup group : rosterEntry.getGroups()) {
    groupNamesList.add(group.getName());
}
groupNames = groupNamesList.toArray(new String[groupNamesList.size()]);

      // Create a new Entry based on the rosterEntry and add it to the packet
      RemoteRosterEntry remoteRosterEntry = new RemoteRosterEntry(rosterEntry.getUser(),
              rosterEntry.getName(), groupNames);

      addRosterEntry(remoteRosterEntry);
  }
项目:EIM    文件:ContacterManager.java   
/**
 * ������з�����ϵ��
 * 
 * @return
 */
public static List<MRosterGroup> getGroups(Roster roster) {
    if (contacters == null)
        throw new RuntimeException("contacters is null");

    List<MRosterGroup> groups = new ArrayList<ContacterManager.MRosterGroup>();
    groups.add(new MRosterGroup(Constant.ALL_FRIEND, getContacterList()));
    for (RosterGroup group : roster.getGroups()) {
        List<User> groupUsers = new ArrayList<User>();
        for (RosterEntry entry : group.getEntries()) {
            groupUsers.add(contacters.get(entry.getUser()));
        }
        groups.add(new MRosterGroup(group.getName(), groupUsers));
    }
    groups.add(new MRosterGroup(Constant.NO_GROUP_FRIEND,
            getNoGroupUserList(roster)));
    return groups;
}
项目:EIM    文件:ContacterManager.java   
/**
 * ��һ�����Ѵ�����ɾ��
 * 
 * @param user
 * @param groupName
 */
public static void removeUserFromGroup(final User user,
        final String groupName, final XMPPConnection connection) {
    if (groupName == null || user == null)
        return;
    new Thread() {
        public void run() {
            RosterGroup group = connection.getRoster().getGroup(groupName);
            if (group != null) {
                try {
                    System.out.println(user.getJID() + "----------------");
                    RosterEntry entry = connection.getRoster().getEntry(
                            user.getJID());
                    if (entry != null)
                        group.removeEntry(entry);
                } catch (XMPPException e) {
                    e.printStackTrace();
                }
            }
        }
    }.start();
}
项目:EIM    文件:ContacterManager.java   
/**
 * ��ӷ��� .
 * 
 * @param user
 * @param groupName
 * @param connection
 */
public static void addGroup(final String groupName,
        final XMPPConnection connection) {
    if (StringUtil.empty(groupName)) {
        return;
    }

    // ��һ��rosterEntry��ӵ�group����PacketCollector���������߳�
    new Thread() {
        public void run() {

            try {
                RosterGroup g = connection.getRoster().getGroup(groupName);
                if (g != null) {
                    return;
                }
                connection.getRoster().createGroup(groupName);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }.start();
}
项目:androidPN-client.    文件:RosterExchange.java   
/**
   * Adds a roster entry to the packet.
   *
   * @param rosterEntry a roster entry to add.
   */
  public void addRosterEntry(RosterEntry rosterEntry) {
// Obtain a String[] from the roster entry groups name 
List<String> groupNamesList = new ArrayList<String>();
String[] groupNames;
for (RosterGroup group : rosterEntry.getGroups()) {
    groupNamesList.add(group.getName());
}
groupNames = groupNamesList.toArray(new String[groupNamesList.size()]);

      // Create a new Entry based on the rosterEntry and add it to the packet
      RemoteRosterEntry remoteRosterEntry = new RemoteRosterEntry(rosterEntry.getUser(),
              rosterEntry.getName(), groupNames);

      addRosterEntry(remoteRosterEntry);
  }
项目:XmppTest    文件:SmackImpl.java   
private void tryToMoveRosterEntryToGroup(String userName, String groupName)
        throws XXException {

    mRoster = mXMPPConnection.getRoster();
    RosterGroup rosterGroup = getRosterGroup(groupName);
    RosterEntry rosterEntry = mRoster.getEntry(userName);

    removeRosterEntryFromGroups(rosterEntry);

    if (groupName.length() == 0)
        return;
    else {
        try {
            rosterGroup.addEntry(rosterEntry);
        } catch (XMPPException e) {
            throw new XXException(e.getLocalizedMessage());
        }
    }
}
项目:olat    文件:InstantMessagingClient.java   
/**
 * Used by Velocity renderer
 * 
 * @param groupname
 * @return a String representing the online buddies out of the number of total buddies for a single group like (3/5)
 */
protected String buddyCountOnlineForGroup(final String groupname) {
    final RosterGroup rosterGroup = connection.getRoster().getGroup(groupname);
    int buddyEntries = rosterGroup.getEntryCount();
    final int allBuddies = buddyEntries;
    for (final Iterator I = rosterGroup.getEntries().iterator(); I.hasNext();) {
        final RosterEntry entry = (RosterEntry) I.next();
        final Presence presence = connection.getRoster().getPresence(entry.getUser());
        if (presence.getType() == Presence.Type.unavailable) {
            buddyEntries--;
        }
    }
    // final string looks like e.g. "(3/5)"
    final StringBuilder sb = new StringBuilder(10);
    sb.append("(");
    sb.append(buddyEntries);
    sb.append("/");
    sb.append(allBuddies);
    sb.append(")");
    return sb.toString();
}
项目:olat    文件:InstantMessagingClient.java   
/**
 * Used by Velocity renderer
 * 
 * @param groupname
 * @return a String representing the online buddies out of the number of total buddies for a single group like (3/5)
 */
protected String buddyCountOnlineForGroup(final String groupname) {
    final RosterGroup rosterGroup = connection.getRoster().getGroup(groupname);
    int buddyEntries = rosterGroup.getEntryCount();
    final int allBuddies = buddyEntries;
    for (final Iterator I = rosterGroup.getEntries().iterator(); I.hasNext();) {
        final RosterEntry entry = (RosterEntry) I.next();
        final Presence presence = connection.getRoster().getPresence(entry.getUser());
        if (presence.getType() == Presence.Type.unavailable) {
            buddyEntries--;
        }
    }
    // final string looks like e.g. "(3/5)"
    final StringBuilder sb = new StringBuilder(10);
    sb.append("(");
    sb.append(buddyEntries);
    sb.append("/");
    sb.append(allBuddies);
    sb.append(")");
    return sb.toString();
}
项目:androidsummary    文件:IMUtil.java   
/**
 * 获得花名册包含的分组列表
 */
public static List<IMRosterGroup> getRosterGroups(Roster roster) {

    List<IMRosterGroup> groups = new ArrayList<IMRosterGroup>();
    groups.add(new IMRosterGroup(IMConstant.ALL_FRIEND, getContacterList()));
    for (RosterGroup group : roster.getGroups()) {
        List<IMUser> users = new ArrayList<IMUser>();
        for (RosterEntry entry : group.getEntries()) {
            users.add(contacters.get(entry.getUser()));
        }
        groups.add(new IMRosterGroup(group.getName(), users));
    }
    groups.add(new IMRosterGroup(IMConstant.NO_GROUP_FRIEND,
            getNoGroupUserList(roster)));
    return groups;
}
项目:xmppsupport_v2    文件:RosterExchange.java   
/**
 * Adds a roster entry to the packet.
 * 
 * @param rosterEntry
 *            a roster entry to add.
 */
public void addRosterEntry(RosterEntry rosterEntry) {
    // Obtain a String[] from the roster entry groups name
    List<String> groupNamesList = new ArrayList<String>();
    String[] groupNames;
    for (RosterGroup group : rosterEntry.getGroups()) {
        groupNamesList.add(group.getName());
    }
    groupNames = groupNamesList.toArray(new String[groupNamesList.size()]);

    // Create a new Entry based on the rosterEntry and add it to the packet
    RemoteRosterEntry remoteRosterEntry = new RemoteRosterEntry(
            rosterEntry.getUser(), rosterEntry.getName(), groupNames);

    addRosterEntry(remoteRosterEntry);
}
项目:smartedu    文件:SmackImpl.java   
private void tryToMoveRosterEntryToGroup(String userName, String groupName)
        throws AppException {

    mRoster = mXMPPConnection.getRoster();
    RosterGroup rosterGroup = getRosterGroup(groupName);
    RosterEntry rosterEntry = mRoster.getEntry(userName);

    removeRosterEntryFromGroups(rosterEntry);

    if (groupName.length() == 0)
        return;
    else {
        try {
            rosterGroup.addEntry(rosterEntry);
        } catch (XMPPException e) {
            throw new AppException(e.getLocalizedMessage());
        }
    }
}
项目:LoLMessenger    文件:ParcelableRoster.java   
public ParcelableRoster(RosterEntry entry, Presence presence) {

        if(entry != null) {
            // entry data 파싱
            this.userID = entry.getUser();
            this.userName = entry.getName();
            for(RosterGroup rosterGroup : entry.getGroups()) { this.group = rosterGroup.getName(); }
        }

        if(presence != null) {
            // 접속상태 확인
            this.availablity = presence.getType().toString();
            if(availablity.equals("available")) parseStatusString( presence.getStatus() );
            if(presence.getMode() != null) this.mode = presence.getMode().toString();
        }
    }
项目:aceim    文件:XMPPRosterListener.java   
void renameGroup(final BuddyGroup buddyGroup) {
    new Thread() {

        @Override
        public void run() {
            try {
                RosterGroup rgroup = getInternalService().getService().getEntityAdapter().buddyGroup2RosterEntry(getInternalService().getConnection(), buddyGroup);

                for (RosterEntry entry : rgroup.getEntries()) {
                    getInternalService().getConnection().getRoster().createEntry(entry.getUser(), entry.getName(), new String[] { buddyGroup.getName() });
                }

                getInternalService().getService().getCoreService().groupAction(ItemAction.MODIFIED, buddyGroup);
            } catch (Exception e) {
                Logger.log(e);
                getInternalService().getService().getCoreService().notification( e.getLocalizedMessage());
            }
        }
    }.start();
}
项目:aceim    文件:XMPPEntityAdapter.java   
public List<BuddyGroup> rosterGroupCollection2BuddyGroupList(Collection<RosterGroup> entries, Collection<RosterEntry> buddies, String ownerUid, Context context, byte serviceId){
    if (entries == null){
        return null;
    }

    List<RosterEntry> list = new ArrayList<RosterEntry>(buddies);

    List<BuddyGroup> groups = new ArrayList<BuddyGroup>(entries.size());
    for (RosterGroup entry: entries){
        groups.add(rosterGroup2BuddyGroup(entry, list, ownerUid, context, serviceId));
    }

    BuddyGroup noGroup = new BuddyGroup(ApiConstants.NO_GROUP_ID, ownerUid, serviceId);
    for (RosterEntry buddyWithNoGroup : list) {
        noGroup.getBuddyList().add(rosterEntry2Buddy(buddyWithNoGroup, ownerUid, context, serviceId));
    }
    groups.add(noGroup);

    return groups;
}
项目:aceim    文件:XMPPCryptoEntityAdapter.java   
@Override
public List<BuddyGroup> rosterGroupCollection2BuddyGroupList(Collection<RosterGroup> entries, Collection<RosterEntry> buddies, String ownerUid, Context context, byte serviceId){
    if (entries == null){
        return null;
    }

    List<RosterEntry> list = new ArrayList<RosterEntry>(buddies);

    List<BuddyGroup> groups = new ArrayList<BuddyGroup>(entries.size());
    for (RosterGroup entry: entries){
        groups.add(rosterGroup2BuddyGroup(entry, list, ownerUid, context, serviceId));
    }

    BuddyGroup noGroup = new BuddyGroup(ApiConstants.NO_GROUP_ID, ownerUid, serviceId);
    for (RosterEntry buddyWithNoGroup : list) {
        noGroup.getBuddyList().add(rosterEntry2Buddy(buddyWithNoGroup, ownerUid, context, serviceId));
    }
    groups.add(noGroup);

    return groups;
}
项目:java-bells    文件:RosterExchange.java   
/**
   * Adds a roster entry to the packet.
   *
   * @param rosterEntry a roster entry to add.
   */
  public void addRosterEntry(RosterEntry rosterEntry) {
// Obtain a String[] from the roster entry groups name 
List<String> groupNamesList = new ArrayList<String>();
String[] groupNames;
for (RosterGroup group : rosterEntry.getGroups()) {
    groupNamesList.add(group.getName());
}
groupNames = groupNamesList.toArray(new String[groupNamesList.size()]);

      // Create a new Entry based on the rosterEntry and add it to the packet
      RemoteRosterEntry remoteRosterEntry = new RemoteRosterEntry(rosterEntry.getUser(),
              rosterEntry.getName(), groupNames);

      addRosterEntry(remoteRosterEntry);
  }
项目:maven-yaxim    文件:SmackableImp.java   
private void tryToMoveRosterEntryToGroup(String userName, String groupName)
        throws YaximXMPPException {

    RosterGroup rosterGroup = getRosterGroup(groupName);
    RosterEntry rosterEntry = mRoster.getEntry(userName);

    removeRosterEntryFromGroups(rosterEntry);

    if (groupName.length() == 0)
        return;
    else {
        try {
            rosterGroup.addEntry(rosterEntry);
        } catch (XMPPException e) {
            throw new YaximXMPPException(e.getLocalizedMessage());
        }
    }
}
项目:telegraph    文件:RosterExchange.java   
/**
   * Adds a roster entry to the packet.
   *
   * @param rosterEntry a roster entry to add.
   */
  public void addRosterEntry(RosterEntry rosterEntry) {
// Obtain a String[] from the roster entry groups name 
List<String> groupNamesList = new ArrayList<String>();
String[] groupNames;
for (RosterGroup group : rosterEntry.getGroups()) {
    groupNamesList.add(group.getName());
}
groupNames = groupNamesList.toArray(new String[groupNamesList.size()]);

      // Create a new Entry based on the rosterEntry and add it to the packet
      RemoteRosterEntry remoteRosterEntry = new RemoteRosterEntry(rosterEntry.getUser(),
              rosterEntry.getName(), groupNames);

      addRosterEntry(remoteRosterEntry);
  }
项目:NewCommunication-Android    文件:RosterExchange.java   
/**
   * Adds a roster entry to the packet.
   *
   * @param rosterEntry a roster entry to add.
   */
  public void addRosterEntry(RosterEntry rosterEntry) {
// Obtain a String[] from the roster entry groups name 
List<String> groupNamesList = new ArrayList<String>();
String[] groupNames;
for (RosterGroup group : rosterEntry.getGroups()) {
    groupNamesList.add(group.getName());
}
groupNames = groupNamesList.toArray(new String[groupNamesList.size()]);

      // Create a new Entry based on the rosterEntry and add it to the packet
      RemoteRosterEntry remoteRosterEntry = new RemoteRosterEntry(rosterEntry.getUser(),
              rosterEntry.getName(), groupNames);

      addRosterEntry(remoteRosterEntry);
  }
项目:spark-svn-mirror    文件:ContactList.java   
/**
 * Removes a contact item from the group.
 *
 * @param item the ContactItem to remove.
 */
private void removeContactFromGroup(ContactItem item) {
    String groupName = item.getGroupName();
    ContactGroup contactGroup = getContactGroup(groupName);
    Roster roster = SparkManager.getConnection().getRoster();
    RosterEntry entry = roster.getEntry(item.getJID());
    if (entry != null && contactGroup != offlineGroup) {
        try {
            RosterGroup rosterGroup = roster.getGroup(groupName);
            if (rosterGroup != null) {
                RosterEntry rosterEntry = rosterGroup.getEntry(entry.getUser());
                if (rosterEntry != null) {
                    rosterGroup.removeEntry(rosterEntry);
                }
            }
            contactGroup.removeContactItem(contactGroup.getContactItemByJID(item.getJID()));
            checkGroup(contactGroup);
        }
        catch (Exception e) {
            Log.error("Error removing user from contact list.", e);
        }
    }
}
项目:spark-svn-mirror    文件:TransferGroupUI.java   
public TransferGroupUI(String groupName) {
    setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false));
    setBackground(Color.white);

    final Roster roster = SparkManager.getConnection().getRoster();
    final RosterGroup rosterGroup = roster.getGroup(groupName);

    final List<RosterEntry> entries = new ArrayList<RosterEntry>(rosterGroup.getEntries());

    Collections.sort(entries, entryComparator);

    for (RosterEntry entry : entries) {
        final UserEntry userEntry = new UserEntry(entry);
        userEntries.add(userEntry);
        add(userEntry);
    }
}
项目:SmackStudy    文件:XMPPUtil.java   
/**
 * 获取某个分组下的所有好友
 * @param xmppConnection
 * @param groupName
 * @return
 */
public static List<RosterEntry> getRosterEntrysForGroup(XMPPConnection xmppConnection,String groupName){
    // 获取花名册对象
    Roster roster = xmppConnection.getRoster();
    // 获取所有好友
    RosterGroup rosterGroup = roster.getGroup(groupName);
    Collection<RosterEntry> rosterEntries = rosterGroup.getEntries();
    return rosterEntries.stream().collect(Collectors.toList());
}
项目:SmackStudy    文件:XMPPUtilTest.java   
@Test
public void testGetAllRosterGroup() {
    XMPPConnection xmppConnection = providerConnection();
    assertTrue(XMPPUtil.login(xmppConnection, "ranrandemo", "admin123"));
    List<RosterGroup> rosterGroups=XMPPUtil.getAllRosterGroup(xmppConnection);
    assertNotNull(rosterGroups);
    assertTrue(rosterGroups.size()>0);
    XMPPUtil.relaseXMPPConnection(xmppConnection);
}
项目:SmackStudy    文件:XMPPUtil.java   
/**
 * 获取所有分组组合
 * @param xmppConnection
 * @return
 */
public static List<RosterGroup> getAllRosterGroup(XMPPConnection xmppConnection) {
    List<RosterGroup> rosterGroups = new ArrayList<>();
    Iterator<RosterGroup> i = xmppConnection.getRoster().getGroups().iterator();
    while (i.hasNext()) {
        rosterGroups.add(i.next());
    }
    return rosterGroups;
}
项目:SmackStudy    文件:XMPPUtil.java   
/**
 * 获取某个组里面的所有好友
 * @param xmppConnection
 * @param groupName      组名
 * @return
 */
public static List<RosterEntry> getRosterEntrysForGroup(XMPPConnection xmppConnection, String groupName) {
    List<RosterEntry> rosterEntries = new ArrayList<RosterEntry>();
    RosterGroup rosterGroup = xmppConnection.getRoster().getGroup(groupName);
    Collection<RosterEntry> rosterEntry = rosterGroup.getEntries();
    Iterator<RosterEntry> i = rosterEntry.iterator();
    while (i.hasNext()) {
        rosterEntries.add(i.next());
    }
    return rosterEntries;
}
项目:SmackStudy    文件:XMPPUtilTest.java   
@Test
public void testGetAllRosterGroup() {
    XMPPConnection xmppConnection = getFullXMPPConnection();
    assertTrue(XMPPUtil.login(xmppConnection, "ranrandemo", "admin123"));
    List<RosterGroup> rosterGroups=XMPPUtil.getAllRosterGroup(xmppConnection);
    assertNotNull(rosterGroups);
    assertTrue(rosterGroups.size()>0);
    XMPPUtil.relaseXMPPConnection(xmppConnection);
}
项目:xmpp    文件:XmppTool.java   
/**
 * 获取所有分组
 *
 * @param
 * @return
 */
public List<RosterGroup> getGroups() {
    Roster roster = getCon().getRoster();
    List<RosterGroup> list = new ArrayList<RosterGroup>();
    list.addAll(roster.getGroups());
    return list;
}
项目:AyoSunny    文件:XmppUtil.java   
/**
 * 返回所有组信息 <RosterGroup>
 * @return List(RosterGroup)
 */
public static List<RosterGroup> getGroups(Roster roster) {
    List<RosterGroup> groupsList = new ArrayList<RosterGroup>();
    Collection<RosterGroup> rosterGroup = roster.getGroups();
    Iterator<RosterGroup> i = rosterGroup.iterator();
    while (i.hasNext())
        groupsList.add(i.next());
    return groupsList;
}
项目:AyoSunny    文件:XmppUtil.java   
/**
 * 返回相应(groupName)组里的所有用户<RosterEntry>
 * @return List(RosterEntry)
 */
public static List<RosterEntry> getEntriesByGroup(Roster roster,
        String groupName) {
    List<RosterEntry> EntriesList = new ArrayList<RosterEntry>();
    RosterGroup rosterGroup = roster.getGroup(groupName);
    Collection<RosterEntry> rosterEntry = rosterGroup.getEntries();
    Iterator<RosterEntry> i = rosterEntry.iterator();
    while (i.hasNext())
        EntriesList.add(i.next());
    return EntriesList;
}
项目:AyoSunny    文件:XmppUtil.java   
/**
 * 把一个好友从组中删除
 * @param userJid
 * @param groupName
 */
public static void removeUserFromGroup(final String userJid,final String groupName, final XMPPConnection connection) {
        RosterGroup group = connection.getRoster().getGroup(groupName);
        if (group != null) {
            try {
                RosterEntry entry = connection.getRoster().getEntry(userJid);
                if (entry != null)
                    group.removeEntry(entry);
            } catch (XMPPException e) {
                e.printStackTrace();
            }
        }
 }
项目:synergynet3.1    文件:PresenceManager.java   
/**
 * Gets the device names online.
 *
 * @param deviceType
 *            the device type
 * @return the device names online
 */
public List<String> getDeviceNamesOnline(String deviceType)
{
    List<String> list = new ArrayList<String>();
    if (connection == null)
    {
        return list;
    }

    Roster roster = connection.getRoster();
    if (roster == null)
    {
        return list;
    }

    try
    {
        RosterGroup rg = roster.getGroup(deviceType);
        for (RosterEntry re : rg.getEntries())
        {
            Presence p = connection.getRoster().getPresence(re.getUser());
            if (p.isAvailable())
            {
                list.add(re.getName());
            }
        }
    }
    catch (NullPointerException e)
    {

    }
    return list;
}
项目:EIM    文件:RosterExchangeManager.java   
/**
 * Sends a roster group to userID. All the entries of the group will be sent to the 
 * target user.
 * 
 * @param rosterGroup the roster group to send
 * @param targetUserID the user that will receive the roster entries
 */
public void send(RosterGroup rosterGroup, String targetUserID) {
    // Create a new message to send the roster
    Message msg = new Message(targetUserID);
    // Create a RosterExchange Package and add it to the message
    RosterExchange rosterExchange = new RosterExchange();
    for (RosterEntry entry : rosterGroup.getEntries()) {
        rosterExchange.addRosterEntry(entry);
    }
    msg.addExtension(rosterExchange);

    // Send the message that contains the roster
    con.sendPacket(msg);
}
项目:EIM    文件:XmppConnectionManager.java   
/**
 * ��ӵ�����
 * 
 * @param roster
 * @param userName
 * @param groupName
 */
public void addUserToGroup(Roster roster, String userName, String groupName) {
    RosterGroup group = roster.getGroup(groupName);
    if (null == group) {
        group = roster.createGroup(groupName);
    }
    RosterEntry entry = roster.getEntry(userName);
    try {
        group.addEntry(entry);
    } catch (XMPPException e) {
        SLog.e(tag, Log.getStackTraceString(e));
    }
}
项目:EIM    文件:ContacterManager.java   
/**
 * ��һ��������ӵ�һ������
 * 
 * @param user
 * @param groupName
 */
public static void addUserToGroup(final User user, final String groupName,
        final XMPPConnection connection) {
    if (groupName == null || user == null)
        return;
    // ��һ��rosterEntry��ӵ�group����PacketCollector���������߳�
    new Thread() {
        public void run() {
            RosterGroup group = connection.getRoster().getGroup(groupName);
            // ������Ѿ����ھ���ӵ�����飬�����ڴ���һ����
            RosterEntry entry = connection.getRoster().getEntry(
                    user.getJID());
            try {
                if (group != null) {
                    if (entry != null)
                        group.addEntry(entry);
                } else {
                    RosterGroup newGroup = connection.getRoster()
                            .createGroup(groupName);
                    if (entry != null)
                        newGroup.addEntry(entry);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }.start();
}
项目:EIM    文件:ContacterManager.java   
/**
 * �����������
 * 
 * @return
 */
public static List<String> getGroupNames(Roster roster) {

    List<String> groupNames = new ArrayList<String>();
    for (RosterGroup group : roster.getGroups()) {
        groupNames.add(group.getName());
    }
    return groupNames;
}