[Ruburple-development] require, add buddy and connect
Joe Edelman
joe.edelman at gmail.com
Sun Jun 8 17:03:27 EDT 2008
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
More information about the Ruburple-development
mailing list