aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin/otr
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2013-09-24 09:49:46 +0300
committerDamian Minkov <damencho@jitsi.org>2013-09-24 09:49:46 +0300
commitb392f5e19158efc7add27fefa402bc33f558a883 (patch)
treebb032aeff87228120ee42bf23ab967e6fb97f01f /src/net/java/sip/communicator/plugin/otr
parent23dcb2536d35828a48555f71a8d860c2abc135ee (diff)
downloadjitsi-b392f5e19158efc7add27fefa402bc33f558a883.zip
jitsi-b392f5e19158efc7add27fefa402bc33f558a883.tar.gz
jitsi-b392f5e19158efc7add27fefa402bc33f558a883.tar.bz2
Adds PluginComponentFactory which is responsible for creating the PluginComponent, fixes the problem of adding multiple instances of the same plugin component on different panels (multi window chats).
Diffstat (limited to 'src/net/java/sip/communicator/plugin/otr')
-rw-r--r--src/net/java/sip/communicator/plugin/otr/OtrActivator.java42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/net/java/sip/communicator/plugin/otr/OtrActivator.java b/src/net/java/sip/communicator/plugin/otr/OtrActivator.java
index 5898f86..6038d9f 100644
--- a/src/net/java/sip/communicator/plugin/otr/OtrActivator.java
+++ b/src/net/java/sip/communicator/plugin/otr/OtrActivator.java
@@ -340,18 +340,20 @@ public class OtrActivator
containerFilter.put(Container.CONTAINER_ID,
Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.getID());
- bundleContext
- .registerService(PluginComponent.class.getName(),
- new OtrMetaContactMenu(
- Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU),
- containerFilter);
+ bundleContext.registerService(
+ PluginComponentFactory.class.getName(),
+ new OtrPluginComponentFactory(
+ Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU),
+ containerFilter);
// Register the chat window menu bar item.
containerFilter.put(Container.CONTAINER_ID,
Container.CONTAINER_CHAT_MENU_BAR.getID());
- bundleContext.registerService(PluginComponent.class.getName(),
- new OtrMetaContactMenu(Container.CONTAINER_CHAT_MENU_BAR),
+ bundleContext.registerService(
+ PluginComponentFactory.class.getName(),
+ new OtrPluginComponentFactory(
+ Container.CONTAINER_CHAT_MENU_BAR),
containerFilter);
// Register the chat button bar default-action-button.
@@ -359,8 +361,9 @@ public class OtrActivator
Container.CONTAINER_CHAT_TOOL_BAR.getID());
bundleContext.registerService(
- PluginComponent.class.getName(),
- new OtrMetaContactButton(Container.CONTAINER_CHAT_TOOL_BAR),
+ PluginComponentFactory.class.getName(),
+ new OtrPluginComponentFactory(
+ Container.CONTAINER_CHAT_TOOL_BAR),
containerFilter);
// Register Swing OTR action handler
@@ -369,8 +372,6 @@ public class OtrActivator
new SwingOtrActionHandler(), null);
}
-
-
// If the general configuration form is disabled don't register it.
if (!configService.getBoolean(OTR_CHAT_CONFIG_DISABLED_PROP, false)
&& !OSUtils.IS_ANDROID)
@@ -446,4 +447,23 @@ public class OtrActivator
}
return metaCListService;
}
+
+ /**
+ * The factory that will be registered in OSGi and will create
+ * otr menu instances.
+ */
+ private class OtrPluginComponentFactory
+ extends PluginComponentFactory
+ {
+ OtrPluginComponentFactory(Container c)
+ {
+ super(c);
+ }
+
+ @Override
+ protected PluginComponent getPluginInstance()
+ {
+ return new OtrMetaContactMenu(getContainer());
+ }
+ }
}