当前位置: 首页>>代码示例>>Java>>正文


Java Roster.getGroup方法代码示例

本文整理汇总了Java中org.jivesoftware.smack.Roster.getGroup方法的典型用法代码示例。如果您正苦于以下问题:Java Roster.getGroup方法的具体用法?Java Roster.getGroup怎么用?Java Roster.getGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.smack.Roster的用法示例。


在下文中一共展示了Roster.getGroup方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addUserToGroup

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * 添加到分组
 *
 * @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));
        }
    }

}
 
开发者ID:jiangzehui,项目名称:xmpp,代码行数:24,代码来源:XmppTool.java

示例2: getEntrysByGroup

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * 获取某一个分组的成员
 *
 * @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;

}
 
开发者ID:jiangzehui,项目名称:xmpp,代码行数:26,代码来源:XmppTool.java

示例3: removeContactFromGroup

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:28,代码来源:ContactList.java

示例4: TransferGroupUI

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:18,代码来源:TransferGroupUI.java

示例5: getRosterEntrysForGroup

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * 获取某个分组下的所有好友
 * @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());
}
 
开发者ID:FanHuaRan,项目名称:SmackStudy,代码行数:15,代码来源:XMPPUtil.java

示例6: getEntriesByGroup

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * 返回相应(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;
}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:15,代码来源:XmppUtil.java

示例7: getDeviceNamesOnline

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:40,代码来源:PresenceManager.java

示例8: addUserToGroup

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * ��ӵ�����
 * 
 * @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));
	}
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:20,代码来源:XmppConnectionManager.java

示例9: doRemoveContactFromListAsync

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
@Override
protected void doRemoveContactFromListAsync(Contact contact, ContactList list) {
    // FIXME synchronize this to executor thread
    if (mConnection == null)
        return;
    Roster roster = mConnection.getRoster();
    String address = contact.getAddress().getAddress();
    try {
        RosterGroup group = roster.getGroup(list.getName());
        if (group == null) {
            debug(TAG, "could not find group " + list.getName() + " in roster");
            return;
        }
        RosterEntry entry = roster.getEntry(address);
        if (entry == null) {
            debug(TAG, "could not find entry " + address + " in group " + list.getName());
            //just ignore it then
        }
        else
        {
            // Remove from Roster if this is the last group
            if (entry.getGroups().size() <= 1)
                roster.removeEntry(entry);
    
            group.removeEntry(entry);
        }
    } catch (XMPPException e) {
        debug(TAG, "remove entry failed: " + e.getMessage());
        throw new RuntimeException(e);
    }
    
    //otherwise, send unsub message and delete from local contact database
    org.jivesoftware.smack.packet.Presence response = new org.jivesoftware.smack.packet.Presence(
            org.jivesoftware.smack.packet.Presence.Type.unsubscribed);
    response.setTo(address);
    sendPacket(response);
    notifyContactListUpdated(list, ContactListListener.LIST_CONTACT_REMOVED, contact);
}
 
开发者ID:prive,项目名称:prive-android,代码行数:39,代码来源:XmppConnection.java

示例10: addEntry

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * Adds a new entry to the users Roster.
 *
 * @param jid      the jid.
 * @param nickname the nickname.
 * @param group    the contact group.
 * @return the new RosterEntry.
 */
public RosterEntry addEntry(String jid, String nickname, String group) {
    String[] groups = {group};

    Roster roster = SparkManager.getConnection().getRoster();
    RosterEntry userEntry = roster.getEntry(jid);

    boolean isSubscribed = true;
    if (userEntry != null) {
        isSubscribed = userEntry.getGroups().size() == 0;
    }

    if (isSubscribed) {
        try {
            roster.createEntry(jid, nickname, new String[]{group});
        }
        catch (XMPPException e) {
            Log.error("Unable to add new entry " + jid, e);
        }
        return roster.getEntry(jid);
    }


    try {
        RosterGroup rosterGroup = roster.getGroup(group);
        if (rosterGroup == null) {
            rosterGroup = roster.createGroup(group);
        }

        if (userEntry == null) {
            roster.createEntry(jid, nickname, groups);
            userEntry = roster.getEntry(jid);
        }
        else {
            userEntry.setName(nickname);
            rosterGroup.addEntry(userEntry);
        }

        userEntry = roster.getEntry(jid);
    }
    catch (XMPPException ex) {
        Log.error(ex);
    }
    return userEntry;
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:53,代码来源:SubscriptionDialog.java

示例11: getEntrysByGroup

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * ��ȡijһ������ij�Ա
 * 
 * @param roster
 * @param groupName
 * @return
 */
public List<RosterEntry> getEntrysByGroup(Roster roster, String groupName) {
	List<RosterEntry> list = new ArrayList<RosterEntry>();
	RosterGroup group = roster.getGroup(groupName);
	list.addAll(group.getEntries());
	return list;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:14,代码来源:XmppConnectionManager.java


注:本文中的org.jivesoftware.smack.Roster.getGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。