本文整理汇总了Java中org.jivesoftware.smack.Roster.removeEntry方法的典型用法代码示例。如果您正苦于以下问题:Java Roster.removeEntry方法的具体用法?Java Roster.removeEntry怎么用?Java Roster.removeEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.Roster
的用法示例。
在下文中一共展示了Roster.removeEntry方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: 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;
}
示例3: 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;
}
}
示例4: 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;
}
示例5: 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;
}
}
示例6: 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);
}
示例7: 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);
}
示例8: 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);
}
}
}
示例9: execute
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
@Override
public XmppResult execute() {
// TODO Auto-generated method stub
XmppResult result = createResult();
Cursor mCursor = null;
try {
// 删除关系表
if (mRosterId != -1) {
mCursor = mContext.getContentResolver().query(
ContentUris.withAppendedId(RosterColumns.CONTENT_URI,
mRosterId),
new String[] { RosterColumns.USERID,
RosterColumns.GROUP_ID }, null, null, null);
if (mCursor != null && mCursor.getCount() == 1) {
mCursor.moveToFirst();
mUserId = mCursor.getString(0);
mGroupId = mCursor.getInt(1);
}
}
Roster roster = XmppConnectionUtils.getInstance().getConnection()
.getRoster();
RosterEntry rosterEntry = roster.getEntry(mUserId);
if (rosterEntry != null) {
roster.removeEntry(rosterEntry);
}
mContext.getContentResolver().delete(
RosterColumns.CONTENT_URI,
RosterColumns.USERID + "='"+mUserId+"' and " + RosterColumns.GROUP_ID
+ "=" + mGroupId,
null);
// 删除本地聊天记录
YiIMUtils.deleteChatRecord(mContext, mUserId);
// 删除本地会话记录
YiIMUtils.deleteConversation(mContext, mUserId);
result.status = Status.SUCCESS;
} catch (Exception e) {
YiLog.getInstance().e(e, "delete friend failed.");
result.obj = e.getMessage();
} finally {
if (mCursor != null) {
mCursor.close();
mCursor = null;
}
}
return result;
}