/
dbus.rb
90 lines (74 loc) · 2.37 KB
/
dbus.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# dbus.rb - Module containing the low-level D-Bus implementation
#
# This file is part of the ruby-dbus project
# Copyright (C) 2007 Arnaud Cornet and Paul van Tilburg
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License, version 2.1 as published by the Free Software Foundation.
# See the file "COPYING" for the exact licensing terms.
require 'dbus/core_ext/class/attribute'
require 'dbus/type'
require 'dbus/introspect'
require 'dbus/export'
require 'dbus/bus.rb'
require 'dbus/marshall'
require 'dbus/message'
require 'dbus/matchrule'
require 'dbus/auth'
require 'socket'
require 'thread'
unless 0.respond_to?(:ord)
# Backward compatibility with Ruby 1.8.6, see http://www.pubbs.net/ruby/200907/65871/
class Integer
def ord; self; end
end
end
# = D-Bus main module
#
# Module containing all the D-Bus modules and classes.
module DBus
# Default socket name for the system bus.
SystemSocketName = "unix:path=/var/run/dbus/system_bus_socket"
# Byte signifying big endianness.
BIG_END = ?B
# Byte signifying little endianness.
LIL_END = ?l
# Byte signifying the host's endianness.
HOST_END = if [0x01020304].pack("L").unpack("V")[0] == 0x01020304
LIL_END
else
BIG_END
end
# General exceptions.
# Exception raised when an invalid packet is encountered.
class InvalidPacketException < Exception
end
# Exception raised when there is a problem with a type (may be unknown or
# mismatch).
class TypeException < Exception
end
# Exception raised when an unmarshalled buffer is truncated and
# incomplete.
class IncompleteBufferException < Exception
end
# Exception raised when an interface is not implemented.
class InterfaceNotImplemented < Exception
end
# Exception raised when an method is not found in the interface.
class MethodNotInInterface < Exception
end
# Exception raised when a method has not been implemented (yet).
class MethodNotImplemented < Exception
end
# Exception raised when a method is invoked with invalid
# parameters (wrong number or type).
class InvalidParameters < Exception
end
# Exception raised when an invalid method name is used.
class InvalidMethodName < Exception
end
# Exception raised when invalid introspection data is parsed/used.
class InvalidIntrospectionData < Exception
end
end # module DBus