yong-purple_ruby 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.txt CHANGED
@@ -18,7 +18,8 @@ sudo gem install yong-purple_ruby
18
18
 
19
19
  Redhat/Centos
20
20
  ---------------
21
- Follow instructions here: http://www.pidgin.im/download/centos_rhel/
21
+ wget -O /etc/yum.repos.d/pidgin.repo http://rpm.pidgin.im/centos/pidgin.repo
22
+ yum -y install glib2-devel libpurple-devel
22
23
  gem sources -a http://gems.github.com (you only have to do this once)
23
24
  sudo gem install yong-purple_ruby
24
25
 
@@ -45,7 +46,7 @@ sudo gem install yong-purple_ruby
45
46
 
46
47
  == Copyright
47
48
 
48
- purple_ruby is Copyright (c) 2009 Xue Yong Zhi and Intridea, Inc., released under the GPL License.
49
+ purple_ruby is Copyright (c) 2009 Xue Yong Zhi and Intridea, Inc. ( http://intridea.com ), released under the GPL License.
49
50
 
50
51
 
51
52
 
data/Rakefile CHANGED
@@ -1,20 +1,7 @@
1
- require 'rubygems'
2
- require 'hoe'
3
1
 
4
- EXT = "ext/ruburple_ext.#{Hoe::DLEXT}"
2
+ EXT = "ext/ruburple_ext.#{Config::CONFIG['DLEXT']}"
5
3
 
6
- Hoe.new('purple_ruby', '0.5.3') do |p|
7
- p.author = 'yong'
8
- p.email = 'yong@intridea.com'
9
- p.url = 'http://www.intridea.com'
10
- p.summary = 'A ruby gem to write server that sends and recives IM messages'
11
- p.description = 'A ruby gem to write server that sends and recives IM messages'
12
-
13
- p.spec_extras[:extensions] = "ext/extconf.rb"
14
- p.clean_globs << EXT << "ext/*.o" << "ext/Makefile"
15
- end
16
-
17
- task :test => EXT
4
+ task :default => EXT
18
5
 
19
6
  file EXT => ["ext/extconf.rb", "ext/purple_ruby.c"] do
20
7
  Dir.chdir "ext" do
@@ -6,8 +6,8 @@
6
6
  #
7
7
  #Send im:
8
8
  #$ irb
9
- #irb(main):001:0> require 'lib/purplegw_ruby'
10
- #irb(main):007:0> PurpleGW.deliver 'prpl-jabber', 'friend@gmail.com', 'hello worlds!'
9
+ #irb(main):001:0> require 'examples/purplegw_example'
10
+ #irb(main):007:0> PurpleGWExample.deliver 'prpl-jabber', 'friend@gmail.com', 'hello worlds!'
11
11
  #
12
12
 
13
13
  require 'hpricot'
data/ext/purple_ruby.c CHANGED
@@ -134,6 +134,8 @@ static VALUE connection_error_handler = Qnil;
134
134
  static VALUE notify_message_handler = Qnil;
135
135
  static VALUE request_handler = Qnil;
136
136
  static VALUE ipc_handler = Qnil;
137
+ static VALUE timer_handler = Qnil;
138
+ guint timer_timeout = 0;
137
139
  VALUE new_buddy_handler = Qnil;
138
140
 
139
141
  extern void
@@ -364,7 +366,7 @@ static void sighandler(int sig)
364
366
  }
365
367
  }
366
368
 
367
- static VALUE init(VALUE self, VALUE debug)
369
+ static VALUE init(VALUE self, VALUE debug, VALUE path)
368
370
  {
369
371
  signal(SIGCHLD, SIG_IGN);
370
372
  signal(SIGPIPE, SIG_IGN);
@@ -374,6 +376,11 @@ static VALUE init(VALUE self, VALUE debug)
374
376
  fd_hash_table = g_hash_table_new(NULL, NULL);
375
377
 
376
378
  purple_debug_set_enabled((debug == Qnil || debug == Qfalse) ? FALSE : TRUE);
379
+
380
+ if (path != Qnil) {
381
+ purple_util_set_user_dir(RSTRING(path)->ptr);
382
+ }
383
+
377
384
  purple_core_set_ui_ops(&core_uiops);
378
385
  purple_eventloop_set_ui_ops(&glib_eventloops);
379
386
 
@@ -554,6 +561,24 @@ static VALUE watch_incoming_ipc(VALUE self, VALUE serverip, VALUE port)
554
561
  return port;
555
562
  }
556
563
 
564
+ static gboolean
565
+ do_timeout(gpointer data)
566
+ {
567
+ VALUE handler = data;
568
+ check_callback(handler, "timer_handler");
569
+ VALUE v = rb_funcall(handler, CALL, 0, 0);
570
+ return (v == Qtrue);
571
+ }
572
+
573
+ static VALUE watch_timer(VALUE self, VALUE delay)
574
+ {
575
+ set_callback(&timer_handler, "timer_handler");
576
+ if (timer_timeout != 0)
577
+ g_source_remove(timer_timeout);
578
+ timer_timeout = g_timeout_add(delay, do_timeout, timer_handler);
579
+ return delay;
580
+ }
581
+
557
582
  static VALUE login(VALUE self, VALUE protocol, VALUE username, VALUE password)
