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();
}
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;
}
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);
}
}
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);
}
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;
}
Aggregations