dbus 0.1.7 → 0.1.8
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/ext/ruby-dbus-connection.c +55 -26
- data/ext/ruby-dbus-message-iter.c +2 -4
- data/ext/ruby-dbus-message.c +2 -0
- data/ext/ruby-dbus.h +0 -2
- data/lib/dbus/version.rb +1 -1
- metadata +2 -2
data/ext/ruby-dbus-connection.c
CHANGED
@@ -8,37 +8,72 @@
|
|
8
8
|
|
9
9
|
#include "ruby-dbus.h"
|
10
10
|
|
11
|
+
typedef struct _RubyDBusConnection {
|
12
|
+
DBusConnection *conn;
|
13
|
+
VALUE callbacks;
|
14
|
+
} RubyDBusConnection;
|
15
|
+
|
11
16
|
VALUE cDBusConnection;
|
12
17
|
|
13
18
|
static void
|
14
|
-
|
19
|
+
rdbus_mark_connection(RubyDBusConnection *wrapper)
|
20
|
+
{
|
21
|
+
DEBUG("DBusConnection.mark <%p>", wrapper->conn);
|
22
|
+
rb_gc_mark(wrapper->callbacks);
|
23
|
+
}
|
24
|
+
|
25
|
+
static void
|
26
|
+
rdbus_free_connection(RubyDBusConnection *wrapper)
|
15
27
|
{
|
16
|
-
DEBUG("DBusConnection.free <%p>", conn);
|
17
|
-
dbus_connection_unref(
|
28
|
+
DEBUG("DBusConnection.free <%p>", wrapper->conn);
|
29
|
+
dbus_connection_unref(wrapper->conn);
|
30
|
+
rb_ary_clear(wrapper->callbacks);
|
31
|
+
wrapper->conn = NULL;
|
32
|
+
wrapper->callbacks = Qnil;
|
33
|
+
ruby_xfree(wrapper);
|
34
|
+
}
|
35
|
+
|
36
|
+
static RubyDBusConnection *
|
37
|
+
rdbus_get_connection_wrapper(VALUE obj)
|
38
|
+
{
|
39
|
+
RubyDBusConnection *wrapper;
|
40
|
+
|
41
|
+
wrapper = NULL;
|
42
|
+
Data_Get_Struct(obj, RubyDBusConnection, wrapper);
|
43
|
+
if (wrapper == NULL)
|
44
|
+
rb_raise(eDBusError, "Failed to retrieve DATA object for DBusConnection");
|
45
|
+
return wrapper;
|
18
46
|
}
|
19
47
|
|
20
48
|
VALUE
|
21
49
|
rdbus_new_connection(DBusConnection *conn, gboolean owner)
|
22
50
|
{
|
51
|
+
RubyDBusConnection *wrapper;
|
52
|
+
|
53
|
+
wrapper = ALLOC(RubyDBusConnection);
|
54
|
+
wrapper->conn = conn;
|
55
|
+
wrapper->callbacks = rb_ary_new();
|
56
|
+
|
23
57
|
if (!owner)
|
24
|
-
dbus_connection_ref(conn);
|
25
|
-
DEBUG("DBusConnection.new <%p> owner=%d", conn, owner);
|
26
|
-
return Data_Wrap_Struct(cDBusConnection,
|
58
|
+
dbus_connection_ref(wrapper->conn);
|
59
|
+
DEBUG("DBusConnection.new <%p> owner=%d", wrapper->conn, owner);
|
60
|
+
return Data_Wrap_Struct(cDBusConnection, rdbus_mark_connection, rdbus_free_connection, wrapper);
|
27
61
|
}
|
28
62
|
|
29
63
|
DBusConnection *
|
30
64
|
rdbus_get_connection(VALUE obj)
|
31
65
|
{
|
32
|
-
|
33
|
-
|
34
|
-
conn = NULL;
|
35
|
-
Data_Get_Struct(obj, DBusConnection, conn);
|
36
|
-
if (conn == NULL)
|
37
|
-
rb_raise(eDBusError, "Failed to retrieve DATA object for DBusConnection");
|
38
|
-
return conn;
|
66
|
+
return rdbus_get_connection_wrapper(obj)->conn;
|
39
67
|
}
|
40
68
|
|
41
|
-
|
69
|
+
static void
|
70
|
+
rdbus_register_connection_callback(VALUE self, VALUE callback)
|
71
|
+
{
|
72
|
+
RubyDBusConnection *wrapper;
|
73
|
+
|
74
|
+
wrapper = rdbus_get_connection_wrapper(self);
|
75
|
+
rb_ary_push(wrapper->callbacks, callback);
|
76
|
+
}
|
42
77
|
|
43
78
|
/*
|
44
79
|
* call-seq:
|
@@ -440,9 +475,6 @@ _on_object_path_unregister(DBusConnection *conn, void *user_data)
|
|
440
475
|
if (exc)
|
441
476
|
rb_warn("Unregister callback raised exception (ignored)");
|
442
477
|
|
443
|
-
rb_gc_unregister_address(&unregister_cb);
|
444
|
-
rb_gc_unregister_address(&message_cb);
|
445
|
-
|
446
478
|
ruby_xfree(data);
|
447
479
|
}
|
448
480
|
|
@@ -517,8 +549,8 @@ cDBusConnection_register_object_path(VALUE self, VALUE path,
|
|
517
549
|
if (dbus_connection_register_object_path(CONN_GET(self), StringValuePtr(path),
|
518
550
|
&vtable, (void *)user_data))
|
519
551
|
{
|
520
|
-
|
521
|
-
|
552
|
+
rdbus_register_connection_callback(self, unregister_cb);
|
553
|
+
rdbus_register_connection_callback(self, message_cb);
|
522
554
|
return Qtrue;
|
523
555
|
}
|
524
556
|
|
@@ -561,8 +593,8 @@ cDBusConnection_register_fallback(VALUE self, VALUE path,
|
|
561
593
|
if (dbus_connection_register_fallback(CONN_GET(self), StringValuePtr(path),
|
562
594
|
&vtable, (void *)user_data))
|
563
595
|
{
|
564
|
-
|
565
|
-
|
596
|
+
rdbus_register_connection_callback(self, unregister_cb);
|
597
|
+
rdbus_register_connection_callback(self, message_cb);
|
566
598
|
return Qtrue;
|
567
599
|
}
|
568
600
|
|
@@ -573,10 +605,7 @@ cDBusConnection_register_fallback(VALUE self, VALUE path,
|
|
573
605
|
static void
|
574
606
|
_free_filter_data(void *user_data)
|
575
607
|
{
|
576
|
-
|
577
|
-
VALUE filter_cb = data[0];
|
578
|
-
rb_gc_unregister_address(&filter_cb);
|
579
|
-
ruby_xfree(data);
|
608
|
+
ruby_xfree(user_data);
|
580
609
|
}
|
581
610
|
|
582
611
|
static VALUE
|
@@ -645,7 +674,7 @@ cDBusConnection_add_filter(VALUE self, VALUE filter_cb)
|
|
645
674
|
if (dbus_connection_add_filter(CONN_GET(self), _on_filter_message,
|
646
675
|
(void*)data, _free_filter_data))
|
647
676
|
{
|
648
|
-
|
677
|
+
rdbus_register_connection_callback(self, filter_cb);
|
649
678
|
return Qtrue;
|
650
679
|
}
|
651
680
|
|
@@ -9,12 +9,10 @@
|
|
9
9
|
#include <stdlib.h>
|
10
10
|
#include "ruby-dbus.h"
|
11
11
|
|
12
|
-
|
13
|
-
* when the DBusMessageIter instance is GC'd. */
|
14
|
-
struct _RubyDBusMessageIter {
|
12
|
+
typedef struct _RubyDBusMessageIter {
|
15
13
|
DBusMessageIter *real_iter;
|
16
14
|
DBusMessage *message;
|
17
|
-
};
|
15
|
+
} RubyDBusMessageIter;
|
18
16
|
|
19
17
|
VALUE cDBusMessageIter;
|
20
18
|
|
data/ext/ruby-dbus-message.c
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
|
11
11
|
VALUE cDBusMessage;
|
12
12
|
|
13
|
+
#ifdef RDBUS_DEBUG
|
13
14
|
static const char *
|
14
15
|
rdbus_message_type_string(DBusMessage *message)
|
15
16
|
{
|
@@ -31,6 +32,7 @@ rdbus_message_type_string(DBusMessage *message)
|
|
31
32
|
return "Unknown";
|
32
33
|
}
|
33
34
|
}
|
35
|
+
#endif
|
34
36
|
|
35
37
|
static void
|
36
38
|
rdbus_free_message(void *message)
|
data/ext/ruby-dbus.h
CHANGED
data/lib/dbus/version.rb
CHANGED