Adds a button in the CallPanel to create a chat between call peers.

cusax-fix
Vincent Lucas 15 years ago
parent b2086c25de
commit 7bd3e9ea05

@ -135,6 +135,7 @@ service.gui.buttons.DESKTOP_BUTTON_SMALL_PRESSED=resources/images/impl/gui/butto
service.gui.buttons.CALL_DESKTOP_BUTTON=resources/images/impl/gui/buttons/callDesktopSharing.png
service.gui.buttons.CHAT_BUTTON_SMALL=resources/images/impl/gui/buttons/chatSmall.png
service.gui.buttons.CHAT_BUTTON_SMALL_PRESSED=resources/images/impl/gui/buttons/chatSmallPressed.png
service.gui.buttons.CHAT_BUTTON_SMALL_WHITE=resources/images/impl/gui/buttons/chatSmallWhite.png
service.gui.buttons.ADD_CONTACT_BUTTON_SMALL=resources/images/impl/gui/buttons/addContactSmall.png
service.gui.buttons.ADD_CONTACT_BUTTON_SMALL_PRESSED=resources/images/impl/gui/buttons/addContactSmallPressed.png
service.gui.buttons.CALL_BUTTON_PRESSED_BG=resources/images/impl/gui/buttons/callButtonPressed.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 75 KiB

@ -21,6 +21,7 @@
import net.java.sip.communicator.impl.gui.event.*;
import net.java.sip.communicator.impl.gui.main.call.conference.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.neomedia.*;
import net.java.sip.communicator.service.neomedia.device.*;
@ -65,6 +66,11 @@ public class CallPanel
*/
private static final String CONFERENCE_BUTTON = "CONFERENCE_BUTTON";
/**
* The chat button name.
*/
private static final String CHAT_BUTTON = "CHAT_BUTTON";
/**
* The hang up button name.
*/
@ -147,6 +153,11 @@ public class CallPanel
ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_BG),
ImageLoader.getImage(ImageLoader.ADD_TO_CALL_BUTTON));
/**
* Chat button.
*/
private SIPCommButton chatButton;
/**
* HangUp button.
*/
@ -307,6 +318,14 @@ public void stateChanged(ChangeEvent e)
transferCallButton = new TransferCallButton(call);
fullScreenButton = new FullScreenButton(this);
chatButton = new SIPCommButton(
ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_BG),
ImageLoader.getImage(ImageLoader.CHAT_BUTTON_SMALL_WHITE));
chatButton.setName(CHAT_BUTTON);
chatButton.setToolTipText(
GuiActivator.getResources().getI18NString("service.gui.CHAT"));
chatButton.addActionListener(this);
localLevel = new InputVolumeControlButton(
call,
ImageLoader.MICROPHONE,
@ -367,6 +386,18 @@ public void stateChanged(ChangeEvent e)
addConferenceSpecificComponents();
}
//chatButton.setEnabled(false);
//Collection<Contact> collectionIMCapableContacts =
// getIMCapableCallPeers();
// Enables the button only if there is 1 and only 1 peer which is
// basicIM capable.
//if(collectionIMCapableContacts.size() == 1)
if(getIMCapableCallPeers().size() == 1)
{
settingsPanel.add(chatButton);
//chatButton.setEnabled(true);
}
dtmfHandler = new DTMFHandler(this);
JComponent bottomBar = createBottomBar();
@ -424,6 +455,22 @@ else if (buttonName.equals(CONFERENCE_BUTTON))
inviteDialog.setVisible(true);
}
else if (buttonName.equals(CHAT_BUTTON))
{
Collection<Contact> collectionIMCapableContacts =
getIMCapableCallPeers();
// If a single peer is basic instant messaging capable, then we
// create a chat with this account.
if(collectionIMCapableContacts.size() == 1)
{
Contact contact = collectionIMCapableContacts.iterator().next();
MetaContact metaContact =
GuiActivator.getContactListService()
.findMetaContactByContact(contact);
GuiActivator.getUIService().getChatWindowManager()
.startChat(metaContact);
}
}
}
/**
@ -1432,4 +1479,42 @@ private void fireTitleChangeEvent()
listeners.next().callTitleChanged(this);
}
}
/**
* Returns the list of call peers which are capable to manage basic instant
* messaging operations.
*
* @return The collection of contacts for this call which are IM capable.
*/
private Collection<Contact> getIMCapableCallPeers()
{
Vector<Contact> contactVector = new Vector<Contact>(
call.getCallPeerCount());
Iterator<? extends CallPeer> callPeers = call.getCallPeers();
CallPeer callPeer;
Contact contact;
// Checks if the protocol provider of this call supports basic
// instant messaging.
if(call.getProtocolProvider().getOperationSet(
OperationSetBasicInstantMessaging.class) != null)
{
// For each peers of this call, checks if it is basic instant
// mesaging capable.
while(callPeers.hasNext())
{
callPeer = callPeers.next();
contact = callPeer.getContact();
// If a peer is basic instant messaging capable, then add
// its account to the list of IM capable peers.
if(callPeer.getProtocolProvider().getOperationSet(
OperationSetBasicInstantMessaging.class) != null &&
contact != null)
{
contactVector.add(contact);
}
}
}
return contactVector;
}
}

@ -331,6 +331,12 @@ public class ImageLoader
public static final ImageID CHAT_BUTTON_SMALL
= new ImageID("service.gui.buttons.CHAT_BUTTON_SMALL");
/**
* The chat button small image white on transparent version.
*/
public static final ImageID CHAT_BUTTON_SMALL_WHITE
= new ImageID("service.gui.buttons.CHAT_BUTTON_SMALL_WHITE");
/**
* The chat call button image.
*/
@ -1821,4 +1827,4 @@ else if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_48x48))
return null;
}
}
}

Loading…
Cancel
Save