source: 3thparty/jmessenger/src/nu/fw/jeti/jabber/elements/IQVersion.java @ 3952

Revision 3952, 2.3 KB checked in by alexandrecorreia, 13 years ago (diff)

Ticket #1710 - Adicao do codigo fonte java do componente jmessenger(jabberit_messenger)

  • Property svn:executable set to *
Line 
1package nu.fw.jeti.jabber.elements;
2
3import java.text.MessageFormat;
4
5import javax.swing.JOptionPane;
6
7import nu.fw.jeti.backend.Start;
8import nu.fw.jeti.jabber.Backend;
9import nu.fw.jeti.util.I18N;
10import nu.fw.jeti.util.Popups;
11import nu.fw.jeti.util.Preferences;
12
13
14/**
15 * <p>Copyright: Copyright (c) 2002</p>
16 *  @author E.S. de Boer
17 * @version 1.0
18 */
19
20public class IQVersion extends Extension implements IQExtension
21{
22        private String os;
23        private String name;
24        private String version;
25
26        public IQVersion(){}
27
28        public IQVersion(String name, String version,String os)
29    {
30                this.os = os;
31                this.name = name;
32                this.version = version;
33    }
34
35        public String getOS(){return os;}
36
37        public String getName(){return name;}
38
39        public String getVersion(){return version;}
40       
41        public void execute(InfoQuery iq,Backend backend)
42        {
43                String type = iq.getType();
44                if (type.equals("get"))
45                {
46                        if(Preferences.getBoolean("jeti", "privacy", false)) return;
47                        String tag = "";
48                        if(Start.applet)tag = "A";
49                        else if(Start.webstart)tag = "W";
50                        IQVersion version = new IQVersion("JETI" +Start.OS2, Start.VERSION + tag + " - " + Start.BUILD_DATE, System.getProperty("os.name") + " " +System.getProperty("os.version"));
51                        backend.send(new InfoQuery(iq.getFrom(),"result", iq.getID(),version));
52                }
53                else if (type.equals("result"))
54                {
55                        versionPopup(iq.getFrom().toString(), getName(), getVersion(), getOS());
56                        //System.out.println(iq.getFrom().toStringNoResource() + " " +  getName() + " " +  getVersion() + " " + getOS());
57                }
58                else if (type.equals("error"))
59                {
60                        Popups.errorPopup(iq.getErrorDescription(), I18N.gettext("main.error.Version_Error"));
61                }
62               
63        }
64       
65        private void versionPopup(String jid,String name,String version,String os)
66        {
67                Popups.popup(MessageFormat.format(I18N.gettext("main.popup.{0}_uses_{1},_version_{2},_On_{3}"),new Object[]{jid,name,version,os}),I18N.gettext("main.popup.Version"),JOptionPane.INFORMATION_MESSAGE);
68        }
69               
70        public void appendToXML(StringBuffer xml)
71    {
72        xml.append("<query xmlns=\"jabber:iq:version\"");
73                if(name == null && version == null && os ==null)
74                { //short cut
75                    xml.append("/>");
76                        return;
77                }
78                xml.append('>');
79                appendElement(xml,"name",name);
80                appendElement(xml,"version",version);
81                appendElement(xml,"os",os);
82                xml.append("</query>");
83    }
84}
85/*
86 * Overrides for emacs
87 * Local variables:
88 * tab-width: 4
89 * End:
90 */
Note: See TracBrowser for help on using the repository browser.