Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
maniel #1
Member since May 2005 · 6 posts
Group memberships: Members
Show profile · Link to this post
Subject: just posting my first (yet not functional) jabber client
Yup, it's not functional at all. It only can login to given server with and without SSL encryption with given resource and priority. I wrote it using Gtk interface (gtk-sharp-2.0), Here it is:

jabber.cs:
using System;

using agsXMPP;

class Connection : XmppClientConnection
{
        public  Connection(string jid, string pass, bool ssl, int pri)
        {
                Jid j = new Jid(jid);

                this.OnLogin    += new ObjectHandler(Login);
                this.OnReadXml  += new XmlHandler(ReadXML);
                this.OnWriteXml += new XmlHandler(WriteXML);
                this.OnError    += new ErrorHandler(Error);

                try
                {
                        this.Server     = j.Server;
                        this.Username   = j.User;
                        this.Password   = pass;
                        this.Priority   = pri;
                        this.AutoAgents = false;
                        this.AutoRoster = false;

                        if(j.Resource != null)
                        {
                                this.Resource   = j.Resource;
                        }
                        else
                        {
                                this.Resource   = "no to pajechali!:P";
                        }

                        if(ssl)
                        {
                                Console.WriteLine("Connection is encrypted!:D");
                                this.Port = 5223;
                                this.UseSSL = ssl;
                        }
                        this.Open();
                }
                catch(Exception ex)
                {
                        Console.WriteLine(ex.ToString());
                        this.Close();
                }
        }

        private static void Error(object o, Exception ex)
        {
                Console.WriteLine(ex.Message);
        }

        public static void ReadXML(object o, string xml)
        {
                if(xml!="")
                        Console.WriteLine("RECV XML: " + xml );

        }

        public static void WriteXML(object o, string xml)
        {
                if(xml!="")
                        Console.WriteLine("SEND XML: " + xml );
        }

        private void Login(object o)
        {
                Console.WriteLine("logged in, sending presence");
                this.SendMyPresence();
        }
}
and gui.cs:
using System;
using Gtk;

class Sharper
{
        static  bool ssltoggle = false;
        static  int priority;
        static  Entry jabberid;
        static  Entry password;
        static  CheckButton cb;
        static  SpinButton spinner;
        static  Button btn;
        static  Connection c;

        static void Main()
        {
                Application.Init();

                Window win = new Window("Sharper");
                win.DeleteEvent += new DeleteEventHandler(Close);

                HBox hb1 = new HBox(true, 2);
                win.Add(hb1);

                VBox vb1 = new VBox(true, 2);
                hb1.Add(vb1);

                jabberid = new Entry();
                jabberid.Editable = true;
                vb1.Add(jabberid);
                jabberid.Show();

                password = new Entry();
                password.Editable = true;
                password.Visibility = false;
                password.InvisibleChar = '*';
                vb1.Add(password);
                password.Show();

                spinner = new SpinButton(0, 9999, 1);
                spinner.ValueChanged += new EventHandler(OnSpinnerValueChanged);
                vb1.Add(spinner);
                spinner.Show();

                cb = new CheckButton("Encrypted connection");
                cb.Toggled += new EventHandler(OnCheckToggled);
                vb1.Add(cb);
                cb.Show();

                btn = new Button("ok");
                btn.Clicked += new EventHandler(OnButtonClicked);
                hb1.Add(btn);
                btn.Show();

                win.ShowAll();

                Application.Run();
        }

        static private void Close(object obj, DeleteEventArgs args)
        {
                try
                {
                        c.Close();
                }
                catch(Exception ex){}
                Application.Quit();
        }

        static private void OnButtonClicked(object obj, EventArgs args)
        {
                if(jabberid.Text != "" && password.Text != "")
                {
                        btn.Sensitive = false;
                        c = new Connection(jabberid.Text, password.Text, ssltoggle, priority);
                }
        }

        static private void OnCheckToggled(object obj, EventArgs args)
        {
                if (cb.Active)
                {
                        ssltoggle = true;
                }
                else
                {
                        ssltoggle = false;
                }
        }

