Search in sources :

Example 1 with GroupChatRoom

use of org.jivesoftware.spark.ui.rooms.GroupChatRoom in project Spark by igniterealtime.

the class GroupChatRoomListener method chatRoomOpened.

@Override
public void chatRoomOpened(ChatRoom room) {
    if (!(room instanceof GroupChatRoom)) {
        return;
    }
    GroupChatRoom groupChatRoom = (GroupChatRoom) room;
    MultiUserChat chat = groupChatRoom.getMultiUserChat();
    chat.addUserStatusListener(new UserStatusListener() {

        public void kicked(String actor, String reason) {
        }

        public void voiceGranted() {
        }

        public void voiceRevoked() {
        }

        public void banned(String actor, String reason) {
        }

        public void membershipGranted() {
        }

        public void membershipRevoked() {
        }

        public void moderatorGranted() {
        }

        public void moderatorRevoked() {
        }

        public void ownershipGranted() {
        }

        public void ownershipRevoked() {
        }

        public void adminGranted() {
        }

        public void adminRevoked() {
        }
    });
}
Also used : GroupChatRoom(org.jivesoftware.spark.ui.rooms.GroupChatRoom) MultiUserChat(org.jivesoftware.smackx.muc.MultiUserChat) UserStatusListener(org.jivesoftware.smackx.muc.UserStatusListener)

Example 2 with GroupChatRoom

use of org.jivesoftware.spark.ui.rooms.GroupChatRoom in project Spark by igniterealtime.

the class ConferenceServices method invitationReceived.

@Override
public void invitationReceived(final XMPPConnection conn, final MultiUserChat room, final String inviter, final String reason, final String password, final Message message) {
    SwingUtilities.invokeLater(() -> {
        Collection<RoomInvitationListener> listeners = new ArrayList<>(SparkManager.getChatManager().getInvitationListeners());
        for (RoomInvitationListener listener : listeners) {
            boolean handle = listener.handleInvitation(conn, room, inviter, reason, password, message);
            if (handle) {
                return;
            }
        }
        // room.
        try {
            SparkManager.getChatManager().getChatContainer().getChatRoom(room.getRoom());
            return;
        } catch (ChatRoomNotFoundException e) {
        // Ignore :)
        }
        final GroupChatInvitationUI invitationUI = new GroupChatInvitationUI(room.getRoom(), inviter, password, reason);
        String message1 = Res.getString("message.invite.to.groupchat", inviter);
        String title = Res.getString("title.group.chat");
        String bareJID = XmppStringUtils.parseBareJid(inviter);
        if (_localPreferences.isAutoAcceptMucInvite()) {
            ConferenceUtils.enterRoomOnSameThread(XmppStringUtils.parseLocalpart(room.getRoom()), room.getRoom(), password);
            MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(SparkManager.getConnection());
            GroupChatRoom chat = UIComponentRegistry.createGroupChatRoom(manager.getMultiUserChat(room.getRoom()));
            showToaster(message1, title, chat);
            return;
        // Nothing to do here, we want to join the
        // room, and stuff
        }
        try {
            ChatRoom chatRoom = SparkManager.getChatManager().getChatContainer().getChatRoom(bareJID);
            // If the ChatRoom exists, add an invitationUI.
            chatRoom.getTranscriptWindow().addComponent(invitationUI);
            // Notify user of incoming invitation.
            chatRoom.increaseUnreadMessageCount();
            chatRoom.scrollToBottom();
            SparkManager.getChatManager().getChatContainer().fireNotifyOnMessage(chatRoom, true, message1, title);
        } catch (ChatRoomNotFoundException e) {
            // If it doesn't exists. Create a new Group
            // Chat Room
            // Create the Group Chat Room
            final MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(SparkManager.getConnection());
            final GroupChatRoom groupChatRoom = UIComponentRegistry.createGroupChatRoom(manager.getMultiUserChat(room.getRoom()));
            showToaster(message1, title, groupChatRoom);
            groupChatRoom.getSplitPane().setDividerSize(5);
            groupChatRoom.getVerticalSlipPane().setDividerLocation(0.6);
            groupChatRoom.getSplitPane().setDividerLocation(0.6);
            String roomName = XmppStringUtils.parseLocalpart(room.getRoom());
            groupChatRoom.setTabTitle(roomName);
            groupChatRoom.getToolBar().setVisible(true);
            SparkManager.getChatManager().getChatContainer().addChatRoom(groupChatRoom);
            groupChatRoom.getTranscriptWindow().addComponent(invitationUI);
            // Notify user of incoming invitation.
            groupChatRoom.increaseUnreadMessageCount();
            groupChatRoom.scrollToBottom();
            SparkManager.getChatManager().getChatContainer().fireNotifyOnMessage(groupChatRoom, true, message1, title);
        }
    // If no listeners handled the invitation,
    // default to generic invite.
    // new ConversationInvitation(conn, room,
    // inviter, reason, password, message);
    });
}
Also used : GroupChatRoom(org.jivesoftware.spark.ui.rooms.GroupChatRoom) MultiUserChatManager(org.jivesoftware.smackx.muc.MultiUserChatManager) GroupChatRoom(org.jivesoftware.spark.ui.rooms.GroupChatRoom) ArrayList(java.util.ArrayList)

