Code Monkey home page Code Monkey logo

dbus-sharp's Introduction

D-Bus for .NET
==============

This is a fork of ndesk-dbus, which is a C# implementation of D-Bus. It's
often referred to as "managed D-Bus" to avoid confusion with existing
bindings (which wrap libdbus).

See http://mono.github.com/dbus-sharp/ for our fork
    - Tarball download: http://github.com/mono/dbus-sharp/downloads
    - GitHub repository: http://www.github.com/mono/dbus-sharp
    - Reporting bugs: http://github.com/mono/dbus-sharp/issues

See http://www.ndesk.org/DBusSharp for Alp Toker's original project

D-Bus is an inter-process communication framework that lets applications
interface with the system event bus as well as allowing them to talk to
one another in a peer-to-peer configuration.

See http://www.freedesktop.org/wiki/Software/dbus for general
information on the D-Bus IPC mechanism.

This software is under active development but is already used by a wide
range of applications for tasks as simple as maintaining a single
instance of the GUI to whole instant messaging frameworks and hardware
detection APIs.

It provides a tested, high-performance bridge to and from all systems
that are exposed via D-Bus, regardless of programming language, UI
toolkit or license. The source code is MIT X11 licensed (Free
Software/Open Source), allowing integration into other projects with
very few restrictions.

The code was written by Alp Toker <[email protected]> and others, and is
maintained by the dbus-sharp team.

It is a clean-room implementation based on the D-Bus Specification
Version 0.11 and study of the wire protocol of existing tools.

It aims for compatibility with Mono and Microsoft .NET frameworks
supporting the 2.0 profile. Backward compatibility with 1.0 will not be
a consideration.

-- 
Alp Toker <[email protected]> and others

dbus-sharp's People

Contributors

ajlennon avatar alanmcgovern avatar arfbtwn avatar atoker avatar bl8 avatar davidnielsen avatar directhex avatar edwardbetts avatar garuma avatar hbons avatar knocte avatar mattguo avatar petejohanson avatar sandyarmstrong avatar steffen-kiess avatar terrajobst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dbus-sharp's Issues

Signals not delivered/event not raised on client proxy

dbus-sharp 0.7 does not correctly raise an event in the client proxy when a signal occurs. This is a regression compared to NDesk.Dbus 0.6.

This can be tested with TestExportInterface.cs from the examples folder.

The sample has server and client in the same code. First process started will be the server. The output from the second invocation, the client, is this:

