From 5168a66d716796880dba7f7ad377816bab0a1d04 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Thu, 29 Jan 2004 22:02:50 +0000 Subject: [PATCH] Answers a "not implemented" error when the IQ is not understood git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2220 b35dd754-fafc-0310-a699-88a17e54d16e --- .../org/jivesoftware/smack/PacketReader.java | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/source/org/jivesoftware/smack/PacketReader.java b/source/org/jivesoftware/smack/PacketReader.java index 5db4fc156..be785d388 100644 --- a/source/org/jivesoftware/smack/PacketReader.java +++ b/source/org/jivesoftware/smack/PacketReader.java @@ -407,15 +407,36 @@ class PacketReader { } } } - // Set basic values on the iq packet. + // Decide what to do when an IQ packet was not understood if (iqPacket == null) { - // If an IQ packet wasn't created above, create an empty IQ packet. - iqPacket = new IQ() { - public String getChildElementXML() { - return null; - } - }; + if (IQ.Type.GET == type || IQ.Type.SET == type ) { + // If the IQ stanza is of type "get" or "set" containing a child element + // qualified by a namespace it does not understand, then answer an IQ of + // type "error" with code 501 ("feature-not-implemented") + iqPacket = new IQ() { + public String getChildElementXML() { + return null; + } + }; + iqPacket.setPacketID(id); + iqPacket.setTo(from); + iqPacket.setFrom(to); + iqPacket.setType(IQ.Type.ERROR); + iqPacket.setError(new XMPPError(501, "feature-not-implemented")); + connection.sendPacket(iqPacket); + return null; + } + else { + // If an IQ packet wasn't created above, create an empty IQ packet. + iqPacket = new IQ() { + public String getChildElementXML() { + return null; + } + }; + } } + + // Set basic values on the iq packet. iqPacket.setPacketID(id); iqPacket.setTo(to); iqPacket.setFrom(from);