From 7bd3e9ea05ae83042db5b8b67a13408643129b41 Mon Sep 17 00:00:00 2001 From: Vincent Lucas Date: Wed, 11 Jan 2012 10:12:32 +0000 Subject: [PATCH] Adds a button in the CallPanel to create a chat between call peers. --- resources/images/images.properties | 1 + .../impl/gui/buttons/chatSmallWhite.png | Bin 0 -> 653 bytes .../gui/buttons/src/contactListButtons.svg | 1659 +++++++++++++++++ .../impl/gui/main/call/CallPanel.java | 85 + .../impl/gui/utils/ImageLoader.java | 8 +- 5 files changed, 1752 insertions(+), 1 deletion(-) create mode 100644 resources/images/impl/gui/buttons/chatSmallWhite.png create mode 100644 resources/images/impl/gui/buttons/src/contactListButtons.svg diff --git a/resources/images/images.properties b/resources/images/images.properties index 30cd87c5f..26bdb9c1a 100644 --- a/resources/images/images.properties +++ b/resources/images/images.properties @@ -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 diff --git a/resources/images/impl/gui/buttons/chatSmallWhite.png b/resources/images/impl/gui/buttons/chatSmallWhite.png new file mode 100644 index 0000000000000000000000000000000000000000..49b1a2df1024072460e8caac23d13d8c361220c8 GIT binary patch literal 653 zcmV;80&@L{P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L00guE00guF7}21#00007bV*G`2iyS) z6f`JqMel(C00Iq3L_t(Y$L*F)Yg0iOg`c_iCTUDlY7hgWU~Qnhbj~$TB&dUfi%d-1!}G4<`*S!~!YnwF?0GTL z7D=*!*%w-^H8(xIKlHLC71eC6%B-SMVYaPib5&t@c~~*0Mq@=%RVPPP?e>bK0SCPS z#V{<8$;<CN(4dnc)@{VPly>6~!1arAvqUbH4ZqE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Background only used tosee the white icon + + + + + + + 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 index ac5c3cfc3..d1c0fbeba 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java @@ -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 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 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 getIMCapableCallPeers() + { + Vector contactVector = new Vector( + call.getCallPeerCount()); + Iterator 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; + } } diff --git a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java index 7d12c87d9..11bfa8ace 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java @@ -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; } -} \ No newline at end of file +}