public DynamicExportObject(Connection conn, ObjectPath object_path, object obj) : base(conn, object_path, obj) { //this.obj = obj; ScriptRuntime runtime = ScriptRuntime.CreateFromConfiguration (); ops = runtime.CreateOperations (); }
public Manager() { dbus_connection = Bus.GetSystemBus(); dbus_service = Service.Get(dbus_connection, INTERFACE_NAME); manager = (ManagerProxy)dbus_service.GetObject(typeof(ManagerProxy), PATH_NAME); dbus_service.SignalCalled += OnSignalCalled; }
protected Dispatcher(Connection conn, string channel_type, string [] property_keys) { this.conn = conn; ChannelType = channel_type; this.property_keys = property_keys; InitializeRequestsInterface (); }
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; }
protected Channel(Connection conn) { if (conn == null) { throw new ArgumentNullException ("conn"); } this.conn = conn; InitializeRequestsInterface (); }
protected Channel(Connection conn, uint target_handle, string channel_type) : this(conn) { if (target_handle == 0 || target_handle == conn.SelfHandle) { throw new ArgumentException ("Invalid TargetId", "target_id"); } this.target_handle = target_handle; this.ChannelType = channel_type; }
public ContactListChannel(Connection conn, string target_id) : base(conn) { if (target_id == null) { throw new ArgumentNullException ("target_id"); } this.target_id = target_id; ChannelType = Constants.CHANNEL_TYPE_CONTACTLIST; }
public static void Init(Connection conn) { IOFunc dispatchHandler = delegate (IntPtr source, IOCondition condition, IntPtr data) { if ((condition & IOCondition.Hup) == IOCondition.Hup) { if (ProtocolInformation.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); }
public static void Main(string[] args) { Application.Init(); try { DBus.Connection connection = DBus.Bus.GetSessionBus(); DBus.Service service = new DBus.Service(connection, NotificationDaemon.Service); NotificationDaemon ndaemon = new NotificationDaemon(); service.RegisterObject(ndaemon, NotificationDaemon.Path); Console.WriteLine("Daemon active."); } catch (Exception e) { Console.WriteLine("Daemon active.", e.Message); } Application.Run(); }
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); }
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 void Init(Connection conn, IOFunc dispatchHandler) { IOChannel channel = new IOChannel ((int)conn.Transport.SocketHandle); IO.AddWatch (channel, IOCondition.In | IOCondition.Hup, dispatchHandler); }
public BusObject(Connection conn, string bus_name, ObjectPath object_path) { this.conn = conn; this.bus_name = bus_name; this.object_path = object_path; }
public PendingCall(Connection conn) { this.conn = conn; }
public static ExportObject CreateExportObject(Connection conn, ObjectPath object_path, object obj) { return new ExportObject(conn, object_path, obj); }
public ExportObject(Connection conn, ObjectPath object_path, object obj) : base(conn, null, object_path) { Object = obj; }
/* private void OnNewChannel (ObjectPath object_path, string channel_type, HandleType handle_type, uint handle, bool suppress_handler) { Console.WriteLine (MSG_PREFIX + "OnNewChannel: op {0}, type {1}, handle {2}", object_path, channel_type, handle); if (channel_type.Equals (CHANNEL_TYPE_DBUSTUBE)) { itube = bus.GetObject<IDBusTube> (CONNMANAGER_GABBLE_IFACE, object_path); //itube.NewTube += OnNewTube; itube.TubeChannelStateChanged += OnTubeChannelStateChanged; // get tube initiator handle // should be = to self_handle on client // should be != to self_handle on server Properties p = bus.GetObject<Properties> (CONNMANAGER_GABBLE_IFACE, object_path); tube_initiator = (uint) p.Get (CHANNEL_IFACE, "InitiatorHandle"); if (tube_initiator == self_handle) { Console.WriteLine (MSG_PREFIX + "Offering DTube"); addr = itube.OfferDBusTube (new Dictionary<string, object>()); Console.WriteLine (MSG_PREFIX + "Tube from {0} offered", addr); } else { addr = itube.AcceptDBusTube (); Console.WriteLine (MSG_PREFIX + "Tube from {0} accepted", addr); } } } */ /* private void OnNewTube (uint id, uint initiator, TubeType type, string service, IDictionary<string,object> parameters, TubeState state) { Console.WriteLine (MSG_PREFIX + "OnNewTube: id {0), initiator {1}, service {2}", id, initiator, service); switch (state) { case TubeState.LocalPending: if (type == TubeType.DBus && initiator != self_handle && service.Equals (DTUBETEST_IFACE)) { Console.WriteLine (MSG_PREFIX + "Accepting DTube"); itube.AcceptDBusTube (id); } break; } } */ private void OnTubeChannelStateChanged(TubeChannelState state) { Console.WriteLine (MSG_PREFIX + "OnTubeStateChanged: state {0}", state); switch (state) { // this state is never reached, so accepting OnNewChannel // leaving here just in case, however case TubeChannelState.LocalPending: addr = itube.Accept (SocketAccessControl.Localhost); Console.WriteLine (MSG_PREFIX + "Tube from {0} accepted", addr); break; // tube ready. set up connection and export/get object case TubeChannelState.Open: dbus_conn = Connection.Open (addr); BusG.Init (dbus_conn); if (tube_initiator != self_handle) RegisterDBusObject (); else { obj = dbus_conn.GetObject<IDTubeTest> (DTUBETEST_IFACE, new ObjectPath (DTUBETEST_PATH)); obj.TestSignal += OnTestSignal; obj.Hello (); IDictionary<string, object>[] dic = obj.HelloDictionary (); Console.WriteLine (MSG_PREFIX + "Got response on tube. Dictionary array has {0} items.", dic.Length); TestStruct[] ts = obj.HelloStruct (); Console.WriteLine (MSG_PREFIX + "Got response on tube. Struct array has {0} items", ts.Length); Properties p = dbus_conn.GetObject<Properties> (DTUBETEST_IFACE, new ObjectPath (DTUBETEST_PATH)); string property = (string) p.Get (DTUBETEST_IFACE, "TestProperty"); Console.WriteLine (MSG_PREFIX + "Got response on tube. Property {0}", property); itube.Close (); } break; case TubeChannelState.NotOffered: break; } }
public NameRequisition(Connection connection, bool allowReplacement) { this.Connection = connection; this.AllowReplacement = allowReplacement; }
public SkypeResponseHandler(Connection dbus) { dbus.Register(new ObjectPath("/com/Skype/Client"), this); }