source: branches/2.2/jabberit_messenger/java_source/src/nu/fw/jeti/plugins/filetransfer/socks5/Socks5Handler.java @ 3102

Revision 3102, 3.1 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) 2004 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// Created on 18-sept-2004
24package nu.fw.jeti.plugins.filetransfer.socks5;
25
26import java.util.LinkedList;
27import java.util.List;
28
29import nu.fw.jeti.jabber.JID;
30import nu.fw.jeti.jabber.elements.Extension;
31import nu.fw.jeti.jabber.handlers.ExtensionHandler;
32import nu.fw.jeti.util.Log;
33
34import org.xml.sax.Attributes;
35
36/**
37 * @author E.S. de Boer
38 *
39 */
40public class Socks5Handler extends ExtensionHandler
41{
42        private String sid;
43        private JID streamHost;
44        private List streamHosts;
45        private JID activate;
46        private JID jid;
47        private String host;
48        private int port;
49        private String zeroConf;
50       
51        public void startHandling(Attributes attr)
52        {
53                sid=null;
54                streamHost=null;
55                streamHosts=null;
56                activate=null;
57                host=zeroConf=null;
58                port=0;
59                jid=null;
60                sid= attr.getValue("sid");
61        }
62       
63        public void startElement(String name,Attributes attr)
64        {
65                if(name.equals("streamhost-used"))
66                {
67                        try
68                        {
69                                streamHost=JID.checkedJIDFromString(attr.getValue("jid"));
70                        } catch (InstantiationException e)
71                        {
72                                // TODO Auto-generated catch block
73                                e.printStackTrace();
74                        }
75                }
76                else if(name.equals("streamhost"))
77                {
78                        try
79                        {
80                                jid=JID.checkedJIDFromString(attr.getValue("jid"));
81                        } catch (InstantiationException e)
82                        {
83                                // TODO Auto-generated catch block
84                                e.printStackTrace();
85                        }
86                        host = attr.getValue("host");
87                        try{
88                                port = Integer.parseInt(attr.getValue("port"));
89                        }catch (NumberFormatException e)
90                        {
91                                // TODO Auto-generated catch block
92                                e.printStackTrace();
93                        }
94                        zeroConf = attr.getValue("zeroconf");
95                }
96        }
97       
98        public void endElement(String name)
99        {
100                if(name.equals("activate"))
101                {
102                        try
103                        {
104                                activate =JID.checkedJIDFromString(getText());
105                        } catch (InstantiationException e)
106                        {
107                                // TODO Auto-generated catch block
108                                e.printStackTrace();
109                        }
110                }
111                else if(name.equals("streamhost"))
112                {
113                        StreamHost h = new StreamHost(jid,host,port,zeroConf);
114                        if(streamHosts==null)streamHosts= new LinkedList();
115                        streamHosts.add(h);
116                        host=zeroConf=null;
117                        port=0;
118                        jid=null;
119                }
120                clearCurrentChars();
121        }
122
123        public Extension build()
124        {
125                return new Socks5Extension(sid,streamHost,streamHosts,activate);
126        }
127}
128/*
129 * Overrides for emacs
130 * Local variables:
131 * tab-width: 4
132 * End:
133 */
Note: See TracBrowser for help on using the repository browser.