From marmorkuchen at kodeaffe.de Sat Jun 7 02:20:54 2008 From: marmorkuchen at kodeaffe.de (agent marmorkuchen) Date: Fri, 06 Jun 2008 23:20:54 -0700 Subject: [Ruburple-development] require, add buddy and connect Message-ID: <20080607062054.GA5732@fuchi.kodeaffe.de> hi there... well, i'm new to the list, new to groundcrew.us and did not code in ruby for a bit more than a year and never programmed any C extension for it. :) so, i wanted to use ruburple to help debugging a problem with the groundcrew people (one of them being one of your developers, hi Joe!) and ran into these: 1) i need require 'rubygems' before require 'ruburple' to use ruburple. dunno if that is specific to Debian, but perhaps it is needed as an addition in your README. 2) can't add a buddy, but according to http://rubyforge.org/pipermail/ruburple-development/2008-May/000072.html, there might be a fix for this available soonish. any news on that? 3) i can't seem to 'connect'. i can login to the server and get the buddy list, for instance. but when calling the method connect, it does not seem to connect, without telling me about any errors. method connecting returns true and method connected returns false, until after a while the system has given up and method connecting returns false. script: #!/usr/bin/env ruby require 'rubygems' require 'ruburple' Ruburple::init Ruburple::subscribe(:received_im_msg, (Proc.new do |a,b,c,d,e| puts "rcv im: #{a}, #{b}, #{c}, #{d}, #{e}" end)) Ruburple::subscribe(:signed_on, (Proc.new do |a| puts "signed on: #{a}" end)) p = Ruburple::get_protocol("XMPP") puts "gonna connect to #{p.id}, #{p.name}, #{p.version}, #{p.summary}, #{p.description}, #{p.author}, #{p.homepage}" a = p.get_account("marmorkuchen at server", "0xdeadbeef") a.buddies.find do |buddy| puts "buddy: #{buddy.name}" end a.connect a.connection.send_im(a.buddies[1].name, "kia ora") a.connection.close looking into ext/ruburple_ext.c, i noticed a few things: - connect actually calls purple_account_set_enabled(), why the renaming? it also seems awkward to me to issue connect, although i am already connected to the server. - rb_ruburple_protocol_account_set_enabled() returns Qnil. why not something like BOOL(enabled)? i presume that the connect method then would not return nil but a boolean value. so far thanks for this promising module and cheers, agent marmorkuchen -- _ ascii ribbon campaign .oOo. GCSd-s:+aC++ULB+++W++M+PS+++Y+ ( ) X Es gibt nur 10 Arten von Menschen auf der Welt, solche die binaer / \ verstehen und solche die es nicht tun. From joe.edelman at gmail.com Sun Jun 8 17:03:27 2008 From: joe.edelman at gmail.com (Joe Edelman) Date: Sun, 8 Jun 2008 17:03:27 -0400 Subject: [Ruburple-development] require, add buddy and connect In-Reply-To: <20080607062054.GA5732@fuchi.kodeaffe.de> References: <20080607062054.GA5732@fuchi.kodeaffe.de> Message-ID: <20080608210327.GH459@fkr.local> Mr Marmorkuchen, You probably want to use the SVN version, rather than the gem, because I'm not sure if they're the same. If you use the SVN version, you don't need to require rubygems. I have a fix for the adding a buddy thing. Enclosed. I haven't committed 'cause I told myself I'd test it more and merge with a different submitted change. It's in production on Groundcrew, though. W/r/t connecting, try running your script line by line at the 'irb' interactive ruby prompt. None of the calls are blocking, so you'd have to insert sleep statements for it to work right. --Joe -- Index: ext/ruburple_ext.c =================================================================== --- ext/ruburple_ext.c (revision 54) +++ ext/ruburple_ext.c (working copy) @@ -1350,20 +1350,27 @@ ruburple_protocol_account_add_buddy(gpointer data) { gpointer *args = (gpointer *) data; - return purple_buddy_new((PurpleAccount *) args[0], (char *) args[1], NULL); + PurpleAccount *account = (PurpleAccount *) args[0]; + char *buddy_name = (char *) args[1]; + PurpleBuddy *buddy = purple_buddy_new(account, buddy_name, NULL); + purple_account_add_buddy(account, buddy); + return buddy; } static VALUE rb_ruburple_protocol_account_add_buddy(VALUE self, VALUE name) { PurpleAccount *account; - gpointer args[2]; - PurpleBuddy *buddy; PURPLE_ACCOUNT(self, account); - args[0] = (gpointer) account; - args[1] = (gpointer) RSTRING(name)->ptr; - buddy = (PurpleBuddy *) call_and_get_result(ruburple_protocol_account_add_buddy, args); - RETURN_QNIL_IF_NULL(buddy); + char *buddy_name = RSTRING(name)->ptr; + PurpleBuddy *buddy = purple_buddy_new(account, buddy_name, NULL); + purple_blist_add_buddy(buddy, NULL, NULL, NULL); + purple_account_add_buddy(account, buddy); return RB_RUBURPLE_BLIST_BUDDY(buddy); } --Joe -- J.E. -- http://nxhx.org -- 413.250.8007 >hi there... > >well, i'm new to the list, new to groundcrew.us and did not code in ruby >for a bit more than a year and never programmed any C extension for it. :) > >so, i wanted to use ruburple to help debugging a problem with the >groundcrew people (one of them being one of your developers, hi Joe!) >and ran into these: > >1) i need > require 'rubygems' > > before > require 'ruburple' > > to use ruburple. dunno if that is specific to Debian, but perhaps it is > needed as an addition in your README. > > >2) can't add a buddy, but according to >http://rubyforge.org/pipermail/ruburple-development/2008-May/000072.html, >there might be a fix for this available soonish. any news on that? > > >3) i can't seem to 'connect'. i can login to the server and get the >buddy list, for instance. but when calling the method connect, it does >not seem to connect, without telling me about any errors. method >connecting returns true and method connected returns false, until after >a while the system has given up and method connecting returns false. > >script: > >#!/usr/bin/env ruby > >require 'rubygems' >require 'ruburple' > >Ruburple::init >Ruburple::subscribe(:received_im_msg, (Proc.new do |a,b,c,d,e| puts "rcv >im: #{a}, #{b}, #{c}, #{d}, #{e}" end)) >Ruburple::subscribe(:signed_on, (Proc.new do |a| puts "signed on: #{a}" >end)) >p = Ruburple::get_protocol("XMPP") >puts "gonna connect to #{p.id}, #{p.name}, #{p.version}, #{p.summary}, >#{p.description}, #{p.author}, #{p.homepage}" >a = p.get_account("marmorkuchen at server", "0xdeadbeef") >a.buddies.find do |buddy| puts "buddy: #{buddy.name}" end >a.connect >a.connection.send_im(a.buddies[1].name, "kia ora") >a.connection.close > >looking into ext/ruburple_ext.c, i noticed a few things: > >- connect actually calls purple_account_set_enabled(), why the > renaming? it also seems awkward to me to issue connect, although i am > already connected to the server. > >- rb_ruburple_protocol_account_set_enabled() returns Qnil. why not > something like BOOL(enabled)? i presume that the connect method then > would not return nil but a boolean value. > > >so far thanks for this promising module and cheers, > agent marmorkuchen >-- > _ ascii ribbon campaign .oOo. GCSd-s:+aC++ULB+++W++M+PS+++Y+ >( ) > X Es gibt nur 10 Arten von Menschen auf der Welt, solche die binaer >/ \ verstehen und solche die es nicht tun. > >_______________________________________________ >Ruburple-development mailing list >Ruburple-development at rubyforge.org >http://rubyforge.org/mailman/listinfo/ruburple-development From marmorkuchen at kodeaffe.de Mon Jun 9 17:24:58 2008 From: marmorkuchen at kodeaffe.de (agent marmorkuchen) Date: Mon, 09 Jun 2008 14:24:58 -0700 Subject: [Ruburple-development] require, add buddy and connect In-Reply-To: <20080608210327.GH459@fkr.local> References: <20080607062054.GA5732@fuchi.kodeaffe.de> <20080608210327.GH459@fkr.local> Message-ID: <20080609212458.GB5742@fuchi.kodeaffe.de> hiya... * Joe Edelman [2008-06-08 14:39 -0700]: > > You probably want to use the SVN version, rather than the gem, because > I'm not sure if they're the same. If you use the SVN version, you don't > need to require rubygems. ok, downloaded, built the gem, uninstalled the previous gem and installed the new. still i have to requite it explicitly. perhaps this has something to do how gem and ruby are setup on a lenny-ish Debian system. > I have a fix for the adding a buddy thing. Enclosed. I haven't committed > 'cause I told myself I'd test it more and merge with a different submitted > change. It's in production on Groundcrew, though. right, gcrbot is now a buddy of mine. hooray! > W/r/t connecting, try running your script line by line at the 'irb' > interactive ruby prompt. None of the calls are blocking, so you'd have > to insert sleep statements for it to work right. i enabled debugging by Ruburple::debug = true and there seems to be something wrong with the SSL connection to the jabber server: irb(main):019:0> (14:03:27) util: Writing file prefs.xml to directory /home/marbellous/.purple (14:03:27) util: Writing file /home/marbellous/.purple/prefs.xml (14:03:27) util: Writing file accounts.xml to directory /home/marbellous/.purple (14:03:27) util: Writing file /home/marbellous/.purple/accounts.xml (14:03:27) util: Writing file blist.xml to directory /home/marbellous/.purple (14:03:27) util: Writing file /home/marbellous/.purple/blist.xml a.connect (14:03:31) account: Connecting to account marbellous at jabber.ccc.de/marmorpalast => nil irb(main):020:0> (14:03:36) util: Writing file accounts.xml to directory /home/marbellous/.purple (14:03:36) util: Writing file /home/marbellous/.purple/accounts.xml (14:03:42) dnssrv: found 0 SRV entries (14:03:42) dns: DNS query for 'jabber.ccc.de' queued (14:03:42) dns: Created new DNS child 7161, there are now 1 children. (14:03:42) dns: Successfully sent DNS request to child 7161 (14:03:42) dns: Got response for 'jabber.ccc.de' (14:03:42) dnsquery: IP resolved for jabber.ccc.de (14:03:42) proxy: Attempting connection to 217.10.10.194 (14:03:42) proxy: Connecting to jabber.ccc.de:5222 with no proxy (14:03:42) proxy: Connection in progress (14:03:42) proxy: Connected to jabber.ccc.de:5222. (14:03:42) jabber: Sending: (14:03:42) jabber: Sending: (14:03:42) jabber: Recv (170): (14:03:42) jabber: Recv (271): DIGEST-MD5PLAIN (14:03:42) jabber: Sending: (14:03:42) jabber: Recv (50): (14:03:43) jabber: Sending (ssl): (14:03:43) jabber: Recv (ssl)(170): (14:03:43) jabber: Recv (ssl)(220): DIGEST-MD5PLAIN (14:03:43) sasl: Mechs found: DIGEST-MD5 PLAIN (14:03:43) jabber: Sending (ssl): (14:03:44) jabber: Recv (ssl)(148): bm9uY2U9IjExMTQ5NzAxNyIscW9wPSJhdXRoIixjaGFyc2V0PXV0Zi04LGFsZ29yaXRobT1tZDUtc2Vzcw== (14:03:44) sasl: DIGEST-MD5 client step 2 (14:03:44) jabber: Sending (ssl): dXNlcm5hbWU9Im1hcm1vcmt1Y2hlbiIscmVhbG09ImphYmJlci5jY2MuZGUiLG5vbmNlPSIxMTE0OTcwMTciLGNub25jZT0iN2plRWUxV3pIaUxSOUV6Vlp3WEZPUjk1VmZpTENodjdXMHpKamI2aTRqND0iLG5jPTAwMDAwMDAxLHFvcD1hdXRoLGRpZ2VzdC11cmk9InhtcHAvamFiYmVyLmNjYy5kZSIscmVzcG9uc2U9OTdiZDFmZDAzNzgwODIxODhiNmQ5N2ZjMzE2N2ZkOTc= (14:03:44) jabber: Recv (ssl)(77): (14:03:44) sasl: Mechs found: PLAIN (14:03:44) jabber: Sending (ssl): AG1hcm1vcmt1Y2hlbgBncm91bmQ0dS4= (14:03:44) jabber: Recv (ssl)(71): (14:03:44) account: Disconnecting account 0x9e42670 (14:03:44) connection: Disconnecting connection 0x9e8aff0 (14:03:44) connection: Destroying connection 0x9e8aff0 (14:03:49) util: Writing file accounts.xml to directory /home/marbellous/.purple (14:03:49) util: Writing file /home/marbellous/.purple/accounts.xml (14:08:24) prefs: /purple/savedstatus/isidleaway changed, scheduling save. (14:08:24) account: Connecting to account marbellous at jabber.ccc.de/marmorpalast (14:08:24) idle: Setting marbellous at jabber.ccc.de/marmorpalast idle 302 seconds (14:08:24) connection: Connecting. gc = 0x9c69fb8 (14:08:24) dnssrv: querying SRV record for _xmpp-client._tcp.jabber.ccc.de (14:08:29) util: Writing file prefs.xml to directory /home/marbellous/.purple (14:08:29) util: Writing file /home/marbellous/.purple/prefs.xml (14:08:29) util: Writing file accounts.xml to directory /home/marbellous/.purple (14:08:29) util: Writing file /home/marbellous/.purple/accounts.xml i had pidgin running in parallel; this account disabled, though. the weird thing is that i now can't enable anymore using pidgin. hopefully, this won't last. perhaps this is a mix-up of ssl-certificates/challenges cached somewhere on client/server and ruburple/pidgin, as both are users of libpurple, interfering with each other. will try another time after it is working on pidgin again. cheers, marmorkuchen > >well, i'm new to the list, new to groundcrew.us and did not code in ruby > >for a bit more than a year and never programmed any C extension for it. :) > > > >so, i wanted to use ruburple to help debugging a problem with the > >groundcrew people (one of them being one of your developers, hi Joe!) > >and ran into these: > > > >1) i need > > require 'rubygems' > > > > before > > require 'ruburple' > > > > to use ruburple. dunno if that is specific to Debian, but perhaps it is > > needed as an addition in your README. > > > > > >2) can't add a buddy, but according to > >http://rubyforge.org/pipermail/ruburple-development/2008-May/000072.html, > >there might be a fix for this available soonish. any news on that? > > > > > >3) i can't seem to 'connect'. i can login to the server and get the > >buddy list, for instance. but when calling the method connect, it does > >not seem to connect, without telling me about any errors. method > >connecting returns true and method connected returns false, until after > >a while the system has given up and method connecting returns false. > > > >script: > > > >#!/usr/bin/env ruby > > > >require 'rubygems' > >require 'ruburple' > > > >Ruburple::init > >Ruburple::subscribe(:received_im_msg, (Proc.new do |a,b,c,d,e| puts "rcv > >im: #{a}, #{b}, #{c}, #{d}, #{e}" end)) > >Ruburple::subscribe(:signed_on, (Proc.new do |a| puts "signed on: #{a}" > >end)) > >p = Ruburple::get_protocol("XMPP") > >puts "gonna connect to #{p.id}, #{p.name}, #{p.version}, #{p.summary}, > >#{p.description}, #{p.author}, #{p.homepage}" > >a = p.get_account("marmorkuchen at server", "0xdeadbeef") > >a.buddies.find do |buddy| puts "buddy: #{buddy.name}" end > >a.connect > >a.connection.send_im(a.buddies[1].name, "kia ora") > >a.connection.close > > > >looking into ext/ruburple_ext.c, i noticed a few things: > > > >- connect actually calls purple_account_set_enabled(), why the > > renaming? it also seems awkward to me to issue connect, although i am > > already connected to the server. > > > >- rb_ruburple_protocol_account_set_enabled() returns Qnil. why not > > something like BOOL(enabled)? i presume that the connect method then > > would not return nil but a boolean value. -- _ ascii ribbon campaign .oOo. GCSd-s:+aC++ULB+++W++M+PS+++Y+ ( ) X Heute die Welt, morgens das Sonnensystem! / \ From ochronus at gmail.com Fri Jun 27 06:20:27 2008 From: ochronus at gmail.com (Csaba Okrona) Date: Fri, 27 Jun 2008 12:20:27 +0200 Subject: [Ruburple-development] Some questions regarding buddy handling Message-ID: Hi, First of all, I have to state I've been using ruburple for only half a day :) I find it a great wrapper lib, though I'm having some difficulties: First, after connecting to an MSN account, when the signed_on event fires, I still have to sleep for a while before I can dare to try iterating through the buddy list - else the code freezes (only a kill -9 stops it). Second, which is a major showstopper for my app, the following code chunk $conn.buddies.find do |buddy| puts "#{buddy.name} #{buddy.account.status.name}" end says "Avaliable" for all of my contacts, though most of them aren't online at all at the time. if I change it to buddy.status.name, it says "Offline" for all. if I say like 'pp buddy.status', it outputs '#' etc., with different hex numbers for everyone. Maybe I'm doing things totally wrong, please help me find the correct way to check for my contacts' statuses. Thank you, Ochronus From joe.edelman at gmail.com Fri Jun 27 09:06:46 2008 From: joe.edelman at gmail.com (Joe Edelman) Date: Fri, 27 Jun 2008 09:06:46 -0400 Subject: [Ruburple-development] Some questions regarding buddy handling In-Reply-To: References: Message-ID: <20080627130646.GC1390@fkr.local> The first problem is interesting. That doesn't happen for me: what platform are you on? Re: the 2nd, buddy.account is *your account*, so it's saying that *you* are available, not your buddy. buddy.status.name should be correct. buddy.status is a buddy object that supports a number of methods, including name. Go look at the bottom of ruburple_ext.c, where you can see all the classes and the methods put on them in C. --Joe -- J.E. -- http://nxhx.org -- 413.250.8007 > Hi, > > First of all, I have to state I've been using ruburple for only half a day > :) > I find it a great wrapper lib, though I'm having some difficulties: > > First, after connecting to an MSN account, when the signed_on event fires, I > still have to sleep for a while before I can dare to try > iterating through the buddy list - else the code freezes (only a kill -9 > stops it). > > Second, which is a major showstopper for my app, the following code chunk > $conn.buddies.find do |buddy| > puts "#{buddy.name} #{buddy.account.status.name}" > end > > says "Avaliable" for all of my contacts, though most of them aren't online > at all at the time. if I change it to buddy.status.name, it says "Offline" > for all. > if I say like 'pp buddy.status', it outputs > '#' etc., with different > hex numbers for everyone. Maybe I'm doing things > totally wrong, please help me find the correct way to check for my contacts' > statuses. > > Thank you, > Ochronus > _______________________________________________ > Ruburple-development mailing list > Ruburple-development at rubyforge.org > http://rubyforge.org/mailman/listinfo/ruburple-development From ochronus at gmail.com Sat Jun 28 01:19:04 2008 From: ochronus at gmail.com (Csaba Okrona) Date: Sat, 28 Jun 2008 07:19:04 +0200 Subject: [Ruburple-development] Some questions regarding buddy handling In-Reply-To: <27acba740806270408x10f896b5ye7b0f9676e748eaa@mail.gmail.com> References: <27acba740806270408x10f896b5ye7b0f9676e748eaa@mail.gmail.com> Message-ID: <9f841fcc0806272219x461dcc74id00c3a2de2b5306@mail.gmail.com> Thank you for your reply and help! Thanks for stating clear that buddy.account is "me", I was a bit confused about this one :) About the hex codes: what I don't get is that there are status constants in ruburple like STATUS_OFFLINE, etc.. What are those used for, if not status checking, and how can I use these pointers? Do I have to use status.name == 'Avaliable', etc. to check for certain statuses? Thanks again, Ochronus On Fri, Jun 27, 2008 at 1:08 PM, Martin Kihlgren wrote: > I believe the signed_on event fires the moment the connection is > established, rather than when the buddy list is downloaded. Perhaps > there is another event for buddy-list-finished or something? I don't > know, you better check the libpurple documentation about that. > > About the status thing - buddy.account is YOUR account, ie the account > the buddy is associated with, so of course it is available if you are > available :) > > buddy.status, however, should work better. I don't know why it doesn't > - it used to work for me :/ > > The hex numbers are the addresses to the status-structures in the > underlying c code for libpurple, so they should look like that (even > if you could implement some nicer pretty-print or inspect string if > you wanted). > > I am not actively developing ruburple anymore, I'm just here in a > mentoring role until someone steps up and wants to take over for real, > so I'm afraid I can't help you all that much if something needs to be > hacked. > > regards, > //Martin > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ochronus at gmail.com Sat Jun 28 01:24:45 2008 From: ochronus at gmail.com (Csaba Okrona) Date: Sat, 28 Jun 2008 07:24:45 +0200 Subject: [Ruburple-development] Some questions regarding buddy handling In-Reply-To: <20080627130646.GC1390@fkr.local> References: <20080627130646.GC1390@fkr.local> Message-ID: <9f841fcc0806272224v510f883dh8c76742c97cc78@mail.gmail.com> Thank you for your reply, The platform: amd64, gentoo, but I compiled pidgin 2.4.2 by hand. I've tried both the official gem for ruburple and the svn version. Here is the relevant section of my code: def list_contacts(a) puts "Signed on, now waiting for buddy list to be populated" sleep 10 while (!$conn.connected? or $conn.buddies.empty?) puts $conn.connected? ? "Connected" : "Not connected" sleep 0.5 end puts "Buddy list populated!" $connected = true puts "listing contacts" $conn.buddies.each do |buddy| puts buddy.name end end Ruburple::init Ruburple::subscribe(:received_im_msg, (Proc.new do |a,b,c,d,e| Thread.new do get_message(a,b,c,d,e) end end) ) Ruburple::subscribe(:signed_on, (Proc.new do |a| list_contacts(a) end)) p = Ruburple::get_protocol("MSN") puts "gonna connect to #{p.id}, #{p.name}, #{p.version}, #{p.summary}, #{p.description}, #{p.author}, #{p.homepage}" $conn = p.get_account("a at b.c", "pass") $conn.connect Now, if I remove that "sleep 10" from the list_contacts method, it freezes (due to a seemingly early access to $conn.buddies) Thanks again, Ochronus On Fri, Jun 27, 2008 at 3:06 PM, Joe Edelman wrote: > The first problem is interesting. That doesn't happen for me: what > platform are you on? > > Re: the 2nd, buddy.account is *your account*, so it's saying that *you* > are available, not your buddy. buddy.status.name should be correct. > buddy.status is a buddy object that supports a number of methods, > including name. > > Go look at the bottom of ruburple_ext.c, where you can see all the > classes and the methods put on them in C. > > --Joe > > -- > J.E. -- http://nxhx.org -- 413.250.8007 > > > Hi, > > > > First of all, I have to state I've been using ruburple for only half a > day > > :) > > I find it a great wrapper lib, though I'm having some difficulties: > > > > First, after connecting to an MSN account, when the signed_on event > fires, I > > still have to sleep for a while before I can dare to try > > iterating through the buddy list - else the code freezes (only a kill -9 > > stops it). > > > > Second, which is a major showstopper for my app, the following code chunk > > $conn.buddies.find do |buddy| > > puts "#{buddy.name} #{buddy.account.status.name}" > > end > > > > says "Avaliable" for all of my contacts, though most of them aren't > online > > at all at the time. if I change it to buddy.status.name, it says > "Offline" > > for all. > > if I say like 'pp buddy.status', it outputs > > '#' etc., with > different > > hex numbers for everyone. Maybe I'm doing things > > totally wrong, please help me find the correct way to check for my > contacts' > > statuses. > > > > Thank you, > > Ochronus > > _______________________________________________ > > Ruburple-development mailing list > > Ruburple-development at rubyforge.org > > http://rubyforge.org/mailman/listinfo/ruburple-development > -------------- next part -------------- An HTML attachment was scrubbed... URL: