yong-purple_ruby 0.1.0 → 0.1.1

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/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'hoe'
3
3
 
4
4
  EXT = "ext/ruburple_ext.#{Hoe::DLEXT}"
5
5
 
6
- Hoe.new('purple_ruby', '0.1.0') do |p|
6
+ Hoe.new('purple_ruby', '0.1.1') do |p|
7
7
  p.author = 'yong'
8
8
  p.email = 'yong@intridea.com'
9
9
  p.url = 'http://www.intridea.com'
@@ -53,13 +53,7 @@ class PurpleGWExample
53
53
  puts "send: #{protocol}, #{user}, #{message}"
54
54
  accounts[protocol].send_im(user, message)
55
55
  end
56
-
57
- trap("INT") {
58
- #TODO ctrl-c can not be detected until a message is coming
59
- puts 'Ctrl-C, quit...'
60
- PurpleRuby.main_loop_stop
61
- }
62
-
56
+
63
57
  PurpleRuby.main_loop_run
64
58
  end
65
59
 
data/ext/purple_ruby.c CHANGED
@@ -20,6 +20,7 @@
20
20
 
21
21
  #include <ruby.h>
22
22
  #include <errno.h>
23
+ #include <signal.h>
23
24
  #include <stdarg.h>
24
25
  #include <netinet/in.h>
25
26
  #include <sys/socket.h>
@@ -162,8 +163,22 @@ static PurpleCoreUiOps core_uiops =
162
163
  NULL
163
164
  };
164
165
 
166
+ static void
167
+ sighandler(int sig)
168
+ {
169
+ switch (sig) {
170
+ case SIGINT:
171
+ g_main_loop_quit(main_loop);
172
+ break;
173
+ }
174
+ }
175
+
176
+
165
177
  static VALUE init(VALUE self, VALUE debug)
166
178
  {
179
+ signal(SIGPIPE, SIG_IGN);
180
+ signal(SIGINT, sighandler);
181
+
167
182
  hash_table = g_hash_table_new(NULL, NULL);
168
183
 
169
184
  purple_debug_set_enabled((debug == Qnil || debug == Qfalse) ? FALSE : TRUE);
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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - yong