diff --git a/src/net/java/sip/communicator/impl/gui/main/CallPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java
similarity index 56%
rename from src/net/java/sip/communicator/impl/gui/main/CallPanel.java
rename to src/net/java/sip/communicator/impl/gui/main/call/CallManager.java
index 7a004e302..a38e5af78 100644
--- a/src/net/java/sip/communicator/impl/gui/main/CallPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/call/CallManager.java
@@ -4,14 +4,19 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
-package net.java.sip.communicator.impl.gui.main;
+package net.java.sip.communicator.impl.gui.main.call;
import java.awt.*;
import java.awt.event.*;
+import java.util.*;
+
import javax.swing.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
+import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.utils.*;
+import net.java.sip.communicator.service.contactlist.*;
+import net.java.sip.communicator.service.protocol.*;
/**
* The CallPanel is the panel that contains the "Call" and "Hangup"
@@ -21,7 +26,7 @@
* @author Yana Stamcheva
*/
-public class CallPanel
+public class CallManager
extends JPanel
implements ActionListener
{
@@ -52,7 +57,9 @@ public class CallPanel
private JPanel minimizeButtonPanel = new JPanel(new FlowLayout(
FlowLayout.RIGHT));
- private MainFrame parentWindow;
+ private MainFrame mainFrame;
+
+ private Hashtable activeCalls = new Hashtable();
private boolean isShown;
@@ -60,11 +67,11 @@ public class CallPanel
* Creates an instance of CallPanel.
* @param parentWindow The main application window.
*/
- public CallPanel(MainFrame parentWindow)
+ public CallManager(MainFrame mainFrame)
{
super(new BorderLayout());
- this.parentWindow = parentWindow;
+ this.mainFrame = mainFrame;
this.buttonsPanel
.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
@@ -97,11 +104,7 @@ private void init()
this.buttonsPanel.add(callButton);
this.buttonsPanel.add(hangupButton);
- this.add(minimizeButtonPanel, BorderLayout.SOUTH);
-
- // Disable all unused buttons.
- this.callButton.setEnabled(false);
- this.hangupButton.setEnabled(false);
+ this.add(minimizeButtonPanel, BorderLayout.SOUTH);
}
/**
@@ -123,12 +126,48 @@ public void actionPerformed(ActionEvent e)
String buttonName = button.getName();
if (buttonName.equalsIgnoreCase("call")) {
- CallReceivePanel cr = new CallReceivePanel(this.parentWindow);
-
- cr.setVisible(true);
+ OperationSetBasicTelephony telephony;
+
+ Object o = mainFrame.getContactListPanel()
+ .getContactList().getSelectedValue();
+
+ if(o != null && o instanceof MetaContact) {
+ MetaContact metaContact
+ = (MetaContact)o;
+
+ Contact contact
+ = getTelephonyContact(metaContact);
+
+ if(contact != null) {
+ telephony
+ = mainFrame.getTelephony(contact.getProtocolProvider());
+
+ Call createdCall = telephony.createCall(contact);
+ CallPanel callPanel = new CallPanel(createdCall);
+ mainFrame.addCallPanel(callPanel);
+
+ activeCalls.put(createdCall, callPanel);
+ }
+ else {
+ //Message to user which says "This contact could not be called!"
+ }
+ }
+ else if(phoneNumberCombo.getSelectedItem() != null) {
+ ProtocolProviderService pps
+ = getDefaultTelephonyProvider();
+
+ if(pps != null) {
+ telephony = mainFrame.getTelephony(pps);
+ telephony.createCall(
+ phoneNumberCombo.getSelectedItem().toString());
+ }
+ }
+ else {
+ //Message to user which says "You must select a contact to call or enter a phone number"
+ }
}
else if (buttonName.equalsIgnoreCase("hangup")) {
-
+
}
else if (buttonName.equalsIgnoreCase("minimize")) {
@@ -139,10 +178,10 @@ else if (buttonName.equalsIgnoreCase("minimize")) {
this.minimizeButtonPanel.add(restoreButton);
this.isShown = false;
- this.parentWindow.getTabbedPane().getContactListPanel()
+ this.mainFrame.getContactListPanel()
.getContactList().requestFocus();
- this.parentWindow.validate();
+ this.mainFrame.validate();
}
else if (buttonName.equalsIgnoreCase("restore")) {
@@ -153,7 +192,7 @@ else if (buttonName.equalsIgnoreCase("restore")) {
this.minimizeButtonPanel.add(minimizeButton);
this.isShown = true;
- this.parentWindow.validate();
+ this.mainFrame.validate();
}
}
@@ -184,4 +223,54 @@ public void setShown(boolean isShown)
this.minimizeButtonPanel.add(restoreButton);
}
}
+
+ /**
+ * For the given MetaContact returns the protocol contact that supports
+ * a basic telephony operation.
+ * @param metaContact the MetaContac we are trying to call
+ * @return returns the protocol contact that supports a basic telephony
+ * operation
+ */
+ private Contact getTelephonyContact(
+ MetaContact metaContact)
+ {
+ String telephonySet
+ = OperationSetBasicTelephony.class.getName();
+
+ Iterator i = metaContact.getContacts();
+ while(i.hasNext()) {
+ Contact contact = (Contact)i.next();
+
+ if(contact.getProtocolProvider()
+ .getSupportedOperationSets()
+ .containsKey(telephonySet)) {
+
+ return contact;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * From all registered protocol providers returns the first one that
+ * supports basic telephony.
+ * @return the first protocol provider from all the registered providers
+ * that supports basic telephony
+ */
+ private ProtocolProviderService getDefaultTelephonyProvider() {
+ String telephonySet
+ = OperationSetBasicTelephony.class.getName();
+
+ Iterator i = mainFrame.getProtocolProviders();
+ while(i.hasNext()) {
+ ProtocolProviderService pps
+ = (ProtocolProviderService) i.next();
+
+ if(pps.getSupportedOperationSets()
+ .containsKey(telephonySet)) {
+ return pps;
+ }
+ }
+ return null;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java
new file mode 100644
index 000000000..ea03c70a4
--- /dev/null
+++ b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java
@@ -0,0 +1,26 @@
+/*
+ * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.impl.gui.main.call;
+
+import javax.swing.*;
+
+import net.java.sip.communicator.service.protocol.*;
+
+public class CallPanel
+ extends JPanel
+{
+ private String callTitle;
+
+ public CallPanel(Call call) {
+ }
+
+ public String getTitle()
+ {
+ return null;
+ }
+
+}
diff --git a/src/net/java/sip/communicator/impl/gui/main/CallReceivePanel.java b/src/net/java/sip/communicator/impl/gui/main/call/CallReceivePanel.java
similarity index 96%
rename from src/net/java/sip/communicator/impl/gui/main/CallReceivePanel.java
rename to src/net/java/sip/communicator/impl/gui/main/call/CallReceivePanel.java
index ca3600376..8b8d5d002 100644
--- a/src/net/java/sip/communicator/impl/gui/main/CallReceivePanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/call/CallReceivePanel.java
@@ -5,12 +5,13 @@
* See terms of license at gnu.org.
*/
-package net.java.sip.communicator.impl.gui.main;
+package net.java.sip.communicator.impl.gui.main.call;
import java.awt.*;
import javax.swing.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
+import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.utils.*;
/**