Example 3 with GroupChatRoom

use of org.jivesoftware.spark.ui.rooms.GroupChatRoom in project Spark by igniterealtime.

the class ConferenceUtils method createPrivateConference.

/**
 * Creates a private conference.
 *
 * @param serviceName the service name to use for the private conference.
 * @param message     the message sent to each individual invitee.
 * @param roomName    the name of the room to create.
 * @param jids        a collection of the user JIDs to invite.
 * @throws SmackException thrown if an error occurs during room creation.
 */
public static void createPrivateConference(String serviceName, String message, String roomName, Collection<String> jids) throws SmackException {
    final String roomJID = XmppStringUtils.escapeLocalpart(roomName) + "@" + serviceName;
    final MultiUserChat multiUserChat = MultiUserChatManager.getInstanceFor(SparkManager.getConnection()).getMultiUserChat(roomJID);
    final LocalPreferences pref = SettingsManager.getLocalPreferences();
    final GroupChatRoom room = UIComponentRegistry.createGroupChatRoom(multiUserChat);
    try {
        // Attempt to create room.
        multiUserChat.create(pref.getNickname());
    } catch (XMPPException | SmackException e) {
        throw new SmackException(e);
    }
    try {
        // Since this is a private room, make the room not public and set user as owner of the room.
        Form submitForm = multiUserChat.getConfigurationForm().createAnswerForm();
        submitForm.setAnswer("muc#roomconfig_publicroom", false);
        submitForm.setAnswer("muc#roomconfig_roomname", roomName);
        final List<String> owners = new ArrayList<>();
        owners.add(SparkManager.getSessionManager().getBareAddress());
        submitForm.setAnswer("muc#roomconfig_roomowners", owners);
        multiUserChat.sendConfigurationForm(submitForm);
    } catch (XMPPException | SmackException e1) {
        Log.error("Unable to send conference room chat configuration form.", e1);
    }
    ChatManager chatManager = SparkManager.getChatManager();
    // Check if room already is open
    try {
        chatManager.getChatContainer().getChatRoom(room.getRoomname());
    } catch (ChatRoomNotFoundException e) {
        chatManager.getChatContainer().addChatRoom(room);
        chatManager.getChatContainer().activateChatRoom(room);
    }
    for (String jid : jids) {
        multiUserChat.invite(jid, message);
        room.getTranscriptWindow().insertNotificationMessage(Res.getString("message.waiting.for.user.to.join", jid), ChatManager.NOTIFICATION_COLOR);
    }
}
Also used : GroupChatRoom(org.jivesoftware.spark.ui.rooms.GroupChatRoom) MultiUserChat(org.jivesoftware.smackx.muc.MultiUserChat) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) Form(org.jivesoftware.smackx.xdata.Form) ChatRoomNotFoundException(org.jivesoftware.spark.ui.ChatRoomNotFoundException) SmackException(org.jivesoftware.smack.SmackException) LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences) XMPPException(org.jivesoftware.smack.XMPPException) ChatManager(org.jivesoftware.spark.ChatManager) MultiUserChatManager(org.jivesoftware.smackx.muc.MultiUserChatManager)

Example 4 with GroupChatRoom

use of org.jivesoftware.spark.ui.rooms.GroupChatRoom in project Spark by igniterealtime.

the class ChatManager method createConferenceRoom.

/**
 * Creates a new public Conference Room.
 *
 * @param roomName    the name of the room.
 * @param serviceName the service name to use (ex.conference.jivesoftware.com)
 * @return the new ChatRoom created. If an error occured, null will be returned.
 */