558
583
  {
559
584
  PurpleAccount* account = purple_account_new(RSTRING(username)->ptr, RSTRING(protocol)->ptr);
@@ -561,6 +586,7 @@ static VALUE login(VALUE self, VALUE protocol, VALUE username, VALUE password)
561
586
  rb_raise(rb_eRuntimeError, "No able to create account: %s", RSTRING(protocol)->ptr);
562
587
  }
563
588
  purple_account_set_password(account, RSTRING(password)->ptr);
589
+ purple_account_set_remember_password(account, TRUE);
564
590
  purple_account_set_enabled(account, UI_ID, TRUE);
565
591
  PurpleSavedStatus *status = purple_savedstatus_new(NULL, PURPLE_STATUS_AVAILABLE);
566
592
  purple_savedstatus_activate(status);
@@ -582,6 +608,8 @@ static VALUE main_loop_run(VALUE self)
582
608
  if (notify_message_handler == Qnil) rb_gc_unregister_address(&notify_message_handler);
583
609
  if (request_handler == Qnil) rb_gc_unregister_address(&request_handler);
584
610
  if (ipc_handler == Qnil) rb_gc_unregister_address(&ipc_handler);
611
+ if (timer_timeout != 0) g_source_remove(timer_timeout);
612
+ if (timer_handler == Qnil) rb_gc_unregister_address(&timer_handler);
585
613
  if (new_buddy_handler == Qnil) rb_gc_unregister_address(&new_buddy_handler);
586
614
  rb_gc_start();
587
615
  #endif
@@ -719,12 +747,20 @@ static VALUE has_buddy(VALUE self, VALUE buddy)
719
747
  }
720
748
  }
721
749
 
750
+ static VALUE acc_delete(VALUE self)
751
+ {
752
+ PurpleAccount *account;
753
+ Data_Get_Struct(self, PurpleAccount, account);
754
+ purple_accounts_delete(account);
755
+ return Qnil;
756
+ }
757
+
722
758
  void Init_purple_ruby()
723
759
  {
724
760
  CALL = rb_intern("call");
725
761
 
726
762
  cPurpleRuby = rb_define_class("PurpleRuby", rb_cObject);
727
- rb_define_singleton_method(cPurpleRuby, "init", init, 1);
763
+ rb_define_singleton_method(cPurpleRuby, "init", init, 2);
728
764
  rb_define_singleton_method(cPurpleRuby, "list_protocols", list_protocols, 0);
729
765
  rb_define_singleton_method(cPurpleRuby, "watch_signed_on_event", watch_signed_on_event, 0);
730
766
  rb_define_singleton_method(cPurpleRuby, "watch_connection_error", watch_connection_error, 0);
@@ -733,6 +769,7 @@ void Init_purple_ruby()
733
769
  rb_define_singleton_method(cPurpleRuby, "watch_request", watch_request, 0);
734
770
  rb_define_singleton_method(cPurpleRuby, "watch_new_buddy", watch_new_buddy, 0);
735
771
  rb_define_singleton_method(cPurpleRuby, "watch_incoming_ipc", watch_incoming_ipc, 2);
772
+ rb_define_singleton_method(cPurpleRuby, "watch_timer", watch_timer, 1);
736
773
  rb_define_singleton_method(cPurpleRuby, "login", login, 3);
737
774
  rb_define_singleton_method(cPurpleRuby, "main_loop_run", main_loop_run, 0);
738
775
  rb_define_singleton_method(cPurpleRuby, "main_loop_stop", main_loop_stop, 0);
@@ -751,4 +788,5 @@ void Init_purple_ruby()
751
788
  rb_define_method(cAccount, "add_buddy", add_buddy, 1);
752
789
  rb_define_method(cAccount, "remove_buddy", remove_buddy, 1);
753
790
  rb_define_method(cAccount, "has_buddy?", has_buddy, 1);
791
+ rb_define_method(cAccount, "delete", acc_delete, 0);
754
792
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yong-purple_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yong
@@ -44,6 +44,7 @@ files:
44
44
  - Rakefile
45
45
  has_rdoc: false
46
46
  homepage: http://www.intridea.com
47
+ licenses:
47
48
  post_install_message:
48
49
  rdoc_options:
49
50
  - --main
@@ -65,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
66
  requirements: []
66
67
 
67
68
  rubyforge_project: purplegw_ruby
68
- rubygems_version: 1.2.0
69
+ rubygems_version: 1.3.5
69
70
  signing_key:
70
71
  specification_version: 2
71
72
  summary: A ruby gem to write server that sends and recives IM messages