Search in sources :

Example 6 with ChatRoom

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

the class CallManager method interlocutorRemoved.

public void interlocutorRemoved(final InterlocutorUI interlocutorUI) {
    if (softPhone.getInterlocutors().size() == 0) {
        if (offPhonePresence == null) {
            // Set user to available when all phone calls are hung up.
            Presence availablePresence = new Presence(Presence.Type.available, "Online", 1, Presence.Mode.available);
            SparkManager.getSessionManager().changePresence(availablePresence);
        } else {
            // Set user presence to last one choosed
            SparkManager.getSessionManager().changePresence(offPhonePresence);
        }
        offPhonePresence = null;
    }
    final SwingWorker delay = new SwingWorker() {

        public Object construct() {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return true;
        }

        public void finished() {
            String phoneNumber = interlocutorUI.getCall().getNumber();
            phoneNumber = SoftPhoneManager.getNumbersFromPhone(phoneNumber);
            final PhonePanel phonePanel = calls.get(phoneNumber);
            if (phonePanel == null) {
                return;
            }
            for (ChatRoom room : SparkManager.getChatManager().getChatContainer().getChatRooms()) {
                Component comp = room.getSplitPane().getRightComponent();
                if (comp != null && comp instanceof PhonePanel) {
                    final PhonePanel cp = (PhonePanel) comp;
                    if (cp == phonePanel) {
                        room.getSplitPane().setRightComponent(null);
                        removePhonePanel(cp);
                        // Remove state mapping
                        softPhone.removeCallSession(room);
                        SparkManager.getChatManager().notifySparkTabHandlers(room);
                    }
                    return;
                }
            }
        }
    };
    delay.start();
}
Also used : ChatRoom(org.jivesoftware.spark.ui.ChatRoom) Presence(org.jivesoftware.smack.packet.Presence) SwingWorker(org.jivesoftware.spark.util.SwingWorker)

Example 7 with ChatRoom

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

the class CallManager method getSparkTab.

/**
 * Returns the <code>SparkTab</code> that acts as a container to this PhonePanel.
 *
 * @param phonePanel the <code>PhonePanel</code>
 * @return the SparkTab.
 */
public SparkTab getSparkTab(PhonePanel phonePanel) {
    final ChatContainer chatContainer = SparkManager.getChatManager().getChatContainer();
    int tabCount = chatContainer.getTabCount();
    for (int i = 0; i < tabCount; i++) {
        SparkTab sparkTab = chatContainer.getTabAt(i);
        Component containerComponent = chatContainer.getComponentInTab(sparkTab);
        if (containerComponent.equals(phonePanel)) {
            return sparkTab;
        }
        if (containerComponent instanceof ChatRoom) {
            ChatRoom chatRoom = (ChatRoom) containerComponent;
            Component rightComponent = chatRoom.getSplitPane().getRightComponent();
            if (phonePanel.equals(rightComponent)) {
                return sparkTab;
            }
        }
    }
    return null;
}
Also used : ChatContainer(org.jivesoftware.spark.ui.ChatContainer) SparkTab(org.jivesoftware.spark.component.tabbedPane.SparkTab) ChatRoom(org.jivesoftware.spark.ui.ChatRoom)

Example 8 with ChatRoom

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

the class InviteSwingWorker method finished.

@Override
public void finished() {
    final String roomName = XmppStringUtils.parseBareJid(roomJID);
    try {
        final ChatRoom room = SparkManager.getChatManager().getChatContainer().getChatRoom(roomName);
        final TranscriptWindow transcriptWindow = room.getTranscriptWindow();
        for (final String jid : (Set<String>) getValue()) {
            final String notification = Res.getString("message.waiting.for.user.to.join", jid);
            transcriptWindow.insertNotificationMessage(notification, ChatManager.NOTIFICATION_COLOR);
        }
    } catch (ChatRoomNotFoundException e) {
        Log.error("Unable to identify chat room tab by name: " + roomName);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ChatRoom(org.jivesoftware.spark.ui.ChatRoom) TranscriptWindow(org.jivesoftware.spark.ui.TranscriptWindow) ChatRoomNotFoundException(org.jivesoftware.spark.ui.ChatRoomNotFoundException)

Example 9 with ChatRoom

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

the class UriManager method handleMessage.

/**
 * handles the ?message URI
 *
 * @param uri
 *            the decoded uri
 */
public void handleMessage(URI uri) {
    String query = uri.getQuery();
    int bodyIndex = query.indexOf("body=");
    String jid = retrieveJID(uri);
    String body = null;
    // Find body
    if (bodyIndex != -1) {
        body = query.substring(bodyIndex + 5);
    }
    body = org.jivesoftware.spark.util.StringUtils.unescapeFromXML(body);
    UserManager userManager = SparkManager.getUserManager();
    String nickname = userManager.getUserNicknameFromJID(jid);
    if (nickname == null) {
        nickname = jid;
    }
    ChatManager chatManager = SparkManager.getChatManager();
    ChatRoom chatRoom = chatManager.createChatRoom(jid, nickname, nickname);
    if (body != null) {
        Message message = new Message();
        message.setBody(body);
        chatRoom.sendMessage(message);
    }
    chatManager.getChatContainer().activateChatRoom(chatRoom);
}
Also used : Message(org.jivesoftware.smack.packet.Message) ChatRoom(org.jivesoftware.spark.ui.ChatRoom) UserManager(org.jivesoftware.spark.UserManager) ChatManager(org.jivesoftware.spark.ChatManager)

Example 10 with ChatRoom

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

the class JingleTabHandler method isTabHandled.

public boolean isTabHandled(SparkTab tab, Component component, boolean isSelectedTab, boolean chatFrameFocused) {
    if (component instanceof ChatRoom) {
        JingleRoomState roomState = manager.getJingleRoomState((ChatRoom) component);
        if (roomState == null) {
            // This is not a jingle room.
            return false;
        }
        // This is a room with a jingle session.
        handleJingleRoom(roomState, tab, (ChatRoom) component, isSelectedTab, chatFrameFocused);
        return true;
    }
    return false;
}
Also used : ChatRoom(org.jivesoftware.spark.ui.ChatRoom) JingleRoomState(org.jivesoftware.sparkplugin.JingleStateManager.JingleRoomState)

Aggregations

ChatRoom (org.jivesoftware.spark.ui.ChatRoom)45 ChatManager (org.jivesoftware.spark.ChatManager)10 ChatRoomImpl (org.jivesoftware.spark.ui.rooms.ChatRoomImpl)10 ActionEvent (java.awt.event.ActionEvent)8 Message (org.jivesoftware.smack.packet.Message)8 ChatRoomNotFoundException (org.jivesoftware.spark.ui.ChatRoomNotFoundException)8 ContactItem (org.jivesoftware.spark.ui.ContactItem)7 Presence (org.jivesoftware.smack.packet.Presence)6 ChatRoomListenerAdapter (org.jivesoftware.spark.ui.ChatRoomListenerAdapter)6 ActionListener (java.awt.event.ActionListener)5 MouseEvent (java.awt.event.MouseEvent)5 Date (java.util.Date)5 JButton (javax.swing.JButton)5 JLabel (javax.swing.JLabel)5 JPanel (javax.swing.JPanel)5 SmackException (org.jivesoftware.smack.SmackException)5 StanzaTypeFilter (org.jivesoftware.smack.filter.StanzaTypeFilter)5 SimpleDateFormat (java.text.SimpleDateFormat)4 JPopupMenu (javax.swing.JPopupMenu)4 SparkManager (org.jivesoftware.spark.SparkManager)4