public ChatRoom createConferenceRoom(String roomName, String serviceName) {
    final MultiUserChat chatRoom = MultiUserChatManager.getInstanceFor(SparkManager.getConnection()).getMultiUserChat(roomName + "@" + serviceName);
    final GroupChatRoom room = UIComponentRegistry.createGroupChatRoom(chatRoom);
    try {
        LocalPreferences pref = SettingsManager.getLocalPreferences();
        chatRoom.create(pref.getNickname());
        // Send an empty room configuration form which indicates that we want
        // an instant room
        chatRoom.sendConfigurationForm(new Form(DataForm.Type.submit));
    } catch (XMPPException | SmackException e1) {
        Log.error("Unable to send conference room chat configuration form.", e1);
        return null;
    }
    getChatContainer().addChatRoom(room);
    return room;
}
Also used : GroupChatRoom(org.jivesoftware.spark.ui.rooms.GroupChatRoom) MultiUserChat(org.jivesoftware.smackx.muc.MultiUserChat) DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) Form(org.jivesoftware.smackx.xdata.Form) SmackException(org.jivesoftware.smack.SmackException) LocalPreferences(org.jivesoftware.sparkimpl.settings.local.LocalPreferences) XMPPException(org.jivesoftware.smack.XMPPException)

Example 5 with GroupChatRoom

use of org.jivesoftware.spark.ui.rooms.GroupChatRoom in project Spark by igniterealtime.

the class Workpane method addButtons.

private void addButtons(final String sessionID, final RequestUtils utils, final ChatRoom room) {
    final ChatRoomButton inviteButton = new ChatRoomButton(FastpathRes.getImageIcon(FastpathRes.CHAT_INVITE_IMAGE_24x24));
    final ChatRoomButton transferButton = new ChatRoomButton(FastpathRes.getImageIcon(FastpathRes.CHAT_TRANSFER_IMAGE_24x24));
    final RolloverButton cannedResponses = new RolloverButton(FastpathRes.getImageIcon(FastpathRes.DOWN_ARROW_IMAGE));
    final ChatRoomButton endButton = new ChatRoomButton(FastpathRes.getImageIcon(FastpathRes.CHAT_ENDED_IMAGE_24x24));
    final ChatRoomButton cobrowseButton = new ChatRoomButton(FastpathRes.getImageIcon(FastpathRes.CHAT_COBROWSE_IMAGE_24x24));
    // Set tooltips
    inviteButton.setToolTipText("Invite another user to join in this conversation.");
    transferButton.setToolTipText("Transfer this conversation to another agent.");
    endButton.setToolTipText("End this conversation.");
    cobrowseButton.setToolTipText("Start a co-browsing session with this user.");
    // Update Canned Response button.
    ResourceUtils.resButton(cannedResponses, FpRes.getString("button.canned.responses"));
    room.getToolBar().addChatRoomButton(inviteButton);
    room.getToolBar().addChatRoomButton(transferButton);
    room.getToolBar().addChatRoomButton(cobrowseButton);
    room.getToolBar().addChatRoomButton(endButton);
    inviteButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            inviteOrTransfer(room, utils.getWorkgroup(), sessionID, false);
        }
    });
    cobrowseButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            CoBrowser browser = new CoBrowser(sessionID, room);
            browser.showDialog();
        }
    });
    transferButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            inviteOrTransfer(room, utils.getWorkgroup(), sessionID, true);
        }
    });
    room.getEditorBar().add(cannedResponses);
    cannedResponses.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            final ChatMacroMenu chatMacroMenu = new ChatMacroMenu(room);
            chatMacroMenu.show(cannedResponses, e.getX(), e.getY());
        }
    });
    endButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent actionEvent) {
            final GroupChatRoom groupChatRoom = (GroupChatRoom) room;
            groupChatRoom.leaveChatRoom();
        }
    });
    // Set Room is Active
    addFastpathChatRoom(room, RoomState.activeRoom);
}
Also used : GroupChatRoom(org.jivesoftware.spark.ui.rooms.GroupChatRoom) RolloverButton(org.jivesoftware.spark.component.RolloverButton)

Aggregations

GroupChatRoom (org.jivesoftware.spark.ui.rooms.GroupChatRoom)18 SmackException (org.jivesoftware.smack.SmackException)8 XMPPException (org.jivesoftware.smack.XMPPException)6 MultiUserChat (org.jivesoftware.smackx.muc.MultiUserChat)6 Form (org.jivesoftware.smackx.xdata.Form)4 ArrayList (java.util.ArrayList)3 ChatManager (org.jivesoftware.spark.ChatManager)3 MultiUserChatManager (org.jivesoftware.smackx.muc.MultiUserChatManager)2 DataForm (org.jivesoftware.smackx.xdata.packet.DataForm)2 ChatNotFoundException (org.jivesoftware.spark.ChatNotFoundException)2 ChatRoom (org.jivesoftware.spark.ui.ChatRoom)2 LocalPreferences (org.jivesoftware.sparkimpl.settings.local.LocalPreferences)2 BorderLayout (java.awt.BorderLayout)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1