diff --git a/src/net/java/sip/communicator/impl/gui/GuiActivator.java b/src/net/java/sip/communicator/impl/gui/GuiActivator.java index f0b8a1634..3b06aef9d 100644 --- a/src/net/java/sip/communicator/impl/gui/GuiActivator.java +++ b/src/net/java/sip/communicator/impl/gui/GuiActivator.java @@ -290,6 +290,86 @@ public static ProtocolProviderService getRegisteredProviderForAccount( return null; } + /** + * Returns a list of all currently registered telephony providers for the + * given protocol name. + * @param protocolName the protocol name + * @param operationSetClass the operation set class for which we're looking + * for providers + * @return a list of all currently registered providers for the given + * protocolName and supporting the given operationSetClass + */ + public static List getRegisteredProviders( + String protocolName, Class operationSetClass) + { + List opSetProviders + = new LinkedList(); + + ProtocolProviderFactory providerFactory + = GuiActivator.getProtocolProviderFactory(protocolName); + + if (providerFactory != null) + { + ServiceReference serRef; + ProtocolProviderService protocolProvider; + + for (AccountID accountID : providerFactory.getRegisteredAccounts()) + { + serRef = providerFactory.getProviderForAccount(accountID); + + protocolProvider + = (ProtocolProviderService) GuiActivator.bundleContext + .getService(serRef); + + if (protocolProvider.getOperationSet(operationSetClass) != null + && protocolProvider.isRegistered()) + { + opSetProviders.add(protocolProvider); + } + } + } + return opSetProviders; + } + + /** + * Returns a list of all currently registered providers, which support the + * given operationSetClass. + * + * @param opSetClass the operation set class for which we're looking + * for providers + * @return a list of all currently registered providers, which support the + * given operationSetClass + */ + public static List getRegisteredProviders( + Class opSetClass) + { + List opSetProviders + = new LinkedList(); + + for (ProtocolProviderFactory providerFactory : GuiActivator + .getProtocolProviderFactories().values()) + { + ServiceReference serRef; + ProtocolProviderService protocolProvider; + + for (AccountID accountID : providerFactory.getRegisteredAccounts()) + { + serRef = providerFactory.getProviderForAccount(accountID); + + protocolProvider + = (ProtocolProviderService) GuiActivator.bundleContext + .getService(serRef); + + if (protocolProvider.getOperationSet(opSetClass) != null + && protocolProvider.isRegistered()) + { + opSetProviders.add(protocolProvider); + } + } + } + return opSetProviders; + } + /** * Returns the AccountManager obtained from the bundle context. * @return the AccountManager obtained from the bundle context diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java index 6dae186a1..b2a46216f 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java @@ -630,73 +630,8 @@ private static CallPanel openCallContainer(Call call) */ public static List getTelephonyProviders() { - List telephonyProviders - = new LinkedList(); - - for (ProtocolProviderFactory providerFactory : GuiActivator - .getProtocolProviderFactories().values()) - { - ServiceReference serRef; - ProtocolProviderService protocolProvider; - - for (AccountID accountID : providerFactory.getRegisteredAccounts()) - { - serRef = providerFactory.getProviderForAccount(accountID); - - protocolProvider - = (ProtocolProviderService) GuiActivator.bundleContext - .getService(serRef); - - if (protocolProvider.getOperationSet( - OperationSetBasicTelephony.class) != null - && protocolProvider.isRegistered()) - { - telephonyProviders.add(protocolProvider); - } - } - } - return telephonyProviders; - } - - /** - * Returns a list of all currently registered telephony providers for the - * given protocol name. - * @param protocolName the protocol name - * @param operationSetClass the operation set class for which we're looking - * for providers - * @return a list of all currently registered providers for the given - * protocolName and supporting the given operationSetClass - */ - public static List getRegisteredProviders( - String protocolName, Class operationSetClass) - { - List telephonyProviders - = new LinkedList(); - - ProtocolProviderFactory providerFactory - = GuiActivator.getProtocolProviderFactory(protocolName); - - if (providerFactory != null) - { - ServiceReference serRef; - ProtocolProviderService protocolProvider; - - for (AccountID accountID : providerFactory.getRegisteredAccounts()) - { - serRef = providerFactory.getProviderForAccount(accountID); - - protocolProvider - = (ProtocolProviderService) GuiActivator.bundleContext - .getService(serRef); - - if (protocolProvider.getOperationSet(operationSetClass) != null - && protocolProvider.isRegistered()) - { - telephonyProviders.add(protocolProvider); - } - } - } - return telephonyProviders; + return GuiActivator + .getRegisteredProviders(OperationSetBasicTelephony.class); } /** diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java index ba03c7172..df525647f 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java @@ -853,8 +853,9 @@ private void call(TreeNode treeNode) else { protocolName = preferredProvider.getProtocolName(); - providers = CallManager.getRegisteredProviders(protocolName, - OperationSetBasicTelephony.class); + providers + = GuiActivator.getRegisteredProviders(protocolName, + OperationSetBasicTelephony.class); } } // If we don't have a preferred provider we try to obtain a @@ -863,9 +864,16 @@ private void call(TreeNode treeNode) { protocolName = detail .getPreferredProtocol(OperationSetBasicTelephony.class); - providers - = CallManager.getRegisteredProviders(protocolName, - OperationSetBasicTelephony.class); + + if (protocolName != null) + providers + = GuiActivator.getRegisteredProviders(protocolName, + OperationSetBasicTelephony.class); + // If the protocol name is null we simply obtain all telephony + // providers. + else + providers + = CallManager.getTelephonyProviders(); } // If our call didn't succeed, try to call through one of the other @@ -950,7 +958,7 @@ private void callVideo(TreeNode treeNode) else { protocolName = preferredProvider.getProtocolName(); - providers = CallManager.getRegisteredProviders(protocolName, + providers = GuiActivator.getRegisteredProviders(protocolName, OperationSetVideoTelephony.class); } } @@ -960,9 +968,15 @@ private void callVideo(TreeNode treeNode) { protocolName = detail .getPreferredProtocol(OperationSetVideoTelephony.class); - providers - = CallManager.getRegisteredProviders(protocolName, - OperationSetVideoTelephony.class); + + if (protocolName != null) + providers + = GuiActivator.getRegisteredProviders(protocolName, + OperationSetVideoTelephony.class); + else + providers + = GuiActivator.getRegisteredProviders( + OperationSetVideoTelephony.class); } // If our call didn't succeed, try to call through one of the other @@ -1051,8 +1065,9 @@ private void shareDesktop(TreeNode treeNode) else { protocolName = preferredProvider.getProtocolName(); - providers = CallManager.getRegisteredProviders(protocolName, - OperationSetDesktopSharingServer.class); + providers + = GuiActivator.getRegisteredProviders(protocolName, + OperationSetDesktopSharingServer.class); } } // If we don't have a preferred provider we try to obtain a @@ -1061,9 +1076,15 @@ private void shareDesktop(TreeNode treeNode) { protocolName = detail.getPreferredProtocol( OperationSetDesktopSharingServer.class); - providers - = CallManager.getRegisteredProviders(protocolName, - OperationSetDesktopSharingServer.class); + + if (protocolName != null) + providers + = GuiActivator.getRegisteredProviders(protocolName, + OperationSetDesktopSharingServer.class); + else + providers + = GuiActivator.getRegisteredProviders( + OperationSetDesktopSharingServer.class); } // If our call didn't succeed, try to call through one of the other