use of org.jivesoftware.spark.ui.rooms.ChatRoomImpl in project Spark by igniterealtime.
the class SparkTransferManager method sendImage.
/**
* Send an image to a user.
*
* @param image the image to send.
* @param room the ChatRoom of the user you wish to send the image to.
*/
public void sendImage(final BufferedImage image, final ChatRoom room) {
File tmpDirectory = new File(Spark.getSparkUserHome(), "/tempImages");
tmpDirectory.mkdirs();
String imageName = "image_" + StringUtils.randomString(2) + ".png";
final File imageFile = new File(tmpDirectory, imageName);
// Write image to system.
room.setCursor(new Cursor(Cursor.WAIT_CURSOR));
SwingWorker writeImageThread = new SwingWorker() {
public Object construct() {
try {
// Write out file in separate thread.
ImageIO.write(image, "png", imageFile);
} catch (IOException e) {
Log.error(e);
}
return true;
}
public void finished() {
ChatRoomImpl roomImpl = (ChatRoomImpl) room;
sendFile(imageFile, roomImpl.getParticipantJID());
SparkManager.getChatManager().getChatContainer().activateChatRoom(room);
room.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
};
writeImageThread.start();
}
use of org.jivesoftware.spark.ui.rooms.ChatRoomImpl in project Spark by igniterealtime.
the class SparkTransferManager method addSendFileButton.
private void addSendFileButton() {
final ChatManager chatManager = SparkManager.getChatManager();
chatManager.addChatRoomListener(new ChatRoomListenerAdapter() {
public void chatRoomOpened(final ChatRoom room) {
if (!(room instanceof ChatRoomImpl)) {
return;
}
// Otherwise,
new ChatRoomTransferDecorator(room);
}
public void chatRoomClosed(ChatRoom room) {
}
});
}
use of org.jivesoftware.spark.ui.rooms.ChatRoomImpl in project Spark by igniterealtime.
the class ConferenceServices method addChatRoomListener.
private void addChatRoomListener() {
ChatManager chatManager = SparkManager.getChatManager();
chatManager.addChatRoomListener(new ChatRoomListener() {
public void chatRoomOpened(final ChatRoom room) {
if (room instanceof ChatRoomImpl) {
final ChatRoomDecorator decorator = new ChatRoomDecorator(room);
decorator.decorate();
}
}
public void chatRoomLeft(ChatRoom room) {
}
public void chatRoomClosed(ChatRoom room) {
}
public void chatRoomActivated(ChatRoom room) {
}
public void userHasJoined(ChatRoom room, String userid) {
}
public void userHasLeft(ChatRoom room, String userid) {
}
});
}
use of org.jivesoftware.spark.ui.rooms.ChatRoomImpl in project Spark by igniterealtime.
the class GroupChatParticipantList method startChat.
protected void startChat(ChatRoom groupChat, String groupJID) {
String userNickname = XmppStringUtils.parseResource(groupJID);
String roomTitle = userNickname + " - " + XmppStringUtils.parseLocalpart(groupChat.getRoomname());
String nicknameOfUser = XmppStringUtils.parseResource(groupJID);
String nickname = groupChat.getNickname();
if (nicknameOfUser.equals(nickname)) {
return;
}
ChatRoom chatRoom;
try {
chatRoom = chatManager.getChatContainer().getChatRoom(groupJID);
} catch (ChatRoomNotFoundException e) {
Log.debug("Could not find chat room - " + groupJID);
// Create new room
chatRoom = new ChatRoomImpl(groupJID, nicknameOfUser, roomTitle);
chatManager.getChatContainer().addChatRoom(chatRoom);
}
chatManager.getChatContainer().activateChatRoom(chatRoom);
}
use of org.jivesoftware.spark.ui.rooms.ChatRoomImpl in project Spark by igniterealtime.
the class BroadcastPlugin method isTabHandled.
public boolean isTabHandled(SparkTab tab, Component component, boolean isSelectedTab, boolean chatFrameFocused) {
if (component instanceof ChatRoom) {
ChatRoom chatroom = (ChatRoom) component;
if (broadcastRooms.contains(chatroom)) {
final ChatRoomImpl room = (ChatRoomImpl) component;
tab.setIcon(SparkRes.getImageIcon(SparkRes.INFORMATION_IMAGE));
String nickname = room.getTabTitle();
nickname = Res.getString("message.broadcast.from", nickname);
tab.setTabTitle(nickname);
if ((!chatFrameFocused || !isSelectedTab) && room.getUnreadMessageCount() > 0) {
// Make tab red.
tab.setTitleColor(Color.red);
tab.setTabBold(true);
} else {
tab.setTitleColor(Color.black);
tab.setTabFont(tab.getDefaultFont());
room.clearUnreadMessageCount();
}
return true;
}
}
return false;
}
Aggregations