SPARK-1827 - Shouldn't allow broadcast to selected users when it is disabled in Client Control (#252)

* SPARK-1758 - Do not show UNFILED group if it's empty

* SPARK-1822 - Add additional default properties to control GUI settings

* SPARK-1822 - Add additional default properties to control GUI settings

* SPARK-1516 - Spark should not let open profile edit by clicking the
avatar if profile changing is disabled

* SPARK-1827 - Shouldn't allow broadcast to selected users when it is
disabled in Client Control

* SPARK-1822 - Add additional default properties to control GUI settings
This commit is contained in:
Michael Klein
2016-11-03 00:18:13 -04:00
committed by wroot
parent afc7e67849
commit e7e84b52f6
8 changed files with 487 additions and 504 deletions

View File

@ -109,12 +109,9 @@ DISABLE_AVATAR_TAB = false
# If true, disable the "Plugins" menu item
DISABLE_PLUGINS_MENU_ITEM = false
# If true, disable the option to transfer files
# If true, disable the option to transfer files and images
DISABLE_FILE_XFER = false
# If true, disable the option to take screenshots
DISABLE_SCREENSHOTS = false
# If true, disable the option to remove contacts and groups in roster
DISABLE_REMOVALS = false

View File

@ -19,7 +19,6 @@
*/
package org.jivesoftware.spark.filetransfer;
import org.jivesoftware.resource.Default;
import org.jivesoftware.resource.Res;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.ui.ChatRoom;
@ -55,29 +54,23 @@ public class ChatRoomTransferDecorator implements KeyListener, FileDropListener,
private ChatRoomButton sendScreenShotButton;
public ChatRoomTransferDecorator(final ChatRoom chatRoom) {
this.chatRoom = chatRoom;
this.chatRoom = chatRoom;
chatRoom.addFileDropListener(this);
chatRoom.getChatInputEditor().addKeyListener(this);
chatRoom.addClosingListener(this);
chatRoom.addFileDropListener(this);
chatRoom.getChatInputEditor().addKeyListener(this);
chatRoom.addClosingListener(this);
// See if we should disable the ability to transfer files
if (!Default.getBoolean("DISABLE_FILE_XFER")) {
sendFileButton = UIComponentRegistry.getButtonFactory().createSendFileButton();
sendFileButton.setToolTipText(Res.getString("message.send.file.to.user"));
sendFileButton = UIComponentRegistry.getButtonFactory().createSendFileButton();
sendFileButton.setToolTipText(Res.getString("message.send.file.to.user"));
chatRoom.addChatRoomButton(sendFileButton);
sendFileButton.addActionListener(this);
}
chatRoom.addChatRoomButton(sendFileButton);
sendFileButton.addActionListener(this);
// See if we should disable the ability to take screenshots
if (!Default.getBoolean("DISABLE_SCREENSHOTS")) {
sendScreenShotButton = UIComponentRegistry.getButtonFactory().createScreenshotButton();
sendScreenShotButton.setToolTipText(Res.getString("message.send.picture"));
sendScreenShotButton = UIComponentRegistry.getButtonFactory().createScreenshotButton();
sendScreenShotButton.setToolTipText(Res.getString("message.send.picture"));
chatRoom.addChatRoomButton(sendScreenShotButton);
sendScreenShotButton.addActionListener(this);
}
chatRoom.addChatRoomButton(sendScreenShotButton);
sendScreenShotButton.addActionListener(this);
}
public void keyTyped(KeyEvent e) {

View File

@ -138,10 +138,9 @@ public class SparkTransferManager {
}
private SparkTransferManager() {
boolean enabled = Enterprise.containsFeature(Enterprise.FILE_TRANSFER_FEATURE);
if (!enabled) {
return;
}
// See if we should disable the option to transfer files and images
if (Default.getBoolean("DISABLE_FILE_XFER") || !Enterprise.containsFeature(Enterprise.FILE_TRANSFER_FEATURE)) return;
SparkManager.getConnection().addConnectionListener(new ConnectionListener() {
@Override

View File

@ -1505,11 +1505,11 @@ moveToOffline(moveToOfflineContactItem);
}
};
// See if we should disable the option to transfer files
if (!Default.getBoolean("DISABLE_FILE_XFER")) {
// See if we should disable the option to transfer files and images
if (!Default.getBoolean("DISABLE_FILE_XFER") && Enterprise.containsFeature(Enterprise.FILE_TRANSFER_FEATURE)) {
sendAction.putValue(Action.SMALL_ICON, SparkRes.getImageIcon(SparkRes.DOCUMENT_16x16));
sendAction.putValue(Action.NAME, Res.getString("menuitem.send.a.file"));
if ((item.getPresence() != null) && Enterprise.containsFeature(Enterprise.FILE_TRANSFER_FEATURE)) popup.add(sendAction);
if (item.getPresence() != null) popup.add(sendAction);
}
popup.addSeparator();
@ -1670,11 +1670,10 @@ moveToOffline(moveToOfflineContactItem);
final JPopupMenu popup = new JPopupMenu();
final JMenuItem sendMessagesMenu = new JMenuItem(Res.getString("menuitem.send.a.message"), SparkRes.getImageIcon(SparkRes.SMALL_MESSAGE_IMAGE));
fireContextMenuListenerPopup(popup, items);
// See if we should disable all "Broadcast" menu items
if (!Default.getBoolean("DISABLE_BROADCAST_MENU_ITEM")) popup.add(sendMessagesMenu);
if (!Default.getBoolean("DISABLE_BROADCAST_MENU_ITEM") && Enterprise.containsFeature(Enterprise.BROADCAST_FEATURE)) popup.add(sendMessagesMenu);
sendMessagesMenu.addActionListener( e1 -> sendMessages(items) );

File diff suppressed because it is too large Load Diff

View File

@ -103,10 +103,8 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, StanzaLi
private Set<ChatRoom> broadcastRooms = new HashSet<>();
public void initialize() {
boolean enabled = Enterprise.containsFeature(Enterprise.BROADCAST_FEATURE);
if (!enabled) {
return;
}
// See if we should disable all "Broadcast" menu items
if (Default.getBoolean("DISABLE_BROADCAST_MENU_ITEM") || !Enterprise.containsFeature(Enterprise.BROADCAST_FEATURE)) return;
// Add as ContainerDecoratr
SparkManager.getChatManager().addSparkTabHandler(this);
@ -118,10 +116,9 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, StanzaLi
final JMenu actionsMenu = SparkManager.getMainWindow().getMenuByName(Res.getString("menuitem.actions"));
JMenuItem broadcastMenu = new JMenuItem(Res.getString("title.broadcast.message"), SparkRes.getImageIcon(SparkRes.MEGAPHONE_16x16));
ResourceUtils.resButton(broadcastMenu, Res.getString("title.broadcast.message"));
// See if we should disable all "Broadcast" menu items
if (!Default.getBoolean("DISABLE_BROADCAST_MENU_ITEM")) actionsMenu.add(broadcastMenu);
actionsMenu.add(broadcastMenu);
broadcastMenu.addActionListener( e -> broadcastToRoster() );
// Register with action menu
@ -175,8 +172,7 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, StanzaLi
broadcastMessageAction.putValue(Action.NAME, Res.getString("menuitem.broadcast.to.group"));
broadcastMessageAction.putValue(Action.SMALL_ICON, SparkRes.getImageIcon(SparkRes.MEGAPHONE_16x16));
// See if we should disable all "Broadcast" menu items
if (!Default.getBoolean("DISABLE_BROADCAST_MENU_ITEM")) popup.add(broadcastMessageAction);
popup.add(broadcastMessageAction);
}
}

View File

@ -36,6 +36,7 @@ import org.jivesoftware.spark.ui.ContactList;
import org.jivesoftware.spark.util.SwingWorker;
import org.jivesoftware.spark.util.UIComponentRegistry;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.plugin.manager.Enterprise;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
@ -157,7 +158,7 @@ public class ContactListAssistantPlugin implements Plugin {
}
// Clean up the extra separator if "Broadcast" menu items are disabled
if (!Default.getBoolean("DISABLE_BROADCAST_MENU_ITEM")) popup.addSeparator();
if (!Default.getBoolean("DISABLE_BROADCAST_MENU_ITEM") && Enterprise.containsFeature(Enterprise.BROADCAST_FEATURE)) popup.addSeparator();
}
}
}

View File

@ -215,10 +215,9 @@ public class VCardManager {
* Adds VCard capabilities to menus and other components in Spark.
*/
private void initializeUI() {
boolean enabled = Enterprise.containsFeature(Enterprise.VCARD_FEATURE);
if (!enabled) {
return;
}
// See if we should disable the "Edit my profile" option under "File"
if (Default.getBoolean("DISABLE_EDIT_PROFILE") || !Enterprise.containsFeature(Enterprise.VCARD_FEATURE)) return;
// Add Actions Menu
final JMenu contactsMenu = SparkManager.getMainWindow().getMenuByName(Res.getString("menuitem.contacts"));
@ -229,8 +228,7 @@ public class VCardManager {
int size = contactsMenu.getMenuComponentCount();
// See if we should disable the "Edit my profile" option under "File"
if (!Default.getBoolean("DISABLE_EDIT_PROFILE")) communicatorMenu.insert(editProfileMenu, 1);
communicatorMenu.insert(editProfileMenu, 1);
editProfileMenu.addActionListener( e -> {
SwingWorker vcardLoaderWorker = new SwingWorker() {