本文整理汇总了Java中org.jivesoftware.smack.RosterEntry.setName方法的典型用法代码示例。如果您正苦于以下问题:Java RosterEntry.setName方法的具体用法?Java RosterEntry.setName怎么用?Java RosterEntry.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.RosterEntry
的用法示例。
在下文中一共展示了RosterEntry.setName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContactList
import org.jivesoftware.smack.RosterEntry; //导入方法依赖的package包/类
List<BuddyGroup> getContactList() {
Roster roster = getInternalService().getConnection().getRoster();
Collection<RosterEntry> entries = roster.getEntries();
for (RosterEntry entry : entries) {
if (entry.getName() == null) {
try {
VCard vc = new VCard();
vc.load(getInternalService().getConnection(), entry.getUser());
String nick = getNicknameFromVCard(vc);
if (nick != null) {
entry.setName(nick);
}
} catch (XMPPException e) {
Logger.log(e);
}
}
}
List<BuddyGroup> groups = getInternalService().getService().getEntityAdapter().rosterGroupCollection2BuddyGroupList(roster.getGroups(), entries, getInternalService().getOnlineInfo().getProtocolUid(), getInternalService().getService().getContext(), getInternalService().getService().getServiceId());
return groups;
}
示例2: setNickname
import org.jivesoftware.smack.RosterEntry; //导入方法依赖的package包/类
/**
* ��������ѵ��dz�
*
* @param user
* @param nickname
*/
public static void setNickname(User user, String nickname,
XMPPConnection connection) {
RosterEntry entry = connection.getRoster().getEntry(user.getJID());
entry.setName(nickname);
}
示例3: renameRosterItem
import org.jivesoftware.smack.RosterEntry; //导入方法依赖的package包/类
@Override
public void renameRosterItem(String user, String newName)
throws XXException {// 重命名联系人,供外部服务调用
// TODO Auto-generated method stub
mRoster = mXMPPConnection.getRoster();
RosterEntry rosterEntry = mRoster.getEntry(user);
if (!(newName.length() > 0) || (rosterEntry == null)) {
throw new XXException("JabberID to rename is invalid!");
}
rosterEntry.setName(newName);
}
示例4: renameRosterItem
import org.jivesoftware.smack.RosterEntry; //导入方法依赖的package包/类
@Override
public void renameRosterItem(String user, String newName)
throws AppException {// 重命名联系人,供外部服务调用
// TODO Auto-generated method stub
mRoster = mXMPPConnection.getRoster();
RosterEntry rosterEntry = mRoster.getEntry(user);
if (!(newName.length() > 0) || (rosterEntry == null)) {
throw new AppException("JabberID to rename is invalid!");
}
rosterEntry.setName(newName);
}
示例5: renameRosterItem
import org.jivesoftware.smack.RosterEntry; //导入方法依赖的package包/类
public void renameRosterItem(String user, String newName)
throws YaximXMPPException {
RosterEntry rosterEntry = mRoster.getEntry(user);
if (!(newName.length() > 0) || (rosterEntry == null)) {
throw new YaximXMPPException("JabberID to rename is invalid!");
}
rosterEntry.setName(newName);
}
示例6: renameBuddy
import org.jivesoftware.smack.RosterEntry; //导入方法依赖的package包/类
void renameBuddy(Buddy buddy) {
Roster roster = getInternalService().getConnection().getRoster();
RosterEntry buddyEntry = roster.getEntry(buddy.getProtocolUid());
buddyEntry.setName(buddy.getName());
getInternalService().getService().getCoreService().buddyAction(ItemAction.MODIFIED, buddy);
}
示例7: addEntry
import org.jivesoftware.smack.RosterEntry; //导入方法依赖的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;
}
示例8: actionPerformed
import org.jivesoftware.smack.RosterEntry; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
if (e.getSource() == addingGroupButton) {
new RosterDialog().showRosterDialog();
}
else if (e.getSource() == chatMenu) {
if (activeItem != null) {
SparkManager.getChatManager().activateChat(activeItem.getJID(), activeItem.getDisplayName());
}
}
else if (e.getSource() == addContactMenu) {
RosterDialog rosterDialog = new RosterDialog();
if (activeGroup != null) {
rosterDialog.setDefaultGroup(activeGroup);
}
rosterDialog.showRosterDialog();
}
else if (e.getSource() == removeContactFromGroupMenu) {
if (activeItem != null) {
removeContactFromGroup(activeItem);
}
}
else if (e.getSource() == renameMenu) {
if (activeItem == null) {
return;
}
String oldAlias = activeItem.getAlias();
String newAlias = JOptionPane.showInputDialog(this, Res.getString("label.rename.to") + ":", oldAlias);
// if user pressed 'cancel', output will be null.
// if user removed alias, output will be an empty String.
if (newAlias != null) {
if (!ModelUtil.hasLength(newAlias)) {
newAlias = null; // allows you to remove an alias.
}
String address = activeItem.getJID();
ContactGroup contactGroup = getContactGroup(activeItem.getGroupName());
ContactItem contactItem = contactGroup.getContactItemByDisplayName(activeItem.getDisplayName());
contactItem.setAlias(newAlias);
final Roster roster = SparkManager.getConnection().getRoster();
RosterEntry entry = roster.getEntry(address);
entry.setName(newAlias);
final Iterator<ContactGroup> contactGroups = groupList.iterator();
String user = StringUtils.parseBareAddress(address);
while (contactGroups.hasNext()) {
ContactGroup cg = contactGroups.next();
ContactItem ci = cg.getContactItemByJID(user);
if (ci != null) {
ci.setAlias(newAlias);
}
}
}
}
}