Option to force disabling history

https://igniterealtime.org/issues/browse/SPARK-1436
This commit is contained in:
wroot
2015-10-10 14:35:23 +03:00
parent 7b985b5d16
commit bfc74c885e
6 changed files with 18 additions and 2 deletions

View File

@ -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();

View File

@ -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=<build 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

View File

@ -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());

View File

@ -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);
}

View File

@ -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<HistoryMessage> messages, boolean append) {

View File

@ -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));