aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin/otr/OtrActivator.java
diff options
context:
space:
mode:
authorGeorge Politis <666f6f@java.net>2009-09-06 15:13:29 +0000
committerGeorge Politis <666f6f@java.net>2009-09-06 15:13:29 +0000
commite2974c6817103f85d8542809a20eede9db8d5142 (patch)
tree145551f100b9bf8d44a68842fdfcab878446b24d /src/net/java/sip/communicator/plugin/otr/OtrActivator.java
parent55b0e3520af51d7324abf24d2a88879d2b894b25 (diff)
downloadjitsi-e2974c6817103f85d8542809a20eede9db8d5142.zip
jitsi-e2974c6817103f85d8542809a20eede9db8d5142.tar.gz
jitsi-e2974c6817103f85d8542809a20eede9db8d5142.tar.bz2
Moved key management functionality from ScOtrEngineImpl to ScOtrKeyManager (new). Updated otr4j@112
Diffstat (limited to 'src/net/java/sip/communicator/plugin/otr/OtrActivator.java')
-rw-r--r--src/net/java/sip/communicator/plugin/otr/OtrActivator.java78
1 files changed, 61 insertions, 17 deletions
diff --git a/src/net/java/sip/communicator/plugin/otr/OtrActivator.java b/src/net/java/sip/communicator/plugin/otr/OtrActivator.java
index 68c8f4a..b1f8b49 100644
--- a/src/net/java/sip/communicator/plugin/otr/OtrActivator.java
+++ b/src/net/java/sip/communicator/plugin/otr/OtrActivator.java
@@ -19,16 +19,16 @@ import org.osgi.framework.*;
* @author George Politis
*/
public class OtrActivator
- implements BundleActivator,
- ServiceListener
+ implements BundleActivator, ServiceListener
{
-
public static BundleContext bundleContext;
private OtrTransformLayer otrTransformLayer;
public static ScOtrEngine scOtrEngine;
+ public static ScOtrKeyManager scOtrKeyManager = new ScOtrKeyManagerImpl();
+
public static ResourceManagementService resourceService;
public static UIService uiService;
@@ -45,8 +45,8 @@ public class OtrActivator
scOtrEngine = new ScOtrEngineImpl();
otrTransformLayer = new OtrTransformLayer();
- resourceService
- = ResourceManagementServiceUtils
+ resourceService =
+ ResourceManagementServiceUtils
.getService(OtrActivator.bundleContext);
if (resourceService == null)
return;
@@ -94,9 +94,9 @@ public class OtrActivator
+ " already installed providers.");
for (ServiceReference protocolProviderRef : protocolProviderRefs)
{
- ProtocolProviderService provider
- = (ProtocolProviderService)
- bundleContext.getService(protocolProviderRef);
+ ProtocolProviderService provider =
+ (ProtocolProviderService) bundleContext
+ .getService(protocolProviderRef);
this.handleProviderAdded(provider);
}
@@ -189,9 +189,9 @@ public class OtrActivator
// in case we found any
for (ServiceReference protocolProviderRef : protocolProviderRefs)
{
- ProtocolProviderService provider
- = (ProtocolProviderService)
- bundleContext.getService(protocolProviderRef);
+ ProtocolProviderService provider =
+ (ProtocolProviderService) bundleContext
+ .getService(protocolProviderRef);
this.handleProviderRemoved(provider);
}
@@ -250,7 +250,52 @@ public class OtrActivator
}
- public static Map<Object, ProtocolProviderFactory> getProtocolProviderFactories()
+ public static List<AccountID> getAllAccountIDs()
+ {
+ Map<Object, ProtocolProviderFactory> providerFactoriesMap =
+ OtrActivator.getProtocolProviderFactories();
+
+ if (providerFactoriesMap == null)
+ return null;
+
+ List<AccountID> accountIDs = new Vector<AccountID>();
+ for (ProtocolProviderFactory providerFactory : providerFactoriesMap
+ .values())
+ {
+ for (AccountID accountID : providerFactory.getRegisteredAccounts())
+ {
+ accountIDs.add(accountID);
+ }
+ }
+
+ return accountIDs;
+ }
+
+ public static AccountID getAccountIDByUID(String uid)
+ {
+ if (uid == null || uid.length() < 1)
+ return null;
+
+ Map<Object, ProtocolProviderFactory> providerFactoriesMap =
+ OtrActivator.getProtocolProviderFactories();
+
+ if (providerFactoriesMap == null)
+ return null;
+
+ for (ProtocolProviderFactory providerFactory : providerFactoriesMap
+ .values())
+ {
+ for (AccountID accountID : providerFactory.getRegisteredAccounts())
+ {
+ if (accountID.getAccountUniqueID().equals(uid))
+ return accountID;
+ }
+ }
+
+ return null;
+ }
+
+ private static Map<Object, ProtocolProviderFactory> getProtocolProviderFactories()
{
ServiceReference[] serRefs = null;
try
@@ -273,12 +318,11 @@ public class OtrActivator
{
for (ServiceReference serRef : serRefs)
{
- ProtocolProviderFactory providerFactory
- = (ProtocolProviderFactory)
- bundleContext.getService(serRef);
+ ProtocolProviderFactory providerFactory =
+ (ProtocolProviderFactory) bundleContext.getService(serRef);
- providerFactoriesMap.put(
- serRef.getProperty(ProtocolProviderFactory.PROTOCOL),
+ providerFactoriesMap.put(serRef
+ .getProperty(ProtocolProviderFactory.PROTOCOL),
providerFactory);
}
}