( I modifed MatchRule.cs (Equals() and GetHashCode() to output the ToString() of the MatchRule. The guid is unique for each MatchRule instance.)

dbus-sharp-0.7.0/examples @ DBUS_VERBOSE=1 mono ./TestExportInterface.exe
Matchrule(09de57d3-3b42-4314-9772-987b9ff66cee): type='signal',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameAcquired',sender='org.freedesktop.DBus'
Warning: No signal handler for NameAcquired
Bad! Generating fallback reader for SimplePresence
Bad! Generating fallback reader for IDemoOne
Bad! Generating fallback reader for IDemoOne

Matchrule(4a636600-f6a5-4d06-8d71-d58f4b0cc7da): type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender='org.ndesk.test'
Matchrule(4a636600-f6a5-4d06-8d71-d58f4b0cc7da): type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender='org.ndesk.test'
Matchrule(da2f2167-0f4a-42cd-90fb-d406614908a5): type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
Warning: No signal handler for SomeEvent

[[ Comment: This should be triggered by demo.FireOffSomeEvent (); on line 37. The event handler was attached on line 36, but is not called. Note how the sender field in the MatchRule differs between the defined MatchRule, and the incomning one, preventing the proper match from occuring. ]]

Matchrule(cf6e9db6-6df6-4cf4-8bc0-ef2a29bb957d): type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
Matchrule(0d381ab4-b24b-498b-b61c-3e555cac3388): type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
Warning: No signal handler for SomeEvent

Matchrule(b9e1994e-c183-48cb-b78f-ec21473b748e): type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
Matchrule(b9e1994e-c183-48cb-b78f-ec21473b748e): type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
Matchrule(030a019a-f1e3-475e-ae78-3f6aef861809): type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
this Matchrule: type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
that Matchrule: type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
Matchrule(030a019a-f1e3-475e-ae78-3f6aef861809): type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
this Matchrule: type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
that Matchrule: type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
Matchrule(030a019a-f1e3-475e-ae78-3f6aef861809): type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
this Matchrule: type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
that Matchrule: type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
Matchrule(27a0ad97-c0f3-4eef-b728-166fb7cba465): type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
this Matchrule: type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
that Matchrule: type='signal',path='/org/ndesk/test',interface='org.ndesk.test',member='SomeEvent',sender=':1.113'
SomeEvent handler: some string, 21, 19.84, a, b
SomeEvent handler two: some string, 21, 19.84, a, b

[[ Comment: This should be triggered from line 46, the two event handlers attached on line 44 and 45. So now it works. And indeed, the sender field is the same for all MatchRules involved in this segment of the code. ]]

[[ Rest of output snipped. ]]

So it appears that the problem relates to the sender field of MatchRule, but I don't know if it is initially set incorrect, or if MatchRule is too picky. What also seems to happen is that after the first method call, the sender field in the defined MatchRule is different, enabling the event to be raised properly.

So in summary:
If an event handler is attached directly after GetObject(), it will never be called due to mismatching sender in MatchRule. But if you first call a method on the client proxy, and only after that attach the event handler, the sender field in the defined MatchRule will be the same as the one generated for the incoming event. Apart from the example code mentioned above, I have confirmed this workaround in my application, which broke after upgrade from NDesk.Dbus 0.6.

Failure adding assembly dbus-sharp.dll to the cache: Strong name cannot be verified for delay-signed assembly

I'm the package maintainer for dbus-sharp for slackbuilds.org.
https://slackbuilds.org/repository/14.2/libraries/dbus-sharp/

I'm getting this compilation error on Slackware64 14.2.

dbus-sharp-0.8.1/
dbus-sharp-0.8.1/aclocal.m4
dbus-sharp-0.8.1/configure
dbus-sharp-0.8.1/NEWS
dbus-sharp-0.8.1/COPYING
dbus-sharp-0.8.1/ChangeLog
dbus-sharp-0.8.1/configure.ac
dbus-sharp-0.8.1/AUTHORS
dbus-sharp-0.8.1/examples/
dbus-sharp-0.8.1/examples/TestNotifications.cs
dbus-sharp-0.8.1/examples/Makefile.am
dbus-sharp-0.8.1/examples/Test.cs
dbus-sharp-0.8.1/examples/TestExportInterface.cs
dbus-sharp-0.8.1/examples/TestSample.cs
dbus-sharp-0.8.1/examples/Notifications.cs
dbus-sharp-0.8.1/examples/Makefile.in
dbus-sharp-0.8.1/src/
dbus-sharp-0.8.1/src/Authentication.cs
dbus-sharp-0.8.1/src/TypeImplementer.cs
dbus-sharp-0.8.1/src/Connection.cs
dbus-sharp-0.8.1/src/Introspection.cs
dbus-sharp-0.8.1/src/ExportObject.cs
dbus-sharp-0.8.1/src/dbus-sharp.dll.config
dbus-sharp-0.8.1/src/ObjectPath.cs
dbus-sharp-0.8.1/src/BusException.cs
dbus-sharp-0.8.1/src/OSHelpers.cs
dbus-sharp-0.8.1/src/AssemblyInfo.cs.in
dbus-sharp-0.8.1/src/dbus-sharp.csproj
dbus-sharp-0.8.1/src/Protocol/
dbus-sharp-0.8.1/src/Protocol/MessageType.cs
dbus-sharp-0.8.1/src/Protocol/MessageDumper.cs
dbus-sharp-0.8.1/src/Protocol/MessageReader.cs
dbus-sharp-0.8.1/src/Protocol/Transport.cs
dbus-sharp-0.8.1/src/Protocol/ProtocolInformation.cs
dbus-sharp-0.8.1/src/Protocol/HeaderFlag.cs
dbus-sharp-0.8.1/src/Protocol/FieldCode.cs
dbus-sharp-0.8.1/src/Protocol/MessageFilter.cs
dbus-sharp-0.8.1/src/Protocol/Message.cs
dbus-sharp-0.8.1/src/Protocol/EndianFlag.cs
dbus-sharp-0.8.1/src/Protocol/SocketTransport.cs
dbus-sharp-0.8.1/src/Protocol/DBusStruct.cs
dbus-sharp-0.8.1/src/Protocol/MessageWriter.cs
dbus-sharp-0.8.1/src/Protocol/Signature.cs
dbus-sharp-0.8.1/src/Protocol/DType.cs
dbus-sharp-0.8.1/src/Protocol/MessageContainer.cs
dbus-sharp-0.8.1/src/Protocol/DValue.cs
dbus-sharp-0.8.1/src/Protocol/Header.cs
dbus-sharp-0.8.1/src/Protocol/MatchRule.cs
dbus-sharp-0.8.1/src/Protocol/PendingCall.cs
dbus-sharp-0.8.1/src/Transports/
dbus-sharp-0.8.1/src/Transports/UnixTransport.cs
dbus-sharp-0.8.1/src/Transports/UnixNativeTransport.cs
dbus-sharp-0.8.1/src/Unix/
dbus-sharp-0.8.1/src/Unix/UnixError.cs
dbus-sharp-0.8.1/src/Unix/UnixStream.cs
dbus-sharp-0.8.1/src/Unix/UnixSocket.cs
dbus-sharp-0.8.1/src/Mapper.cs
dbus-sharp-0.8.1/src/Makefile.am
dbus-sharp-0.8.1/src/BusObject.cs
dbus-sharp-0.8.1/src/DProxy.cs
dbus-sharp-0.8.1/src/ArgDirection.cs
dbus-sharp-0.8.1/src/AddressEntry.cs
dbus-sharp-0.8.1/src/AssemblyInfo.cs
dbus-sharp-0.8.1/src/DBus.cs
dbus-sharp-0.8.1/src/Address.cs
dbus-sharp-0.8.1/src/Bus.cs
dbus-sharp-0.8.1/src/Makefile.in
dbus-sharp-0.8.1/Makefile.am
dbus-sharp-0.8.1/INSTALL
dbus-sharp-0.8.1/dbus-sharp.snk
dbus-sharp-0.8.1/tools/
dbus-sharp-0.8.1/tools/Monitor.cs
dbus-sharp-0.8.1/tools/Makefile.am
dbus-sharp-0.8.1/tools/Introspect.cs
dbus-sharp-0.8.1/tools/Makefile.in
dbus-sharp-0.8.1/install-sh
dbus-sharp-0.8.1/tests/
dbus-sharp-0.8.1/tests/dbus-sharp-tests.csproj
dbus-sharp-0.8.1/tests/MessageReaderTest.cs
dbus-sharp-0.8.1/tests/AddressTest.cs
dbus-sharp-0.8.1/tests/IntrospectorTest.cs
dbus-sharp-0.8.1/tests/ExportInterfaceTest.cs
dbus-sharp-0.8.1/tests/ObjectPathTest.cs
dbus-sharp-0.8.1/tests/Makefile.am
dbus-sharp-0.8.1/tests/AuthenticationTest.cs
dbus-sharp-0.8.1/tests/BusTests.cs
dbus-sharp-0.8.1/tests/MatchRuleTest.cs
dbus-sharp-0.8.1/tests/RenamedInterfaceTest.cs
dbus-sharp-0.8.1/tests/SignatureTest.cs
dbus-sharp-0.8.1/tests/MessageWriterTest.cs
dbus-sharp-0.8.1/tests/Makefile.in
dbus-sharp-0.8.1/dbus-sharp-2.0.pc.in
dbus-sharp-0.8.1/README
dbus-sharp-0.8.1/dbus-sharp.sln
dbus-sharp-0.8.1/missing
dbus-sharp-0.8.1/Makefile.in
checking for a BSD-compatible install... /usr/bin/ginstall -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for MONO... yes
checking for gmcs... /usr/bin/mcs
checking for gacutil... /usr/bin/gacutil
checking for xbuild... /usr/bin/xbuild
checking for Mono.Posix.dll... found
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating dbus-sharp-2.0.pc
config.status: creating src/AssemblyInfo.cs
config.status: creating src/Makefile
config.status: creating tools/Makefile
config.status: creating examples/Makefile
config.status: creating tests/Makefile
Making all in src
make[1]: Entering directory '/tmp/SBo/dbus-sharp-0.8.1/src'
/usr/bin/xbuild /nologo /verbosity:quiet dbus-sharp.csproj
Protocol/Header.cs(95,18): warning CS0649: Field 'Header.FieldCodeEntry.Value' is never assigned to, and will always have its default value null
Protocol/Header.cs(94,16): warning CS0649: Field 'Header.FieldCodeEntry.Code' is never assigned to, and will always have its default value 0
make[1]: Leaving directory '/tmp/SBo/dbus-sharp-0.8.1/src'
Making all in tools
make[1]: Entering directory '/tmp/SBo/dbus-sharp-0.8.1/tools'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/tmp/SBo/dbus-sharp-0.8.1/tools'
Making all in examples
make[1]: Entering directory '/tmp/SBo/dbus-sharp-0.8.1/examples'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/tmp/SBo/dbus-sharp-0.8.1/examples'
Making all in tests
make[1]: Entering directory '/tmp/SBo/dbus-sharp-0.8.1/tests'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/tmp/SBo/dbus-sharp-0.8.1/tests'
make[1]: Entering directory '/tmp/SBo/dbus-sharp-0.8.1'
make[1]: Nothing to be done for 'all-am'.
make[1]: Leaving directory '/tmp/SBo/dbus-sharp-0.8.1'
Making install in src
make[1]: Entering directory '/tmp/SBo/dbus-sharp-0.8.1/src'
make[2]: Entering directory '/tmp/SBo/dbus-sharp-0.8.1/src'
make[2]: Nothing to be done for 'install-exec-am'.
/usr/bin/xbuild /nologo /verbosity:quiet dbus-sharp.csproj
/usr/bin/gacutil /i dbus-sharp.dll /package dbus-sharp-2.0 /f /gacdir /usr/lib /root /tmp/SBo/package-dbus-sharp/usr/lib
Failure adding assembly dbus-sharp.dll to the cache: Strong name cannot be verified for delay-signed assembly
Makefile:453: recipe for target 'install-data-local' failed
make[2]: *** [install-data-local] Error 1
make[2]: Leaving directory '/tmp/SBo/dbus-sharp-0.8.1/src'
Makefile:340: recipe for target 'install-am' failed
make[1]: *** [install-am] Error 2
make[1]: Leaving directory '/tmp/SBo/dbus-sharp-0.8.1/src'
Makefile:394: recipe for target 'install-recursive' failed
make: *** [install-recursive] Error 1
I've searched other distros including Gentoo, Debian, Arch, and Void. I'm not finding a way to fix these compilation issues.

Add Connection.(Un)TrapSignals

A TrapSignals and UntrapSignals is needed for the implementation of certain DBus protocols like Avahi, where signals can come in between getting an ObjectPath as the return value of a function call and connecting handlers to its signals. Example use-case, as found in Mono.Zeroconf:

        DBusManager.Bus.TrapSignals ();

        lock (this) {
            if (resolver != null) {
                throw new InvalidOperationException ("The service is already running a resolve operation");
            }

            ObjectPath path = DBusManager.Server.ServiceResolverNew (AvahiInterface, AvahiProtocol, 
                Name ?? String.Empty, RegType ?? String.Empty, ReplyDomain ?? String.Empty, 
                AvahiProtocol, LookupFlags.None);

            resolver = DBusManager.GetObject<IAvahiServiceResolver> (path);
        }

        resolver.Failure += OnResolveFailure;
        resolver.Found += OnResolveFound;

        DBusManager.Bus.UntrapSignals ();

Interface with same function name

Type: System.Exception
Message: System.ArgumentOutOfRangeException: ArgRange_Array
Parameter name: count

at OpenMedicus.IShellBusProxy.OpenPatient (Int32 pid) [0x00000] in :0
at OpenMedicus.Modules.Emessage.OpenPatientOrCreate (System.String cpr) [0x0005c] in /home/mkj/Projects/XMedicus/modules/emessage/Emessage.cs:1765

As you can see in my interface, I have 2 functions with the same name. This worked fine in 0.7 but fails in 0.8. Is it not possible to have this ?

[Interface("org.openmedicus.shell")]
public interface IShellBus
{
    bool IsPatientOpen (int id);
    bool OpenPatient (int pid);
    int OpenPatient (string cpr);
    void ShowMainWindow ();
    int GetActivePatient ();
}

Compile error: Protocol/MessageReader.cs(579,25): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type `T'

I've been attempting to compile 0.8.0 on my Mac but it fails with the following output.
hub.com/DavidNielsen/bockbuild

2013-11-07 10:36:58: Building dbus-sharp on python-posix (4 CPU)
+ /Users/gnomeuser/Documents/Projekter/bockbuild-timo/profiles/banshee/build-root/_install/bin/tar xf /Users/gnomeuser/Documents/Projekter/bockbuild-timo/cache/8eaea9441901d411974e55cde896df33838f3b69 -O > /dev/null
+ using cached source: /Users/gnomeuser/Documents/Projekter/bockbuild-timo/cache/8eaea9441901d411974e55cde896df33838f3b69
==> 2013-11-07 10:36:58: Preping dbus-sharp
+ /Users/gnomeuser/Documents/Projekter/bockbuild-timo/profiles/banshee/build-root/_install/bin/tar xf /Users/gnomeuser/Documents/Projekter/bockbuild-timo/cache/8eaea9441901d411974e55cde896df33838f3b69
+ cd "mono-dbus-sharp-8eaea94"
==> 2013-11-07 10:36:58: Building dbus-sharp
+ ./autogen.sh --prefix="/Users/gnomeuser/Documents/Projekter/bockbuild-timo/profiles/banshee/build-root/_install"
configure.ac:8: installing './install-sh'
configure.ac:8: installing './missing'
Makefile.am: installing './INSTALL'
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking for pkg-config... /Users/gnomeuser/Documents/Projekter/bockbuild-timo/profiles/banshee/build-root/_install/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for MONO... yes
checking for gmcs... /Users/gnomeuser/Documents/Projekter/bockbuild-timo/profiles/banshee/build-root/_install/bin/gmcs
checking for gacutil... /Users/gnomeuser/Documents/Projekter/bockbuild-timo/profiles/banshee/build-root/_install/bin/gacutil
checking for xbuild... /Users/gnomeuser/Documents/Projekter/bockbuild-timo/profiles/banshee/build-root/_install/bin/xbuild
checking for Mono.Posix.dll... found
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating dbus-sharp-2.0.pc
config.status: creating src/AssemblyInfo.cs
config.status: creating src/Makefile
config.status: creating tools/Makefile
config.status: creating examples/Makefile
config.status: creating tests/Makefile
+ make -j4
Making all in src
/Users/gnomeuser/Documents/Projekter/bockbuild-timo/profiles/banshee/build-root/_install/bin/xbuild /nologo /verbosity:quiet dbus-sharp.csproj
/Users/gnomeuser/Documents/Projekter/bockbuild-timo/profiles/banshee/build-root/_install/lib/mono/4.0/Microsoft.CSharp.targets: warning : A circular reference was found involving the import of '/Users/gnomeuser/Documents/Projekter/bockbuild-timo/profiles/banshee/build-root/_install/lib/mono/4.0/Microsoft.Common.targets'. It was earlier imported by '/Users/gnomeuser/Documents/Projekter/bockbuild-timo/profiles/banshee/build-root/_install/lib/mono/4.0/Microsoft.CSHARP.Targets'. Only the first import of this file will be used, ignoring others.
/Users/gnomeuser/Documents/Projekter/bockbuild-timo/profiles/banshee/build-root/_install/lib/mono/4.0/Microsoft.CSharp.targets: warning : A circular reference was found involving the import of '/Users/gnomeuser/Documents/Projekter/bockbuild-timo/profiles/banshee/build-root/_install/lib/mono/4.0/Microsoft.Common.targets'. It was earlier imported by '/Users/gnomeuser/Documents/Projekter/bockbuild-timo/profiles/banshee/build-root/_install/lib/mono/4.0/Microsoft.CSHARP.Targets'. Only the first import of this file will be used, ignoring others.
Protocol/MessageReader.cs(579,25): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type T' Protocol/MessageWriter.cs(431,26): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed typeT'
make[1]: *** [dbus-sharp.dll] Error 1
make: *** [all-recursive] Error 1

Support for UNIX_FD

The DBus spec defines a UNIX_FD type, short code h, as "Unsigned 32-bit integer representing an index into an out-of-band array of file descriptors, transferred via some platform-specific mechanism (mnemonic: h for handle)"

This type is missing from DBus#, and is needed for MonoDevelop.

How to deal with method calls that depend on slow running services?

Does dbus-sharp provide functionality of doing method calls where the call will be launched immediately, and a callback will be executed when the method call returns a value.
I am looking for something similar to what GLibDBus provides with dbus_g_proxy_begin_call and dbus_g_proxy_end_call.

Lost connection leaves pending calls hanging

If the D-Bus connection is lost, any calls waiting for a reply will keep waiting indefinitely.
Is this intentional behaviour or is the D-Bus daemon expected to store and forward messages upon reconnection?

KeyNotFoundException thrown in NDesk.DBus.BusObject.ToggleSignal

I just got this exception with Banshee using dbus-sharp 0.7:

[14 Debug 13:16:44.450] DAAP Proxy listening for connections on port 8089
[13 Debug 13:16:44.703] Found DAAP share Mediathek von Jordan, trying to resolve...

Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2[NDesk.DBus.MatchRule,System.Delegate].get_Item (NDesk.DBus.MatchRule key) [0x00000] in :0
at NDesk.DBus.BusObject.ToggleSignal (System.String iface, System.String member, System.Delegate dlg, Boolean adding) [0x00000] in :0
at IAvahiServiceResolverProxy.remove_Found (Mono.Zeroconf.Providers.AvahiDBus.ServiceResolverFoundHandler ) [0x00000] in :0
at Mono.Zeroconf.Providers.AvahiDBus.BrowseService.DisposeResolver () [0x00000] in :0
at Mono.Zeroconf.Providers.AvahiDBus.BrowseService.Dispose () [0x00000] in :0
at Mono.Zeroconf.Providers.AvahiDBus.ServiceBrowser.OnItemNew (Int32 interface, Protocol protocol, System.String name, System.String type, System.String domain, LookupResultFlags flags) [0x00000] in :0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in :0
at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in :0
at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in :0
at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in :0
at NDesk.DBus.Connection.HandleSignal (NDesk.DBus.Message msg) [0x00000] in :0
at NDesk.DBus.Connection.DispatchSignals () [0x00000] in :0
at NDesk.DBus.PendingCall.get_Reply () [0x00000] in :0
at NDesk.DBus.Connection.SendWithReplyAndBlock (NDesk.DBus.Message msg) [0x00000] in :0
at NDesk.DBus.BusObject.SendMethodCall (System.String iface, System.String member, System.String inSigStr, NDesk.DBus.MessageWriter writer, System.Type retType, System.Exception& exception) [0x00000] in :0
at IBusProxy.AddMatch (System.String ) [0x00000] in :0
at NDesk.DBus.Bus.AddMatch (System.String rule) [0x00000] in :0
at NDesk.DBus.BusObject.ToggleSignal (System.String iface, System.String member, System.Delegate dlg, Boolean adding) [0x00000] in :0
at IAvahiServiceResolverProxy.add_Failure (Mono.Zeroconf.Providers.AvahiDBus.ServiceResolverErrorHandler ) [0x00000] in :0
at Mono.Zeroconf.Providers.AvahiDBus.BrowseService.Resolve () [0x00000] in :0
at Daap.ServiceLocator.OnServiceAdded (System.Object o, Mono.Zeroconf.ServiceBrowseEventArgs args) [0x0003c] in /home/knocte/Documents/Code/bansheeDEBUGUNMANAGED1/src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs:129
at Mono.Zeroconf.Providers.AvahiDBus.ServiceBrowser.OnServiceAdded (Mono.Zeroconf.Providers.AvahiDBus.BrowseService service) [0x00000] in :0
at Mono.Zeroconf.Providers.AvahiDBus.ServiceBrowser.OnItemNew (Int32 interface, Protocol protocol, System.String name, System.String type, System.String domain, LookupResultFlags flags) [0x00000] in :0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in :0
at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in :0
at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in :0
at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in :0
at NDesk.DBus.Connection.HandleSignal (NDesk.DBus.Message msg) [0x00000] in :0
at NDesk.DBus.Connection.DispatchSignals () [0x00000] in :0
at NDesk.DBus.Connection.Iterate () [0x00000] in :0
at Mono.Zeroconf.Providers.AvahiDBus.DBusManager.IterateThread (System.Object o) [0x00000] in :0
make: *** [run] Error 255

nonce-tcp is not working

I can't get dbus-sharp to connect to a dbus-deamon running with method nonce-tcp. I'm using DBUS 1.8.12.

Anyone has this working ?

Where to track bugs?

We shouldn't use the ndesk-maintainers project in Launchpad to track our fork's bugs.

We can either set up a new project in LP or use github.

Github advantages:

  • Already here (no work)
  • Integration with pull requests 2.0
  • All of our stuff in one infrastructure

LP advantages:

  • More advanced bug tracking
  • Somewhat easier to copy existing bugs to forked project
  • Easier working with Ubuntu crowd

Any thoughts?

interface extending Properties could call Properties methods in 0.7, but not 0.8

If I have this code:

[Interface("org.freedesktop.hostname1")]
interface IHostname1 : Introspectable, Properties
{
    void SetHostname (string name, bool userInteraction);
    void SetStaticHostname (string name, bool userInteraction);
    void SetPrettyHostname (string name, bool userInteraction);
    void SetIconName (string name, bool userInteraction);
    void SetChassis (string name, bool userInteraction);

    string Hostname { get; }
    string StaticHostname { get; }
    string PrettyHostname { get; }
    string IconName { get; }
    string Chassis { get; }
}

and compile it against dbus-sharp 0.7 on Debian 7, I can do this to get an org.freedesktop.DBus.Properties.GetAll call:

IHostname1 hostnamed = Bus.System.GetObject<IHostname1>(HOSTNAME1_NAME, HOSTNAME1_PATH);
IDictionary<string,object> asv;
asv = hostnamed.GetAll (HOSTNAME1_IFACE);

Under 0.8 or git master, this tries to call org.freedesktop.hostname1.GetAll which doesn't exist. (Or am I meant to do a separate GetObject call for the Properties interface to achieve that?)

Signal delivery between two applications delayed

I'm working to connect two programs using D-Bus. The first program is my own, written in C# and using dbus-sharp. The second is written by a 3rd-party in C++ using Qt and QtDBus. The second program exposes an object with two methods and two signals (this is what I'm trying to plug in to). In my program I've written the D-Bus interface, and I've been able to get the proxy object and call its methods. I have received signals, but in an odd manner. I do not receive the signals asynchronously; I only receive signals after calling one of the proxy object's methods.

To check my sanity, I duplicated the issue using completely unrelated code. For this test, I used the QtDBus example project "remotecontrolledcar". The subproject, "car", creates a simple scene for driving a remote-controlled car using D-Bus. The exported Car object defines a signal, but never emits it. In order to create a useful test, I have Car::timerEvent(QTimerEvent*) emit crashed() when the car reaches a certain height (i.e. transform().dy() < -200). For the client program, I simply reimplemented Qt's "controller" subproject using C#, dbus-sharp, and (yuck!) winforms. I subscribe to the crashed event with a simple handler that shows a MessageBox with the message "CRASHED!".

With my C# controller, I can drive the car just fine. Using dbus-monitor, I can also observe that the signal is sent:

signal sender=:1.232 -> dest=(null destination) serial=9 path=/Car; interface=com.trolltech.Examples.CarInterface; member=crashed

Although I see this signal get sent, nothing occurs on the client. Only after I click any of the method buttons do I get the signal.

I guess my question is, what gives?

Test Operating System: Ubuntu 10.04 LTS
dbus-sharp version: 2.0.0.0 (from 1863311, compiled using VS on Win7)
libQtDBus version: 4.6.2

Connection.IsConnected is not set to false when connection to dbus is lost

Currently, when the connection to dbus is lost (e.g. because the dbus sever is killed), Connection.Iterate() will return without setting Connection.IsConnected to false. A program using dbus-sharp then will call DBus.Iterate() again, causing 100% CPU load without doing anything.

The problem is that Transport.ReadMessageReal() returns null when the read from the socket return 0, but Connection.Iterate()/Connection.HandleMessage() do not take any action then msg is null (they probably should terminate the connection).

Signals doesn't seem to be fired (or received) properly

So was debugging the BansheeCollectionIndexer when we noted that the signals doesn't seem to fire of properly, I wrote up a small example application which shows the (or another?) problem quite clearly.

I'm using dbus-sharp 0.7 from elemantary PPA on maverick but I have a feeling its been problematic well before the namespace change (as CollectionIndexer 2.0 has the same problem and is using NDesk).

I created this small test application http://paste.ubuntu.com/662122/ which will keep doing OnTick in server but it will never reach the client. If I uncomment line 51 and the client sends one method first it does work but it seems like something is not right with the signalling? In banshee collection indexer I'm fairly certain they do a method before signals but perhaps it could guide you to the problem?

Thanks for your time,
Tobias Arrskog

Mirroring old ndesk-dbus releases

I don't think we should mirror the old releases in a publicly visible, easily accessible way. They are ABI incompatible with us and do technically reflect a different project.

Connection.GetObject blocked in signal handler

Hey,

Getting an object inside a signal handler seems to block execution on the main thread when running an Iterate loop inside a separate thread. Example:

    class MyClass
    {
        Connection connection;
        SomeObject someObject;

        public MyClass()
        {
            connection = Bus.System;

            new Thread(new ThreadStart(() =>
            {
                while (connection.IsConnected)
                {
                    connection.Iterate();
                }
            })).Start();

            someObject = connection.GetObject<SomeObject>(bus_name, objpath...);

            someObject.Callback += () =>
            {
                SomeObject2 so2 = connection.GetObject<SomeObject2>(bus_name, path...);

            }
        }
    }

When the someObject.Callback handler is called the main thread stops when trying to get the SomeObject2 object. My solution to this is to create a new thread in the signal handler and from there access SomeObject2. That seems to work just fine. Am I missing something?

Running in Mono 4.6.2 on Ubuntu 16.04.

Better exception when serialized class lacks default constructor

Over DBus I call a method that takes a parameter of type MyClass. This class has no default constructor. I get a NullReferenceException which is not helpful at all!

System.: Object reference not set to an instance of an object
at System.Reflection.Emit.ILGenerator.Emit (OpCode opcode, System.Reflection.ConstructorInfo con) [0x0001b] in /home/oskar/mono24/mono-2.6.7/mono-2.6.7/mcs/class/corlib/System.Reflection.Emit/ILGenerator.cs:536
at DBus.TypeImplementer.GenStructReader (System.Reflection.Emit.ILGenerator ilg, System.Type type) [0x00014] in /home/oskar/mono24/mono-2.6.7/dbus-sharp-0.7.0/src/TypeImplementer.cs:298
[... snipped lots of stack frames ...]

I think TypeImplementer.GenStructReader() should check for null return value from GetConstructor() and throw a proper exception with a more helpful error message.

Also, this problem does not show until actually trying to receive a message containing the offending type. It would perhaps be better to check for this already when the object is registered with the connection, to become aware of the problem earlier. Perhaps this is a bit more complex to achieve though.

Not able to catch the Dbus-Signal ?

I have written a C# application to connect with the linux application running on virtual machine and i am able to connect and execute different methods.
I am not able to catch the signal emitted by my Linux application even though i can see it in the dubs-monitor.

C# Code:

using System;
using NDesk.DBus;
using org.freedesktop.DBus;
using System.Threading;

namespace DBusGeneric
{
    public class Program
    {
        public static Connection conn;
        public static Test Store;
        public static string InterfaceName = "org.gnome.Shell.SearchProvider2";
        public delegate void OnEmitSignalHandler();

        static void Main(string[] args)
        {

            conn = Connection.Open("tcp:host=IP Address,port=Port No");

            Thread thread = new Thread(MainLoop);
            thread.Start();

            string name = "org.freedesktop.DBus";
            ObjectPath opath = new ObjectPath("/");
            IBus bus = conn.GetObject<IBus>(name, opath);
            bus.Hello();

            string busName = "org.example.TestServer";
            ObjectPath objPath = new ObjectPath("/org/example/TestObject");
            Introspectable intr = conn.GetObject<Introspectable>(busName, objPath);
            string xmlData = intr.Introspect(); ;
            Console.WriteLine("\n");
            Console.WriteLine("xmlData: " + xmlData);

            Console.WriteLine("\n");

            Store = conn.GetObject<Test>(busName, objPath);
            Store.OnEmitSignal += Store_OnEmitSignal;
            Store.EmitSignal();
            Store.Ping();
          
            Console.ReadKey();

        }

        public static void  MainLoop()
        {
            while(true)
            {
                conn.Iterate();
            }
           
        }

        private static void Store_OnEmitSignal()
        {
            Console.WriteLine("/////////////////// Received Signal ///////////////////////");
        }

        [Interface("org.example.TestInterface")]
        public interface Test
        {
            event OnEmitSignalHandler OnEmitSignal;
            void EmitSignal();
            string Ping();
           
        }
    }
    }

dbus-monitor (Virtual Machine)

method call time=1510038376.630555 sender=:1.1110 -> destination=:1.0 serial=42 path=/org/example/TestObject; interface=org.example.TestInterface; member=EmitSignal
signal time=1510038376.631501 sender=:1.0 -> destination=(null destination) serial=43730 path=/org/example/TestObject; interface=org.example.TestInterface; member=OnEmitSignal
method return time=1510038376.631530 sender=:1.0 -> destination=:1.1110 serial=43731 reply_serial=42
method call time=1510038376.672772 sender=:1.1110 -> destination=org.freedesktop.DBus serial=43 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',path='/org/freedesktop/DBus',arg0='org.example.TestServer'"
method call time=1510038376.673839 sender=:1.1110 -> destination=org.freedesktop.DBus serial=44 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.example.TestServer',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',path='/org/example/TestObject',arg0='org.example.TestInterface'"
method call time=1510038376.675216 sender=:1.1110 -> destination=org.freedesktop.DBus serial=45 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.example.TestServer',interface='org.example.TestInterface',path='/org/example/TestObject'"

It is visible that when i call EmitSignal method, OnEmitSignal is being emitted but i cant see it on the windows side.

I tried to do the Glib main loop integration but i could not build and use the reference of Ndesk.Dbus.Glib.

Can anyone help me on how can i achieve this and also capture signals from VM on my windows system.

Complete removal of ndesk name

Following meebey's advice, we need to just stop using the ndesk name/key completely. This includes:

  • Change code namespace from NDesk.Dbus to Dbus
  • Change assembly name (Dbus.dll, dbus-sharp.dll?)
  • Use the mono key to sign our assembly, or make our own key (ask Miguel et al?)
  • Change .pc file (dbus-sharp.pc)

Any upstream project would need to change their build and code to explicitly use our fork instead of ndesk-dbus. Supporting both in code shouldn't be any harder than "using NDesk.Dbus=Dbus;", right?

Linux, no output from interface method

Pretty much new to using dbus and I have following sample, that wouldn't work for me.

I use "org.freedesktop.ScreenSaver" interface with method int GetIdleTime() to retrieve idle duration,
and "com.canonical.Unity.Session" interface to provide Locked event.

I retrieve instances of both interfaces using T GetObject
Everything works fine so far, untill,
if, for example I call GetIdleTime() inside Locked event delegate.

Once locked event occur, and tries to read idle time, it never completes reading it. No exceptions, just hangs.
I tried looping idle time every 200ms for example, even while passing into Locked state, and out, no problems there.

Could someone please clarify if I am misusing the dbus or deadlock like this happens by design??

Edit
Tried to bubble event with reactive extensions and schedule subscription on new thread and it seemed to work now.

How to emit signals with dbus-sharp?

I must be missing something, how would I emit a signal from dbus-sharp? I looked through the examples but don't see anything that looks analogous.

How to catch signals?

I'm playing with the Notifications example, I would like to print something on the console output when a notification is closed. So I added the event to the interface

    [Interface ("org.freedesktop.Notifications")]
    public interface Notifications : Introspectable, Properties
    {
        ServerInformation GetServerInformation ();
        string[] GetCapabilities ();
        void CloseNotification (uint id);
        uint Notify (string app_name, uint id, string icon, string summary, string body, string[] actions, IDictionary<string,object> hints, int timeout);
        event NotificationClosedHandler NotificationClosed;
        event ActionInvokedHandler ActionInvoked;
    }
    public delegate void NotificationClosedHandler (uint id, uint reason);
    public delegate void ActionInvokedHandler (uint id, string action);

And the delegate in the main:

    nf.NotificationClosed += delegate(uint id, uint reason) {
        Console.WriteLine("Notification Closed");
    };

The code compiles without errors but I nothing is printed when a notifications is closed.

Ubuntu, PrepareForSleep signal never fired

ubuntu 16.04 LTS

I have recently switched from NDesk.Dbus Nuget to latest build here.

After switch I never received signal "PrepareForSleep" from interface "org.freedesktop.login1.Manager" again.
Maybe dbus connection gets disconnected too early?

Bump minimum framework profile?

ndesk-dbus was developed with .NET 2.0 and C# 2.0 mindset but, especially with Mono 2.8 going to be released soonish, we can safely assume that 3.5 and 4.0 are going to be definitely around by the time projects start using us. The question then is do we really have to stick with C# 2.0 in our code?

I personally don't see a problem to at least use C# 3.0 and .NET 3.5 (i.e. Linq) since it doesn't break anything for anyone (same compiler and all) but we may also move directly to C# 4 and .NET 4.0 (and thus force use of dmcs compiler).

Thoughts?

Package-config files should use @libdir@ for libdir

Both the dbus-sharp-1.0.pc.in and dbus-sharp-glib-1.0.pc.in should use @libdir@ for the libdir variable instead of hardcoding it to ${exec_prefix}/lib. This prevents errors and issues preventing installation and detection of these packages when installing programs that use these libraries on systems that use lib64 for x64 systems, such as Fedora.

Implement org.freedesktop.DBus.Properties for exported objects

Exported objects' properties are not accessible via the standard org.freedesktop.DBus.Properties interface.

I'm attaching a first, rough patch for fixing this. It implements Get and Set but not GetAll. It could use some work in terms of checking the requested property interface, etc.

Patch against ndesk-dbus: https://bugs.launchpad.net/ndesk-dbus/+bug/494823/+attachment/1065839/+files/0001-First-rough-pass-implementing-Properties-iface.patch

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.