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 +1 -1
- data/examples/purplegw_example.rb +1 -7
- data/ext/purple_ruby.c +15 -0
- metadata +1 -1
data/Rakefile
CHANGED
@@ -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);
|