1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright (c) 2003-2012 by AG-Software 											 *
3  * All Rights Reserved.																 *
4  * Contact information for AG-Software is available at http://www.ag-software.de	 *
5  *																					 *
6  * Licence:																			 *
7  * The agsXMPP SDK is released under a dual licence									 *
8  * agsXMPP can be used under either of two licences									 *
9  * 																					 *
10  * A commercial licence which is probably the most appropriate for commercial 		 *
11  * corporate use and closed source projects. 										 *
12  *																					 *
13  * The GNU Public License (GPL) is probably most appropriate for inclusion in		 *
14  * other open source projects.														 *
15  *																					 *
16  * See README.html for details.														 *
17  *																					 *
18  * For general enquiries visit our website at:										 *
19  * http://www.ag-software.de														 *
20  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
21 
22 using System;
23 
24 using agsXMPP.Xml.Dom;
25 
26 namespace agsXMPP.protocol.extensions.pubsub.@event
27 {
28     /*
29         <message from='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo'>
30           <event xmlns='http://jabber.org/protocol/pubsub#event'>
31             <items node='blogs/princely_musings'>
32               <item id='ae890ac52d0df67ed7cfdf51b644e901'>
33                 <entry xmlns='http://www.w3.org/2005/Atom'>
34                   <title>Soliloquy</title>
35                   <summary>
36                         To be, or not to be: that is the question:
37                         Whether 'tis nobler in the mind to suffer
38                         The slings and arrows of outrageous fortune,
39                         Or to take arms against a sea of troubles,
40                         And by opposing end them?
41                   </summary>
42                   <link rel='alternate' type='text/html'
43                         href='http://denmark.lit/2003/12/13/atom03'/>
44                   <id>tag:denmark.lit,2003:entry-32397</id>
45                   <published>2003-12-13T18:30:02Z</published>
46                   <updated>2003-12-13T18:30:02Z</updated>
47                 </entry>
48               </item>
49             </items>
50           </event>
51         </message>
52 
53         <xs:element name='items'>
54             <xs:complexType>
55               <xs:sequence>
56                 <xs:element ref='item' minOccurs='0' maxOccurs='unbounded'/>
57               </xs:sequence>
58               <xs:attribute name='node' type='xs:string' use='required'/>
59             </xs:complexType>
60         </xs:element>
61     */
62 
63     public class Items : Element
64     {
65         #region << Constructors >>
66         public Items()
67         {
68             this.TagName    = "items";
69             this.Namespace  = Uri.PUBSUB_EVENT;
70         }
71 
72         public Items(string node) : this()
73         {
74             this.Node = node;
75         }
76         #endregion
77 
78         public string Node
79         {
80             get { return GetAttribute("node"); }
81             set { SetAttribute("node", value); }
82         }
83 
84         /// <summary>
85         /// Add a payload Item
86         /// </summary>
87         /// <returns>returns the added Item</returns>
88         public Item AddItem()
89         {
90             Item item = new Item();
91             AddChild(item);
92             return item;
93         }
94 
95         /// <summary>
96         ///
97         /// </summary>
98         /// <param name="item"></param>
99         /// <returns>returns the added item</returns>
100         public Item AddItem(Item item)
101         {
102             AddChild(item);
103             return item;
104         }
105 
106         /// <summary>
107         /// This will return all payload items. Multiple items are possible, but doe the most implementaions one item
108         /// should be enough
109         /// </summary>
110         /// <returns>returns an Array of Items</returns>
111         public Item[] GetItems()
112         {
113             ElementList nl = SelectElements(typeof(Item));
114             Item[] items = new Item[nl.Count];
115             int i = 0;
116             foreach (Element e in nl)
117             {
118                 items[i] = (Item)e;
119                 i++;
120             }
121             return items;
122         }
123 	}
124 }
125