From 40dd0838f64469b76030a7570f5c161f6ac368c9 Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Wed, 26 Sep 2012 22:03:06 +0000 Subject: [PATCH] Adds a video call button in the chat window. --- .../images/impl/gui/buttons/chatVideoCall.png | Bin 859 -> 1473 bytes .../gui/main/chat/toolBars/MainToolBar.java | 261 +++++++++++------- 2 files changed, 156 insertions(+), 105 deletions(-) diff --git a/resources/images/impl/gui/buttons/chatVideoCall.png b/resources/images/impl/gui/buttons/chatVideoCall.png index 11e54ec2a42e1e989a8732396943cc25c5b909d2..697e2578d62f9ca5874dc11178470b58fa1b05b0 100644 GIT binary patch literal 1473 zcmeAS@N?(olHy`uVBq!ia0vp^vLMXC1|-8Kr}G0T$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWuD@%o&*>5hW46K32*3xq68pHF_1f1wh>l3^w)^1&PVosU-?Y zsp*+{wo31J?^jaDOtDo8H}y5}EpSfF$n>ZxN)4{^3rViZPPR-@vbR&PsjvbXkegbP zs8ErclUHn2VXFi-*9yo63F|8KW+g=7RhMR$W{Yl!|Z$R@KEJl?AE#L8-<0 zrA5iW_()TRX$FQJev3c~fv&OgFUkZ)N@9*nesXDUYF>$_i>(q+MlU5Z#mddx+|AI? z+{D1#$iU3P(9qJ=z|qCf$<@it+1$+0(Gq3`HoX?6juxg)W^QiI#*T)Du7*xd7M702 zW=<|{&MpR~rbaNmo_WP3iFwJXFncqB_Coc#;?-;AT$Gwvl3x^(pPvIu0Rb8LCHch} z`2`Bj!Db2?zKO}1c_0BzPy|8z>ylcOS(cjOR+OKs01jcROe`)iG&cY`*VWm;4dQbP z0}EqER|{h^17k-sXF~%esNNKELQNm&7=2LkKuRt!Az&H=G2w|H$bn~{)I4CGDFSAW zi90S|Vqjo=@9E+gQgQ3ew6k7^9R!YV{@LgIYUL&G{zu*%ZSz?8Ynl9=_~U9={O?`) ze!};o;;ngGUMzKg>8qo-b?vj;k~gl+Saz0eRZ~hrWR%(O*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0d;li^;JWTN z03C%wVGY1)IZe+wY;JBo@_ip9mFIbzp67ifX_u2jL{94K>j#xm5dgGHJ>}*~Y95(TV?b+tQbTTqlBr=BH^M$@(lppq zEiEmNM@B}vP196CMkGrgj~swI#kJd8TU)EGt$(f0NH&#YY}UY3+qT^gpubY)Aw<&Y z^m 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); + } + } + } }