[vassalengine-svn-trunk] [vassalengine-svn] SF.net SVN: vassalengine:[6172] VASSAL-src/trunk/src/VA
Brought to you by:
rodneykinney,
uckelman
From: <swa...@us...> - 2009-10-18 05:34:19
|
Revision: 6172 http://vassalengine.svn.sourceforge.net/vassalengine/?rev=6172&view=rev Author: swampwallaby Date: 2009-10-18 05:34:10 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Jabber Client Updates - Invitations Modified Paths: -------------- VASSAL-src/trunk/src/VASSAL/chat/LockableChatServerConnection.java VASSAL-src/trunk/src/VASSAL/chat/jabber/JabberClient.java VASSAL-src/trunk/src/VASSAL/chat/jabber/JabberRoom.java Modified: VASSAL-src/trunk/src/VASSAL/chat/LockableChatServerConnection.java =================================================================== --- VASSAL-src/trunk/src/VASSAL/chat/LockableChatServerConnection.java 2009-10-17 21:57:35 UTC (rev 6171) +++ VASSAL-src/trunk/src/VASSAL/chat/LockableChatServerConnection.java 2009-10-18 05:34:10 UTC (rev 6172) @@ -28,6 +28,9 @@ /** Invite a player to this room */ void sendInvite(Player p); + /** Process Invitation */ + void doInvite(String playerId, String roomName); + /** Can a player be kicked from this room by me? */ boolean isKickable(Player kickee); Modified: VASSAL-src/trunk/src/VASSAL/chat/jabber/JabberClient.java =================================================================== --- VASSAL-src/trunk/src/VASSAL/chat/jabber/JabberClient.java 2009-10-17 21:57:35 UTC (rev 6171) +++ VASSAL-src/trunk/src/VASSAL/chat/jabber/JabberClient.java 2009-10-18 05:34:10 UTC (rev 6172) @@ -34,6 +34,7 @@ import java.util.Set; import javax.swing.JFrame; +import javax.swing.JOptionPane; import org.jivesoftware.smack.Chat; import org.jivesoftware.smack.ConnectionConfiguration; @@ -85,6 +86,7 @@ import VASSAL.command.Command; import VASSAL.command.CommandEncoder; import VASSAL.i18n.Resources; +import VASSAL.tools.swing.Dialogs; public class JabberClient implements LockableChatServerConnection, PacketListener, ServerStatus, ChatControlsInitializer, PlayerEncoder { @@ -246,11 +248,25 @@ fireStatus(Resources.getString("Server.connected", host + ":" + port)); GameModule.getGameModule().addIdChangeListener(idChangeListener); MultiUserChat.addInvitationListener(conn, new InvitationListener() { - public void invitationReceived(XMPPConnection conn, String room, String inviter, String reason, String password, Message mess) { - // Reject the invitation - MultiUserChat.decline(conn, room, inviter, "I'm busy right now"); + public void invitationReceived(XMPPConnection conn, String room, + String inviter, String reason, String password, Message mess) { + final String playerName = inviter.split("@")[0]; + final String roomName = JabberRoom.jidToName(room); + final int i = Dialogs.showConfirmDialog(GameModule + .getGameModule().getFrame(), "Invitation to join room", + "Invitation to join room", Resources.getString( + "Chat.invitation", playerName, roomName), + JOptionPane.QUESTION_MESSAGE, null, + JOptionPane.YES_NO_OPTION, "Invite" + inviter, Resources + .getString("Chat.ignore_invitation")); + if (i == 0) { + doInvite(inviter, roomName); + } + else { + MultiUserChat.decline(conn, room, inviter, ""); + } } - }); + }); } // FIXME: review error message @@ -327,6 +343,10 @@ return currentChat == null ? null : currentChat.getRoom(); } + public void setRoom(String roomName) { + setRoom(roomMgr.getRoomByName(this, roomName)); + } + public void setRoom(Room r) { JabberRoom newRoom = null; try { @@ -390,6 +410,7 @@ } } + /** Can a player be invited to this room? */ public boolean isInvitable(Player invitee) { // invitee is not me if (!invitee.equals(me)) { @@ -405,10 +426,24 @@ return false; } + /** Send invitation to player */ public void sendInvite(Player invitee) { - currentChat.invite(invitee.getId(), "hi"); + try { + currentChat.grantMembership(invitee.getId()); + } + catch (XMPPException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + currentChat.invite(invitee.getId(), ""); } + /** Process an invitation */ + public void doInvite(String playerId, String roomName) { + setRoom(roomName); + } + + /** Is a player kickable from this room? */ public boolean isKickable(Player kickee) { // kickee is not me if (!kickee.equals(me)) { @@ -424,6 +459,7 @@ return false; } + /** Kick a player from this room */ public void kick(Player kickee) { } Modified: VASSAL-src/trunk/src/VASSAL/chat/jabber/JabberRoom.java =================================================================== --- VASSAL-src/trunk/src/VASSAL/chat/jabber/JabberRoom.java 2009-10-17 21:57:35 UTC (rev 6171) +++ VASSAL-src/trunk/src/VASSAL/chat/jabber/JabberRoom.java 2009-10-18 05:34:10 UTC (rev 6172) @@ -43,6 +43,12 @@ this.client = client; } + public static String jidToName(String jid) { + final String roomRef = jid.split("@")[0]; + final String[] parts = roomRef.split("2f"); + return parts[parts.length-1]; + } + public String getJID() { return jid; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ vassalengine-svn mailing list vas...@li... https://lists.sourceforge.net/lists/listinfo/vassalengine-svn |