| 22 import org.jivesoftware.smack.SmackException; |
22 import org.jivesoftware.smack.SmackException; |
| 23 import org.jivesoftware.smack.XMPPException; |
23 import org.jivesoftware.smack.XMPPException; |
| 24 import org.jivesoftware.smack.filter.MessageWithBodiesFilter; |
24 import org.jivesoftware.smack.filter.MessageWithBodiesFilter; |
| 25 import org.jivesoftware.smack.packet.Message; |
25 import org.jivesoftware.smack.packet.Message; |
| 26 import org.jivesoftware.smack.packet.MessageBuilder; |
26 import org.jivesoftware.smack.packet.MessageBuilder; |
| |
27 import org.jivesoftware.smack.packet.Presence; |
| 27 import org.jivesoftware.smack.roster.Roster; |
28 import org.jivesoftware.smack.roster.Roster; |
| 28 import org.jivesoftware.smack.roster.RosterEntry; |
29 import org.jivesoftware.smack.roster.RosterEntry; |
| 29 import org.jivesoftware.smack.tcp.XMPPTCPConnection; |
30 import org.jivesoftware.smack.tcp.XMPPTCPConnection; |
| 30 import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; |
31 import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; |
| |
32 import org.jxmpp.jid.Jid; |
| 31 import org.jxmpp.stringprep.XmppStringprepException; |
33 import org.jxmpp.stringprep.XmppStringprepException; |
| 32 |
34 |
| 33 public class Xmpp extends Thread { |
35 public class Xmpp extends Thread { |
| 34 private final XMPPTCPConnectionConfiguration config; |
36 private final XMPPTCPConnectionConfiguration config; |
| 35 |
37 |
| 131 var jid = stanza.getFrom(); |
132 var jid = stanza.getFrom(); |
| 132 if(jid != null) { |
133 if(jid != null) { |
| 133 String body = ((Message)stanza).getBody(); |
134 String body = ((Message)stanza).getBody(); |
| 134 App.getInstance().dispatchMessage(jid, body, true); |
135 App.getInstance().dispatchMessage(jid, body, true); |
| 135 } |
136 } |
| 136 }), MessageWithBodiesFilter.INSTANCE); |
137 }), MessageWithBodiesFilter.INSTANCE); |
| |
138 connection.addAsyncStanzaListener(stanza -> { |
| |
139 if (stanza instanceof Presence) { |
| |
140 Presence presence = (Presence) stanza; |
| |
141 Jid from = presence.getFrom(); |
| |
142 Presence.Type type = presence.getType(); |
| |
143 App.getInstance().handlePresence(from, type); |
| |
144 } |
| |
145 }, stanza -> stanza instanceof Presence); |
| 137 List<RosterEntry> roster = getRosterItems(); |
146 List<RosterEntry> roster = getRosterItems(); |
| 138 if(roster != null) { |
147 if(roster != null) { |
| 139 App.getInstance().setContacts(roster); |
148 App.getInstance().setContacts(roster); |
| 140 } |
149 } |
| 141 |
150 |