use of org.jxmpp.stringprep.XmppStringprepException in project Spark by igniterealtime.
the class AgentConversations method checkPopup.
private void checkPopup(MouseEvent e) {
if (e.isPopupTrigger()) {
// Check if monitor
try {
AgentConversation item = list.getSelectedValue();
boolean isMonitor = FastpathPlugin.getAgentSession().hasMonitorPrivileges(SparkManager.getConnection());
if (isMonitor) {
JPopupMenu menu = new JPopupMenu();
final String sessionID = item.getSessionID();
Action joinAction = new AbstractAction() {
private static final long serialVersionUID = 8239167390330425891L;
public void actionPerformed(ActionEvent actionEvent) {
// Get Conference
try {
final MultiUserChatManager multiUserChatManager = MultiUserChatManager.getInstanceFor(SparkManager.getConnection());
List<DomainBareJid> col = multiUserChatManager.getMucServiceDomains();
if (col.size() == 0) {
return;
}
DomainBareJid serviceName = col.iterator().next();
EntityBareJid roomName = JidCreate.entityBareFrom(sessionID + "@" + serviceName);
LocalPreferences pref = SettingsManager.getLocalPreferences();
final Resourcepart nickname = pref.getNickname();
MultiUserChat muc = multiUserChatManager.getMultiUserChat(roomName);
ConferenceUtils.enterRoom(muc, roomName, nickname, null);
if (muc.isJoined()) {
// Try and remove myself as an owner if I am one.
Collection<Affiliate> owners;
try {
owners = muc.getOwners();
} catch (XMPPException | SmackException e1) {
return;
}
Iterator<Affiliate> iter = owners.iterator();
List<Jid> list = new ArrayList<>();
while (iter.hasNext()) {
Affiliate affilitate = iter.next();
Jid jid = affilitate.getJid();
if (!jid.equals(SparkManager.getSessionManager().getUserBareAddress())) {
list.add(jid);
}
}
if (list.size() > 0) {
FillableForm form = muc.getConfigurationForm().getFillableForm();
List<String> listStrings = JidUtil.toStringList(list);
form.setAnswer("muc#roomconfig_roomowners", listStrings);
// new DataFormDialog(groupChat, form);
muc.sendConfigurationForm(form);
}
}
} catch (Exception e1) {
Log.error(e1);
}
}
};
joinAction.putValue(Action.NAME, FpRes.getString("menuitem.join.chat"));
menu.add(joinAction);
Action monitorAction = new AbstractAction() {
private static final long serialVersionUID = -2072254190661466657L;
public void actionPerformed(ActionEvent actionEvent) {
// Make user an owner.
try {
FastpathPlugin.getAgentSession().makeRoomOwner(SparkManager.getConnection(), sessionID);
final MultiUserChatManager multiUserChatManager = MultiUserChatManager.getInstanceFor(SparkManager.getConnection());
List<DomainBareJid> col = multiUserChatManager.getMucServiceDomains();
if (col.size() == 0) {
return;
}
DomainBareJid serviceName = col.iterator().next();
EntityBareJid roomName = JidCreate.entityBareFrom(sessionID + "@" + serviceName);
LocalPreferences pref = SettingsManager.getLocalPreferences();
final Resourcepart nickname = pref.getNickname();
MultiUserChat muc = multiUserChatManager.getMultiUserChat(roomName);
ConferenceUtils.enterRoom(muc, roomName, nickname, null);
} catch (XMPPException | SmackException | InterruptedException | XmppStringprepException e1) {
Log.error(e1);
}
}
};
monitorAction.putValue(Action.NAME, FpRes.getString("menuitem.monitor.chat"));
menu.add(monitorAction);
menu.show(list, e.getX(), e.getY());
}
} catch (XMPPException | SmackException | InterruptedException e1) {
Log.error(e1);
}
}
}
Aggregations