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


Java Roster.getEntry方法代码示例

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


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

示例1: perform

import org.jivesoftware.smack.Roster; //导入方法依赖的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;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:20,代码来源:RosterAction.java

示例2: 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

示例3: enableUser

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * This method sends a friend request to the user if he isn't already in the bots {@link Roster}
 * . {@inheritDoc}
 */
@Override
public void enableUser(String username) {
    if (!connection.isConnected()) {
        return;
    }
    Roster roster = connection.getRoster();
    if (roster != null && roster.getEntry(username) != null) {
        return;
    }
    try {
        String clientId = ClientAndChannelContextHolder.getClient().getClientId();
        Presence subscribe = new Presence(Presence.Type.subscribe);
        subscribe.setFrom(sender);
        subscribe.setTo(username + "." + clientId + XMPPPatternUtils.getUserSuffix());
        connection.sendPacket(subscribe);
        Presence subscribed = new Presence(Presence.Type.subscribed);
        subscribed.setFrom(sender);
        subscribed.setTo(username + "." + clientId + XMPPPatternUtils.getUserSuffix());
        connection.sendPacket(subscribed);
    } catch (NotConnectedException e) {
        LOG.debug("Could not send friendship request because XMPP connector is disconnected");
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:28,代码来源:XMPPConnector.java

示例4: 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

示例5: removeUser

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * 删除好友
 *
 * @param userName
 * @return
 */
public boolean removeUser(String userName) {
    Roster roster = con.getRoster();
    try {
        RosterEntry entry = roster.getEntry(userName);
        if (null != entry) {
            roster.removeEntry(entry);
        }
        return true;
    } catch (XMPPException e) {
        SLog.e(tag, Log.getStackTraceString(e));
    }
    return false;
}
 
开发者ID:jiangzehui,项目名称:xmpp,代码行数:20,代码来源:XmppTool.java

示例6: removeUser

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * 删除一个好友
 * @param roster
 * @param userJid
 * @return
 */
public static boolean removeUser(Roster roster,String userJid)
{
	try {
		RosterEntry entry = roster.getEntry(userJid);
		roster.removeEntry(entry);
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		return false;
	}		
}
 
开发者ID:cowthan,项目名称:AyoSunny,代码行数:18,代码来源:XmppUtil.java

示例7: 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

示例8: removeUser

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * ɾ������
 * 
 * @param roster
 * @param userName
 * @return
 */
public boolean removeUser(Roster roster, String userName) {
	try {
		if (userName.contains("@"))
			userName = userName.split("@")[0];
		RosterEntry entry = roster.getEntry(userName);
		if (null != entry)
			roster.removeEntry(entry);
		return true;
	} catch (XMPPException e) {
		SLog.e(tag, Log.getStackTraceString(e));
	}
	return false;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:21,代码来源:XmppConnectionManager.java

示例9: deleteUser

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * 
 * �ӻ�������ɾ���û�.
 * 
 * @param Jid
 * @throws XMPPException
 */
public static void deleteUser(String userJid) throws XMPPException {

	Roster roster = XmppConnectionManager.getInstance().getConnection()
			.getRoster();
	RosterEntry entry = roster.getEntry(userJid);
	XmppConnectionManager.getInstance().getConnection().getRoster()
			.removeEntry(entry);

}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:17,代码来源:ContacterManager.java

示例10: removeUser

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * ɾ��һ������
 * @param roster
 * @param userJid
 * @return
 */
public static boolean removeUser(Roster roster,String userJid)
{
	try {
		RosterEntry entry = roster.getEntry(userJid);
		roster.removeEntry(entry);
		return true;
	} catch (Exception e) {
		e.printStackTrace();
		return false;
	}		
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:18,代码来源:XmppService.java

示例11: getImage

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
private void getImage(String requestAgent, String workgroup, HttpServletRequest request, HttpServletResponse response) {
    ChatManager chatManager = ChatManager.getInstance();

    boolean isOnline = WorkgroupStatus.isOnline(workgroup);
    final SettingsManager imageManager = SettingsManager.getInstance();

    final Roster roster = chatManager.getGlobalConnection().getRoster();
    final Presence presence = roster.getPresence(requestAgent);

    isOnline = isOnline && presence != null && presence.getType() == Presence.Type.available;

    if (!isOnline) {
        Object o = roster.getEntry(requestAgent);
        if (o == null) {
            try {
                roster.createEntry(requestAgent, requestAgent, null);
            }
            catch (XMPPException e) {
               WebLog.logError("Error creating new roster entry:", e);
            }
        }
    }

    byte[] image;
    if (isOnline) {
        image = imageManager.getImage("personalonline", workgroup, getServletContext());
    }
    else {
        image = imageManager.getImage("personaloffline", workgroup, getServletContext());
    }

    imageManager.writeBytesToStream(image, response);
}
 
开发者ID:igniterealtime,项目名称:Fastpath-webchat,代码行数:34,代码来源:DynamicImageServlet.java

示例12: 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

示例13: handleRemove

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
    * Handles the ?remove URI
    * 
    * @param uri
    *            the decoded uri
    * @throws Exception
    */
   public void handleRemove(URI uri) throws Exception {
// xmpp:[email protected]?remove

String jid = retrieveJID(uri);
Roster roster = SparkManager.getConnection().getRoster();
RosterEntry entry = roster.getEntry(jid);
roster.removeEntry(entry);
   }
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:16,代码来源:UriManager.java

示例14: updateUserPresence

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
 * Updates the users presence.
 *
 * @param presence the user to update.
 * @throws Exception if there is a problem while updating the user's presence.
 */
private synchronized void updateUserPresence(Presence presence) throws Exception {
    if (presence.getError() != null) {
        // We ignore this.
        return;
    }

    final Roster roster = SparkManager.getConnection().getRoster();

    final String bareJID = StringUtils.parseBareAddress(presence.getFrom());

    RosterEntry entry = roster.getEntry(bareJID);
    boolean isPending = entry != null && (entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
        && RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus();

    // If online, check to see if they are in the offline group.
    // If so, remove from offline group and add to all groups they
    // belong to.

    if (presence.getType() == Presence.Type.available && offlineGroup.getContactItemByJID(bareJID) != null || (presence.getFrom().indexOf("workgroup.") != -1)) {
        changeOfflineToOnline(bareJID, entry, presence);
    }
    else if (presence.getType() == Presence.Type.available) {
        updateContactItemsPresence(presence, entry, bareJID);
    }
    else if (presence.getType() == Presence.Type.unavailable && !isPending) {
        // If not available, move to offline group.
        Presence rosterPresence = PresenceManager.getPresence(bareJID);
        if (!rosterPresence.isAvailable()) {
            moveToOfflineGroup(presence, bareJID);
        }
        else {
            updateContactItemsPresence(rosterPresence, entry, bareJID);
        }
    }
    
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:43,代码来源:ContactList.java

示例15: removeContactFromRoster

import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
private void removeContactFromRoster(ContactItem item) {
    Roster roster = SparkManager.getConnection().getRoster();
    RosterEntry entry = roster.getEntry(item.getJID());
    if (entry != null) {
        try {
            roster.removeEntry(entry);
        }
        catch (XMPPException e) {
            Log.warning("Unable to remove roster entry.", e);
        }
    }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:13,代码来源:ContactList.java


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