pangdudu-ruby-dbus 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/dbus.rb ADDED
@@ -0,0 +1,88 @@
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
+ require 'rubygems'
11
+ require 'rofl' #http://github.com/pangdudu/rofl/tree/master makes the debug/tracing easy
12
+ #comes from the Rofl logger/tracer module
13
+ @logger.level = Logger::DEBUG
14
+
15
+ require 'dbus/type'
16
+ require 'dbus/introspect'
17
+ require 'dbus/export'
18
+ require 'dbus/bus'
19
+ require 'dbus/marshall'
20
+ require 'dbus/message'
21
+ require 'dbus/matchrule'
22
+ require 'dbus/auth'
23
+ require 'socket'
24
+ require 'thread'
25
+
26
+ # = D-Bus main module
27
+ #
28
+ # Module containing all the D-Bus modules and classes.
29
+ module DBus
30
+ # Default socket name for the system bus.
31
+ SystemSocketName = "unix:path=/var/run/dbus/system_bus_socket"
32
+
33
+ # Socket name for the session bus, not pretty.
34
+ SessionSocketName = ENV["DBUS_SESSION_BUS_ADDRESS"]
35
+
36
+ # Byte signifying big endianness.
37
+ BIG_END = ?B
38
+ # Byte signifying little endianness.
39
+ LIL_END = ?l
40
+
41
+ # Byte signifying the host's endianness.
42
+ HOST_END = if [0x01020304].pack("L").unpack("V")[0] == 0x01020304
43
+ LIL_END
44
+ else
45
+ BIG_END
46
+ end
47
+
48
+ # General exceptions.
49
+
50
+ # Exception raised when an invalid packet is encountered.
51
+ class InvalidPacketException < Exception
52
+ end
53
+
54
+ # Exception raised when there is a problem with a type (may be unknown or
55
+ # mismatch).
56
+ class TypeException < Exception
57
+ end
58
+
59
+ # Exception raised when an unmarshalled buffer is truncated and
60
+ # incomplete.
61
+ class IncompleteBufferException < Exception
62
+ end
63
+
64
+ # Exception raised when an interface is not implemented.
65
+ class InterfaceNotImplemented < Exception
66
+ end
67
+
68
+ # Exception raised when an method is not found in the interface.
69
+ class MethodNotInInterface < Exception
70
+ end
71
+
72
+ # Exception raised when a method has not been implemented (yet).
73
+ class MethodNotImplemented < Exception
74
+ end
75
+
76
+ # Exception raised when a method is invoked with invalid
77
+ # parameters (wrong number or type).
78
+ class InvalidParameters < Exception
79
+ end
80
+
81
+ # Exception raised when an invalid method name is used.
82
+ class InvalidMethodName < Exception
83
+ end
84
+
85
+ # Exception raised when invalid introspection data is parsed/used.
86
+ class InvalidIntrospectionData < Exception
87
+ end
88
+ end # module DBus
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'rubygems'
4
+ require 'rofl'
5
+ require 'dbus'
6
+
7
+ =begin
8
+ puts "NOW LISTING SYSTEM BUS:\n"
9
+
10
+ #show services on system bus
11
+ sysbus = DBus::SystemBus.instance
12
+ puts "\tsystem bus - listnames:"
13
+ sysbus.proxy.ListNames[0].each { |name| puts "\t\tservice: #{name}" } unless sysbus.nil?
14
+ =end
15
+ #test sockets
16
+
17
+ puts "NOW LISTING SESSION BUS:\n"
18
+
19
+ #show services on a tcp session bus
20
+ #socket_name = "unix:path=/tmp/socket_test_session_bus_socket" #look at: config/remote.session.dbus.conf
21
+ #socket_name = "tcp:host=0.0.0.0,port=2687,family=ipv4" #look at: config/remote.session.dbus.conf
22
+ socket_name = "tcp:host=10.11.12.13,port=2687,family=ipv4" #look at: config/remote.session.dbus.conf
23
+ dlog "\tsession socket name: #{socket_name}"
24
+ DBus.const_set("SessionSocketName", socket_name) #overwrite the modules constant
25
+ sesbus = DBus::SessionBus.instance
26
+ dlog "\tsession bus - listnames:"
27
+ sesbus.proxy.ListNames[0].each { |name| dlog "\t\tservice: #{name}" } unless sesbus.nil?
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pangdudu-ruby-dbus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ruby DBUS Team, pangdudu
8
+ autorequire: dbus
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-27 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: pangdudu-rofl
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Ruby module for interaction with dbus, panda dev fork.
26
+ email: pangdudu@github
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.rdoc
33
+ - COPYING
34
+ files:
35
+ - COPYING
36
+ - README.rdoc
37
+ - lib/dbus
38
+ - lib/dbus/message.rb
39
+ - lib/dbus/auth.rb
40
+ - lib/dbus/marshall.rb
41
+ - lib/dbus/export.rb
42
+ - lib/dbus/type.rb
43
+ - lib/dbus/introspect.rb
44
+ - lib/dbus/matchrule.rb
45
+ - lib/dbus/bus.rb
46
+ - lib/dbus.rb
47
+ - config/remote.session.dbus.conf
48
+ - config/start_dbus_session.sh
49
+ - test/simple_socket_test.rb
50
+ has_rdoc: true
51
+ homepage: http://github.com/pangdudu/ruby-dbus/tree/master
52
+ licenses:
53
+ post_install_message:
54
+ rdoc_options: []
55
+
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ version:
70
+ requirements: []
71
+
72
+ rubyforge_project:
73
+ rubygems_version: 1.3.5
74
+ signing_key:
75
+ specification_version: 2
76
+ summary: Ruby module for interaction with dbus.
77
+ test_files: []
78
+