source: branches/2.2/jabberit_messenger/java_source/src/nu/fw/jeti/jabber/elements/IQDiscoInfo.java @ 3102

Revision 3102, 3.3 KB checked in by amuller, 14 years ago (diff)

Ticket #986 - Efetuado merge para o Branch 2.2( atualizacao do modulo)

  • Property svn:executable set to *
Line 
1/*
2 *      Jeti, a Java Jabber client, Copyright (C) 2003 E.S. de Boer 
3 *
4 *  This program is free software; you can redistribute it and/or modify
5 *  it under the terms of the GNU General Public License as published by
6 *  the Free Software Foundation; either version 2 of the License, or
7 *  (at your option) any later version.
8 *
9 *  This program is distributed in the hope that it will be useful,
10 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 *      GNU General Public License for more details.
13 *
14 *  You should have received a copy of the GNU General Public License
15 *  along with this program; if not, write to the Free Software
16 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 *
18 *      For questions, comments etc,
19 *      use the website at http://jeti.jabberstudio.org
20 *  or mail me at eric@jeti.tk
21 */
22
23
24//Created on 6-aug-2004
25package nu.fw.jeti.jabber.elements;
26
27import java.util.Collections;
28import java.util.Iterator;
29import java.util.LinkedList;
30import java.util.List;
31
32import nu.fw.jeti.jabber.Backend;
33
34/**
35 * @author E.S. de Boer
36 * implements the http://jabber.org/protocol/disco#info'/ spec
37 */
38public class IQDiscoInfo extends Extension implements IQExtension, DiscoveryInfo
39{
40        private String node;
41        private List identities;
42        private List features;
43       
44
45        public IQDiscoInfo()
46        {}
47       
48        public IQDiscoInfo(String node)
49        {
50                this.node = node;
51        }
52
53        public IQDiscoInfo(String node,List identities,List features)
54        {
55                this.node = node;
56                this.identities = identities;
57                this.features = features;
58        }
59
60        public String getNode()
61        {
62                return node;
63        }
64
65        public Iterator getIdentities()
66        {
67                if (identities == null)return null;
68                return identities.iterator();
69        }
70       
71        public List getFeatures()
72        {
73                return Collections.unmodifiableList(features);
74        }
75       
76        public boolean hasFeatures()
77        {
78                return features!=null;
79        }
80       
81        //discovery implementations
82        //use the first identity, browse can not have more identities
83        public String getName()
84        {
85                if (identities == null)return null;
86                return ((DiscoIdentity)identities.get(0)).getName();
87        }
88
89        //discovery implementations
90        //use the first identity, browse can not have more identities
91        public String getCategory()
92        {
93                if (identities == null)return null;
94                return ((DiscoIdentity)identities.get(0)).getCategory();
95        }
96
97        //discovery implementations
98        //use the first identity, browse can not have more identities
99        public String getType()
100        {
101                if (identities == null)return null;
102                return ((DiscoIdentity)identities.get(0)).getType();
103        }
104       
105
106//      public boolean hasChildItems()
107//      {
108//              return identities != null;
109//      }
110       
111        public void execute(InfoQuery iq,Backend backend){}
112
113        public void appendToXML(StringBuffer xml)
114        {
115                xml.append("<query xmlns= 'http://jabber.org/protocol/disco#info'");
116                appendAttribute(xml, "node", node);
117                if (identities == null && features==null)
118                { //short cut
119                        xml.append("/>");
120                        return;
121                }
122                xml.append('>');
123                if (identities != null)
124                {
125                        for (Iterator i = identities.iterator(); i.hasNext();)
126                        {
127                                ((DiscoIdentity) i.next()).appendToXML(xml);
128                        }
129                }
130                if(features!=null)
131                {
132                        for (Iterator i = features.iterator(); i.hasNext();)
133                        {
134                                xml.append("<feature var='" + i.next() +"'/>");
135                        }
136                }
137                xml.append("</query>");
138        }
139}
140
141/*
142 * Overrides for emacs
143 * Local variables:
144 * tab-width: 4
145 * End:
146 */
Note: See TracBrowser for help on using the repository browser.