dbus 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/ruby-dbus-bus.c +110 -0
- data/ext/ruby-dbus-connection.c +14 -22
- data/lib/dbus.rb +20 -0
- data/lib/dbus/version.rb +1 -1
- data/test/tc_connection.rb +8 -0
- metadata +5 -4
data/ext/ruby-dbus-bus.c
CHANGED
@@ -43,6 +43,74 @@ mDBusBinding_bus_get(int argc, VALUE *argv)
|
|
43
43
|
return CONN_NEW(conn);
|
44
44
|
}
|
45
45
|
|
46
|
+
/*
|
47
|
+
* call-seq:
|
48
|
+
* bus_register(connection) => true|false
|
49
|
+
*
|
50
|
+
* Registers a connection with the bus
|
51
|
+
*/
|
52
|
+
static VALUE
|
53
|
+
mDBusBinding_bus_register(VALUE klass, VALUE conn)
|
54
|
+
{
|
55
|
+
dbus_bool_t ret;
|
56
|
+
|
57
|
+
ret = FALSE;
|
58
|
+
RDBUS_TRY(
|
59
|
+
ret = dbus_bus_register(CONN_GET(conn), &error)
|
60
|
+
);
|
61
|
+
|
62
|
+
if (ret)
|
63
|
+
return Qtrue;
|
64
|
+
return Qfalse;
|
65
|
+
}
|
66
|
+
|
67
|
+
/*
|
68
|
+
* call-seq:
|
69
|
+
* bus_set_base_service(connection, base_service) => true|false
|
70
|
+
*
|
71
|
+
* Sets the base service name of the given connection.
|
72
|
+
*
|
73
|
+
*/
|
74
|
+
static VALUE
|
75
|
+
mDBusBinding_bus_set_base_service(VALUE klass, VALUE conn, VALUE name)
|
76
|
+
{
|
77
|
+
if (!dbus_bus_set_base_service(CONN_GET(conn), StringValuePtr(name)))
|
78
|
+
return Qfalse;
|
79
|
+
return Qtrue;
|
80
|
+
}
|
81
|
+
|
82
|
+
/*
|
83
|
+
* call-seq:
|
84
|
+
* bus_get_base_service(connection) => name
|
85
|
+
*
|
86
|
+
* Gets the base service name of the given connection. This value can be used
|
87
|
+
* for the +destination+ field of a DBusMessage.
|
88
|
+
*/
|
89
|
+
static VALUE
|
90
|
+
mDBusBinding_bus_get_base_service(VALUE klass, VALUE conn)
|
91
|
+
{
|
92
|
+
return rb_str_new2(dbus_bus_get_base_service(CONN_GET(conn)));
|
93
|
+
}
|
94
|
+
|
95
|
+
/*
|
96
|
+
* call-seq:
|
97
|
+
* bus_get_unix_user(connection, service_name) => uid
|
98
|
+
*
|
99
|
+
* Gets the UNIX user ID for for the given service on this bus.
|
100
|
+
*/
|
101
|
+
static VALUE
|
102
|
+
mDBusBinding_bus_get_unix_user(VALUE klass, VALUE conn, VALUE name)
|
103
|
+
{
|
104
|
+
VALUE uid;
|
105
|
+
|
106
|
+
uid = -1;
|
107
|
+
RDBUS_TRY(
|
108
|
+
uid = LONG2NUM(dbus_bus_get_unix_user(CONN_GET(conn),
|
109
|
+
StringValuePtr(name), &error))
|
110
|
+
);
|
111
|
+
return uid;
|
112
|
+
}
|
113
|
+
|
46
114
|
/*
|
47
115
|
* call-seq:
|
48
116
|
* bus_acquire_service(connection, service_name, [flags=0]) => retcode
|
@@ -135,11 +203,53 @@ mDBusBinding_bus_remove_match(VALUE klass, VALUE conn, VALUE rule)
|
|
135
203
|
return Qnil;
|
136
204
|
}
|
137
205
|
|
206
|
+
/*
|
207
|
+
* call-seq:
|
208
|
+
* bus_activate_service(connection, service_name, [flags=0]) => [true|false, result]
|
209
|
+
*
|
210
|
+
* Activates the given service. The flags parameter currently (D-BUS 0.22) does
|
211
|
+
* nothing.
|
212
|
+
*/
|
213
|
+
static VALUE
|
214
|
+
mDBusBinding_bus_activate_service(int argc, VALUE *argv)
|
215
|
+
{
|
216
|
+
VALUE conn;
|
217
|
+
VALUE name;
|
218
|
+
VALUE flags;
|
219
|
+
dbus_uint32_t service_flags;
|
220
|
+
dbus_uint32_t result;
|
221
|
+
VALUE ret;
|
222
|
+
dbus_bool_t dbus_ret;
|
223
|
+
|
224
|
+
conn = name = flags = Qnil;
|
225
|
+
service_flags = 0;
|
226
|
+
rb_scan_args(argc, argv, "21", &conn, &name, &flags);
|
227
|
+
if (flags != Qnil)
|
228
|
+
service_flags = NUM2INT(flags);
|
229
|
+
|
230
|
+
result = 0;
|
231
|
+
dbus_ret = FALSE;
|
232
|
+
RDBUS_TRY(
|
233
|
+
dbus_ret = dbus_bus_activate_service(CONN_GET(conn), StringValuePtr(name),
|
234
|
+
service_flags, &result, &error)
|
235
|
+
);
|
236
|
+
|
237
|
+
ret = rb_ary_new();
|
238
|
+
rb_ary_push(ret, dbus_ret ? Qtrue : Qfalse);
|
239
|
+
rb_ary_push(ret, INT2NUM(result));
|
240
|
+
return ret;
|
241
|
+
}
|
242
|
+
|
138
243
|
void Init_dbus_bus()
|
139
244
|
{
|
140
245
|
rb_define_module_function(mDBusBinding, "bus_get", mDBusBinding_bus_get, -1);
|
246
|
+
rb_define_module_function(mDBusBinding, "bus_register", mDBusBinding_bus_register, 1);
|
247
|
+
rb_define_module_function(mDBusBinding, "bus_set_base_service", mDBusBinding_bus_set_base_service, 2);
|
248
|
+
rb_define_module_function(mDBusBinding, "bus_get_base_service", mDBusBinding_bus_get_base_service, 1);
|
249
|
+
rb_define_module_function(mDBusBinding, "bus_get_unix_user", mDBusBinding_bus_get_unix_user, 2);
|
141
250
|
rb_define_module_function(mDBusBinding, "bus_acquire_service", mDBusBinding_bus_acquire_service, -1);
|
142
251
|
rb_define_module_function(mDBusBinding, "bus_service_exists", mDBusBinding_bus_service_exists, 2);
|
252
|
+
rb_define_module_function(mDBusBinding, "bus_activate_service", mDBusBinding_bus_activate_service, -1);
|
143
253
|
rb_define_module_function(mDBusBinding, "bus_add_match", mDBusBinding_bus_add_match, 2);
|
144
254
|
rb_define_module_function(mDBusBinding, "bus_remove_match", mDBusBinding_bus_remove_match, 2);
|
145
255
|
}
|
data/ext/ruby-dbus-connection.c
CHANGED
@@ -99,19 +99,6 @@ cDBusConnection_open(VALUE klass, VALUE address)
|
|
99
99
|
return CONN_NEW_TAKE_OWNERSHIP(conn);
|
100
100
|
}
|
101
101
|
|
102
|
-
/*
|
103
|
-
* call-seq:
|
104
|
-
* get_base_service => name
|
105
|
-
*
|
106
|
-
* Gets the base service name of the connection. This value can be used
|
107
|
-
* for the +destination+ field of a DBusMessage.
|
108
|
-
*/
|
109
|
-
static VALUE
|
110
|
-
cDBusConnection_get_base_service(VALUE self)
|
111
|
-
{
|
112
|
-
return rb_str_new2(dbus_bus_get_base_service(CONN_GET(self)));
|
113
|
-
}
|
114
|
-
|
115
102
|
/*
|
116
103
|
* call-seq:
|
117
104
|
* setup_with_g_main => nil
|
@@ -472,8 +459,10 @@ _on_object_path_unregister(DBusConnection *conn, void *user_data)
|
|
472
459
|
exc = 0;
|
473
460
|
rb_protect(_real_call_unregister_cb, (VALUE)args, &exc);
|
474
461
|
|
475
|
-
if (exc)
|
476
|
-
rb_warn("Unregister callback raised exception (ignored)");
|
462
|
+
if (exc) {
|
463
|
+
rb_warn("Unregister callback raised exception (ignored), backtrace:");
|
464
|
+
rb_backtrace();
|
465
|
+
}
|
477
466
|
|
478
467
|
ruby_xfree(data);
|
479
468
|
}
|
@@ -505,10 +494,12 @@ _on_object_path_message(DBusConnection *conn, DBusMessage *msg, void *user_data)
|
|
505
494
|
exc = 0;
|
506
495
|
ret = rb_protect(_real_call_message_cb, (VALUE)args, &exc);
|
507
496
|
|
508
|
-
if (exc)
|
509
|
-
rb_warn("Message callback raised exception (ignored)");
|
497
|
+
if (exc) {
|
498
|
+
rb_warn("Message callback raised exception (ignored), backtrace:");
|
499
|
+
rb_backtrace();
|
500
|
+
}
|
510
501
|
|
511
|
-
if (ret
|
502
|
+
if (NIL_P(ret))
|
512
503
|
result = DBUS_HANDLER_RESULT_HANDLED;
|
513
504
|
result = NUM2INT(ret);
|
514
505
|
return result;
|
@@ -635,10 +626,12 @@ _on_filter_message(DBusConnection *conn, DBusMessage *msg, void *user_data)
|
|
635
626
|
exc = 0;
|
636
627
|
ret = rb_protect(_real_call_filter_cb, (VALUE)args, &exc);
|
637
628
|
|
638
|
-
if (exc)
|
639
|
-
rb_warn("Filter callback raised exception (ignored)");
|
629
|
+
if (exc) {
|
630
|
+
rb_warn("Filter callback raised exception (ignored), backtrace:");
|
631
|
+
rb_backtrace();
|
632
|
+
}
|
640
633
|
|
641
|
-
if (ret
|
634
|
+
if (NIL_P(ret))
|
642
635
|
result = DBUS_HANDLER_RESULT_HANDLED;
|
643
636
|
result = NUM2INT(ret);
|
644
637
|
return result;
|
@@ -739,7 +732,6 @@ Init_dbus_connection()
|
|
739
732
|
rb_define_singleton_method(cDBusConnection, "open", cDBusConnection_open, 1);
|
740
733
|
rb_define_singleton_method(cDBusConnection, "new", cDBusConnection_open, 1);
|
741
734
|
|
742
|
-
rb_define_method(cDBusConnection, "get_base_service", cDBusConnection_get_base_service, 0);
|
743
735
|
rb_define_method(cDBusConnection, "setup_with_g_main", cDBusConnection_setup_with_g_main, 0);
|
744
736
|
rb_define_method(cDBusConnection, "disconnect", cDBusConnection_disconnect, 0);
|
745
737
|
rb_define_method(cDBusConnection, "get_is_connected", cDBusConnection_get_is_connected, 0);
|
data/lib/dbus.rb
CHANGED
@@ -87,6 +87,26 @@ module DBus
|
|
87
87
|
rule
|
88
88
|
end
|
89
89
|
|
90
|
+
# Activates the given service on this bus
|
91
|
+
def activate_service(service_name, flags=0)
|
92
|
+
DBus::Binding::bus_activate_service(@connection, service_name, flags)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Returns the UNIX user ID for the given service
|
96
|
+
def get_unix_user(service_name)
|
97
|
+
DBus::Binding::bus_get_unix_user(@connection, service_name)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Returns the base service name of this bus
|
101
|
+
def get_base_service
|
102
|
+
DBus::Binding::bus_get_base_service(@connection)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Sets the base service name of this bus
|
106
|
+
def set_base_service(service_name)
|
107
|
+
DBus::Binding::bus_set_base_service(@connection, service_name)
|
108
|
+
end
|
109
|
+
|
90
110
|
protected
|
91
111
|
def signal_dispatcher(connection, message)
|
92
112
|
return HANDLER_RESULT_NOT_YET_HANDLED unless message.get_type == MESSAGE_TYPE_SIGNAL
|
data/lib/dbus/version.rb
CHANGED
data/test/tc_connection.rb
CHANGED
@@ -19,6 +19,14 @@ class TC_DBusConnection < Test::Unit::TestCase
|
|
19
19
|
conn = DBus::Binding::bus_get(DBus::BUS_SYSTEM)
|
20
20
|
assert(!conn.nil?)
|
21
21
|
assert(conn.is_a?(DBus::Binding::DBusConnection))
|
22
|
+
service_name = DBus::Binding::bus_get_base_service(conn)
|
23
|
+
assert(!service_name.nil?)
|
24
|
+
# uid = DBus::Binding::bus_get_unix_user(conn, nil)
|
25
|
+
# p uid
|
26
|
+
# assert(uid)
|
27
|
+
DBus::Binding::bus_set_base_service(conn, "test.service.Name")
|
28
|
+
assert(DBus::Binding::bus_get_base_service(conn) == "test.service.Name")
|
29
|
+
#DBus::Binding::bus_activate_service(conn, "org.gnomemeeting.instance")
|
22
30
|
end
|
23
31
|
|
24
32
|
def test_conn_open_new
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.3
|
3
3
|
specification_version: 1
|
4
4
|
name: dbus
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2004-12-
|
6
|
+
version: 0.1.9
|
7
|
+
date: 2004-12-28
|
8
8
|
summary: Ruby bindings for D-BUS.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
|
-
author: Leon Breedt
|
12
11
|
email: bitserf@gmail.com
|
13
12
|
homepage: http://rubyforge.org/projects/dbus-ruby
|
14
13
|
rubyforge_project: dbus-ruby
|
@@ -25,6 +24,8 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
24
|
version: 0.0.0
|
26
25
|
version:
|
27
26
|
platform: ruby
|
27
|
+
authors:
|
28
|
+
- Leon Breedt
|
28
29
|
files:
|
29
30
|
- examples/example-signal-emitter.rb
|
30
31
|
- examples/list-session-services.rb
|