public static JID full(String jid) { jid = StringUtils.defaultString(jid); return new JID( XmppStringUtils.parseLocalpart(jid), XmppStringUtils.parseDomain(jid), XmppStringUtils.parseResource(jid)); }
private void showInvitationInChat(final GameOfferPacket invitation) { invitation.setType(IQ.Type.result); invitation.setTo(invitation.getFrom()); final ChatRoom room = SparkManager.getChatManager() .getChatRoom(XmppStringUtils.parseBareJid(invitation.getFrom())); String name = XmppStringUtils.parseLocalpart(invitation.getFrom()); final JPanel panel = new JPanel(); JLabel text = new JLabel("Game request from" + name); JLabel game = new JLabel("Battleships"); game.setFont(new Font("Dialog", Font.BOLD, 24)); game.setForeground(Color.RED); JButton accept = new JButton(Res.getString("button.accept").replace("&", "")); JButton decline = new JButton(Res.getString("button.decline").replace("&", "")); panel.add(text); panel.add(game); panel.add(accept); panel.add(decline); room.getTranscriptWindow().addComponent(panel); accept.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { SparkManager.getConnection().sendStanza(invitation); } catch (SmackException.NotConnectedException e1) { Log.warning("Unable to send invitation accept to " + invitation.getTo(), e1); } invitation.setStartingPlayer(!invitation.isStartingPlayer()); ChatRoomOpeningListener.createWindow(invitation, invitation.getFrom()); panel.remove(3); panel.remove(2); panel.repaint(); panel.revalidate(); } }); decline.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { invitation.setType(IQ.Type.error); try { SparkManager.getConnection().sendStanza(invitation); } catch (SmackException.NotConnectedException e1) { Log.warning("Unable to send invitation decline to " + invitation.getTo(), e1); } panel.remove(3); panel.remove(2); panel.repaint(); panel.revalidate(); } }); }
public static JID bare(String jid) { jid = StringUtils.defaultString(jid); return new JID(XmppStringUtils.parseLocalpart(jid), XmppStringUtils.parseDomain(jid), ""); }