(JabberDataBlock data)
| 68 | } |
| 69 | |
| 70 | public int blockArrived(JabberDataBlock data) { |
| 71 | if (!(data instanceof Iq)) return BLOCK_REJECTED; |
| 72 | String type=data.getTypeAttribute(); |
| 73 | String from=data.getAttribute("from"); |
| 74 | |
| 75 | if (from!=null) { |
| 76 | if (!new Jid(from).equals(sd.roster.selfContact().jid, false)) |
| 77 | return BLOCK_REJECTED; |
| 78 | } else return BLOCK_REJECTED; |
| 79 | |
| 80 | //System.out.println(">>> "+data.toString()); |
| 81 | |
| 82 | if (type.equals("get")) { |
| 83 | JabberDataBlock query=data.getChildBlock("query"); |
| 84 | if (query.isJabberNameSpace(ServiceDiscovery.NS_INFO)) { |
| 85 | Iq reply=new Iq(data.getAttribute("from"), Iq.TYPE_RESULT, data.getAttribute("id")); |
| 86 | JabberDataBlock replyChild=reply.addChildNs("query", ServiceDiscovery.NS_INFO); |
| 87 | if (query.getAttribute("node")!=null) |
| 88 | if (!query.getAttribute("node").equals(ServiceDiscovery.NS_CMDS)) { |
| 89 | replyChild.setAttribute("node", query.getAttribute("node")); |
| 90 | JabberDataBlock identity=replyChild.addChild("identity", ""); |
| 91 | identity.setAttribute("category", "automation"); |
| 92 | identity.setTypeAttribute("command-node"); |
| 93 | JabberDataBlock feature1=replyChild.addChild("feature", ""); |
| 94 | feature1.setAttribute("var", ServiceDiscovery.NS_CMDS); |
| 95 | JabberDataBlock feature2=replyChild.addChild("feature", ""); |
| 96 | feature2.setAttribute("var", DiscoForm.NS_XDATA); |
| 97 | } |
| 98 | sd.getTheStream().send(reply); |
| 99 | return BLOCK_PROCESSED; |
| 100 | |
| 101 | } else if (query.isJabberNameSpace(ServiceDiscovery.NS_ITEMS)) { |
| 102 | if (!query.getAttribute("node").equals(ServiceDiscovery.NS_CMDS)) { |
| 103 | Iq reply=new Iq(data.getAttribute("from"), Iq.TYPE_RESULT, data.getAttribute("id")); |
| 104 | JabberDataBlock replyChild=reply.addChildNs("query", ServiceDiscovery.NS_ITEMS); |
| 105 | if (query.getAttribute("node")!=null) |
| 106 | replyChild.setAttribute("node", query.getAttribute("node")); |
| 107 | sd.getTheStream().send(reply); |
| 108 | return BLOCK_PROCESSED; |
| 109 | } else { |
| 110 | Iq reply=new Iq(data.getAttribute("from"), Iq.TYPE_RESULT, data.getAttribute("id")); |
| 111 | reply.addChild(query); |
| 112 | |
| 113 | //http://jabber.org/protocol/rc#set-status //4.1 Change Status |
| 114 | JabberDataBlock status=query.addChild("item", ""); |
| 115 | status.setAttribute("jid", sd.roster.selfContact().getJid().toString()); |
| 116 | status.setAttribute("node", "set-status"); |
| 117 | status.setAttribute("name", "Set Status"); |
| 118 | //#ifndef WMUC |
| 119 | //http://jabber.org/protocol/rc#leave-groupchats //4.5 Leave Groupchats |
| 120 | JabberDataBlock leaveChats=query.addChild("item", ""); |
| 121 | leaveChats.setAttribute("jid", sd.roster.selfContact().getJid().toString()); |
| 122 | leaveChats.setAttribute("node", "leave-groupchats"); |
| 123 | leaveChats.setAttribute("name", "Leave Groupchats"); |
| 124 | //#endif |
| 125 | sd.getTheStream().send(reply); |
| 126 | |
| 127 | return BLOCK_PROCESSED; |
nothing calls this directly
no test coverage detected