📄 bsbrowsebean.java
字号:
package edu.ou.kmi.buddyspace.plugins.browse.core;
/*
* BSBrowseBean.java
*
* Project: BuddySpace
* (C) Copyright Knowledge Media Institute 2002
*
*
* Created on 18 November 2002, 16:15
*/
import java.util.*;
import org.jabber.jabberbeans.*;
import org.jabber.jabberbeans.util.*;
import org.jabber.jabberbeans.Extension.*;
/**
* <code>BSBrowseBean</code> provides browsing.
* It relies on <code>BrowseBean</code>, which is initialized using given
* <code>ConnectionBean</code> (this must be reset after reconnection).
*
* @author Jiri Komzak, Knowledge Media Institute, Open University, United Kingdom
*/
public class BSBrowseBean implements BrowseListener {
//protected Hashtable curPresences;
protected BrowseBean browseBean = null;
protected final String name = "Browse";
/**
* Constructor
*/
public BSBrowseBean() {
browseBean = new BrowseBean();
browseBean.addBrowseListener(this);
}
/**
* Constructor, which sets existing and connected <code>ConnectionBean</code>.
* Then this is registered as listener for packet events.
*/
public BSBrowseBean(ConnectionBean connection) {
this();
setConnection(connection);
}
/**
* Sets existing and connected <code>ConnectionBean</code>.
* Then this is registered as listener for packet and connection events.
*/
public void setConnection(ConnectionBean connection) {
/*if (this.connection != null) {
this.connection.delPacketListener(this);
this.connection.delConnectionListener(this);
}*/
if (connection != null)
browseBean.setConnBean(connection);
else {
//cmd4: to fix bug in BrowseBean not accepting null ConnectionBean
browseBean.setConnBean(new ConnectionBean());
}
/*if (connection != null) {
connection.addPacketListener(this);
connection.addConnectionListener(this);
}*/
}
/**
* Returns currently used <code>ConnectionBean</code>.
*/
public ConnectionBean getConnection() {
return (browseBean != null)? browseBean.getConnBean() : null;
}
/** Called when disconnected */
public void disconnected() {
}
/** Browses the given jid */
public void browseTo(String jidStr, PacketID id, boolean refresh) {
if (browseBean == null) return;
browseBean.browseTo(jidStr, id, refresh);
}
/**
* Clears the cache.
*/
public void clear() {
}
/**
* Frees all object bindings to allow object destroy
*/
protected void prepareToDestroy() {
//removeAllBrowseListeners();
if (browseBean != null) {
browseBean.delBrowseListener(this);
browseBean = null;
}
}
// *** LISTENER METHODS ***
/**
* Invoked when an error occures.
*/
public void error(InfoQuery iq, String id) {
//firePresenceChanged(new BSPresenceInfo(p));
}
/**
* Invoked when a packet received.
*/
public void received(BrowseItem b, java.lang.String id) {
}
// *** browse listeners ***
/**
* Adds <code>BSPresenceListener</code> to listeners notified when
* presence state of some of buddies changes.
*
* @see #removePresenceListener
* @see #removeAllPresenceListeners
* @see #firePresenceChanged
* @see #fireSubscriptionRequested
* @see #fireSubscriptionApproved
*/
public void addBrowseListener(BrowseListener listener) {
if (browseBean == null) return;
browseBean.addBrowseListener(listener);
}
/**
* Removes <code>BSBrowseListener</code> to listeners notified when
* presence state of some of buddies changes.
*
* @see #addPresenceListener
* @see #removeAllPresenceListeners
* @see #firePresenceChanged
* @see #fireSubscriptionRequested
* @see #fireSubscriptionApproved
*/
public void removeBrowseListener(BrowseListener listener) {
if (browseBean == null) return;
browseBean.delBrowseListener(listener);
}
/**
* Removes all listeners notified when presence state of some of buddies changes.
* This can be used before to free dependencies and allow dispose of
* all objects.
*
* @see #addPresenceListener
* @see #removePresenceListener
* @see #firePresenceChanged
* @see #fireSubscriptionRequested
* @see #fireSubscriptionApproved
*/
/*public void removeAllPresenceListeners() {
presenceListeners.clear();
}*/
/**
* Notifies presence listeners about presence state of some of buddies change.
*
* @see #addPresenceListener
* @see #removePresenceListener
* @see #removeAllPresenceListeners
* @see #fireSubscriptionRequested
* @see #fireSubscriptionApproved
*/
/*private void fireReceived(BrowseItem b, String id) {
for (Enumeration e = presenceListeners.elements(); e.hasMoreElements(); ) {
BSBrowseListener listener = (BSBrowseListener) e.nextElement();
listener.fireReceived(b, id);
}
}*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -