From bfc74c885e37b37f0050e2b50f2d405e82136f2f Mon Sep 17 00:00:00 2001 From: wroot Date: Sat, 10 Oct 2015 14:35:23 +0300 Subject: [PATCH] Option to force disabling history https://igniterealtime.org/issues/browse/SPARK-1436 --- src/java/org/jivesoftware/resource/Default.java | 1 + src/java/org/jivesoftware/resource/default.properties | 6 +++++- src/java/org/jivesoftware/spark/ui/rooms/ChatRoomImpl.java | 3 ++- .../sparkimpl/plugin/transcripts/ChatTranscriptPlugin.java | 5 +++++ .../sparkimpl/plugin/transcripts/ChatTranscripts.java | 3 +++ .../sparkimpl/preference/chat/ChatPreferencePanel.java | 2 ++ 6 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/java/org/jivesoftware/resource/Default.java b/src/java/org/jivesoftware/resource/Default.java index a48a3973..9cd4ea1b 100644 --- a/src/java/org/jivesoftware/resource/Default.java +++ b/src/java/org/jivesoftware/resource/Default.java @@ -101,6 +101,7 @@ public class Default { public static final String USER_DIRECTORY_MAC = "USER_DIRECTORY_MAC"; public static final String HOSTNAME_AS_RESOURCE = "HOSTNAME_AS_RESOURCE"; public static final String VERSION_AS_RESOURCE = "VERSION_AS_RESOURCE"; + public static final String HISTORY_DISABLED = "HISTORY_DISABLED"; static ClassLoader cl = SparkRes.class.getClassLoader(); diff --git a/src/java/org/jivesoftware/resource/default.properties b/src/java/org/jivesoftware/resource/default.properties index 60d908c8..cd719c2e 100644 --- a/src/java/org/jivesoftware/resource/default.properties +++ b/src/java/org/jivesoftware/resource/default.properties @@ -8,7 +8,7 @@ APPLICATION_NAME = Spark SHORT_NAME = Spark ############# Auto Set During Build ############# -APPLICATION_VERSION = 2.7.1 +APPLICATION_VERSION = 2.7.2 # Passed into ant via cmd line argument: # -Dbuild.number= # If not passed in, this field is ignored. @@ -46,6 +46,10 @@ ADVANCED_DISABLED = HOSTNAME_AS_RESOURCE = false VERSION_AS_RESOURCE = false +# When enabled it removes history from the chat window and doesn't save history into transcript files. Also removes history +# settings from the preferences, removes history button from the chat window and contact's history context menu. +HISTORY_DISABLED = false + #If Advanded preferences is enabled you are able to remove tabs, except the "General" tab #Removes SSO Tab SSO_DISABLED = false diff --git a/src/java/org/jivesoftware/spark/ui/rooms/ChatRoomImpl.java b/src/java/org/jivesoftware/spark/ui/rooms/ChatRoomImpl.java index 5a451aee..61f7d405 100644 --- a/src/java/org/jivesoftware/spark/ui/rooms/ChatRoomImpl.java +++ b/src/java/org/jivesoftware/spark/ui/rooms/ChatRoomImpl.java @@ -735,7 +735,7 @@ public class ChatRoomImpl extends ChatRoom { vcardPanel = new VCardPanel(participantJID); getToolBar().add(vcardPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 2, 0, 2), 0, 0)); - + if (!Default.getBoolean("HISTORY_DISABLED")) { final LocalPreferences localPreferences = SettingsManager.getLocalPreferences(); if (!localPreferences.isChatHistoryEnabled()) { return; @@ -782,6 +782,7 @@ public class ChatRoomImpl extends ChatRoom { } chatTranscript.release(); } + } private boolean isOnline() { Presence presence = roster.getPresence(getParticipantJID()); diff --git a/src/java/org/jivesoftware/sparkimpl/plugin/transcripts/ChatTranscriptPlugin.java b/src/java/org/jivesoftware/sparkimpl/plugin/transcripts/ChatTranscriptPlugin.java index 23196dab..10184b94 100644 --- a/src/java/org/jivesoftware/sparkimpl/plugin/transcripts/ChatTranscriptPlugin.java +++ b/src/java/org/jivesoftware/sparkimpl/plugin/transcripts/ChatTranscriptPlugin.java @@ -40,6 +40,7 @@ import javax.swing.JScrollPane; import javax.swing.JTextArea; import org.jivesoftware.MainWindowListener; +import org.jivesoftware.resource.Default; import org.jivesoftware.resource.Res; import org.jivesoftware.resource.SparkRes; import org.jivesoftware.smack.ConnectionListener; @@ -111,7 +112,9 @@ public class ChatTranscriptPlugin implements ChatRoomListener { contactList.addContextMenuListener(new ContextMenuListener() { public void poppingUp(Object object, JPopupMenu popup) { if (object instanceof ContactItem) { + if (!Default.getBoolean("HISTORY_DISABLED")) { popup.add(viewHistoryAction); + } popup.add(showStatusMessageAction); } } @@ -331,7 +334,9 @@ public class ChatTranscriptPlugin implements ChatRoomListener { return; } chatHistoryButton = UIComponentRegistry.getButtonFactory().createChatTranscriptButton(); + if (!Default.getBoolean("HISTORY_DISABLED")) { chatRoom.addChatRoomButton(chatHistoryButton); + } chatHistoryButton.setToolTipText(Res.getString("tooltip.view.history")); chatHistoryButton.addActionListener(this); } diff --git a/src/java/org/jivesoftware/sparkimpl/plugin/transcripts/ChatTranscripts.java b/src/java/org/jivesoftware/sparkimpl/plugin/transcripts/ChatTranscripts.java index e6d9bcd9..6943ba13 100644 --- a/src/java/org/jivesoftware/sparkimpl/plugin/transcripts/ChatTranscripts.java +++ b/src/java/org/jivesoftware/sparkimpl/plugin/transcripts/ChatTranscripts.java @@ -19,6 +19,7 @@ */ package org.jivesoftware.sparkimpl.plugin.transcripts; +import org.jivesoftware.resource.Default; import org.jivesoftware.spark.SparkManager; import org.jivesoftware.spark.UserManager; import org.jivesoftware.spark.util.StringUtils; @@ -71,6 +72,7 @@ public final class ChatTranscripts { public static void appendToTranscript(String jid, ChatTranscript transcript) { final File transcriptFile = getTranscriptFile(jid); + if (!Default.getBoolean("HISTORY_DISABLED")) { // Write Full Transcript, appending the messages. writeToFile(transcriptFile, transcript.getMessages(), true); @@ -81,6 +83,7 @@ public final class ChatTranscripts { tempTranscript.addHistoryMessage(message); } writeToFile(currentHistoryFile, tempTranscript.getNumberOfEntries(20), false); + } } private static void writeToFile(File transcriptFile, Collection messages, boolean append) { diff --git a/src/java/org/jivesoftware/sparkimpl/preference/chat/ChatPreferencePanel.java b/src/java/org/jivesoftware/sparkimpl/preference/chat/ChatPreferencePanel.java index fc0d3091..2f6d065c 100644 --- a/src/java/org/jivesoftware/sparkimpl/preference/chat/ChatPreferencePanel.java +++ b/src/java/org/jivesoftware/sparkimpl/preference/chat/ChatPreferencePanel.java @@ -135,8 +135,10 @@ public class ChatPreferencePanel extends JPanel implements ActionListener { chatWindowPanel.add(format12s, new GridBagConstraints(2, 1, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); chatWindowPanel.add(groupChatNotificationBox, new GridBagConstraints(0, 2, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); + if (!Default.getBoolean("HISTORY_DISABLED")) { chatWindowPanel.add(hideChatHistory, new GridBagConstraints(0, 3, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); chatWindowPanel.add(hidePrevChatHistory, new GridBagConstraints(0, 4, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); + } chatWindowPanel.add(sortChatHistoryAscending, new GridBagConstraints(0, 5, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); chatWindowPanel.add(tabsOnTopBox, new GridBagConstraints(0, 6, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); chatWindowPanel.add(buzzBox, new GridBagConstraints(0, 7, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));