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


Java Roster.getEntry方法代码示例

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


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

示例1: removeFromRoster

import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public boolean removeFromRoster(JID jid) {
    if (!this.isConnected()) {
        LOGGER.info("not connected");
        return false;
    }
    Roster roster = Roster.getInstanceFor(mConn);
    RosterEntry entry = roster.getEntry(jid.toBareSmack());
    if (entry == null) {
        LOGGER.info("can't find roster entry for jid: "+jid);
        return true;
    }
    try {
        // blocking
        roster.removeEntry(entry);
    } catch (SmackException.NotLoggedInException |
            SmackException.NoResponseException |
            XMPPException.XMPPErrorException |
            SmackException.NotConnectedException |
            InterruptedException ex) {
        LOGGER.log(Level.WARNING, "can't remove contact from roster", ex);
        return false;
    }
    return true;
}
 
开发者ID:kontalk,项目名称:desktopclient-java,代码行数:25,代码来源:Client.java

示例2: updateRosterEntry

import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void updateRosterEntry(JID jid, String newName) {
    if (!this.isConnected()) {
        LOGGER.info("not connected");
        return;
    }
    Roster roster = Roster.getInstanceFor(mConn);
    RosterEntry entry = roster.getEntry(jid.toBareSmack());
    if (entry == null) {
        LOGGER.warning("can't find roster entry for jid: "+jid);
        return;
    }
    try {
        entry.setName(newName);
    } catch (SmackException.NotConnectedException |
            SmackException.NoResponseException |
            XMPPException.XMPPErrorException |
            InterruptedException ex) {
        LOGGER.log(Level.WARNING, "can't set name for entry", ex);
    }
}
 
开发者ID:kontalk,项目名称:desktopclient-java,代码行数:21,代码来源:Client.java

示例3: removeContact

import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void removeContact(String remoteAccount) {
    try {
        Roster roster = Roster.getInstanceFor(mConnection);
        RosterEntry entry = roster.getEntry(remoteAccount);
        roster.removeEntry(entry);

        clearConversationsWith(remoteAccount);

        XmppServiceBroadcastEventEmitter.broadcastContactRemoved(remoteAccount);

    } catch (Exception exc) {
        Logger.error(TAG, "Error while removing contact: " + remoteAccount, exc);
    }
}
 
开发者ID:VoiSmart,项目名称:xmpp-service,代码行数:15,代码来源:XmppServiceConnection.java

示例4: renameContact

import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
public void renameContact(String remoteAccount, String newAlias) {
    try {
        Roster roster = Roster.getInstanceFor(mConnection);
        RosterEntry entry = roster.getEntry(remoteAccount);
        entry.setName(newAlias);

        XmppServiceBroadcastEventEmitter.broadcastContactRenamed(remoteAccount, newAlias);

    } catch (Exception exc) {
        Logger.error(TAG, "Error while renaming contact: " + remoteAccount, exc);
    }
}
 
开发者ID:VoiSmart,项目名称:xmpp-service,代码行数:13,代码来源:XmppServiceConnection.java

示例5: entriesUpdated

import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
@Override
public void entriesUpdated(Collection<String> addresses) {
    if (addresses == null || addresses.isEmpty()) {
        return;
    }

    Roster roster = Roster.getInstanceFor(mConnection);
    if (roster == null) {
        Logger.info(TAG, "entriesUpdated - No roster instance, skipping rebuild roster");
        return;
    }

    ArrayList<XmppRosterEntry> entries = getRosterEntries();
    if (entries == null || entries.isEmpty()) {
        Logger.info(TAG, "entriesUpdated - No roster entries. Skipping rebuild roster");
        return;
    }

    for (String destination : addresses) {
        destination = getXmppJid(destination);
        RosterEntry entry = roster.getEntry(destination);
        XmppRosterEntry xmppRosterEntry = getRosterEntryFor(roster, entry);
        int index = entries.indexOf(xmppRosterEntry);
        if (index < 0) {
            entries.add(xmppRosterEntry);
        } else {
            entries.set(index, xmppRosterEntry);
        }

    }

    Collections.sort(entries);
    XmppServiceBroadcastEventEmitter.broadcastRosterChanged();
}
 
开发者ID:VoiSmart,项目名称:xmpp-service,代码行数:35,代码来源:XmppServiceConnection.java

示例6: getRosterEntry

import org.jivesoftware.smack.roster.Roster; //导入方法依赖的package包/类
RosterEntry getRosterEntry(BareJid jid) {
    Roster roster = getRoster();
    return (roster != null) ? roster.getEntry(jid) : null;
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:5,代码来源:MessageCenterService.java


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