[Pkg-cli-apps-commits] [SCM] banshee-community-extensions branch, master, updated. debian/2.0.1-1-5-ga9986d7
Chow Loong Jin
hyperair at ubuntu.com
Wed Jul 6 02:44:13 UTC 2011
The following commit has been merged in the master branch:
commit e468baa313aafd5d327132250c37b9bd26137579
Author: Chow Loong Jin <hyperair at ubuntu.com>
Date: Wed Jul 6 04:03:56 2011 +0800
Cherry-pick port to DBus#
diff --git a/debian/patches/0001-Use-DBus-instead-of-NDesk.DBus.patch b/debian/patches/0001-Use-DBus-instead-of-NDesk.DBus.patch
new file mode 100644
index 0000000..f0bca3d
--- /dev/null
+++ b/debian/patches/0001-Use-DBus-instead-of-NDesk.DBus.patch
@@ -0,0 +1,11409 @@
+From d9d9f886e80524396669b54582a8d312ebef7577 Mon Sep 17 00:00:00 2001
+From: Chow Loong Jin <hyperair at ubuntu.com>
+Date: Sat, 28 May 2011 00:45:09 +0800
+Subject: [PATCH] Use DBus# instead of NDesk.DBus
+
+---
+ src/Awn/Banshee.Awn/AwnPlugin.cs | 6 +-
+ .../Banshee.Telepathy.API/Account.cs | 2 +-
+ .../Banshee.Telepathy.API/Channels/Channel.cs | 2 +-
+ .../Channels/ContactListChannel.cs | 4 +-
+ .../Banshee.Telepathy.API/ConnectionLocator.cs | 2 +-
+ .../Banshee.Telepathy.API/DBus/DBusConnection.cs | 10 +-
+ .../Banshee.Telepathy.API/DBus/DBusUtility.cs | 2 +-
+ .../Banshee.Telepathy.API/DBus/EmpathyHandler.cs | 2 +-
+ .../Dispatchers/ChannelHandler.cs | 4 +-
+ .../Dispatchers/Dispatcher.cs | 2 +-
+ .../Banshee.Telepathy.DBus/IMetadataProvider.cs | 2 +-
+ .../IMetadataProviderService.cs | 2 +-
+ .../Banshee.Telepathy.DBus/IPlaylistProvider.cs | 2 +-
+ .../MetadataProviderService.cs | 2 +-
+ .../Banshee.Telepathy.DBus/PlaylistProvider.cs | 2 +-
+ .../Banshee.Telepathy/Banshee.Telepathy.csproj | 2 +-
+ .../Banshee.Telepathy/TelepathyService.cs | 4 +-
+ src/Telepathy/Banshee.Telepathy/Makefile.am | 34 +-
+ .../Banshee.Telepathy/NDesk.DBus/Address.cs | 188 ----
+ .../Banshee.Telepathy/NDesk.DBus/Authentication.cs | 538 ---------
+ src/Telepathy/Banshee.Telepathy/NDesk.DBus/Bus.cs | 179 ---
+ .../Banshee.Telepathy/NDesk.DBus/BusObject.cs | 398 -------
+ .../Banshee.Telepathy/NDesk.DBus/Connection.cs | 592 ----------
+ src/Telepathy/Banshee.Telepathy/NDesk.DBus/DBus.cs | 98 --
+ .../Banshee.Telepathy/NDesk.DBus/DProxy.cs | 79 --
+ .../Banshee.Telepathy/NDesk.DBus/Daemon.cs | 222 ----
+ .../NDesk.DBus/DynamicExportObject.cs | 98 --
+ .../Banshee.Telepathy/NDesk.DBus/ExportObject.cs | 200 ----
+ .../Banshee.Telepathy/NDesk.DBus/GLib.IO.cs | 222 ----
+ src/Telepathy/Banshee.Telepathy/NDesk.DBus/GLib.cs | 53 -
+ .../Banshee.Telepathy/NDesk.DBus/Introspection.cs | 316 ------
+ .../NDesk.DBus/IntrospectionSchema.cs | 118 --
+ .../Banshee.Telepathy/NDesk.DBus/Mapper.cs | 387 -------
+ .../Banshee.Telepathy/NDesk.DBus/MatchRule.cs | 319 ------
+ .../Banshee.Telepathy/NDesk.DBus/Message.cs | 492 ---------
+ .../Banshee.Telepathy/NDesk.DBus/MessageFilter.cs | 58 -
+ .../Banshee.Telepathy/NDesk.DBus/MessageReader.cs | 494 ---------
+ .../Banshee.Telepathy/NDesk.DBus/MessageWriter.cs | 570 ----------
+ .../Banshee.Telepathy/NDesk.DBus/NDesk.DBus.csproj | 74 --
+ .../Banshee.Telepathy/NDesk.DBus/PendingCall.cs | 111 --
+ .../Banshee.Telepathy/NDesk.DBus/PipeTransport.cs | 119 --
+ .../Banshee.Telepathy/NDesk.DBus/Protocol.cs | 497 ---------
+ .../Banshee.Telepathy/NDesk.DBus/Server.cs | 503 ---------
+ .../Banshee.Telepathy/NDesk.DBus/ServerBus.cs | 715 ------------
+ .../Banshee.Telepathy/NDesk.DBus/Signature.cs | 897 ---------------
+ .../NDesk.DBus/SocketTransport.cs | 70 --
+ .../Banshee.Telepathy/NDesk.DBus/Transport.cs | 405 -------
+ .../Banshee.Telepathy/NDesk.DBus/TypeDefiner.cs | 227 ----
+ .../NDesk.DBus/TypeImplementer.cs | 1154 --------------------
+ .../Banshee.Telepathy/NDesk.DBus/TypeRental.cs | 504 ---------
+ src/Telepathy/Banshee.Telepathy/NDesk.DBus/Unix.cs | 484 --------
+ .../NDesk.DBus/UnixMonoTransport.cs | 66 --
+ .../NDesk.DBus/UnixNativeTransport.cs | 192 ----
+ .../Banshee.Telepathy/NDesk.DBus/UnixTransport.cs | 29 -
+ .../Banshee.Telepathy/NDesk.DBus/Wrapper.cs | 158 ---
+ .../Banshee.Telepathy/NDesk.DBus/daemon.mk | 11 -
+ .../Banshee.Telepathy/Telepathy/MissionControl.cs | 2 +-
+ .../Banshee.Telepathy/Telepathy/Telepathy.cs | 2 +-
+ 58 files changed, 29 insertions(+), 11898 deletions(-)
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/Address.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/Authentication.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/Bus.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/BusObject.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/Connection.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/DBus.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/DProxy.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/Daemon.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/DynamicExportObject.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/ExportObject.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/GLib.IO.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/GLib.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/Introspection.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/IntrospectionSchema.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/Mapper.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/MatchRule.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/Message.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/MessageFilter.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/MessageReader.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/MessageWriter.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/NDesk.DBus.csproj
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/PendingCall.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/PipeTransport.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/Protocol.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/Server.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/ServerBus.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/Signature.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/SocketTransport.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/Transport.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/TypeDefiner.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/TypeImplementer.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/TypeRental.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/Unix.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/UnixMonoTransport.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/UnixNativeTransport.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/UnixTransport.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/Wrapper.cs
+ delete mode 100644 src/Telepathy/Banshee.Telepathy/NDesk.DBus/daemon.mk
+
+Index: banshee-community-extensions/src/Awn/Banshee.Awn/AwnPlugin.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Awn/Banshee.Awn/AwnPlugin.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Awn/Banshee.Awn/AwnPlugin.cs 2011-07-06 04:00:39.049158390 +0800
+@@ -34,7 +34,7 @@
+
+ namespace Banshee.Awn
+ {
+- [NDesk.DBus.Interface("com.google.code.Awn")]
++ [DBus.Interface("com.google.code.Awn")]
+ public interface IAvantWindowNavigator
+ {
+ void SetTaskIconByName (string TaskName, string ImageFileLocation);
+@@ -74,8 +74,8 @@
+ try {
+ Log.DebugFormat ("BansheeAwn. Starting {0}", Application.ActiveClient.ClientId);
+
+- awn = NDesk.DBus.Bus.Session.GetObject<IAvantWindowNavigator> ("com.google.code.Awn",
+- new NDesk.DBus.ObjectPath ("/com/google/code/Awn"));
++ awn = DBus.Bus.Session.GetObject<IAvantWindowNavigator> ("com.google.code.Awn",
++ new DBus.ObjectPath ("/com/google/code/Awn"));
+
+ // Dummy call to check that awn is really there
+ awn.UnsetTaskIconByName ("banshee-dummy");
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Account.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Account.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Account.cs 2011-07-06 04:00:39.049158390 +0800
+@@ -29,7 +29,7 @@
+ using System;
+ using System.Collections.Generic;
+
+-using NDesk.DBus;
++using DBus;
+
+ using Telepathy;
+
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Channels/Channel.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Channels/Channel.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Channels/Channel.cs 2011-07-06 04:00:39.052491712 +0800
+@@ -29,7 +29,7 @@
+ using System;
+ using System.Collections.Generic;
+
+-using NDesk.DBus;
++using DBus;
+
+ using Banshee.Telepathy.API.DBus;
+
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Channels/ContactListChannel.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Channels/ContactListChannel.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Channels/ContactListChannel.cs 2011-07-06 04:00:39.052491712 +0800
+@@ -31,7 +31,7 @@
+
+ using Banshee.Telepathy.API.DBus;
+
+-using NDesk.DBus;
++using DBus;
+
+ using Telepathy;
+
+@@ -174,4 +174,4 @@
+ }
+ }
+ }
+-}
+\ No newline at end of file
++}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/ConnectionLocator.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/ConnectionLocator.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/ConnectionLocator.cs 2011-07-06 04:00:39.052491712 +0800
+@@ -29,7 +29,7 @@
+ using System;
+ using System.Collections.Generic;
+
+-using NDesk.DBus;
++using DBus;
+
+ using Telepathy;
+
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/DBus/DBusConnection.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/DBus/DBusConnection.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/DBus/DBusConnection.cs 2011-07-06 04:00:39.052491712 +0800
+@@ -29,14 +29,14 @@
+ using System;
+ using System.Collections.Generic;
+
+-using NDesk.DBus;
++using DBus;
+
+ namespace Banshee.Telepathy.API.DBus
+ {
+ public sealed class DBusConnection
+ {
+ private string address;
+- private NDesk.DBus.Connection conn = null;
++ private global::DBus.Connection conn = null;
+ private IDictionary <string, object> registered;
+
+ private DBusConnection ()
+@@ -47,7 +47,7 @@
+ public DBusConnection (string address) : this ()
+ {
+ Address = address;
+- conn = NDesk.DBus.Connection.Open (address);
++ conn = global::DBus.Connection.Open (address);
+ }
+
+ public DBusConnection (string address, bool mainloop) : this (address)
+@@ -126,8 +126,8 @@
+ public void ConnectToMainLoop ()
+ {
+ if (conn != null) {
+- BusG.Init (conn);
++ global::DBus.BusG.Init (conn);
+ }
+ }
+ }
+-}
+\ No newline at end of file
++}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/DBus/DBusUtility.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/DBus/DBusUtility.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/DBus/DBusUtility.cs 2011-07-06 04:00:39.055825033 +0800
+@@ -30,7 +30,7 @@
+ using System;
+ using System.Collections.Generic;
+
+-using NDesk.DBus;
++using DBus;
+ using org.freedesktop.DBus;
+
+ namespace Banshee.Telepathy.API.DBus
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/DBus/EmpathyHandler.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/DBus/EmpathyHandler.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/DBus/EmpathyHandler.cs 2011-07-06 04:00:39.055825033 +0800
+@@ -28,7 +28,7 @@
+
+ using System;
+
+-using NDesk.DBus;
++using DBus;
+
+ namespace Banshee.Telepathy.API.DBus
+ {
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Dispatchers/ChannelHandler.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Dispatchers/ChannelHandler.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Dispatchers/ChannelHandler.cs 2011-07-06 04:00:39.055825033 +0800
+@@ -29,7 +29,7 @@
+ using System;
+ using System.Collections.Generic;
+
+-using NDesk.DBus;
++using DBus;
+ using org.freedesktop.DBus;
+
+ using Telepathy;
+@@ -180,4 +180,4 @@
+
+ }
+ }
+-}
+\ No newline at end of file
++}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Dispatchers/Dispatcher.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Dispatchers/Dispatcher.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.API/Dispatchers/Dispatcher.cs 2011-07-06 04:00:39.055825033 +0800
+@@ -29,7 +29,7 @@
+ using System;
+ using System.Collections.Generic;
+
+-using NDesk.DBus;
++using DBus;
+
+ using Telepathy;
+
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/IMetadataProvider.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/IMetadataProvider.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/IMetadataProvider.cs 2011-07-06 04:00:39.059158354 +0800
+@@ -28,7 +28,7 @@
+
+ using System;
+ using System.Collections.Generic;
+-using NDesk.DBus;
++using DBus;
+
+ namespace Banshee.Telepathy.DBus
+ {
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/IMetadataProviderService.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/IMetadataProviderService.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/IMetadataProviderService.cs 2011-07-06 04:00:39.059158354 +0800
+@@ -28,7 +28,7 @@
+
+ using System;
+ using System.Collections.Generic;
+-using NDesk.DBus;
++using DBus;
+
+ namespace Banshee.Telepathy.DBus
+ {
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/IPlaylistProvider.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/IPlaylistProvider.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/IPlaylistProvider.cs 2011-07-06 04:00:39.059158354 +0800
+@@ -28,7 +28,7 @@
+
+ using System;
+ using System.Collections.Generic;
+-using NDesk.DBus;
++using DBus;
+
+ namespace Banshee.Telepathy.DBus
+ {
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/MetadataProviderService.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/MetadataProviderService.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/MetadataProviderService.cs 2011-07-06 04:00:39.059158354 +0800
+@@ -37,7 +37,7 @@
+
+ using Hyena;
+
+-using NDesk.DBus;
++using DBus;
+
+ namespace Banshee.Telepathy.DBus
+ {
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/PlaylistProvider.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/PlaylistProvider.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy.DBus/PlaylistProvider.cs 2011-07-06 04:00:39.059158354 +0800
+@@ -37,7 +37,7 @@
+
+ using Hyena.Data.Sqlite;
+
+-using NDesk.DBus;
++using DBus;
+
+ namespace Banshee.Telepathy.DBus
+ {
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy/TelepathyService.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy/TelepathyService.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Banshee.Telepathy/TelepathyService.cs 2011-07-06 04:00:39.062491674 +0800
+@@ -150,8 +150,8 @@
+
+ public void DelayedInitialize ()
+ {
+- // require for bundled version of NDesk.DBus
+- NDesk.DBus.BusG.Init ();
++ // require for bundled version of DBus
++ global::DBus.BusG.Init ();
+
+ conn_map = new Dictionary <string, Connection> ();
+ source_map = new Dictionary <string, IDictionary <Contact, ContactSource>> ();
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Makefile.am
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Makefile.am 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Makefile.am 2011-07-06 04:00:39.062491674 +0800
+@@ -82,39 +82,7 @@
+ Banshee.Telepathy.DBus/PlaylistProvider.cs \
+ Telepathy/Constants.cs \
+ Telepathy/MissionControl.cs \
+- Telepathy/Telepathy.cs \
+- NDesk.DBus/Address.cs \
+- NDesk.DBus/Authentication.cs \
+- NDesk.DBus/Bus.cs \
+- NDesk.DBus/BusObject.cs \
+- NDesk.DBus/Connection.cs \
+- NDesk.DBus/DBus.cs \
+- NDesk.DBus/DProxy.cs \
+- NDesk.DBus/ExportObject.cs \
+- NDesk.DBus/GLib.cs \
+- NDesk.DBus/GLib.IO.cs \
+- NDesk.DBus/Introspection.cs \
+- NDesk.DBus/IntrospectionSchema.cs \
+- NDesk.DBus/Mapper.cs \
+- NDesk.DBus/MatchRule.cs \
+- NDesk.DBus/Message.cs \
+- NDesk.DBus/MessageFilter.cs \
+- NDesk.DBus/MessageReader.cs \
+- NDesk.DBus/MessageWriter.cs \
+- NDesk.DBus/PendingCall.cs \
+- NDesk.DBus/Protocol.cs \
+- NDesk.DBus/Server.cs \
+- NDesk.DBus/ServerBus.cs \
+- NDesk.DBus/Signature.cs \
+- NDesk.DBus/SocketTransport.cs \
+- NDesk.DBus/Transport.cs \
+- NDesk.DBus/TypeDefiner.cs \
+- NDesk.DBus/TypeImplementer.cs \
+- NDesk.DBus/Unix.cs \
+- NDesk.DBus/UnixMonoTransport.cs \
+- NDesk.DBus/UnixNativeTransport.cs \
+- NDesk.DBus/UnixTransport.cs \
+- NDesk.DBus/Wrapper.cs
++ Telepathy/Telepathy.cs
+
+ RESOURCES = \
+ Resources/ActiveSourceUI.xml \
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Address.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Address.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,188 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Text;
+-using System.Collections.Generic;
+-
+-namespace NDesk.DBus
+-{
+- // Subclass obsolete BadAddressException to avoid ABI break
+-#pragma warning disable 0618
+- //public class InvalidAddressException : Exception
+- public class InvalidAddressException : BadAddressException
+- {
+- public InvalidAddressException (string reason) : base (reason) {}
+- }
+-#pragma warning restore 0618
+-
+- [Obsolete ("Use InvalidAddressException")]
+- public class BadAddressException : Exception
+- {
+- public BadAddressException (string reason) : base (reason) {}
+- }
+-
+- class AddressEntry
+- {
+- public string Method;
+- public readonly IDictionary<string,string> Properties = new Dictionary<string,string> ();
+- public UUID GUID = UUID.Zero;
+-
+- public override string ToString ()
+- {
+- StringBuilder sb = new StringBuilder ();
+- sb.Append (Method);
+- sb.Append (':');
+-
+- bool first = true;
+- foreach (KeyValuePair<string,string> prop in Properties) {
+- if (first)
+- first = false;
+- else
+- sb.Append (',');
+-
+- sb.Append (prop.Key);
+- sb.Append ('=');
+- sb.Append (Escape (prop.Value));
+- }
+-
+- if (GUID != UUID.Zero) {
+- if (Properties.Count != 0)
+- sb.Append (',');
+- sb.Append ("guid");
+- sb.Append ('=');
+- sb.Append (GUID.ToString ());
+- }
+-
+- return sb.ToString ();
+- }
+-
+- static string Escape (string str)
+- {
+- if (str == null)
+- return String.Empty;
+-
+- StringBuilder sb = new StringBuilder ();
+- int len = str.Length;
+-
+- for (int i = 0 ; i != len ; i++) {
+- char c = str[i];
+-
+- //everything other than the optionally escaped chars _must_ be escaped
+- if (Char.IsLetterOrDigit (c) || c == '-' || c == '_' || c == '/' || c == '\\' || c == '.')
+- sb.Append (c);
+- else
+- sb.Append (Uri.HexEscape (c));
+- }
+-
+- return sb.ToString ();
+- }
+-
+- static string Unescape (string str)
+- {
+- if (str == null)
+- return String.Empty;
+-
+- StringBuilder sb = new StringBuilder ();
+- int len = str.Length;
+- int i = 0;
+- while (i != len) {
+- if (Uri.IsHexEncoding (str, i))
+- sb.Append (Uri.HexUnescape (str, ref i));
+- else
+- sb.Append (str[i++]);
+- }
+-
+- return sb.ToString ();
+- }
+-
+-
+- public static AddressEntry Parse (string s)
+- {
+- AddressEntry entry = new AddressEntry ();
+-
+- string[] parts = s.Split (':');
+-
+- if (parts.Length < 2)
+- throw new InvalidAddressException ("No colon found");
+- if (parts.Length > 2)
+- throw new InvalidAddressException ("Too many colons found");
+-
+- entry.Method = parts[0];
+-
+- foreach (string propStr in parts[1].Split (',')) {
+- parts = propStr.Split ('=');
+-
+- if (parts.Length < 2)
+- throw new InvalidAddressException ("No equals sign found");
+- if (parts.Length > 2)
+- throw new InvalidAddressException ("Too many equals signs found");
+-
+- if (parts[0] == "guid") {
+- try {
+- entry.GUID = UUID.Parse (parts[1]);
+- } catch {
+- throw new InvalidAddressException ("Invalid guid specified");
+- }
+- continue;
+- }
+-
+- entry.Properties[parts[0]] = Unescape (parts[1]);
+- }
+-
+- return entry;
+- }
+- }
+-
+- static class Address
+- {
+- //(unix:(path|abstract)=.*,guid=.*|tcp:host=.*(,port=.*)?);? ...
+- public static AddressEntry[] Parse (string addresses)
+- {
+- if (addresses == null)
+- throw new ArgumentNullException (addresses);
+-
+- List<AddressEntry> entries = new List<AddressEntry> ();
+-
+- foreach (string entryStr in addresses.Split (';'))
+- entries.Add (AddressEntry.Parse (entryStr));
+-
+- return entries.ToArray ();
+- }
+-
+- const string SYSTEM_BUS_ADDRESS = "unix:path=/var/run/dbus/system_bus_socket";
+- public static string System
+- {
+- get {
+- string addr = Environment.GetEnvironmentVariable ("DBUS_SYSTEM_BUS_ADDRESS");
+-
+- if (String.IsNullOrEmpty (addr))
+- addr = SYSTEM_BUS_ADDRESS;
+-
+- return addr;
+- }
+- }
+-
+- public static string Session
+- {
+- get {
+- return Environment.GetEnvironmentVariable ("DBUS_SESSION_BUS_ADDRESS");
+- }
+- }
+-
+- public static string Starter
+- {
+- get {
+- return Environment.GetEnvironmentVariable ("DBUS_STARTER_ADDRESS");
+- }
+- }
+-
+- public static string StarterBusType
+- {
+- get {
+- return Environment.GetEnvironmentVariable ("DBUS_STARTER_BUS_TYPE");
+- }
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Authentication.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Authentication.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,538 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Collections.Generic;
+-using System.IO;
+-using System.Text;
+-using System.Text.RegularExpressions;
+-using System.Globalization;
+-
+-namespace NDesk.DBus
+-{
+- using Authentication;
+-
+- //using System.Runtime.InteropServices;
+- //[StructLayout (LayoutKind.Sequential)]
+- unsafe struct UUID
+- {
+- private int a, b, c, d;
+- const int ByteLength = 16;
+-
+- public static readonly UUID Zero = new UUID ();
+-
+- public static bool operator == (UUID a, UUID b)
+- {
+- if (a.a == b.a && a.b == b.b && a.c == b.c && a.d == b.d)
+- return true;
+- else
+- return false;
+- }
+-
+- public static bool operator != (UUID a, UUID b)
+- {
+- return !(a == b);
+- }
+-
+- public override bool Equals (object o)
+- {
+- if (o == null)
+- return false;
+-
+- if (!(o is UUID))
+- return false;
+-
+- return this == (UUID)o;
+- }
+-
+- public override int GetHashCode ()
+- {
+- return a ^ b ^ c ^ d;
+- }
+-
+- public override string ToString ()
+- {
+- StringBuilder sb = new StringBuilder (ByteLength * 2);
+-
+- fixed (int* p = &a) {
+- byte* bp = (byte*)p;
+- for (int i = 0 ; i != ByteLength ; i++)
+- sb.Append (bp[i].ToString ("x2", CultureInfo.InvariantCulture));
+- }
+-
+- return sb.ToString ();
+- }
+-
+- public static UUID Parse (string hex)
+- {
+- if (hex.Length != ByteLength * 2)
+- throw new Exception ("Cannot parse UUID/GUID of invalid length");
+-
+- UUID id = new UUID ();
+-
+- byte* result = (byte*)&id.a;
+- int n = 0, i = 0;
+- while (n < ByteLength) {
+- result[n] = (byte)(Sasl.FromHexChar (hex[i++]) << 4);
+- result[n++] += Sasl.FromHexChar (hex[i++]);
+- }
+-
+- return id;
+- }
+-
+- static Random rand = new Random ();
+- static byte[] buf = new byte[12];
+- public static UUID Generate (DateTime timestamp)
+- {
+- UUID id = new UUID ();
+-
+- lock (buf) {
+- rand.NextBytes (buf);
+- fixed (byte* bp = &buf[0]) {
+- int* p = (int*)bp;
+- id.a = p[0];
+- id.b = p[1];
+- id.c = p[2];
+- }
+- }
+-
+- //id.d is assigned to by Timestamp
+- id.Timestamp = timestamp;
+-
+- return id;
+- }
+-
+- public static UUID Generate ()
+- {
+- return Generate (DateTime.Now);
+- }
+-
+- public uint UnixTimestamp
+- {
+- get {
+- uint unixTime;
+-
+- fixed (int* ip = &d) {
+- if (BitConverter.IsLittleEndian) {
+- byte* p = (byte*)ip;
+- byte* bp = (byte*)&unixTime;
+- bp[0] = p[3];
+- bp[1] = p[2];
+- bp[2] = p[1];
+- bp[3] = p[0];
+- } else {
+- unixTime = *(uint*)ip;
+- }
+- }
+-
+- return unixTime;
+- } set {
+- uint unixTime = value;
+-
+- fixed (int* ip = &d) {
+- if (BitConverter.IsLittleEndian) {
+- byte* p = (byte*)&unixTime;
+- byte* bp = (byte*)ip;
+- bp[0] = p[3];
+- bp[1] = p[2];
+- bp[2] = p[1];
+- bp[3] = p[0];
+- } else {
+- *(uint*)ip = unixTime;
+- }
+- }
+- }
+- }
+-
+- public DateTime Timestamp
+- {
+- get {
+- return Sasl.UnixToDateTime (UnixTimestamp);
+- } set {
+- UnixTimestamp = (uint)Sasl.DateTimeToUnix (value);
+- }
+- }
+- }
+-}
+-
+-namespace NDesk.DBus.Authentication
+-{
+- enum ClientState
+- {
+- WaitingForData,
+- WaitingForOK,
+- WaitingForReject,
+- }
+-
+- enum ServerState
+- {
+- WaitingForAuth,
+- WaitingForData,
+- WaitingForBegin,
+- }
+-
+- class AuthCommand
+- {
+- /*
+- public AuthCommand (string value)
+- {
+- //this.Value = value;
+- this.Value = value.Trim ();
+- }
+- */
+-
+-
+- public AuthCommand (string value)
+- {
+- //this.Value = value;
+- this.Value = value.Trim ();
+- Args.AddRange (Value.Split (' '));
+- }
+-
+- readonly List<string> Args = new List<string> ();
+-
+- public string this[int index]
+- {
+- get {
+- if (index >= Args.Count)
+- return String.Empty;
+- return Args[index];
+- }
+- }
+-
+- /*
+- public AuthCommand (string value, params string[] args)
+- {
+- if (args.Length == 0)
+- this.Value = value;
+- else
+- this.Value = value + " " + String.Join (" ", args);
+- }
+- */
+-
+- public readonly string Value;
+- }
+-
+- class SaslPeer : IEnumerable<AuthCommand>
+- {
+- //public Connection conn;
+- public SaslPeer Peer;
+-
+- public Stream stream = null;
+- public bool UseConsole = false;
+-
+- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator ()
+- {
+- return GetEnumerator ();
+- }
+-
+- internal bool isFinalRead = false;
+-
+- public virtual IEnumerator<AuthCommand> GetEnumerator ()
+- {
+- // Read the mandatory null credentials byte
+- /*
+- if (!UseConsole)
+- if (conn.Transport.Stream.ReadByte () != 0)
+- yield break;
+- */
+-
+- TextReader sr;
+- sr = UseConsole ? Console.In : new StreamReader (stream, Encoding.ASCII);
+-
+- while (true) {
+- string ln;
+- bool isEnd = false;
+- if (!UseConsole && isFinalRead) {
+- StringBuilder sb = new StringBuilder ();
+-
+- while (true) {
+- //MemoryStream ms = new MemoryStream ();
+- // TODO: Use char instead? Check for -1?
+- int a = stream.ReadByte ();
+-
+- if (a == -1) {
+- isEnd = true;
+- break;
+- }
+-
+- if (a == '\r') {
+- int b = stream.ReadByte ();
+- if (b != '\n')
+- throw new Exception ();
+- break;
+- }
+-
+- sb.Append ((char)a);
+- }
+-
+- ln = sb.ToString ();
+- //isFinalRead = false;
+- } else {
+- ln = sr.ReadLine ();
+- }
+-
+- //if (isEnd && ln == string.Empty)
+- // yield break;
+- if (ln == null)
+- yield break;
+- if (ln != String.Empty)
+- yield return new AuthCommand (ln);
+- if (isEnd)
+- yield break;
+- }
+- }
+-
+- public bool Authenticate ()
+- {
+- return Run (this);
+- }
+-
+- public bool AuthenticateSelf ()
+- {
+- //IEnumerator<AuthCommand> a = Peer.GetEnumerator ();
+- IEnumerator<AuthCommand> b = GetEnumerator ();
+- //bool ret = b.MoveNext ();
+- while (b.MoveNext ()) {
+- if (b.Current.Value == "BEGIN")
+- return true;
+- }
+- return false;
+- }
+-
+- public virtual bool Run (IEnumerable<AuthCommand> commands)
+- {
+- TextWriter sw;
+- sw = UseConsole ? Console.Out : new StreamWriter (stream, Encoding.ASCII);
+- if (!UseConsole)
+- sw.NewLine = "\r\n";
+-
+- foreach (AuthCommand command in commands) {
+- if (command == null) {
+- // Disconnect here?
+- return false;
+- }
+- sw.WriteLine (command.Value);
+- sw.Flush ();
+- }
+-
+- return true;
+- }
+- }
+-
+- class SaslClient : SaslPeer
+- {
+- public string Identity = String.Empty;
+-
+- //static Regex rejectedRegex = new Regex (@"^REJECTED(\s+(\w+))*$");
+-
+- // This enables simple support for multiple AUTH schemes
+- enum AuthMech
+- {
+- External,
+- Anonymous,
+- None,
+- }
+-
+- public override IEnumerator<AuthCommand> GetEnumerator ()
+- {
+- IEnumerator<AuthCommand> replies = Peer.GetEnumerator ();
+-
+- AuthMech currMech = AuthMech.External;
+-
+- while (true) {
+- Peer.isFinalRead = false;
+-
+- if (currMech == AuthMech.External) {
+- string str = Identity;
+- byte[] bs = Encoding.ASCII.GetBytes (str);
+- string initialData = Sasl.ToHex (bs);
+- yield return new AuthCommand ("AUTH EXTERNAL " + initialData);
+- currMech = AuthMech.Anonymous;
+- } else if (currMech == AuthMech.Anonymous) {
+- yield return new AuthCommand ("AUTH ANONYMOUS");
+- currMech = AuthMech.None;
+- } else {
+- throw new Exception ("Authentication failure");
+- }
+-
+- Peer.isFinalRead = true;
+-
+- AuthCommand reply;
+- if (!replies.MoveNext ())
+- yield break;
+- reply = replies.Current;
+-
+- if (reply[0] == "REJECTED") {
+- continue;
+- }
+-
+- /*
+- Match m = rejectedRegex.Match (reply.Value);
+- if (m.Success) {
+- string[] mechanisms = m.Groups[1].Value.Split (' ');
+- //yield return new AuthCommand ("CANCEL");
+- continue;
+- }
+- */
+-
+- if (reply[0] != "OK") {
+- yield return new AuthCommand ("ERROR");
+- continue;
+- }
+-
+- if (reply[1] == String.Empty)
+- ActualId = UUID.Zero;
+- else
+- ActualId = UUID.Parse (reply[1]);
+-
+- yield return new AuthCommand ("BEGIN");
+- yield break;
+- }
+-
+- }
+-
+- public UUID ActualId = UUID.Zero;
+- }
+-
+- class SaslServer : SaslPeer
+- {
+- //public int MaxFailures = 10;
+- public UUID Guid = UUID.Zero;
+-
+- public long uid = 0;
+-
+- static Regex authRegex = new Regex (@"^AUTH\s+(\w+)(?:\s+(.*))?$");
+- static string[] supportedMechanisms = {"EXTERNAL"};
+-
+- public override IEnumerator<AuthCommand> GetEnumerator ()
+- {
+- IEnumerator<AuthCommand> replies = Peer.GetEnumerator ();
+-
+- while (true) {
+- Peer.isFinalRead = false;
+-
+- AuthCommand reply;
+- if (!replies.MoveNext ()) {
+- yield return null;
+- yield break;
+- //continue;
+- }
+- reply = replies.Current;
+-
+- Match m = authRegex.Match (reply.Value);
+- if (!m.Success) {
+- yield return new AuthCommand ("ERROR");
+- continue;
+- }
+-
+- string mechanism = m.Groups[1].Value;
+- string initialResponse = m.Groups[2].Value;
+-
+- if (mechanism == "EXTERNAL") {
+- try {
+- byte[] bs = Sasl.FromHex (initialResponse);
+- string authStr = Encoding.ASCII.GetString (bs);
+- uid = UInt32.Parse (authStr);
+- } catch {
+- uid = 0;
+- }
+- //return RunExternal (Run (), initialResponse);
+- } else {
+- yield return new AuthCommand ("REJECTED " + String.Join (" ", supportedMechanisms));
+- continue;
+- }
+-
+- if (Guid == UUID.Zero)
+- yield return new AuthCommand ("OK");
+- else
+- yield return new AuthCommand ("OK " + Guid.ToString ());
+-
+- Peer.isFinalRead = true;
+-
+- if (!replies.MoveNext ()) {
+- /*
+- yield break;
+- continue;
+- */
+- yield return null;
+- yield break;
+- }
+-
+- reply = replies.Current;
+- if (reply.Value != "BEGIN") {
+- yield return new AuthCommand ("ERROR");
+- continue;
+- }
+-
+- yield break;
+- }
+- }
+- }
+-
+- static class Sasl
+- {
+- //From Mono.Unix.Native.NativeConvert
+- //should these methods use long or (u)int?
+- public static DateTime UnixToDateTime (long time)
+- {
+- DateTime LocalUnixEpoch = new DateTime (1970, 1, 1);
+- TimeSpan LocalUtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset (DateTime.UtcNow);
+- return LocalUnixEpoch.AddSeconds ((double) time + LocalUtcOffset.TotalSeconds);
+- }
+-
+- public static long DateTimeToUnix (DateTime time)
+- {
+- DateTime LocalUnixEpoch = new DateTime (1970, 1, 1);
+- TimeSpan LocalUtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset (DateTime.UtcNow);
+- TimeSpan unixTime = time.Subtract (LocalUnixEpoch) - LocalUtcOffset;
+-
+- return (long) unixTime.TotalSeconds;
+- }
+-
+- //From Mono.Security.Cryptography
+- //Modified to output lowercase hex
+- static public string ToHex (byte[] input)
+- {
+- if (input == null)
+- return null;
+-
+- StringBuilder sb = new StringBuilder (input.Length * 2);
+- foreach (byte b in input) {
+- sb.Append (b.ToString ("x2", CultureInfo.InvariantCulture));
+- }
+- return sb.ToString ();
+- }
+-
+- //From Mono.Security.Cryptography
+- static public byte FromHexChar (char c)
+- {
+- if ((c >= 'a') && (c <= 'f'))
+- return (byte) (c - 'a' + 10);
+- if ((c >= 'A') && (c <= 'F'))
+- return (byte) (c - 'A' + 10);
+- if ((c >= '0') && (c <= '9'))
+- return (byte) (c - '0');
+- throw new ArgumentException ("Invalid hex char");
+- }
+-
+- //From Mono.Security.Cryptography
+- static public byte[] FromHex (string hex)
+- {
+- if (hex == null)
+- return null;
+- if ((hex.Length & 0x1) == 0x1)
+- throw new ArgumentException ("Length must be a multiple of 2");
+-
+- byte[] result = new byte [hex.Length >> 1];
+- int n = 0;
+- int i = 0;
+- while (n < result.Length) {
+- result [n] = (byte) (FromHexChar (hex [i++]) << 4);
+- result [n++] += FromHexChar (hex [i++]);
+- }
+- return result;
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Bus.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Bus.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,179 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Collections.Generic;
+-using org.freedesktop.DBus;
+-
+-namespace NDesk.DBus
+-{
+- public sealed class Bus : Connection
+- {
+- static Bus systemBus = null;
+- public static Bus System
+- {
+- get {
+- if (systemBus == null) {
+- try {
+- if (Address.StarterBusType == "system")
+- systemBus = Starter;
+- else
+- systemBus = Bus.Open (Address.System);
+- } catch (Exception e) {
+- throw new Exception ("Unable to open the system message bus.", e);
+- }
+- }
+-
+- return systemBus;
+- }
+- }
+-
+- static Bus sessionBus = null;
+- public static Bus Session
+- {
+- get {
+- if (sessionBus == null) {
+- try {
+- if (Address.StarterBusType == "session")
+- sessionBus = Starter;
+- else
+- sessionBus = Bus.Open (Address.Session);
+- } catch (Exception e) {
+- throw new Exception ("Unable to open the session message bus.", e);
+- }
+- }
+-
+- return sessionBus;
+- }
+- }
+-
+- //TODO: parsing of starter bus type, or maybe do this another way
+- static Bus starterBus = null;
+- public static Bus Starter
+- {
+- get {
+- if (starterBus == null) {
+- try {
+- starterBus = Bus.Open (Address.Starter);
+- } catch (Exception e) {
+- throw new Exception ("Unable to open the starter message bus.", e);
+- }
+- }
+-
+- return starterBus;
+- }
+- }
+-
+- //public static readonly Bus Session = null;
+-
+- //TODO: use the guid, not the whole address string
+- //TODO: consider what happens when a connection has been closed
+- static Dictionary<string,Bus> buses = new Dictionary<string,Bus> ();
+-
+- //public static Connection Open (string address)
+- public static new Bus Open (string address)
+- {
+- if (address == null)
+- throw new ArgumentNullException ("address");
+-
+- Bus bus;
+- if (buses.TryGetValue (address, out bus))
+- return bus;
+-
+- bus = new Bus (address);
+- buses[address] = bus;
+-
+- return bus;
+- }
+-
+- IBus bus;
+-
+- static readonly string DBusName = "org.freedesktop.DBus";
+- static readonly ObjectPath DBusPath = new ObjectPath ("/org/freedesktop/DBus");
+-
+- public Bus (string address) : base (address)
+- {
+- bus = GetObject<IBus> (DBusName, DBusPath);
+-
+- /*
+- bus.NameAcquired += delegate (string acquired_name) {
+- Console.WriteLine ("NameAcquired: " + acquired_name);
+- };
+- */
+- Register ();
+- }
+-
+- //should this be public?
+- //as long as Bus subclasses Connection, having a Register with a completely different meaning is bad
+- void Register ()
+- {
+- if (unique_name != null)
+- throw new Exception ("Bus already has a unique name");
+-
+- unique_name = bus.Hello ();
+- }
+-
+- public ulong GetUnixUser (string name)
+- {
+- return bus.GetConnectionUnixUser (name);
+- }
+-
+- public RequestNameReply RequestName (string name)
+- {
+- return RequestName (name, NameFlag.None);
+- }
+-
+- public RequestNameReply RequestName (string name, NameFlag flags)
+- {
+- return bus.RequestName (name, flags);
+- }
+-
+- public ReleaseNameReply ReleaseName (string name)
+- {
+- return bus.ReleaseName (name);
+- }
+-
+- public bool NameHasOwner (string name)
+- {
+- return bus.NameHasOwner (name);
+- }
+-
+- public StartReply StartServiceByName (string name)
+- {
+- return StartServiceByName (name, 0);
+- }
+-
+- public StartReply StartServiceByName (string name, uint flags)
+- {
+- return bus.StartServiceByName (name, flags);
+- }
+-
+- internal protected override void AddMatch (string rule)
+- {
+- bus.AddMatch (rule);
+- }
+-
+- internal protected override void RemoveMatch (string rule)
+- {
+- bus.RemoveMatch (rule);
+- }
+-
+- public string GetId ()
+- {
+- return bus.GetId ();
+- }
+-
+- string unique_name = null;
+- public string UniqueName
+- {
+- get {
+- return unique_name;
+- } set {
+- if (unique_name != null)
+- throw new Exception ("Unique name can only be set once");
+- unique_name = value;
+- }
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/BusObject.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/BusObject.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,398 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Reflection;
+-using System.Reflection.Emit;
+-using System.Collections.Generic;
+-
+-namespace NDesk.DBus
+-{
+- class BusObject
+- {
+- protected Connection conn;
+- string bus_name;
+- ObjectPath object_path;
+-
+- //protected BusObject ()
+- public BusObject ()
+- {
+- }
+-
+- public BusObject (Connection conn, string bus_name, ObjectPath object_path)
+- {
+- this.conn = conn;
+- this.bus_name = bus_name;
+- this.object_path = object_path;
+- }
+-
+- public Connection Connection
+- {
+- get {
+- return conn;
+- }
+- }
+-
+- public string BusName
+- {
+- get {
+- return bus_name;
+- }
+- }
+-
+- public ObjectPath Path
+- {
+- get {
+- return object_path;
+- }
+- }
+-
+- public void ToggleSignal (string iface, string member, Delegate dlg, bool adding)
+- {
+- MatchRule rule = new MatchRule ();
+- rule.MessageType = MessageType.Signal;
+- rule.Fields.Add (FieldCode.Interface, new MatchTest (iface));
+- rule.Fields.Add (FieldCode.Member, new MatchTest (member));
+- rule.Fields.Add (FieldCode.Path, new MatchTest (object_path));
+-
+- if (adding) {
+- if (conn.Handlers.ContainsKey (rule))
+- conn.Handlers[rule] = Delegate.Combine (conn.Handlers[rule], dlg);
+- else {
+- conn.Handlers[rule] = dlg;
+- conn.AddMatch (rule.ToString ());
+- }
+- } else {
+- conn.Handlers[rule] = Delegate.Remove (conn.Handlers[rule], dlg);
+- if (conn.Handlers[rule] == null) {
+- conn.RemoveMatch (rule.ToString ());
+- conn.Handlers.Remove (rule);
+- }
+- }
+- }
+-
+- public void SendSignal (string iface, string member, string inSigStr, MessageWriter writer, Type retType, out Exception exception)
+- {
+- exception = null;
+-
+- //TODO: don't ignore retVal, exception etc.
+-
+- Signature outSig = String.IsNullOrEmpty (inSigStr) ? Signature.Empty : new Signature (inSigStr);
+-
+- Signal signal = new Signal (object_path, iface, member);
+- signal.message.Signature = outSig;
+-
+- Message signalMsg = signal.message;
+- signalMsg.Body = writer.ToArray ();
+-
+- conn.Send (signalMsg);
+- }
+-
+- public object SendMethodCallOld (string iface, string member, string inSigStr, MessageWriter writer, Type retType, out Exception exception)
+- {
+- exception = null;
+-
+- //TODO: don't ignore retVal, exception etc.
+-
+- Signature inSig = String.IsNullOrEmpty (inSigStr) ? Signature.Empty : new Signature (inSigStr);
+-
+- MethodCall method_call = new MethodCall (object_path, iface, member, bus_name, inSig);
+-
+- Message callMsg = method_call.message;
+- callMsg.Body = writer.ToArray ();
+-
+- //Invoke Code::
+-
+- //TODO: complete out parameter support
+- /*
+- Type[] outParmTypes = Mapper.GetTypes (ArgDirection.Out, mi.GetParameters ());
+- Signature outParmSig = Signature.GetSig (outParmTypes);
+-
+- if (outParmSig != Signature.Empty)
+- throw new Exception ("Out parameters not yet supported: out_signature='" + outParmSig.Value + "'");
+- */
+-
+- Type[] outTypes = new Type[1];
+- outTypes[0] = retType;
+-
+- //we default to always requiring replies for now, even though unnecessary
+- //this is to make sure errors are handled synchronously
+- //TODO: don't hard code this
+- bool needsReply = true;
+-
+- //if (mi.ReturnType == typeof (void))
+- // needsReply = false;
+-
+- callMsg.ReplyExpected = needsReply;
+- callMsg.Signature = inSig;
+-
+- if (!needsReply) {
+- conn.Send (callMsg);
+- return null;
+- }
+-
+-#if PROTO_REPLY_SIGNATURE
+- if (needsReply) {
+- Signature outSig = Signature.GetSig (outTypes);
+- callMsg.Header[FieldCode.ReplySignature] = outSig;
+- }
+-#endif
+-
+- Message retMsg = conn.SendWithReplyAndBlock (callMsg);
+-
+- object retVal = null;
+-
+- //handle the reply message
+- switch (retMsg.Header.MessageType) {
+- case MessageType.MethodReturn:
+- object[] retVals = MessageHelper.GetDynamicValues (retMsg, outTypes);
+- if (retVals.Length != 0)
+- retVal = retVals[retVals.Length - 1];
+- break;
+- case MessageType.Error:
+- //TODO: typed exceptions
+- Error error = new Error (retMsg);
+- string errMsg = String.Empty;
+- if (retMsg.Signature.Value.StartsWith ("s")) {
+- MessageReader reader = new MessageReader (retMsg);
+- errMsg = reader.ReadString ();
+- }
+- exception = new Exception (error.ErrorName + ": " + errMsg);
+- break;
+- default:
+- throw new Exception ("Got unexpected message of type " + retMsg.Header.MessageType + " while waiting for a MethodReturn or Error");
+- }
+-
+- return retVal;
+- }
+-
+- public MessageReader SendMethodCall (string iface, string member, string inSigStr, MessageWriter writer, Type retType, out Exception exception)
+- {
+- exception = null;
+-
+- //TODO: don't ignore retVal, exception etc.
+-
+- Signature inSig = String.IsNullOrEmpty (inSigStr) ? Signature.Empty : new Signature (inSigStr);
+-
+- MethodCall method_call = new MethodCall (object_path, iface, member, bus_name, inSig);
+-
+- Message callMsg = method_call.message;
+- callMsg.Body = writer.ToArray ();
+-
+- //Invoke Code::
+-
+- //TODO: complete out parameter support
+- /*
+- Type[] outParmTypes = Mapper.GetTypes (ArgDirection.Out, mi.GetParameters ());
+- Signature outParmSig = Signature.GetSig (outParmTypes);
+-
+- if (outParmSig != Signature.Empty)
+- throw new Exception ("Out parameters not yet supported: out_signature='" + outParmSig.Value + "'");
+- */
+-
+- Type[] outTypes = new Type[1];
+- outTypes[0] = retType;
+-
+- //we default to always requiring replies for now, even though unnecessary
+- //this is to make sure errors are handled synchronously
+- //TODO: don't hard code this
+- bool needsReply = true;
+-
+- //if (mi.ReturnType == typeof (void))
+- // needsReply = false;
+-
+- callMsg.ReplyExpected = needsReply;
+- callMsg.Signature = inSig;
+-
+- if (!needsReply) {
+- conn.Send (callMsg);
+- return null;
+- }
+-
+-#if PROTO_REPLY_SIGNATURE
+- if (needsReply) {
+- Signature outSig = Signature.GetSig (outTypes);
+- callMsg.Header[FieldCode.ReplySignature] = outSig;
+- }
+-#endif
+-
+- Message retMsg = conn.SendWithReplyAndBlock (callMsg);
+-
+- MessageReader retVal = null;
+-
+- //handle the reply message
+- switch (retMsg.Header.MessageType) {
+- case MessageType.MethodReturn:
+- retVal = new MessageReader (retMsg);
+- break;
+- case MessageType.Error:
+- //TODO: typed exceptions
+- Error error = new Error (retMsg);
+- string errMsg = String.Empty;
+- if (retMsg.Signature.Value.StartsWith ("s")) {
+- MessageReader reader = new MessageReader (retMsg);
+- errMsg = reader.ReadString ();
+- }
+- exception = new Exception (error.ErrorName + ": " + errMsg);
+- break;
+- default:
+- throw new Exception ("Got unexpected message of type " + retMsg.Header.MessageType + " while waiting for a MethodReturn or Error");
+- }
+-
+- return retVal;
+- }
+-
+- public void Invoke (MethodBase methodBase, string methodName, object[] inArgs, out object[] outArgs, out object retVal, out Exception exception)
+- {
+- outArgs = new object[0];
+- retVal = null;
+- exception = null;
+-
+- MethodInfo mi = methodBase as MethodInfo;
+-
+- if (mi != null && mi.IsSpecialName && (methodName.StartsWith ("add_") || methodName.StartsWith ("remove_"))) {
+- string[] parts = methodName.Split (new char[]{'_'}, 2);
+- string ename = parts[1];
+- Delegate dlg = (Delegate)inArgs[0];
+-
+- ToggleSignal (Mapper.GetInterfaceName (mi), ename, dlg, parts[0] == "add");
+-
+- return;
+- }
+-
+- Type[] inTypes = Mapper.GetTypes (ArgDirection.In, mi.GetParameters ());
+- Signature inSig = Signature.GetSig (inTypes);
+-
+- MethodCall method_call;
+- Message callMsg;
+-
+- //build the outbound method call message
+- {
+- //this bit is error-prone (no null checking) and will need rewriting when DProxy is replaced
+- string iface = null;
+- if (mi != null)
+- iface = Mapper.GetInterfaceName (mi);
+-
+- //map property accessors
+- //TODO: this needs to be done properly, not with simple String.Replace
+- //note that IsSpecialName is also for event accessors, but we already handled those and returned
+- if (mi != null && mi.IsSpecialName) {
+- methodName = methodName.Replace ("get_", "Get");
+- methodName = methodName.Replace ("set_", "Set");
+- }
+-
+- method_call = new MethodCall (object_path, iface, methodName, bus_name, inSig);
+-
+- callMsg = method_call.message;
+-
+- if (inArgs != null && inArgs.Length != 0) {
+- MessageWriter writer = new MessageWriter (Connection.NativeEndianness);
+- writer.connection = conn;
+-
+- for (int i = 0 ; i != inTypes.Length ; i++)
+- writer.Write (inTypes[i], inArgs[i]);
+-
+- callMsg.Body = writer.ToArray ();
+- }
+- }
+-
+- //TODO: complete out parameter support
+- /*
+- Type[] outParmTypes = Mapper.GetTypes (ArgDirection.Out, mi.GetParameters ());
+- Signature outParmSig = Signature.GetSig (outParmTypes);
+-
+- if (outParmSig != Signature.Empty)
+- throw new Exception ("Out parameters not yet supported: out_signature='" + outParmSig.Value + "'");
+- */
+-
+- Type[] outTypes = new Type[1];
+- outTypes[0] = mi.ReturnType;
+-
+- //we default to always requiring replies for now, even though unnecessary
+- //this is to make sure errors are handled synchronously
+- //TODO: don't hard code this
+- bool needsReply = true;
+-
+- //if (mi.ReturnType == typeof (void))
+- // needsReply = false;
+-
+- callMsg.ReplyExpected = needsReply;
+- callMsg.Signature = inSig;
+-
+- if (!needsReply) {
+- conn.Send (callMsg);
+- return;
+- }
+-
+-#if PROTO_REPLY_SIGNATURE
+- if (needsReply) {
+- Signature outSig = Signature.GetSig (outTypes);
+- callMsg.Header[FieldCode.ReplySignature] = outSig;
+- }
+-#endif
+-
+- Message retMsg = conn.SendWithReplyAndBlock (callMsg);
+-
+- //handle the reply message
+- switch (retMsg.Header.MessageType) {
+- case MessageType.MethodReturn:
+- object[] retVals = MessageHelper.GetDynamicValues (retMsg, outTypes);
+- if (retVals.Length != 0)
+- retVal = retVals[retVals.Length - 1];
+- break;
+- case MessageType.Error:
+- //TODO: typed exceptions
+- Error error = new Error (retMsg);
+- string errMsg = String.Empty;
+- if (retMsg.Signature.Value.StartsWith ("s")) {
+- MessageReader reader = new MessageReader (retMsg);
+- errMsg = reader.ReadString ();
+- }
+- exception = new Exception (error.ErrorName + ": " + errMsg);
+- break;
+- default:
+- throw new Exception ("Got unexpected message of type " + retMsg.Header.MessageType + " while waiting for a MethodReturn or Error");
+- }
+-
+- return;
+- }
+-
+- public static object GetObject (Connection conn, string bus_name, ObjectPath object_path, Type declType)
+- {
+- Type proxyType = TypeImplementer.Root.GetImplementation (declType);
+-
+- //BusObject inst = (BusObject)Activator.CreateInstance (proxyType);
+- object instObj = Activator.CreateInstance (proxyType);
+- BusObject inst = GetBusObject (instObj);
+- inst.conn = conn;
+- inst.bus_name = bus_name;
+- inst.object_path = object_path;
+-
+- return instObj;
+- }
+-
+- static Dictionary<object,BusObject> boCache = new Dictionary<object,BusObject>();
+- public static BusObject GetBusObject (object instObj)
+- {
+- if (instObj is BusObject)
+- return (BusObject)instObj;
+-
+- BusObject inst;
+- if (boCache.TryGetValue (instObj, out inst))
+- return inst;
+-
+- inst = new BusObject ();
+- boCache[instObj] = inst;
+-
+- return inst;
+- }
+-
+- public Delegate GetHookupDelegate (EventInfo ei)
+- {
+- DynamicMethod hookupMethod = TypeImplementer.GetHookupMethod (ei);
+- Delegate d = hookupMethod.CreateDelegate (ei.EventHandlerType, this);
+- return d;
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Connection.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Connection.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,592 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Collections.Generic;
+-using System.IO;
+-using System.Threading;
+-using System.Reflection;
+-
+-namespace NDesk.DBus
+-{
+- using Authentication;
+- using Transports;
+-
+- public partial class Connection
+- {
+- Transport transport;
+- internal Transport Transport {
+- get {
+- return transport;
+- } set {
+- transport = value;
+- transport.Connection = this;
+- }
+- }
+-
+- protected Connection () {}
+-
+- internal Connection (Transport transport)
+- {
+- this.transport = transport;
+- transport.Connection = this;
+- }
+-
+- //should this be public?
+- internal Connection (string address)
+- {
+- OpenPrivate (address);
+- Authenticate ();
+- }
+-
+- internal bool isConnected = false;
+- public bool IsConnected
+- {
+- get {
+- return isConnected;
+- }
+- }
+-
+- // TODO: Complete disconnection support
+- internal bool isShared = false;
+- public void Close ()
+- {
+- if (isShared)
+- throw new Exception ("Cannot disconnect a shared Connection");
+-
+- if (!IsConnected)
+- return;
+-
+- transport.Disconnect ();
+- isConnected = false;
+- }
+-
+- //should we do connection sharing here?
+- public static Connection Open (string address)
+- {
+- Connection conn = new Connection ();
+- conn.OpenPrivate (address);
+- conn.Authenticate ();
+-
+- return conn;
+- }
+-
+- internal void OpenPrivate (string address)
+- {
+- if (address == null)
+- throw new ArgumentNullException ("address");
+-
+- AddressEntry[] entries = Address.Parse (address);
+- if (entries.Length == 0)
+- throw new Exception ("No addresses were found");
+-
+- //TODO: try alternative addresses if needed
+- AddressEntry entry = entries[0];
+-
+- Id = entry.GUID;
+- Transport = Transport.Create (entry);
+- isConnected = true;
+- }
+-
+- internal UUID Id = UUID.Zero;
+-
+- void Authenticate ()
+- {
+- if (transport != null)
+- transport.WriteCred ();
+-
+- SaslClient auth = new SaslClient ();
+- auth.Identity = transport.AuthString ();
+- auth.stream = transport.Stream;
+- auth.Peer = new SaslPeer ();
+- auth.Peer.Peer = auth;
+- auth.Peer.stream = transport.Stream;
+-
+- if (!auth.Authenticate ())
+- throw new Exception ("Authentication failure");
+-
+- if (Id != UUID.Zero)
+- if (auth.ActualId != Id)
+- throw new Exception ("Authentication failure: Unexpected GUID");
+-
+- if (Id == UUID.Zero)
+- Id = auth.ActualId;
+-
+- isAuthenticated = true;
+-
+- //(((SocketTransport)Transport).socket).Blocking = false;
+- }
+-
+- internal bool isAuthenticated = false;
+- internal bool IsAuthenticated
+- {
+- get {
+- return isAuthenticated;
+- }
+- }
+-
+- //Interlocked.Increment() handles the overflow condition for uint correctly, so it's ok to store the value as an int but cast it to uint
+- int serial = 0;
+- internal uint GenerateSerial ()
+- {
+- //return ++serial;
+- return (uint)Interlocked.Increment (ref serial);
+- }
+-
+- internal Message SendWithReplyAndBlock (Message msg)
+- {
+- PendingCall pending = SendWithReply (msg);
+- return pending.Reply;
+- }
+-
+- internal PendingCall SendWithReply (Message msg)
+- {
+- msg.ReplyExpected = true;
+-
+- if (msg.Header.Serial == 0)
+- msg.Header.Serial = GenerateSerial ();
+-
+- // Should we throttle the maximum number of concurrent PendingCalls?
+- // Should we support timeouts?
+- PendingCall pending = new PendingCall (this);
+- pendingCalls[msg.Header.Serial] = pending;
+-
+- Send (msg);
+- //WriteMessage (msg);
+-
+- return pending;
+- }
+-
+- internal virtual uint Send (Message msg)
+- {
+- if (msg.Header.Serial == 0)
+- msg.Header.Serial = GenerateSerial ();
+-
+- transport.WriteMessage (msg);
+-
+- //Outbound.Enqueue (msg);
+- //temporary
+- //Flush ();
+-
+- return msg.Header.Serial;
+- }
+-
+- Queue<Message> Inbound = new Queue<Message> ();
+- /*
+- Queue<Message> Outbound = new Queue<Message> ();
+-
+- public void Flush ()
+- {
+- //should just iterate the enumerator here
+- while (Outbound.Count != 0) {
+- Message msg = Outbound.Dequeue ();
+- WriteMessage (msg);
+- }
+- }
+-
+- public bool ReadWrite (int timeout_milliseconds)
+- {
+- //TODO
+-
+- return true;
+- }
+-
+- public bool ReadWrite ()
+- {
+- return ReadWrite (-1);
+- }
+-
+- public bool Dispatch ()
+- {
+- //TODO
+- Message msg = Inbound.Dequeue ();
+- //HandleMessage (msg);
+-
+- return true;
+- }
+-
+- public bool ReadWriteDispatch (int timeout_milliseconds)
+- {
+- //TODO
+- return Dispatch ();
+- }
+-
+- public bool ReadWriteDispatch ()
+- {
+- return ReadWriteDispatch (-1);
+- }
+- */
+-
+- //temporary hack
+- internal void DispatchSignals ()
+- {
+- lock (Inbound) {
+- while (Inbound.Count != 0) {
+- Message msg = Inbound.Dequeue ();
+- HandleSignal (msg);
+- }
+- }
+- }
+-
+- internal Thread mainThread = Thread.CurrentThread;
+-
+- //temporary hack
+- public void Iterate ()
+- {
+- mainThread = Thread.CurrentThread;
+-
+- //Message msg = Inbound.Dequeue ();
+- Message msg = transport.ReadMessage ();
+- //if (msg != null)
+- HandleMessage (msg);
+- DispatchSignals ();
+- }
+-
+- internal void Dispatch ()
+- {
+- while (transport.Inbound.Count != 0) {
+- Message msg = transport.Inbound.Dequeue ();
+- HandleMessage (msg);
+- }
+- DispatchSignals ();
+- }
+-
+- internal virtual void HandleMessage (Message msg)
+- {
+- if (msg == null)
+- return;
+-
+- //TODO: support disconnection situations properly and move this check elsewhere
+- if (msg == null)
+- throw new ArgumentNullException ("msg", "Cannot handle a null message; maybe the bus was disconnected");
+-
+- //TODO: Restrict messages to Local ObjectPath?
+-
+- {
+- object field_value = msg.Header[FieldCode.ReplySerial];
+- if (field_value != null) {
+- uint reply_serial = (uint)field_value;
+- PendingCall pending;
+-
+- if (pendingCalls.TryGetValue (reply_serial, out pending)) {
+- if (pendingCalls.Remove (reply_serial))
+- pending.Reply = msg;
+-
+- return;
+- }
+-
+- //we discard reply messages with no corresponding PendingCall
+- if (Protocol.Verbose)
+- Console.Error.WriteLine ("Unexpected reply message received: MessageType='" + msg.Header.MessageType + "', ReplySerial=" + reply_serial);
+-
+- return;
+- }
+- }
+-
+- switch (msg.Header.MessageType) {
+- case MessageType.MethodCall:
+- MethodCall method_call = new MethodCall (msg);
+- HandleMethodCall (method_call);
+- break;
+- case MessageType.Signal:
+- //HandleSignal (msg);
+- lock (Inbound)
+- Inbound.Enqueue (msg);
+- break;
+- case MessageType.Error:
+- //TODO: better exception handling
+- Error error = new Error (msg);
+- string errMsg = String.Empty;
+- if (msg.Signature.Value.StartsWith ("s")) {
+- MessageReader reader = new MessageReader (msg);
+- errMsg = reader.ReadString ();
+- }
+- //throw new Exception ("Remote Error: Signature='" + msg.Signature.Value + "' " + error.ErrorName + ": " + errMsg);
+- //if (Protocol.Verbose)
+- Console.Error.WriteLine ("Remote Error: Signature='" + msg.Signature.Value + "' " + error.ErrorName + ": " + errMsg);
+- break;
+- case MessageType.Invalid:
+- default:
+- throw new Exception ("Invalid message received: MessageType='" + msg.Header.MessageType + "'");
+- }
+- }
+-
+- Dictionary<uint,PendingCall> pendingCalls = new Dictionary<uint,PendingCall> ();
+-
+- //this might need reworking with MulticastDelegate
+- internal void HandleSignal (Message msg)
+- {
+- Signal signal = new Signal (msg);
+-
+- //TODO: this is a hack, not necessary when MatchRule is complete
+- MatchRule rule = new MatchRule ();
+- rule.MessageType = MessageType.Signal;
+- rule.Fields.Add (FieldCode.Interface, new MatchTest (signal.Interface));
+- rule.Fields.Add (FieldCode.Member, new MatchTest (signal.Member));
+- rule.Fields.Add (FieldCode.Path, new MatchTest (signal.Path));
+-
+- Delegate dlg;
+- if (Handlers.TryGetValue (rule, out dlg)) {
+- MethodInfo mi = dlg.GetType ().GetMethod ("Invoke");
+-
+- bool compatible = false;
+- Signature inSig, outSig;
+-
+- if (TypeImplementer.SigsForMethod(mi, out inSig, out outSig))
+- if (outSig == Signature.Empty && inSig == msg.Signature)
+- compatible = true;
+-
+- if (!compatible) {
+- if (Protocol.Verbose)
+- Console.Error.WriteLine ("Signal argument mismatch: " + signal.Interface + '.' + signal.Member);
+- return;
+- }
+-
+- //signals have no return value
+- dlg.DynamicInvoke (MessageHelper.GetDynamicValues (msg, mi.GetParameters ()));
+- } else {
+- //TODO: how should we handle this condition? sending an Error may not be appropriate in this case
+- if (Protocol.Verbose)
+- Console.Error.WriteLine ("Warning: No signal handler for " + signal.Member);
+- }
+- }
+-
+- internal Dictionary<MatchRule,Delegate> Handlers = new Dictionary<MatchRule,Delegate> ();
+-
+- //very messy
+- internal void MaybeSendUnknownMethodError (MethodCall method_call)
+- {
+- Message msg = MessageHelper.CreateUnknownMethodError (method_call);
+- if (msg != null)
+- Send (msg);
+- }
+-
+- //not particularly efficient and needs to be generalized
+- internal void HandleMethodCall (MethodCall method_call)
+- {
+- //TODO: Ping and Introspect need to be abstracted and moved somewhere more appropriate once message filter infrastructure is complete
+-
+- //FIXME: these special cases are slightly broken for the case where the member but not the interface is specified in the message
+- if (method_call.Interface == "org.freedesktop.DBus.Peer") {
+- switch (method_call.Member) {
+- case "Ping":
+- Send (MessageHelper.ConstructReply (method_call));
+- return;
+- case "GetMachineId":
+- if (MachineId != UUID.Zero) {
+- Send (MessageHelper.ConstructReply (method_call, MachineId.ToString ()));
+- return;
+- } else {
+- // Might want to send back an error here?
+- }
+- break;
+- }
+- }
+-
+- if (method_call.Interface == "org.freedesktop.DBus.Introspectable" && method_call.Member == "Introspect") {
+- Introspector intro = new Introspector ();
+- intro.root_path = method_call.Path;
+- intro.WriteStart ();
+-
+- //FIXME: do this properly
+- //this is messy and inefficient
+- List<string> linkNodes = new List<string> ();
+- int depth = method_call.Path.Decomposed.Length;
+- foreach (ObjectPath pth in RegisteredObjects.Keys) {
+- if (pth.Value == (method_call.Path.Value)) {
+- ExportObject exo = (ExportObject)RegisteredObjects[pth];
+- exo.WriteIntrospect (intro);
+- } else {
+- for (ObjectPath cur = pth ; cur != null ; cur = cur.Parent) {
+- if (cur.Value == method_call.Path.Value) {
+- string linkNode = pth.Decomposed[depth];
+- if (!linkNodes.Contains (linkNode)) {
+- intro.WriteNode (linkNode);
+- linkNodes.Add (linkNode);
+- }
+- }
+- }
+- }
+- }
+-
+- intro.WriteEnd ();
+-
+- Message reply = MessageHelper.ConstructReply (method_call, intro.xml);
+- Send (reply);
+- return;
+- }
+-
+- BusObject bo;
+- if (RegisteredObjects.TryGetValue (method_call.Path, out bo)) {
+- ExportObject eo = (ExportObject)bo;
+- eo.HandleMethodCall (method_call);
+- } else {
+- MaybeSendUnknownMethodError (method_call);
+- }
+- }
+-
+- Dictionary<ObjectPath,BusObject> RegisteredObjects = new Dictionary<ObjectPath,BusObject> ();
+-
+- //FIXME: this shouldn't be part of the core API
+- //that also applies to much of the other object mapping code
+-
+- public object GetObject (Type type, string bus_name, ObjectPath path)
+- {
+- //if (type == null)
+- // return GetObject (bus_name, path);
+-
+- //if the requested type is an interface, we can implement it efficiently
+- //otherwise we fall back to using a transparent proxy
+- if (type.IsInterface || type.IsAbstract) {
+- return BusObject.GetObject (this, bus_name, path, type);
+- } else {
+- if (Protocol.Verbose)
+- Console.Error.WriteLine ("Warning: Note that MarshalByRefObject use is not recommended; for best performance, define interfaces");
+-
+- BusObject busObject = new BusObject (this, bus_name, path);
+- DProxy prox = new DProxy (busObject, type);
+- return prox.GetTransparentProxy ();
+- }
+- }
+-
+- public T GetObject<T> (string bus_name, ObjectPath path)
+- {
+- return (T)GetObject (typeof (T), bus_name, path);
+- }
+-
+- [Obsolete ("Use the overload of Register() which does not take a bus_name parameter")]
+- public void Register (string bus_name, ObjectPath path, object obj)
+- {
+- Register (path, obj);
+- }
+-
+- [Obsolete ("Use the overload of Unregister() which does not take a bus_name parameter")]
+- public object Unregister (string bus_name, ObjectPath path)
+- {
+- return Unregister (path);
+- }
+-
+- public void Register (ObjectPath path, object obj)
+- {
+- ExportObject eo = ExportObject.CreateExportObject (this, path, obj);
+- eo.Registered = true;
+-
+- //TODO: implement some kind of tree data structure or internal object hierarchy. right now we are ignoring the name and putting all object paths in one namespace, which is bad
+- RegisteredObjects[path] = eo;
+- }
+-
+- public object Unregister (ObjectPath path)
+- {
+- BusObject bo;
+-
+- if (!RegisteredObjects.TryGetValue (path, out bo))
+- throw new Exception ("Cannot unregister " + path + " as it isn't registered");
+-
+- RegisteredObjects.Remove (path);
+-
+- ExportObject eo = (ExportObject)bo;
+- eo.Registered = false;
+-
+- return eo.obj;
+- }
+-
+- //these look out of place, but are useful
+- internal protected virtual void AddMatch (string rule)
+- {
+- }
+-
+- internal protected virtual void RemoveMatch (string rule)
+- {
+- }
+-
+- // Maybe we should use XDG/basedir or check an env var for this?
+- const string machineUuidFilename = @"/var/lib/dbus/machine-id";
+- static UUID? machineId = null;
+- private static object idReadLock = new object ();
+- internal static UUID MachineId
+- {
+- get {
+- lock (idReadLock) {
+- if (machineId != null)
+- return (UUID)machineId;
+- try {
+- machineId = ReadMachineId (machineUuidFilename);
+- } catch {
+- machineId = UUID.Zero;
+- }
+- return (UUID)machineId;
+- }
+- }
+- }
+-
+- static UUID ReadMachineId (string fname)
+- {
+- using (FileStream fs = File.OpenRead (fname)) {
+- // Length is typically 33 (32 for the UUID, plus a linefeed)
+- //if (fs.Length < 32)
+- // return UUID.Zero;
+-
+- byte[] data = new byte[32];
+-
+- int pos = 0;
+- while (pos < data.Length) {
+- int read = fs.Read (data, pos, data.Length - pos);
+- if (read == 0)
+- break;
+- pos += read;
+- }
+-
+- if (pos != data.Length)
+- //return UUID.Zero;
+- throw new Exception ("Insufficient data while reading GUID string");
+-
+- return UUID.Parse (System.Text.Encoding.ASCII.GetString (data));
+- }
+- }
+-
+-
+- /*
+- [DllImport ("advapi32.dll", SetLastError = true)]
+- static extern bool GetCurrentHwProfile (IntPtr fProfile);
+-
+- [StructLayout (LayoutKind.Sequential)]
+- private class HWProfile
+- {
+- public Int32 dwDockInfo;
+- [MarshalAs (UnmanagedType.ByValTStr, SizeConst = 39)]
+- public string szHwProfileGuid;
+- [MarshalAs (UnmanagedType.ByValTStr, SizeConst = 80)]
+- public string szHwProfileName;
+- }
+-
+- static UUID ReadMachineIdWin32 ()
+- {
+- // Completely untested
+- string lText = null;
+-
+- IntPtr lHWInfoPtr = Marshal.AllocHGlobal (123);
+- HWProfile lProfile = new HWProfile ();
+- Marshal.StructureToPtr (lProfile, lHWInfoPtr, false);
+- if (GetCurrentHwProfile (lHWInfoPtr)) {
+- Marshal.PtrToStructure (lHWInfoPtr, lProfile);
+- lText = lProfile.szHwProfileGuid.ToString ();
+- }
+- Marshal.FreeHGlobal (lHWInfoPtr);
+-
+- string uuidString = lText.Replace ("-", String.Empty).Substring (1, 32);
+- return UUID.Parse (uuidString);
+- }
+- */
+-
+- static Connection ()
+- {
+- if (BitConverter.IsLittleEndian)
+- NativeEndianness = EndianFlag.Little;
+- else
+- NativeEndianness = EndianFlag.Big;
+- }
+-
+- internal static readonly EndianFlag NativeEndianness;
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/DBus.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/DBus.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,98 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Collections.Generic;
+-using NDesk.DBus;
+-
+-namespace org.freedesktop.DBus
+-{
+- [Flags]
+- public enum NameFlag : uint
+- {
+- None = 0,
+- AllowReplacement = 0x1,
+- ReplaceExisting = 0x2,
+- DoNotQueue = 0x4,
+- }
+-
+- public enum RequestNameReply : uint
+- {
+- PrimaryOwner = 1,
+- InQueue,
+- Exists,
+- AlreadyOwner,
+- }
+-
+- public enum ReleaseNameReply : uint
+- {
+- Released = 1,
+- NonExistent,
+- NotOwner,
+- }
+-
+- public enum StartReply : uint
+- {
+- //The service was successfully started.
+- Success = 1,
+- //A connection already owns the given name.
+- AlreadyRunning,
+- }
+-
+- public delegate void NameOwnerChangedHandler (string name, string old_owner, string new_owner);
+- public delegate void NameAcquiredHandler (string name);
+- public delegate void NameLostHandler (string name);
+-
+- [Interface ("org.freedesktop.DBus.Peer")]
+- public interface Peer
+- {
+- void Ping ();
+- [return: Argument ("machine_uuid")]
+- string GetMachineId ();
+- }
+-
+- [Interface ("org.freedesktop.DBus.Introspectable")]
+- public interface Introspectable
+- {
+- [return: Argument ("data")]
+- string Introspect ();
+- }
+-
+- [Interface ("org.freedesktop.DBus.Properties")]
+- public interface Properties
+- {
+- [return: Argument ("value")]
+- object Get (string @interface, string propname);
+- void Set (string @interface, string propname, object value);
+- [return: Argument ("props")]
+- IDictionary<string,object> GetAll (string @interface);
+- }
+-
+- [Interface ("org.freedesktop.DBus")]
+- public interface IBus
+- {
+- RequestNameReply RequestName (string name, NameFlag flags);
+- ReleaseNameReply ReleaseName (string name);
+- string Hello ();
+- string[] ListNames ();
+- string[] ListActivatableNames ();
+- bool NameHasOwner (string name);
+- event NameOwnerChangedHandler NameOwnerChanged;
+- event NameLostHandler NameLost;
+- event NameAcquiredHandler NameAcquired;
+- StartReply StartServiceByName (string name, uint flags);
+- void UpdateActivationEnvironment (IDictionary<string, string> environment);
+- string GetNameOwner (string name);
+- uint GetConnectionUnixUser (string connection_name);
+- void AddMatch (string rule);
+- void RemoveMatch (string rule);
+- string GetId ();
+-
+- //undocumented in spec
+- string[] ListQueuedOwners (string name);
+- uint GetConnectionUnixProcessID (string connection_name);
+- byte[] GetConnectionSELinuxSecurityContext (string connection_name);
+- void ReloadConfig ();
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/DProxy.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/DProxy.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,79 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Reflection;
+-using System.Runtime.Remoting.Proxies;
+-using System.Runtime.Remoting.Messaging;
+-
+-namespace NDesk.DBus
+-{
+- //marked internal because this is really an implementation detail and needs to be replaced
+- internal class DProxy : RealProxy
+- {
+- protected BusObject busObject;
+-
+- public DProxy (BusObject busObject, Type type) : base(type)
+- {
+- this.busObject = busObject;
+- }
+-
+- static MethodInfo mi_GetHashCode = typeof (object).GetMethod ("GetHashCode");
+- static MethodInfo mi_Equals = typeof (object).GetMethod ("Equals", BindingFlags.Instance);
+- static MethodInfo mi_ToString = typeof (object).GetMethod ("ToString");
+- static MethodInfo mi_GetLifetimeService = typeof (MarshalByRefObject).GetMethod ("GetLifetimeService");
+-
+- object GetDefaultReturn (MethodBase mi, object[] inArgs)
+- {
+- if (mi == mi_GetHashCode)
+- return busObject.Path.Value.GetHashCode ();
+- if (mi == mi_Equals)
+- return busObject.Path.Value == ((BusObject)((MarshalByRefObject)inArgs[0]).GetLifetimeService ()).Path.Value;
+- if (mi == mi_ToString)
+- return busObject.Path.Value;
+- if (mi == mi_GetLifetimeService)
+- return busObject;
+-
+- return null;
+- }
+-
+- public override IMessage Invoke (IMessage message)
+- {
+- IMethodCallMessage callMessage = (IMethodCallMessage) message;
+-
+- object defaultRetVal = GetDefaultReturn (callMessage.MethodBase, callMessage.InArgs);
+- if (defaultRetVal != null) {
+- MethodReturnMessageWrapper defaultReturnMessage = new MethodReturnMessageWrapper ((IMethodReturnMessage) message);
+- defaultReturnMessage.ReturnValue = defaultRetVal;
+-
+- return defaultReturnMessage;
+- }
+-
+- object[] outArgs;
+- object retVal;
+- Exception exception;
+- busObject.Invoke (callMessage.MethodBase, callMessage.MethodName, callMessage.InArgs, out outArgs, out retVal, out exception);
+-
+- MethodReturnMessageWrapper returnMessage = new MethodReturnMessageWrapper ((IMethodReturnMessage) message);
+- returnMessage.Exception = exception;
+- returnMessage.ReturnValue = retVal;
+-
+- return returnMessage;
+- }
+-
+- /*
+- public override ObjRef CreateObjRef (Type ServerType)
+- {
+- throw new System.NotImplementedException ();
+- }
+- */
+-
+- ~DProxy ()
+- {
+- //FIXME: remove handlers/match rules here
+- if (Protocol.Verbose)
+- Console.Error.WriteLine ("Warning: Finalization of " + busObject.Path + " not yet supported");
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/ExportObject.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/ExportObject.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,200 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Collections.Generic;
+-using System.Reflection;
+-using System.Reflection.Emit;
+-
+-using org.freedesktop.DBus;
+-
+-namespace NDesk.DBus
+-{
+- //TODO: perhaps ExportObject should not derive from BusObject
+- internal class ExportObject : BusObject, IDisposable //, Peer
+- {
+- public object obj;
+-
+- public ExportObject (Connection conn, ObjectPath object_path, object obj) : base (conn, null, object_path)
+- {
+- this.obj = obj;
+- }
+-
+- //maybe add checks to make sure this is not called more than once
+- //it's a bit silly as a property
+- bool isRegistered = false;
+- public virtual bool Registered
+- {
+- get {
+- return isRegistered;
+- }
+- set {
+- if (value == isRegistered)
+- return;
+-
+- Type type = obj.GetType ();
+-
+- foreach (MemberInfo mi in Mapper.GetPublicMembers (type)) {
+- EventInfo ei = mi as EventInfo;
+-
+- if (ei == null)
+- continue;
+-
+- Delegate dlg = GetHookupDelegate (ei);
+-
+- if (value)
+- ei.AddEventHandler (obj, dlg);
+- else
+- ei.RemoveEventHandler (obj, dlg);
+- }
+-
+- isRegistered = value;
+- }
+- }
+-
+- internal virtual void WriteIntrospect (Introspector intro)
+- {
+- intro.WriteType (obj.GetType ());
+- }
+-
+- internal static MethodCaller2 GetMCaller (MethodInfo mi)
+- {
+- MethodCaller2 mCaller;
+- if (!mCallers.TryGetValue (mi, out mCaller)) {
+- //mCaller = TypeImplementer.GenCaller (mi, obj);
+- mCaller = TypeImplementer.GenCaller2 (mi);
+- mCallers[mi] = mCaller;
+- }
+- return mCaller;
+- }
+-
+- public static ExportObject CreateExportObject (Connection conn, ObjectPath object_path, object obj)
+- {
+- Type type = obj.GetType ();
+-
+-#if DLR
+- if (type.Name == "RubyObject" || type.FullName == "IronPython.Runtime.Types.OldInstance")
+- return new DynamicExportObject (conn, object_path, obj);
+-#endif
+-
+- return new ExportObject (conn, object_path, obj);
+- }
+-
+- static internal readonly Dictionary<MethodInfo,MethodCaller2> mCallers = new Dictionary<MethodInfo,MethodCaller2> ();
+- public virtual void HandleMethodCall (MethodCall method_call)
+- {
+- Type type = obj.GetType ();
+-
+- //object retObj = type.InvokeMember (msg.Member, BindingFlags.InvokeMethod, null, obj, MessageHelper.GetDynamicValues (msg));
+-
+- //TODO: there is no member name mapping for properties etc. yet
+-
+- // FIXME: Inefficient to do this on every call
+- MethodInfo mi = Mapper.GetMethod (type, method_call);
+-
+- if (mi == null) {
+- conn.MaybeSendUnknownMethodError (method_call);
+- return;
+- }
+-
+- MethodCaller2 mCaller;
+- if (!mCallers.TryGetValue (mi, out mCaller)) {
+- //mCaller = TypeImplementer.GenCaller (mi, obj);
+- mCaller = TypeImplementer.GenCaller2 (mi);
+- mCallers[mi] = mCaller;
+- }
+-
+- Signature inSig, outSig;
+- TypeImplementer.SigsForMethod (mi, out inSig, out outSig);
+-
+- Message msg = method_call.message;
+- MessageReader msgReader = new MessageReader (method_call.message);
+- MessageWriter retWriter = new MessageWriter ();
+-
+- /*
+- MessageWriter retWriter = null;
+- if (msg.ReplyExpected)
+- retWriter = new MessageWriter ();
+- */
+-
+- Exception raisedException = null;
+- try {
+- //mCaller (msgReader, method_call.message, retWriter);
+- mCaller (obj, msgReader, method_call.message, retWriter);
+- } catch (Exception e) {
+- raisedException = e;
+- }
+-
+- if (!msg.ReplyExpected)
+- return;
+-
+- Message replyMsg;
+-
+- if (raisedException == null) {
+- MethodReturn method_return = new MethodReturn (msg.Header.Serial);
+- replyMsg = method_return.message;
+- replyMsg.Body = retWriter.ToArray ();
+- replyMsg.Signature = outSig;
+- } else {
+- Error error;
+- // BusException allows precisely formatted Error messages.
+- BusException busException = raisedException as BusException;
+- if (busException != null)
+- error = method_call.CreateError (busException.ErrorName, busException.ErrorMessage);
+- else if (raisedException is ArgumentException && raisedException.TargetSite.Name == mi.Name) {
+- // Name match trick above is a hack since we don't have the resolved MethodInfo.
+- ArgumentException argException = (ArgumentException)raisedException;
+- using (System.IO.StringReader sr = new System.IO.StringReader (argException.Message)) {
+- error = method_call.CreateError ("org.freedesktop.DBus.Error.InvalidArgs", sr.ReadLine ());
+- }
+- } else
+- error = method_call.CreateError (Mapper.GetInterfaceName (raisedException.GetType ()), raisedException.Message);
+-
+- replyMsg = error.message;
+- }
+-
+- if (method_call.Sender != null)
+- replyMsg.Header[FieldCode.Destination] = method_call.Sender;
+-
+- conn.Send (replyMsg);
+- }
+-
+- /*
+- public void Ping ()
+- {
+- }
+-
+- public string GetMachineId ()
+- {
+- //TODO: implement this
+- return String.Empty;
+- }
+- */
+-
+-#region IDisposable
+- public void Dispose ()
+- {
+- Dispose (true);
+- GC.SuppressFinalize (this);
+- }
+-
+- ~ExportObject ()
+- {
+- Dispose (false);
+- }
+-
+- protected virtual void Dispose (bool disposing)
+- {
+- if (disposing)
+- {
+- if (obj != null)
+- {
+- Registered = false;
+- obj = null;
+- }
+- }
+- }
+-#endregion
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/GLib.IO.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/GLib.IO.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,222 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Collections;
+-using System.Runtime.InteropServices;
+-
+-namespace NDesk.GLib
+-{
+- /*
+- Specifies the type of function which is called when a data element is destroyed. It is passed the pointer to the data element and should free any memory and resources allocated for it.
+-
+- @data: the data element.
+- */
+- delegate void DestroyNotify (IntPtr data);
+-
+- /*
+- Specifies the type of function passed to g_io_add_watch() or g_io_add_watch_full(), which is called when the requested condition on a GIOChannel is satisfied.
+-
+- @source: the GIOChannel event source.
+- @condition: the condition which has been satisfied.
+- @data: user data set in g_io_add_watch() or g_io_add_watch_full().
+-
+- Returns: the function should return FALSE if the event source should be removed.
+- */
+- delegate bool IOFunc (IntPtr source, IOCondition condition, IntPtr data);
+-
+- struct IOChannel
+- {
+- const string GLIB = "libglib-2.0-0.dll";
+-
+- public IntPtr Handle;
+-
+- [DllImport(GLIB)]
+- static extern IntPtr g_io_channel_unix_new (int fd);
+-
+- public IOChannel (int fd)
+- {
+- Handle = g_io_channel_unix_new (fd);
+- }
+-
+- [DllImport(GLIB)]
+- static extern int g_io_channel_unix_get_fd (IntPtr channel);
+-
+- public int UnixFd
+- {
+- get {
+- return g_io_channel_unix_get_fd (Handle);
+- }
+- }
+-
+- [DllImport(GLIB)]
+- public static extern IntPtr g_io_channel_win32_new_fd (int fd);
+-
+- [DllImport(GLIB)]
+- public static extern IntPtr g_io_channel_win32_new_socket (int socket);
+-
+- [DllImport(GLIB)]
+- public static extern IntPtr g_io_channel_win32_new_messages (uint hwnd);
+-
+-
+- [DllImport(GLIB)]
+- public static extern uint g_io_channel_get_buffer_size (IntPtr channel);
+-
+- [DllImport(GLIB)]
+- public static extern void g_io_channel_set_buffer_size (IntPtr channel, uint size);
+-
+- public uint BufferSize
+- {
+- get {
+- return g_io_channel_get_buffer_size (Handle);
+- } set {
+- g_io_channel_set_buffer_size (Handle, value);
+- }
+- }
+-
+- [DllImport(GLIB)]
+- public static extern IOCondition g_io_channel_get_buffer_condition (IntPtr channel);
+-
+- public IOCondition BufferCondition
+- {
+- get {
+- return g_io_channel_get_buffer_condition (Handle);
+- }
+- }
+-
+- [DllImport(GLIB)]
+- public static extern IOFlags g_io_channel_get_flags (IntPtr channel);
+-
+- [DllImport(GLIB)]
+- static extern short g_io_channel_set_flags (IntPtr channel, IOFlags flags, IntPtr error);
+-
+- public IOFlags Flags
+- {
+- get {
+- return g_io_channel_get_flags (Handle);
+- } set {
+- //TODO: fix return and error
+- g_io_channel_set_flags (Handle, value, IntPtr.Zero);
+- }
+- }
+- }
+-
+- class IO
+- {
+- const string GLIB = "libglib-2.0-0.dll";
+-
+- //TODO: better memory management
+- public static ArrayList objs = new ArrayList ();
+-
+- /*
+- Adds the GIOChannel into the main event loop with the default priority.
+-
+- @channel: a GIOChannel.
+- @condition: the condition to watch for.
+- @func: the function to call when the condition is satisfied.
+- @user_data: user data to pass to func.
+-
+- Returns: the event source id.
+- */
+- [DllImport(GLIB)]
+- protected static extern uint g_io_add_watch (IntPtr channel, IOCondition condition, IOFunc func, IntPtr user_data);
+-
+- public static uint AddWatch (IOChannel channel, IOCondition condition, IOFunc func)
+- {
+- objs.Add (func);
+-
+- return g_io_add_watch (channel.Handle, condition, func, IntPtr.Zero);
+- }
+-
+- /*
+- Adds the GIOChannel into the main event loop with the given priority.
+-
+- @channel: a GIOChannel.
+- @priority: the priority of the GIOChannel source.
+- @condition: the condition to watch for.
+- @func: the function to call when the condition is satisfied.
+- @user_data: user data to pass to func.
+- @notify: the function to call when the source is removed.
+-
+- Returns: the event source id.
+- */
+- [DllImport(GLIB)]
+- protected static extern uint g_io_add_watch_full (IntPtr channel, int priority, IOCondition condition, IOFunc func, IntPtr user_data, DestroyNotify notify);
+-
+- public static uint AddWatch (IOChannel channel, int priority, IOCondition condition, IOFunc func, DestroyNotify notify)
+- {
+- objs.Add (func);
+- objs.Add (notify);
+-
+- return g_io_add_watch_full (channel.Handle, priority, condition, func, IntPtr.Zero, notify);
+- }
+-
+- [DllImport(GLIB)]
+- protected static extern IntPtr g_main_context_default ();
+-
+- public static IntPtr MainContextDefault ()
+- {
+- return g_main_context_default ();
+- }
+-
+- [DllImport(GLIB)]
+- protected static extern void g_main_context_wakeup (IntPtr context);
+-
+- public static void MainContextWakeup (IntPtr context)
+- {
+- g_main_context_wakeup (context);
+- }
+- }
+-
+- //From Mono.Unix and poll(2)
+- [Flags]
+- enum PollEvents : short {
+- POLLIN = 0x0001, // There is data to read
+- POLLPRI = 0x0002, // There is urgent data to read
+- POLLOUT = 0x0004, // Writing now will not block
+- POLLERR = 0x0008, // Error condition
+- POLLHUP = 0x0010, // Hung up
+- POLLNVAL = 0x0020, // Invalid request; fd not open
+- // XPG4.2 definitions (via _XOPEN_SOURCE)
+- POLLRDNORM = 0x0040, // Normal data may be read
+- POLLRDBAND = 0x0080, // Priority data may be read
+- POLLWRNORM = 0x0100, // Writing now will not block
+- POLLWRBAND = 0x0200, // Priority data may be written
+- }
+-
+- //A bitwise combination representing a condition to watch for on an event source.
+- [Flags]
+- enum IOCondition : short
+- {
+- //There is data to read.
+- In = PollEvents.POLLIN,
+- //Data can be written (without blocking).
+- Out = PollEvents.POLLOUT,
+- //There is urgent data to read.
+- Pri = PollEvents.POLLPRI,
+- //Error condition.
+- Err = PollEvents.POLLERR,
+- //Hung up (the connection has been broken, usually for pipes and sockets).
+- Hup = PollEvents.POLLHUP,
+- //Invalid request. The file descriptor is not open.
+- Nval = PollEvents.POLLNVAL,
+- }
+-
+- [Flags]
+- enum IOFlags : short
+- {
+- Append = 1 << 0,
+- Nonblock = 1 << 1,
+- //Read only flag
+- IsReadable = 1 << 2,
+- //Read only flag
+- isWriteable = 1 << 3,
+- //Read only flag
+- IsSeekable = 1 << 4,
+- //?
+- Mask = (1 << 5) - 1,
+- GetMask = Mask,
+- SetMask = Append | Nonblock,
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/GLib.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/GLib.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,53 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using NDesk.DBus;
+-using NDesk.GLib;
+-using org.freedesktop.DBus;
+-
+-namespace NDesk.DBus
+-{
+- //FIXME: this API needs review and de-unixification. It is horrid, but gets the job done.
+- public static class BusG
+- {
+- static bool initialized = false;
+- public static void Init ()
+- {
+- if (initialized)
+- return;
+-
+- Init (Bus.System);
+- Init (Bus.Session);
+- //TODO: consider starter bus?
+-
+- initialized = true;
+- }
+-
+- public static void Init (Connection conn)
+- {
+- IOFunc dispatchHandler = delegate (IntPtr source, IOCondition condition, IntPtr data) {
+- if ((condition & IOCondition.Hup) == IOCondition.Hup) {
+- if (Protocol.Verbose)
+- Console.Error.WriteLine ("Warning: Connection was probably hung up (" + condition + ")");
+-
+- //TODO: handle disconnection properly, consider memory management
+- return false;
+- }
+-
+- //this may not provide expected behaviour all the time, but works for now
+- conn.Iterate ();
+- return true;
+- };
+-
+- Init (conn, dispatchHandler);
+- }
+-
+- static void Init (Connection conn, IOFunc dispatchHandler)
+- {
+- IOChannel channel = new IOChannel ((int)conn.Transport.SocketHandle);
+- IO.AddWatch (channel, IOCondition.In | IOCondition.Hup, dispatchHandler);
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Introspection.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Introspection.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,316 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Collections.Generic;
+-using System.IO;
+-using System.Xml;
+-using System.Text;
+-using System.Reflection;
+-
+-namespace NDesk.DBus
+-{
+- //TODO: complete this class
+- class Introspector
+- {
+- const string NAMESPACE = "http://www.freedesktop.org/standards/dbus";
+- const string PUBLIC_IDENTIFIER = "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN";
+- const string SYSTEM_IDENTIFIER = "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";
+-
+- public StringBuilder sb;
+- public string xml;
+- public ObjectPath root_path = ObjectPath.Root;
+- public bool ExtendedAnnotations = false;
+-
+- protected XmlWriter writer;
+-
+- public Introspector ()
+- {
+- XmlWriterSettings settings = new XmlWriterSettings ();
+- settings.Indent = true;
+- settings.IndentChars = (" ");
+- settings.OmitXmlDeclaration = true;
+-
+- sb = new StringBuilder ();
+-
+- writer = XmlWriter.Create (sb, settings);
+- }
+-
+- static string GetProductDescription ()
+- {
+- String version;
+-
+- Assembly assembly = Assembly.GetExecutingAssembly ();
+- AssemblyName aname = assembly.GetName ();
+-
+- AssemblyInformationalVersionAttribute iversion = Attribute.GetCustomAttribute (assembly, typeof (AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;
+-
+- if (iversion != null)
+- version = iversion.InformationalVersion;
+- else
+- version = aname.Version.ToString ();
+-
+- return aname.Name + " " + version;
+- }
+-
+- public void WriteStart ()
+- {
+- writer.WriteDocType ("node", PUBLIC_IDENTIFIER, SYSTEM_IDENTIFIER, null);
+-
+- writer.WriteComment (" " + GetProductDescription () + " ");
+-
+- //the root node element
+- writer.WriteStartElement ("node");
+- }
+-
+- public void WriteNode (string name)
+- {
+- writer.WriteStartElement ("node");
+- writer.WriteAttributeString ("name", name);
+- writer.WriteEndElement ();
+- }
+-
+- public void WriteEnd ()
+- {
+- /*
+- WriteEnum (typeof (org.freedesktop.DBus.NameFlag));
+- WriteEnum (typeof (org.freedesktop.DBus.NameReply));
+- WriteEnum (typeof (org.freedesktop.DBus.ReleaseNameReply));
+- WriteEnum (typeof (org.freedesktop.DBus.StartReply));
+- WriteInterface (typeof (org.freedesktop.DBus.IBus));
+- */
+-
+- writer.WriteEndElement ();
+-
+- writer.Flush ();
+- xml = sb.ToString ();
+- }
+-
+- //public void WriteNode ()
+- public void WriteType (Type target_type)
+- {
+- //writer.WriteStartElement ("node");
+-
+- //TODO: non-well-known introspection has paths as well, which we don't do yet. read the spec again
+- //hackishly just remove the root '/' to make the path relative for now
+- //writer.WriteAttributeString ("name", target_path.Value.Substring (1));
+- //writer.WriteAttributeString ("name", "test");
+-
+- //reflect our own interface manually
+- WriteInterface (typeof (org.freedesktop.DBus.Introspectable));
+-
+- //reflect the target interface
+- if (target_type != null) {
+- WriteInterface (target_type);
+-
+- foreach (Type ifType in target_type.GetInterfaces ())
+- WriteInterface (ifType);
+- }
+-
+- //TODO: review recursion of interfaces and inheritance hierarchy
+-
+- //writer.WriteEndElement ();
+- }
+-
+- public void WriteArg (ParameterInfo pi)
+- {
+- WriteArg (pi.ParameterType, Mapper.GetArgumentName (pi), pi.IsOut, false);
+- }
+-
+- public void WriteArgReverse (ParameterInfo pi)
+- {
+- WriteArg (pi.ParameterType, Mapper.GetArgumentName (pi), pi.IsOut, true);
+- }
+-
+- //TODO: clean up and get rid of reverse (or argIsOut) parm
+- public void WriteArg (Type argType, string argName, bool argIsOut, bool reverse)
+- {
+- argType = argIsOut ? argType.GetElementType () : argType;
+- if (argType == typeof (void))
+- return;
+-
+- writer.WriteStartElement ("arg");
+-
+- if (!String.IsNullOrEmpty (argName))
+- writer.WriteAttributeString ("name", argName);
+-
+- //we can't rely on the default direction (qt-dbus requires a direction at time of writing), so we use a boolean to reverse the parameter direction and make it explicit
+-
+- if (argIsOut)
+- writer.WriteAttributeString ("direction", !reverse ? "out" : "in");
+- else
+- writer.WriteAttributeString ("direction", !reverse ? "in" : "out");
+-
+- Signature sig = Signature.GetSig (argType);
+-
+- //TODO: avoid writing null (DType.Invalid) to the XML stream
+- writer.WriteAttributeString ("type", sig.Value);
+-
+- //annotations aren't valid in an arg element, so this is disabled
+- //if (argType.IsEnum)
+- // WriteAnnotation ("org.ndesk.DBus.Enum", Mapper.GetInterfaceName (argType));
+-
+- writer.WriteEndElement ();
+- }
+-
+- public void WriteMethod (MethodInfo mi)
+- {
+- writer.WriteStartElement ("method");
+- writer.WriteAttributeString ("name", mi.Name);
+-
+- foreach (ParameterInfo pi in mi.GetParameters ())
+- WriteArg (pi);
+-
+- //Mono <= 1.1.13 doesn't support MethodInfo.ReturnParameter, so avoid it
+- //WriteArgReverse (mi.ReturnParameter);
+- WriteArg (mi.ReturnType, Mapper.GetArgumentName (mi.ReturnTypeCustomAttributes, "ret"), false, true);
+-
+- WriteAnnotations (mi);
+-
+- writer.WriteEndElement ();
+- }
+-
+- public void WriteProperty (PropertyInfo pri)
+- {
+- //expose properties as dbus properties
+- writer.WriteStartElement ("property");
+- writer.WriteAttributeString ("name", pri.Name);
+- writer.WriteAttributeString ("type", Signature.GetSig (pri.PropertyType).Value);
+- string access = (pri.CanRead ? "read" : String.Empty) + (pri.CanWrite ? "write" : String.Empty);
+- writer.WriteAttributeString ("access", access);
+- WriteAnnotations (pri);
+- writer.WriteEndElement ();
+-
+- //expose properties as methods also
+- //it may not be worth doing this in the long run
+- /*
+- if (pri.CanRead) {
+- writer.WriteStartElement ("method");
+- writer.WriteAttributeString ("name", "Get" + pri.Name);
+- WriteArgReverse (pri.GetGetMethod ().ReturnParameter);
+- writer.WriteEndElement ();
+- }
+-
+- if (pri.CanWrite) {
+- writer.WriteStartElement ("method");
+- writer.WriteAttributeString ("name", "Set" + pri.Name);
+- foreach (ParameterInfo pi in pri.GetSetMethod ().GetParameters ())
+- WriteArg (pi);
+- writer.WriteEndElement ();
+- }
+- */
+- }
+-
+- public void WriteSignal (EventInfo ei)
+- {
+- writer.WriteStartElement ("signal");
+- writer.WriteAttributeString ("name", ei.Name);
+-
+- foreach (ParameterInfo pi in ei.EventHandlerType.GetMethod ("Invoke").GetParameters ())
+- WriteArgReverse (pi);
+-
+- if (ExtendedAnnotations) {
+- string handlerName = Mapper.GetInterfaceName (ei.EventHandlerType);
+- WriteAnnotation ("org.ndesk.DBus.SignalHandler", handlerName);
+- }
+-
+- WriteAnnotations (ei);
+-
+- //no need to consider the delegate return value as dbus doesn't support it
+- writer.WriteEndElement ();
+- }
+-
+- const BindingFlags relevantBindingFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly;
+-
+- public void WriteInterface (Type type)
+- {
+- if (type == null)
+- return;
+-
+- //TODO: this is unreliable, fix it
+- if (!Mapper.IsPublic (type))
+- return;
+-
+- writer.WriteStartElement ("interface");
+-
+- writer.WriteAttributeString ("name", Mapper.GetInterfaceName (type));
+-
+- /*
+- foreach (MemberInfo mbi in type.GetMembers (relevantBindingFlags)) {
+- switch (mbi.MemberType) {
+- case MemberTypes.Method:
+- if (!((MethodInfo)mbi).IsSpecialName)
+- WriteMethod ((MethodInfo)mbi);
+- break;
+- case MemberTypes.Event:
+- WriteSignal ((EventInfo)mbi);
+- break;
+- case MemberTypes.Property:
+- WriteProperty ((PropertyInfo)mbi);
+- break;
+- default:
+- Console.Error.WriteLine ("Warning: Unhandled MemberType '{0}' encountered while introspecting {1}", mbi.MemberType, type.FullName);
+- break;
+- }
+- }
+- */
+-
+- foreach (MethodInfo mi in type.GetMethods (relevantBindingFlags))
+- if (!mi.IsSpecialName)
+- WriteMethod (mi);
+-
+- foreach (EventInfo ei in type.GetEvents (relevantBindingFlags))
+- WriteSignal (ei);
+-
+- foreach (PropertyInfo pri in type.GetProperties (relevantBindingFlags))
+- WriteProperty (pri);
+-
+- //TODO: indexers
+-
+- //TODO: attributes as annotations?
+-
+- writer.WriteEndElement ();
+-
+- //this recursion seems somewhat inelegant
+- WriteInterface (type.BaseType);
+- }
+-
+- public void WriteAnnotations (ICustomAttributeProvider attrProvider)
+- {
+- if (Mapper.IsDeprecated (attrProvider))
+- WriteAnnotation ("org.freedesktop.DBus.Deprecated", "true");
+- }
+-
+- public void WriteAnnotation (string name, string value)
+- {
+- writer.WriteStartElement ("annotation");
+-
+- writer.WriteAttributeString ("name", name);
+- writer.WriteAttributeString ("value", value);
+-
+- writer.WriteEndElement ();
+- }
+-
+- //this is not in the spec, and is not finalized
+- public void WriteEnum (Type type)
+- {
+- writer.WriteStartElement ("enum");
+- writer.WriteAttributeString ("name", Mapper.GetInterfaceName (type));
+- writer.WriteAttributeString ("type", Signature.GetSig (type.GetElementType ()).Value);
+- writer.WriteAttributeString ("flags", (type.IsDefined (typeof (FlagsAttribute), false)) ? "true" : "false");
+-
+- string[] names = Enum.GetNames (type);
+-
+- int i = 0;
+- foreach (Enum val in Enum.GetValues (type)) {
+- writer.WriteStartElement ("element");
+- writer.WriteAttributeString ("name", names[i++]);
+- writer.WriteAttributeString ("value", val.ToString ("d"));
+- writer.WriteEndElement ();
+- }
+-
+- writer.WriteEndElement ();
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/IntrospectionSchema.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/IntrospectionSchema.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,118 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Xml.Serialization;
+-using System.Collections.Generic;
+-
+-namespace NDesk.DBus.Introspection
+-{
+- [XmlRootAttribute(IsNullable=true)]
+- public class Member {
+- [XmlAttributeAttribute("name")]
+- public string Name;
+- }
+-
+- [XmlRootAttribute("node", IsNullable=true)]
+- public class Node {
+-
+- [XmlAttributeAttribute("name")]
+- public string Name;
+-
+- [XmlElementAttribute("interface", Type=typeof(@Interface))]
+- public Interface[] Interfaces;
+- [XmlElementAttribute("node", Type=typeof(Node))]
+- public Node[] Nodes;
+- }
+-
+- [XmlRootAttribute("interface", IsNullable=true)]
+- public class @Interface {
+-
+- [XmlAttributeAttribute("name")]
+- public string Name;
+-
+- /*
+- [XmlElementAttribute("method", Type=typeof(Method))]
+- [XmlElementAttribute("signal", Type=typeof(Signal))]
+- [XmlElementAttribute("property", Type=typeof(Property))]
+- //[XmlElementAttribute("annotation", Type=typeof(Annotation))]
+- //public Member[] Members;
+- */
+-
+- [XmlElementAttribute("method", Type=typeof(Method))]
+- public Method[] Methods;
+-
+- [XmlElementAttribute("signal", Type=typeof(Signal))]
+- public Signal[] Signals;
+-
+- [XmlElementAttribute("property", Type=typeof(Property))]
+- public Property[] Properties;
+- }
+-
+- [XmlRootAttribute(IsNullable=true)]
+- public class Method : Member {
+-
+- /*
+- [XmlElementAttribute("arg", Type=typeof(Argument))]
+- [XmlElementAttribute("annotation", Type=typeof(Annotation))]
+- public object[] Items;
+- */
+-
+- //[System.ComponentModel.DefaultValue(new Argument[0])]
+- [XmlElementAttribute("arg", Type=typeof(Argument))]
+- //public List<Argument> Arguments;
+- public Argument[] Arguments;
+- }
+-
+- [XmlRootAttribute(IsNullable=true)]
+- public class Argument {
+-
+- [XmlAttributeAttribute("name")]
+- public string Name = String.Empty;
+-
+- [XmlAttributeAttribute("type")]
+- public string Type;
+-
+- [System.ComponentModel.DefaultValue(ArgDirection. at in)]
+- [XmlAttributeAttribute("direction")]
+- public ArgDirection Direction = ArgDirection. at in;
+- }
+-
+- public enum ArgDirection {
+- @in,
+- @out,
+- }
+-
+- [XmlRootAttribute(IsNullable=true)]
+- public class Annotation {
+-
+- [XmlAttributeAttribute("name")]
+- public string Name = String.Empty;
+-
+- [XmlAttributeAttribute("value")]
+- public string Value = String.Empty;
+- }
+-
+- [XmlRootAttribute("signal", IsNullable=true)]
+- public class Signal : Method {
+- }
+-
+- [XmlRootAttribute(IsNullable=true)]
+- public class Property : Member {
+- [XmlAttributeAttribute("type")]
+- public string Type = String.Empty;
+-
+- [XmlAttributeAttribute("access")]
+- public propertyAccess Access;
+-
+- [XmlElementAttribute("annotation")]
+- public Annotation[] Annotations;
+- }
+-
+- public enum propertyAccess {
+- read,
+- write,
+- readwrite,
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Mapper.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Mapper.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,387 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Collections.Generic;
+-using System.Reflection;
+-
+-namespace NDesk.DBus
+-{
+- static class Mapper
+- {
+- //TODO: move these Get*Name helpers somewhere more appropriate
+- public static string GetArgumentName (ParameterInfo pi)
+- {
+- string argName = pi.Name;
+-
+- if (pi.IsRetval && String.IsNullOrEmpty (argName))
+- argName = "ret";
+-
+- return GetArgumentName ((ICustomAttributeProvider)pi, argName);
+- }
+-
+- public static string GetArgumentName (ICustomAttributeProvider attrProvider, string defaultName)
+- {
+- string argName = defaultName;
+-
+- //TODO: no need for foreach
+- foreach (ArgumentAttribute aa in attrProvider.GetCustomAttributes (typeof (ArgumentAttribute), true))
+- argName = aa.Name;
+-
+- return argName;
+- }
+-
+- //TODO: these two methods are quite messy and need review
+- public static IEnumerable<MemberInfo> GetPublicMembers (Type type)
+- {
+- //note that Type.GetInterfaces() returns all interfaces with flattened hierarchy
+- foreach (Type ifType in type.GetInterfaces ())
+- foreach (MemberInfo mi in GetDeclaredPublicMembers (ifType))
+- yield return mi;
+-
+- if (IsPublic (type))
+- foreach (MemberInfo mi in GetDeclaredPublicMembers (type))
+- yield return mi;
+- }
+-
+- static IEnumerable<MemberInfo> GetDeclaredPublicMembers (Type type)
+- {
+- if (IsPublic (type))
+- foreach (MemberInfo mi in type.GetMembers (BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
+- yield return mi;
+- }
+-
+- //this method walks the interface tree in an undefined manner and returns the first match, or if no matches are found, null
+- //the logic needs review and cleanup
+- //TODO: unify member name mapping as is already done with interfaces and args
+- public static MethodInfo GetMethod (Type type, MethodCall method_call)
+- {
+- foreach (MemberInfo member in Mapper.GetPublicMembers (type)) {
+- //this could be made more efficient by using the given interface name earlier and avoiding walking through all public interfaces
+- if (method_call.Interface != null)
+- if (GetInterfaceName (member) != method_call.Interface)
+- continue;
+-
+- MethodInfo meth = null;
+- Type[] inTypes = null;
+-
+- if (member is PropertyInfo) {
+- PropertyInfo prop = member as PropertyInfo;
+-
+- MethodInfo getter = prop.GetGetMethod (false);
+- MethodInfo setter = prop.GetSetMethod (false);
+-
+- if (getter != null && "Get" + prop.Name == method_call.Member) {
+- meth = getter;
+- inTypes = Type.EmptyTypes;
+- } else if (setter != null && "Set" + prop.Name == method_call.Member) {
+- meth = setter;
+- inTypes = new Type[] {prop.PropertyType};
+- }
+- } else {
+- meth = member as MethodInfo;
+-
+- if (meth == null)
+- continue;
+-
+- if (meth.Name != method_call.Member)
+- continue;
+-
+- inTypes = Mapper.GetTypes (ArgDirection.In, meth.GetParameters ());
+- }
+-
+- if (meth == null || inTypes == null)
+- continue;
+-
+- Signature inSig = Signature.GetSig (inTypes);
+-
+- if (inSig != method_call.Signature)
+- continue;
+-
+- return meth;
+- }
+-
+- return null;
+- }
+-
+- public static bool IsPublic (MemberInfo mi)
+- {
+- return IsPublic (mi.DeclaringType);
+- }
+-
+- public static bool IsPublic (Type type)
+- {
+- //we need to have a proper look at what's really public at some point
+- //this will do for now
+-
+- if (type.IsDefined (typeof (InterfaceAttribute), false))
+- return true;
+-
+- if (type.IsSubclassOf (typeof (MarshalByRefObject)))
+- return true;
+-
+- return false;
+- }
+-
+- public static string GetInterfaceName (MemberInfo mi)
+- {
+- return GetInterfaceName (mi.DeclaringType);
+- }
+-
+- public static string GetInterfaceName (Type type)
+- {
+- string interfaceName = type.FullName;
+-
+- //TODO: better fallbacks and namespace mangling when no InterfaceAttribute is available
+-
+- //TODO: no need for foreach
+- foreach (InterfaceAttribute ia in type.GetCustomAttributes (typeof (InterfaceAttribute), true))
+- interfaceName = ia.Name;
+-
+- return interfaceName;
+- }
+-
+- public static Type[] GetTypes (ArgDirection dir, ParameterInfo[] parms)
+- {
+- List<Type> types = new List<Type> ();
+-
+- //TODO: consider InOut/Ref
+-
+- for (int i = 0 ; i != parms.Length ; i++) {
+- switch (dir) {
+- case ArgDirection.In:
+- //docs say IsIn isn't reliable, and this is indeed true
+- //if (parms[i].IsIn)
+- if (!parms[i].IsOut)
+- types.Add (parms[i].ParameterType);
+- break;
+- case ArgDirection.Out:
+- if (parms[i].IsOut) {
+- //TODO: note that IsOut is optional to the compiler, we may want to use IsByRef instead
+- //eg: if (parms[i].ParameterType.IsByRef)
+- types.Add (parms[i].ParameterType.GetElementType ());
+- }
+- break;
+- }
+- }
+-
+- return types.ToArray ();
+- }
+-
+- public static bool IsDeprecated (ICustomAttributeProvider attrProvider)
+- {
+- return attrProvider.IsDefined (typeof (ObsoleteAttribute), true);
+- }
+-
+- static bool AreEqual (Type[] a, Type[] b)
+- {
+- if (a.Length != b.Length)
+- return false;
+-
+- for (int i = 0 ; i != a.Length ; i++)
+- if (a[i] != b[i])
+- return false;
+-
+- return true;
+- }
+-
+- //workaround for Mono bug #81035 (memory leak)
+- static List<Type> genTypes = new List<Type> ();
+- internal static Type GetGenericType (Type defType, Type[] parms)
+- {
+- foreach (Type genType in genTypes) {
+- if (genType.GetGenericTypeDefinition () != defType)
+- continue;
+-
+- Type[] genParms = genType.GetGenericArguments ();
+-
+- if (!AreEqual (genParms, parms))
+- continue;
+-
+- return genType;
+- }
+-
+- Type type = defType.MakeGenericType (parms);
+- genTypes.Add (type);
+- return type;
+- }
+- }
+-
+- //TODO: this class is messy, move the methods somewhere more appropriate
+- static class MessageHelper
+- {
+- public static Message CreateUnknownMethodError (MethodCall method_call)
+- {
+- if (!method_call.message.ReplyExpected)
+- return null;
+-
+- string errMsg = String.Format ("Method \"{0}\" with signature \"{1}\" on interface \"{2}\" doesn't exist", method_call.Member, method_call.Signature.Value, method_call.Interface);
+-
+- Error error = new Error ("org.freedesktop.DBus.Error.UnknownMethod", method_call.message.Header.Serial);
+- error.message.Signature = new Signature (DType.String);
+-
+- MessageWriter writer = new MessageWriter (Connection.NativeEndianness);
+- writer.Write (errMsg);
+- error.message.Body = writer.ToArray ();
+-
+- //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p
+- if (method_call.Sender != null)
+- error.message.Header[FieldCode.Destination] = method_call.Sender;
+-
+- return error.message;
+- }
+-
+- public static void WriteDynamicValues (MessageWriter mw, ParameterInfo[] parms, object[] vals)
+- {
+- foreach (ParameterInfo parm in parms) {
+- if (!parm.IsOut)
+- continue;
+-
+- Type actualType = parm.ParameterType.GetElementType ();
+- mw.Write (actualType, vals[parm.Position]);
+- }
+- }
+-
+- public static object[] GetDynamicValues (Message msg, ParameterInfo[] parms)
+- {
+- //TODO: this validation check should provide better information, eg. message dump or a stack trace, or at least the interface/member
+- /*
+- if (Protocol.Verbose) {
+- Signature expected = Signature.GetSig (types);
+- Signature actual = msg.Signature;
+- if (actual != expected)
+- Console.Error.WriteLine ("Warning: The signature of the message does not match that of the handler: " + "Expected '" + expected + "', got '" + actual + "'");
+- }
+- */
+-
+- object[] vals = new object[parms.Length];
+-
+- if (msg.Body != null) {
+- MessageReader reader = new MessageReader (msg);
+- foreach (ParameterInfo parm in parms) {
+- if (parm.IsOut)
+- continue;
+-
+- vals[parm.Position] = reader.ReadValue (parm.ParameterType);
+- }
+- }
+-
+- return vals;
+- }
+-
+- public static object[] GetDynamicValues (Message msg, Type[] types)
+- {
+- //TODO: this validation check should provide better information, eg. message dump or a stack trace, or at least the interface/member
+- if (Protocol.Verbose) {
+- Signature expected = Signature.GetSig (types);
+- Signature actual = msg.Signature;
+- if (actual != expected)
+- Console.Error.WriteLine ("Warning: The signature of the message does not match that of the handler: " + "Expected '" + expected + "', got '" + actual + "'");
+- }
+-
+- object[] vals = new object[types.Length];
+-
+- if (msg.Body != null) {
+- MessageReader reader = new MessageReader (msg);
+-
+- for (int i = 0 ; i != types.Length ; i++)
+- vals[i] = reader.ReadValue (types[i]);
+- }
+-
+- return vals;
+- }
+-
+- public static object[] GetDynamicValues (Message msg)
+- {
+- Type[] types = msg.Signature.ToTypes ();
+- return GetDynamicValues (msg, types);
+- }
+-
+- public static Message ConstructReply (MethodCall method_call, params object[] vals)
+- {
+- MethodReturn method_return = new MethodReturn (method_call.message.Header.Serial);
+- Message replyMsg = method_return.message;
+-
+- Signature inSig = Signature.GetSig (vals);
+-
+- if (vals != null && vals.Length != 0) {
+- MessageWriter writer = new MessageWriter (Connection.NativeEndianness);
+-
+- foreach (object arg in vals)
+- writer.Write (arg.GetType (), arg);
+-
+- replyMsg.Body = writer.ToArray ();
+- }
+-
+- //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p
+- if (method_call.Sender != null)
+- replyMsg.Header[FieldCode.Destination] = method_call.Sender;
+-
+- replyMsg.Signature = inSig;
+-
+- //replyMsg.WriteHeader ();
+-
+- return replyMsg;
+- }
+-
+- public static Message ConstructDynamicReply (MethodCall method_call, MethodInfo mi, object retVal, object[] vals)
+- {
+- Type retType = mi.ReturnType;
+-
+- MethodReturn method_return = new MethodReturn (method_call.message.Header.Serial);
+- Message replyMsg = method_return.message;
+-
+- Signature outSig = Signature.GetSig (retType);
+- outSig += Signature.GetSig (Mapper.GetTypes (ArgDirection.Out, mi.GetParameters ()));
+-
+- if (outSig != Signature.Empty) {
+- MessageWriter writer = new MessageWriter (Connection.NativeEndianness);
+-
+- //first write the return value, if any
+- if (retType != null && retType != typeof (void))
+- writer.Write (retType, retVal);
+-
+- //then write the out args
+- WriteDynamicValues (writer, mi.GetParameters (), vals);
+-
+- replyMsg.Body = writer.ToArray ();
+- }
+-
+- //TODO: we should be more strict here, but this fallback was added as a quick fix for p2p
+- if (method_call.Sender != null)
+- replyMsg.Header[FieldCode.Destination] = method_call.Sender;
+-
+- replyMsg.Signature = outSig;
+-
+- return replyMsg;
+- }
+- }
+-
+- [AttributeUsage (AttributeTargets.Interface | AttributeTargets.Class, AllowMultiple=false, Inherited=true)]
+- public class InterfaceAttribute : Attribute
+- {
+- public string Name;
+-
+- public InterfaceAttribute (string name)
+- {
+- this.Name = name;
+- }
+- }
+-
+- [AttributeUsage (AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple=false, Inherited=true)]
+- public class ArgumentAttribute : Attribute
+- {
+- public string Name;
+-
+- public ArgumentAttribute (string name)
+- {
+- this.Name = name;
+- }
+-
+- public static string GetSignatureString (Type type)
+- {
+- return Signature.GetSig (type).Value;
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/MatchRule.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/MatchRule.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,319 +0,0 @@
+-// Copyright 2007 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Text;
+-using System.Text.RegularExpressions;
+-using System.Collections.Generic;
+-
+-namespace NDesk.DBus
+-{
+- class MatchRule
+- {
+- public MessageType? MessageType;
+- public readonly SortedList<FieldCode,MatchTest> Fields = new SortedList<FieldCode,MatchTest> ();
+- //public readonly SortedList<int,MatchTest> Args = new SortedList<int,MatchTest> ();
+- public readonly HashSet<ArgMatchTest> Args = new HashSet<ArgMatchTest> ();
+-
+- public MatchRule ()
+- {
+- }
+-
+- static void Append (StringBuilder sb, string key, object value)
+- {
+- Append (sb, key, value.ToString ());
+- }
+-
+- static void Append (StringBuilder sb, string key, string value)
+- {
+- if (sb.Length != 0)
+- sb.Append (',');
+-
+- sb.Append (key);
+- sb.Append ("='");
+- sb.Append (value.Replace (@"\", @"\\").Replace (@"'", @"\'"));
+- sb.Append ('\'');
+- }
+-
+- static void AppendArg (StringBuilder sb, int index, string value)
+- {
+- Append (sb, "arg" + index, value);
+- }
+-
+- static void AppendPathArg (StringBuilder sb, int index, ObjectPath value)
+- {
+- Append (sb, "arg" + index + "path", value.ToString ());
+- }
+-
+- public override bool Equals (object o)
+- {
+- MatchRule r = o as MatchRule;
+- if (o == null)
+- return false;
+-
+- return ToString () == r.ToString ();
+- }
+-
+- public override int GetHashCode ()
+- {
+- //FIXME: not at all optimal
+- return ToString ().GetHashCode ();
+- }
+-
+- public override string ToString ()
+- {
+- StringBuilder sb = new StringBuilder ();
+-
+- if (MessageType != null)
+- Append (sb, "type", MessageFilter.MessageTypeToString ((MessageType)MessageType));
+-
+- // Note that fdo D-Bus daemon sorts in a different order.
+- // It shouldn't matter though as long as we're consistent.
+- foreach (KeyValuePair<FieldCode,MatchTest> pair in Fields) {
+- Append (sb, pair.Key.ToString ().ToLower (), pair.Value.Value);
+- }
+-
+- // Sorting the list here is not ideal
+- List<ArgMatchTest> tests = new List<ArgMatchTest> (Args);
+- tests.Sort ( delegate (ArgMatchTest aa, ArgMatchTest bb) { return aa.ArgNum - bb.ArgNum; } );
+-
+- if (Args != null)
+- foreach (ArgMatchTest test in tests)
+- if (test.Signature == Signature.StringSig)
+- AppendArg (sb, test.ArgNum, (string)test.Value);
+- else if (test.Signature == Signature.ObjectPathSig)
+- AppendPathArg (sb, test.ArgNum, (ObjectPath)test.Value);
+-
+- return sb.ToString ();
+- }
+-
+- public static void Test (HashSet<ArgMatchTest> a, Message msg)
+- {
+- List<Signature> sigs = new List<Signature> ();
+- sigs.AddRange (msg.Signature.GetParts ());
+-
+- if (sigs.Count == 0) {
+- a.Clear ();
+- return;
+- }
+-
+- a.RemoveWhere ( delegate (ArgMatchTest t) { return t.ArgNum >= sigs.Count || t.Signature != sigs[t.ArgNum]; } );
+-
+- // Sorting the list here is not ideal
+- List<ArgMatchTest> tests = new List<ArgMatchTest> (a);
+- tests.Sort ( delegate (ArgMatchTest aa, ArgMatchTest bb) { return aa.ArgNum - bb.ArgNum; } );
+-
+- if (tests.Count == 0) {
+- a.Clear ();
+- return;
+- }
+-
+- MessageReader reader = new MessageReader (msg);
+-
+- int argNum = 0;
+- foreach (ArgMatchTest test in tests) {
+- if (argNum > test.ArgNum) {
+- // This test cannot pass because a previous test already did.
+- // So we already know it will fail without even trying.
+- // This logic will need to be changed to support wildcards.
+- a.Remove (test);
+- continue;
+- }
+-
+- while (argNum != test.ArgNum) {
+- Signature sig = sigs[argNum];
+- if (!reader.StepOver (sig))
+- throw new Exception ();
+- argNum++;
+- }
+-
+- // TODO: Avoid re-reading values
+- int savedPos = reader.pos;
+- if (!reader.ReadValue (test.Signature[0]).Equals (test.Value)) {
+- a.Remove (test);
+- reader.pos = savedPos;
+- continue;
+- }
+-
+- argNum++;
+- }
+- }
+-
+- public bool MatchesHeader (Message msg)
+- {
+- if (MessageType != null)
+- if (msg.Header.MessageType != MessageType)
+- return false;
+-
+- foreach (KeyValuePair<FieldCode,MatchTest> pair in Fields) {
+- object value;
+- if (!msg.Header.Fields.TryGetValue ((byte)pair.Key, out value))
+- return false;
+- if (!pair.Value.Value.Equals (value))
+- return false;
+- }
+-
+- return true;
+- }
+-
+- static Regex argNRegex = new Regex (@"^arg(\d+)(path)?$");
+- static Regex matchRuleRegex = new Regex (@"(\w+)\s*=\s*'((\\\\|\\'|[^'\\])*)'", RegexOptions.Compiled);
+- public static MatchRule Parse (string text)
+- {
+- if (text.Length > Protocol.MaxMatchRuleLength)
+- throw new Exception ("Match rule length exceeds maximum " + Protocol.MaxMatchRuleLength + " characters");
+-
+- MatchRule r = new MatchRule ();
+-
+- // TODO: Stricter validation. Tighten up the regex.
+- // It currently succeeds and silently drops malformed test parts.
+-
+- for (Match m = matchRuleRegex.Match (text) ; m.Success ; m = m.NextMatch ()) {
+- string key = m.Groups[1].Value;
+- string value = m.Groups[2].Value;
+- // This unescaping may not be perfect..
+- value = value.Replace (@"\\", @"\");
+- value = value.Replace (@"\'", @"'");
+-
+- if (key.StartsWith ("arg")) {
+- Match mArg = argNRegex.Match (key);
+- if (!mArg.Success)
+- return null;
+- int argNum = (int)UInt32.Parse (mArg.Groups[1].Value);
+-
+- if (argNum < 0 || argNum >= Protocol.MaxMatchRuleArgs)
+- throw new Exception ("arg match must be between 0 and " + (Protocol.MaxMatchRuleArgs - 1) + " inclusive");
+-
+- //if (r.Args.ContainsKey (argNum))
+- // return null;
+-
+- string argType = mArg.Groups[2].Value;
+-
+- if (argType == "path")
+- r.Args.Add (new ArgMatchTest (argNum, new ObjectPath (value)));
+- else
+- r.Args.Add (new ArgMatchTest (argNum, value));
+-
+- continue;
+- }
+-
+- //TODO: more consistent error handling
+- switch (key) {
+- case "type":
+- if (r.MessageType != null)
+- return null;
+- r.MessageType = MessageFilter.StringToMessageType (value);
+- break;
+- case "interface":
+- r.Fields[FieldCode.Interface] = new MatchTest (value);
+- break;
+- case "member":
+- r.Fields[FieldCode.Member] = new MatchTest (value);
+- break;
+- case "path":
+- r.Fields[FieldCode.Path] = new MatchTest (new ObjectPath (value));
+- break;
+- case "sender":
+- r.Fields[FieldCode.Sender] = new MatchTest (value);
+- break;
+- case "destination":
+- r.Fields[FieldCode.Destination] = new MatchTest (value);
+- break;
+- default:
+- if (Protocol.Verbose)
+- Console.Error.WriteLine ("Warning: Unrecognized match rule key: " + key);
+- break;
+- }
+- }
+-
+- return r;
+- }
+- }
+-
+- class HeaderTest : MatchTest
+- {
+- public FieldCode Field;
+- public HeaderTest (FieldCode field, object value)
+- {
+- Field = field;
+- Signature = Signature.GetSig (value.GetType ());
+- Value = value;
+- }
+- }
+-
+- struct ArgMatchTest
+- {
+- public int ArgNum;
+- public Signature Signature;
+- public object Value;
+-
+- public ArgMatchTest (int argNum, string value)
+- {
+- ArgNum = argNum;
+- Signature = Signature.StringSig;
+- Value = value;
+- }
+-
+- public ArgMatchTest (int argNum, ObjectPath value)
+- {
+- ArgNum = argNum;
+- Signature = Signature.ObjectPathSig;
+- Value = value;
+- }
+-
+- public override int GetHashCode ()
+- {
+- return Signature.GetHashCode () ^ Value.GetHashCode () ^ ArgNum;
+- }
+- }
+-
+- /*
+- class ArgMatchTest : MatchTest
+- {
+- public int ArgNum;
+-
+- public ArgMatchTest (int argNum, string value) : base (value)
+- {
+- ArgNum = argNum;
+- }
+-
+- public ArgMatchTest (int argNum, ObjectPath value) : base (value)
+- {
+- ArgNum = argNum;
+- }
+-
+- public override int GetHashCode ()
+- {
+- return base.GetHashCode () ^ ArgNum;
+- }
+- }
+- */
+-
+- class MatchTest
+- {
+- public Signature Signature;
+- public object Value;
+-
+- public override int GetHashCode ()
+- {
+- return Signature.GetHashCode () ^ Value.GetHashCode ();
+- }
+-
+- protected MatchTest ()
+- {
+- }
+-
+- public MatchTest (string value)
+- {
+- Signature = Signature.StringSig;
+- Value = value;
+- }
+-
+- public MatchTest (ObjectPath value)
+- {
+- Signature = Signature.ObjectPathSig;
+- Value = value;
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Message.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Message.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,492 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Collections.Generic;
+-using System.IO;
+-
+-namespace NDesk.DBus
+-{
+- class Message
+- {
+- public Message ()
+- {
+- Header.Endianness = Connection.NativeEndianness;
+- Header.MessageType = MessageType.MethodCall;
+- Header.Flags = HeaderFlag.NoReplyExpected; //TODO: is this the right place to do this?
+- Header.MajorVersion = Protocol.Version;
+- Header.Fields = new Dictionary<byte, object> ();
+- }
+-
+- public Header Header = new Header ();
+-
+- public Connection Connection;
+-
+- public Signature Signature
+- {
+- get {
+- object o = Header[FieldCode.Signature];
+- if (o == null)
+- return Signature.Empty;
+- else
+- return (Signature)o;
+- } set {
+- if (value == Signature.Empty)
+- Header[FieldCode.Signature] = null;
+- else
+- Header[FieldCode.Signature] = value;
+- }
+- }
+-
+- public bool ReplyExpected
+- {
+- get {
+- return (Header.Flags & HeaderFlag.NoReplyExpected) == HeaderFlag.None;
+- } set {
+- if (value)
+- Header.Flags &= ~HeaderFlag.NoReplyExpected; //flag off
+- else
+- Header.Flags |= HeaderFlag.NoReplyExpected; //flag on
+- }
+- }
+-
+- //public HeaderField[] HeaderFields;
+- //public Dictionary<FieldCode,object>;
+-
+- public byte[] Body;
+-
+- //TODO: make use of Locked
+- /*
+- protected bool locked = false;
+- public bool Locked
+- {
+- get {
+- return locked;
+- }
+- }
+- */
+-
+- public void HandleHeader (Header headerIn)
+- {
+- Header = headerIn;
+- }
+-
+- static System.Reflection.MethodInfo hHandler = typeof (Message).GetMethod ("HandleHeader");
+- public void SetHeaderData (byte[] data)
+- {
+- EndianFlag endianness = (EndianFlag)data[0];
+- MessageReader reader = new MessageReader (endianness, data);
+-
+- MethodCaller2 mCaller = ExportObject.GetMCaller (hHandler);
+- mCaller (this, reader, null, new MessageWriter ());
+- }
+-
+- //public HeaderField[] Fields;
+-
+- /*
+- public void SetHeaderData (byte[] data)
+- {
+- EndianFlag endianness = (EndianFlag)data[0];
+- MessageReader reader = new MessageReader (endianness, data);
+-
+- Header = (Header)reader.ReadStruct (typeof (Header));
+- }
+- */
+-
+- //TypeWriter<Header> headerWriter = TypeImplementer.GetTypeWriter<Header> ();
+- public byte[] GetHeaderData ()
+- {
+- if (Body != null)
+- Header.Length = (uint)Body.Length;
+-
+- MessageWriter writer = new MessageWriter (Header.Endianness);
+-
+- //writer.stream.Capacity = 512;
+- //headerWriter (writer, Header);
+-
+- writer.Write ((byte)Header.Endianness);
+- writer.Write ((byte)Header.MessageType);
+- writer.Write ((byte)Header.Flags);
+- writer.Write (Header.MajorVersion);
+- writer.Write (Header.Length);
+- writer.Write (Header.Serial);
+- writer.WriteHeaderFields (Header.Fields);
+-
+- writer.CloseWrite ();
+-
+- return writer.ToArray ();
+- }
+-
+- public void GetHeaderDataToStream (Stream stream)
+- {
+- if (Body != null)
+- Header.Length = (uint)Body.Length;
+-
+- MessageWriter writer = new MessageWriter (Header.Endianness);
+-
+- //headerWriter (writer, Header);
+-
+- writer.Write ((byte)Header.Endianness);
+- writer.Write ((byte)Header.MessageType);
+- writer.Write ((byte)Header.Flags);
+- writer.Write (Header.MajorVersion);
+- writer.Write (Header.Length);
+- writer.Write (Header.Serial);
+- writer.WriteHeaderFields (Header.Fields);
+-
+- writer.CloseWrite ();
+-
+- writer.ToStream (stream);
+- }
+- }
+-
+- // Allows conversion of complex variants via System.Convert
+- class DValue : IConvertible
+- {
+- // TODO: Note that we currently drop the originating Connection/Message details
+- // They may be useful later in conversion!
+-
+- internal EndianFlag endianness;
+- internal Signature signature;
+- internal byte[] data;
+-
+- public bool CanConvertTo (Type conversionType)
+- {
+- Signature typeSig = Signature.GetSig (conversionType);
+- return signature == typeSig;
+- }
+-
+- public TypeCode GetTypeCode ()
+- {
+- return TypeCode.Object;
+- }
+-
+- public object ToType (Type conversionType)
+- {
+- return ToType (conversionType, null);
+- }
+-
+- public object ToType (Type conversionType, IFormatProvider provider)
+- {
+- Signature typeSig = Signature.GetSig (conversionType);
+- if (typeSig != signature)
+- throw new InvalidCastException ();
+-
+- MessageReader reader = new MessageReader (endianness, data);
+- return reader.ReadValue (conversionType);
+- }
+-
+- public override string ToString ()
+- {
+- // Seems a reasonable way of providing the signature to the API layer
+- return signature.ToString ();
+- }
+-
+- // IConvertible implementation:
+-
+- /*
+- public TypeCode GetTypeCode ()
+- {
+- throw new NotSupportedException ();
+- }
+- */
+-
+- public bool ToBoolean (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+-
+- public byte ToByte (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+-
+- public char ToChar (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+-
+- public DateTime ToDateTime (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+-
+- public decimal ToDecimal (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+-
+- public double ToDouble (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+-
+- public short ToInt16 (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+-
+- public int ToInt32 (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+-
+- public long ToInt64 (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+-
+- public sbyte ToSByte (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+-
+- public float ToSingle (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+-
+- public string ToString (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+-
+- /*
+- public object ToType (Type conversionType, IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+- */
+-
+- public ushort ToUInt16 (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+-
+- public uint ToUInt32 (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+-
+- public ulong ToUInt64 (IFormatProvider provider)
+- {
+- throw new NotSupportedException ();
+- }
+- }
+-
+- partial class MessageReader
+- {
+- // Note: This method doesn't support aggregate signatures
+- public bool StepOver (Signature sig)
+- {
+- if (sig == Signature.VariantSig) {
+- Signature valueSig = ReadSignature ();
+- return StepOver (valueSig);
+- }
+-
+- if (sig == Signature.StringSig) {
+- uint valueLength = ReadUInt32 ();
+- pos += (int)valueLength;
+- pos++;
+- return true;
+- }
+-
+- if (sig == Signature.SignatureSig) {
+- byte valueLength = ReadByte ();
+- pos += valueLength;
+- pos++;
+- return true;
+- }
+-
+- // No need to handle dicts specially. IsArray does the job
+- if (sig.IsArray) {
+- Signature elemSig = sig.GetElementSignature ();
+- uint ln = ReadUInt32 ();
+- pos = Protocol.Padded (pos, elemSig.Alignment);
+- pos += (int)ln;
+- return true;
+- }
+-
+- int endPos = pos;
+- if (sig.GetFixedSize (ref endPos)) {
+- pos = endPos;
+- return true;
+- }
+-
+- if (sig.IsDictEntry) {
+- pos = Protocol.Padded (pos, sig.Alignment);
+- Signature sigKey, sigValue;
+- sig.GetDictEntrySignatures (out sigKey, out sigValue);
+- if (!StepOver (sigKey))
+- return false;
+- if (!StepOver (sigValue))
+- return false;
+- return true;
+- }
+-
+- if (sig.IsStruct) {
+- pos = Protocol.Padded (pos, sig.Alignment);
+- foreach (Signature fieldSig in sig.GetFieldSignatures ())
+- if (!StepOver (fieldSig))
+- return false;
+- return true;
+- }
+-
+- throw new Exception ("Can't step over '" + sig + "'");
+- //return false;
+- }
+-
+- public IEnumerable<Signature> StepInto (Signature sig)
+- {
+- if (sig == Signature.VariantSig) {
+- Signature valueSig = ReadSignature ();
+- yield return valueSig;
+- yield break;
+- }
+-
+- // No need to handle dicts specially. IsArray does the job
+- if (sig.IsArray) {
+- Signature elemSig = sig.GetElementSignature ();
+- uint ln = ReadUInt32 ();
+- ReadPad (elemSig.Alignment);
+- int endPos = pos + (int)ln;
+- while (pos < endPos)
+- yield return elemSig;
+- yield break;
+- }
+-
+- if (sig.IsDictEntry) {
+- pos = Protocol.Padded (pos, sig.Alignment);
+- Signature sigKey, sigValue;
+- sig.GetDictEntrySignatures (out sigKey, out sigValue);
+- yield return sigKey;
+- yield return sigValue;
+- yield break;
+- }
+-
+- if (sig.IsStruct) {
+- pos = Protocol.Padded (pos, sig.Alignment);
+- foreach (Signature fieldSig in sig.GetFieldSignatures ())
+- yield return fieldSig;
+- yield break;
+- }
+-
+- throw new Exception ("Can't step into '" + sig + "'");
+- //yield break;
+- }
+- }
+-
+- class MessageDumper
+- {
+- public static byte[] ReadBlock (TextReader r)
+- {
+- //if (Body == null)
+- // return;
+-
+- MemoryStream ms = new MemoryStream ();
+-
+- while (true) {
+- string ln = r.ReadLine ();
+- if (ln == null)
+- break;
+- if (!ReadFromHex (ms, ln))
+- break;
+- }
+-
+- if (ms.Length == 0)
+- return null;
+-
+- return ms.ToArray ();
+- }
+-
+- public static void WriteComment (string comment, TextWriter w)
+- {
+- w.WriteLine ("# " + comment);
+- }
+-
+- public static void WriteBlock (byte[] Body, TextWriter w)
+- {
+- //if (Body == null)
+- // return;
+- if (Body != null)
+- for (int i = 0 ; i != Body.Length ; i++) {
+- if (i == 0) {}
+- else if (i % 32 == 0)
+- w.WriteLine ();
+- else if (i % 4 == 0)
+- w.Write (' ');
+-
+- w.Write (Body[i].ToString ("x2", System.Globalization.CultureInfo.InvariantCulture));
+- }
+-
+- w.Write ('.');
+- w.WriteLine ();
+- w.Flush ();
+- }
+-
+- public static void WriteMessage (Message msg, TextWriter w)
+- {
+- w.WriteLine ("# Message");
+- w.WriteLine ("# Header");
+- MessageDumper.WriteBlock (msg.GetHeaderData (), w);
+- w.WriteLine ("# Body");
+- MessageDumper.WriteBlock (msg.Body, w);
+- w.WriteLine ();
+- w.Flush ();
+- }
+-
+- public static Message ReadMessage (TextReader r)
+- {
+- byte[] header = MessageDumper.ReadBlock (r);
+-
+- if (header == null)
+- return null;
+-
+- byte[] body = MessageDumper.ReadBlock (r);
+-
+- Message msg = new Message ();
+- msg.SetHeaderData (header);
+- msg.Body = body;
+-
+- return msg;
+- }
+-
+- static byte FromHexChar (char c)
+- {
+- if ((c >= 'a') && (c <= 'f'))
+- return (byte) (c - 'a' + 10);
+- if ((c >= 'A') && (c <= 'F'))
+- return (byte) (c - 'A' + 10);
+- if ((c >= '0') && (c <= '9'))
+- return (byte) (c - '0');
+- throw new ArgumentException ("Invalid hex char");
+- }
+-
+- static bool ReadFromHex (Stream ms, string hex)
+- {
+- if (hex.StartsWith ("#"))
+- return true;
+-
+- int i = 0;
+- while (i < hex.Length) {
+- if (char.IsWhiteSpace (hex [i])) {
+- i++;
+- continue;
+- }
+-
+- if (hex [i] == '.') {
+- ms.Flush ();
+- return false;
+- }
+-
+- byte res = (byte) (FromHexChar (hex [i++]) << 4);
+- res += FromHexChar (hex [i++]);
+- ms.WriteByte (res);
+- }
+-
+- ms.Flush ();
+- return true;
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/MessageFilter.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/MessageFilter.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,58 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-
+-namespace NDesk.DBus
+-{
+- class MessageFilter
+- {
+- //this should probably be made to use HeaderField or similar
+- //this class is not generalized yet
+-
+- public static string MessageTypeToString (MessageType mtype)
+- {
+- switch (mtype)
+- {
+- case MessageType.MethodCall:
+- return "method_call";
+- case MessageType.MethodReturn:
+- return "method_return";
+- case MessageType.Error:
+- return "error";
+- case MessageType.Signal:
+- return "signal";
+- case MessageType.Invalid:
+- return "invalid";
+- default:
+- throw new Exception ("Bad MessageType: " + mtype);
+- }
+- }
+-
+- public static MessageType StringToMessageType (string text)
+- {
+- switch (text)
+- {
+- case "method_call":
+- return MessageType.MethodCall;
+- case "method_return":
+- return MessageType.MethodReturn;
+- case "error":
+- return MessageType.Error;
+- case "signal":
+- return MessageType.Signal;
+- case "invalid":
+- return MessageType.Invalid;
+- default:
+- throw new Exception ("Bad MessageType: " + text);
+- }
+- }
+-
+- //TODO: remove this -- left here for the benefit of the monitor tool for now
+- public static string CreateMatchRule (MessageType mtype)
+- {
+- return "type='" + MessageTypeToString (mtype) + "'";
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/MessageReader.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/MessageReader.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,494 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Text;
+-using System.Collections.Generic;
+-using System.IO;
+-using System.Reflection;
+-
+-namespace NDesk.DBus
+-{
+- partial class MessageReader
+- {
+- protected EndianFlag endianness;
+- //protected byte[] data;
+- public byte[] data;
+- //TODO: this should be uint or long to handle long messages
+- //internal int pos = 0;
+- public int pos = 0;
+- protected Message message;
+-
+- public MessageReader (EndianFlag endianness, byte[] data)
+- {
+- //if (data == null)
+- // throw new ArgumentNullException ("data");
+- if (data == null)
+- data = new byte[0];
+-
+- this.endianness = endianness;
+- this.IsNativeEndian = endianness == Connection.NativeEndianness;
+- this.data = data;
+- }
+-
+- public MessageReader (Message message) : this (message.Header.Endianness, message.Body)
+- {
+- if (message == null)
+- throw new ArgumentNullException ("message");
+-
+- this.message = message;
+- }
+-
+- public readonly bool IsNativeEndian;
+-
+- public object ReadValue (Type type)
+- {
+- if (type == typeof (void))
+- return null;
+-
+- if (type.IsArray) {
+- return ReadArray (type.GetElementType ());
+- } else if (type == typeof (ObjectPath)) {
+- return ReadObjectPath ();
+- } else if (type == typeof (Signature)) {
+- return ReadSignature ();
+- } else if (type == typeof (object)) {
+- return ReadVariant ();
+- } else if (type == typeof (string)) {
+- return ReadString ();
+- } else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (IDictionary<,>)) {
+- Type[] genArgs = type.GetGenericArguments ();
+- //Type dictType = typeof (Dictionary<,>).MakeGenericType (genArgs);
+- //workaround for Mono bug #81035 (memory leak)
+- Type dictType = Mapper.GetGenericType (typeof (Dictionary<,>), genArgs);
+- System.Collections.IDictionary idict = (System.Collections.IDictionary)Activator.CreateInstance(dictType, new object[0]);
+- GetValueToDict (genArgs[0], genArgs[1], idict);
+- return idict;
+- } else if (Mapper.IsPublic (type)) {
+- return GetObject (type);
+- } else if (!type.IsPrimitive && !type.IsEnum) {
+- return ReadStruct (type);
+- } else {
+- object val;
+- DType dtype = Signature.TypeToDType (type);
+- val = ReadValue (dtype);
+-
+- if (type.IsEnum)
+- val = Enum.ToObject (type, val);
+-
+- return val;
+- }
+- }
+-
+- //helper method, should not be used generally
+- public object ReadValue (DType dtype)
+- {
+- switch (dtype)
+- {
+- case DType.Byte:
+- return ReadByte ();
+-
+- case DType.Boolean:
+- return ReadBoolean ();
+-
+- case DType.Int16:
+- return ReadInt16 ();
+-
+- case DType.UInt16:
+- return ReadUInt16 ();
+-
+- case DType.Int32:
+- return ReadInt32 ();
+-
+- case DType.UInt32:
+- return ReadUInt32 ();
+-
+- case DType.Int64:
+- return ReadInt64 ();
+-
+- case DType.UInt64:
+- return ReadUInt64 ();
+-
+-#if !DISABLE_SINGLE
+- case DType.Single:
+- return ReadSingle ();
+-#endif
+-
+- case DType.Double:
+- return ReadDouble ();
+-
+- case DType.String:
+- return ReadString ();
+-
+- case DType.ObjectPath:
+- return ReadObjectPath ();
+-
+- case DType.Signature:
+- return ReadSignature ();
+-
+- case DType.Variant:
+- return ReadVariant ();
+-
+- default:
+- throw new Exception ("Unhandled D-Bus type: " + dtype);
+- }
+- }
+-
+- public object GetObject (Type type)
+- {
+- ObjectPath path = ReadObjectPath ();
+-
+- return message.Connection.GetObject (type, (string)message.Header[FieldCode.Sender], path);
+- }
+-
+- public byte ReadByte ()
+- {
+- return data[pos++];
+- }
+-
+- public bool ReadBoolean ()
+- {
+- uint intval = ReadUInt32 ();
+-
+- switch (intval) {
+- case 0:
+- return false;
+- case 1:
+- return true;
+- default:
+- throw new Exception ("Read value " + intval + " at position " + pos + " while expecting boolean (0/1)");
+- }
+- }
+-
+- unsafe protected void MarshalUShort (void* dstPtr)
+- {
+- ReadPad (2);
+-
+- if (data.Length < pos + 2)
+- throw new Exception ("Cannot read beyond end of data");
+-
+- if (endianness == Connection.NativeEndianness) {
+- fixed (byte* p = &data[pos])
+- *((ushort*)dstPtr) = *((ushort*)p);
+- } else {
+- byte* dst = (byte*)dstPtr;
+- dst[0] = data[pos + 1];
+- dst[1] = data[pos + 0];
+- }
+-
+- pos += 2;
+- }
+-
+- unsafe public short ReadInt16 ()
+- {
+- short val;
+-
+- MarshalUShort (&val);
+-
+- return val;
+- }
+-
+- unsafe public ushort ReadUInt16 ()
+- {
+- ushort val;
+-
+- MarshalUShort (&val);
+-
+- return val;
+- }
+-
+- unsafe protected void MarshalUInt (void* dstPtr)
+- {
+- ReadPad (4);
+-
+- if (data.Length < pos + 4)
+- throw new Exception ("Cannot read beyond end of data");
+-
+- if (endianness == Connection.NativeEndianness) {
+- fixed (byte* p = &data[pos])
+- *((uint*)dstPtr) = *((uint*)p);
+- } else {
+- byte* dst = (byte*)dstPtr;
+- dst[0] = data[pos + 3];
+- dst[1] = data[pos + 2];
+- dst[2] = data[pos + 1];
+- dst[3] = data[pos + 0];
+- }
+-
+- pos += 4;
+- }
+-
+- unsafe public int ReadInt32 ()
+- {
+- int val;
+-
+- MarshalUInt (&val);
+-
+- return val;
+- }
+-
+- unsafe public uint ReadUInt32 ()
+- {
+- uint val;
+-
+- MarshalUInt (&val);
+-
+- return val;
+- }
+-
+- unsafe protected void MarshalULong (void* dstPtr)
+- {
+- ReadPad (8);
+-
+- if (data.Length < pos + 8)
+- throw new Exception ("Cannot read beyond end of data");
+-
+- if (endianness == Connection.NativeEndianness) {
+- fixed (byte* p = &data[pos])
+- *((ulong*)dstPtr) = *((ulong*)p);
+- } else {
+- byte* dst = (byte*)dstPtr;
+- for (int i = 0; i < 8; ++i)
+- dst[i] = data[pos + (7 - i)];
+- }
+-
+- pos += 8;
+- }
+-
+- unsafe public long ReadInt64 ()
+- {
+- long val;
+-
+- MarshalULong (&val);
+-
+- return val;
+- }
+-
+- unsafe public ulong ReadUInt64 ()
+- {
+- ulong val;
+-
+- MarshalULong (&val);
+-
+- return val;
+- }
+-
+-#if !DISABLE_SINGLE
+- unsafe public float ReadSingle ()
+- {
+- float val;
+-
+- MarshalUInt (&val);
+-
+- return val;
+- }
+-#endif
+-
+- unsafe public double ReadDouble ()
+- {
+- double val;
+-
+- MarshalULong (&val);
+-
+- return val;
+- }
+-
+- public string ReadString ()
+- {
+- uint ln = ReadUInt32 ();
+-
+- string val = Encoding.UTF8.GetString (data, pos, (int)ln);
+- pos += (int)ln;
+- ReadNull ();
+-
+- return val;
+- }
+-
+- public ObjectPath ReadObjectPath ()
+- {
+- //exactly the same as string
+- return new ObjectPath (ReadString ());
+- }
+-
+- public Signature ReadSignature ()
+- {
+- byte ln = ReadByte ();
+-
+- // Avoid an array allocation for small signatures
+- if (ln == 1) {
+- DType dtype = (DType)ReadByte ();
+- ReadNull ();
+- return new Signature (dtype);
+- }
+-
+- if (ln > Protocol.MaxSignatureLength)
+- throw new Exception ("Signature length " + ln + " exceeds maximum allowed " + Protocol.MaxSignatureLength + " bytes");
+-
+- byte[] sigData = new byte[ln];
+- Array.Copy (data, pos, sigData, 0, (int)ln);
+- pos += (int)ln;
+- ReadNull ();
+-
+- return Signature.Take (sigData);
+- }
+-
+- public object ReadVariant ()
+- {
+- return ReadValue (ReadSignature ());
+- }
+-
+- // Used primarily for reading variant values
+- object ReadValue (Signature sig)
+- {
+- if (sig.IsPrimitive)
+- return ReadValue (sig[0]);
+-
+- Type t = null;
+- try {
+- t = sig.ToType ();
+- } catch (NotSupportedException e) {
+- // We don't catch other exceptions as they indicate a malformed signature
+- if (Protocol.Verbose)
+- Console.Error.WriteLine (e.Message);
+- }
+-
+- /*
+- if (t == null) {
+- StepOver (sig);
+- return null;
+- }
+- */
+-
+- if (t == null) {
+- ReadPad (sig.Alignment);
+- int startPos = pos;
+- StepOver (sig);
+- int ln = pos - startPos;
+-
+- DValue dv = new DValue();
+- dv.endianness = endianness;
+- dv.signature = sig;
+- dv.data = new byte[ln];
+- Array.Copy (data, startPos, dv.data, 0, ln);
+- return dv;
+- }
+-
+- return ReadValue (t);
+- }
+-
+- //not pretty or efficient but works
+- public void GetValueToDict (Type keyType, Type valType, System.Collections.IDictionary val)
+- {
+- uint ln = ReadUInt32 ();
+-
+- if (ln > Protocol.MaxArrayLength)
+- throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes");
+-
+- //advance to the alignment of the element
+- //ReadPad (Protocol.GetAlignment (Signature.TypeToDType (type)));
+- ReadPad (8);
+-
+- int endPos = pos + (int)ln;
+-
+- //while (stream.Position != endPos)
+- while (pos < endPos)
+- {
+- ReadPad (8);
+-
+- val.Add (ReadValue (keyType), ReadValue (valType));
+- }
+-
+- if (pos != endPos)
+- throw new Exception ("Read pos " + pos + " != ep " + endPos);
+- }
+-
+- //this could be made generic to avoid boxing
+- public Array ReadArray (Type elemType)
+- {
+- uint ln = ReadUInt32 ();
+-
+- if (ln > Protocol.MaxArrayLength)
+- throw new Exception ("Array length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes");
+-
+- //TODO: more fast paths for primitive arrays
+- if (elemType == typeof (byte)) {
+- byte[] valb = new byte[ln];
+- Array.Copy (data, pos, valb, 0, (int)ln);
+- pos += (int)ln;
+- return valb;
+- }
+-
+- //advance to the alignment of the element
+- ReadPad (Protocol.GetAlignment (Signature.TypeToDType (elemType)));
+-
+- int endPos = pos + (int)ln;
+-
+- //List<T> vals = new List<T> ();
+- System.Collections.ArrayList vals = new System.Collections.ArrayList ();
+-
+- //while (stream.Position != endPos)
+- while (pos < endPos)
+- vals.Add (ReadValue (elemType));
+-
+- if (pos != endPos)
+- throw new Exception ("Read pos " + pos + " != ep " + endPos);
+-
+- return vals.ToArray (elemType);
+- }
+-
+- //struct
+- //probably the wrong place for this
+- //there might be more elegant solutions
+- public object ReadStruct (Type type)
+- {
+- ReadPad (8);
+-
+- object val = Activator.CreateInstance (type);
+-
+- /*
+- if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (KeyValuePair<,>)) {
+- object elem;
+-
+- System.Reflection.PropertyInfo key_prop = type.GetProperty ("Key");
+- GetValue (key_prop.PropertyType, out elem);
+- key_prop.SetValue (val, elem, null);
+-
+- System.Reflection.PropertyInfo val_prop = type.GetProperty ("Value");
+- GetValue (val_prop.PropertyType, out elem);
+- val_prop.SetValue (val, elem, null);
+-
+- return;
+- }
+- */
+-
+- FieldInfo[] fis = type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
+-
+- foreach (System.Reflection.FieldInfo fi in fis)
+- fi.SetValue (val, ReadValue (fi.FieldType));
+-
+- return val;
+- }
+-
+- public void ReadNull ()
+- {
+- if (data[pos] != 0)
+- throw new Exception ("Read non-zero byte at position " + pos + " while expecting null terminator");
+- pos++;
+- }
+-
+- /*
+- public void ReadPad (int alignment)
+- {
+- pos = Protocol.Padded (pos, alignment);
+- }
+- */
+-
+- public void ReadPad (int alignment)
+- {
+- for (int endPos = Protocol.Padded (pos, alignment) ; pos != endPos ; pos++)
+- if (data[pos] != 0)
+- throw new Exception ("Read non-zero byte at position " + pos + " while expecting padding");
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/MessageWriter.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/MessageWriter.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,570 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Text;
+-using System.Collections.Generic;
+-using System.IO;
+-using System.Reflection;
+-using System.Runtime.InteropServices;
+-
+-namespace NDesk.DBus
+-{
+- sealed class MessageWriter
+- {
+- EndianFlag endianness;
+- internal MemoryStream stream;
+-
+- public Connection connection;
+-
+- //a default constructor is a bad idea for now as we want to make sure the header and content-type match
+- public MessageWriter () : this (Connection.NativeEndianness) {}
+-
+- public MessageWriter (EndianFlag endianness)
+- {
+- this.endianness = endianness;
+- stream = new MemoryStream ();
+- }
+-
+- public byte[] ToArray ()
+- {
+- //TODO: mark the writer locked or something here
+- return stream.ToArray ();
+- }
+-
+- public void ToStream (Stream dest)
+- {
+- stream.WriteTo (dest);
+- }
+-
+- public void CloseWrite ()
+- {
+- WritePad (8);
+- }
+-
+- public void Write (byte val)
+- {
+- stream.WriteByte (val);
+- }
+-
+- public void Write (bool val)
+- {
+- Write ((uint) (val ? 1 : 0));
+- }
+-
+- // Buffer for integer marshaling
+- byte[] dst = new byte[8];
+- unsafe void MarshalUShort (void* dataPtr)
+- {
+- WritePad (2);
+-
+- if (endianness == Connection.NativeEndianness) {
+- fixed (byte* p = &dst[0])
+- *((ushort*)p) = *((ushort*)dataPtr);
+- } else {
+- byte* data = (byte*)dataPtr;
+- dst[0] = data[1];
+- dst[1] = data[0];
+- }
+-
+- stream.Write (dst, 0, 2);
+- }
+-
+- unsafe public void Write (short val)
+- {
+- MarshalUShort (&val);
+- }
+-
+- unsafe public void Write (ushort val)
+- {
+- MarshalUShort (&val);
+- }
+-
+- unsafe void MarshalUInt (void* dataPtr)
+- {
+- WritePad (4);
+-
+- if (endianness == Connection.NativeEndianness) {
+- fixed (byte* p = &dst[0])
+- *((uint*)p) = *((uint*)dataPtr);
+- } else {
+- byte* data = (byte*)dataPtr;
+- dst[0] = data[3];
+- dst[1] = data[2];
+- dst[2] = data[1];
+- dst[3] = data[0];
+- }
+-
+- stream.Write (dst, 0, 4);
+- }
+-
+- unsafe public void Write (int val)
+- {
+- MarshalUInt (&val);
+- }
+-
+- unsafe public void Write (uint val)
+- {
+- MarshalUInt (&val);
+- }
+-
+- unsafe void MarshalULong (void* dataPtr)
+- {
+- WritePad (8);
+-
+- if (endianness == Connection.NativeEndianness) {
+- fixed (byte* p = &dst[0])
+- *((ulong*)p) = *((ulong*)dataPtr);
+- } else {
+- byte* data = (byte*)dataPtr;
+- for (int i = 0; i < 8; ++i)
+- dst[i] = data[7 - i];
+- }
+-
+- stream.Write (dst, 0, 8);
+- }
+-
+- unsafe public void Write (long val)
+- {
+- MarshalULong (&val);
+- }
+-
+- unsafe public void Write (ulong val)
+- {
+- MarshalULong (&val);
+- }
+-
+-#if !DISABLE_SINGLE
+- unsafe public void Write (float val)
+- {
+- MarshalUInt (&val);
+- }
+-#endif
+-
+- unsafe public void Write (double val)
+- {
+- MarshalULong (&val);
+- }
+-
+- public void Write (string val)
+- {
+- byte[] utf8_data = Encoding.UTF8.GetBytes (val);
+- Write ((uint)utf8_data.Length);
+- stream.Write (utf8_data, 0, utf8_data.Length);
+- WriteNull ();
+- }
+-
+- public void Write (ObjectPath val)
+- {
+- Write (val.Value);
+- }
+-
+- public void Write (Signature val)
+- {
+- byte[] ascii_data = val.GetBuffer ();
+-
+- if (ascii_data.Length > Protocol.MaxSignatureLength)
+- throw new Exception ("Signature length " + ascii_data.Length + " exceeds maximum allowed " + Protocol.MaxSignatureLength + " bytes");
+-
+- Write ((byte)ascii_data.Length);
+- stream.Write (ascii_data, 0, ascii_data.Length);
+- WriteNull ();
+- }
+-
+- [Obsolete]
+- public void WriteComplex (object val, Type type)
+- {
+- if (type == typeof (void))
+- return;
+-
+- if (type.IsArray) {
+- MethodInfo miDict = typeof (MessageWriter).GetMethod ("WriteArray");
+- MethodInfo mi = miDict.MakeGenericMethod (type.GetElementType ());
+- mi.Invoke (this, new object[] {val});
+- } else if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) {
+- Type[] genArgs = type.GetGenericArguments ();
+- MethodInfo miDict = typeof (MessageWriter).GetMethod ("WriteFromDict");
+- MethodInfo mi = miDict.MakeGenericMethod (genArgs);
+- mi.Invoke (this, new object[] {val});
+- } else if (Mapper.IsPublic (type)) {
+- WriteObject (type, val);
+- } else if (!type.IsPrimitive && !type.IsEnum) {
+- WriteValueType (val, type);
+- /*
+- } else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (Nullable<>)) {
+- //is it possible to support nullable types?
+- Type[] genArgs = type.GetGenericArguments ();
+- WriteVariant (genArgs[0], val);
+- */
+- } else {
+- throw new Exception ("Can't write");
+- }
+- }
+-
+- [Obsolete]
+- public void Write (Type type, object val)
+- {
+- if (type == typeof (void))
+- return;
+-
+- if (type.IsArray) {
+- MethodInfo miDict = typeof (MessageWriter).GetMethod ("WriteArray");
+- MethodInfo mi = miDict.MakeGenericMethod (type.GetElementType ());
+- mi.Invoke (this, new object[] {val});
+- } else if (type == typeof (ObjectPath)) {
+- Write ((ObjectPath)val);
+- } else if (type == typeof (Signature)) {
+- Write ((Signature)val);
+- } else if (type == typeof (object)) {
+- Write (val);
+- } else if (type == typeof (string)) {
+- Write ((string)val);
+- } else if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) {
+- Type[] genArgs = type.GetGenericArguments ();
+- MethodInfo miDict = typeof (MessageWriter).GetMethod ("WriteFromDict");
+- MethodInfo mi = miDict.MakeGenericMethod (genArgs);
+- mi.Invoke (this, new object[] {val});
+- } else if (Mapper.IsPublic (type)) {
+- WriteObject (type, val);
+- } else if (!type.IsPrimitive && !type.IsEnum) {
+- WriteValueType (val, type);
+- } else {
+- Write (Signature.TypeToDType (type), val);
+- }
+- }
+-
+- //helper method, should not be used as it boxes needlessly
+- public void Write (DType dtype, object val)
+- {
+- switch (dtype)
+- {
+- case DType.Byte:
+- {
+- Write ((byte)val);
+- }
+- break;
+- case DType.Boolean:
+- {
+- Write ((bool)val);
+- }
+- break;
+- case DType.Int16:
+- {
+- Write ((short)val);
+- }
+- break;
+- case DType.UInt16:
+- {
+- Write ((ushort)val);
+- }
+- break;
+- case DType.Int32:
+- {
+- Write ((int)val);
+- }
+- break;
+- case DType.UInt32:
+- {
+- Write ((uint)val);
+- }
+- break;
+- case DType.Int64:
+- {
+- Write ((long)val);
+- }
+- break;
+- case DType.UInt64:
+- {
+- Write ((ulong)val);
+- }
+- break;
+-#if !DISABLE_SINGLE
+- case DType.Single:
+- {
+- Write ((float)val);
+- }
+- break;
+-#endif
+- case DType.Double:
+- {
+- Write ((double)val);
+- }
+- break;
+- case DType.String:
+- {
+- Write ((string)val);
+- }
+- break;
+- case DType.ObjectPath:
+- {
+- Write ((ObjectPath)val);
+- }
+- break;
+- case DType.Signature:
+- {
+- Write ((Signature)val);
+- }
+- break;
+- case DType.Variant:
+- {
+- Write ((object)val);
+- }
+- break;
+- default:
+- throw new Exception ("Unhandled D-Bus type: " + dtype);
+- }
+- }
+-
+- public void WriteObject (Type type, object val)
+- {
+- ObjectPath path;
+-
+- BusObject bobj = val as BusObject;
+-
+- if (bobj == null && val is MarshalByRefObject) {
+- bobj = ((MarshalByRefObject)val).GetLifetimeService () as BusObject;
+- }
+-
+- if (bobj == null)
+- throw new Exception ("No object reference to write");
+-
+- path = bobj.Path;
+-
+- Write (path);
+- }
+-
+- //variant
+- public void Write (object val)
+- {
+- if (val == null)
+- throw new NotSupportedException ("Cannot send null variant");
+-
+- if (val is DValue) {
+- DValue dv = (DValue)val;
+-
+- if (dv.endianness != endianness)
+- throw new NotImplementedException ("Writing opposite endian DValues not yet implemented.");
+-
+- Write (dv.signature);
+- WritePad (dv.signature.Alignment);
+- stream.Write (dv.data, 0, dv.data.Length);
+- return;
+- }
+-
+- Type type = val.GetType ();
+-
+- WriteVariant (type, val);
+- }
+-
+- public void WriteVariant (Type type, object val)
+- {
+- Signature sig = Signature.GetSig (type);
+-
+- Write (sig);
+- Write (type, val);
+- }
+-
+- //this requires a seekable stream for now
+- public unsafe void WriteArray<T> (T[] val)
+- {
+- Type elemType = typeof (T);
+-
+- if (elemType == typeof (byte)) {
+- if (val.Length > Protocol.MaxArrayLength)
+- throw new Exception ("Array length " + val.Length + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes");
+-
+- Write ((uint)val.Length);
+- stream.Write ((byte[])(object)val, 0, val.Length);
+- return;
+- }
+-
+- if (elemType.IsEnum)
+- elemType = Enum.GetUnderlyingType (elemType);
+-
+- Signature sigElem = Signature.GetSig (elemType);
+- int fixedSize = 0;
+- if (endianness == Connection.NativeEndianness && elemType.IsValueType && !sigElem.IsStruct && sigElem.GetFixedSize (ref fixedSize)) {
+- int byteLength = fixedSize * val.Length;
+- if (byteLength > Protocol.MaxArrayLength)
+- throw new Exception ("Array length " + byteLength + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes");
+- Write ((uint)byteLength);
+- WritePad (sigElem.Alignment);
+-
+- GCHandle valHandle = GCHandle.Alloc (val, GCHandleType.Pinned);
+- IntPtr p = valHandle.AddrOfPinnedObject ();
+- byte[] data = new byte[byteLength];
+- byte* bp = (byte*)p;
+- for (int i = 0 ; i != byteLength ; i++)
+- data[i] = bp[i];
+- stream.Write (data, 0, data.Length);
+- valHandle.Free ();
+- return;
+- }
+-
+- long origPos = stream.Position;
+- Write ((uint)0);
+-
+- //advance to the alignment of the element
+- WritePad (sigElem.Alignment);
+-
+- long startPos = stream.Position;
+-
+- TypeWriter<T> tWriter = TypeImplementer.GetTypeWriter<T> ();
+-
+- foreach (T elem in val)
+- tWriter (this, elem);
+-
+- long endPos = stream.Position;
+- uint ln = (uint)(endPos - startPos);
+- stream.Position = origPos;
+-
+- if (ln > Protocol.MaxArrayLength)
+- throw new Exception ("Array length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes");
+-
+- Write (ln);
+- stream.Position = endPos;
+- }
+-
+- public void WriteValueType (object val, Type type)
+- {
+- MethodInfo mi = TypeImplementer.GetWriteMethod (type);
+- mi.Invoke (null, new object[] {this, val});
+- }
+-
+- public void WriteStructure<T> (T value)
+- {
+- TypeWriter<T> tWriter = TypeImplementer.GetTypeWriter<T> ();
+- tWriter (this, value);
+- }
+-
+- public void WriteFromDict<TKey,TValue> (IDictionary<TKey,TValue> val)
+- {
+- long origPos = stream.Position;
+- Write ((uint)0);
+-
+- WritePad (8);
+-
+- long startPos = stream.Position;
+-
+- TypeWriter<TKey> keyWriter = TypeImplementer.GetTypeWriter<TKey> ();
+- TypeWriter<TValue> valueWriter = TypeImplementer.GetTypeWriter<TValue> ();
+-
+- foreach (KeyValuePair<TKey,TValue> entry in val)
+- {
+- WritePad (8);
+- keyWriter (this, entry.Key);
+- valueWriter (this, entry.Value);
+- }
+-
+- long endPos = stream.Position;
+- uint ln = (uint)(endPos - startPos);
+- stream.Position = origPos;
+-
+- if (ln > Protocol.MaxArrayLength)
+- throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes");
+-
+- Write (ln);
+- stream.Position = endPos;
+- }
+-
+- /*
+- public void Write (IDictionary<FieldCode, object> val)
+- {
+- WriteHeaderDict(val);
+- }
+-
+- public void Write (Dictionary<FieldCode, object> val)
+- {
+- WriteHeaderDict (val);
+- }
+- */
+-
+- /*
+- public void Write (Dictionary<byte, object> val)
+- {
+- long origPos = stream.Position;
+- Write ((uint)0);
+-
+- WritePad (8);
+-
+- long startPos = stream.Position;
+-
+- foreach (KeyValuePair<byte, object> entry in val) {
+- WritePad (8);
+- Write (entry.Key);
+- Write (entry.Value);
+- }
+-
+- long endPos = stream.Position;
+- uint ln = (uint)(endPos - startPos);
+- stream.Position = origPos;
+-
+- if (ln > Protocol.MaxArrayLength)
+- throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes");
+-
+- Write (ln);
+- stream.Position = endPos;
+- }
+- */
+-
+- internal void WriteHeaderFields (Dictionary<byte, object> val)
+- {
+- long origPos = stream.Position;
+- Write ((uint)0);
+-
+- WritePad (8);
+-
+- long startPos = stream.Position;
+-
+- foreach (KeyValuePair<byte, object> entry in val) {
+- WritePad (8);
+- Write (entry.Key);
+- switch ((FieldCode)entry.Key) {
+- case FieldCode.Destination:
+- case FieldCode.ErrorName:
+- case FieldCode.Interface:
+- case FieldCode.Member:
+- case FieldCode.Sender:
+- Write (Signature.StringSig);
+- Write ((string)entry.Value);
+- break;
+- case FieldCode.Path:
+- Write (Signature.ObjectPathSig);
+- Write ((ObjectPath)entry.Value);
+- break;
+- case FieldCode.ReplySerial:
+- Write (Signature.UInt32Sig);
+- Write ((uint)entry.Value);
+- break;
+- default:
+- Write (entry.Value);
+- break;
+- }
+- }
+-
+- long endPos = stream.Position;
+- uint ln = (uint)(endPos - startPos);
+- stream.Position = origPos;
+-
+- if (ln > Protocol.MaxArrayLength)
+- throw new Exception ("Dict length " + ln + " exceeds maximum allowed " + Protocol.MaxArrayLength + " bytes");
+-
+- Write (ln);
+- stream.Position = endPos;
+- }
+-
+- public void WriteNull ()
+- {
+- stream.WriteByte (0);
+- }
+-
+- // Source buffer for zero-padding
+- static readonly byte[] nullBytes = new byte[8];
+- public void WritePad (int alignment)
+- {
+- int needed = Protocol.PadNeeded ((int)stream.Position, alignment);
+- stream.Write (nullBytes, 0, needed);
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/PendingCall.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/PendingCall.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,111 +0,0 @@
+-// Copyright 2007 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Threading;
+-
+-namespace NDesk.DBus
+-{
+- class PendingCall : IAsyncResult
+- {
+- Connection conn;
+- Message reply = null;
+- //AutoResetEvent waitHandle = new AutoResetEvent (false);
+- ManualResetEvent waitHandle;
+-
+- public PendingCall (Connection conn)
+- {
+- this.conn = conn;
+- }
+-
+- public Message Reply
+- {
+- get {
+- if (reply != null)
+- return reply;
+-
+- if (Thread.CurrentThread == conn.mainThread) {
+- /*
+- while (reply == null)
+- conn.Iterate ();
+- */
+-
+- while (reply == null)
+- conn.HandleMessage (conn.Transport.ReadMessage ());
+-
+- completedSync = true;
+-
+- conn.DispatchSignals ();
+- } else {
+- if (waitHandle == null)
+- waitHandle = new ManualResetEvent (false);
+-
+- // TODO: Possible race condition?
+- while (reply == null)
+- waitHandle.WaitOne ();
+-
+- completedSync = false;
+- }
+-
+- return reply;
+- } set {
+- if (reply != null)
+- throw new Exception ("Cannot handle reply more than once");
+-
+- reply = value;
+-
+- if (waitHandle != null)
+- waitHandle.Set ();
+-
+- if (Completed != null)
+- Completed (reply);
+- }
+- }
+-
+- public event Action<Message> Completed;
+- bool completedSync;
+-
+- public void Cancel ()
+- {
+- throw new NotImplementedException ();
+- }
+-
+-
+-
+- #region IAsyncResult Members
+-
+- object IAsyncResult.AsyncState
+- {
+- get {
+- return conn;
+- }
+- }
+-
+- WaitHandle IAsyncResult.AsyncWaitHandle
+- {
+- get {
+- if (waitHandle == null)
+- waitHandle = new ManualResetEvent (false);
+-
+- return waitHandle;
+- }
+- }
+-
+- bool IAsyncResult.CompletedSynchronously
+- {
+- get {
+- return reply != null && completedSync;
+- }
+- }
+-
+- bool IAsyncResult.IsCompleted
+- {
+- get {
+- return reply != null;
+- }
+- }
+-
+- #endregion
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Protocol.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Protocol.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,497 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Collections.Generic;
+-
+-namespace NDesk.DBus
+-{
+- //yyyyuua{yv}
+- //struct Header
+- class Header
+- {
+- public EndianFlag Endianness;
+- public MessageType MessageType;
+- public HeaderFlag Flags;
+- public byte MajorVersion;
+- public uint Length;
+- public uint Serial;
+- //public HeaderField[] Fields;
+-
+- // Dictionary keyed by Enum has performance issues on .NET
+- // So we key by byte and use an indexer instead.
+- public Dictionary<byte, object> Fields;
+- public object this[FieldCode key]
+- {
+- get
+- {
+- object value = null;
+- Fields.TryGetValue ((byte)key, out value);
+- return value;
+- } set {
+- if (value == null)
+- Fields.Remove((byte)key);
+- else
+- Fields[(byte)key] = value;
+- }
+- }
+-
+- /*
+- public static DType TypeForField (FieldCode f)
+- {
+- switch (f) {
+- case FieldCode.Invalid:
+- return DType.Invalid;
+- case FieldCode.Path:
+- return DType.ObjectPath;
+- case FieldCode.Interface:
+- return DType.String;
+- case FieldCode.Member:
+- return DType.String;
+- case FieldCode.ErrorName:
+- return DType.String;
+- case FieldCode.ReplySerial:
+- return DType.UInt32;
+- case FieldCode.Destination:
+- return DType.String;
+- case FieldCode.Sender:
+- return DType.String;
+- case FieldCode.Signature:
+- return DType.Signature;
+-#if PROTO_REPLY_SIGNATURE
+- case FieldCode.ReplySignature: //note: not supported in dbus
+- return DType.Signature;
+-#endif
+- default:
+- return DType.Invalid;
+- }
+- }
+- */
+- }
+-
+- /*
+- public struct HeaderField
+- {
+- //public HeaderField (FieldCode code, object value)
+- //{
+- // this.Code = code;
+- // this.Value = value;
+- //}
+-
+- public static HeaderField Create (FieldCode code, object value)
+- {
+- HeaderField hf;
+-
+- hf.Code = code;
+- hf.Value = value;
+-
+- return hf;
+- }
+-
+- public FieldCode Code;
+- public object Value;
+- }
+- */
+-
+- /*
+- struct HeaderFieldSet
+- {
+- public ObjectPath Path;
+- public string Interface;
+- public string Member;
+- public string ErrorName;
+- public uint ReplySerial;
+- public string Destination;
+- public string Sender;
+- //public Signature Signature;
+- public Signature Sig;
+-
+-#if PROTO_REPLY_SIGNATURE
+- public Signature ReplySignature;
+-#endif
+-
+- public void Read (MessageReader reader)
+- {
+- FieldCode code = (FieldCode)reader.ReadByte ();
+- }
+-
+- public void Write (MessageWriter writer)
+- {
+- // TODO: Write overall length
+-
+- if (Path != null) {
+- writer.WritePad (8);
+- writer.Write ((byte)FieldCode.Path);
+- writer.Write (Signature.ObjectPathSig);
+- writer.Write (Path);
+- }
+-
+- if (Interface != null) {
+- writer.WritePad (8);
+- writer.Write ((byte)FieldCode.Interface);
+- writer.Write (Signature.StringSig);
+- writer.Write (Interface);
+- }
+-
+- if (Member != null) {
+- writer.WritePad (8);
+- writer.Write ((byte)FieldCode.Member);
+- writer.Write (Signature.StringSig);
+- writer.Write (Member);
+- }
+-
+- if (ErrorName != null) {
+- writer.WritePad (8);
+- writer.Write ((byte)FieldCode.ErrorName);
+- writer.Write (Signature.StringSig);
+- writer.Write (ErrorName);
+- }
+-
+- if (ReplySerial != 0) {
+- writer.WritePad (8);
+- writer.Write ((byte)FieldCode.ReplySerial);
+- writer.Write (Signature.UInt32Sig);
+- writer.Write (ReplySerial);
+- }
+-
+- if (Destination != null) {
+- writer.WritePad (8);
+- writer.Write ((byte)FieldCode.Destination);
+- writer.Write (Signature.StringSig);
+- writer.Write (Destination);
+- }
+-
+- if (Sender != null) {
+- writer.WritePad (8);
+- writer.Write ((byte)FieldCode.Sender);
+- writer.Write (Signature.StringSig);
+- writer.Write (Sender);
+- }
+-
+- if (Sig != Signature.Empty) {
+- writer.WritePad (8);
+- writer.Write ((byte)FieldCode.Signature);
+- writer.Write (Signature.SignatureSig);
+- writer.Write (Sig);
+- }
+- }
+- }
+- */
+-
+- enum MessageType : byte
+- {
+- //This is an invalid type.
+- Invalid,
+- //Method call.
+- MethodCall,
+- //Method reply with returned data.
+- MethodReturn,
+- //Error reply. If the first argument exists and is a string, it is an error message.
+- Error,
+- //Signal emission.
+- Signal,
+- }
+-
+- enum FieldCode : byte
+- {
+- Invalid,
+- Path,
+- Interface,
+- Member,
+- ErrorName,
+- ReplySerial,
+- Destination,
+- Sender,
+- Signature,
+-#if PROTO_REPLY_SIGNATURE
+- ReplySignature, //note: not supported in dbus
+-#endif
+- }
+-
+- enum EndianFlag : byte
+- {
+- Little = (byte)'l',
+- Big = (byte)'B',
+- }
+-
+- [Flags]
+- enum HeaderFlag : byte
+- {
+- None = 0,
+- NoReplyExpected = 0x1,
+- NoAutoStart = 0x2,
+- }
+-
+- public sealed class ObjectPath : IComparable, IComparable<ObjectPath>, IEquatable<ObjectPath>
+- {
+- public static readonly ObjectPath Root = new ObjectPath ("/");
+-
+- internal readonly string Value;
+-
+- public ObjectPath (string value)
+- {
+- if (value == null)
+- throw new ArgumentNullException ("value");
+-
+- this.Value = value;
+- }
+-
+- public int CompareTo (ObjectPath other)
+- {
+- if (other == null)
+- return 1;
+-
+- return Value.CompareTo (other.Value);
+- }
+-
+- public int CompareTo (object otherObject)
+- {
+- ObjectPath other = otherObject as ObjectPath;
+-
+- if (other == null)
+- return 1;
+-
+- return Value.CompareTo (other.Value);
+- }
+-
+- public bool Equals (ObjectPath other)
+- {
+- if (other == null)
+- return false;
+-
+- return Value == other.Value;
+- }
+-
+- public override bool Equals (object o)
+- {
+- ObjectPath b = o as ObjectPath;
+-
+- if (b == null)
+- return false;
+-
+- return Value.Equals (b.Value);
+- }
+-
+- public static bool operator == (ObjectPath a, ObjectPath b)
+- {
+- object aa = a, bb = b;
+- if (aa == null && bb == null)
+- return true;
+-
+- if (aa == null || bb == null)
+- return false;
+-
+- return a.Value == b.Value;
+- }
+-
+- public static bool operator != (ObjectPath a, ObjectPath b)
+- {
+- return !(a == b);
+- }
+-
+- public override int GetHashCode ()
+- {
+- return Value.GetHashCode ();
+- }
+-
+- public override string ToString ()
+- {
+- return Value;
+- }
+-
+- //this may or may not prove useful
+- internal string[] Decomposed
+- {
+- get {
+- return Value.Split (new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
+- /*
+- } set {
+- Value = String.Join ("/", value);
+- */
+- }
+- }
+-
+- internal ObjectPath Parent
+- {
+- get {
+- if (Value == Root.Value)
+- return null;
+-
+- string par = Value.Substring (0, Value.LastIndexOf ('/'));
+- if (par == String.Empty)
+- par = "/";
+-
+- return new ObjectPath (par);
+- }
+- }
+-
+- /*
+- public int CompareTo (object value)
+- {
+- return 1;
+- }
+-
+- public int CompareTo (ObjectPath value)
+- {
+- return 1;
+- }
+-
+- public bool Equals (ObjectPath value)
+- {
+- return false;
+- }
+- */
+- }
+-
+- static class Protocol
+- {
+- //protocol versions that we support
+- public const byte MinVersion = 0;
+- public const byte Version = 1;
+- public const byte MaxVersion = Version + 1;
+-
+- public const uint MaxMessageLength = 134217728; //2 to the 27th power
+- public const uint MaxArrayLength = 67108864; //2 to the 26th power
+- public const uint MaxSignatureLength = 255;
+- public const uint MaxArrayDepth = 32;
+- public const uint MaxStructDepth = 32;
+-
+- //this is not strictly related to Protocol since names are passed around as strings
+- internal const uint MaxNameLength = 255;
+- internal const uint MaxMatchRuleLength = 1024;
+- internal const uint MaxMatchRuleArgs = 64;
+-
+- public static int PadNeeded (int pos, int alignment)
+- {
+- int pad = pos % alignment;
+- pad = pad == 0 ? 0 : alignment - pad;
+-
+- return pad;
+- }
+-
+- public static int Padded (int pos, int alignment)
+- {
+- int pad = pos % alignment;
+- if (pad != 0)
+- pos += alignment - pad;
+-
+- return pos;
+- }
+-
+- public static int GetAlignment (DType dtype)
+- {
+- switch (dtype) {
+- case DType.Byte:
+- return 1;
+- case DType.Boolean:
+- return 4;
+- case DType.Int16:
+- case DType.UInt16:
+- return 2;
+- case DType.Int32:
+- case DType.UInt32:
+- return 4;
+- case DType.Int64:
+- case DType.UInt64:
+- return 8;
+-#if !DISABLE_SINGLE
+- case DType.Single: //Not yet supported!
+- return 4;
+-#endif
+- case DType.Double:
+- return 8;
+- case DType.String:
+- return 4;
+- case DType.ObjectPath:
+- return 4;
+- case DType.Signature:
+- return 1;
+- case DType.Array:
+- return 4;
+- case DType.Struct:
+- case DType.StructBegin:
+- return 8;
+- case DType.Variant:
+- return 1;
+- case DType.DictEntry:
+- case DType.DictEntryBegin:
+- return 8;
+- case DType.Invalid:
+- default:
+- throw new Exception ("Cannot determine alignment of " + dtype);
+- }
+- }
+-
+- //this class may not be the best place for Verbose
+- public readonly static bool Verbose;
+-
+- static Protocol ()
+- {
+- Verbose = !String.IsNullOrEmpty (Environment.GetEnvironmentVariable ("DBUS_VERBOSE"));
+- }
+- }
+-
+- // Currently only for internal use on exported objects
+- class BusException : Exception
+- {
+- public BusException (string errorName, string errorMessage)
+- {
+- this.ErrorName = errorName;
+- this.ErrorMessage = errorMessage;
+- }
+-
+- public BusException (string errorName, string format, params object[] args)
+- {
+- this.ErrorName = errorName;
+- this.ErrorMessage = String.Format (format, args);
+- }
+-
+- public override string Message
+- {
+- get
+- {
+- return ErrorName + ": " + ErrorMessage;
+- }
+- }
+-
+- public readonly string ErrorName;
+-
+- public readonly string ErrorMessage;
+- }
+-
+-#if UNDOCUMENTED_IN_SPEC
+-/*
+-"org.freedesktop.DBus.Error.Failed"
+-"org.freedesktop.DBus.Error.NoMemory"
+-"org.freedesktop.DBus.Error.ServiceUnknown"
+-"org.freedesktop.DBus.Error.NameHasNoOwner"
+-"org.freedesktop.DBus.Error.NoReply"
+-"org.freedesktop.DBus.Error.IOError"
+-"org.freedesktop.DBus.Error.BadAddress"
+-"org.freedesktop.DBus.Error.NotSupported"
+-"org.freedesktop.DBus.Error.LimitsExceeded"
+-"org.freedesktop.DBus.Error.AccessDenied"
+-"org.freedesktop.DBus.Error.AuthFailed"
+-"org.freedesktop.DBus.Error.NoServer"
+-"org.freedesktop.DBus.Error.Timeout"
+-"org.freedesktop.DBus.Error.NoNetwork"
+-"org.freedesktop.DBus.Error.AddressInUse"
+-"org.freedesktop.DBus.Error.Disconnected"
+-"org.freedesktop.DBus.Error.InvalidArgs"
+-"org.freedesktop.DBus.Error.FileNotFound"
+-"org.freedesktop.DBus.Error.UnknownMethod"
+-"org.freedesktop.DBus.Error.TimedOut"
+-"org.freedesktop.DBus.Error.MatchRuleNotFound"
+-"org.freedesktop.DBus.Error.MatchRuleInvalid"
+-"org.freedesktop.DBus.Error.Spawn.ExecFailed"
+-"org.freedesktop.DBus.Error.Spawn.ForkFailed"
+-"org.freedesktop.DBus.Error.Spawn.ChildExited"
+-"org.freedesktop.DBus.Error.Spawn.ChildSignaled"
+-"org.freedesktop.DBus.Error.Spawn.Failed"
+-"org.freedesktop.DBus.Error.UnixProcessIdUnknown"
+-"org.freedesktop.DBus.Error.InvalidSignature"
+-"org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown"
+-*/
+-#endif
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Server.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Server.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,503 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.IO;
+-using System.Net;
+-using System.Net.Sockets;
+-using System.Threading;
+-
+-#if ENABLE_PIPES
+-using System.IO.Pipes;
+-#endif
+-
+-namespace NDesk.DBus
+-{
+- using Unix;
+- using Transports;
+- using Authentication;
+-
+- //TODO: complete this class
+- abstract class Server
+- {
+- // Was Listen()
+- public static Server ListenAt (string address)
+- {
+- AddressEntry[] entries = NDesk.DBus.Address.Parse (address);
+-
+- foreach (AddressEntry entry in entries) {
+- try {
+- switch (entry.Method) {
+- case "tcp":
+- return new TcpServer (entry.ToString ());
+- case "unix":
+- return new UnixServer (entry.ToString ());
+-#if ENABLE_PIPES
+- case "win":
+- return new WinServer (entry.ToString ());
+-#endif
+- }
+- } catch (Exception e) {
+- if (Protocol.Verbose)
+- Console.Error.WriteLine (e.Message);
+- }
+- }
+-
+- // TODO: Should call Listen on the Server?
+-
+- return null;
+-
+- /*
+- server.address = address;
+-
+- server.Id = entry.GUID;
+- if (server.Id == UUID.Zero)
+- server.Id = UUID.Generate ();
+- */
+- }
+-
+- public abstract void Listen ();
+-
+- public abstract void Disconnect ();
+-
+- public virtual bool IsConnected
+- {
+- get {
+- return true;
+- }
+- }
+-
+- internal string address;
+- public string Address
+- {
+- get {
+- return address;
+- }
+- }
+-
+- public UUID Id = UUID.Zero;
+-
+- public abstract event Action<Connection> NewConnection;
+-
+- // FIXME: The follow fields do not belong here!
+- // TODO: Make these a thread-specific CallContext prop
+- [ThreadStatic]
+- public Connection CurrentMessageConnection;
+- [ThreadStatic]
+- public Message CurrentMessage;
+- public ServerBus SBus = null;
+- }
+-
+- class UnixServer : Server
+- {
+- string unixPath = null;
+- bool isAbstract;
+-
+- public UnixServer (string address)
+- {
+- AddressEntry[] entries = NDesk.DBus.Address.Parse (address);
+- AddressEntry entry = entries[0];
+-
+- if (entry.Method != "unix")
+- throw new Exception ();
+-
+- string val;
+- if (entry.Properties.TryGetValue ("path", out val)) {
+- unixPath = val;
+- isAbstract = false;
+- } else if (entry.Properties.TryGetValue ("abstract", out val)) {
+- unixPath = val;
+- isAbstract = true;
+- }
+-
+- if (String.IsNullOrEmpty (unixPath))
+- throw new Exception ("Address path is invalid");
+-
+- if (entry.GUID == UUID.Zero)
+- entry.GUID = UUID.Generate ();
+- Id = entry.GUID;
+-
+- /*
+- Id = entry.GUID;
+- if (Id == UUID.Zero)
+- Id = UUID.Generate ();
+- */
+-
+- this.address = entry.ToString ();
+- //Console.WriteLine ("Server address: " + Address);
+- }
+-
+- public override void Disconnect ()
+- {
+- }
+-
+- bool AcceptClient (UnixSocket csock, out ServerConnection conn)
+- {
+- //TODO: use the right abstraction here, probably using the Server class
+- UnixNativeTransport transport = new UnixNativeTransport ();
+- //client.Client.Blocking = true;
+- transport.socket = csock;
+- transport.SocketHandle = (long)csock.Handle;
+- transport.Stream = new UnixStream (csock);
+- //Connection conn = new Connection (transport);
+- //Connection conn = new ServerConnection (transport);
+- //ServerConnection conn = new ServerConnection (transport);
+- conn = new ServerConnection (transport);
+- conn.Server = this;
+- conn.Id = Id;
+-
+- if (conn.Transport.Stream.ReadByte () != 0)
+- return false;
+-
+- conn.isConnected = true;
+-
+- SaslPeer remote = new SaslPeer ();
+- remote.stream = transport.Stream;
+- SaslServer local = new SaslServer ();
+- local.stream = transport.Stream;
+- local.Guid = Id;
+-
+- local.Peer = remote;
+- remote.Peer = local;
+-
+- bool success = local.Authenticate ();
+-
+- Console.WriteLine ("Success? " + success);
+-
+- if (!success)
+- return false;
+-
+- conn.UserId = ((SaslServer)local).uid;
+-
+- conn.isAuthenticated = true;
+-
+- return true;
+- }
+-
+- public override void Listen ()
+- {
+- byte[] sa = isAbstract ? UnixNativeTransport.GetSockAddrAbstract (unixPath) : UnixNativeTransport.GetSockAddr (unixPath);
+- UnixSocket usock = new UnixSocket ();
+- usock.Bind (sa);
+- usock.Listen (50);
+-
+- while (true) {
+- Console.WriteLine ("Waiting for client on " + (isAbstract ? "abstract " : String.Empty) + "path " + unixPath);
+- UnixSocket csock = usock.Accept ();
+- Console.WriteLine ("Client connected");
+-
+- ServerConnection conn;
+- if (!AcceptClient (csock, out conn)) {
+- Console.WriteLine ("Client rejected");
+- csock.Close ();
+- continue;
+- }
+-
+- //GLib.Idle.Add (delegate {
+-
+- if (NewConnection != null)
+- NewConnection (conn);
+-
+- //BusG.Init (conn);
+- /*
+- conn.Iterate ();
+- Console.WriteLine ("done iter");
+- BusG.Init (conn);
+- Console.WriteLine ("done init");
+- */
+-
+- //GLib.Idle.Add (delegate { BusG.Init (conn); return false; });
+- #if USE_GLIB
+- BusG.Init (conn);
+- #else
+- new Thread (new ThreadStart (delegate { while (conn.IsConnected) conn.Iterate (); })).Start ();
+- #endif
+- Console.WriteLine ("done init");
+-
+-
+- //return false;
+- //});
+- }
+- }
+-
+- /*
+- public void ConnectionLost (Connection conn)
+- {
+- }
+- */
+-
+- public override event Action<Connection> NewConnection;
+- }
+-
+- class TcpServer : Server
+- {
+- uint port = 0;
+- public TcpServer (string address)
+- {
+- AddressEntry[] entries = NDesk.DBus.Address.Parse (address);
+- AddressEntry entry = entries[0];
+-
+- if (entry.Method != "tcp")
+- throw new Exception ();
+-
+- string val;
+- if (entry.Properties.TryGetValue ("port", out val))
+- port = UInt32.Parse (val);
+-
+- if (entry.GUID == UUID.Zero)
+- entry.GUID = UUID.Generate ();
+- Id = entry.GUID;
+-
+- /*
+- Id = entry.GUID;
+- if (Id == UUID.Zero)
+- Id = UUID.Generate ();
+- */
+-
+- this.address = entry.ToString ();
+- //Console.WriteLine ("Server address: " + Address);
+- }
+-
+- public override void Disconnect ()
+- {
+- }
+-
+- bool AcceptClient (TcpClient client, out ServerConnection conn)
+- {
+- //TODO: use the right abstraction here, probably using the Server class
+- SocketTransport transport = new SocketTransport ();
+- client.Client.Blocking = true;
+- transport.SocketHandle = (long)client.Client.Handle;
+- transport.Stream = client.GetStream ();
+- //Connection conn = new Connection (transport);
+- //Connection conn = new ServerConnection (transport);
+- //ServerConnection conn = new ServerConnection (transport);
+- conn = new ServerConnection (transport);
+- conn.Server = this;
+- conn.Id = Id;
+-
+- if (conn.Transport.Stream.ReadByte () != 0)
+- return false;
+-
+- conn.isConnected = true;
+-
+- SaslPeer remote = new SaslPeer ();
+- remote.stream = transport.Stream;
+- SaslServer local = new SaslServer ();
+- local.stream = transport.Stream;
+- local.Guid = Id;
+-
+- local.Peer = remote;
+- remote.Peer = local;
+-
+- bool success = local.Authenticate ();
+-
+- Console.WriteLine ("Success? " + success);
+-
+- if (!success)
+- return false;
+-
+- conn.UserId = ((SaslServer)local).uid;
+-
+- conn.isAuthenticated = true;
+-
+- return true;
+- }
+-
+- public override void Listen ()
+- {
+- TcpListener server = new TcpListener (IPAddress.Any, (int)port);
+- server.Server.Blocking = true;
+-
+- server.Start ();
+-
+- while (true) {
+- //Console.WriteLine ("Waiting for client on TCP port " + port);
+- TcpClient client = server.AcceptTcpClient ();
+- /*
+- client.NoDelay = true;
+- client.ReceiveBufferSize = (int)Protocol.MaxMessageLength;
+- client.SendBufferSize = (int)Protocol.MaxMessageLength;
+- */
+- //Console.WriteLine ("Client connected");
+-
+- ServerConnection conn;
+- if (!AcceptClient (client, out conn)) {
+- Console.WriteLine ("Client rejected");
+- client.Close ();
+- continue;
+- }
+-
+- //client.Client.Blocking = false;
+-
+-
+- //GLib.Idle.Add (delegate {
+-
+- if (NewConnection != null)
+- NewConnection (conn);
+-
+- //BusG.Init (conn);
+- /*
+- conn.Iterate ();
+- Console.WriteLine ("done iter");
+- BusG.Init (conn);
+- Console.WriteLine ("done init");
+- */
+-
+- //GLib.Idle.Add (delegate { BusG.Init (conn); return false; });
+- #if USE_GLIB
+- BusG.Init (conn);
+- #else
+- new Thread (new ThreadStart (delegate { while (conn.IsConnected) conn.Iterate (); })).Start ();
+- #endif
+- //Console.WriteLine ("done init");
+-
+- //return false;
+- //});
+- }
+- }
+-
+- /*
+- public void ConnectionLost (Connection conn)
+- {
+- }
+- */
+-
+- public override event Action<Connection> NewConnection;
+- }
+-
+- #if ENABLE_PIPES
+- class WinServer : Server
+- {
+- string pipePath;
+-
+- public WinServer (string address)
+- {
+- AddressEntry[] entries = NDesk.DBus.Address.Parse (address);
+- AddressEntry entry = entries[0];
+-
+- if (entry.Method != "win")
+- throw new Exception ();
+-
+- string val;
+- if (entry.Properties.TryGetValue ("path", out val)) {
+- pipePath = val;
+- }
+-
+- if (String.IsNullOrEmpty (pipePath))
+- throw new Exception ("Address path is invalid");
+-
+- if (entry.GUID == UUID.Zero)
+- entry.GUID = UUID.Generate ();
+- Id = entry.GUID;
+-
+- /*
+- Id = entry.GUID;
+- if (Id == UUID.Zero)
+- Id = UUID.Generate ();
+- */
+-
+- this.address = entry.ToString ();
+- Console.WriteLine ("Server address: " + Address);
+- }
+-
+- public override void Disconnect ()
+- {
+- }
+-
+- bool AcceptClient (PipeStream client, out ServerConnection conn)
+- {
+- PipeTransport transport = new PipeTransport ();
+- //client.Client.Blocking = true;
+- //transport.SocketHandle = (long)client.Client.Handle;
+- transport.Stream = client;
+- conn = new ServerConnection (transport);
+- conn.Server = this;
+- conn.Id = Id;
+-
+- if (conn.Transport.Stream.ReadByte () != 0)
+- return false;
+-
+- conn.isConnected = true;
+-
+- SaslPeer remote = new SaslPeer ();
+- remote.stream = transport.Stream;
+- SaslServer local = new SaslServer ();
+- local.stream = transport.Stream;
+- local.Guid = Id;
+-
+- local.Peer = remote;
+- remote.Peer = local;
+-
+- bool success = local.Authenticate ();
+- //bool success = true;
+-
+- Console.WriteLine ("Success? " + success);
+-
+- if (!success)
+- return false;
+-
+- conn.UserId = ((SaslServer)local).uid;
+-
+- conn.isAuthenticated = true;
+-
+- return true;
+- }
+-
+- static int numPipeThreads = 16;
+-
+- public override void Listen ()
+- {
+- // TODO: Use a ThreadPool to have an adaptive number of reusable threads.
+- for (int i = 0; i != numPipeThreads; i++) {
+- Thread newThread = new Thread (new ThreadStart (DoListen));
+- newThread.Name = "DBusPipeServer" + i;
+- // Hack to allow shutdown without Joining threads for now.
+- newThread.IsBackground = true;
+- newThread.Start ();
+- }
+-
+- Console.WriteLine ("Press enter to exit.");
+- Console.ReadLine ();
+- }
+-
+- void DoListen ()
+- {
+- while (true)
+- using (NamedPipeServerStream pipeServer = new NamedPipeServerStream (pipePath, PipeDirection.InOut, numPipeThreads, PipeTransmissionMode.Byte, PipeOptions.Asynchronous, (int)Protocol.MaxMessageLength, (int)Protocol.MaxMessageLength)) {
+- Console.WriteLine ("Waiting for client on path " + pipePath);
+- pipeServer.WaitForConnection ();
+-
+- Console.WriteLine ("Client connected");
+-
+- ServerConnection conn;
+- if (!AcceptClient (pipeServer, out conn)) {
+- Console.WriteLine ("Client rejected");
+- pipeServer.Disconnect ();
+- continue;
+- }
+-
+- pipeServer.Flush ();
+- pipeServer.WaitForPipeDrain ();
+-
+- if (NewConnection != null)
+- NewConnection (conn);
+-
+- while (conn.IsConnected)
+- conn.Iterate ();
+-
+- pipeServer.Disconnect ();
+- }
+- }
+-
+- /*
+- public void ConnectionLost (Connection conn)
+- {
+- }
+- */
+-
+- public override event Action<Connection> NewConnection;
+- }
+-#endif
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/ServerBus.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/ServerBus.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,715 +0,0 @@
+-// Copyright 2009 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-//#define USE_GLIB
+-
+-using System;
+-using System.Collections.Generic;
+-using System.Diagnostics;
+-using System.IO;
+-using System.Threading;
+-
+-using NDesk.DBus.Transports;
+-using org.freedesktop.DBus;
+-
+-namespace NDesk.DBus
+-{
+- public class ServerBus : org.freedesktop.DBus.IBus
+- {
+- public static readonly ObjectPath Path = new ObjectPath ("/org/freedesktop/DBus");
+- public const string DBusBusName = "org.freedesktop.DBus";
+- public const string DBusInterface = "org.freedesktop.DBus";
+-
+- static string ValidateBusName (string name)
+- {
+- if (name == String.Empty)
+- return "cannot be empty";
+- //if (name.StartsWith (":"))
+- // return "cannot be a unique name";
+- return null;
+- }
+-
+- static bool BusNameIsValid (string name, out string nameError)
+- {
+- nameError = ValidateBusName (name);
+- return nameError == null;
+- }
+-
+- readonly List<Connection> conns = new List<Connection> ();
+-
+- internal Server server;
+-
+- ServerConnection Caller
+- {
+- get
+- {
+- return server.CurrentMessageConnection as ServerConnection;
+- }
+- }
+-
+- public void AddConnection (Connection conn)
+- {
+- if (conns.Contains (conn))
+- throw new Exception ("Cannot add connection");
+-
+- conns.Add (conn);
+- conn.Register (Path, this);
+- //((ExportObject)conn.RegisteredObjects[Path]).Registered = false;
+- }
+-
+- public void RemoveConnection (Connection conn)
+- {
+- Console.Error.WriteLine ("RemoveConn");
+-
+- if (!conns.Remove (conn))
+- throw new Exception ("Cannot remove connection");
+-
+- //conn.Unregister (Path);
+-
+- List<string> namesToDisown = new List<string> ();
+- foreach (KeyValuePair<string, Connection> pair in Names) {
+- if (pair.Value == conn)
+- namesToDisown.Add (pair.Key);
+- }
+-
+- List<MatchRule> toRemove = new List<MatchRule> ();
+- foreach (KeyValuePair<MatchRule, List<Connection>> pair in Rules) {
+- //while (pair.Value.Remove (Caller)) { }
+- while (pair.Value.Remove (conn)) { }
+- //while (pair.Value.Remove (Caller)) { Console.WriteLine ("Remove!"); }
+- //pair.Value.RemoveAll ( delegate (Connection conn) { conn == Caller; } )
+- if (pair.Value.Count == 0)
+- toRemove.Add (pair.Key);
+- //Rules.Remove (pair);
+- //Rules.Remove<KeyValuePair<MatchRule,List<Connection>>> (pair);
+- //((ICollection<System.Collections.Generic.KeyValuePair<MatchRule,List<Connection>>>)Rules).Remove<KeyValuePair<MatchRule,List<Connection>>> (pair);
+- //((ICollection<System.Collections.Generic.KeyValuePair<MatchRule,List<Connection>>>)Rules).Remove (pair);
+- }
+-
+- foreach (MatchRule r in toRemove)
+- Rules.Remove (r);
+-
+- // TODO: Check the order of signals
+- // TODO: Atomicity
+-
+- foreach (string name in namesToDisown)
+- Names.Remove (name);
+-
+- foreach (string name in namesToDisown)
+- NameOwnerChanged (name, ((ServerConnection)conn).UniqueName, String.Empty);
+-
+- // TODO: Unregister earlier?
+- conn.Unregister (Path);
+- }
+-
+- struct NameRequisition
+- {
+- public NameRequisition (Connection connection, bool allowReplacement)
+- {
+- this.Connection = connection;
+- this.AllowReplacement = allowReplacement;
+- }
+-
+- public readonly Connection Connection;
+- public readonly bool AllowReplacement;
+- }
+-
+- //SortedList<>
+- readonly Dictionary<string, Connection> Names = new Dictionary<string, Connection> ();
+- //readonly SortedList<string,Connection> Names = new SortedList<string,Connection> ();
+- //readonly SortedDictionary<string,Connection> Names = new SortedDictionary<string,Connection> ();
+- public RequestNameReply RequestName (string name, NameFlag flags)
+- {
+- Console.Error.WriteLine ("RequestName " + name);
+- string nameError;
+- if (!BusNameIsValid (name, out nameError))
+- throw new ArgumentException (String.Format ("Requested name \"{0}\" is not valid: {1}", name, nameError), "name");
+-
+- if (name.StartsWith (":"))
+- throw new ArgumentException (String.Format ("Cannot acquire a name starting with ':' such as \"{0}\"", name), "name");
+-
+- if (name == DBusBusName)
+- throw new ArgumentException (String.Format ("Connection \"{0}\" is not allowed to own the name \"{1}\" because it is reserved for D-Bus' use only", Caller.UniqueName ?? "(inactive)", name), "name");
+-
+- // TODO: Policy delegate support
+-
+- // TODO: NameFlag support
+-
+- if (flags != NameFlag.None)
+- Console.Error.WriteLine ("Warning: Ignoring unimplemented NameFlags: " + flags);
+-
+- Connection c;
+- if (!Names.TryGetValue (name, out c)) {
+- Names[name] = Caller;
+- RaiseNameSignal ("Acquired", name);
+- NameOwnerChanged (name, String.Empty, Caller.UniqueName);
+-
+- Message activationMessage;
+- if (activationMessages.TryGetValue (name, out activationMessage)) {
+- activationMessages.Remove (name);
+- Caller.SendReal (activationMessage);
+- }
+-
+- return RequestNameReply.PrimaryOwner;
+- } else if (c == Caller)
+- return RequestNameReply.AlreadyOwner;
+- else
+- return RequestNameReply.Exists;
+- }
+-
+- public ReleaseNameReply ReleaseName (string name)
+- {
+- string nameError;
+- if (!BusNameIsValid (name, out nameError))
+- throw new ArgumentException (String.Format ("Given bus name \"{0}\" is not valid: {1}", name, nameError), "name");
+-
+- if (name.StartsWith (":"))
+- throw new ArgumentException (String.Format ("Cannot release a name starting with ':' such as \"{0}\"", name), "name");
+-
+- if (name == DBusBusName)
+- throw new ArgumentException (String.Format ("Cannot release the \"{0}\" name because it is owned by the bus", name), "name");
+-
+- Connection c;
+- if (!Names.TryGetValue (name, out c))
+- return ReleaseNameReply.NonExistent;
+-
+- if (c != Caller)
+- return ReleaseNameReply.NotOwner;
+-
+- Names.Remove (name);
+- // TODO: Does official daemon send NameLost signal here? Do the same.
+- RaiseNameSignal ("Lost", name);
+- NameOwnerChanged (name, Caller.UniqueName, String.Empty);
+- return ReleaseNameReply.Released;
+- }
+-
+- int uniqueMajor = 1;
+- int uniqueMinor = -1;
+-
+- string CreateUniqueName ()
+- {
+- int newMajor = uniqueMajor;
+- int newMinor = Interlocked.Increment (ref uniqueMinor);
+-
+- // Major wrapping should probably be made atomic too.
+- if (newMinor == Int32.MaxValue) {
+- if (uniqueMajor == Int32.MaxValue)
+- uniqueMajor = 1;
+- else
+- uniqueMajor++;
+- uniqueMinor = -1;
+- }
+-
+- string uniqueName = String.Format (":{0}.{1}", newMajor, newMinor);
+-
+- // We could check if the unique name already has an owner here for absolute correctness.
+- Debug.Assert (!NameHasOwner (uniqueName));
+-
+- return uniqueName;
+- }
+-
+- public string Hello ()
+- {
+- if (Caller.UniqueName != null)
+- throw new DBusException ("Failed", "Already handled an Hello message");
+-
+- string uniqueName = CreateUniqueName ();
+-
+- Console.Error.WriteLine ("Hello " + uniqueName + "!");
+- Caller.UniqueName = uniqueName;
+- Names[uniqueName] = Caller;
+-
+- // TODO: Verify the order in which these messages are sent.
+- //NameAcquired (uniqueName);
+- RaiseNameSignal ("Acquired", uniqueName);
+- NameOwnerChanged (uniqueName, String.Empty, uniqueName);
+-
+- return uniqueName;
+- }
+-
+- void RaiseNameSignal (string memberSuffix, string name)
+- {
+- // Name* signals on org.freedesktop.DBus are connection-specific.
+- // We handle them here as a special case.
+-
+- Signal nameSignal = new Signal (Path, DBusInterface, "Name" + memberSuffix);
+- MessageWriter mw = new MessageWriter ();
+- mw.Write (name);
+- nameSignal.message.Body = mw.ToArray ();
+- nameSignal.message.Signature = Signature.StringSig;
+- Caller.Send (nameSignal.message);
+- }
+-
+- public string[] ListNames ()
+- {
+- List<string> names = new List<string> ();
+- names.Add (DBusBusName);
+- names.AddRange (Names.Keys);
+- return names.ToArray ();
+- }
+-
+- public string[] ListActivatableNames ()
+- {
+- List<string> names = new List<string> ();
+- names.AddRange (services.Keys);
+- return names.ToArray ();
+- }
+-
+- public bool NameHasOwner (string name)
+- {
+- if (name == DBusBusName)
+- return true;
+-
+- return Names.ContainsKey (name);
+- }
+-
+- public event NameOwnerChangedHandler NameOwnerChanged;
+- public event NameLostHandler NameLost;
+- public event NameAcquiredHandler NameAcquired;
+-
+- public StartReply StartServiceByName (string name, uint flags)
+- {
+- if (name == DBusBusName)
+- return StartReply.AlreadyRunning;
+-
+- if (Names.ContainsKey (name))
+- return StartReply.AlreadyRunning;
+-
+- if (!StartProcessNamed (name))
+- throw new DBusException ("Spawn.ServiceNotFound", "The name {0} was not provided by any .service files", name);
+-
+- return StartReply.Success;
+- }
+-
+- Dictionary<string, string> activationEnv = new Dictionary<string, string> ();
+- public void UpdateActivationEnvironment (IDictionary<string, string> environment)
+- {
+- foreach (KeyValuePair<string, string> pair in environment) {
+- if (pair.Key == String.Empty)
+- continue;
+- if (pair.Value == String.Empty)
+- activationEnv.Remove (pair.Key);
+- else
+- activationEnv[pair.Key] = pair.Value;
+- }
+- }
+-
+- public string GetNameOwner (string name)
+- {
+- if (name == DBusBusName)
+- return DBusBusName;
+-
+- Connection c;
+- if (!Names.TryGetValue (name, out c))
+- throw new DBusException ("NameHasNoOwner", "Could not get owner of name '{0}': no such name", name);
+-
+- return ((ServerConnection)c).UniqueName;
+- }
+-
+- public uint GetConnectionUnixUser (string name)
+- {
+- if (name == DBusBusName)
+- return (uint)Process.GetCurrentProcess ().Id;
+-
+- Connection c;
+- if (!Names.TryGetValue (name, out c))
+- throw new DBusException ("NameHasNoOwner", "Could not get UID of name '{0}': no such name", name);
+-
+- if (((ServerConnection)c).UserId == 0)
+- throw new DBusException ("Failed", "Could not determine UID for '{0}'", name);
+-
+- return (uint)((ServerConnection)c).UserId;
+- }
+-
+- Dictionary<string, Message> activationMessages = new Dictionary<string, Message> ();
+-
+- internal void HandleMessage (Message msg)
+- {
+- if (msg == null)
+- return;
+-
+- //List<Connection> recipients = new List<Connection> ();
+- HashSet<Connection> recipients = new HashSet<Connection> ();
+- //HashSet<Connection> recipientsAll = new HashSet<Connection> (Connections);
+-
+- object fieldValue = msg.Header[FieldCode.Destination];
+- if (fieldValue != null) {
+- string destination = (string)fieldValue;
+- Connection destConn;
+- if (Names.TryGetValue (destination, out destConn))
+- recipients.Add (destConn);
+- else if (destination != DBusBusName && !destination.StartsWith (":") && (msg.Header.Flags & HeaderFlag.NoAutoStart) != HeaderFlag.NoAutoStart) {
+- // Attempt activation
+- StartProcessNamed (destination);
+- //Thread.Sleep (5000);
+- // TODO: Route the message to the newly activated service!
+- activationMessages[destination] = msg;
+- //if (Names.TryGetValue (destination, out destConn))
+- // recipients.Add (destConn);
+- //else
+- // Console.Error.WriteLine ("Couldn't route message to activated service");
+- } else if (destination != DBusBusName) {
+- // Send an error when there's no hope of getting the requested reply
+- if (msg.ReplyExpected) {
+- // Error org.freedesktop.DBus.Error.ServiceUnknown: The name {0} was not provided by any .service files
+- Message rmsg = MessageHelper.CreateUnknownMethodError (new MethodCall (msg));
+- if (rmsg != null) {
+- //Caller.Send (rmsg);
+- Caller.SendReal (rmsg);
+- return;
+- }
+- }
+-
+- }
+- }
+-
+- HashSet<Connection> recipientsMatchingHeader = new HashSet<Connection> ();
+-
+- HashSet<ArgMatchTest> a = new HashSet<ArgMatchTest> ();
+- foreach (KeyValuePair<MatchRule, List<Connection>> pair in Rules) {
+- if (recipients.IsSupersetOf (pair.Value))
+- continue;
+- if (pair.Key.MatchesHeader (msg)) {
+- a.UnionWith (pair.Key.Args);
+- recipientsMatchingHeader.UnionWith (pair.Value);
+- }
+- }
+-
+- MatchRule.Test (a, msg);
+-
+- foreach (KeyValuePair<MatchRule, List<Connection>> pair in Rules) {
+- if (recipients.IsSupersetOf (pair.Value))
+- continue;
+- if (!recipientsMatchingHeader.IsSupersetOf (pair.Value))
+- continue;
+- if (a.IsSupersetOf (pair.Key.Args))
+- recipients.UnionWith (pair.Value);
+- }
+-
+- foreach (Connection conn in recipients) {
+- // TODO: rewrite/don't header fields
+- //conn.Send (msg);
+- // TODO: Zero the Serial or not?
+- //msg.Header.Serial = 0;
+- ((ServerConnection)conn).SendReal (msg);
+- }
+- }
+-
+- //SortedDictionary<MatchRule,int> Rules = new SortedDictionary<MatchRule,int> ();
+- //Dictionary<MatchRule,int> Rules = new Dictionary<MatchRule,int> ();
+- Dictionary<MatchRule, List<Connection>> Rules = new Dictionary<MatchRule, List<Connection>> ();
+- public void AddMatch (string rule)
+- {
+- MatchRule r = MatchRule.Parse (rule);
+-
+- if (r == null)
+- throw new Exception ("r == null");
+-
+- if (!Rules.ContainsKey (r))
+- Rules[r] = new List<Connection> ();
+-
+- // Each occurrence of a Connection in the list represents one value-unique AddMatch call
+- Rules[r].Add (Caller);
+-
+- Console.WriteLine ("Added. Rules count: " + Rules.Count);
+- }
+-
+- public void RemoveMatch (string rule)
+- {
+- MatchRule r = MatchRule.Parse (rule);
+-
+- if (r == null)
+- throw new Exception ("r == null");
+-
+- if (!Rules.ContainsKey (r))
+- throw new Exception ();
+-
+- // We remove precisely one occurrence of the calling connection
+- Rules[r].Remove (Caller);
+- if (Rules[r].Count == 0)
+- Rules.Remove (r);
+-
+- Console.WriteLine ("Removed. Rules count: " + Rules.Count);
+- }
+-
+- public string GetId ()
+- {
+- return Caller.Id.ToString ();
+- }
+-
+- // Undocumented in spec
+- public string[] ListQueuedOwners (string name)
+- {
+- // ?
+- if (name == DBusBusName)
+- return new string[] { DBusBusName };
+-
+- Connection c;
+- if (!Names.TryGetValue (name, out c))
+- throw new DBusException ("NameHasNoOwner", "Could not get owners of name '{0}': no such name", name);
+-
+- return new string[] { ((ServerConnection)c).UniqueName };
+- }
+-
+- // Undocumented in spec
+- public uint GetConnectionUnixProcessID (string connection_name)
+- {
+- Connection c;
+- if (!Names.TryGetValue (connection_name, out c))
+- throw new DBusException ("NameHasNoOwner", "Could not get PID of name '{0}': no such name", connection_name);
+-
+- uint pid;
+- if (!c.Transport.TryGetPeerPid (out pid))
+- throw new DBusException ("UnixProcessIdUnknown", "Could not determine PID for '{0}'", connection_name);
+-
+- return pid;
+- }
+-
+- // Undocumented in spec
+- public byte[] GetConnectionSELinuxSecurityContext (string connection_name)
+- {
+- throw new DBusException ("SELinuxSecurityContextUnknown", "Could not determine security context for '{0}'", connection_name);
+- }
+-
+- // Undocumented in spec
+- public void ReloadConfig ()
+- {
+- ScanServices ();
+- }
+-
+- Dictionary<string, string> services = new Dictionary<string, string> ();
+- public string svcPath = "/usr/share/dbus-1/services";
+- public void ScanServices ()
+- {
+- services.Clear ();
+-
+- string[] svcs = Directory.GetFiles (svcPath, "*.service");
+- foreach (string svc in svcs) {
+- string fname = System.IO.Path.Combine (svcPath, svc);
+- using (TextReader r = new StreamReader (fname)) {
+- string ln;
+- string cmd = null;
+- string name = null;
+- while ((ln = r.ReadLine ()) != null) {
+- if (ln.StartsWith ("Exec="))
+- cmd = ln.Remove (0, 5);
+- else if (ln.StartsWith ("Name="))
+- name = ln.Remove (0, 5);
+- }
+-
+- // TODO: use XdgNet
+- // TODO: Validate names and trim strings
+- if (name != null && cmd != null)
+- services[name] = cmd;
+- }
+- }
+- }
+-
+- public bool allowActivation = false;
+- bool StartProcessNamed (string name)
+- {
+- Console.Error.WriteLine ("Start " + name);
+-
+- if (!allowActivation)
+- return false;
+-
+- string cmd;
+- if (!services.TryGetValue (name, out cmd))
+- return false;
+-
+- try {
+- StartProcess (cmd);
+- } catch (Exception e) {
+- Console.Error.WriteLine (e);
+- return false;
+- }
+-
+- return true;
+- }
+-
+- // Can be "session" or "system"
+- public string busType = "session";
+-
+- void StartProcess (string fname)
+- {
+- if (!allowActivation)
+- return;
+-
+- try {
+- ProcessStartInfo startInfo = new ProcessStartInfo (fname);
+- startInfo.UseShellExecute = false;
+-
+- foreach (KeyValuePair<string, string> pair in activationEnv) {
+- startInfo.EnvironmentVariables[pair.Key] = pair.Value;
+- }
+-
+- startInfo.EnvironmentVariables["DBUS_STARTER_BUS_TYPE"] = busType;
+- startInfo.EnvironmentVariables["DBUS_" + busType.ToUpper () + "_BUS_ADDRESS"] = server.address;
+- startInfo.EnvironmentVariables["DBUS_STARTER_ADDRESS"] = server.address;
+- startInfo.EnvironmentVariables["DBUS_STARTER_BUS_TYPE"] = busType;
+- Process myProcess = Process.Start (startInfo);
+- } catch (Exception e) {
+- Console.Error.WriteLine (e);
+- }
+- }
+- }
+-
+- class ServerConnection : Connection
+- {
+- public Server Server;
+-
+- public ServerConnection (Transport t)
+- : base (t)
+- {
+- }
+-
+- bool shouldDump = false;
+-
+- override internal void HandleMessage (Message msg)
+- {
+- if (!isConnected)
+- return;
+-
+- if (msg == null) {
+- Console.Error.WriteLine ("Disconnected!");
+- isConnected = false;
+- //Server.Bus.RemoveConnection (this);
+- //ServerBus sbus = Unregister (new ObjectPath ("/org/freedesktop/DBus")) as ServerBus;
+-
+- /*
+- ServerBus sbus = Unregister (new ObjectPath ("/org/freedesktop/DBus")) as ServerBus;
+- Register (new ObjectPath ("/org/freedesktop/DBus"), sbus);
+- sbus.RemoveConnection (this);
+- */
+-
+- Server.SBus.RemoveConnection (this);
+-
+- //Server.ConnectionLost (this);
+- return;
+- }
+-
+- Server.CurrentMessageConnection = this;
+- Server.CurrentMessage = msg;
+-
+- try {
+- if (shouldDump) {
+- MessageDumper.WriteComment ("Handling:", Console.Out);
+- MessageDumper.WriteMessage (msg, Console.Out);
+- }
+-
+- if (UniqueName != null)
+- msg.Header[FieldCode.Sender] = UniqueName;
+-
+- object fieldValue = msg.Header[FieldCode.Destination];
+- if (fieldValue != null) {
+- if ((string)fieldValue == ServerBus.DBusBusName) {
+-
+- // Workaround for our daemon only listening on a single path
+- if (msg.Header.MessageType == NDesk.DBus.MessageType.MethodCall)
+- msg.Header[FieldCode.Path] = ServerBus.Path;
+-
+- base.HandleMessage (msg);
+- //return;
+- }
+- }
+- //base.HandleMessage (msg);
+-
+- Server.SBus.HandleMessage (msg);
+- } finally {
+- Server.CurrentMessageConnection = null;
+- Server.CurrentMessage = null;
+- }
+- }
+-
+- override internal uint Send (Message msg)
+- {
+- if (!isConnected)
+- return 0;
+-
+- /*
+- if (msg.Header.MessageType == NDesk.DBus.MessageType.Signal) {
+- Signal signal = new Signal (msg);
+- if (signal.Member == "NameAcquired" || signal.Member == "NameLost") {
+- string dest = (string)msg.Header[FieldCode.Destination];
+- if (dest != UniqueName)
+- return 0;
+- }
+- }
+- */
+-
+- if (msg.Header.MessageType != NDesk.DBus.MessageType.MethodReturn) {
+- msg.Header[FieldCode.Sender] = ServerBus.DBusBusName;
+- }
+-
+- if (UniqueName != null)
+- msg.Header[FieldCode.Destination] = UniqueName;
+-
+- if (shouldDump) {
+- MessageDumper.WriteComment ("Sending:", Console.Out);
+- MessageDumper.WriteMessage (msg, Console.Out);
+- }
+-
+- //return base.Send (msg);
+- return SendReal (msg);
+- }
+-
+- internal uint SendReal (Message msg)
+- {
+- if (!isConnected)
+- return 0;
+-
+- try {
+- return base.Send (msg);
+- } catch {
+- //} catch (System.IO.IOException) {
+- isConnected = false;
+- Server.SBus.RemoveConnection (this);
+- }
+- return 0;
+- }
+-
+- //ServerBus SBus;
+- public string UniqueName = null;
+- public long UserId = 0;
+-
+- ~ServerConnection ()
+- {
+- Console.Error.WriteLine ("Good! ~ServerConnection () for {0}", UniqueName ?? "(inactive)");
+- }
+- }
+-
+- internal class BusContext
+- {
+- protected Connection connection = null;
+- public Connection Connection
+- {
+- get
+- {
+- return connection;
+- }
+- }
+-
+- protected Message message = null;
+- internal Message CurrentMessage
+- {
+- get
+- {
+- return message;
+- }
+- }
+-
+- public string SenderName = null;
+- }
+-
+- class DBusException : BusException
+- {
+- public DBusException (string errorNameSuffix, string format, params object[] args)
+- : base (ServerBus.DBusInterface + ".Error." + errorNameSuffix, format, args)
+- {
+- // Note: This won't log ArgumentExceptions which are used in some places.
+- if (Protocol.Verbose)
+- Console.Error.WriteLine (Message);
+- }
+- }
+-}
+\ No newline at end of file
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Signature.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Signature.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,897 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Text;
+-
+-using System.Collections.Generic;
+-//TODO: Reflection should be done at a higher level than this class
+-using System.Reflection;
+-
+-namespace NDesk.DBus
+-{
+- //maybe this should be nullable?
+- struct Signature
+- {
+- //TODO: this class needs some work
+- //Data should probably include the null terminator
+-
+- public static readonly Signature Empty = new Signature (String.Empty);
+- public static readonly Signature ByteSig = Allocate (DType.Byte);
+- public static readonly Signature UInt16Sig = Allocate (DType.UInt16);
+- public static readonly Signature UInt32Sig = Allocate (DType.UInt32);
+- public static readonly Signature StringSig = Allocate (DType.String);
+- public static readonly Signature ObjectPathSig = Allocate (DType.ObjectPath);
+- public static readonly Signature SignatureSig = Allocate (DType.Signature);
+- public static readonly Signature VariantSig = Allocate (DType.Variant);
+-
+- public static bool operator == (Signature a, Signature b)
+- {
+- if (a.data == b.data)
+- return true;
+-
+- if (a.data == null)
+- return false;
+-
+- if (b.data == null)
+- return false;
+-
+- if (a.data.Length != b.data.Length)
+- return false;
+-
+- for (int i = 0 ; i != a.data.Length ; i++)
+- if (a.data[i] != b.data[i])
+- return false;
+-
+- return true;
+- }
+-
+- public static bool operator != (Signature a, Signature b)
+- {
+- return !(a == b);
+- }
+-
+- public override bool Equals (object o)
+- {
+- if (o == null)
+- return false;
+-
+- if (!(o is Signature))
+- return false;
+-
+- return this == (Signature)o;
+- }
+-
+- public override int GetHashCode ()
+- {
+- // TODO: Avoid string conversion
+- return Value.GetHashCode ();
+- }
+-
+- public static Signature operator + (Signature s1, Signature s2)
+- {
+- return Concat (s1, s2);
+- }
+-
+- public static Signature Concat (Signature s1, Signature s2)
+- {
+- if (s1.data == null && s2.data == null)
+- return Signature.Empty;
+-
+- if (s1.data == null)
+- return s2;
+-
+- if (s2.data == null)
+- return s1;
+-
+- if (s1.Length + s2.Length == 0)
+- return Signature.Empty;
+-
+- byte[] data = new byte[s1.data.Length + s2.data.Length];
+- s1.data.CopyTo (data, 0);
+- s2.data.CopyTo (data, s1.data.Length);
+- return Signature.Take (data);
+- }
+-
+- public Signature (string value)
+- {
+- if (value.Length == 0) {
+- this.data = Empty.data;
+- return;
+- }
+-
+- if (value.Length == 1) {
+- this.data = DataForDType ((DType)value[0]);
+- return;
+- }
+-
+- this.data = Encoding.ASCII.GetBytes (value);
+- }
+-
+- internal static Signature Take (byte[] value)
+- {
+- Signature sig;
+-
+- if (value.Length == 0) {
+- sig.data = Empty.data;
+- return sig;
+- }
+-
+- if (value.Length == 1) {
+- sig.data = DataForDType ((DType)value[0]);
+- return sig;
+- }
+-
+- sig.data = value;
+- return sig;
+- }
+-
+- static byte[] DataForDType (DType value)
+- {
+- // Reduce heap allocations.
+- // For now, we only cache the most common protocol signatures.
+- switch (value) {
+- case DType.Byte:
+- return ByteSig.data;
+- case DType.UInt16:
+- return UInt16Sig.data;
+- case DType.UInt32:
+- return UInt32Sig.data;
+- case DType.String:
+- return StringSig.data;
+- case DType.ObjectPath:
+- return ObjectPathSig.data;
+- case DType.Signature:
+- return SignatureSig.data;
+- case DType.Variant:
+- return VariantSig.data;
+- default:
+- return new byte[] {(byte)value};
+- }
+- }
+-
+- private static Signature Allocate (DType value)
+- {
+- Signature sig;
+- sig.data = new byte[] {(byte)value};
+- return sig;
+- }
+-
+- internal Signature (DType value)
+- {
+- this.data = DataForDType (value);
+- }
+-
+- internal Signature (DType[] value)
+- {
+- if (value.Length == 0) {
+- this.data = Empty.data;
+- return;
+- }
+-
+- if (value.Length == 1) {
+- this.data = DataForDType (value[0]);
+- return;
+- }
+-
+- this.data = new byte[value.Length];
+-
+- for (int i = 0 ; i != value.Length ; i++)
+- this.data[i] = (byte)value[i];
+- }
+-
+- byte[] data;
+-
+- //TODO: this should be private, but MessageWriter and Monitor still use it
+- //[Obsolete]
+- public byte[] GetBuffer ()
+- {
+- return data;
+- }
+-
+- internal DType this[int index]
+- {
+- get {
+- return (DType)data[index];
+- }
+- }
+-
+- public int Length
+- {
+- get {
+- return data.Length;
+- }
+- }
+-
+- //[Obsolete]
+- public string Value
+- {
+- get {
+- //FIXME: hack to handle bad case when Data is null
+- if (data == null)
+- return String.Empty;
+-
+- return Encoding.ASCII.GetString (data);
+- }
+- }
+-
+- public override string ToString ()
+- {
+- return Value;
+-
+- /*
+- StringBuilder sb = new StringBuilder ();
+-
+- foreach (DType t in data) {
+- //we shouldn't rely on object mapping here, but it's an easy way to get string representations for now
+- Type type = DTypeToType (t);
+- if (type != null) {
+- sb.Append (type.Name);
+- } else {
+- char c = (char)t;
+- if (!Char.IsControl (c))
+- sb.Append (c);
+- else
+- sb.Append (@"\" + (int)c);
+- }
+- sb.Append (" ");
+- }
+-
+- return sb.ToString ();
+- */
+- }
+-
+- public Signature MakeArraySignature ()
+- {
+- return new Signature (DType.Array) + this;
+- }
+-
+- public static Signature MakeStruct (params Signature[] elems)
+- {
+- Signature sig = Signature.Empty;
+-
+- sig += new Signature (DType.StructBegin);
+-
+- foreach (Signature elem in elems)
+- sig += elem;
+-
+- sig += new Signature (DType.StructEnd);
+-
+- return sig;
+- }
+-
+- public static Signature MakeDictEntry (Signature keyType, Signature valueType)
+- {
+- Signature sig = Signature.Empty;
+-
+- sig += new Signature (DType.DictEntryBegin);
+-
+- sig += keyType;
+- sig += valueType;
+-
+- sig += new Signature (DType.DictEntryEnd);
+-
+- return sig;
+- }
+-
+- public static Signature MakeDict (Signature keyType, Signature valueType)
+- {
+- return MakeDictEntry (keyType, valueType).MakeArraySignature ();
+- }
+-
+- public int Alignment
+- {
+- get {
+- if (data.Length == 0)
+- return 0;
+-
+- return Protocol.GetAlignment (this[0]);
+- }
+- }
+-
+- static int GetSize (DType dtype)
+- {
+- switch (dtype) {
+- case DType.Byte:
+- return 1;
+- case DType.Boolean:
+- return 4;
+- case DType.Int16:
+- case DType.UInt16:
+- return 2;
+- case DType.Int32:
+- case DType.UInt32:
+- return 4;
+- case DType.Int64:
+- case DType.UInt64:
+- return 8;
+-#if !DISABLE_SINGLE
+- case DType.Single: //Not yet supported!
+- return 4;
+-#endif
+- case DType.Double:
+- return 8;
+- case DType.String:
+- case DType.ObjectPath:
+- case DType.Signature:
+- case DType.Array:
+- case DType.StructBegin:
+- case DType.Variant:
+- case DType.DictEntryBegin:
+- return -1;
+- case DType.Invalid:
+- default:
+- throw new Exception ("Cannot determine size of " + dtype);
+- }
+- }
+-
+- public bool GetFixedSize (ref int size)
+- {
+- if (size < 0)
+- return false;
+-
+- if (data.Length == 0)
+- return true;
+-
+- // Sensible?
+- size = Protocol.Padded (size, Alignment);
+-
+- if (data.Length == 1) {
+- int valueSize = GetSize (this[0]);
+-
+- if (valueSize == -1)
+- return false;
+-
+- size += valueSize;
+- return true;
+- }
+-
+- if (IsStructlike) {
+- foreach (Signature sig in GetParts ())
+- if (!sig.GetFixedSize (ref size))
+- return false;
+- return true;
+- }
+-
+- if (IsArray || IsDict)
+- return false;
+-
+- if (IsStruct) {
+- foreach (Signature sig in GetFieldSignatures ())
+- if (!sig.GetFixedSize (ref size))
+- return false;
+- return true;
+- }
+-
+- // Any other cases?
+- throw new Exception ();
+- }
+-
+- public bool IsFixedSize
+- {
+- get {
+- if (data.Length == 0)
+- return true;
+-
+- if (data.Length == 1) {
+- int size = GetSize (this[0]);
+- return size != -1;
+- }
+-
+- if (IsStructlike) {
+- foreach (Signature sig in GetParts ())
+- if (!sig.IsFixedSize)
+- return false;
+- return true;
+- }
+-
+- if (IsArray || IsDict)
+- return false;
+-
+- if (IsStruct) {
+- foreach (Signature sig in GetFieldSignatures ())
+- if (!sig.IsFixedSize)
+- return false;
+- return true;
+- }
+-
+- // Any other cases?
+- throw new Exception ();
+- }
+- }
+-
+- //TODO: complete this
+- public bool IsPrimitive
+- {
+- get {
+- if (data.Length != 1)
+- return false;
+-
+- if (this[0] == DType.Variant)
+- return false;
+-
+- if (this[0] == DType.Invalid)
+- return false;
+-
+- return true;
+- }
+- }
+-
+- public bool IsStruct
+- {
+- get {
+- if (Length < 2)
+- return false;
+-
+- if (this[0] != DType.StructBegin)
+- return false;
+-
+- // FIXME: Incorrect! What if this is in fact a Structlike starting and finishing with structs?
+- if (this[Length - 1] != DType.StructEnd)
+- return false;
+-
+- return true;
+- }
+- }
+-
+- public bool IsDictEntry
+- {
+- get {
+- if (Length < 2)
+- return false;
+-
+- if (this[0] != DType.DictEntryBegin)
+- return false;
+-
+- // FIXME: Incorrect! What if this is in fact a Structlike starting and finishing with structs?
+- if (this[Length - 1] != DType.DictEntryEnd)
+- return false;
+-
+- return true;
+- }
+- }
+-
+- public bool IsStructlike
+- {
+- get {
+- if (Length < 2)
+- return false;
+-
+- if (IsArray)
+- return false;
+-
+- if (IsDict)
+- return false;
+-
+- if (IsStruct)
+- return false;
+-
+- return true;
+- }
+- }
+-
+- public bool IsDict
+- {
+- get {
+- if (Length < 3)
+- return false;
+-
+- if (!IsArray)
+- return false;
+-
+- // 0 is 'a'
+- if (this[1] != DType.DictEntryBegin)
+- return false;
+-
+- return true;
+- }
+- }
+-
+- public bool IsArray
+- {
+- get {
+- if (Length < 2)
+- return false;
+-
+- if (this[0] != DType.Array)
+- return false;
+-
+- return true;
+- }
+- }
+-
+- public Signature GetElementSignature ()
+- {
+- if (!IsArray)
+- throw new Exception ("Cannot get the element signature of a non-array (signature was '" + this + "')");
+-
+- //TODO: improve this
+- //if (IsDict)
+- // throw new NotSupportedException ("Parsing dict signature is not supported (signature was '" + this + "')");
+-
+- // Skip over 'a'
+- int pos = 1;
+- return GetNextSignature (ref pos);
+- }
+-
+- public Type[] ToTypes ()
+- {
+- // TODO: Find a way to avoid these null checks everywhere.
+- if (data == null)
+- return Type.EmptyTypes;
+-
+- List<Type> types = new List<Type> ();
+- for (int i = 0 ; i != data.Length ; types.Add (ToType (ref i)));
+- return types.ToArray ();
+- }
+-
+- public Type ToType ()
+- {
+- int pos = 0;
+- Type ret = ToType (ref pos);
+- if (pos != data.Length)
+- throw new Exception ("Signature '" + Value + "' is not a single complete type");
+- return ret;
+- }
+-
+- internal static DType TypeCodeToDType (TypeCode typeCode)
+- {
+- switch (typeCode)
+- {
+- case TypeCode.Empty:
+- return DType.Invalid;
+- case TypeCode.Object:
+- return DType.Invalid;
+- case TypeCode.DBNull:
+- return DType.Invalid;
+- case TypeCode.Boolean:
+- return DType.Boolean;
+- case TypeCode.Char:
+- return DType.UInt16;
+- case TypeCode.SByte:
+- return DType.Byte;
+- case TypeCode.Byte:
+- return DType.Byte;
+- case TypeCode.Int16:
+- return DType.Int16;
+- case TypeCode.UInt16:
+- return DType.UInt16;
+- case TypeCode.Int32:
+- return DType.Int32;
+- case TypeCode.UInt32:
+- return DType.UInt32;
+- case TypeCode.Int64:
+- return DType.Int64;
+- case TypeCode.UInt64:
+- return DType.UInt64;
+- case TypeCode.Single:
+- return DType.Single;
+- case TypeCode.Double:
+- return DType.Double;
+- case TypeCode.Decimal:
+- return DType.Invalid;
+- case TypeCode.DateTime:
+- return DType.Invalid;
+- case TypeCode.String:
+- return DType.String;
+- default:
+- return DType.Invalid;
+- }
+- }
+-
+- //FIXME: this method is bad, get rid of it
+- internal static DType TypeToDType (Type type)
+- {
+- if (type == typeof (void))
+- return DType.Invalid;
+-
+- if (type == typeof (string))
+- return DType.String;
+-
+- if (type == typeof (ObjectPath))
+- return DType.ObjectPath;
+-
+- if (type == typeof (Signature))
+- return DType.Signature;
+-
+- if (type == typeof (object))
+- return DType.Variant;
+-
+- if (type.IsPrimitive)
+- return TypeCodeToDType (Type.GetTypeCode (type));
+-
+- if (type.IsEnum)
+- return TypeToDType (Enum.GetUnderlyingType (type));
+-
+- //needs work
+- if (type.IsArray)
+- return DType.Array;
+-
+- //if (type.UnderlyingSystemType != null)
+- // return TypeToDType (type.UnderlyingSystemType);
+- if (Mapper.IsPublic (type))
+- return DType.ObjectPath;
+-
+- if (!type.IsPrimitive && !type.IsEnum)
+- return DType.Struct;
+-
+- //TODO: maybe throw an exception here
+- return DType.Invalid;
+- }
+-
+- /*
+- public static DType TypeToDType (Type type)
+- {
+- if (type == null)
+- return DType.Invalid;
+- else if (type == typeof (byte))
+- return DType.Byte;
+- else if (type == typeof (bool))
+- return DType.Boolean;
+- else if (type == typeof (short))
+- return DType.Int16;
+- else if (type == typeof (ushort))
+- return DType.UInt16;
+- else if (type == typeof (int))
+- return DType.Int32;
+- else if (type == typeof (uint))
+- return DType.UInt32;
+- else if (type == typeof (long))
+- return DType.Int64;
+- else if (type == typeof (ulong))
+- return DType.UInt64;
+- else if (type == typeof (float)) //not supported by libdbus at time of writing
+- return DType.Single;
+- else if (type == typeof (double))
+- return DType.Double;
+- else if (type == typeof (string))
+- return DType.String;
+- else if (type == typeof (ObjectPath))
+- return DType.ObjectPath;
+- else if (type == typeof (Signature))
+- return DType.Signature;
+- else
+- return DType.Invalid;
+- }
+- */
+-
+- public IEnumerable<Signature> GetFieldSignatures ()
+- {
+- if (this == Signature.Empty || this[0] != DType.StructBegin)
+- throw new Exception ("Not a struct");
+-
+- for (int pos = 1 ; pos < data.Length - 1 ;)
+- yield return GetNextSignature (ref pos);
+- }
+-
+- public void GetDictEntrySignatures (out Signature sigKey, out Signature sigValue)
+- {
+- if (this == Signature.Empty || this[0] != DType.DictEntryBegin)
+- throw new Exception ("Not a DictEntry");
+-
+- int pos = 1;
+- sigKey = GetNextSignature (ref pos);
+- sigValue = GetNextSignature (ref pos);
+- }
+-
+- public IEnumerable<Signature> GetParts ()
+- {
+- if (data == null)
+- yield break;
+- for (int pos = 0 ; pos < data.Length ;) {
+- yield return GetNextSignature (ref pos);
+- }
+- }
+-
+- public Signature GetNextSignature (ref int pos)
+- {
+- if (data == null)
+- return Signature.Empty;
+-
+- DType dtype = (DType)data[pos++];
+-
+- switch (dtype) {
+- //case DType.Invalid:
+- // return typeof (void);
+- case DType.Array:
+- //peek to see if this is in fact a dictionary
+- if ((DType)data[pos] == DType.DictEntryBegin) {
+- //skip over the {
+- pos++;
+- Signature keyType = GetNextSignature (ref pos);
+- Signature valueType = GetNextSignature (ref pos);
+- //skip over the }
+- pos++;
+- return Signature.MakeDict (keyType, valueType);
+- } else {
+- Signature elementType = GetNextSignature (ref pos);
+- return elementType.MakeArraySignature ();
+- }
+- //case DType.DictEntryBegin: // FIXME: DictEntries should be handled separately.
+- case DType.StructBegin:
+- //List<Signature> fieldTypes = new List<Signature> ();
+- Signature fieldsSig = Signature.Empty;
+- while ((DType)data[pos] != DType.StructEnd)
+- fieldsSig += GetNextSignature (ref pos);
+- //skip over the )
+- pos++;
+- return Signature.MakeStruct (fieldsSig);
+- //return fieldsSig;
+- case DType.DictEntryBegin:
+- Signature sigKey = GetNextSignature (ref pos);
+- Signature sigValue = GetNextSignature (ref pos);
+- //skip over the }
+- pos++;
+- return Signature.MakeDictEntry (sigKey, sigValue);
+- default:
+- return new Signature (dtype);
+- }
+- }
+-
+- public Type ToType (ref int pos)
+- {
+- // TODO: Find a way to avoid these null checks everywhere.
+- if (data == null)
+- return typeof (void);
+-
+- DType dtype = (DType)data[pos++];
+-
+- switch (dtype) {
+- case DType.Invalid:
+- return typeof (void);
+- case DType.Byte:
+- return typeof (byte);
+- case DType.Boolean:
+- return typeof (bool);
+- case DType.Int16:
+- return typeof (short);
+- case DType.UInt16:
+- return typeof (ushort);
+- case DType.Int32:
+- return typeof (int);
+- case DType.UInt32:
+- return typeof (uint);
+- case DType.Int64:
+- return typeof (long);
+- case DType.UInt64:
+- return typeof (ulong);
+- case DType.Single: ////not supported by libdbus at time of writing
+- return typeof (float);
+- case DType.Double:
+- return typeof (double);
+- case DType.String:
+- return typeof (string);
+- case DType.ObjectPath:
+- return typeof (ObjectPath);
+- case DType.Signature:
+- return typeof (Signature);
+- case DType.Array:
+- //peek to see if this is in fact a dictionary
+- if ((DType)data[pos] == DType.DictEntryBegin) {
+- //skip over the {
+- pos++;
+- Type keyType = ToType (ref pos);
+- Type valueType = ToType (ref pos);
+- //skip over the }
+- pos++;
+- //return typeof (IDictionary<,>).MakeGenericType (new Type[] {keyType, valueType});
+- //workaround for Mono bug #81035 (memory leak)
+- return Mapper.GetGenericType (typeof (IDictionary<,>), new Type[] {keyType, valueType});
+- } else {
+- return ToType (ref pos).MakeArrayType ();
+- }
+- case DType.Struct:
+- return typeof (ValueType);
+- case DType.DictEntry:
+- return typeof (System.Collections.Generic.KeyValuePair<,>);
+- case DType.Variant:
+- return typeof (object);
+- default:
+- throw new NotSupportedException ("Parsing or converting this signature is not yet supported (signature was '" + this + "'), at DType." + dtype);
+- }
+- }
+-
+- public static Signature GetSig (object[] objs)
+- {
+- return GetSig (Type.GetTypeArray (objs));
+- }
+-
+- public static Signature GetSig (Type[] types)
+- {
+- if (types == null)
+- throw new ArgumentNullException ("types");
+-
+- Signature sig = Signature.Empty;
+-
+- foreach (Type type in types)
+- sig += GetSig (type);
+-
+- return sig;
+- }
+-
+- public static Signature GetSig (Type type)
+- {
+- if (type == null)
+- throw new ArgumentNullException ("type");
+-
+- //this is inelegant, but works for now
+- if (type == typeof (Signature))
+- return new Signature (DType.Signature);
+-
+- if (type == typeof (ObjectPath))
+- return new Signature (DType.ObjectPath);
+-
+- if (type == typeof (void))
+- return Signature.Empty;
+-
+- if (type == typeof (string))
+- return new Signature (DType.String);
+-
+- if (type == typeof (object))
+- return new Signature (DType.Variant);
+-
+- if (type.IsArray)
+- return GetSig (type.GetElementType ()).MakeArraySignature ();
+-
+- if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) {
+-
+- Type[] genArgs = type.GetGenericArguments ();
+- return Signature.MakeDict (GetSig (genArgs[0]), GetSig (genArgs[1]));
+- }
+-
+- if (Mapper.IsPublic (type)) {
+- return new Signature (DType.ObjectPath);
+- }
+-
+- if (!type.IsPrimitive && !type.IsEnum) {
+- Signature sig = Signature.Empty;
+-
+- foreach (FieldInfo fi in type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
+- sig += GetSig (fi.FieldType);
+-
+- return Signature.MakeStruct (sig);
+- }
+-
+- DType dtype = Signature.TypeToDType (type);
+- return new Signature (dtype);
+- }
+- }
+-
+- enum ArgDirection
+- {
+- In,
+- Out,
+- }
+-
+- enum DType : byte
+- {
+- Invalid = (byte)'\0',
+-
+- Byte = (byte)'y',
+- Boolean = (byte)'b',
+- Int16 = (byte)'n',
+- UInt16 = (byte)'q',
+- Int32 = (byte)'i',
+- UInt32 = (byte)'u',
+- Int64 = (byte)'x',
+- UInt64 = (byte)'t',
+- Single = (byte)'f', //This is not yet supported!
+- Double = (byte)'d',
+- String = (byte)'s',
+- ObjectPath = (byte)'o',
+- Signature = (byte)'g',
+-
+- Array = (byte)'a',
+- [Obsolete ("Not in protocol")]
+- Struct = (byte)'r',
+- [Obsolete ("Not in protocol")]
+- DictEntry = (byte)'e',
+- Variant = (byte)'v',
+-
+- StructBegin = (byte)'(',
+- StructEnd = (byte)')',
+- DictEntryBegin = (byte)'{',
+- DictEntryEnd = (byte)'}',
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/SocketTransport.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/SocketTransport.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,70 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.IO;
+-using System.Net;
+-using System.Net.Sockets;
+-
+-namespace NDesk.DBus.Transports
+-{
+- class SocketTransport : Transport
+- {
+- internal Socket socket;
+-
+- public override void Open (AddressEntry entry)
+- {
+- string host, portStr, family;
+- int port;
+-
+- if (!entry.Properties.TryGetValue ("host", out host))
+- host = "localhost";
+-
+- if (!entry.Properties.TryGetValue ("port", out portStr))
+- throw new Exception ("No port specified");
+-
+- if (!Int32.TryParse (portStr, out port))
+- throw new Exception ("Invalid port: \"" + port + "\"");
+-
+- if (!entry.Properties.TryGetValue ("family", out family))
+- family = null;
+-
+- Open (host, port, family);
+- }
+-
+- public void Open (string host, int port, string family)
+- {
+- //TODO: use Socket directly
+- TcpClient client = new TcpClient (host, port);
+- /*
+- client.NoDelay = true;
+- client.ReceiveBufferSize = (int)Protocol.MaxMessageLength;
+- client.SendBufferSize = (int)Protocol.MaxMessageLength;
+- */
+- this.socket = client.Client;
+- SocketHandle = (long)client.Client.Handle;
+- Stream = client.GetStream ();
+- }
+-
+- public void Open (Socket socket)
+- {
+- this.socket = socket;
+-
+- socket.Blocking = true;
+- SocketHandle = (long)socket.Handle;
+- //Stream = new UnixStream ((int)socket.Handle);
+- Stream = new NetworkStream (socket);
+- }
+-
+- public override void WriteCred ()
+- {
+- Stream.WriteByte (0);
+- }
+-
+- public override string AuthString ()
+- {
+- return String.Empty;
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Transport.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Transport.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,405 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Collections.Generic;
+-using System.IO;
+-using System.Threading;
+-
+-namespace NDesk.DBus.Transports
+-{
+- abstract class Transport
+- {
+- public static Transport Create (AddressEntry entry)
+- {
+- switch (entry.Method) {
+- case "tcp":
+- {
+- Transport transport = new SocketTransport ();
+- transport.Open (entry);
+- return transport;
+- }
+-#if !PORTABLE
+- case "unix":
+- {
+- //Transport transport = new UnixMonoTransport ();
+- Transport transport = new UnixNativeTransport ();
+- transport.Open (entry);
+- return transport;
+- }
+-#endif
+-#if ENABLE_PIPES
+- case "win": {
+- Transport transport = new PipeTransport ();
+- transport.Open (entry);
+- return transport;
+- }
+-#endif
+- default:
+- throw new NotSupportedException ("Transport method \"" + entry.Method + "\" not supported");
+- }
+- }
+-
+- protected Connection connection;
+-
+- public Connection Connection
+- {
+- get {
+- return connection;
+- } set {
+- connection = value;
+- }
+- }
+-
+- //TODO: design this properly
+-
+- //this is just a temporary solution
+- public Stream Stream;
+- public long SocketHandle;
+- public abstract void Open (AddressEntry entry);
+- public abstract string AuthString ();
+- public abstract void WriteCred ();
+-
+- public virtual bool TryGetPeerPid (out uint pid)
+- {
+- pid = 0;
+- return false;
+- }
+- /*
+- }
+-
+- abstract class StreamTransport : Transport
+- {
+- */
+- Stream ns {
+- get {
+- return this.Stream;
+- }
+- }
+-
+- public virtual void Disconnect ()
+- {
+- ns.Dispose ();
+- }
+-
+- internal Queue<Message> Inbound = new Queue<Message> ();
+-
+- public event EventHandler WakeUp;
+- protected void FireWakeUp ()
+- {
+- if (WakeUp != null)
+- WakeUp (this, EventArgs.Empty);
+- }
+-
+- internal Message TryReadMessage ()
+- {
+- GetData ();
+- if (Inbound.Count > 0)
+- return Inbound.Dequeue ();
+- return null;
+- }
+-
+- public void Iterate ()
+- {
+- GetData ();
+- }
+-
+- internal Message ReadMessage ()
+- {
+- // Hack to complete pending async reads in progress.
+- while (msgRdr != null)
+- GetData ();
+-
+- //return ReadMessageReal ();
+- try {
+- return ReadMessageReal ();
+- } catch (IOException e) {
+- if (Protocol.Verbose)
+- Console.Error.WriteLine (e.Message);
+- connection.isConnected = false;
+- return null;
+- }
+- }
+-
+- int Read (byte[] buffer, int offset, int count)
+- {
+- int read = 0;
+- //System.Net.Sockets.NetworkStream nns = ns as System.Net.Sockets.NetworkStream;
+- //SocketTransport st = this as SocketTransport;
+- while (read < count) {
+- // FIXME: Remove this hack to support non-blocking sockets on Windows
+- //if (st != null && st.socket.Blocking == false && nns != null && !nns.DataAvailable) {
+- /*
+- if (nns != null && !nns.DataAvailable) {
+- System.Threading.Thread.Sleep (10);
+- continue;
+- }
+- */
+- int nread = ns.Read (buffer, offset + read, count - read);
+- if (nread == 0)
+- break;
+- read += nread;
+- }
+-
+- //if (read < count)
+- // throw new Exception ();
+-
+- if (read > count)
+- throw new Exception ();
+-
+- return read;
+- }
+- //protected MemoryStream mbuf = new MemoryStream ();
+- //byte[] mmbuf = new byte[Protocol.MaxMessageLength];
+- byte[] mmbuf = null;
+-
+- int mmpos = 0;
+- int mmneeded = 16;
+- IEnumerator<MsgState> msgRdr;
+- //int nIters = 0;
+- public void GetData ()
+- {
+- //nIters++;
+- //Console.WriteLine ("nIters: " + nIters);
+- if (msgRdr == null) {
+- msgRdr = ReadMessageReal2 ();
+- }
+-
+- /*
+- {
+- System.Net.Sockets.NetworkStream nns = ns as System.Net.Sockets.NetworkStream;
+- SocketTransport st = this as SocketTransport;
+- if (!nns.DataAvailable)
+- return null;
+- }
+- */
+-
+- SocketTransport st = this as SocketTransport;
+-
+- //int nread = ns.Read (mmbuf, mmpos, 16);
+-
+- int avail = st.socket.Available;
+- if (mmneeded == 0)
+- throw new Exception ();
+- //if (avail < mmneeded)
+- // System.Threading.Thread.Sleep (10);
+-
+- if (avail == 0)
+- return;
+-
+- avail = Math.Min (avail, mmneeded);
+- int nread = st.socket.Receive (mmbuf, mmpos, avail, System.Net.Sockets.SocketFlags.None);
+- mmpos += nread;
+- mmneeded -= nread;
+- if (!msgRdr.MoveNext ())
+- throw new Exception ();
+-
+- MsgState state = msgRdr.Current;
+- if (state != MsgState.Done)
+- return;
+-
+- mmpos = 0;
+- mmneeded = 16;
+-
+- msgRdr = null;
+- }
+-
+- enum MsgState
+- {
+- Wait16,
+- WaitHeader,
+- WaitBody,
+- Done,
+- }
+-
+- IEnumerator<MsgState> ReadMessageReal2 ()
+- {
+- byte[] body = null;
+- mmneeded = 16;
+- while (mmpos < 16)
+- yield return MsgState.Wait16;
+-
+- EndianFlag endianness = (EndianFlag)mmbuf[0];
+- MessageReader reader = new MessageReader (endianness, mmbuf);
+-
+- //discard the endian byte as we've already read it
+- reader.ReadByte ();
+-
+- //discard message type and flags, which we don't care about here
+- reader.ReadByte ();
+- reader.ReadByte ();
+-
+- byte version = reader.ReadByte ();
+-
+- if (version < Protocol.MinVersion || version > Protocol.MaxVersion)
+- throw new NotSupportedException ("Protocol version '" + version.ToString () + "' is not supported");
+-
+- if (Protocol.Verbose)
+- if (version != Protocol.Version)
+- Console.Error.WriteLine ("Warning: Protocol version '" + version.ToString () + "' is not explicitly supported but may be compatible");
+-
+- uint bodyLength = reader.ReadUInt32 ();
+- //discard serial
+- reader.ReadUInt32 ();
+- uint headerLength = reader.ReadUInt32 ();
+-
+- //this check may become relevant if a future version of the protocol allows larger messages
+- /*
+- if (bodyLength > Int32.MaxValue || headerLength > Int32.MaxValue)
+- throw new NotImplementedException ("Long messages are not yet supported");
+- */
+-
+- int bodyLen = (int)bodyLength;
+- int toRead = (int)headerLength;
+-
+- //we fixup to include the padding following the header
+- toRead = Protocol.Padded (toRead, 8);
+-
+- long msgLength = toRead + bodyLen;
+- if (msgLength > Protocol.MaxMessageLength)
+- throw new Exception ("Message length " + msgLength + " exceeds maximum allowed " + Protocol.MaxMessageLength + " bytes");
+-
+- byte[] header = new byte[16 + toRead];
+- Array.Copy (mmbuf, header, 16);
+-
+- mmneeded = toRead;
+- while (mmpos < 16 + toRead)
+- yield return MsgState.WaitHeader;
+-
+- Array.Copy (mmbuf, 16, header, 16, toRead);
+-
+- //if (read != toRead)
+- // throw new Exception ("Message header length mismatch: " + read + " of expected " + toRead);
+-
+- mmneeded = bodyLen;
+- while (mmpos < 16 + toRead + bodyLen)
+- yield return MsgState.WaitBody;
+-
+- //read the body
+- if (bodyLen != 0) {
+- body = new byte[bodyLen];
+-
+- Array.Copy (mmbuf, 16 + toRead, body, 0, bodyLen);
+-
+- //if (read != bodyLen)
+- // throw new Exception ("Message body length mismatch: " + read + " of expected " + bodyLen);
+- }
+-
+- Message msg = new Message ();
+- msg.Connection = this.Connection;
+- msg.Body = body;
+- msg.SetHeaderData (header);
+-
+- Inbound.Enqueue (msg);
+-
+- mmneeded = 16;
+-
+- yield return MsgState.Done;
+- }
+-
+- Message ReadMessageReal ()
+- {
+- byte[] header;
+- byte[] body = null;
+-
+- int read;
+-
+- //16 bytes is the size of the fixed part of the header
+- byte[] hbuf = new byte[16];
+- read = Read (hbuf, 0, 16);
+-
+- if (read == 0)
+- return null;
+-
+- if (read != 16)
+- throw new Exception ("Header read length mismatch: " + read + " of expected " + "16");
+-
+- EndianFlag endianness = (EndianFlag)hbuf[0];
+- MessageReader reader = new MessageReader (endianness, hbuf);
+-
+- //discard the endian byte as we've already read it
+- reader.ReadByte ();
+-
+- //discard message type and flags, which we don't care about here
+- reader.ReadByte ();
+- reader.ReadByte ();
+-
+- byte version = reader.ReadByte ();
+-
+- if (version < Protocol.MinVersion || version > Protocol.MaxVersion)
+- throw new NotSupportedException ("Protocol version '" + version.ToString () + "' is not supported");
+-
+- if (Protocol.Verbose)
+- if (version != Protocol.Version)
+- Console.Error.WriteLine ("Warning: Protocol version '" + version.ToString () + "' is not explicitly supported but may be compatible");
+-
+- uint bodyLength = reader.ReadUInt32 ();
+- //discard serial
+- reader.ReadUInt32 ();
+- uint headerLength = reader.ReadUInt32 ();
+-
+- //this check may become relevant if a future version of the protocol allows larger messages
+- /*
+- if (bodyLength > Int32.MaxValue || headerLength > Int32.MaxValue)
+- throw new NotImplementedException ("Long messages are not yet supported");
+- */
+-
+- int bodyLen = (int)bodyLength;
+- int toRead = (int)headerLength;
+-
+- //we fixup to include the padding following the header
+- toRead = Protocol.Padded (toRead, 8);
+-
+- long msgLength = toRead + bodyLen;
+- if (msgLength > Protocol.MaxMessageLength)
+- throw new Exception ("Message length " + msgLength + " exceeds maximum allowed " + Protocol.MaxMessageLength + " bytes");
+-
+- header = new byte[16 + toRead];
+- Array.Copy (hbuf, header, 16);
+-
+- read = Read (header, 16, toRead);
+-
+- if (read != toRead)
+- throw new Exception ("Message header length mismatch: " + read + " of expected " + toRead);
+-
+- //read the body
+- if (bodyLen != 0) {
+- body = new byte[bodyLen];
+-
+- read = Read (body, 0, bodyLen);
+-
+- if (read != bodyLen)
+- throw new Exception ("Message body length mismatch: " + read + " of expected " + bodyLen);
+- }
+-
+- Message msg = new Message ();
+- msg.Connection = this.Connection;
+- msg.Body = body;
+- msg.SetHeaderData (header);
+-
+- return msg;
+- }
+-
+- object writeLock = new object ();
+- internal virtual void WriteMessage (Message msg)
+- {
+- /*
+- byte[] HeaderData = msg.GetHeaderData ();
+-
+- long msgLength = HeaderData.Length + (msg.Body != null ? msg.Body.Length : 0);
+- if (msgLength > Protocol.MaxMessageLength)
+- throw new Exception ("Message length " + msgLength + " exceeds maximum allowed " + Protocol.MaxMessageLength + " bytes");
+- */
+-
+- lock (writeLock) {
+- //ns.Write (HeaderData, 0, HeaderData.Length);
+- msg.GetHeaderDataToStream (ns);
+- if (msg.Body != null && msg.Body.Length != 0)
+- ns.Write (msg.Body, 0, msg.Body.Length);
+- ns.Flush ();
+- }
+-
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/TypeDefiner.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/TypeDefiner.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,227 +0,0 @@
+-// Copyright 2007 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Reflection;
+-using System.Reflection.Emit;
+-using System.Collections.Generic;
+-
+-using System.IO;
+-using System.Xml.Serialization;
+-
+-namespace NDesk.DBus
+-{
+- using Introspection;
+-
+- //FIXME: debug hack
+- public delegate void VoidHandler ();
+-
+- public partial class Connection
+- {
+- //dynamically defines a Type for the proxy object using D-Bus introspection
+- public object GetObject (string bus_name, ObjectPath path)
+- {
+- org.freedesktop.DBus.Introspectable intros = GetObject<org.freedesktop.DBus.Introspectable> (bus_name, path);
+- string data = intros.Introspect ();
+-
+- StringReader sr = new StringReader (data);
+- XmlSerializer sz = new XmlSerializer (typeof (Node));
+- Node node = (Node)sz.Deserialize (sr);
+-
+- Type type = TypeDefiner.Define (node.Interfaces);
+-
+- return GetObject (type, bus_name, path);
+- }
+-
+- //FIXME: debug hack
+- ~Connection ()
+- {
+- if (Protocol.Verbose)
+- TypeDefiner.Save ();
+- }
+- }
+-
+- static class TypeDefiner
+- {
+- static AssemblyBuilder asmBdef;
+- static ModuleBuilder modBdef;
+-
+- static void InitHack ()
+- {
+- if (asmBdef != null)
+- return;
+-
+- asmBdef = AppDomain.CurrentDomain.DefineDynamicAssembly (new AssemblyName ("Defs"), AssemblyBuilderAccess.RunAndSave);
+- //asmBdef = System.Threading.Thread.GetDomain ().DefineDynamicAssembly (new AssemblyName ("DefAssembly"), AssemblyBuilderAccess.RunAndSave);
+- modBdef = asmBdef.DefineDynamicModule ("Defs.dll", "Defs.dll");
+- }
+-
+- static uint ifaceId = 0;
+- public static Type Define (Interface[] ifaces)
+- {
+- InitHack ();
+-
+- //Provide a unique interface name
+- //This is a bit ugly
+- string ifaceName = "Aggregate" + (ifaceId++);
+-
+- TypeBuilder typeB = modBdef.DefineType (ifaceName, TypeAttributes.Public | TypeAttributes.Interface | TypeAttributes.Abstract);
+- foreach (Interface iface in ifaces)
+- typeB.AddInterfaceImplementation (Define (iface));
+-
+- return typeB.CreateType ();
+- }
+-
+- static Type Define (Interface iface)
+- {
+- InitHack ();
+-
+- int lastDotPos = iface.Name.LastIndexOf ('.');
+- string nsName = iface.Name.Substring (0, lastDotPos);
+- string ifaceName = iface.Name.Substring (lastDotPos+1);
+-
+- nsName = nsName.Replace ('.', Type.Delimiter);
+-
+- //using the full interface name is ok, but makes consuming the type from C# difficult since namespaces/Type names may overlap
+- TypeBuilder typeB = modBdef.DefineType (nsName + Type.Delimiter + "I" + ifaceName, TypeAttributes.Public | TypeAttributes.Interface | TypeAttributes.Abstract);
+- Define (typeB, iface);
+-
+- return typeB.CreateType ();
+- }
+-
+- public static void Save ()
+- {
+- asmBdef.Save ("Defs.dll");
+- }
+-
+- const MethodAttributes ifaceMethAttr = MethodAttributes.HideBySig | MethodAttributes.NewSlot | MethodAttributes.Public | MethodAttributes.Abstract | MethodAttributes.Virtual;
+-
+- public static Type DefineHandler (ModuleBuilder modB, NDesk.DBus.Introspection.Signal declSignal)
+- {
+- string dlgName = declSignal.Name + "Handler";
+- TypeBuilder handlerB = modB.DefineType (dlgName, TypeAttributes.Public | TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.AnsiClass | TypeAttributes.AutoClass, typeof (System.MulticastDelegate));
+- const MethodAttributes mattr = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Virtual | MethodAttributes.NewSlot;
+-
+- ConstructorBuilder constructorBuilder = handlerB.DefineConstructor (MethodAttributes.RTSpecialName | MethodAttributes.HideBySig | MethodAttributes.Public, CallingConventions.Standard, new Type[] { typeof (object), typeof (System.IntPtr) });
+- constructorBuilder.SetImplementationFlags (MethodImplAttributes.Runtime | MethodImplAttributes.Managed);
+-
+- //MethodBuilder invokeB = handlerB.DefineMethod ("Invoke", mattr, typeof (void), Type.EmptyTypes);
+- MethodBuilder invokeB = DefineSignal (handlerB, "Invoke", mattr, declSignal.Arguments, true);
+-
+- invokeB.SetImplementationFlags (MethodImplAttributes.Runtime | MethodImplAttributes.Managed);
+- return handlerB.CreateType ();
+- }
+-
+- public static MethodBuilder DefineSignal (TypeBuilder typeB, string name, MethodAttributes mattr, Argument[] args, bool isSignal)
+- {
+- // TODO: Share this method for both signals and methods.
+-
+- //MethodBuilder mb = tb.DefineMethod (name, mattr, typeof(void), Type.EmptyTypes);
+-
+- List<Type> parms = new List<Type> ();
+-
+- if (args != null)
+- foreach (Argument arg in args) {
+- //if (arg.Direction == Introspection.ArgDirection. at in)
+- parms.Add (new Signature (arg.Type).ToType ());
+- //if (arg.Direction == Introspection.ArgDirection. at out)
+- // parms.Add (new Signature (arg.Type).ToType ().MakeByRefType ());
+- }
+-
+- Type retType = typeof (void);
+-
+- /*
+- Signature outSig = Signature.Empty;
+- //this just takes the last out arg and uses is as the return type
+- if (declMethod.Arguments != null)
+- foreach (Argument arg in declMethod.Arguments)
+- if (arg.Direction == Introspection.ArgDirection. at out)
+- outSig = new Signature (arg.Type);
+-
+- Type retType = outSig == Signature.Empty ? typeof (void) : outSig.ToType ();
+- */
+- MethodBuilder mb = typeB.DefineMethod (name, mattr, retType, parms.ToArray ());
+-
+- //define the parameter attributes and names
+- if (args != null) {
+- int argNum = 0;
+-
+- foreach (Argument arg in args) {
+- //if (arg.Direction == Introspection.ArgDirection. at in)
+- mb.DefineParameter (++argNum, ParameterAttributes.In, arg.Name ?? ("arg" + argNum));
+- //if (arg.Direction == Introspection.ArgDirection. at out)
+- // method_builder.DefineParameter (++argNum, ParameterAttributes.Out, arg.Name);
+- }
+- }
+-
+- return mb;
+- }
+-
+- public static MethodBuilder DefineMethod (TypeBuilder typeB, string name, MethodAttributes mattr, Argument[] args, bool isSignal)
+- {
+- // TODO: Share this method for both signals and methods.
+-
+- List<Type> parms = new List<Type> ();
+-
+- if (args != null)
+- for (int argNum = 0; argNum != args.Length; argNum++) {
+- Argument arg = args[argNum];
+- Signature sig = new Signature (arg.Type);
+- Type argType = sig.ToType ();
+- if (arg.Direction == Introspection.ArgDirection. at out)
+- argType = argType.MakeByRefType ();
+- parms.Add (argType);
+- }
+-
+- MethodBuilder mb = typeB.DefineMethod (name, mattr, typeof (void), parms.ToArray ());
+-
+- if (args != null)
+- for (int argNum = 0; argNum != args.Length; argNum++) {
+- Argument arg = args[argNum];
+-
+- ParameterAttributes pattrs = (arg.Direction == Introspection.ArgDirection. at out) ? ParameterAttributes.Out : ParameterAttributes.In;
+- mb.DefineParameter (argNum + 1, pattrs, arg.Name ?? ("arg" + argNum));
+- }
+-
+- return mb;
+- }
+-
+- public static void Define (TypeBuilder typeB, Interface iface)
+- {
+- foreach (Method declMethod in iface.Methods)
+- DefineMethod (typeB, declMethod.Name, ifaceMethAttr, declMethod.Arguments, false);
+-
+- if (iface.Properties != null)
+- foreach (NDesk.DBus.Introspection.Property prop in iface.Properties) {
+- Type propType = new Signature (prop.Type).ToType ();
+-
+- PropertyBuilder prop_builder = typeB.DefineProperty (prop.Name, PropertyAttributes.None, propType, Type.EmptyTypes);
+-
+- if (prop.Access == propertyAccess.read || prop.Access == propertyAccess.readwrite)
+- prop_builder.SetGetMethod (typeB.DefineMethod ("get_" + prop.Name, ifaceMethAttr | MethodAttributes.SpecialName, propType, Type.EmptyTypes));
+-
+- if (prop.Access == propertyAccess.write || prop.Access == propertyAccess.readwrite)
+- prop_builder.SetSetMethod (typeB.DefineMethod ("set_" + prop.Name, ifaceMethAttr | MethodAttributes.SpecialName, null, new Type[] {propType}));
+- }
+-
+- if (iface.Signals != null)
+- foreach (NDesk.DBus.Introspection.Signal signal in iface.Signals) {
+- Type eventType = DefineHandler (modBdef, signal);
+-
+- EventBuilder event_builder = typeB.DefineEvent (signal.Name, EventAttributes.None, eventType);
+-
+- event_builder.SetAddOnMethod (typeB.DefineMethod ("add_" + signal.Name, ifaceMethAttr | MethodAttributes.SpecialName, null, new Type[] {eventType}));
+-
+- event_builder.SetRemoveOnMethod (typeB.DefineMethod ("remove_" + signal.Name, ifaceMethAttr | MethodAttributes.SpecialName, null, new Type[] {eventType}));
+- }
+-
+- //apply InterfaceAttribute
+- ConstructorInfo interfaceAttributeCtor = typeof (InterfaceAttribute).GetConstructor(new Type[] {typeof (string)});
+-
+- CustomAttributeBuilder cab = new CustomAttributeBuilder (interfaceAttributeCtor, new object[] {iface.Name});
+-
+- typeB.SetCustomAttribute (cab);
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/TypeImplementer.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/TypeImplementer.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,1154 +0,0 @@
+-// Copyright 2007 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Reflection;
+-using System.Reflection.Emit;
+-using System.Collections.Generic;
+-
+-namespace NDesk.DBus
+-{
+- class TypeImplementer
+- {
+- public static TypeImplementer Root = new TypeImplementer ("NDesk.DBus.Proxies", false);
+- AssemblyBuilder asmB;
+- ModuleBuilder modB;
+- //List<Assembly> cacheAs = new List<Assembly> ();
+-
+- public TypeImplementer (string name, bool canSave)
+- {
+- //asmB = AppDomain.CurrentDomain.DefineDynamicAssembly (new AssemblyName ("NDesk.DBus.Proxies"), AssemblyBuilderAccess.Run);
+- asmB = AppDomain.CurrentDomain.DefineDynamicAssembly (new AssemblyName ("NDesk.DBus.Proxies"), canSave ? AssemblyBuilderAccess.RunAndSave : AssemblyBuilderAccess.Run);
+- modB = asmB.DefineDynamicModule ("NDesk.DBus.Proxies");
+- //modB = asmB.DefineDynamicModule ("NDesk.DBus.Proxies.dll", "NDesk.DBus.Proxies.dll");
+- //Load ("NDesk.DBus.Proxies");
+- }
+-
+- /*
+- public void Load (string fname)
+- {
+- try {
+- cacheAs.Add (AppDomain.CurrentDomain.Load (fname));
+- } catch {
+- }
+- }
+-
+- public void Save ()
+- {
+- string fname = "NDesk.DBus.Proxies.dll";
+- System.IO.File.Delete (fname);
+- asmB.Save (fname);
+- }
+- */
+-
+- Dictionary<Type,Type> map = new Dictionary<Type,Type> ();
+-
+- public Type GetImplementation (Type declType)
+- {
+- Type retT;
+-
+- if (map.TryGetValue (declType, out retT))
+- return retT;
+-
+- string proxyName = declType.Name + "Proxy";
+-
+- /*
+- foreach (Assembly cacheA in cacheAs) {
+- Type rt = cacheA.GetType (proxyName, false);
+- if (rt != null) {
+- Console.WriteLine ("HIT " + rt);
+- map[declType] = rt;
+- return rt;
+- }
+- }
+- */
+-
+- Type parentType;
+-
+- if (declType.IsInterface)
+- parentType = typeof (BusObject);
+- else
+- parentType = declType;
+-
+- TypeBuilder typeB = modB.DefineType (proxyName, TypeAttributes.Class | TypeAttributes.Public, parentType);
+-
+- if (false && !declType.IsInterface) {
+- foreach (MethodInfo mi in declType.GetMethods (BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) {
+- MethodBody body = mi.GetMethodBody ();
+- Console.WriteLine(mi + ":");
+- foreach (LocalVariableInfo lvar in body.LocalVariables) {
+- Console.WriteLine(lvar.LocalIndex + ": " + lvar.LocalType);
+- }
+- Console.WriteLine();
+-
+- //DynamicMethod method_builder = new DynamicMethod ("Write" + t.Name, typeof (void), new Type[] {typeof (MessageWriter), t}, typeof (MessageWriter));
+- //DynamicMethod dm = new DynamicMethod ("RepProx", typeof(void), new Type[] { typeof(object), typeof(int), typeof(string) }, typeof(object));
+- //DynamicILInfo dil = dm.GetDynamicILInfo ();
+- //dil.SetCode(body.GetILAsByteArray (), body.MaxStackSize);
+-
+- //MethodBuilder mb = typeB.DefineMethod ("RepProx", MethodAttributes.Public | MethodAttributes.Static, typeof(void), new Type[] { typeof(object), typeof(int), typeof(string) });
+- //MethodBuilder mb = typeB.DefineMethod ("RepProx", MethodAttributes.Public | MethodAttributes.Static, typeof(void), new Type[] { declType, typeof(int), typeof(string) });
+- //
+-
+- //MethodAttributes attrs = mi.Attributes;
+- //^ MethodAttributes.Abstract;
+- //attrs ^= MethodAttributes.NewSlot;
+- //attrs |= MethodAttributes.Final;
+-
+- //MethodAttributes.Public
+- MethodAttributes attrs = MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.HideBySig;
+- Console.WriteLine("cwl attrs: " + typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }).Attributes);
+- //DynamicILInfo dil = mi.GetDynamicILInfo ();
+-
+- ParameterInfo[] parms = mi.GetParameters();
+- //MethodBuilder mb = typeB.DefineMethod ("RepProx", attrs, typeof(void), new Type[] { typeof(int), typeof(string) });
+- //MethodBuilder mb = typeB.DefineMethod ("RepProx", attrs, typeof(void), new Type[] { declType, typeof(int), typeof(string) });
+- MethodBuilder mb = typeB.DefineMethod ("RepProx", attrs, typeof(void), new Type[] { typeof(object), typeof(int), typeof(string) });
+-
+- mb.DefineParameter (0, ParameterAttributes.None, "self");
+- for (int i = 0; i < parms.Length ; i++) {
+- Console.WriteLine("i={0} pos={1} {2} {3}", i, parms[i].Position, parms[i].Attributes, parms[i]);
+- mb.DefineParameter (parms[i].Position + 1, parms[i].Attributes, parms[i].Name);
+- }
+-
+- }
+- }
+-
+-
+- if (declType.IsInterface)
+- Implement (typeB, declType);
+-
+- foreach (Type iface in declType.GetInterfaces ())
+- Implement (typeB, iface);
+-
+- retT = typeB.CreateType ();
+- map[declType] = retT;
+-
+- return retT;
+- }
+-
+- static void Implement (TypeBuilder typeB, Type iface)
+- {
+- typeB.AddInterfaceImplementation (iface);
+-
+- Dictionary<string,MethodBuilder> builders = new Dictionary<string,MethodBuilder> ();
+-
+- foreach (MethodInfo declMethod in iface.GetMethods ()) {
+- ParameterInfo[] parms = declMethod.GetParameters ();
+-
+- Type[] parmTypes = new Type[parms.Length];
+- for (int i = 0 ; i < parms.Length ; i++)
+- parmTypes[i] = parms[i].ParameterType;
+-
+- MethodAttributes attrs = declMethod.Attributes ^ MethodAttributes.Abstract;
+- attrs ^= MethodAttributes.NewSlot;
+- attrs |= MethodAttributes.Final;
+- MethodBuilder method_builder = typeB.DefineMethod (declMethod.Name, attrs, declMethod.ReturnType, parmTypes);
+- typeB.DefineMethodOverride (method_builder, declMethod);
+-
+- //define in/out/ref/name for each of the parameters
+- for (int i = 0; i < parms.Length ; i++)
+- method_builder.DefineParameter (i + 1, parms[i].Attributes, parms[i].Name);
+-
+- //Console.WriteLine ("retType: " + declMethod.ReturnType);
+- ILGenerator ilg = method_builder.GetILGenerator ();
+- GenHookupMethod (ilg, declMethod, sendMethodCallMethod, Mapper.GetInterfaceName (iface), declMethod.Name);
+-
+- if (declMethod.IsSpecialName)
+- builders[declMethod.Name] = method_builder;
+- }
+-
+- foreach (EventInfo declEvent in iface.GetEvents ())
+- {
+- EventBuilder event_builder = typeB.DefineEvent (declEvent.Name, declEvent.Attributes, declEvent.EventHandlerType);
+- event_builder.SetAddOnMethod (builders["add_" + declEvent.Name]);
+- event_builder.SetRemoveOnMethod (builders["remove_" + declEvent.Name]);
+- }
+-
+- foreach (PropertyInfo declProp in iface.GetProperties ())
+- {
+- List<Type> indexers = new List<Type> ();
+- foreach (ParameterInfo pi in declProp.GetIndexParameters ())
+- indexers.Add (pi.ParameterType);
+-
+- PropertyBuilder prop_builder = typeB.DefineProperty (declProp.Name, declProp.Attributes, declProp.PropertyType, indexers.ToArray ());
+- MethodBuilder mb;
+- if (builders.TryGetValue ("get_" + declProp.Name, out mb))
+- prop_builder.SetGetMethod (mb);
+- if (builders.TryGetValue ("set_" + declProp.Name, out mb))
+- prop_builder.SetSetMethod (mb);
+- }
+- }
+-
+- static MethodInfo sendMethodCallMethod = typeof (BusObject).GetMethod ("SendMethodCall");
+- static MethodInfo sendSignalMethod = typeof (BusObject).GetMethod ("SendSignal");
+- static MethodInfo toggleSignalMethod = typeof (BusObject).GetMethod ("ToggleSignal");
+-
+- static Dictionary<EventInfo,DynamicMethod> hookup_methods = new Dictionary<EventInfo,DynamicMethod> ();
+- public static DynamicMethod GetHookupMethod (EventInfo ei)
+- {
+- DynamicMethod hookupMethod;
+- if (hookup_methods.TryGetValue (ei, out hookupMethod))
+- return hookupMethod;
+-
+- if (ei.EventHandlerType.IsAssignableFrom (typeof (System.EventHandler)))
+- Console.Error.WriteLine ("Warning: Cannot yet fully expose EventHandler and its subclasses: " + ei.EventHandlerType);
+-
+- MethodInfo declMethod = ei.EventHandlerType.GetMethod ("Invoke");
+-
+- hookupMethod = GetHookupMethod (declMethod, sendSignalMethod, Mapper.GetInterfaceName (ei), ei.Name);
+-
+- hookup_methods[ei] = hookupMethod;
+-
+- return hookupMethod;
+- }
+-
+- public static DynamicMethod GetHookupMethod (MethodInfo declMethod, MethodInfo invokeMethod, string @interface, string member)
+- {
+- ParameterInfo[] delegateParms = declMethod.GetParameters ();
+- Type[] hookupParms = new Type[delegateParms.Length+1];
+- hookupParms[0] = typeof (BusObject);
+- for (int i = 0; i < delegateParms.Length ; i++)
+- hookupParms[i+1] = delegateParms[i].ParameterType;
+-
+- DynamicMethod hookupMethod = new DynamicMethod ("Handle" + member, declMethod.ReturnType, hookupParms, typeof (MessageWriter));
+-
+- ILGenerator ilg = hookupMethod.GetILGenerator ();
+-
+- GenHookupMethod (ilg, declMethod, invokeMethod, @interface, member);
+-
+- return hookupMethod;
+- }
+-
+- //static MethodInfo getMethodFromHandleMethod = typeof (MethodBase).GetMethod ("GetMethodFromHandle", new Type[] {typeof (RuntimeMethodHandle)});
+- static MethodInfo getTypeFromHandleMethod = typeof (Type).GetMethod ("GetTypeFromHandle", new Type[] {typeof (RuntimeTypeHandle)});
+- static ConstructorInfo argumentNullExceptionConstructor = typeof (ArgumentNullException).GetConstructor (new Type[] {typeof (string)});
+- static ConstructorInfo messageWriterConstructor = typeof (MessageWriter).GetConstructor (Type.EmptyTypes);
+- static MethodInfo messageWriterWriteMethod = typeof (MessageWriter).GetMethod ("WriteComplex", new Type[] {typeof (object), typeof (Type)});
+- static MethodInfo messageWriterWritePad = typeof (MessageWriter).GetMethod ("WritePad", new Type[] {typeof (int)});
+- static MethodInfo messageReaderReadPad = typeof (MessageReader).GetMethod ("ReadPad", new Type[] {typeof (int)});
+-
+- static Dictionary<Type,MethodInfo> writeMethods = new Dictionary<Type,MethodInfo> ();
+-
+- public static MethodInfo GetWriteMethod (Type t)
+- {
+- MethodInfo meth;
+-
+- if (writeMethods.TryGetValue (t, out meth))
+- return meth;
+-
+- /*
+- Type tUnder = t;
+- if (t.IsEnum)
+- tUnder = Enum.GetUnderlyingType (t);
+-
+- meth = typeof (MessageWriter).GetMethod ("Write", BindingFlags.ExactBinding | BindingFlags.Instance | BindingFlags.Public, null, new Type[] {tUnder}, null);
+- if (meth != null) {
+- writeMethods[t] = meth;
+- return meth;
+- }
+- */
+-
+- DynamicMethod method_builder = new DynamicMethod ("Write" + t.Name, typeof (void), new Type[] {typeof (MessageWriter), t}, typeof (MessageWriter), true);
+-
+- ILGenerator ilg = method_builder.GetILGenerator ();
+-
+- ilg.Emit (OpCodes.Ldarg_0);
+- ilg.Emit (OpCodes.Ldarg_1);
+-
+- GenWriter (ilg, t);
+-
+- ilg.Emit (OpCodes.Ret);
+-
+- meth = method_builder;
+-
+- writeMethods[t] = meth;
+- return meth;
+- }
+-
+- static Dictionary<Type,object> typeWriters = new Dictionary<Type,object> ();
+- public static TypeWriter<T> GetTypeWriter<T> ()
+- {
+- Type t = typeof (T);
+-
+- object value;
+- if (typeWriters.TryGetValue (t, out value))
+- return (TypeWriter<T>)value;
+-
+- MethodInfo mi = GetWriteMethod (t);
+- DynamicMethod dm = mi as DynamicMethod;
+- if (dm == null)
+- return null;
+-
+- TypeWriter<T> tWriter = dm.CreateDelegate (typeof (TypeWriter<T>)) as TypeWriter<T>;
+- typeWriters[t] = tWriter;
+- return tWriter;
+- }
+-
+- //takes the Writer instance and the value of Type t off the stack, writes it
+- public static void GenWriter (ILGenerator ilg, Type t)
+- {
+- Type tUnder = t;
+- //bool imprecise = false;
+-
+- if (t.IsEnum) {
+- tUnder = Enum.GetUnderlyingType (t);
+- //imprecise = true;
+- }
+-
+- Type type = t;
+-
+- //MethodInfo exactWriteMethod = typeof (MessageWriter).GetMethod ("Write", new Type[] {tUnder});
+- MethodInfo exactWriteMethod = typeof (MessageWriter).GetMethod ("Write", BindingFlags.ExactBinding | BindingFlags.Instance | BindingFlags.Public, null, new Type[] {tUnder}, null);
+- //ExactBinding InvokeMethod
+-
+- if (exactWriteMethod != null) {
+- //if (imprecise)
+- // ilg.Emit (OpCodes.Castclass, tUnder);
+-
+- ilg.Emit (exactWriteMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactWriteMethod);
+- } else if (t.IsArray) {
+- MethodInfo mi = typeof (MessageWriter).GetMethod ("WriteArray");
+- exactWriteMethod = mi.MakeGenericMethod (type.GetElementType ());
+- ilg.Emit (exactWriteMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactWriteMethod);
+- } else if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) {
+- Type[] genArgs = type.GetGenericArguments ();
+- MethodInfo mi = typeof (MessageWriter).GetMethod ("WriteFromDict");
+- exactWriteMethod = mi.MakeGenericMethod (genArgs);
+- ilg.Emit (exactWriteMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactWriteMethod);
+- } else if (false) {
+- //..boxed if necessary
+- if (t.IsValueType)
+- ilg.Emit (OpCodes.Box, t);
+-
+- //the Type parameter
+- ilg.Emit (OpCodes.Ldtoken, t);
+- ilg.Emit (OpCodes.Call, getTypeFromHandleMethod);
+-
+- ilg.Emit (messageWriterWriteMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, messageWriterWriteMethod);
+- } else {
+- GenStructWriter (ilg, t);
+- }
+- }
+-
+- public static IEnumerable<FieldInfo> GetMarshalFields (Type type)
+- {
+- // FIXME: Field order!
+- return type.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
+- }
+-
+- /*
+- public static void GetBlittableSegments (IEnumerable<FieldInfo> fields)
+- {
+- int totalSize = 0;
+- //List<FieldInfo>
+- //foreach (FieldInfo fi in GetMarshalFields (type))
+- foreach (FieldInfo fi in fields) {
+- Type t = fi.FieldType;
+- Signature sig = Signature.GetSig (t);
+- int fixedSize = totalSize;
+- if (sig.GetFixedSize (ref fixedSize)) {
+- totalSize = fixedSize;
+- continue;
+- }
+-
+- //ilg.Emit (OpCodes.Ldflda, fiStart);
+- }
+- }
+- */
+-
+- //takes a writer and a reference to an object off the stack
+- public static void GenStructWriter (ILGenerator ilg, Type type)
+- {
+- LocalBuilder val = ilg.DeclareLocal (type);
+- ilg.Emit (OpCodes.Stloc, val);
+-
+- LocalBuilder writer = ilg.DeclareLocal (typeof (MessageWriter));
+- ilg.Emit (OpCodes.Stloc, writer);
+-
+- //align to 8 for structs
+- ilg.Emit (OpCodes.Ldloc, writer);
+- ilg.Emit (OpCodes.Ldc_I4, 8);
+- ilg.Emit (OpCodes.Call, messageWriterWritePad);
+-
+- foreach (FieldInfo fi in GetMarshalFields (type)) {
+- Type t = fi.FieldType;
+-
+- // null checking of fields
+- if (!t.IsValueType) {
+- Label notNull = ilg.DefineLabel ();
+-
+- //if the value is null...
+- //ilg.Emit (OpCodes.Ldarg, i);
+- ilg.Emit (OpCodes.Ldloc, val);
+- ilg.Emit (OpCodes.Ldfld, fi);
+-
+- ilg.Emit (OpCodes.Brtrue_S, notNull);
+-
+- //...throw Exception
+- string paramName = fi.Name;
+- ilg.Emit (OpCodes.Ldstr, paramName);
+- // TODO: Should not really be argumentNullException
+- ilg.Emit (OpCodes.Newobj, argumentNullExceptionConstructor);
+- ilg.Emit (OpCodes.Throw);
+-
+- //was not null, so all is well
+- ilg.MarkLabel (notNull);
+- }
+-
+- //the Writer to write to
+- ilg.Emit (OpCodes.Ldloc, writer);
+-
+- //the object to read from
+- ilg.Emit (OpCodes.Ldloc, val);
+- ilg.Emit (OpCodes.Ldfld, fi);
+-
+- GenWriter (ilg, t);
+- }
+- }
+-
+- //takes a reader and a reference to an object off the stack
+- public static void GenStructReader (ILGenerator ilg, Type type)
+- {
+- /*
+- int fixedSize = 0;
+- if (Signature.GetSig (type).GetFixedSize (ref fixedSize)) {
+- Console.Error.WriteLine ("Type " + type + " is blittable.");
+- }
+- */
+-
+- // FIXME: Newobj fails if type has no default ctor!
+-
+- //Console.WriteLine ("GenStructReader " + type);
+- LocalBuilder val = ilg.DeclareLocal (type);
+- ConstructorInfo ctor = type.GetConstructor (Type.EmptyTypes);
+- //ConstructorInfo ctor = type.TypeInitializer;
+- //Console.WriteLine ("ctor: " + ctor);
+- //if (ctor != null)
+- ilg.Emit (OpCodes.Newobj, ctor);
+- //ilg.Emit (OpCodes.Ldloca, type);
+- //ilg.Emit (OpCodes.Initobj, type);
+- //if (!type.IsValueType)
+- ilg.Emit (OpCodes.Stloc, val);
+-
+- LocalBuilder reader = ilg.DeclareLocal (typeof (MessageReader));
+- ilg.Emit (OpCodes.Stloc, reader);
+-
+- //align to 8 for structs
+- ilg.Emit (OpCodes.Ldloc, reader);
+- ilg.Emit (OpCodes.Ldc_I4, 8);
+- ilg.Emit (OpCodes.Call, messageReaderReadPad);
+-
+- foreach (FieldInfo fi in GetMarshalFields (type)) {
+- Type t = fi.FieldType;
+-
+- //the object to read into
+- ilg.Emit (OpCodes.Ldloc, val);
+-
+- //the Reader to read from
+- ilg.Emit (OpCodes.Ldloc, reader);
+-
+- GenReader (ilg, t);
+-
+- ilg.Emit (OpCodes.Stfld, fi);
+- }
+-
+- ilg.Emit (OpCodes.Ldloc, val);
+- //if (type.IsValueType)
+- // ilg.Emit (OpCodes.Box, type);
+- }
+-
+- static MethodInfo getBusObject = typeof(BusObject).GetMethod("GetBusObject");
+-
+- public static void GenHookupMethod (ILGenerator ilg, MethodInfo declMethod, MethodInfo invokeMethod, string @interface, string member)
+- {
+- ParameterInfo[] parms = declMethod.GetParameters ();
+- Type retType = declMethod.ReturnType;
+-
+- //the BusObject instance
+- ilg.Emit (OpCodes.Ldarg_0);
+-
+- ilg.Emit (OpCodes.Call, getBusObject);
+-
+- //MethodInfo
+- /*
+- ilg.Emit (OpCodes.Ldtoken, declMethod);
+- ilg.Emit (OpCodes.Call, getMethodFromHandleMethod);
+- */
+-
+- //interface
+- ilg.Emit (OpCodes.Ldstr, @interface);
+-
+- //special case event add/remove methods
+- if (declMethod.IsSpecialName && (declMethod.Name.StartsWith ("add_") || declMethod.Name.StartsWith ("remove_"))) {
+- string[] parts = declMethod.Name.Split (new char[]{'_'}, 2);
+- string ename = parts[1];
+- //Delegate dlg = (Delegate)inArgs[0];
+- bool adding = parts[0] == "add";
+-
+- ilg.Emit (OpCodes.Ldstr, ename);
+-
+- ilg.Emit (OpCodes.Ldarg_1);
+-
+- ilg.Emit (OpCodes.Ldc_I4, adding ? 1 : 0);
+-
+- ilg.Emit (OpCodes.Tailcall);
+- ilg.Emit (toggleSignalMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, toggleSignalMethod);
+- ilg.Emit (OpCodes.Ret);
+- return;
+- }
+-
+- //property accessor mapping
+- if (declMethod.IsSpecialName) {
+- if (member.StartsWith ("get_"))
+- member = "Get" + member.Substring (4);
+- else if (member.StartsWith ("set_"))
+- member = "Set" + member.Substring (4);
+- }
+-
+- //member
+- ilg.Emit (OpCodes.Ldstr, member);
+-
+- //signature
+- Signature inSig = Signature.Empty;
+- Signature outSig = Signature.Empty;
+- SigsForMethod (declMethod, out inSig, out outSig);
+-
+- ilg.Emit (OpCodes.Ldstr, inSig.Value);
+-
+- LocalBuilder writer = ilg.DeclareLocal (typeof (MessageWriter));
+- ilg.Emit (OpCodes.Newobj, messageWriterConstructor);
+- ilg.Emit (OpCodes.Stloc, writer);
+-
+- foreach (ParameterInfo parm in parms)
+- {
+- if (parm.IsOut)
+- continue;
+-
+- Type t = parm.ParameterType;
+- //offset by one to account for "this"
+- int i = parm.Position + 1;
+-
+- //null checking of parameters (but not their recursive contents)
+- if (!t.IsValueType) {
+- Label notNull = ilg.DefineLabel ();
+-
+- //if the value is null...
+- ilg.Emit (OpCodes.Ldarg, i);
+- ilg.Emit (OpCodes.Brtrue_S, notNull);
+-
+- //...throw Exception
+- string paramName = parm.Name;
+- ilg.Emit (OpCodes.Ldstr, paramName);
+- ilg.Emit (OpCodes.Newobj, argumentNullExceptionConstructor);
+- ilg.Emit (OpCodes.Throw);
+-
+- //was not null, so all is well
+- ilg.MarkLabel (notNull);
+- }
+-
+- ilg.Emit (OpCodes.Ldloc, writer);
+-
+- //the parameter
+- ilg.Emit (OpCodes.Ldarg, i);
+-
+- GenWriter (ilg, t);
+- }
+-
+- ilg.Emit (OpCodes.Ldloc, writer);
+-
+- //the expected return Type
+- ilg.Emit (OpCodes.Ldtoken, retType);
+- ilg.Emit (OpCodes.Call, getTypeFromHandleMethod);
+-
+- LocalBuilder exc = ilg.DeclareLocal (typeof (Exception));
+- ilg.Emit (OpCodes.Ldloca_S, exc);
+-
+- //make the call
+- ilg.Emit (invokeMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, invokeMethod);
+-
+- //define a label we'll use to deal with a non-null Exception
+- Label noErr = ilg.DefineLabel ();
+-
+- //if the out Exception is not null...
+- ilg.Emit (OpCodes.Ldloc, exc);
+- ilg.Emit (OpCodes.Brfalse_S, noErr);
+-
+- //...throw it.
+- ilg.Emit (OpCodes.Ldloc, exc);
+- ilg.Emit (OpCodes.Throw);
+-
+- //Exception was null, so all is well
+- ilg.MarkLabel (noErr);
+-
+- if (invokeMethod.ReturnType == typeof (MessageReader)) {
+- /*
+- Label notNull = ilg.DefineLabel ();
+- //if the value is null...
+- ilg.Emit (OpCodes.Ldarg, i);
+- ilg.Emit (OpCodes.Brtrue_S, notNull);
+- //was not null, so all is well
+- ilg.MarkLabel (notNull);
+- */
+-
+- LocalBuilder reader = ilg.DeclareLocal (typeof (MessageReader));
+- ilg.Emit (OpCodes.Stloc, reader);
+-
+- foreach (ParameterInfo parm in parms)
+- {
+- //t.IsByRef
+- if (!parm.IsOut)
+- continue;
+-
+- Type t = parm.ParameterType.GetElementType ();
+- //offset by one to account for "this"
+- int i = parm.Position + 1;
+-
+- ilg.Emit (OpCodes.Ldarg, i);
+- ilg.Emit (OpCodes.Ldloc, reader);
+- GenReader (ilg, t);
+- ilg.Emit (OpCodes.Stobj, t);
+- }
+-
+- if (retType != typeof (void)) {
+- ilg.Emit (OpCodes.Ldloc, reader);
+- GenReader (ilg, retType);
+- }
+-
+- ilg.Emit (OpCodes.Ret);
+- return;
+- }
+-
+- if (retType == typeof (void)) {
+- //we aren't expecting a return value, so throw away the (hopefully) null return
+- if (invokeMethod.ReturnType != typeof (void))
+- ilg.Emit (OpCodes.Pop);
+- } else {
+- if (retType.IsValueType)
+- ilg.Emit (OpCodes.Unbox_Any, retType);
+- else
+- ilg.Emit (OpCodes.Castclass, retType);
+- }
+-
+- ilg.Emit (OpCodes.Ret);
+- }
+-
+-
+- public static bool SigsForMethod (MethodInfo mi, out Signature inSig, out Signature outSig)
+- {
+- inSig = Signature.Empty;
+- outSig = Signature.Empty;
+-
+- foreach (ParameterInfo parm in mi.GetParameters ()) {
+- if (parm.IsOut)
+- outSig += Signature.GetSig (parm.ParameterType.GetElementType ());
+- else
+- inSig += Signature.GetSig (parm.ParameterType);
+- }
+-
+- outSig += Signature.GetSig (mi.ReturnType);
+-
+- return true;
+- }
+-
+- static Dictionary<Type,MethodInfo> readMethods = new Dictionary<Type,MethodInfo> ();
+- static void InitReaders ()
+- {
+- foreach (MethodInfo mi in typeof (MessageReader).GetMethods (BindingFlags.Instance | BindingFlags.Public)) {
+- if (!mi.Name.StartsWith ("Read"))
+- continue;
+- if (mi.ReturnType == typeof (void))
+- continue;
+- if (mi.GetParameters ().Length != 0)
+- continue;
+- //Console.WriteLine ("Adding reader " + mi);
+- readMethods[mi.ReturnType] = mi;
+- }
+- }
+-
+- internal static MethodInfo GetReadMethod (Type t)
+- {
+- if (readMethods.Count == 0)
+- InitReaders ();
+-
+- MethodInfo mi;
+- if (readMethods.TryGetValue (t, out mi))
+- return mi;
+-
+- /*
+- Type tIn = t;
+- if (t.IsValueType)
+- */
+-
+- /*
+- DynamicMethod meth = new DynamicMethod ("Read" + t.Name, t, new Type[] {typeof (MessageReader)}, true);
+-
+- ILGenerator ilg = meth.GetILGenerator ();
+- ilg.Emit (OpCodes.Ldarg_0);
+- ilg.Emit (OpCodes.Ldarg_1);
+-
+- //GenStructReader (ilg, t);
+- GenReader (ilg, t);
+-
+- ilg.Emit (OpCodes.Ret);
+-
+- writeMethods[t] = meth;
+- return meth;
+- */
+- return null;
+- }
+-
+- internal static MethodCaller2 GenCaller2 (MethodInfo target)
+- {
+- DynamicMethod hookupMethod = GenReadMethod (target);
+- MethodCaller2 caller = hookupMethod.CreateDelegate (typeof (MethodCaller2)) as MethodCaller2;
+- return caller;
+- }
+-
+- internal static MethodCaller GenCaller (MethodInfo target, object targetInstance)
+- {
+- DynamicMethod hookupMethod = GenReadMethod (target);
+- MethodCaller caller = hookupMethod.CreateDelegate (typeof (MethodCaller), targetInstance) as MethodCaller;
+- return caller;
+- }
+-
+- internal static DynamicMethod GenReadMethod (MethodInfo target)
+- {
+- //Type[] parms = new Type[] { typeof (object), typeof (MessageReader), typeof (Message) };
+- Type[] parms = new Type[] { typeof (object), typeof (MessageReader), typeof (Message), typeof (MessageWriter) };
+- DynamicMethod hookupMethod = new DynamicMethod ("Caller", typeof (void), parms, typeof (MessageReader));
+- Gen (hookupMethod, target);
+- return hookupMethod;
+- }
+-
+- static void Gen (DynamicMethod hookupMethod, MethodInfo declMethod)
+- {
+- //Console.Error.WriteLine ("Target: " + declMethod);
+- ILGenerator ilg = hookupMethod.GetILGenerator ();
+-
+- ParameterInfo[] parms = declMethod.GetParameters ();
+- Type retType = declMethod.ReturnType;
+-
+- //if (retType != typeof (void))
+- // throw new Exception ("Bad retType " + retType);
+-
+- // The target instance
+- ilg.Emit (OpCodes.Ldarg_0);
+-
+- Dictionary<ParameterInfo,LocalBuilder> locals = new Dictionary<ParameterInfo,LocalBuilder> ();
+-
+- foreach (ParameterInfo parm in parms) {
+- /*
+- if (parm.IsOut)
+- continue;
+- */
+-
+- Type parmType = parm.ParameterType;
+-
+- if (parm.IsOut) {
+- LocalBuilder parmLocal = ilg.DeclareLocal (parmType.GetElementType ());
+- locals[parm] = parmLocal;
+- ilg.Emit (OpCodes.Ldloca, parmLocal);
+- continue;
+- }
+-
+- /*
+- MethodInfo exactMethod = GetReadMethod (parmType);
+- // The MessageReader instance
+- ilg.Emit (OpCodes.Ldarg_1);
+- ilg.Emit (exactMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactMethod);
+- */
+-
+- ilg.Emit (OpCodes.Ldarg_1);
+- GenReader (ilg, parmType);
+- }
+-
+- //ilg.Emit (OpCodes.Ldc_I4, 8);
+- ilg.Emit (declMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, declMethod);
+-
+- foreach (ParameterInfo parm in parms) {
+- if (!parm.IsOut)
+- continue;
+-
+- Type parmType = parm.ParameterType.GetElementType ();
+-
+- LocalBuilder parmLocal = locals[parm];
+- ilg.Emit (OpCodes.Ldarg_3); // writer
+- ilg.Emit (OpCodes.Ldloc, parmLocal);
+- GenWriter (ilg, parmType);
+- }
+-
+- if (retType != typeof (void)) {
+- // Skip reply message construction if MessageWriter is null
+- /*
+- Label needsReply = ilg.DefineLabel ();
+- ilg.Emit (OpCodes.Ldarg_3); // writer
+- ilg.Emit (OpCodes.Brtrue_S, needsReply);
+- ilg.Emit (OpCodes.Pop);
+- //ilg.Emit (OpCodes.Brfalse_S, endLabel);
+- */
+-
+- //Console.WriteLine ("retType: " + retType);
+- LocalBuilder retLocal = ilg.DeclareLocal (retType);
+- ilg.Emit (OpCodes.Stloc, retLocal);
+-
+- /*
+- LocalBuilder writer = ilg.DeclareLocal (typeof (MessageWriter));
+- ilg.Emit (OpCodes.Newobj, messageWriterConstructor);
+- ilg.Emit (OpCodes.Stloc, writer);
+- */
+-
+- ilg.Emit (OpCodes.Ldarg_3); // writer
+- //ilg.Emit (OpCodes.Ldloc, writer);
+- ilg.Emit (OpCodes.Ldloc, retLocal);
+- GenWriter (ilg, retType);
+-
+- //ilg.Emit (OpCodes.Ldloc, writer);
+- //ilg.MarkLabel (endLabel);
+- }
+-
+- ilg.Emit (OpCodes.Ret);
+- }
+-
+- // System.MethodAccessException: Method `ManagedDBusTestExport:<Main>m__0 (string,object,double,MyTuple)' is inaccessible from method `(wrapper dynamic-method) object:Caller (object,NDesk.DBus.MessageReader,NDesk.DBus.Message,NDesk.DBus.MessageWriter)'
+-
+- //takes the Reader instance off the stack, puts value of type t on the stack
+- public static void GenReader (ILGenerator ilg, Type t)
+- {
+- // TODO: Cache generated methods
+- // TODO: Generate methods with the correct module/type permissions
+-
+- Type tUnder = t;
+- //bool imprecise = false;
+-
+- if (t.IsEnum) {
+- tUnder = Enum.GetUnderlyingType (t);
+- //imprecise = true;
+- }
+-
+- MethodInfo exactMethod = GetReadMethod (tUnder);
+- if (exactMethod != null)
+- ilg.Emit (exactMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactMethod);
+- else if (t.IsArray)
+- GenReadCollection (ilg, t);
+- else if (t.IsGenericType && (t.GetGenericTypeDefinition () == typeof (IList<>)))
+- GenReadCollection (ilg, t);
+- else if (t.IsGenericType && (t.GetGenericTypeDefinition () == typeof (IDictionary<,>) || t.GetGenericTypeDefinition () == typeof (Dictionary<,>)))
+- GenReadCollection (ilg, t);
+- else if (t.IsInterface)
+- GenFallbackReader (ilg, tUnder);
+- else if (!tUnder.IsValueType) {
+- //Console.Error.WriteLine ("Gen struct reader for " + t);
+- //ilg.Emit (OpCodes.Newobj, messageWriterConstructor);
+- //if (tUnder.IsValueType)
+- // throw new Exception ("Can't handle value types yet");
+- GenStructReader (ilg, tUnder);
+- } else
+- GenFallbackReader (ilg, tUnder);
+-
+- /*
+- //if (t.IsValueType)
+- // ilg.Emit (OpCodes.Unbox_Any, t);
+- //else
+- ilg.Emit (OpCodes.Castclass, t);
+- */
+- }
+-
+- public static void GenFallbackReader (ILGenerator ilg, Type t)
+- {
+- // TODO: do we want non-tUnder here for Castclass use?
+- if (Protocol.Verbose)
+- Console.Error.WriteLine ("Bad! Generating fallback reader for " + t);
+-
+- MethodInfo exactMethod;
+- exactMethod = typeof (MessageReader).GetMethod ("ReadValue", new Type[] { typeof (System.Type) });
+-
+- // The Type parameter
+- ilg.Emit (OpCodes.Ldtoken, t);
+- ilg.Emit (OpCodes.Call, getTypeFromHandleMethod);
+-
+- ilg.Emit (exactMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactMethod);
+-
+- if (t.IsValueType)
+- ilg.Emit (OpCodes.Unbox_Any, t);
+- else
+- ilg.Emit (OpCodes.Castclass, t);
+- }
+-
+- public static void GenReadArrayFixed (ILGenerator ilg, Type t, int knownElemSize)
+- {
+- //Console.Error.WriteLine ("GenReadArrayFixed " + t);
+- LocalBuilder readerLocal = ilg.DeclareLocal (typeof (MessageReader));
+- ilg.Emit (OpCodes.Stloc, readerLocal);
+-
+- Type tElem = t.GetElementType ();
+- Signature sigElem = Signature.GetSig (tElem);
+- int alignElem = sigElem.Alignment;
+- int knownElemSizePadded = Protocol.Padded (knownElemSize, sigElem.Alignment);
+- Type tUnder = tElem.IsEnum ? Enum.GetUnderlyingType (tElem) : tElem;
+- int managedElemSize = System.Runtime.InteropServices.Marshal.SizeOf (tUnder);
+-
+- /*
+- Console.WriteLine ("managedElemSize: " + managedElemSize);
+- Console.WriteLine ("elemSize: " + knownElemSize);
+- Console.WriteLine ("elemSizePadded: " + knownElemSizePadded);
+- */
+-
+- // Read the array's byte length
+- ilg.Emit (OpCodes.Ldloc, readerLocal);
+- MethodInfo exactMethod = GetReadMethod (typeof (uint));
+- ilg.Emit (exactMethod.IsFinal ? OpCodes.Call : OpCodes.Callvirt, exactMethod);
+- LocalBuilder sizeLocal = ilg.DeclareLocal (typeof (uint));
+- ilg.Emit (OpCodes.Stloc, sizeLocal);
+-
+- /*
+- // Take the array's byte length
+- ilg.Emit (OpCodes.Ldloc, sizeLocal);
+- // Divide by the known element size
+- //ilg.Emit (OpCodes.Ldc_I4, knownElemSizePadded);
+- ilg.Emit (OpCodes.Ldc_I4, knownElemSize);
+- ilg.Emit (OpCodes.Div_Un);
+- */
+-
+- // Create a new array of the correct element length
+- ilg.Emit (OpCodes.Ldloc, sizeLocal);
+- if (knownElemSizePadded > 1) {
+- ilg.Emit (OpCodes.Ldc_I4, alignElem);
+- MethodInfo paddedMethod = typeof (Protocol).GetMethod ("Padded");
+- ilg.Emit (OpCodes.Call, paddedMethod);
+- // Divide by the known element size
+- ilg.Emit (OpCodes.Ldc_I4, knownElemSizePadded);
+- ilg.Emit (OpCodes.Div_Un);
+- }
+- ilg.Emit (OpCodes.Newarr, tElem);
+- LocalBuilder aryLocal = ilg.DeclareLocal (t);
+- ilg.Emit (OpCodes.Stloc, aryLocal);
+-
+- Label nonBlitLabel = ilg.DefineLabel ();
+- Label endLabel = ilg.DefineLabel ();
+-
+- // Skip read or blit for zero-length arrays.
+- ilg.Emit (OpCodes.Ldloc, sizeLocal);
+- ilg.Emit (OpCodes.Brfalse, endLabel);
+-
+- // WARNING: This may skew pos when we later increment it!
+- if (alignElem > 4) {
+- // Align to element if alignment requirement is higher than 4 (since we just read a uint)
+- ilg.Emit (OpCodes.Ldloc, readerLocal);
+- ilg.Emit (OpCodes.Ldc_I4, alignElem);
+- ilg.Emit (OpCodes.Call, messageReaderReadPad);
+- }
+-
+- // Blit where possible
+-
+- // shouldBlit: Blit if endian is native
+- // mustBlit: Blit regardless of endian (ie. byte or structs containing only bytes)
+-
+- bool shouldBlit = tElem.IsValueType && knownElemSizePadded == managedElemSize && !sigElem.IsStruct;
+- //bool shouldBlit = tElem.IsValueType && knownElemSizePadded == managedElemSize;
+-
+- // bool and char are not reliably blittable, so we don't allow blitting in these cases.
+- // Their exact layout varies between runtimes, platforms and even data types.
+- shouldBlit &= tElem != typeof (bool) && tElem != typeof (char);
+-
+- bool mustBlit = shouldBlit && knownElemSizePadded == 1;
+-
+- if (shouldBlit) {
+- //Console.Error.WriteLine ("Blit read array " + tElem);
+-
+- if (!mustBlit) {
+- // Check to see if we can blit the data structures
+- FieldInfo nativeEndianField = typeof (MessageReader).GetField ("IsNativeEndian");
+- ilg.Emit (OpCodes.Ldloc, readerLocal);
+- ilg.Emit (OpCodes.Ldfld, nativeEndianField);
+- ilg.Emit (OpCodes.Brfalse_S, nonBlitLabel);
+- }
+-
+- // Get the destination address
+- ilg.Emit (OpCodes.Ldloc, aryLocal);
+- ilg.Emit (OpCodes.Ldc_I4_0);
+- ilg.Emit (OpCodes.Ldelema, tElem);
+-
+- // Get the source address
+- FieldInfo dataField = typeof (MessageReader).GetField ("data");
+- FieldInfo posField = typeof (MessageReader).GetField ("pos");
+- ilg.Emit (OpCodes.Ldloc, readerLocal);
+- ilg.Emit (OpCodes.Ldfld, dataField);
+- {
+- ilg.Emit (OpCodes.Ldloc, readerLocal);
+- ilg.Emit (OpCodes.Ldfld, posField);
+- }
+- ilg.Emit (OpCodes.Ldelema, typeof (byte));
+-
+- // The number of bytes to copy
+- ilg.Emit (OpCodes.Ldloc, sizeLocal);
+-
+- // Blit the array
+- ilg.Emit (OpCodes.Cpblk);
+-
+- // pos += bytesRead
+- ilg.Emit (OpCodes.Ldloc, readerLocal);
+- ilg.Emit (OpCodes.Ldloc, readerLocal);
+- ilg.Emit (OpCodes.Ldfld, posField);
+- ilg.Emit (OpCodes.Ldloc, sizeLocal);
+- ilg.Emit (OpCodes.Add);
+- ilg.Emit (OpCodes.Stfld, posField);
+-
+- ilg.Emit (OpCodes.Br, endLabel);
+- }
+-
+- if (!mustBlit) {
+- ilg.MarkLabel (nonBlitLabel);
+-
+- // for (int i = 0 ; i < ary.Length ; i++)
+- LocalBuilder indexLocal = ilg.DeclareLocal (typeof (int));
+- ilg.Emit (OpCodes.Ldc_I4_0);
+- ilg.Emit (OpCodes.Stloc, indexLocal);
+-
+- Label loopStartLabel = ilg.DefineLabel ();
+- Label loopEndLabel = ilg.DefineLabel ();
+-
+- ilg.Emit (OpCodes.Br, loopEndLabel);
+-
+- ilg.MarkLabel (loopStartLabel);
+-
+- {
+- // Read and store an element to the array
+- ilg.Emit (OpCodes.Ldloc, aryLocal);
+- ilg.Emit (OpCodes.Ldloc, indexLocal);
+-
+- ilg.Emit (OpCodes.Ldloc, readerLocal);
+- GenReader (ilg, tElem);
+-
+- ilg.Emit (OpCodes.Stelem, tElem);
+- }
+-
+- // i++
+- ilg.Emit (OpCodes.Ldloc, indexLocal);
+- ilg.Emit (OpCodes.Ldc_I4_1);
+- ilg.Emit (OpCodes.Add);
+- ilg.Emit (OpCodes.Stloc, indexLocal);
+-
+- ilg.MarkLabel (loopEndLabel);
+- ilg.Emit (OpCodes.Ldloc, indexLocal);
+- ilg.Emit (OpCodes.Ldloc, aryLocal);
+- ilg.Emit (OpCodes.Ldlen);
+- ilg.Emit (OpCodes.Blt, loopStartLabel);
+- }
+-
+- ilg.MarkLabel (endLabel);
+-
+- // Return the new array
+- ilg.Emit (OpCodes.Ldloc, aryLocal);
+- }
+-
+- public static void GenReadCollection (ILGenerator ilg, Type type)
+- {
+- //Console.WriteLine ("GenReadCollection " + type);
+- //Console.WriteLine ("Sig: " + Signature.GetSig (type));
+- int fixedSize = 0;
+- if (type.IsArray && Signature.GetSig (type.GetElementType ()).GetFixedSize (ref fixedSize)) {
+- GenReadArrayFixed (ilg, type, fixedSize);
+- return;
+- }
+-
+- LocalBuilder readerLocal = ilg.DeclareLocal (typeof (MessageReader));
+- ilg.Emit (OpCodes.Stloc, readerLocal);
+-
+- //Type[] genArgs = type.GetGenericArguments ();
+- Type[] genArgs = type.IsArray ? new Type[] { type.GetElementType () } : type.GetGenericArguments ();
+- //Type[] genArgs = new Type[] { type.GetElementType () };
+- //Type tElem = genArgs[0];
+-
+- //Type collType = Mapper.GetGenericType (typeof (List<>), genArgs);
+- Type collType = Mapper.GetGenericType (genArgs.Length == 2 ? typeof (Dictionary<,>) : typeof (List<>), genArgs);
+-
+- ConstructorInfo ctor = collType.GetConstructor (Type.EmptyTypes);
+- ilg.Emit (OpCodes.Newobj, ctor);
+-
+- LocalBuilder collLocal = ilg.DeclareLocal (collType);
+- ilg.Emit (OpCodes.Stloc, collLocal);
+-
+- //MethodInfo addMethod = dictType.GetMethod ("Add", new Type[] { tKey, tValue });
+- MethodInfo addMethod = collType.GetMethod ("Add", genArgs);
+-
+-
+- // Read the array's byte length
+- MethodInfo readUInt32Method = GetReadMethod (typeof (uint));
+- ilg.Emit (OpCodes.Ldloc, readerLocal);
+- ilg.Emit (readUInt32Method.IsFinal ? OpCodes.Call : OpCodes.Callvirt, readUInt32Method);
+-
+- {
+- // Align to 8 for structs
+- ilg.Emit (OpCodes.Ldloc, readerLocal);
+- //ilg.Emit (OpCodes.Ldc_I4, 8);
+- // TODO: This padding logic is sketchy
+- ilg.Emit (OpCodes.Ldc_I4, genArgs.Length > 1 ? 8 : Signature.GetSig (genArgs[0]).Alignment);
+- ilg.Emit (OpCodes.Call, messageReaderReadPad);
+- }
+-
+- // Similar to the fixed array loop code
+-
+- FieldInfo posField = typeof (MessageReader).GetField ("pos");
+- LocalBuilder endPosLocal = ilg.DeclareLocal (typeof (int));
+- ilg.Emit (OpCodes.Ldloc, readerLocal);
+- ilg.Emit (OpCodes.Ldfld, posField);
+-
+- // Add the current position and byte length to determine endPos
+- // TODO: Consider padding?
+- ilg.Emit (OpCodes.Add);
+- ilg.Emit (OpCodes.Stloc, endPosLocal);
+-
+- {
+- Label loopStartLabel = ilg.DefineLabel ();
+- Label loopEndLabel = ilg.DefineLabel ();
+-
+- ilg.Emit (OpCodes.Br, loopEndLabel);
+-
+- ilg.MarkLabel (loopStartLabel);
+-
+- {
+- if (genArgs.Length > 1) {
+- // Align to 8 for structs
+- ilg.Emit (OpCodes.Ldloc, readerLocal);
+- ilg.Emit (OpCodes.Ldc_I4, 8);
+- ilg.Emit (OpCodes.Call, messageReaderReadPad);
+- }
+-
+- // Read and store an element to the array
+- ilg.Emit (OpCodes.Ldloc, collLocal);
+-
+- foreach (Type genArg in genArgs) {
+- ilg.Emit (OpCodes.Ldloc, readerLocal);
+- GenReader (ilg, genArg);
+- }
+-
+- ilg.Emit (OpCodes.Call, addMethod);
+- }
+-
+- ilg.MarkLabel (loopEndLabel);
+-
+- //ilg.Emit (OpCodes.Ldloc, indexLocal);
+- ilg.Emit (OpCodes.Ldloc, readerLocal);
+- ilg.Emit (OpCodes.Ldfld, posField);
+-
+- ilg.Emit (OpCodes.Ldloc, endPosLocal);
+- ilg.Emit (OpCodes.Blt, loopStartLabel);
+- }
+-
+- // Return the new collection
+- ilg.Emit (OpCodes.Ldloc, collLocal);
+-
+- if (type.IsArray) {
+- MethodInfo toArrayMethod = collType.GetMethod ("ToArray", Type.EmptyTypes);
+- ilg.Emit (OpCodes.Call, toArrayMethod);
+- }
+- }
+- }
+-
+- internal delegate void TypeWriter<T> (MessageWriter writer, T value);
+-
+- internal delegate void MethodCaller (MessageReader rdr, Message msg, MessageWriter ret);
+- internal delegate void MethodCaller2 (object instance, MessageReader rdr, Message msg, MessageWriter ret);
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Unix.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Unix.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,484 +0,0 @@
+-// Copyright 2008 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.IO;
+-using System.Runtime.InteropServices;
+-
+-namespace NDesk.Unix
+-{
+- // size_t
+- using SizeT = System.UIntPtr;
+- // ssize_t
+- using SSizeT = System.IntPtr;
+- // socklen_t: assumed to be 4 bytes
+- // uid_t: assumed to be 4 bytes
+-
+- sealed class UnixStream : Stream //, IDisposable
+- {
+- public readonly UnixSocket usock;
+-
+- public UnixStream (int fd)
+- {
+- this.usock = new UnixSocket (fd);
+- }
+-
+- public UnixStream (UnixSocket usock)
+- {
+- this.usock = usock;
+- }
+-
+- public override bool CanRead
+- {
+- get {
+- return true;
+- }
+- }
+-
+- public override bool CanSeek
+- {
+- get {
+- return false;
+- }
+- }
+-
+- public override bool CanWrite
+- {
+- get {
+- return true;
+- }
+- }
+-
+- public override long Length
+- {
+- get {
+- throw new NotImplementedException ("Seeking is not implemented");
+- }
+- }
+-
+- public override long Position
+- {
+- get {
+- throw new NotImplementedException ("Seeking is not implemented");
+- } set {
+- throw new NotImplementedException ("Seeking is not implemented");
+- }
+- }
+-
+- public override long Seek (long offset, SeekOrigin origin)
+- {
+- throw new NotImplementedException ("Seeking is not implemented");
+- }
+-
+- public override void SetLength (long value)
+- {
+- throw new NotImplementedException ("Not implemented");
+- }
+-
+- public override void Flush ()
+- {
+- }
+-
+- public override int Read ([In, Out] byte[] buffer, int offset, int count)
+- {
+- return usock.Read (buffer, offset, count);
+- }
+-
+- public override void Write (byte[] buffer, int offset, int count)
+- {
+- usock.Write (buffer, offset, count);
+- }
+-
+- unsafe public override int ReadByte ()
+- {
+- byte value;
+- usock.Read (&value, 1);
+- return value;
+- }
+-
+- unsafe public override void WriteByte (byte value)
+- {
+- usock.Write (&value, 1);
+- }
+- }
+-
+- static class UnixUid
+- {
+- internal const string LIBC = "libc";
+-
+- [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=false)]
+- static extern uint getuid ();
+-
+- [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=false)]
+- static extern uint geteuid ();
+-
+- public static long GetUID ()
+- {
+- long uid = getuid ();
+- return uid;
+- }
+-
+- public static long GetEUID ()
+- {
+- long euid = geteuid ();
+- return euid;
+- }
+- }
+-
+- static class UnixError
+- {
+- internal const string LIBC = "libc";
+-
+- [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=false)]
+- static extern IntPtr strerror (int errnum);
+-
+- static string GetErrorString (int errnum)
+- {
+- IntPtr strPtr = strerror (errnum);
+-
+- if (strPtr == IntPtr.Zero)
+- return "Unknown Unix error";
+-
+- return Marshal.PtrToStringAnsi (strPtr);
+- }
+-
+- // FIXME: Don't hard-code this.
+- const int EINTR = 4;
+-
+- public static bool ShouldRetry
+- {
+- get {
+- int errno = System.Runtime.InteropServices.Marshal.GetLastWin32Error ();
+- return errno == EINTR;
+- }
+- }
+-
+- public static Exception GetLastUnixException ()
+- {
+- int errno = System.Runtime.InteropServices.Marshal.GetLastWin32Error ();
+- return new Exception (String.Format ("Error {0}: {1}", errno, GetErrorString (errno)));
+- }
+- }
+-
+- //[StructLayout(LayoutKind.Sequential, Pack=1)]
+- unsafe struct IOVector
+- {
+- public IOVector (IntPtr bbase, int length)
+- {
+- this.Base = (void*)bbase;
+- this.length = (SizeT)length;
+- }
+-
+- //public IntPtr Base;
+- public void* Base;
+-
+- public SizeT length;
+- public int Length
+- {
+- get {
+- return (int)length;
+- } set {
+- length = (SizeT)value;
+- }
+- }
+- }
+-
+- /*
+- unsafe class SockAddr
+- {
+- byte[] data;
+- }
+- */
+-
+- unsafe class UnixSocket
+- {
+- internal const string LIBC = "libc";
+-
+- // Solaris provides socket functionality in libsocket rather than libc.
+- // We use a dllmap in the .config to deal with this.
+- internal const string LIBSOCKET = "libsocket";
+-
+- public const short AF_UNIX = 1;
+- // FIXME: SOCK_STREAM is 2 on Solaris
+- public const short SOCK_STREAM = 1;
+-
+- [DllImport (LIBC, CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
+- internal static extern IntPtr fork ();
+-
+- [DllImport (LIBC, CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
+- internal static extern int dup2 (int fd, int fd2);
+-
+- [DllImport (LIBC, CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
+- internal static extern int open ([MarshalAs(UnmanagedType.LPStr)] string path, int oflag);
+-
+- [DllImport (LIBC, CallingConvention = CallingConvention.Cdecl, SetLastError = true)]
+- internal static extern IntPtr setsid ();
+-
+-
+- [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- internal static extern int close (int fd);
+-
+- [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- protected static extern int socket (int domain, int type, int protocol);
+-
+- [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- protected static extern int connect (int sockfd, byte[] serv_addr, uint addrlen);
+-
+- [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- protected static extern int bind (int sockfd, byte[] my_addr, uint addrlen);
+-
+- [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- protected static extern int listen (int sockfd, int backlog);
+-
+- //TODO: this prototype is probably wrong, fix it
+- [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- protected static extern int accept (int sockfd, void* addr, ref uint addrlen);
+-
+- //TODO: confirm and make use of these functions
+- [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- protected static extern int getsockopt (int s, int optname, IntPtr optval, ref uint optlen);
+-
+- [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- protected static extern int setsockopt (int s, int optname, IntPtr optval, uint optlen);
+-
+- [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- unsafe static extern SSizeT read (int fd, byte* buf, SizeT count);
+-
+- [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- unsafe static extern SSizeT write (int fd, byte* buf, SizeT count);
+-
+- [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- unsafe static extern SSizeT readv (int fd, IOVector* iov, int iovcnt);
+-
+- [DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- unsafe static extern SSizeT writev (int fd, IOVector* iov, int iovcnt);
+-
+- // Linux
+- //[DllImport (LIBC, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- //static extern int vmsplice (int fd, IOVector* iov, uint nr_segs, uint flags);
+-
+- [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- public static extern SSizeT recvmsg (int s, void* msg, int flags);
+-
+- [DllImport (LIBSOCKET, CallingConvention=CallingConvention.Cdecl, SetLastError=true)]
+- public static extern SSizeT sendmsg (int s, void* msg, int flags);
+-
+- public int Handle;
+- bool ownsHandle = false;
+-
+- public UnixSocket (int handle) : this (handle, false)
+- {
+- }
+-
+- public UnixSocket (int handle, bool ownsHandle)
+- {
+- this.Handle = handle;
+- this.ownsHandle = ownsHandle;
+- // TODO: SafeHandle?
+- }
+-
+- public UnixSocket ()
+- {
+- //TODO: don't hard-code PF_UNIX and SOCK_STREAM or SocketType.Stream
+- //AddressFamily family, SocketType type, ProtocolType proto
+-
+- int r = socket (AF_UNIX, SOCK_STREAM, 0);
+- if (r < 0)
+- throw UnixError.GetLastUnixException ();
+-
+- Handle = r;
+- ownsHandle = true;
+- }
+-
+- ~UnixSocket ()
+- {
+- if (ownsHandle && Handle > 0)
+- Close ();
+- }
+-
+- protected bool connected = false;
+-
+- //TODO: consider memory management
+- public void Close ()
+- {
+- int r = 0;
+-
+- do {
+- r = close (Handle);
+- } while (r < 0 && UnixError.ShouldRetry);
+-
+- if (r < 0)
+- throw UnixError.GetLastUnixException ();
+-
+- Handle = -1;
+- connected = false;
+- }
+-
+- //TODO: consider memory management
+- public void Connect (byte[] remote_end)
+- {
+- int r = 0;
+-
+- do {
+- r = connect (Handle, remote_end, (uint)remote_end.Length);
+- } while (r < 0 && UnixError.ShouldRetry);
+-
+- if (r < 0)
+- throw UnixError.GetLastUnixException ();
+-
+- connected = true;
+- }
+-
+- //assigns a name to the socket
+- public void Bind (byte[] local_end)
+- {
+- int r = bind (Handle, local_end, (uint)local_end.Length);
+- if (r < 0)
+- throw UnixError.GetLastUnixException ();
+- }
+-
+- public void Listen (int backlog)
+- {
+- int r = listen (Handle, backlog);
+- if (r < 0)
+- throw UnixError.GetLastUnixException ();
+- }
+-
+- public UnixSocket Accept ()
+- {
+- byte[] addr = new byte[110];
+- uint addrlen = (uint)addr.Length;
+-
+- fixed (byte* addrP = addr) {
+- int r = 0;
+-
+- do {
+- r = accept (Handle, addrP, ref addrlen);
+- } while (r < 0 && UnixError.ShouldRetry);
+-
+- if (r < 0)
+- throw UnixError.GetLastUnixException ();
+-
+- //TODO: use the returned addr
+- //string str = Encoding.Default.GetString (addr, 0, (int)addrlen);
+- return new UnixSocket (r, true);
+- }
+- }
+-
+- unsafe public int Read (byte[] buf, int offset, int count)
+- {
+- fixed (byte* bufP = buf)
+- return Read (bufP + offset, count);
+- }
+-
+- public int Write (byte[] buf, int offset, int count)
+- {
+- fixed (byte* bufP = buf)
+- return Write (bufP + offset, count);
+- }
+-
+- unsafe public int Read (byte* bufP, int count)
+- {
+- int r = 0;
+-
+- do {
+- r = (int)read (Handle, bufP, (SizeT)count);
+- } while (r < 0 && UnixError.ShouldRetry);
+-
+- if (r < 0)
+- throw UnixError.GetLastUnixException ();
+-
+- return r;
+- }
+-
+- public int Write (byte* bufP, int count)
+- {
+- int r = 0;
+-
+- do {
+- r = (int)write (Handle, bufP, (SizeT)count);
+- } while (r < 0 && UnixError.ShouldRetry);
+-
+- if (r < 0)
+- throw UnixError.GetLastUnixException ();
+-
+- return r;
+- }
+-
+- public int RecvMsg (void* bufP, int flags)
+- {
+- int r = 0;
+-
+- do {
+- r = (int)recvmsg (Handle, bufP, flags);
+- } while (r < 0 && UnixError.ShouldRetry);
+-
+- if (r < 0)
+- throw UnixError.GetLastUnixException ();
+-
+- return r;
+- }
+-
+- public int SendMsg (void* bufP, int flags)
+- {
+- int r = 0;
+-
+- do {
+- r = (int)sendmsg (Handle, bufP, flags);
+- } while (r < 0 && UnixError.ShouldRetry);
+-
+- if (r < 0)
+- throw UnixError.GetLastUnixException ();
+-
+- return r;
+- }
+-
+- public int ReadV (IOVector* iov, int count)
+- {
+- //FIXME: Handle EINTR here or elsewhere
+- //FIXME: handle r != count
+- //TODO: check offset correctness
+-
+- int r = (int)readv (Handle, iov, count);
+- if (r < 0)
+- throw UnixError.GetLastUnixException ();
+-
+- return r;
+- }
+-
+- public int WriteV (IOVector* iov, int count)
+- {
+- //FIXME: Handle EINTR here or elsewhere
+- //FIXME: handle r != count
+- //TODO: check offset correctness
+-
+- int r = (int)writev (Handle, iov, count);
+- if (r < 0)
+- throw UnixError.GetLastUnixException ();
+-
+- return r;
+- }
+-
+- public int Write (IOVector[] iov, int offset, int count)
+- {
+- //FIXME: Handle EINTR here or elsewhere
+- //FIXME: handle r != count
+- //TODO: check offset correctness
+-
+- fixed (IOVector* bufP = &iov[offset]) {
+- int r = (int)writev (Handle, bufP + offset, count);
+- if (r < 0)
+- throw UnixError.GetLastUnixException ();
+-
+- return r;
+- }
+- }
+-
+- public int Write (IOVector[] iov)
+- {
+- return Write (iov, 0, iov.Length);
+- }
+-
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/UnixMonoTransport.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/UnixMonoTransport.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,66 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.IO;
+-using System.Net;
+-using System.Net.Sockets;
+-
+-using Mono.Unix;
+-using Mono.Unix.Native;
+-
+-namespace NDesk.DBus.Transports
+-{
+- class UnixMonoTransport : UnixTransport
+- {
+- protected Socket socket;
+-
+- public override void Open (string path, bool @abstract)
+- {
+- if (@abstract)
+- socket = OpenAbstractUnix (path);
+- else
+- socket = OpenUnix (path);
+-
+- socket.Blocking = true;
+- SocketHandle = (long)socket.Handle;
+- //Stream = new UnixStream ((int)socket.Handle);
+- Stream = new NetworkStream (socket);
+- }
+-
+- //send peer credentials null byte. note that this might not be portable
+- //there are also selinux, BSD etc. considerations
+- public override void WriteCred ()
+- {
+- Stream.WriteByte (0);
+- }
+-
+- public override string AuthString ()
+- {
+- long uid = UnixUserInfo.GetRealUserId ();
+-
+- return uid.ToString ();
+- }
+-
+- protected Socket OpenAbstractUnix (string path)
+- {
+- AbstractUnixEndPoint ep = new AbstractUnixEndPoint (path);
+-
+- Socket client = new Socket (AddressFamily.Unix, SocketType.Stream, 0);
+- client.Connect (ep);
+-
+- return client;
+- }
+-
+- public Socket OpenUnix (string path)
+- {
+- UnixEndPoint remoteEndPoint = new UnixEndPoint (path);
+-
+- Socket client = new Socket (AddressFamily.Unix, SocketType.Stream, 0);
+- client.Connect (remoteEndPoint);
+-
+- return client;
+- }
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/UnixNativeTransport.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/UnixNativeTransport.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,192 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-//We send BSD-style credentials on all platforms
+-//Doesn't seem to break Linux (but is redundant there)
+-//This may turn out to be a bad idea
+-#define HAVE_CMSGCRED
+-
+-using System;
+-using System.IO;
+-using System.Text;
+-using System.Runtime.InteropServices;
+-using NDesk.Unix;
+-
+-namespace NDesk.DBus.Transports
+-{
+- class UnixNativeTransport : UnixTransport
+- {
+- //protected UnixSocket socket;
+- internal UnixSocket socket;
+-
+- public override string AuthString ()
+- {
+- long uid = UnixUid.GetEUID ();
+- return uid.ToString ();
+- }
+-
+- public override void Open (string path, bool @abstract)
+- {
+- if (String.IsNullOrEmpty (path))
+- throw new ArgumentException ("path");
+-
+- if (@abstract)
+- socket = OpenAbstractUnix (path);
+- else
+- socket = OpenUnix (path);
+-
+- //socket.Blocking = true;
+- SocketHandle = (long)socket.Handle;
+- //Stream = new UnixStream ((int)socket.Handle);
+- Stream = new UnixStream (socket);
+- }
+-
+- //send peer credentials null byte
+- //different platforms do this in different ways
+-#if HAVE_CMSGCRED
+- unsafe void WriteBsdCred ()
+- {
+- //null credentials byte
+- byte buf = 0;
+-
+- IOVector iov = new IOVector ();
+- //iov.Base = (IntPtr)(&buf);
+- iov.Base = &buf;
+- iov.Length = 1;
+-
+- msghdr msg = new msghdr ();
+- msg.msg_iov = &iov;
+- msg.msg_iovlen = 1;
+-
+- cmsg cm = new cmsg ();
+- msg.msg_control = (IntPtr)(&cm);
+- msg.msg_controllen = (uint)sizeof (cmsg);
+- cm.hdr.cmsg_len = (uint)sizeof (cmsg);
+- cm.hdr.cmsg_level = 0xffff; //SOL_SOCKET
+- cm.hdr.cmsg_type = 0x03; //SCM_CREDS
+-
+- int written = socket.SendMsg (&msg, 0);
+- if (written != 1)
+- throw new Exception ("Failed to write credentials");
+- }
+-#endif
+-
+- public override void WriteCred ()
+- {
+-#if HAVE_CMSGCRED
+- try {
+- WriteBsdCred ();
+- return;
+- } catch {
+- if (Protocol.Verbose)
+- Console.Error.WriteLine ("Warning: WriteBsdCred() failed; falling back to ordinary WriteCred()");
+- }
+-#endif
+- //null credentials byte
+- byte buf = 0;
+- Stream.WriteByte (buf);
+- }
+-
+- public static byte[] GetSockAddr (string path)
+- {
+- byte[] p = Encoding.Default.GetBytes (path);
+-
+- byte[] sa = new byte[2 + p.Length + 1];
+-
+- //we use BitConverter to stay endian-safe
+- byte[] afData = BitConverter.GetBytes (UnixSocket.AF_UNIX);
+- sa[0] = afData[0];
+- sa[1] = afData[1];
+-
+- for (int i = 0 ; i != p.Length ; i++)
+- sa[2 + i] = p[i];
+- sa[2 + p.Length] = 0; //null suffix for domain socket addresses, see unix(7)
+-
+- return sa;
+- }
+-
+- public static byte[] GetSockAddrAbstract (string path)
+- {
+- byte[] p = Encoding.Default.GetBytes (path);
+-
+- byte[] sa = new byte[2 + 1 + p.Length];
+-
+- //we use BitConverter to stay endian-safe
+- byte[] afData = BitConverter.GetBytes (UnixSocket.AF_UNIX);
+- sa[0] = afData[0];
+- sa[1] = afData[1];
+-
+- sa[2] = 0; //null prefix for abstract domain socket addresses, see unix(7)
+- for (int i = 0 ; i != p.Length ; i++)
+- sa[3 + i] = p[i];
+-
+- return sa;
+- }
+-
+- internal UnixSocket OpenUnix (string path)
+- {
+- byte[] sa = GetSockAddr (path);
+- UnixSocket client = new UnixSocket ();
+- client.Connect (sa);
+- return client;
+- }
+-
+- internal UnixSocket OpenAbstractUnix (string path)
+- {
+- byte[] sa = GetSockAddrAbstract (path);
+- UnixSocket client = new UnixSocket ();
+- client.Connect (sa);
+- return client;
+- }
+- }
+-
+-#if HAVE_CMSGCRED
+- /*
+- public struct msg
+- {
+- public IntPtr msg_next;
+- public long msg_type;
+- public ushort msg_ts;
+- short msg_spot;
+- IntPtr label;
+- }
+- */
+-
+- unsafe struct msghdr
+- {
+- public IntPtr msg_name; //optional address
+- public uint msg_namelen; //size of address
+- public IOVector *msg_iov; //scatter/gather array
+- public int msg_iovlen; //# elements in msg_iov
+- public IntPtr msg_control; //ancillary data, see below
+- public uint msg_controllen; //ancillary data buffer len
+- public int msg_flags; //flags on received message
+- }
+-
+- struct cmsghdr
+- {
+- public uint cmsg_len; //data byte count, including header
+- public int cmsg_level; //originating protocol
+- public int cmsg_type; //protocol-specific type
+- }
+-
+- unsafe struct cmsgcred
+- {
+- const int CMGROUP_MAX = 16;
+-
+- public int cmcred_pid; //PID of sending process
+- public uint cmcred_uid; //real UID of sending process
+- public uint cmcred_euid; //effective UID of sending process
+- public uint cmcred_gid; //real GID of sending process
+- public short cmcred_ngroups; //number or groups
+- public fixed uint cmcred_groups[CMGROUP_MAX]; //groups
+- }
+-
+- struct cmsg
+- {
+- public cmsghdr hdr;
+- public cmsgcred cred;
+- }
+-#endif
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/UnixTransport.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/UnixTransport.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,29 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.IO;
+-
+-namespace NDesk.DBus.Transports
+-{
+- abstract class UnixTransport : Transport
+- {
+- public override void Open (AddressEntry entry)
+- {
+- string path;
+- bool abstr;
+-
+- if (entry.Properties.TryGetValue ("path", out path))
+- abstr = false;
+- else if (entry.Properties.TryGetValue ("abstract", out path))
+- abstr = true;
+- else
+- throw new Exception ("No path specified for UNIX transport");
+-
+- Open (path, abstr);
+- }
+-
+- public abstract void Open (string path, bool @abstract);
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Wrapper.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/NDesk.DBus/Wrapper.cs 2011-06-26 23:45:40.000000000 +0800
++++ /dev/null 1970-01-01 00:00:00.000000000 +0000
+@@ -1,158 +0,0 @@
+-// Copyright 2006 Alp Toker <alp at atoker.com>
+-// This software is made available under the MIT License
+-// See COPYING for details
+-
+-using System;
+-using System.Collections.Generic;
+-using System.IO;
+-
+-namespace NDesk.DBus
+-{
+- //TODO: complete and use these wrapper classes
+- //not sure exactly what I'm thinking but there seems to be sense here
+-
+- //FIXME: signature sending/receiving is currently ambiguous in this code
+- //FIXME: in fact, these classes are totally broken and end up doing no-op, do not use without understanding the problem
+- class MethodCall
+- {
+- public Message message = new Message ();
+-
+- public MethodCall (ObjectPath path, string @interface, string member, string destination, Signature signature)
+- {
+- message.Header.MessageType = MessageType.MethodCall;
+- message.ReplyExpected = true;
+- message.Header[FieldCode.Path] = path;
+- message.Header[FieldCode.Interface] = @interface;
+- message.Header[FieldCode.Member] = member;
+- message.Header[FieldCode.Destination] = destination;
+- //TODO: consider setting Sender here for p2p situations
+- //this will allow us to remove the p2p hacks in MethodCall and Message
+-#if PROTO_REPLY_SIGNATURE
+- //TODO
+-#endif
+- message.Signature = signature;
+- }
+-
+- public MethodCall (Message message)
+- {
+- this.message = message;
+- Path = (ObjectPath)message.Header[FieldCode.Path];
+- Interface = (string)message.Header[FieldCode.Interface];
+- Member = (string)message.Header[FieldCode.Member];
+- Destination = (string)message.Header[FieldCode.Destination];
+- //TODO: filled by the bus so reliable, but not the case for p2p
+- //so we make it optional here, but this needs some more thought
+- //if (message.Header.Fields.ContainsKey (FieldCode.Sender))
+- Sender = (string)message.Header[FieldCode.Sender];
+-#if PROTO_REPLY_SIGNATURE
+- //TODO: note that an empty ReplySignature should really be treated differently to the field not existing!
+- if (message.Header.Fields.ContainsKey (FieldCode.ReplySignature))
+- ReplySignature = (Signature)message.Header[FieldCode.ReplySignature];
+- else
+- ReplySignature = Signature.Empty;
+-#endif
+- Signature = message.Signature;
+- }
+-
+- public ObjectPath Path;
+- public string Interface;
+- public string Member;
+- public string Destination;
+- public string Sender;
+-#if PROTO_REPLY_SIGNATURE
+- public Signature ReplySignature;
+-#endif
+- public Signature Signature;
+-
+- public Error CreateError (string errorName, string errorMessage)
+- {
+- Error error = new Error (errorName, message.Header.Serial);
+- error.message.Signature = Signature.StringSig;
+-
+- MessageWriter writer = new MessageWriter (message.Header.Endianness);
+- //writer.connection = conn;
+- writer.Write (errorMessage);
+- error.message.Body = writer.ToArray ();
+-
+- //if (method_call.Sender != null)
+- // replyMsg.Header[FieldCode.Destination] = method_call.Sender;
+-
+- return error;
+- }
+- }
+-
+- class MethodReturn
+- {
+- public Message message = new Message ();
+-
+- public MethodReturn (uint reply_serial)
+- {
+- message.Header.MessageType = MessageType.MethodReturn;
+- message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart;
+- message.Header[FieldCode.ReplySerial] = reply_serial;
+- //signature optional?
+- //message.Header[FieldCode.Signature] = signature;
+- }
+-
+- public MethodReturn (Message message)
+- {
+- this.message = message;
+- ReplySerial = (uint)message.Header[FieldCode.ReplySerial];
+- }
+-
+- public uint ReplySerial;
+- }
+-
+- class Error
+- {
+- public Message message = new Message ();
+-
+- public Error (string error_name, uint reply_serial)
+- {
+- message.Header.MessageType = MessageType.Error;
+- message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart;
+- message.Header[FieldCode.ErrorName] = error_name;
+- message.Header[FieldCode.ReplySerial] = reply_serial;
+- }
+-
+- public Error (Message message)
+- {
+- this.message = message;
+- ErrorName = (string)message.Header[FieldCode.ErrorName];
+- ReplySerial = (uint)message.Header[FieldCode.ReplySerial];
+- //Signature = (Signature)message.Header[FieldCode.Signature];
+- }
+-
+- public string ErrorName;
+- public uint ReplySerial;
+- //public Signature Signature;
+- }
+-
+- class Signal
+- {
+- public Message message = new Message ();
+-
+- public Signal (ObjectPath path, string @interface, string member)
+- {
+- message.Header.MessageType = MessageType.Signal;
+- message.Header.Flags = HeaderFlag.NoReplyExpected | HeaderFlag.NoAutoStart;
+- message.Header[FieldCode.Path] = path;
+- message.Header[FieldCode.Interface] = @interface;
+- message.Header[FieldCode.Member] = member;
+- }
+-
+- public Signal (Message message)
+- {
+- this.message = message;
+- Path = (ObjectPath)message.Header[FieldCode.Path];
+- Interface = (string)message.Header[FieldCode.Interface];
+- Member = (string)message.Header[FieldCode.Member];
+- Sender = (string)message.Header[FieldCode.Sender];
+- }
+-
+- public ObjectPath Path;
+- public string Interface;
+- public string Member;
+- public string Sender;
+- }
+-}
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Telepathy/MissionControl.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Telepathy/MissionControl.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Telepathy/MissionControl.cs 2011-07-06 04:00:39.075824960 +0800
+@@ -23,7 +23,7 @@
+
+ using System;
+ using System.Collections.Generic;
+-using NDesk.DBus;
++using DBus;
+
+ namespace Telepathy.MissionControl
+ {
+Index: banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Telepathy/Telepathy.cs
+===================================================================
+--- banshee-community-extensions.orig/src/Telepathy/Banshee.Telepathy/Telepathy/Telepathy.cs 2011-06-26 23:45:40.000000000 +0800
++++ banshee-community-extensions/src/Telepathy/Banshee.Telepathy/Telepathy/Telepathy.cs 2011-07-06 04:00:39.075824960 +0800
+@@ -24,7 +24,7 @@
+
+ using System;
+ using System.Collections.Generic;
+-using NDesk.DBus;
++using DBus;
+
+ namespace Telepathy
+ {
diff --git a/debian/patches/series b/debian/patches/series
index 41d2436..2558e82 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
+0001-Use-DBus-instead-of-NDesk.DBus.patch
fsck-intltool.patch
--
banshee-community-extensions
More information about the Pkg-cli-apps-commits
mailing list