| 1 |
using Gee; |
| 2 |
|
| 3 |
namespace Xmpp.Xep.ServiceDiscovery { |
| 4 |
|
| 5 |
public class ItemsResult { |
| 6 |
public Iq.Stanza iq { get; private set; } |
| 7 |
|
| 8 |
public ArrayList<Item> items { |
| 9 |
owned get { |
| 10 |
ArrayList<Item> ret = new ArrayList<Item>(); |
| 11 |
foreach (StanzaNode feature_node in iq.stanza.get_subnode("query", NS_URI_ITEMS).get_subnodes("item", NS_URI_ITEMS)) { |
| 12 |
try { |
| 13 |
ret.add(new Item(new Jid(feature_node.get_attribute("jid", NS_URI_ITEMS)), |
| 14 |
feature_node.get_attribute("name", NS_URI_ITEMS), |
| 15 |
feature_node.get_attribute("node", NS_URI_ITEMS))); |
| 16 |
} catch (InvalidJidError e) { |
| 17 |
warning("Ignoring service at invalid Jid: %s", e.message); |
| 18 |
} |
| 19 |
} |
| 20 |
return ret; |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
private ItemsResult.from_iq(Iq.Stanza iq) { |
| 25 |
this.iq = iq; |
| 26 |
} |
| 27 |
|
| 28 |
public static ItemsResult? create_from_iq(Iq.Stanza iq) { |
| 29 |
if (iq.type_ != Iq.Stanza.TYPE_RESULT) return null; |
| 30 |
|
| 31 |
if (iq.stanza.get_subnode("query", NS_URI_ITEMS) == null) return null; |
| 32 |
|
| 33 |
return new ItemsResult.from_iq(iq); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
} |