aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhristoterezov <hristo@jitsi.org>2014-02-12 18:06:52 +0200
committerhristoterezov <hristo@jitsi.org>2014-02-12 18:06:52 +0200
commit5810b3199bcd988f273564714ed174e2ef70b686 (patch)
treee5ff7972951ab8701f4670dc3421391693007fdc
parent5d36831f2255b97c20baabe72760030df746289d (diff)
downloadjitsi-5810b3199bcd988f273564714ed174e2ef70b686.zip
jitsi-5810b3199bcd988f273564714ed174e2ef70b686.tar.gz
jitsi-5810b3199bcd988f273564714ed174e2ef70b686.tar.bz2
Implements destroy chat room functionality. Adds destroy chat room button and right hand menu item.
-rw-r--r--resources/images/images.properties5
-rw-r--r--resources/images/impl/gui/buttons/destroyChat.pngbin0 -> 1217 bytes
-rw-r--r--resources/images/impl/gui/buttons/destroyChatOver.pngbin0 -> 1342 bytes
-rw-r--r--resources/images/impl/gui/buttons/destroyChatPressed.pngbin0 -> 1423 bytes
-rw-r--r--resources/images/impl/gui/common/destroyChatRightMenu.pngbin0 -> 1279 bytes
-rw-r--r--resources/images/impl/gui/common/oppeningChatroomSettings.pngbin0 -> 1298 bytes
-rw-r--r--resources/languages/resources.properties3
-rw-r--r--src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java74
-rw-r--r--src/net/java/sip/communicator/impl/muc/MUCServiceImpl.java20
-rw-r--r--src/net/java/sip/communicator/impl/protocol/irc/ChatRoomIrcImpl.java11
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java20
-rw-r--r--src/net/java/sip/communicator/impl/protocol/mock/MockChatRoom.java13
-rw-r--r--src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomDestroyReasonDialog.java147
-rw-r--r--src/net/java/sip/communicator/service/protocol/ChatRoom.java20
14 files changed, 296 insertions, 17 deletions
diff --git a/resources/images/images.properties b/resources/images/images.properties
index 1b05f48..b933124 100644
--- a/resources/images/images.properties
+++ b/resources/images/images.properties
@@ -117,6 +117,8 @@ service.gui.icons.CERTIFICATE_WARNING=resources/images/impl/gui/common/certifica
service.gui.icons.CONFERENCE_CALL=resources/images/impl/gui/common/conferenceCall.png
service.gui.icons.VIDEO_BRIDGE=resources/images/impl/gui/common/videoBridge.png
service.gui.icons.CONFERENCE_VIDEO_INDICATOR=resources/images/impl/gui/common/conferenceVideoIndicator.png
+service.gui.icons.OPEN_AUTOMATICALLY=resources/images/impl/gui/common/oppeningChatroomSettings.png
+service.gui.icons.DESTROY_CHATROOM=resources/images/impl/gui/common/destroyChatRightMenu.png
# Status icons
service.gui.statusmessage.GLOBAL_STATUS_MESSAGE_ICON=resources/images/impl/gui/common/globalStatusMessage.png
@@ -280,6 +282,9 @@ service.gui.icons.AUTOJOIN_ON_ICON_PRESSED_BUTTON=resources/images/impl/gui/butt
service.gui.icons.AUTOJOIN_OFF_ICON_BUTTON=resources/images/impl/gui/buttons/autoJoinOff.png
service.gui.icons.AUTOJOIN_OFF_ICON_ROLLOVER_BUTTON=resources/images/impl/gui/buttons/autoJoinOffOver.png
service.gui.icons.AUTOJOIN_OFF_ICON_PRESSED_BUTTON=resources/images/impl/gui/buttons/autoJoinOffPressed.png
+service.gui.icons.DESTROY_ICON_BUTTON=resources/images/impl/gui/buttons/destroyChat.png
+service.gui.icons.DESTROY_ICON_ROLLOVER_BUTTON=resources/images/impl/gui/buttons/destroyChatOver.png
+service.gui.icons.DESTROY_ICON_PRESSED_BUTTON=resources/images/impl/gui/buttons/destroyChatPressed.png
# Sound level icons
service.gui.soundlevel.SOUND_LEVEL_ACTIVE_LEFT=resources/images/impl/gui/common/soundlevel/soundActiveLeft.png
diff --git a/resources/images/impl/gui/buttons/destroyChat.png b/resources/images/impl/gui/buttons/destroyChat.png
new file mode 100644
index 0000000..4882b37
--- /dev/null
+++ b/resources/images/impl/gui/buttons/destroyChat.png
Binary files differ
diff --git a/resources/images/impl/gui/buttons/destroyChatOver.png b/resources/images/impl/gui/buttons/destroyChatOver.png
new file mode 100644
index 0000000..f962fac
--- /dev/null
+++ b/resources/images/impl/gui/buttons/destroyChatOver.png
Binary files differ
diff --git a/resources/images/impl/gui/buttons/destroyChatPressed.png b/resources/images/impl/gui/buttons/destroyChatPressed.png
new file mode 100644
index 0000000..198b715
--- /dev/null
+++ b/resources/images/impl/gui/buttons/destroyChatPressed.png
Binary files differ
diff --git a/resources/images/impl/gui/common/destroyChatRightMenu.png b/resources/images/impl/gui/common/destroyChatRightMenu.png
new file mode 100644
index 0000000..4d2dc25
--- /dev/null
+++ b/resources/images/impl/gui/common/destroyChatRightMenu.png
Binary files differ
diff --git a/resources/images/impl/gui/common/oppeningChatroomSettings.png b/resources/images/impl/gui/common/oppeningChatroomSettings.png
new file mode 100644
index 0000000..03226fd
--- /dev/null
+++ b/resources/images/impl/gui/common/oppeningChatroomSettings.png
Binary files differ
diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties
index f5d63c6..4dd970d 100644
--- a/resources/languages/resources.properties
+++ b/resources/languages/resources.properties
@@ -56,6 +56,7 @@ service.gui.ADMINISTRATOR=administrator
service.gui.ADVANCED=&Advanced
service.gui.ALL=&All
service.gui.ALL_CONTACTS=&All contacts
+service.gui.ALTERNATE_ADDRESS=Alternate address
service.gui.APPLY=&Apply
service.gui.ARE_CALLING={0} are calling...
service.gui.ARE_NOW=You are now {0}
@@ -192,6 +193,8 @@ service.gui.DO_NOT_SHOW_AGAIN=Don't show this message again
service.gui.DOWNLOAD_NOW=&Download now
service.gui.DRAG_FOR_SHARING=Drag here anything you want to share...
service.gui.DURATION=duration
+service.gui.DESTROY_CHATROOM=Destroy chat room
+service.gui.DESTROY_MESSAGE=To inform other participants, please enter a reason and an alternative chat room address to join.
service.gui.EDIT=&Edit
service.gui.EDITED_AT=edited at {0}
service.gui.EMAIL=Email
diff --git a/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java b/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java
index 419e378..c144072 100644
--- a/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java
+++ b/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java
@@ -44,7 +44,8 @@ public class MUCCustomContactActionService
"leave",
"join",
"autojoin",
- "autojoin_pressed"
+ "autojoin_pressed",
+ "destroy_chatroom"
};
/**
@@ -54,7 +55,8 @@ public class MUCCustomContactActionService
"service.gui.LEAVE",
"service.gui.JOIN",
"service.gui.JOIN_AUTOMATICALLY",
- "service.gui.JOIN_AUTOMATICALLY"
+ "service.gui.JOIN_AUTOMATICALLY",
+ "service.gui.DESTROY_CHATROOM"
};
/**
@@ -64,7 +66,8 @@ public class MUCCustomContactActionService
"service.gui.icons.LEAVE_ICON_BUTTON",
"service.gui.icons.JOIN_ICON_BUTTON",
"service.gui.icons.AUTOJOIN_ON_ICON_BUTTON",
- "service.gui.icons.AUTOJOIN_OFF_ICON_BUTTON"
+ "service.gui.icons.AUTOJOIN_OFF_ICON_BUTTON",
+ "service.gui.icons.DESTROY_ICON_BUTTON"
};
/**
@@ -74,7 +77,8 @@ public class MUCCustomContactActionService
"service.gui.icons.LEAVE_ICON_ROLLOVER_BUTTON",
"service.gui.icons.JOIN_ICON_ROLLOVER_BUTTON",
"service.gui.icons.AUTOJOIN_ON_ICON_ROLLOVER_BUTTON",
- "service.gui.icons.AUTOJOIN_OFF_ICON_ROLLOVER_BUTTON"
+ "service.gui.icons.AUTOJOIN_OFF_ICON_ROLLOVER_BUTTON",
+ "service.gui.icons.DESTROY_ICON_ROLLOVER_BUTTON"
};
/**
@@ -85,6 +89,7 @@ public class MUCCustomContactActionService
"service.gui.icons.JOIN_ICON_PRESSED_BUTTON",
"service.gui.icons.AUTOJOIN_ON_ICON_PRESSED_BUTTON",
"service.gui.icons.AUTOJOIN_OFF_ICON_PRESSED_BUTTON",
+ "service.gui.icons.DESTROY_ICON_PRESSED_BUTTON"
};
/**
@@ -99,7 +104,8 @@ public class MUCCustomContactActionService
"change_nick",
"autojoin",
"autojoin_pressed",
- "open_automatically"
+ "open_automatically",
+ "destroy_chatroom"
};
/**
@@ -114,7 +120,8 @@ public class MUCCustomContactActionService
"service.gui.CHANGE_NICK",
"service.gui.JOIN_AUTOMATICALLY",
"service.gui.DONT_JOIN_AUTOMATICALLY",
- "service.gui.OPEN_AUTOMATICALLY"
+ "service.gui.OPEN_AUTOMATICALLY",
+ "service.gui.DESTROY_CHATROOM"
};
/**
@@ -129,7 +136,8 @@ public class MUCCustomContactActionService
"service.gui.icons.RENAME_16x16_ICON",
"service.gui.icons.AUTOJOIN",
"service.gui.icons.AUTOJOIN",
- null
+ "service.gui.icons.OPEN_AUTOMATICALLY",
+ "service.gui.icons.DESTROY_CHATROOM"
};
/**
@@ -205,6 +213,27 @@ public class MUCCustomContactActionService
};
/**
+ * A runnable that destroys the chat room.
+ */
+ private MUCCustomActionRunnable destroyActionRunnable
+ = new MUCCustomActionRunnable()
+ {
+
+ @Override
+ public void run()
+ {
+ String destroyOptions[]
+ = ChatRoomDestroyReasonDialog.getDestroyOptions();
+ if(destroyOptions == null)
+ return;
+
+ MUCActivator.getMUCService().destroyChatRoom(chatRoomWrapper,
+ destroyOptions[0], destroyOptions[1]);
+
+ }
+ };
+
+ /**
* Array of <tt>MUCCustomActionRunnable</tt> objects for the custom menu
* items. They will be executed when the item is pressed.
*/
@@ -212,7 +241,8 @@ public class MUCCustomContactActionService
leaveRunnable,
joinRunnable,
autoJoinRunnable,
- autoJoinRunnable
+ autoJoinRunnable,
+ destroyActionRunnable
};
/**
@@ -299,7 +329,8 @@ public class MUCCustomContactActionService
chatRoomWrapper.getParentProvider().getProtocolProvider(),
chatRoomWrapper.getChatRoomID());
}
- }
+ },
+ destroyActionRunnable
};
/**
@@ -315,6 +346,7 @@ public class MUCCustomContactActionService
null,
null,
null,
+ null,
null
};
@@ -486,6 +518,18 @@ public class MUCCustomContactActionService
{
return actionsEnabledCheckers[1].check(actionSource);
}
+ else if(name.equals("destroy_chatroom"))
+ {
+ ChatRoomSourceContact contact
+ = (ChatRoomSourceContact) actionSource;
+ ChatRoomWrapper room = MUCActivator.getMUCService()
+ .findChatRoomWrapperFromSourceContact(contact);
+ if(room == null || room.getChatRoom() == null)
+ return false;
+ if(room.getChatRoom().getUserRole().equals(ChatRoomMemberRole.OWNER))
+ return true;
+ return false;
+ }
else
{
ChatRoomSourceContact contact
@@ -619,6 +663,18 @@ public class MUCCustomContactActionService
if(name.equals("autojoin_pressed"))
return room.isAutojoin();
}
+ else if(name.equals("destroy_chatroom"))
+ {
+ ChatRoomSourceContact contact
+ = (ChatRoomSourceContact) actionSource;
+ ChatRoomWrapper room = MUCActivator.getMUCService()
+ .findChatRoomWrapperFromSourceContact(contact);
+ if(room == null || room.getChatRoom() == null)
+ return false;
+ if(room.getChatRoom().getUserRole().equals(ChatRoomMemberRole.OWNER))
+ return true;
+ return false;
+ }
return true;
}
diff --git a/src/net/java/sip/communicator/impl/muc/MUCServiceImpl.java b/src/net/java/sip/communicator/impl/muc/MUCServiceImpl.java
index 9a2dac2..729649f 100644
--- a/src/net/java/sip/communicator/impl/muc/MUCServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/muc/MUCServiceImpl.java
@@ -10,7 +10,6 @@ import java.util.*;
import org.jitsi.service.resources.*;
-
import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.plugin.desktoputil.chat.*;
import net.java.sip.communicator.service.contactsource.*;
@@ -929,6 +928,25 @@ public class MUCServiceImpl
}
/**
+ * Destroys the given <tt>ChatRoom</tt> from the list of all chat rooms.
+ *
+ * @param chatRoomWrapper the <tt>ChatRoomWrapper</tt> to be destroyed.
+ * @param reason the reason for destroying.
+ * @param alternateAddress the alternate address.
+ */
+ public void destroyChatRoom(ChatRoomWrapper chatRoomWrapper,
+ String reason, String alternateAddress)
+ {
+ if(chatRoomWrapper.getChatRoom().destroy(reason, alternateAddress))
+ {
+ MUCActivator.getUIService().closeChatRoomWindow(
+ chatRoomWrapper);
+ chatRoomList.removeChatRoom(chatRoomWrapper);
+ }
+
+ }
+
+ /**
* Adds a ChatRoomProviderWrapperListener to the listener list.
*
* @param listener the ChatRoomProviderWrapperListener to be added
diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomIrcImpl.java
index e079f56..2586066 100644
--- a/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomIrcImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/irc/ChatRoomIrcImpl.java
@@ -1208,4 +1208,15 @@ public class ChatRoomIrcImpl
*/
@Override
public void updatePrivateContactPresenceStatus(Contact sourceContact) { }
+
+ /**
+ * Destroys the chat room.
+ * @param reason the reason for destroying.
+ * @param alternateAddress the alternate address
+ * @return <tt>true</tt> if the room is destroyed.
+ */
+ public boolean destroy(String reason, String alternateAddress)
+ {
+ return true;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java
index 87ff01d..f07083b 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java
@@ -810,6 +810,26 @@ public class ChatRoomJabberImpl
}
/**
+ * Destroys the chat room.
+ * @param reason the reason for destroying.
+ * @param alternateAddress the alternate address
+ * @return <tt>true</tt> if the room is destroyed.
+ */
+ public boolean destroy(String reason, String alternateAddress)
+ {
+ try
+ {
+ multiUserChat.destroy(reason, alternateAddress);
+ }
+ catch (XMPPException e)
+ {
+ logger.warn("Error occured while destroying chat room", e);
+ return false;
+ }
+ return true;
+ }
+
+ /**
* Leave this chat room.
*/
public void leave()
diff --git a/src/net/java/sip/communicator/impl/protocol/mock/MockChatRoom.java b/src/net/java/sip/communicator/impl/protocol/mock/MockChatRoom.java
index 2415cec..3855cf5 100644
--- a/src/net/java/sip/communicator/impl/protocol/mock/MockChatRoom.java
+++ b/src/net/java/sip/communicator/impl/protocol/mock/MockChatRoom.java
@@ -776,7 +776,7 @@ public class MockChatRoom
{
return null;
// TODO Auto-generated method stub
-
+
}
/**
@@ -794,4 +794,15 @@ public class MockChatRoom
*/
@Override
public void updatePrivateContactPresenceStatus(Contact sourceContact) { }
+
+ /**
+ * Destroys the chat room.
+ * @param reason the reason for destroying.
+ * @param alternateAddress the alternate address
+ * @return <tt>true</tt> if the room is destroyed.
+ */
+ public boolean destroy(String reason, String alternateAddress)
+ {
+ return true;
+ }
}
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomDestroyReasonDialog.java b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomDestroyReasonDialog.java
new file mode 100644
index 0000000..d537184
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomDestroyReasonDialog.java
@@ -0,0 +1,147 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.plugin.desktoputil.chat;
+
+import java.awt.*;
+
+import javax.swing.*;
+
+import net.java.sip.communicator.plugin.desktoputil.*;
+
+/**
+ * Dialog with fields for reason and alternate address.
+ *
+ * @author Hristo Terezov
+ */
+public class ChatRoomDestroyReasonDialog extends MessageDialog
+{
+ /**
+ * Serial id.
+ */
+ private static final long serialVersionUID = -916498752420264164L;
+
+ /**
+ * Text field for the alternate address.
+ */
+ private SIPCommTextField alternateAddress
+ = new SIPCommTextField("chatroom@example.com");
+
+ /**
+ * Text field for reason text.
+ */
+ private JTextField reasonField = new JTextField();
+
+ /**
+ * Constructs new chat room destroy dialog.
+ *
+ * @param title the title of the dialog
+ * @param message the message shown in this dialog
+ */
+ public ChatRoomDestroyReasonDialog(String title, String message)
+ {
+ super(null, title, message,
+ DesktopUtilActivator.getResources().getI18NString("service.gui.OK"),
+ false);
+ this.setIcon((ImageIcon)null);
+
+ alternateAddress.setFont(alternateAddress.getFont().deriveFont(12f));
+
+ JLabel altAddressLabel
+ = new JLabel(DesktopUtilActivator.getResources()
+ .getI18NString("service.gui.ALTERNATE_ADDRESS") + ":");
+
+ JLabel reasonLabel
+ = new JLabel(DesktopUtilActivator.getResources()
+ .getI18NString("service.gui.REASON") + ":");
+
+ JPanel labelsPanel = new JPanel(new GridLayout(2, 1));
+ labelsPanel.add(reasonLabel);
+ labelsPanel.add(altAddressLabel);
+
+ JPanel valuesPanel = new JPanel(new GridLayout(2, 1));
+ valuesPanel.add(reasonField);
+ valuesPanel.add(alternateAddress);
+
+ JPanel fieldsPanel = new JPanel(new BorderLayout());
+ fieldsPanel .add(labelsPanel, BorderLayout.WEST);
+
+ fieldsPanel.add(valuesPanel, BorderLayout.CENTER);
+ fieldsPanel.add(new JLabel(" "), BorderLayout.EAST);
+ fieldsPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ fieldsPanel.setOpaque(false);
+
+
+
+ replaceCheckBoxPanel(fieldsPanel);
+ this.pack();
+ }
+
+ /**
+ * Returns the text entered in the alternate address field.
+ *
+ * @return the text from the alternate address field.
+ */
+ public String getAlternateAddress()
+ {
+ return alternateAddress.getText();
+ }
+
+ /**
+ * Returns the text entered in the reason field.
+ *
+ * @return the text from the reason field.
+ */
+ public String getReason()
+ {
+ return reasonField.getText();
+ }
+
+ /**
+ * Opens a dialog with a fields for the reason and alternate address and
+ * returns them.
+ *
+ * @return array with the reason and alternate address values.
+ */
+ public static String[] getDestroyOptions()
+ {
+ ChatRoomDestroyReasonDialog reasonDialog =
+ new ChatRoomDestroyReasonDialog(DesktopUtilActivator.getResources()
+ .getI18NString("service.gui.DESTROY_CHATROOM"),
+ DesktopUtilActivator.getResources().getI18NString(
+ "service.gui.DESTROY_MESSAGE"));
+
+ int result = reasonDialog.showDialog();
+
+ String destroyOptions[] = new String[2];
+
+ if (result == MessageDialog.OK_RETURN_CODE)
+ {
+ destroyOptions[0] = proccessFieldValues(reasonDialog.getReason());
+ destroyOptions[1]
+ = proccessFieldValues(reasonDialog.getAlternateAddress());
+ }
+ else
+ {
+ destroyOptions = null;
+ }
+
+
+ return destroyOptions;
+ }
+
+ private static String proccessFieldValues(String value)
+ {
+ if(value != null)
+ {
+ value = value.trim();
+ if(value.equals(""))
+ value = null;
+ }
+ return value;
+ }
+
+}
diff --git a/src/net/java/sip/communicator/service/protocol/ChatRoom.java b/src/net/java/sip/communicator/service/protocol/ChatRoom.java
index 05ff6a6..9c20593 100644
--- a/src/net/java/sip/communicator/service/protocol/ChatRoom.java
+++ b/src/net/java/sip/communicator/service/protocol/ChatRoom.java
@@ -425,9 +425,9 @@ public interface ChatRoom
public boolean isPersistent();
/**
- * Finds private messaging contact by nickname. If the contact doesn't
+ * Finds private messaging contact by nickname. If the contact doesn't
* exists a new volatile contact is created.
- *
+ *
* @param nickname the nickname of the contact.
* @return the contact instance.
*/
@@ -555,14 +555,14 @@ public interface ChatRoom
/**
* Updates the presence status of private messaging contact.
- *
+ *
* @param nickname the nickname of the contact.
*/
public void updatePrivateContactPresenceStatus(String nickname);
/**
* Updates the presence status of private messaging contact.
- *
+ *
* @param contact the contact.
*/
public void updatePrivateContactPresenceStatus(Contact contact);
@@ -584,16 +584,24 @@ public interface ChatRoom
*/
public void removeConferencePublishedListener(
ChatRoomConferencePublishedListener listener);
-
+
/**
* Returns cached <tt>ConferenceDescription</tt> instances.
* @return the cached <tt>ConferenceDescription</tt> instances.
*/
public Map<String, ConferenceDescription> getCachedConferenceDescriptions();
-
+
/**
* Returns the number of cached <tt>ConferenceDescription</tt> instances.
* @return the number of cached <tt>ConferenceDescription</tt> instances.
*/
public int getCachedConferenceDescriptionSize();
+
+ /**
+ * Destroys the chat room.
+ * @param reason the reason for destroying.
+ * @param alternateAddress the alternate address
+ * @return <tt>true</tt> if the room is destroyed.
+ */
+ public boolean destroy(String reason, String alternateAddress);
}