circus-deployment 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +23 -0
- data/README.md +0 -0
- data/bin/circus +24 -0
- data/lib/bundler/circus_bundler.rb +24 -0
- data/lib/bundler/circus_util.rb +43 -0
- data/lib/bundler/patches.rb +18 -0
- data/lib/circus/act.rb +74 -0
- data/lib/circus/actstore_client.rb +30 -0
- data/lib/circus/agents/agent.rb +59 -0
- data/lib/circus/agents/client.rb +77 -0
- data/lib/circus/agents/connection.rb +76 -0
- data/lib/circus/agents/conversation.rb +17 -0
- data/lib/circus/agents/dbus_connection.rb +85 -0
- data/lib/circus/agents/dbus_logger.rb +34 -0
- data/lib/circus/agents/encoding.rb +32 -0
- data/lib/circus/agents/logger.rb +52 -0
- data/lib/circus/agents/params.rb +47 -0
- data/lib/circus/agents/ssh_connection.rb +120 -0
- data/lib/circus/application.rb +99 -0
- data/lib/circus/booth_client.rb +25 -0
- data/lib/circus/booth_tool.rb +98 -0
- data/lib/circus/cli.rb +147 -0
- data/lib/circus/clown_client.rb +27 -0
- data/lib/circus/connection_builder.rb +32 -0
- data/lib/circus/external_util.rb +14 -0
- data/lib/circus/local_config.rb +65 -0
- data/lib/circus/profiles/base.rb +115 -0
- data/lib/circus/profiles/django.rb +90 -0
- data/lib/circus/profiles/jekyll.rb +90 -0
- data/lib/circus/profiles/make_base.rb +17 -0
- data/lib/circus/profiles/pure_py.rb +46 -0
- data/lib/circus/profiles/pure_rb.rb +48 -0
- data/lib/circus/profiles/python_base.rb +39 -0
- data/lib/circus/profiles/rack.rb +59 -0
- data/lib/circus/profiles/ruby_base.rb +52 -0
- data/lib/circus/profiles/shell.rb +46 -0
- data/lib/circus/profiles.rb +10 -0
- data/lib/circus/repos/git.rb +42 -0
- data/lib/circus/repos/mercurial.rb +42 -0
- data/lib/circus/repos.rb +16 -0
- data/lib/circus/resource_allocator_client.rb +19 -0
- data/lib/circus/stdout_logger.rb +11 -0
- data/lib/circus/version.rb +3 -0
- data/lib/circus.rb +9 -0
- data/vendor/ruby-dbus/COPYING +504 -0
- data/vendor/ruby-dbus/ChangeLog +782 -0
- data/vendor/ruby-dbus/HOWTO-RELEASE +14 -0
- data/vendor/ruby-dbus/NEWS +104 -0
- data/vendor/ruby-dbus/README +53 -0
- data/vendor/ruby-dbus/Rakefile +47 -0
- data/vendor/ruby-dbus/doc/tutorial/src/00.index.page +12 -0
- data/vendor/ruby-dbus/doc/tutorial/src/10.intro.page +127 -0
- data/vendor/ruby-dbus/doc/tutorial/src/20.basic_client.page +174 -0
- data/vendor/ruby-dbus/doc/tutorial/src/30.service.page +121 -0
- data/vendor/ruby-dbus/doc/tutorial/src/default.css +129 -0
- data/vendor/ruby-dbus/doc/tutorial/src/default.template +46 -0
- data/vendor/ruby-dbus/examples/gdbus/gdbus +255 -0
- data/vendor/ruby-dbus/examples/gdbus/gdbus.glade +184 -0
- data/vendor/ruby-dbus/examples/gdbus/launch.sh +4 -0
- data/vendor/ruby-dbus/examples/no-introspect/nm-test.rb +21 -0
- data/vendor/ruby-dbus/examples/no-introspect/tracker-test.rb +16 -0
- data/vendor/ruby-dbus/examples/rhythmbox/playpause.rb +25 -0
- data/vendor/ruby-dbus/examples/service/call_service.rb +25 -0
- data/vendor/ruby-dbus/examples/service/service_newapi.rb +51 -0
- data/vendor/ruby-dbus/examples/simple/call_introspect.rb +34 -0
- data/vendor/ruby-dbus/examples/utils/listnames.rb +11 -0
- data/vendor/ruby-dbus/examples/utils/notify.rb +19 -0
- data/vendor/ruby-dbus/lib/dbus/auth.rb +156 -0
- data/vendor/ruby-dbus/lib/dbus/bus.rb +750 -0
- data/vendor/ruby-dbus/lib/dbus/export.rb +133 -0
- data/vendor/ruby-dbus/lib/dbus/introspect.rb +544 -0
- data/vendor/ruby-dbus/lib/dbus/marshall.rb +443 -0
- data/vendor/ruby-dbus/lib/dbus/matchrule.rb +100 -0
- data/vendor/ruby-dbus/lib/dbus/message.rb +293 -0
- data/vendor/ruby-dbus/lib/dbus/type.rb +222 -0
- data/vendor/ruby-dbus/lib/dbus.rb +89 -0
- data/vendor/ruby-dbus/ruby-dbus.gemspec +28 -0
- data/vendor/ruby-dbus/setup.rb +1585 -0
- data/vendor/ruby-dbus/test/Makefile +4 -0
- data/vendor/ruby-dbus/test/bus_driver_test.rb +21 -0
- data/vendor/ruby-dbus/test/server_robustness_test.rb +41 -0
- data/vendor/ruby-dbus/test/server_test.rb +44 -0
- data/vendor/ruby-dbus/test/service_newapi.rb +99 -0
- data/vendor/ruby-dbus/test/session_bus_test_manual.rb +20 -0
- data/vendor/ruby-dbus/test/signal_test.rb +57 -0
- data/vendor/ruby-dbus/test/t1 +4 -0
- data/vendor/ruby-dbus/test/t2.rb +66 -0
- data/vendor/ruby-dbus/test/t3-ticket27.rb +18 -0
- data/vendor/ruby-dbus/test/t5-report-dbus-interface.rb +58 -0
- data/vendor/ruby-dbus/test/t6-loop.rb +85 -0
- data/vendor/ruby-dbus/test/test_all +26 -0
- data/vendor/ruby-dbus/test/test_server +74 -0
- data/vendor/ruby-dbus/test/variant_test.rb +66 -0
- metadata +225 -0
@@ -0,0 +1,293 @@
|
|
1
|
+
# dbus.rb - Module containing the low-level D-Bus implementation
|
2
|
+
#
|
3
|
+
# This file is part of the ruby-dbus project
|
4
|
+
# Copyright (C) 2007 Arnaud Cornet and Paul van Tilburg
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License, version 2.1 as published by the Free Software Foundation.
|
9
|
+
# See the file "COPYING" for the exact licensing terms.
|
10
|
+
|
11
|
+
# = D-Bus main module
|
12
|
+
#
|
13
|
+
# Module containing all the D-Bus modules and classes.
|
14
|
+
module DBus
|
15
|
+
# = InvalidDestinationName class
|
16
|
+
# Thrown when you try do send a message to /org/freedesktop/DBus/Local, that
|
17
|
+
# is reserved.
|
18
|
+
class InvalidDestinationName < Exception
|
19
|
+
end
|
20
|
+
|
21
|
+
# = D-Bus message class
|
22
|
+
#
|
23
|
+
# Class that holds any type of message that travels over the bus.
|
24
|
+
class Message
|
25
|
+
# The serial number of the message.
|
26
|
+
@@serial = 1
|
27
|
+
# Mutex that protects updates on the serial number.
|
28
|
+
@@serial_mutex = Mutex.new
|
29
|
+
# Type of a message (by specification).
|
30
|
+
MESSAGE_SIGNATURE = "yyyyuua(yv)"
|
31
|
+
|
32
|
+
# FIXME: following message type constants should be under Message::Type IMO
|
33
|
+
# well, yeah sure
|
34
|
+
#
|
35
|
+
# Invalid message type.
|
36
|
+
INVALID = 0
|
37
|
+
# Method call message type.
|
38
|
+
METHOD_CALL = 1
|
39
|
+
# Method call return value message type.
|
40
|
+
METHOD_RETURN = 2
|
41
|
+
# Error message type.
|
42
|
+
ERROR = 3
|
43
|
+
# Signal message type.
|
44
|
+
SIGNAL = 4
|
45
|
+
|
46
|
+
# Message flag signyfing that no reply is expected.
|
47
|
+
NO_REPLY_EXPECTED = 0x1
|
48
|
+
# Message flag signifying that no automatic start is required/must be
|
49
|
+
# performed.
|
50
|
+
NO_AUTO_START = 0x2
|
51
|
+
|
52
|
+
# The type of the message.
|
53
|
+
attr_reader :message_type
|
54
|
+
# The path of the object instance the message must be sent to/is sent from.
|
55
|
+
attr_accessor :path
|
56
|
+
# The interface of the object that must be used/was used.
|
57
|
+
attr_accessor :interface
|
58
|
+
# The interface member (method/signal name) of the object that must be
|
59
|
+
# used/was used.
|
60
|
+
attr_accessor :member
|
61
|
+
# The name of the error (in case of an error message type).
|
62
|
+
attr_accessor :error_name
|
63
|
+
# The destination connection of the object that must be used/was used.
|
64
|
+
attr_accessor :destination
|
65
|
+
# The sender of the message.
|
66
|
+
attr_accessor :sender
|
67
|
+
# The signature of the message contents.
|
68
|
+
attr_accessor :signature
|
69
|
+
# The serial number of the message this message is a reply for.
|
70
|
+
attr_accessor :reply_serial
|
71
|
+
# The protocol.
|
72
|
+
attr_reader :protocol
|
73
|
+
# The serial of the message.
|
74
|
+
attr_reader :serial
|
75
|
+
# The parameters of the message.
|
76
|
+
attr_reader :params
|
77
|
+
|
78
|
+
# Create a message with message type _mtype_ with default values and a
|
79
|
+
# unique serial number.
|
80
|
+
def initialize(mtype = INVALID)
|
81
|
+
@message_type = mtype
|
82
|
+
|
83
|
+
@flags = 0
|
84
|
+
@protocol = 1
|
85
|
+
@body_length = 0
|
86
|
+
@signature = String.new
|
87
|
+
@@serial_mutex.synchronize do
|
88
|
+
@serial = @@serial
|
89
|
+
@@serial += 1
|
90
|
+
end
|
91
|
+
@params = Array.new
|
92
|
+
@destination = nil
|
93
|
+
@interface = nil
|
94
|
+
@error_name = nil
|
95
|
+
@member = nil
|
96
|
+
@path = nil
|
97
|
+
@reply_serial = nil
|
98
|
+
|
99
|
+
if mtype == METHOD_RETURN
|
100
|
+
@flags = NO_REPLY_EXPECTED
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Create an error reply to a message _m_.
|
105
|
+
def self.error(m, error_name, description=nil)
|
106
|
+
e = Message.new(ERROR)
|
107
|
+
e.reply_serial = m.serial
|
108
|
+
e.destination = m.sender
|
109
|
+
e.error_name = error_name
|
110
|
+
unless description.nil?
|
111
|
+
e.add_param(Type::STRING, description)
|
112
|
+
end
|
113
|
+
e
|
114
|
+
end
|
115
|
+
|
116
|
+
# Mark this message as a reply to a another message _m_, taking
|
117
|
+
# the serial number of _m_ as reply serial and the sender of _m_ as
|
118
|
+
# destination.
|
119
|
+
def reply_to(m)
|
120
|
+
@message_type = METHOD_RETURN
|
121
|
+
@reply_serial = m.serial
|
122
|
+
@destination = m.sender
|
123
|
+
self
|
124
|
+
end
|
125
|
+
|
126
|
+
# Add a parameter _val_ of type _type_ to the message.
|
127
|
+
def add_param(type, val)
|
128
|
+
type = type.chr if type.kind_of?(Fixnum)
|
129
|
+
@signature += type.to_s
|
130
|
+
@params << [type, val]
|
131
|
+
end
|
132
|
+
|
133
|
+
# FIXME: what are these? a message element constant enumeration?
|
134
|
+
# See method below, in a message, you have and array of optional parameters
|
135
|
+
# that come with an index, to determine their meaning. The values are in
|
136
|
+
# spec, more a definition than an enumeration.
|
137
|
+
|
138
|
+
PATH = 1
|
139
|
+
INTERFACE = 2
|
140
|
+
MEMBER = 3
|
141
|
+
ERROR_NAME = 4
|
142
|
+
REPLY_SERIAL = 5
|
143
|
+
DESTINATION = 6
|
144
|
+
SENDER = 7
|
145
|
+
SIGNATURE = 8
|
146
|
+
|
147
|
+
# Marshall the message with its current set parameters and return
|
148
|
+
# it in a packet form.
|
149
|
+
def marshall
|
150
|
+
if @path == "/org/freedesktop/DBus/Local"
|
151
|
+
raise InvalidDestinationName
|
152
|
+
end
|
153
|
+
|
154
|
+
params = PacketMarshaller.new
|
155
|
+
@params.each do |param|
|
156
|
+
params.append(param[0], param[1])
|
157
|
+
end
|
158
|
+
@body_length = params.packet.length
|
159
|
+
|
160
|
+
marshaller = PacketMarshaller.new
|
161
|
+
marshaller.append(Type::BYTE, HOST_END)
|
162
|
+
marshaller.append(Type::BYTE, @message_type)
|
163
|
+
marshaller.append(Type::BYTE, @flags)
|
164
|
+
marshaller.append(Type::BYTE, @protocol)
|
165
|
+
marshaller.append(Type::UINT32, @body_length)
|
166
|
+
marshaller.append(Type::UINT32, @serial)
|
167
|
+
marshaller.array(Type::Parser.new("y").parse[0]) do
|
168
|
+
if @path
|
169
|
+
marshaller.struct do
|
170
|
+
marshaller.append(Type::BYTE, PATH)
|
171
|
+
marshaller.append(Type::BYTE, 1)
|
172
|
+
marshaller.append_simple_string("o")
|
173
|
+
marshaller.append(Type::OBJECT_PATH, @path)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
if @interface
|
177
|
+
marshaller.struct do
|
178
|
+
marshaller.append(Type::BYTE, INTERFACE)
|
179
|
+
marshaller.append(Type::BYTE, 1)
|
180
|
+
marshaller.append_simple_string("s")
|
181
|
+
marshaller.append(Type::STRING, @interface)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
if @member
|
185
|
+
marshaller.struct do
|
186
|
+
marshaller.append(Type::BYTE, MEMBER)
|
187
|
+
marshaller.append(Type::BYTE, 1)
|
188
|
+
marshaller.append_simple_string("s")
|
189
|
+
marshaller.append(Type::STRING, @member)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
if @error_name
|
193
|
+
marshaller.struct do
|
194
|
+
marshaller.append(Type::BYTE, ERROR_NAME)
|
195
|
+
marshaller.append(Type::BYTE, 1)
|
196
|
+
marshaller.append_simple_string("s")
|
197
|
+
marshaller.append(Type::STRING, @error_name)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
if @reply_serial
|
201
|
+
marshaller.struct do
|
202
|
+
marshaller.append(Type::BYTE, REPLY_SERIAL)
|
203
|
+
marshaller.append(Type::BYTE, 1)
|
204
|
+
marshaller.append_simple_string("u")
|
205
|
+
marshaller.append(Type::UINT32, @reply_serial)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
if @destination
|
209
|
+
marshaller.struct do
|
210
|
+
marshaller.append(Type::BYTE, DESTINATION)
|
211
|
+
marshaller.append(Type::BYTE, 1)
|
212
|
+
marshaller.append_simple_string("s")
|
213
|
+
marshaller.append(Type::STRING, @destination)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
if @signature != ""
|
217
|
+
marshaller.struct do
|
218
|
+
marshaller.append(Type::BYTE, SIGNATURE)
|
219
|
+
marshaller.append(Type::BYTE, 1)
|
220
|
+
marshaller.append_simple_string("g")
|
221
|
+
marshaller.append(Type::SIGNATURE, @signature)
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
marshaller.align(8)
|
226
|
+
@params.each do |param|
|
227
|
+
marshaller.append(param[0], param[1])
|
228
|
+
end
|
229
|
+
marshaller.packet
|
230
|
+
end
|
231
|
+
|
232
|
+
# Unmarshall a packet contained in the buffer _buf_ and set the
|
233
|
+
# parameters of the message object according the data found in the
|
234
|
+
# buffer.
|
235
|
+
# Return the detected message and the index pointer of the buffer where
|
236
|
+
# the message data ended.
|
237
|
+
def unmarshall_buffer(buf)
|
238
|
+
buf = buf.dup
|
239
|
+
if buf[0] == ?l
|
240
|
+
endianness = LIL_END
|
241
|
+
else
|
242
|
+
endianness = BIG_END
|
243
|
+
end
|
244
|
+
pu = PacketUnmarshaller.new(buf, endianness)
|
245
|
+
mdata = pu.unmarshall(MESSAGE_SIGNATURE)
|
246
|
+
dummy, @message_type, @flags, @protocol, @body_length, @serial,
|
247
|
+
headers = mdata
|
248
|
+
|
249
|
+
headers.each do |struct|
|
250
|
+
case struct[0]
|
251
|
+
when PATH
|
252
|
+
@path = struct[1]
|
253
|
+
when INTERFACE
|
254
|
+
@interface = struct[1]
|
255
|
+
when MEMBER
|
256
|
+
@member = struct[1]
|
257
|
+
when ERROR_NAME
|
258
|
+
@error_name = struct[1]
|
259
|
+
when REPLY_SERIAL
|
260
|
+
@reply_serial = struct[1]
|
261
|
+
when DESTINATION
|
262
|
+
@destination = struct[1]
|
263
|
+
when SENDER
|
264
|
+
@sender = struct[1]
|
265
|
+
when SIGNATURE
|
266
|
+
@signature = struct[1]
|
267
|
+
end
|
268
|
+
end
|
269
|
+
pu.align(8)
|
270
|
+
if @body_length > 0 and @signature
|
271
|
+
@params = pu.unmarshall(@signature, @body_length)
|
272
|
+
end
|
273
|
+
[self, pu.idx]
|
274
|
+
end # def unmarshall_buf
|
275
|
+
|
276
|
+
# Unmarshall the data of a message found in the buffer _buf_ using
|
277
|
+
# Message#unmarshall_buf.
|
278
|
+
# Return the message.
|
279
|
+
def unmarshall(buf)
|
280
|
+
ret, size = unmarshall_buffer(buf)
|
281
|
+
ret
|
282
|
+
end
|
283
|
+
end # class Message
|
284
|
+
|
285
|
+
# A helper exception on errors
|
286
|
+
class Error < Exception
|
287
|
+
attr_reader :dbus_message
|
288
|
+
def initialize(msg)
|
289
|
+
super(msg.error_name + ": " + msg.params.join(", "))
|
290
|
+
@dbus_message = msg
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end # module DBus
|
@@ -0,0 +1,222 @@
|
|
1
|
+
# dbus/type.rb - module containing low-level D-Bus data type information
|
2
|
+
#
|
3
|
+
# This file is part of the ruby-dbus project
|
4
|
+
# Copyright (C) 2007 Arnaud Cornet and Paul van Tilburg
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License, version 2.1 as published by the Free Software Foundation.
|
9
|
+
# See the file "COPYING" for the exact licensing terms.
|
10
|
+
|
11
|
+
module DBus
|
12
|
+
|
13
|
+
# = D-Bus type module
|
14
|
+
#
|
15
|
+
# This module containts the constants of the types specified in the D-Bus
|
16
|
+
# protocol.
|
17
|
+
module Type
|
18
|
+
# The types.
|
19
|
+
INVALID = 0
|
20
|
+
BYTE = ?y
|
21
|
+
BOOLEAN = ?b
|
22
|
+
INT16 = ?n
|
23
|
+
UINT16 = ?q
|
24
|
+
INT32 = ?i
|
25
|
+
UINT32 = ?u
|
26
|
+
INT64 = ?x
|
27
|
+
UINT64 = ?t
|
28
|
+
DOUBLE = ?d
|
29
|
+
STRUCT = ?r
|
30
|
+
ARRAY = ?a
|
31
|
+
VARIANT = ?v
|
32
|
+
OBJECT_PATH = ?o
|
33
|
+
STRING = ?s
|
34
|
+
SIGNATURE = ?g
|
35
|
+
DICT_ENTRY = ?e
|
36
|
+
|
37
|
+
# Mapping from type number to name.
|
38
|
+
TypeName = {
|
39
|
+
INVALID => "INVALID",
|
40
|
+
BYTE => "BYTE",
|
41
|
+
BOOLEAN => "BOOLEAN",
|
42
|
+
INT16 => "INT16",
|
43
|
+
UINT16 => "UINT16",
|
44
|
+
INT32 => "INT32",
|
45
|
+
UINT32 => "UINT32",
|
46
|
+
INT64 => "INT64",
|
47
|
+
UINT64 => "UINT64",
|
48
|
+
DOUBLE => "DOUBLE",
|
49
|
+
STRUCT => "STRUCT",
|
50
|
+
ARRAY => "ARRAY",
|
51
|
+
VARIANT => "VARIANT",
|
52
|
+
OBJECT_PATH => "OBJECT_PATH",
|
53
|
+
STRING => "STRING",
|
54
|
+
SIGNATURE => "SIGNATURE",
|
55
|
+
DICT_ENTRY => "DICT_ENTRY"
|
56
|
+
}
|
57
|
+
|
58
|
+
# Exception raised when an unknown/incorrect type is encountered.
|
59
|
+
class SignatureException < Exception
|
60
|
+
end
|
61
|
+
|
62
|
+
# = D-Bus type conversion class
|
63
|
+
#
|
64
|
+
# Helper class for representing a D-Bus type.
|
65
|
+
class Type
|
66
|
+
# Returns the signature type number.
|
67
|
+
attr_reader :sigtype
|
68
|
+
# Return contained member types.
|
69
|
+
attr_reader :members
|
70
|
+
|
71
|
+
# Create a new type instance for type number _sigtype_.
|
72
|
+
def initialize(sigtype)
|
73
|
+
if not TypeName.keys.member?(sigtype)
|
74
|
+
raise SignatureException, "Unknown key in signature: #{sigtype.chr}"
|
75
|
+
end
|
76
|
+
@sigtype = sigtype
|
77
|
+
@members = Array.new
|
78
|
+
end
|
79
|
+
|
80
|
+
# Return the required alignment for the type.
|
81
|
+
def alignment
|
82
|
+
{
|
83
|
+
BYTE => 1,
|
84
|
+
BOOLEAN => 4,
|
85
|
+
INT16 => 2,
|
86
|
+
UINT16 => 2,
|
87
|
+
INT32 => 4,
|
88
|
+
UINT32 => 4,
|
89
|
+
INT64 => 8,
|
90
|
+
UINT64 => 8,
|
91
|
+
STRUCT => 8,
|
92
|
+
DICT_ENTRY => 8,
|
93
|
+
DOUBLE => 8,
|
94
|
+
ARRAY => 4,
|
95
|
+
VARIANT => 1,
|
96
|
+
OBJECT_PATH => 4,
|
97
|
+
STRING => 4,
|
98
|
+
SIGNATURE => 1,
|
99
|
+
}[@sigtype]
|
100
|
+
end
|
101
|
+
|
102
|
+
# Return a string representation of the type according to the
|
103
|
+
# D-Bus specification.
|
104
|
+
def to_s
|
105
|
+
case @sigtype
|
106
|
+
when STRUCT
|
107
|
+
"(" + @members.collect { |t| t.to_s }.join + ")"
|
108
|
+
when ARRAY
|
109
|
+
"a" + child.to_s
|
110
|
+
when DICT_ENTRY
|
111
|
+
"{" + @members.collect { |t| t.to_s }.join + "}"
|
112
|
+
else
|
113
|
+
if not TypeName.keys.member?(@sigtype)
|
114
|
+
raise NotImplementedError
|
115
|
+
end
|
116
|
+
@sigtype.chr
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
# Add a new member type _a_.
|
121
|
+
def <<(a)
|
122
|
+
if not [STRUCT, ARRAY, DICT_ENTRY].member?(@sigtype)
|
123
|
+
raise SignatureException
|
124
|
+
end
|
125
|
+
raise SignatureException if @sigtype == ARRAY and @members.size > 0
|
126
|
+
if @sigtype == DICT_ENTRY
|
127
|
+
if @members.size == 2
|
128
|
+
raise SignatureException, "Dict entries have exactly two members"
|
129
|
+
end
|
130
|
+
if @members.size == 0
|
131
|
+
if [STRUCT, ARRAY, DICT_ENTRY].member?(a.sigtype)
|
132
|
+
raise SignatureException, "Dict entry keys must be basic types"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
@members << a
|
137
|
+
end
|
138
|
+
|
139
|
+
# Return the first contained member type.
|
140
|
+
def child
|
141
|
+
@members[0]
|
142
|
+
end
|
143
|
+
|
144
|
+
def inspect
|
145
|
+
s = TypeName[@sigtype]
|
146
|
+
if [STRUCT, ARRAY].member?(@sigtype)
|
147
|
+
s += ": " + @members.inspect
|
148
|
+
end
|
149
|
+
s
|
150
|
+
end
|
151
|
+
end # class Type
|
152
|
+
|
153
|
+
# = D-Bus type parser class
|
154
|
+
#
|
155
|
+
# Helper class to parse a type signature in the protocol.
|
156
|
+
class Parser
|
157
|
+
# Create a new parser for the given _signature_.
|
158
|
+
def initialize(signature)
|
159
|
+
@signature = signature
|
160
|
+
@idx = 0
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns the next character from the signature.
|
164
|
+
def nextchar
|
165
|
+
c = @signature[@idx]
|
166
|
+
@idx += 1
|
167
|
+
c
|
168
|
+
end
|
169
|
+
|
170
|
+
# Parse one character _c_ of the signature.
|
171
|
+
def parse_one(c)
|
172
|
+
res = nil
|
173
|
+
case c
|
174
|
+
when ?a
|
175
|
+
res = Type.new(ARRAY)
|
176
|
+
child = parse_one(nextchar)
|
177
|
+
res << child
|
178
|
+
when ?(
|
179
|
+
res = Type.new(STRUCT)
|
180
|
+
while (c = nextchar) != nil and c != ?)
|
181
|
+
res << parse_one(c)
|
182
|
+
end
|
183
|
+
raise SignatureException, "Parse error in #{@signature}" if c == nil
|
184
|
+
when ?{
|
185
|
+
res = Type.new(DICT_ENTRY)
|
186
|
+
while (c = nextchar) != nil and c != ?}
|
187
|
+
res << parse_one(c)
|
188
|
+
end
|
189
|
+
raise SignatureException, "Parse error in #{@signature}" if c == nil
|
190
|
+
else
|
191
|
+
res = Type.new(c)
|
192
|
+
end
|
193
|
+
res
|
194
|
+
end
|
195
|
+
|
196
|
+
# Parse the entire signature, return a DBus::Type object.
|
197
|
+
def parse
|
198
|
+
@idx = 0
|
199
|
+
ret = Array.new
|
200
|
+
while (c = nextchar)
|
201
|
+
ret << parse_one(c)
|
202
|
+
end
|
203
|
+
ret
|
204
|
+
end
|
205
|
+
end # class Parser
|
206
|
+
end # module Type
|
207
|
+
|
208
|
+
# shortcuts
|
209
|
+
|
210
|
+
# Parse a String to a DBus::Type::Type
|
211
|
+
def type(string_type)
|
212
|
+
Type::Parser.new(string_type).parse[0]
|
213
|
+
end
|
214
|
+
module_function :type
|
215
|
+
|
216
|
+
# Make an explicit [Type, value] pair
|
217
|
+
def variant(string_type, value)
|
218
|
+
[type(string_type), value]
|
219
|
+
end
|
220
|
+
module_function :variant
|
221
|
+
|
222
|
+
end # module DBus
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# dbus.rb - Module containing the low-level D-Bus implementation
|
2
|
+
#
|
3
|
+
# This file is part of the ruby-dbus project
|
4
|
+
# Copyright (C) 2007 Arnaud Cornet and Paul van Tilburg
|
5
|
+
#
|
6
|
+
# This library is free software; you can redistribute it and/or
|
7
|
+
# modify it under the terms of the GNU Lesser General Public
|
8
|
+
# License, version 2.1 as published by the Free Software Foundation.
|
9
|
+
# See the file "COPYING" for the exact licensing terms.
|
10
|
+
|
11
|
+
require 'dbus/type'
|
12
|
+
require 'dbus/introspect'
|
13
|
+
require 'dbus/export'
|
14
|
+
require 'dbus/bus.rb'
|
15
|
+
require 'dbus/marshall'
|
16
|
+
require 'dbus/message'
|
17
|
+
require 'dbus/matchrule'
|
18
|
+
require 'dbus/auth'
|
19
|
+
|
20
|
+
require 'socket'
|
21
|
+
require 'thread'
|
22
|
+
|
23
|
+
unless 0.respond_to?(:ord)
|
24
|
+
# Backward compatibility with Ruby 1.8.6, see http://www.pubbs.net/ruby/200907/65871/
|
25
|
+
class Integer
|
26
|
+
def ord; self; end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# = D-Bus main module
|
31
|
+
#
|
32
|
+
# Module containing all the D-Bus modules and classes.
|
33
|
+
module DBus
|
34
|
+
# Default socket name for the system bus.
|
35
|
+
SystemSocketName = "unix:path=/var/run/dbus/system_bus_socket"
|
36
|
+
|
37
|
+
# Byte signifying big endianness.
|
38
|
+
BIG_END = ?B
|
39
|
+
# Byte signifying little endianness.
|
40
|
+
LIL_END = ?l
|
41
|
+
|
42
|
+
# Byte signifying the host's endianness.
|
43
|
+
HOST_END = if [0x01020304].pack("L").unpack("V")[0] == 0x01020304
|
44
|
+
LIL_END
|
45
|
+
else
|
46
|
+
BIG_END
|
47
|
+
end
|
48
|
+
|
49
|
+
# General exceptions.
|
50
|
+
|
51
|
+
# Exception raised when an invalid packet is encountered.
|
52
|
+
class InvalidPacketException < Exception
|
53
|
+
end
|
54
|
+
|
55
|
+
# Exception raised when there is a problem with a type (may be unknown or
|
56
|
+
# mismatch).
|
57
|
+
class TypeException < Exception
|
58
|
+
end
|
59
|
+
|
60
|
+
# Exception raised when an unmarshalled buffer is truncated and
|
61
|
+
# incomplete.
|
62
|
+
class IncompleteBufferException < Exception
|
63
|
+
end
|
64
|
+
|
65
|
+
# Exception raised when an interface is not implemented.
|
66
|
+
class InterfaceNotImplemented < Exception
|
67
|
+
end
|
68
|
+
|
69
|
+
# Exception raised when an method is not found in the interface.
|
70
|
+
class MethodNotInInterface < Exception
|
71
|
+
end
|
72
|
+
|
73
|
+
# Exception raised when a method has not been implemented (yet).
|
74
|
+
class MethodNotImplemented < Exception
|
75
|
+
end
|
76
|
+
|
77
|
+
# Exception raised when a method is invoked with invalid
|
78
|
+
# parameters (wrong number or type).
|
79
|
+
class InvalidParameters < Exception
|
80
|
+
end
|
81
|
+
|
82
|
+
# Exception raised when an invalid method name is used.
|
83
|
+
class InvalidMethodName < Exception
|
84
|
+
end
|
85
|
+
|
86
|
+
# Exception raised when invalid introspection data is parsed/used.
|
87
|
+
class InvalidIntrospectionData < Exception
|
88
|
+
end
|
89
|
+
end # module DBus
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{ruby-dbus}
|
5
|
+
s.version = "0.3.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Ruby DBus Team"]
|
9
|
+
s.autorequire = %q{dbus}
|
10
|
+
s.date = %q{2010-03-28}
|
11
|
+
s.email = %q{ruby-dbus-devel@lists.luon.net}
|
12
|
+
s.extra_rdoc_files = ["ChangeLog", "COPYING", "README", "NEWS"]
|
13
|
+
s.files = ["doc/tutorial/src/00.index.page", "doc/tutorial/src/10.intro.page", "doc/tutorial/src/20.basic_client.page", "doc/tutorial/src/30.service.page", "doc/tutorial/src/default.css", "doc/tutorial/src/default.template", "examples/gdbus", "examples/gdbus/gdbus", "examples/gdbus/gdbus.glade", "examples/gdbus/launch.sh", "examples/no-introspect", "examples/no-introspect/nm-test.rb", "examples/no-introspect/tracker-test.rb", "examples/rhythmbox", "examples/rhythmbox/playpause.rb", "examples/service", "examples/service/call_service.rb", "examples/service/service_newapi.rb", "examples/simple", "examples/simple/call_introspect.rb", "examples/utils", "examples/utils/listnames.rb", "examples/utils/notify.rb", "lib/dbus", "lib/dbus.rb", "lib/dbus/auth.rb", "lib/dbus/bus.rb", "lib/dbus/export.rb", "lib/dbus/introspect.rb", "lib/dbus/marshall.rb", "lib/dbus/matchrule.rb", "lib/dbus/message.rb", "lib/dbus/type.rb", "setup.rb", "test/Makefile", "test/bus_driver_test.rb", "test/server_robustness_test.rb", "test/server_test.rb", "test/service_newapi.rb", "test/session_bus_test_manual.rb", "test/signal_test.rb", "test/t1", "test/t2.rb", "test/t3-ticket27.rb", "test/t5-report-dbus-interface.rb", "test/t6-loop.rb", "test/test_all", "test/test_server", "test/variant_test.rb", "ChangeLog", "COPYING", "README", "NEWS"]
|
14
|
+
s.homepage = %q{http://trac.luon.net/data/ruby-dbus/}
|
15
|
+
s.require_paths = ["lib"]
|
16
|
+
s.rubygems_version = %q{1.3.5}
|
17
|
+
s.summary = %q{Ruby module for interaction with DBus}
|
18
|
+
|
19
|
+
if s.respond_to? :specification_version then
|
20
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
21
|
+
s.specification_version = 3
|
22
|
+
|
23
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
24
|
+
else
|
25
|
+
end
|
26
|
+
else
|
27
|
+
end
|
28
|
+
end
|