本文整理汇总了Java中org.jivesoftware.smack.RosterEntry类的典型用法代码示例。如果您正苦于以下问题:Java RosterEntry类的具体用法?Java RosterEntry怎么用?Java RosterEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RosterEntry类属于org.jivesoftware.smack包,在下文中一共展示了RosterEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: perform
import org.jivesoftware.smack.RosterEntry; //导入依赖的package包/类
@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;
}
示例2: removeUser
import org.jivesoftware.smack.RosterEntry; //导入依赖的package包/类
/**
* 删除好友
* @param xmppConnection
* @param userName
* @return
*/
public static boolean removeUser(XMPPConnection xmppConnection,String userName) {
try {
RosterEntry entry = null;
if (userName.contains("@")){
entry = xmppConnection.getRoster().getEntry(
userName + "@" + xmppConnection.getServiceName());
}else{
entry = xmppConnection.getRoster().getEntry(
userName + "@" + xmppConnection.getServiceName());
}
if (entry == null){
entry = xmppConnection.getRoster().getEntry(userName);
}
xmppConnection.getRoster().removeEntry(entry);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
示例3: removeUser
import org.jivesoftware.smack.RosterEntry; //导入依赖的package包/类
/**
* 删除好友
* @param xmppConnection
* @param userName
* @return
*/
public static boolean removeUser(XMPPConnection xmppConnection, String userName) {
try {
RosterEntry entry = null;
if (userName.contains("@")) {
entry = xmppConnection.getRoster().getEntry(
userName + "@" + xmppConnection.getServiceName());
} else {
entry = xmppConnection.getRoster().getEntry(
userName + "@" + xmppConnection.getServiceName());
}
if (entry == null) {
entry = xmppConnection.getRoster().getEntry(userName);
}
xmppConnection.getRoster().removeEntry(entry);
return true;
} catch (Exception e) {
Log.e("removeUser", e.getMessage());
e.printStackTrace();
return false;
}
}
示例4: addUserToGroup
import org.jivesoftware.smack.RosterEntry; //导入依赖的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));
}
}
}
示例5: getEntrysByGroup
import org.jivesoftware.smack.RosterEntry; //导入依赖的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;
}
示例6: isFriendly
import org.jivesoftware.smack.RosterEntry; //导入依赖的package包/类
/**
* 判断是否是好友
*
* @param
* @param user
* @return
*/
public boolean isFriendly(String user) {
Roster roster = getCon().getRoster();
List<RosterEntry> list = new ArrayList<RosterEntry>();
list.addAll(roster.getEntries());
for (int i = 0; i < list.size(); i++) {
Log.i("xmppttttttttt", list.get(i).getUser().toUpperCase() + "\t" + user);
if (list.get(i).getUser().contains(user.toLowerCase())) {
if (list.get(i).getType().toString().equals("both")) {
return true;
} else {
return false;
}
}
}
return false;
}
示例7: findFriends
import org.jivesoftware.smack.RosterEntry; //导入依赖的package包/类
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();
}
}
示例8: addUserToGroup
import org.jivesoftware.smack.RosterEntry; //导入依赖的package包/类
/**
* 把一个好友添加到一个组中
* @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();
}
}
示例9: getEntry
import org.jivesoftware.smack.RosterEntry; //导入依赖的package包/类
public RosterEntry getEntry(String userOrBuddyId) {
RosterEntry entry = null;
String id = null;
int pos = userOrBuddyId.indexOf("/");
if (pos > 0) {
id = userOrBuddyId.substring(0, pos);
} else {
id = userOrBuddyId;
}
entry = roster.getEntry(id);
if (entry != null) {
return entry;
}
if (idToEntry.containsKey(id)) {
return idToEntry.get(id);
}
return null;
}
示例10: notifyCurrentPresence
import org.jivesoftware.smack.RosterEntry; //导入依赖的package包/类
/**
* Notify current presence.
*
* @param connection
* the connection
*/
private void notifyCurrentPresence(XMPPConnection connection)
{
if (multiplicityGroup == null)
{
log.log(Level.WARNING, "Could not find the multiplicity roster group.");
return;
}
log.log(Level.FINE, "Loading roster entries.");
for (RosterEntry re : multiplicityGroup.getEntries())
{
log.finer("Roster entry check availability on " + re.getUser());
Presence presence = roster.getPresence(re.getUser());
if (presence.isAvailable())
{
log.finer(" is available!");
notifyDeviceAvailable(re.getName());
}
}
}
示例11: namesToJIDs
import org.jivesoftware.smack.RosterEntry; //导入依赖的package包/类
/**
* Names to ji ds.
*
* @param devices
* the devices
* @return the string[]
*/
public String[] namesToJIDs(String... devices)
{
String[] jids = new String[devices.length];
for (RosterEntry re : xmpp.getRoster().getEntries())
{
for (int i = 0; i < devices.length; i++)
{
if (re.getName().equals(devices[i]))
{
jids[i] = re.getUser();
}
}
}
return jids;
}
示例12: addRosterEntry
import org.jivesoftware.smack.RosterEntry; //导入依赖的package包/类
/**
* 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);
}
示例13: getGroups
import org.jivesoftware.smack.RosterEntry; //导入依赖的package包/类
/**
* ������з�����ϵ��
*
* @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;
}
示例14: transEntryToUser
import org.jivesoftware.smack.RosterEntry; //导入依赖的package包/类
/**
* ����RosterEntry����һ��User
*
* @param entry
* @return
*/
public static User transEntryToUser(RosterEntry entry, Roster roster) {
User user = new User();
if (entry.getName() == null) {
user.setName(StringUtil.getUserNameByJid(entry.getUser()));
} else {
user.setName(entry.getName());
}
user.setJID(entry.getUser());
System.out.println(entry.getUser());
Presence presence = roster.getPresence(entry.getUser());
user.setFrom(presence.getFrom());
user.setStatus(presence.getStatus());
user.setSize(entry.getGroups().size());
user.setAvailable(presence.isAvailable());
user.setType(entry.getType());
return user;
}
示例15: removeUserFromGroup
import org.jivesoftware.smack.RosterEntry; //导入依赖的package包/类
/**
* ��һ�����Ѵ�����ɾ��
*
* @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();
}