From c03769c3f5d591fae290700d280a417eb3bd68da Mon Sep 17 00:00:00 2001 From: Yana Stamcheva Date: Wed, 8 Aug 2007 14:45:00 +0000 Subject: [PATCH] choose automatically the selected telephony account depending on the selected contact - patch created by Symphorien --- .../impl/gui/main/call/CallManager.java | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) 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 812704d3a..d30d4b0f3 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 @@ -462,6 +462,21 @@ private Contact getTelephonyContact(MetaContact metaContact) return null; } + /** + * Returns the account selector box. + * + * @return the account selector box. + */ + public AccountSelectorBox getAccountSelectorBox() + { + return accountSelectorBox; + } + + /** + * Sets the protocol provider to use for a call. + * + * @param provider the protocol provider to use for a call. + */ public void setCallProvider(ProtocolProviderService provider) { this.selectedCallProvider = provider; @@ -592,7 +607,38 @@ public void valueChanged(ListSelectionEvent e) && (o instanceof MetaContact)) { setCallMetaContact(true); - callButton.setEnabled(true); + + // Switch automatically to the appropriate pps in account selector + // box and enable callButton if telephony is supported by one of + // accounts owning contact(s) enclosed in this metacontact. + MetaContact mContact = (MetaContact) o; + Iterator contacts = mContact.getContacts(); + boolean telephonySupported = false; + + while (contacts.hasNext()) + { + Contact contact = (Contact) contacts.next(); + ProtocolProviderService pps = contact.getProtocolProvider(); + + if (pps.getOperationSet(OperationSetBasicTelephony.class) + != null) + { + mainFrame.getCallManager().getAccountSelectorBox(). + setSelected(pps); + + telephonySupported = true; + break; + } + } + + if (telephonySupported) + { + callButton.setEnabled(true); + } + else + { + callButton.setEnabled(false); + } } else if (phoneNumberCombo.isComboFieldEmpty()) {