strophe_ruby 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/Rakefile +1 -1
  2. data/ext/strophe_ruby/strophe_ruby.c +17 -13
  3. metadata +2 -2
data/Rakefile CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # Generate all the Rake tasks
5
5
  # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
- $hoe = Hoe.new('strophe_ruby', '0.0.3') do |p|
6
+ $hoe = Hoe.new('strophe_ruby', '0.0.4') do |p|
7
7
  p.developer('François Lamontagne', 'flamontagne@gmail.com')
8
8
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
9
  p.rubyforge_name = p.name # TODO this is default value
@@ -14,8 +14,9 @@ VALUE client_conn_handler;
14
14
  VALUE cStanza;
15
15
 
16
16
  /* release the stanza. Called automatically by the GC */
17
- static void t_xmpp_stanza_release(xmpp_stanza_t *stanza) {
18
- xmpp_stanza_release(stanza);
17
+ static void t_xmpp_stanza_release(void *stanza) {
18
+ if(stanza != NULL)
19
+ xmpp_stanza_release(stanza);
19
20
  }
20
21
 
21
22
  /* Initialize the strophe library */
@@ -60,9 +61,11 @@ VALUE t_xmpp_stop(VALUE self, VALUE rb_ctx) {
60
61
  return Qtrue;
61
62
  }
62
63
 
63
- /* free the context object (called by the GC) */
64
- static void t_xmpp_ctx_free(xmpp_ctx_t *ctx) {
65
- xmpp_ctx_free(ctx);
64
+ /* free the context object (because it causes segmentation error once in a while) */
65
+ static VALUE t_xmpp_ctx_free(VALUE self) {
66
+ xmpp_ctx_t *ctx;
67
+ Data_Get_Struct(self,xmpp_ctx_t,ctx);
68
+ xmpp_ctx_free(ctx);
66
69
  }
67
70
 
68
71
  /* Get the status of the control loop
@@ -90,7 +93,7 @@ VALUE t_xmpp_ctx_new(VALUE class, VALUE log_level) {
90
93
  level=FIX2INT(log_level);
91
94
  log = xmpp_get_default_logger((xmpp_log_level_t)level);
92
95
  xmpp_ctx_t *ctx = xmpp_ctx_new(NULL, log);
93
- VALUE tdata = Data_Wrap_Struct(class, 0, t_xmpp_ctx_free, ctx);
96
+ VALUE tdata = Data_Wrap_Struct(class, 0, free, ctx);
94
97
  VALUE argv[1];
95
98
  argv[0] = log_level;
96
99
  rb_obj_call_init(tdata,1,argv);
@@ -103,12 +106,13 @@ static VALUE t_xmpp_ctx_init(VALUE self, VALUE log_level) {
103
106
  return self;
104
107
  }
105
108
 
106
- /* Release the connection object. (called by GC) */
107
- static void t_xmpp_conn_release(xmpp_conn_t *conn) {
108
- xmpp_conn_release(conn);
109
+ /* Release the connection object. (Currently not called at all... because it causes segmentation error once in a while) */
110
+ static VALUE t_xmpp_conn_release(VALUE self) {
111
+ xmpp_conn_t *conn;
112
+ Data_Get_Struct(self,xmpp_conn_t,conn);
113
+ xmpp_conn_release(conn);
109
114
  }
110
115
 
111
-
112
116
  /* Initialize a connection object. We register instance variables that will hold the various callbacks
113
117
  You should not manipulate instance variables. Use add_handler instead.
114
118
  Maybe put this into xmpp_conn_new?
@@ -130,7 +134,7 @@ VALUE t_xmpp_conn_new(VALUE class, VALUE rb_ctx) {
130
134
  Data_Get_Struct(rb_ctx, xmpp_ctx_t, ctx);
131
135
 
132
136
  xmpp_conn_t *conn = xmpp_conn_new(ctx);
133
- VALUE tdata = Data_Wrap_Struct(class, 0, t_xmpp_conn_release, conn);
137
+ VALUE tdata = Data_Wrap_Struct(class, 0, free, conn);
134
138
  VALUE argv[1];
135
139
  argv[0] = rb_ctx;
136
140
 
@@ -613,7 +617,7 @@ void Init_strophe_ruby() {
613
617
  cContext = rb_define_class_under(mStropheRuby, "Context", rb_cObject);
614
618
  rb_define_singleton_method(cContext, "new", t_xmpp_ctx_new, 1);
615
619
  rb_define_method(cContext, "initialize", t_xmpp_ctx_init, 1);
616
- //rb_define_method(cContext, "free", t_xmpp_ctx_free, 0);
620
+ rb_define_method(cContext, "free", t_xmpp_ctx_free, 0);
617
621
  rb_define_method(cContext, "loop_status", t_xmpp_get_loop_status, 0);
618
622
  rb_define_method(cContext, "loop_status=", t_xmpp_set_loop_status, 1);
619
623
 
@@ -622,7 +626,7 @@ void Init_strophe_ruby() {
622
626
  rb_define_singleton_method(cConnection, "new", t_xmpp_conn_new, 1);
623
627
  rb_define_method(cConnection, "initialize", t_xmpp_conn_init, 1);
624
628
  rb_define_method(cConnection, "clone", t_xmpp_conn_clone, 1);
625
- //rb_define_method(cConnection, "release", t_xmpp_conn_release, 0);
629
+ rb_define_method(cConnection, "release", t_xmpp_conn_release, 0);
626
630
  rb_define_method(cConnection, "jid", t_xmpp_conn_get_jid,0);
627
631
  rb_define_method(cConnection, "jid=", t_xmpp_conn_set_jid,1);
628
632
  rb_define_method(cConnection, "password", t_xmpp_conn_get_pass,0);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strophe_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Fran\xC3\xA7ois Lamontagne"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-11 00:00:00 -05:00
12
+ date: 2008-12-12 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency