From nobody at rubyforge.org Mon Dec 3 07:04:21 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 3 Dec 2007 07:04:21 -0500 (EST) Subject: [Ruburple-submits] [47] trunk/ruburple/README: updated the README to reflect the fact that the connection is not ready for sending after you have called connect Message-ID: <20071203120421.C3C5B1598065@rubyforge.org> Revision: 47 Author: zond Date: 2007-12-03 07:04:21 -0500 (Mon, 03 Dec 2007) Log Message: ----------- updated the README to reflect the fact that the connection is not ready for sending after you have called connect Modified Paths: -------------- trunk/ruburple/README Modified: trunk/ruburple/README =================================================================== --- trunk/ruburple/README 2007-11-28 23:23:25 UTC (rev 46) +++ trunk/ruburple/README 2007-12-03 12:04:21 UTC (rev 47) @@ -29,13 +29,15 @@ require 'ruburple' Ruburple::init Ruburple::subscribe(:received_im_msg) do |a,b,c,d,e| puts "rcv im: #{a}, #{b}, #{c}, #{d}, #{e}" end - Ruburple::subscribe(:signed_on) do |a| puts "signed on: #{a}" end + Ruburple::subscribe(:signed_on) do |a| + puts "signed on: #{a}" + a.connection.send_im("some_other at msn_account", "some message") + a.connection.close + end p = Ruburple::get_protocol("MSN") puts "gonna connect to #{p.id}, #{p.name}, #{p.version}, #{p.summary}, #{p.description}, #{p.author}, #{p.homepage}" a = p.get_account("some at msn.account", "some_msn_password") a.connect - a.connection.send_im("some_other at msn_account", "some message") - a.connection.close == It doesnt work! From nobody at rubyforge.org Mon Dec 3 07:14:59 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Mon, 3 Dec 2007 07:14:59 -0500 (EST) Subject: [Ruburple-submits] [48] trunk/ruburple/README: uhm, i seem to have posted a broken example. Message-ID: <20071203121459.BDB4718585BC@rubyforge.org> Revision: 48 Author: zond Date: 2007-12-03 07:14:59 -0500 (Mon, 03 Dec 2007) Log Message: ----------- uhm, i seem to have posted a broken example. here is a working one... it is somewhat more complex, but it was necessary since I noticed that you cant call back inside libpurple in an event handler (which sucks, that should be fixed, really) Modified Paths: -------------- trunk/ruburple/README Modified: trunk/ruburple/README =================================================================== --- trunk/ruburple/README 2007-12-03 12:04:21 UTC (rev 47) +++ trunk/ruburple/README 2007-12-03 12:14:59 UTC (rev 48) @@ -24,20 +24,29 @@ == Usage example: -This example uses almost all methods defined in the ruburple gem. For a few other methods look at the test/ruburple_test.rb. +This example uses some methods defined in the ruburple gem. For a few other methods look at the test/ruburple_test.rb. require 'ruburple' + require 'monitor' + signed_on_lock = Monitor.new + signed_on_flag = MonitorMixin::ConditionVariable.new(signed_on_lock) Ruburple::init Ruburple::subscribe(:received_im_msg) do |a,b,c,d,e| puts "rcv im: #{a}, #{b}, #{c}, #{d}, #{e}" end - Ruburple::subscribe(:signed_on) do |a| - puts "signed on: #{a}" - a.connection.send_im("some_other at msn_account", "some message") - a.connection.close + Ruburple::subscribe(:signed_on) do |c| + puts "signed on: #{c}" + signed_on_lock.synchronize do + signed_on_flag.broadcast + end end - p = Ruburple::get_protocol("MSN") + 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("some at msn.account", "some_msn_password") + a = p.get_account("blabahtest1 at gmail.com", "blabah1") a.connect + signed_on_lock.synchronize do + signed_on_flag.wait + end + a.connection.send_im("zondolfin at gmail.com", "some message") + a.connection.close == It doesnt work! From nobody at rubyforge.org Fri Dec 7 07:42:20 2007 From: nobody at rubyforge.org (nobody at rubyforge.org) Date: Fri, 7 Dec 2007 07:42:20 -0500 (EST) Subject: [Ruburple-submits] [49] trunk/ruburple/ext/ruburple_ext.c: account#add_buddy(buddy_name) Message-ID: <20071207124221.0BECF18585E5@rubyforge.org> Revision: 49 Author: joe_edelman Date: 2007-12-07 07:42:20 -0500 (Fri, 07 Dec 2007) Log Message: ----------- account#add_buddy(buddy_name) I apologize for not adding these things to the tests. I haven't got the tests configured with two accounts etc on my system yet, just haven't taken the time. Nonetheless, add_buddy and the icon stuff seem to work well on Mac OS X Tiger and FreeBSD. --Joe Modified Paths: -------------- trunk/ruburple/ext/ruburple_ext.c Modified: trunk/ruburple/ext/ruburple_ext.c =================================================================== --- trunk/ruburple/ext/ruburple_ext.c 2007-12-03 12:14:59 UTC (rev 48) +++ trunk/ruburple/ext/ruburple_ext.c 2007-12-07 12:42:20 UTC (rev 49) @@ -1312,6 +1312,27 @@ } static gpointer +ruburple_protocol_account_add_buddy(gpointer data) +{ + gpointer *args = (gpointer *) data; + return purple_buddy_new((PurpleAccount *) args[0], (char *) args[1], NULL); +} + +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); + return RB_RUBURPLE_BLIST_BUDDY(buddy); +} + +static gpointer ruburple_protocol_account_get_buddy(gpointer data) { gpointer *args = (gpointer *) data; @@ -1627,6 +1648,7 @@ rb_define_method(rb_ruburple_protocol_account, "alias", rb_ruburple_protocol_account_get_alias, 0); rb_define_method(rb_ruburple_protocol_account, "has_buddy?", rb_ruburple_protocol_account_has_buddy, 1); rb_define_method(rb_ruburple_protocol_account, "get_buddy", rb_ruburple_protocol_account_get_buddy, 1); + rb_define_method(rb_ruburple_protocol_account, "add_buddy", rb_ruburple_protocol_account_add_buddy, 1); rb_define_method(rb_ruburple_protocol_account, "buddies", rb_ruburple_protocol_account_get_buddies, -1); rb_define_method(rb_ruburple_protocol_account, "uid", rb_ruburple_protocol_account_get_uid, 0); rb_define_method(rb_ruburple_protocol_account, "status", rb_ruburple_protocol_account_get_status, 0);