From a3b27e8724b1f0b8b6579de45e8027fab70f809d Mon Sep 17 00:00:00 2001 From: Valentin Martinet Date: Sun, 17 Jan 2010 15:29:48 +0000 Subject: [PATCH] Adds support for invitation reason (Yahoo! & ICQ) --- .../impl/gui/main/chat/ChatPanel.java | 6 +++-- .../conference/ConferenceChatManager.java | 7 ++--- ...OperationSetAdHocMultiUserChatIcqImpl.java | 5 ++-- ...OperationSetAdHocMultiUserChatMsnImpl.java | 23 +++++++++------- ...erationSetAdHocMultiUserChatYahooImpl.java | 26 +++++++++++++------ 5 files changed, 42 insertions(+), 25 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java index 56d03a781..20166d91a 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java @@ -1957,7 +1957,8 @@ public void inviteContacts( ChatTransport inviteChatTransport, { ChatRoomWrapper chatRoomWrapper = conferenceChatManager.createChatRoom( - inviteChatTransport.getProtocolProvider(), chatContacts); + inviteChatTransport.getProtocolProvider(), + chatContacts); conferenceChatSession = new ConferenceChatSession(this, chatRoomWrapper); @@ -1968,7 +1969,8 @@ else if (inviteChatTransport.getProtocolProvider(). AdHocChatRoomWrapper chatRoomWrapper = conferenceChatManager.createAdHocChatRoom( inviteChatTransport.getProtocolProvider(), - chatContacts); + chatContacts, + reason); conferenceChatSession = new AdHocConferenceChatSession(this, chatRoomWrapper); diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java index a6376d5a1..1f0bb97f6 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java @@ -762,12 +762,14 @@ public ChatRoomWrapper createChatRoom( * * @param protocolProvider the parent protocol provider. * @param contacts the contacts invited when creating the chat room. + * @param reason the reason for this invitation * @return the AdHocChatRoomWrapper corresponding to the created * ad hoc chat room */ public AdHocChatRoomWrapper createAdHocChatRoom( ProtocolProviderService protocolProvider, - Collection contacts) + Collection contacts, + String reason) { AdHocChatRoomWrapper chatRoomWrapper = null; @@ -795,8 +797,7 @@ public AdHocChatRoomWrapper createAdHocChatRoom( chatRoom = groupChatOpSet.createAdHocChatRoom( - "chatroom-" + new Date().getTime(), - members); + "chatroom-" + new Date().getTime(), members, reason); } catch (OperationFailedException ex) { diff --git a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetAdHocMultiUserChatIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetAdHocMultiUserChatIcqImpl.java index 05d7fdb56..a9511026b 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetAdHocMultiUserChatIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetAdHocMultiUserChatIcqImpl.java @@ -194,13 +194,14 @@ public AdHocChatRoom createAdHocChatRoom(String roomName, * * @param adHocRoomName the name of the ad-hoc room * @param contacts the list of contacts + * @param reason the reason to be sent with the invitation for contacts. * * @return the ad-hoc room that has been just created * @throws OperationFailedException * @throws OperationNotSupportedException */ public AdHocChatRoom createAdHocChatRoom(String adHocRoomName, - List contacts) + List contacts, String reason) throws OperationFailedException, OperationNotSupportedException { @@ -213,7 +214,7 @@ public AdHocChatRoom createAdHocChatRoom(String adHocRoomName, { ContactIcqImpl newContact = (ContactIcqImpl) contact; - adHocChatRoom.invite(newContact.getAddress(), ""); + adHocChatRoom.invite(newContact.getAddress(), reason); } } diff --git a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetAdHocMultiUserChatMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetAdHocMultiUserChatMsnImpl.java index fdde12b39..267df29ad 100644 --- a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetAdHocMultiUserChatMsnImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetAdHocMultiUserChatMsnImpl.java @@ -173,13 +173,16 @@ public Message createMessage(String messageText) * * @param adHocRoomName the name of the ad-hoc room * @param contacts the list of contacts + * @param reason the reason (will not be used since MSN does not support + * invitation with the possibility to reject it) * * @return the ad-hoc room that has been just created * @throws OperationFailedException * @throws OperationNotSupportedException */ public AdHocChatRoom createAdHocChatRoom( String adHocRoomName, - List contacts) + List contacts, + String reason) throws OperationFailedException, OperationNotSupportedException { AdHocChatRoom adHocChatRoom = createAdHocChatRoom( @@ -191,7 +194,7 @@ public AdHocChatRoom createAdHocChatRoom( String adHocRoomName, { ContactMsnImpl newContact = (ContactMsnImpl) contact; - adHocChatRoom.invite(newContact.getAddress(), ""); + adHocChatRoom.invite(newContact.getAddress(), reason); } } @@ -199,8 +202,8 @@ public AdHocChatRoom createAdHocChatRoom( String adHocRoomName, } /** - * Creates an AdHocChatRoom whose name is _adHocRoomName with the - * properties contained in _adHocRoomProperties + * Creates an AdHocChatRoom whose name is adHocRoomName with the + * properties contained in adHocRoomProperties * * @param adHocRoomName the name of the ad-hoc room * @param adHocRoomProperties the ad-hoc room's properties @@ -227,7 +230,7 @@ public AdHocChatRoom createAdHocChatRoom(String adHocRoomName, // when the room hasn't been created, we create it. adHocRoom = createLocalAdHocChatRoomInstance(adHocRoomName, id); } - + return adHocRoom; } @@ -245,7 +248,7 @@ private AdHocChatRoomMsnImpl createLocalAdHocChatRoomInstance( { AdHocChatRoomMsnImpl adHocChatRoom = new AdHocChatRoomMsnImpl(adHocChatRoomName, this.provider); - + // We put it to the pending ad hoc chat rooms, waiting for the // switchboard to be created. this.pendingAdHocChatRoomList.put(switchboardId, adHocChatRoom); @@ -533,7 +536,7 @@ public void contactJoinSwitchboard( MsnSwitchboard switchboard, { if (!isGroupChatMessage(switchboard)) return; - + try { AdHocChatRoomMsnImpl chatRoom @@ -543,7 +546,7 @@ public void contactJoinSwitchboard( MsnSwitchboard switchboard, { chatRoom = createLocalAdHocChatRoomInstance(switchboard); } - + OperationSetPersistentPresenceMsnImpl presenceOpSet = (OperationSetPersistentPresenceMsnImpl) provider .getOperationSet(OperationSetPersistentPresence.class); @@ -626,8 +629,8 @@ public void switchboardClosed(MsnSwitchboard switchboard) */ public void switchboardStarted(MsnSwitchboard switchboard) { - Object switchboardID = switchboard.getAttachment(); - + Object switchboardID = switchboard.getAttachment(); + AdHocChatRoomMsnImpl adHocChatRoom = null; if (switchboardID != null && pendingAdHocChatRoomList.containsKey(switchboardID)) diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetAdHocMultiUserChatYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetAdHocMultiUserChatYahooImpl.java index e0700c49d..3019f04fc 100644 --- a/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetAdHocMultiUserChatYahooImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/yahoo/OperationSetAdHocMultiUserChatYahooImpl.java @@ -218,24 +218,24 @@ public AdHocChatRoom createAdHocChatRoom(String roomName, Map roomProperties) throws OperationFailedException { - return createAdHocChatRoom(roomName, (String[]) null); + return createAdHocChatRoom(roomName, (String[]) null, ""); } /** * Creates an ad-hoc room with the named adHocRoomName and in * including to the specified contacts. When the method returns the - * ad-hoc room the local user will not have joined it and thus will not - * receive messages on it until the AdHocChatRoom.join() method is - * called. + * ad-hoc room the local user will have joined it. * * @return the ad-hoc room that has been just created * @param adHocRoomName the name of the room to be created * @param contacts the list of contacts + * @param reason the reason for contacts' invitation * @throws OperationFailedException if the room couldn't be created for * some reason */ public AdHocChatRoom createAdHocChatRoom( String adHocRoomName, - List contacts) + List contacts, + String reason) throws OperationFailedException { String[] invitedContacts = null; // parameter used for room's creation @@ -258,12 +258,22 @@ public AdHocChatRoom createAdHocChatRoom( String adHocRoomName, } } - return createAdHocChatRoom(adHocRoomName, invitedContacts); + return createAdHocChatRoom(adHocRoomName, invitedContacts, reason); } + /** + * + * + * @param roomName name of the chatroom + * @param invitedContacts contacts to be invited to this room + * @param reason reason of this invitation + * @return AdHocChatRoom the ad-hoc room that has been just created + * @throws OperationFailedException + */ private AdHocChatRoom createAdHocChatRoom( String roomName, - String[] invitedContacts) + String[] invitedContacts, + String reason) throws OperationFailedException { if (invitedContacts == null) @@ -276,7 +286,7 @@ private AdHocChatRoom createAdHocChatRoom( YahooConference conference = yahooProvider.getYahooSession().createConference( invitedContacts, // users invited to this conference - "", // invite message / topic + reason, // invite message / topic yahooProvider.getYahooSession().getLoginIdentity()); chatRoom = createLocalChatRoomInstance(conference);