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.

cusax-fix
Damian Minkov 12 years ago
parent a9cd74ac92
commit b330917676

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

@ -12,6 +12,7 @@
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.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 void dispose()
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();
}
}
}

@ -58,16 +58,6 @@ public 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 KnownFingerprintsTableModel()
.getService(protocolProviderRefs[i]);
Iterator<MetaContact> metaContacts =
service.findAllMetaContactsForProvider(provider);
OtrActivator.getContactListService()
.findAllMetaContactsForProvider(provider);
while (metaContacts.hasNext())
{
MetaContact metaContact = metaContacts.next();

@ -8,6 +8,7 @@
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.*;
@ -95,6 +96,11 @@ public class OtrActivator
*/
public static UIService uiService;
/**
* The <tt>MetaContactListService</tt> reference.
*/
private static MetaContactListService metaCListService;
/**
* Gets an {@link AccountID} by its UID.
*
@ -422,4 +428,22 @@ public void stop(BundleContext bc) throws Exception
}
}
}
/**
* 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;
}
}

@ -14,6 +14,7 @@
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 void sessionStatusChanged(SessionID sessionID)
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 void sessionStatusChanged(SessionID sessionID)
});
}
/**
* 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)

Loading…
Cancel
Save