diff --git a/resources/images/impl/gui/buttons/chatVideoCall.png b/resources/images/impl/gui/buttons/chatVideoCall.png index 11e54ec2a..697e2578d 100644 Binary files a/resources/images/impl/gui/buttons/chatVideoCall.png and b/resources/images/impl/gui/buttons/chatVideoCall.png differ diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java index 1c63daf85..28c5c158a 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java @@ -185,7 +185,7 @@ protected void init() this.add(leaveChatRoomButton); this.add(callButton); -// this.add(callVideoButton); + this.add(callVideoButton); this.add(desktopSharingButton); this.add(sendFileButton); @@ -550,110 +550,11 @@ else if (buttonText.equals("leave")) } else if (buttonText.equals("call")) { - ChatSession chatSession = chatPanel.getChatSession(); - - List telTransports = null; - if (chatSession != null) - telTransports = chatSession - .getTransportsForOperationSet( - OperationSetBasicTelephony.class); - - List contactOpSetSupported = - getOperationSetForCapabilities(telTransports, - OperationSetBasicTelephony.class); - - MetaContact metaContact - = GuiActivator.getUIService().getChatContact(chatPanel); - - List phones - = CallManager.getAdditionalNumbers(metaContact); - - if (telTransports != null || phones.size() > 0) - { - if (contactOpSetSupported.size() == 1 && phones.size() == 0) - { - ChatTransport transport = contactOpSetSupported.get(0); - CallManager.createCall( - transport.getProtocolProvider(), - transport.getName()); - } - else if (contactOpSetSupported.size() == 0 - && phones.size() == 1) - { - UIContactDetail detail = phones.get(0); - - ProtocolProviderService preferredProvider - = detail.getPreferredProtocolProvider( - OperationSetBasicTelephony.class); - - List providers - = GuiActivator.getOpSetRegisteredProviders( - OperationSetBasicTelephony.class, - preferredProvider, - detail.getPreferredProtocol( - OperationSetBasicTelephony.class)); - - if (providers != null) - { - int providersCount = providers.size(); - - if (providersCount <= 0) - { - new ErrorDialog(null, - GuiActivator.getResources().getI18NString( - "service.gui.CALL_FAILED"), - GuiActivator.getResources().getI18NString( - "service.gui.NO_ONLINE_TELEPHONY_ACCOUNT")) - .showDialog(); - } - else if (providersCount == 1) - { - CallManager.createCall( - providers.get(0), detail.getAddress()); - } - else if (providersCount > 1) - { - ChooseCallAccountPopupMenu chooseAccountDialog = - new ChooseCallAccountPopupMenu( - callButton, detail.getAddress(), providers); - Point location = new Point(callButton.getX(), - callButton.getY() + callButton.getHeight()); - - SwingUtilities.convertPointToScreen( - location, this); - - chooseAccountDialog - .showPopupMenu(location.x, location.y); - } - } - } - else if ((contactOpSetSupported.size() + phones.size()) > 1) - { - List allContacts = new ArrayList(); - for(ChatTransport t : contactOpSetSupported) - { - allContacts.add(t); - } - for(UIContactDetail t : phones) - { - allContacts.add(t); - } - - ChooseCallAccountPopupMenu chooseAccountDialog - = new ChooseCallAccountPopupMenu( - callButton, - allContacts); - - Point location = new Point(callButton.getX(), - callButton.getY() + callButton.getHeight()); - - SwingUtilities.convertPointToScreen( - location, this); - - chooseAccountDialog - .showPopupMenu(location.x, location.y); - } - } + call(false); + } + else if (buttonText.equals("callVideo")) + { + call(true); } else if (buttonText.equals("desktop")) { @@ -873,4 +774,154 @@ public void detailsRetrieved(Iterator details) } } + /** + * Establishes a call. + * + * @param isVideo indicates if a video call should be established. + */ + private void call(boolean isVideo) + { + ChatPanel chatPanel = chatContainer.getCurrentChat(); + + ChatSession chatSession = chatPanel.getChatSession(); + + List telTransports = null; + if (chatSession != null) + telTransports = chatSession + .getTransportsForOperationSet( + OperationSetBasicTelephony.class); + + List contactOpSetSupported; + + if (isVideo) + contactOpSetSupported = + getOperationSetForCapabilities(telTransports, + OperationSetVideoTelephony.class); + else + contactOpSetSupported = + getOperationSetForCapabilities(telTransports, + OperationSetBasicTelephony.class); + + MetaContact metaContact + = GuiActivator.getUIService().getChatContact(chatPanel); + + List phones + = CallManager.getAdditionalNumbers(metaContact); + + if (telTransports != null || phones.size() > 0) + { + if (contactOpSetSupported.size() == 1 && phones.size() == 0) + { + ChatTransport transport = contactOpSetSupported.get(0); + if (isVideo) + CallManager.createVideoCall( + transport.getProtocolProvider(), + transport.getName()); + else + CallManager.createCall( + transport.getProtocolProvider(), + transport.getName()); + } + else if (contactOpSetSupported.size() == 0 + && phones.size() == 1) + { + UIContactDetail detail = phones.get(0); + + ProtocolProviderService preferredProvider + = detail.getPreferredProtocolProvider( + OperationSetBasicTelephony.class); + + List providers + = GuiActivator.getOpSetRegisteredProviders( + OperationSetBasicTelephony.class, + preferredProvider, + detail.getPreferredProtocol( + OperationSetBasicTelephony.class)); + + if (providers != null) + { + int providersCount = providers.size(); + + if (providersCount <= 0) + { + new ErrorDialog(null, + GuiActivator.getResources().getI18NString( + "service.gui.CALL_FAILED"), + GuiActivator.getResources().getI18NString( + "service.gui.NO_ONLINE_TELEPHONY_ACCOUNT")) + .showDialog(); + } + else if (providersCount == 1) + { + if (isVideo) + CallManager.createVideoCall( + providers.get(0), detail.getAddress()); + else + CallManager.createCall( + providers.get(0), detail.getAddress()); + } + else if (providersCount > 1) + { + ChooseCallAccountPopupMenu chooseAccountDialog; + + if (isVideo) + chooseAccountDialog = + new ChooseCallAccountPopupMenu( + callButton, detail.getAddress(), providers, + OperationSetVideoTelephony.class); + else + chooseAccountDialog = + new ChooseCallAccountPopupMenu( + callButton, detail.getAddress(), providers, + OperationSetBasicTelephony.class); + + Point location = new Point(callButton.getX(), + callButton.getY() + callButton.getHeight()); + + SwingUtilities.convertPointToScreen( + location, this); + + chooseAccountDialog + .showPopupMenu(location.x, location.y); + } + } + } + else if ((contactOpSetSupported.size() + phones.size()) > 1) + { + List allContacts = new ArrayList(); + for(ChatTransport t : contactOpSetSupported) + { + allContacts.add(t); + } + for(UIContactDetail t : phones) + { + allContacts.add(t); + } + + ChooseCallAccountPopupMenu chooseAccountDialog; + + if (isVideo) + chooseAccountDialog + = new ChooseCallAccountPopupMenu( + callButton, + allContacts, + OperationSetVideoTelephony.class); + else + chooseAccountDialog + = new ChooseCallAccountPopupMenu( + callButton, + allContacts, + OperationSetBasicTelephony.class); + + Point location = new Point(callButton.getX(), + callButton.getY() + callButton.getHeight()); + + SwingUtilities.convertPointToScreen( + location, this); + + chooseAccountDialog + .showPopupMenu(location.x, location.y); + } + } + } }