diff options
author | Damian Minkov <damencho@jitsi.org> | 2013-09-11 17:50:11 +0300 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2013-09-11 17:50:11 +0300 |
commit | b330917676268bbcf498f63b971dabff32eaa6ac (patch) | |
tree | a5cf70469364fbc4d4ffd85fca72c1f567016b12 | |
parent | a9cd74ac92b2ea61e805b4cfd2ad8e10450dce1b (diff) | |
download | jitsi-b330917676268bbcf498f63b971dabff32eaa6ac.zip jitsi-b330917676268bbcf498f63b971dabff32eaa6ac.tar.gz jitsi-b330917676268bbcf498f63b971dabff32eaa6ac.tar.bz2 |
Adds message when otr session is enabled whether chat logging history is on or off and an option to open menu to change this settings.
5 files changed, 100 insertions, 11 deletions
diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties index e17968e..afe6b33 100644 --- a/resources/languages/resources.properties +++ b/resources/languages/resources.properties @@ -1541,6 +1541,8 @@ plugin.otr.activator.unverifiedsessionstared=<b>Unverified</b> private conversat plugin.otr.activator.sessionstared=Private conversation with {0} started. plugin.otr.activator.sessionfinished={0} has ended his/her private conversation with you; you should do the same. plugin.otr.activator.sessionlost=Private conversation with {0} lost. +plugin.otr.activator.historyon={0} is recording this conversation on your device. You can <A href=\"jitsi://{1}/{2}\">turn off chat history here</a>. +plugin.otr.activator.historyoff={0} is NOT recording this conversation. You can <A href=\"jitsi://{1}/{2}\">activate chat history here</a>. # global proxy plugin plugin.globalproxy.GLOBAL_PROXY_CONFIG=Global Proxy diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/HistorySelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/HistorySelectorBox.java index f87d641..21a5786 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/HistorySelectorBox.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/HistorySelectorBox.java @@ -12,6 +12,7 @@ import net.java.sip.communicator.impl.gui.main.chat.history.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; import net.java.sip.communicator.service.contactlist.*; +import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.msghistory.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.skin.*; @@ -22,6 +23,7 @@ import java.awt.*; import java.awt.event.*; import java.beans.*; import java.io.*; +import java.net.*; /** * The <tt>HistorySelectorBox</tt> is the component where user could choose a @@ -35,6 +37,7 @@ public class HistorySelectorBox implements ActionListener, PropertyChangeListener, ChatChangeListener, + ChatLinkClickedListener, Skinnable { /** @@ -346,5 +349,20 @@ public class HistorySelectorBox public void chatChanged(ChatPanel panel) { changeHistoryIcon(); + + panel.addChatLinkClickedListener(this); + } + + /** + * If a link is clicked with certain action to open the history popup menu. + * @param url The URI of the link that was clicked. + */ + @Override + public void chatLinkClicked(URI url) + { + if(url.getPath().equals("/showHistoryPopupMenu")) + { + this.doClick(); + } } } diff --git a/src/net/java/sip/communicator/plugin/otr/KnownFingerprintsTableModel.java b/src/net/java/sip/communicator/plugin/otr/KnownFingerprintsTableModel.java index becc4a5..c158d0f 100644 --- a/src/net/java/sip/communicator/plugin/otr/KnownFingerprintsTableModel.java +++ b/src/net/java/sip/communicator/plugin/otr/KnownFingerprintsTableModel.java @@ -58,16 +58,6 @@ public class KnownFingerprintsTableModel || protocolProviderRefs.length < 1) return; - // Get the metacontactlist service. - ServiceReference ref = - OtrActivator.bundleContext - .getServiceReference(MetaContactListService.class - .getName()); - - MetaContactListService service - = (MetaContactListService) OtrActivator - .bundleContext.getService(ref); - // Populate contacts. for (int i = 0; i < protocolProviderRefs.length; i++) { @@ -77,7 +67,8 @@ public class KnownFingerprintsTableModel .getService(protocolProviderRefs[i]); Iterator<MetaContact> metaContacts = - service.findAllMetaContactsForProvider(provider); + OtrActivator.getContactListService() + .findAllMetaContactsForProvider(provider); while (metaContacts.hasNext()) { MetaContact metaContact = metaContacts.next(); diff --git a/src/net/java/sip/communicator/plugin/otr/OtrActivator.java b/src/net/java/sip/communicator/plugin/otr/OtrActivator.java index 3b10939..5898f86 100644 --- a/src/net/java/sip/communicator/plugin/otr/OtrActivator.java +++ b/src/net/java/sip/communicator/plugin/otr/OtrActivator.java @@ -8,6 +8,7 @@ package net.java.sip.communicator.plugin.otr; import java.util.*; +import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; @@ -96,6 +97,11 @@ public class OtrActivator public static UIService uiService; /** + * The <tt>MetaContactListService</tt> reference. + */ + private static MetaContactListService metaCListService; + + /** * Gets an {@link AccountID} by its UID. * * @param uid The {@link AccountID} UID. @@ -422,4 +428,22 @@ public class OtrActivator } } } + + /** + * Returns the <tt>MetaContactListService</tt> obtained from the bundle + * context. + * @return the <tt>MetaContactListService</tt> obtained from the bundle + * context + */ + public static MetaContactListService getContactListService() + { + if (metaCListService == null) + { + metaCListService + = ServiceUtils.getService( + bundleContext, + MetaContactListService.class); + } + return metaCListService; + } } diff --git a/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java b/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java index 8ddc98e..7c23559 100644 --- a/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java +++ b/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java @@ -14,6 +14,7 @@ import net.java.otr4j.*; import net.java.otr4j.session.*;
import net.java.sip.communicator.service.browserlauncher.*;
+import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
@@ -208,6 +209,42 @@ public class ScOtrEngineImpl OperationSetBasicInstantMessaging.HTML_MIME_TYPE);
}
+
+ // show info whether history is on or off
+ String otrAndHistoryMessage;
+ if(!ConfigurationUtils.isHistoryLoggingEnabled()
+ || !isHistoryLoggingEnabled(contact))
+ {
+ otrAndHistoryMessage =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.historyoff",
+ new String[]{
+ OtrActivator.resourceService
+ .getSettingsString(
+ "service.gui.APPLICATION_NAME"),
+ this.getClass().getName(),
+ "showHistoryPopupMenu"
+ });
+ }
+ else
+ {
+ otrAndHistoryMessage =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.historyon",
+ new String[]{
+ OtrActivator.resourceService
+ .getSettingsString(
+ "service.gui.APPLICATION_NAME"),
+ this.getClass().getName(),
+ "showHistoryPopupMenu"
+ });
+ }
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(),
+ new Date(), Chat.SYSTEM_MESSAGE,
+ otrAndHistoryMessage,
+ OperationSetBasicInstantMessaging.HTML_MIME_TYPE);
+
message
= OtrActivator.resourceService.getI18NString(
OtrActivator.scOtrKeyManager.isVerified(contact)
@@ -243,6 +280,23 @@ public class ScOtrEngineImpl });
}
+ /**
+ * Checks whether history is enabled for the metacontact containing
+ * the <tt>contact</tt>.
+ * @param contact the contact to check.
+ * @return whether chat logging is enabled while chatting
+ * with <tt>contact</tt>.
+ */
+ private boolean isHistoryLoggingEnabled(Contact contact)
+ {
+ MetaContact metaContact = OtrActivator
+ .getContactListService().findMetaContactByContact(contact);
+ if(metaContact != null)
+ return ConfigurationUtils.isHistoryLoggingEnabled(metaContact);
+ else
+ return true;
+ }
+
public void addListener(ScOtrEngineListener l)
{
synchronized (listeners)
|