        static private void OnSpinnerValueChanged(object obj, EventArgs args)
        {
                priority = spinner.ValueAsInt;
        }
}
BTW, I had noticed that your library is badly documented (i use online documentation b'cause *chm documentation is quite unusable on Linux), please, fix it if you can :)
Avatar
Alex #2
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
hi Maniel,

cool to see that people use it on linux too. Yes the documentation could be better. I will release a update in the next days, and i will add more docs. But if you have any questions post them here or contact me with email.

Alex
Avatar
ongbeech #3
Member since Jul 2005 · 7 posts
Group memberships: Members
Show profile · Link to this post
hi.. i actually modified the codes above to be used in vb.net. The codes were working perfectly on my PDA which I use to do a test login to my jabber server via activesyn. But today, I encountered an error "target maching actively refused connection" during tcpconnection and I didn't change the login codes.
Avatar
maniel #4
Member since May 2005 · 6 posts
Group memberships: Members
Show profile · Link to this post
... in the meantime i've been developing the program above, it has been grown,now it's written in c# 2.0 and it has an xml config file(with password  b64 'encoding':P), something that looks like roster (it even writes a jig of clicked row:).
But.. unfortunately... i've noticed that new agsxmpp has been released, it compiles fine, without any errors or warnings with the new lib, but it doesn't work.. It seems to not get any xml;/ i don't know why.
after xmpp.Open() im getting only:
SEND XML: <stream:stream to='jabber.autocom.pl' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>
and it freezes, after closing a window (xmpp.Close()) i'm getting the next portion of xml:
SEND XML: </stream:stream>
RECV XML: <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; from=&quot;jabber.autocom.pl&quot; version=&quot;1.0&quot; id=&quot;lpu70wtkrt9ridr1rliwr1d46qelnhy96sg7parg&quot; >
RECV XML: <stream:features xmlns:stream=&quot;http://etherx.jabber.org/streams&quot;><xmlns:starttls xmlns:xmlns=&quot;http://www.w3.org/2000/xmlns/&quot; /><xmlns:mechanisms xmlns:xmlns=&quot;http://www.w3.org/2000/xmlns/&quot;><mechanism xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;>DIGEST-MD5</mechanism><mechanism xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;>PLAIN</mechanism></xmlns:mechanisms></stream:features>
SEND XML: <iq xmlns=&quot;jabber:client&quot; id=&quot;agsXMPP_1&quot; type=&quot;get&quot; to=&quot;jabber.autocom.pl&quot;><query xmlns=&quot;jabber:iq:auth&quot;><username>myusername</username></query></iq>
RECV XML: </stream:stream>
And ofcourse program ends;] This looks weird, has something importand changed in this library?
I don't remember the version of the old lib I'm using but new lib has  version 0.34. it all runs on mono 1.1.8.2 on Linux
Avatar
Alex #5
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
hi maniel,

you should find all changes in the changelog. I hope you have the old lib that was working for you. When not i keep all older releases on the server.
Could you send your project or a small sample that doesnt work for you?
Which server are you using? Is it public so that i can test with it?

Alex
Avatar
Alex #6
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
ok just created a account on your server and had no problems. Work okay with me. Even with SASL login. But i tested on windows. I have to reinstall my linux machine because of some library conflicts and problems. I will try it there later in the evening then.

Alex
Avatar
maniel #7
Member since May 2005 · 6 posts
Group memberships: Members
Show profile · Link to this post
the progam above is a good sample, it doesnt work too with the new lib..
@alex: how do you build agsxmpp on linux?, i've used
grep '.cs' agsXMPP_Desktop.csproj |awk '{print $3}'|sed 's=\\=/=g' |xargs mcs -r:System.Drawing.dll -r:/opt/mono/lib/mono/1.0/Mono.Security.dll -t:library -out:agsXMPP_Desktop.dll -d:SSL
and maybe it's because of it..
it was screaming:
Xml/kXml2/KXmlParser.cs(410) error CS0135: 'prefix' has a different meaning in a child block
Xml/kXml2/KXmlParser.cs(318): 'prefix' (name of symbol related to previous error
so i've deleted line 318 (string prefix;) because of conflicting declarations.. the library has compiled successfully but, as i had mentioned before, it doesn't work for me maybe its because of modifications..
Avatar
Alex #8
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
hi maniel,

i use monodevelop and import the solutions from Microsoft .NET.
I changed the xml parser a while ago to the new kxml parser. I will checkout this again under linux.

Alex
Avatar
Alex #9
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
hi maniel,

i was able to reproduce the problem on linux and windows with the latest MONO release.
The problem is located in kXmlParser.cs
here it is line:
srcCount = reader.Read(srcBuf, 0, srcBuf.Length);

This line reads Data from the network stream to a buffer. By default it tries to read 1024 Byte which is set in the member variable m_Bufferize.

So when m_Bufferize > then the Data available in the NetworkStream then MS .NET reads all the Data available in the Stream and returns immediately.

In MONO this line blocks until the stream is closed or there are 1024 Bytes of data available. So there is a different behaviour in MONO and MS .NET.
I will try to talk to the Mono developers and file a bug or feature request.
For now a easy fix is to set m_Bufferize = 1 and change line 81 in StreamParser.cs to:
p.setInput(reader.BaseStream, &quot;UTF-8&quot;);

This worked for me on Windows with MONO. But i will tra it also on Linux.

Alex
Avatar
maniel #10
Member since May 2005 · 6 posts
Group memberships: Members
Show profile · Link to this post
ok the lib works fine with changes you mentioned and renaming `prefix' variable to something else in lines 318,322,327 and 333 because of name conflicts with variable defined in line 265
Avatar
Alex #11
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
hi maniel,

i uploaded a new version with all this changes yesterday. Would cool when you could also try this latest version 0.35.

Alex
Avatar
maniel #12
Member since May 2005 · 6 posts
Group memberships: Members
Show profile · Link to this post
ok, it works fine ;-)
now, one question: how to use starttls?
and once again: documentation!;-)
Avatar
Alex #13
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
hi maniel,

now, one question: how to use starttls?
starttls has a very high priority on my TODO list. Its coming. But i need changes in the socket stuff and i the jabber protocol.

and once again: documentation!;-)
yes i know. This has very high priority too. But give me some input. What kind of documentation you wanna see?

1) PDF documents
2) lots of source code samples
3) XML source code comments (Ndoc)

my favorite is 2 combined with 3

Alex
Avatar
maniel #14
Member since May 2005 · 6 posts
Group memberships: Members
Show profile · Link to this post
I'd like an online documentation in html:)
Avatar
pecesama #15
Member since Jun 2005 · 8 posts
Group memberships: Members
Show profile · Link to this post
I'd like 2 combined with 3 too, please
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS