本文整理汇总了Java中org.jivesoftware.openfire.session.ClientSession.setActiveList方法的典型用法代码示例。如果您正苦于以下问题:Java ClientSession.setActiveList方法的具体用法?Java ClientSession.setActiveList怎么用?Java ClientSession.setActiveList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.openfire.session.ClientSession
的用法示例。
在下文中一共展示了ClientSession.setActiveList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setActiveList
import org.jivesoftware.openfire.session.ClientSession; //导入方法依赖的package包/类
/**
* User has specified a new active list that should be used for the current session.
*
* @param packet IQ packet setting new active list for the current session.
* @param from sender of the IQ packet.
* @param listName name of the new active list for the current session.
* @return acknowledge of success.
*/
private IQ setActiveList(IQ packet, JID from, String listName) {
IQ result = IQ.createResultIQ(packet);
Element childElement = packet.getChildElement().createCopy();
result.setChildElement(childElement);
// Get the list
PrivacyList list = manager.getPrivacyList(from.getNode(), listName);
if (list != null) {
// Get the user session
ClientSession session = sessionManager.getSession(from);
if (session != null) {
// Set the new active list for this session
session.setActiveList(list);
}
}
else {
// List not found
result.setError(PacketError.Condition.item_not_found);
}
return result;
}
示例2: run
import org.jivesoftware.openfire.session.ClientSession; //导入方法依赖的package包/类
public void run() {
ClientSession session = ((ClientSession) getSession());
PrivacyList list = null;
// Get the privacy list to set
if (listName != null) {
try {
String username = session.getUsername();
list = PrivacyListManager.getInstance().getPrivacyList(username, listName);
} catch (UserNotFoundException e) {
// Should never happen
}
}
// Set the privacy list to the session
if (activeList) {
session.setActiveList(list);
}
else {
session.setDefaultList(list);
}
}
示例3: declineActiveList
import org.jivesoftware.openfire.session.ClientSession; //导入方法依赖的package包/类
/**
* User has requested that no active list should be used for the current session. Return
* acknowledge of success.
*
* @param packet IQ packet declining active list for the current session.
* @param from sender of the IQ packet.
* @return acknowledge of success.
*/
private IQ declineActiveList(IQ packet, JID from) {
// Get the user session
ClientSession session = sessionManager.getSession(from);
// Set that there is no active list for this session
session.setActiveList(null);
// Return acknowledge of success
return IQ.createResultIQ(packet);
}
示例4: updateOrCreateList
import org.jivesoftware.openfire.session.ClientSession; //导入方法依赖的package包/类
/**
* Updates an existing privacy list or creates a new one with the specified items list. The
* new list will not become the active or default list by default. The user will have to
* send another packet to set the new list as active or default.<p>
*
* Once the list was updated or created a "privacy list push" will be sent to all
* connected resources of the user.
*
* @param packet IQ packet updating or creating a new privacy list.
* @param from sender of the IQ packet.
* @param listElement the element containing the list and its items.
* @return acknowledge of success.
*/
private IQ updateOrCreateList(IQ packet, JID from, Element listElement) {
IQ result = IQ.createResultIQ(packet);
Element childElement = packet.getChildElement().createCopy();
result.setChildElement(childElement);
String listName = listElement.attributeValue("name");
PrivacyList list = manager.getPrivacyList(from.getNode(), listName);
if (list == null) {
list = manager.createPrivacyList(from.getNode(), listName, listElement);
}
else {
// Update existing list
list.updateList(listElement);
provider.updatePrivacyList(from.getNode(), list);
// Make sure that existing user sessions that are using the updated list are poining
// to the updated instance. This may happen since PrivacyListManager uses a Cache that
// may expire so it's possible to have many instances representing the same privacy
// list. Therefore, if a list is modified then we need to make sure that all
// instances are replaced with the updated instance. An OR Mapping Tool would have
// avoided this issue since identity is ensured.
for (ClientSession session : sessionManager.getSessions(from.getNode())) {
if (list.equals(session.getDefaultList())) {
session.setDefaultList(list);
}
if (list.equals(session.getActiveList())) {
session.setActiveList(list);
}
}
}
// Send a "privacy list push" to all connected resources
IQ pushPacket = new IQ(IQ.Type.set);
Element child = pushPacket.setChildElement("query", "jabber:iq:privacy");
child.addElement("list").addAttribute("name", list.getName());
sessionManager.userBroadcast(from.getNode(), pushPacket);
return result;
}
示例5: deleteList
import org.jivesoftware.openfire.session.ClientSession; //导入方法依赖的package包/类
private IQ deleteList(IQ packet, JID from, String listName) {
ClientSession currentSession;
IQ result = IQ.createResultIQ(packet);
Element childElement = packet.getChildElement().createCopy();
result.setChildElement(childElement);
// Get the list to delete
PrivacyList list = manager.getPrivacyList(from.getNode(), listName);
if (list == null) {
// List to delete was not found
result.setError(PacketError.Condition.item_not_found);
return result;
}
else {
currentSession = sessionManager.getSession(from);
// Check if the list is being used by another session
for (ClientSession session : sessionManager.getSessions(from.getNode())) {
if (currentSession == session) {
// Ignore the active session for this checking
continue;
}
if (list.equals(session.getDefaultList()) || list.equals(session.getActiveList())) {
// List to delete is being used by another session so return a conflict error
result.setError(PacketError.Condition.conflict);
return result;
}
}
}
// Remove the list from the active session (if it was being used)
if (list.equals(currentSession.getDefaultList())) {
currentSession.setDefaultList(null);
}
if (list.equals(currentSession.getActiveList())) {
currentSession.setActiveList(null);
}
manager.deletePrivacyList(from.getNode(), listName);
return result;
}