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


Java RosterEntry.setName方法代码示例

本文整理汇总了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;
}
 
开发者ID:snuk182,项目名称:aceim,代码行数:24,代码来源:XMPPRosterListener.java

示例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);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:13,代码来源:ContacterManager.java

示例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);
}
 
开发者ID:victoryckl,项目名称:XmppTest,代码行数:13,代码来源:SmackImpl.java

示例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);
}
 
开发者ID:misty-rain,项目名称:smartedu,代码行数:13,代码来源:SmackImpl.java

示例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);
}
 
开发者ID:ufo22940268,项目名称:maven-yaxim,代码行数:10,代码来源:SmackableImp.java

示例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);
}
 
开发者ID:snuk182,项目名称:aceim,代码行数:7,代码来源:XMPPRosterListener.java

示例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;
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:53,代码来源:SubscriptionDialog.java

示例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);
             }
         }
        }
    }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:59,代码来源:ContactList.java


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