(JabberDataBlock data)
| 50 | } |
| 51 | |
| 52 | public int blockArrived(JabberDataBlock data) { |
| 53 | if (!(data instanceof Iq)) |
| 54 | return BLOCK_REJECTED; |
| 55 | |
| 56 | String type=data.getTypeAttribute(); |
| 57 | String from=data.getAttribute("from"); |
| 58 | String id=data.getAttribute("id"); |
| 59 | |
| 60 | if (type.equals("result") || type.equals("error")) { |
| 61 | if (id.equals(PING)) { |
| 62 | StaticData.getInstance().getTheStream().pingSent=false; |
| 63 | return BLOCK_PROCESSED; |
| 64 | } |
| 65 | } |
| 66 | if (type.equals("get")) { |
| 67 | JabberDataBlock ping=data.getChildBlock(PING); |
| 68 | if (ping!=null) { |
| 69 | if (ping.getAttribute("xmlns").equals("urn:xmpp:ping")) { |
| 70 | Iq reply=new Iq(from, Iq.TYPE_RESULT, id); |
| 71 | StaticData.getInstance().getTheStream().send(reply); |
| 72 | return BLOCK_PROCESSED; |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | if (type.equals("result")) { |
| 77 | if (id.startsWith(_PING_)) { |
| 78 | Roster roster=StaticData.getInstance().roster; |
| 79 | Contact c=roster.getContact(from, false); |
| 80 | |
| 81 | String pong = pingToString(id.substring(6)); |
| 82 | |
| 83 | roster.querysign=false; |
| 84 | |
| 85 | if (pong!=null) { |
| 86 | Msg m=new Msg(Msg.MESSAGE_TYPE_SYSTEM, "pong", SR.MS_PING, pong); |
| 87 | roster.messageStore(c, m); |
| 88 | roster.redraw(); |
| 89 | } |
| 90 | return BLOCK_PROCESSED; |
| 91 | } |
| 92 | } |
| 93 | return BLOCK_REJECTED; |
| 94 | } |
| 95 | |
| 96 | private String pingToString(String time) { |
| 97 | String timePing=Long.toString((Time.utcTimeMillis()-Long.parseLong(time))/10); |
nothing calls this directly
no test coverage detected