Exemplo n.º 1
0
        public Object(eldbus.Connection conn, string bus, string path)
        {
            if (conn == null)
            {
                throw new System.ArgumentNullException("conn");
            }

            if (bus == null)
            {
                throw new System.ArgumentNullException("bus");
            }

            if (path == null)
            {
                throw new System.ArgumentNullException("path");
            }

            var handle = eldbus_object_get(conn.Handle, bus, path);

            if (handle == IntPtr.Zero)
            {
                throw new SEHException("Eldbus: could not get `Object' object from eldbus_object_get");
            }

            InitNew(handle, true);
        }
Exemplo n.º 2
0
        public static void eldbus_connection_get_unique_name()
        {
            var conn = new eldbus.Connection(eldbus.Connection.Type.Session);

            Console.WriteLine(conn.GetUniqueName());
            conn.Dispose();
        }
Exemplo n.º 3
0
        public static void utc_eldbus_introspect_p()
        {
            var conn = new eldbus.Connection(eldbus.Connection.Type.System);

            var obj = new eldbus.Object(conn, DBusBus, DBusPath);

            IntPtr timeout        = IntPtr.Zero;
            int    messageCapture = 0;
            bool   isSuccess      = false;

            eldbus.MessageDelegate objectMessageCb = delegate(eldbus.Message msg, eldbus.Pending p)
            {
                try
                {
                    if (timeout != IntPtr.Zero)
                    {
                        ecore_timer_del(timeout);
                        timeout = IntPtr.Zero;
                    }

                    string errname;
                    string errmsg;

                    if (messageCapture == 5)
                    {
                        if (!msg.GetError(out errname, out errmsg))
                        {
                            string txt;
                            if (msg.Get(out txt))
                            {
                                if (!String.IsNullOrEmpty(txt))
                                {
                                    isSuccess = true;
                                }
                            }
                        }
                    }
                }
                finally
                {
                    ecore_main_loop_quit();
                }
            };

            eldbus.Pending pending = obj.Introspect(objectMessageCb);

            AssertEquals(pending.GetMethod(), "Introspect");

            timeout = ecore_timer_add(2.0, GetEcoreLoopClose(), IntPtr.Zero);
            Assert(timeout != IntPtr.Zero);

            messageCapture = 5;

            ecore_main_loop_begin();

            Assert(isSuccess, "Method Introspect is not call");

            obj.Dispose();
            conn.Dispose();
        }
Exemplo n.º 4
0
        public static void utc_eldbus_introspect_p()
        {
            var app  = Efl.App.AppMain;
            var conn = new eldbus.Connection(eldbus.Connection.Type.Session);

            var obj = new eldbus.Object(conn, DBusBus, DBusPath);

            int  messageCapture = 0;
            bool isSuccess      = false;

            eldbus.MessageDelegate objectMessageCb = delegate(eldbus.Message msg, eldbus.Pending p)
            {
                try
                {
                    string errname;
                    string errmsg;

                    if (messageCapture == 5)
                    {
                        if (!msg.GetError(out errname, out errmsg))
                        {
                            string txt;
                            if (msg.Get(out txt))
                            {
                                if (!String.IsNullOrEmpty(txt))
                                {
                                    isSuccess = true;
                                }
                            }
                        }
                    }
                }
                finally
                {
                    app.Quit(0);
                }
            };

            eldbus.Pending pending = obj.Introspect(objectMessageCb);

            AssertEquals(pending.GetMethod(), "Introspect");

            var timer = new Efl.LoopTimer(app, 2.0);

            timer.TimerTickEvent += (object sender, EventArgs e) => {
                app.Quit(0);
            };

            messageCapture = 5;

            app.Begin();

            Assert(isSuccess, "Method Introspect is not call");

            timer.Dispose();
            obj.Dispose();
            conn.Dispose();
        }
Exemplo n.º 5
0
        private static void ActivableList(eldbus.MessageDelegate messageCb)
        {
            isSuccess = false;

            var conn = new eldbus.Connection(eldbus.Connection.Type.System);

            eldbus.Pending pending = conn.ActivableList(messageCb);

            timeout = ecore_timer_add(2.0, GetEcoreLoopClose(), IntPtr.Zero);
            Assert(timeout != IntPtr.Zero);

            ecore_main_loop_begin();

            Assert(isSuccess, "Method ListActivatableNames is not call");

            conn.Dispose();
        }
Exemplo n.º 6
0
        public static void utc_eldbus_message_ref_unref_p()
        {
            var conn = new eldbus.Connection(eldbus.Connection.Type.Session);

            eldbus.Message msg = eldbus.Message.NewMethodCall(DBusBus, DBusPath, DBusInterface, "GetId");

            msg.Ref();
            msg.Unref();

            string pathMsg = msg.GetPath();

            AssertEquals(DBusPath, pathMsg);

            msg.Unref();
            msg.Own = false;

            msg.Dispose();
            conn.Dispose();
        }
Exemplo n.º 7
0
        private static void ActivatableList(eldbus.MessageDelegate messageCb)
        {
            isSuccess = false;

            var app  = Efl.App.AppMain;
            var conn = new eldbus.Connection(eldbus.Connection.Type.Session);

            eldbus.Pending pending = conn.ActivatableList(messageCb);

            AssertEquals(pending.GetMethod(), "ListActivatableNames");

            var timer = new Efl.LoopTimer(app, 2.0);

            timer.TimerTickEvent += (object sender, EventArgs e) => {
                app.Quit(0);
            };

            app.Begin();

            Assert(isSuccess, "Method ListActivatableNames is not call");

            timer.Dispose();
            conn.Dispose();
        }
Exemplo n.º 8
0
        public static void utc_eldbus_object_send_info_get_p()
        {
            var app  = Efl.App.AppMain;
            var conn = new eldbus.Connection(eldbus.Connection.Type.Session);

            var obj = new eldbus.Object(conn, DBusBus, DBusPath);

            string busFromObject = obj.GetBusName();

            AssertEquals(DBusBus, busFromObject);

            string pathFromObject = obj.GetPath();

            AssertEquals(DBusPath, pathFromObject);

            obj.Ref();
            obj.Unref();

            {
                var connectionFromObj = obj.GetConnection();
                Assert(conn.Handle == connectionFromObj.Handle);
                connectionFromObj.Dispose();
            }

            int  messageCapture = 0;
            bool isSuccess      = false;

            eldbus.MessageDelegate objectMessageCb = delegate(eldbus.Message msg, eldbus.Pending p)
            {
                try
                {
                    string errname;
                    string errmsg;

                    if (messageCapture == 5)
                    {
                        if (!msg.GetError(out errname, out errmsg))
                        {
                            string txt;
                            if (msg.Get(out txt))
                            {
                                if (!String.IsNullOrEmpty(txt))
                                {
                                    isSuccess = true;
                                }
                            }
                        }
                    }
                }
                finally
                {
                    app.Quit(0);
                }
            };

            var methodName = "GetId";
            var message    = obj.NewMethodCall(DBusInterface, methodName);

            eldbus.Pending pending = obj.Send(message, objectMessageCb, -1);

            AssertEquals(pending.GetMethod(), methodName);

            var timer = new Efl.LoopTimer(app, 2.0);

            timer.TimerTickEvent += (object sender, EventArgs e) => {
                app.Quit(0);
            };

            messageCapture = 5;

            app.Begin();

            Assert(isSuccess, $"Method {methodName} is not call");

            timer.Dispose();
            message.Dispose();
            obj.Dispose();
            conn.Dispose();
        }
Exemplo n.º 9
0
        public static void eldbus_connection_new_starter()
        {
            var conn = new eldbus.Connection(eldbus.Connection.Type.Starter);

            conn.Dispose();
        }
Exemplo n.º 10
0
        public static void eldbus_connection_new_session()
        {
            var conn = new eldbus.Connection(eldbus.Connection.Type.Session);

            conn.Dispose();
        }
Exemplo n.º 11
0
        public static void utc_eldbus_message_info_data_get_p()
        {
            isSuccess = false;

            var app  = Efl.App.AppMain;
            var conn = new eldbus.Connection(eldbus.Connection.Type.Session);

            string methodName = "GetId";

            eldbus.Message msg = eldbus.Message.NewMethodCall(DBusBus, DBusPath, DBusInterface, methodName);

            string interfaceMsg = msg.GetInterface();

            AssertEquals(DBusInterface, interfaceMsg);

            string methodMsg = msg.GetMember();

            AssertEquals(methodName, methodMsg);

            string pathMsg = msg.GetPath();

            AssertEquals(DBusPath, pathMsg);

            eldbus.MessageDelegate messageMethodCb = delegate(eldbus.Message m, eldbus.Pending p)
            {
                try
                {
                    string errname, errmsg;
                    if (!m.GetError(out errname, out errmsg))
                    {
                        string txt;
                        if (m.Get(out txt))
                        {
                            if (!String.IsNullOrEmpty(txt))
                            {
                                if (m.GetSender() == DBusBus &&
                                    !String.IsNullOrEmpty(m.GetDestination()))
                                {
                                    isSuccess = true;
                                }
                            }
                        }
                    }
                }
                finally
                {
                    app.Quit(0);
                }
            };

            const int timeoutSendMs = 1000;

            eldbus.Pending pending = conn.Send(msg, messageMethodCb, timeoutSendMs);

            AssertEquals(pending.GetMethod(), methodName);

            var timer = new Efl.LoopTimer(app, 2.0);

            timer.TimerTickEvent += (object sender, EventArgs e) => {
                app.Quit(0);
            };

            app.Begin();

            Assert(isSuccess, $"Method {methodName} is not call");

            timer.Dispose();
            msg.Dispose();
            conn.Dispose();
        }
Exemplo n.º 12
0
        public static void eldbus_connection_new_system()
        {
            var conn = new eldbus.Connection(eldbus.Connection.Type.System);

            conn.Dispose();
        }
Exemplo n.º 13
0
        public static void utc_eldbus_message_info_data_get_p()
        {
            isSuccess = false;

            var conn = new eldbus.Connection(eldbus.Connection.Type.System);

            string methodName = "GetId";

            eldbus.Message msg = eldbus.Message.NewMethodCall(DBusBus, DBusPath, DBusInterface, methodName);

            string interfaceMsg = msg.GetInterface();

            AssertEquals(DBusInterface, interfaceMsg);

            string methodMsg = msg.GetMember();

            AssertEquals(methodName, methodMsg);

            string pathMsg = msg.GetPath();

            AssertEquals(DBusPath, pathMsg);

            eldbus.MessageDelegate messageMethodCb = delegate(eldbus.Message m, eldbus.Pending p)
            {
                try
                {
                    if (timeout != IntPtr.Zero)
                    {
                        ecore_timer_del(timeout);
                        timeout = IntPtr.Zero;
                    }

                    string errname, errmsg;
                    if (!m.GetError(out errname, out errmsg))
                    {
                        string txt;
                        if (m.Get(out txt))
                        {
                            if (!String.IsNullOrEmpty(txt))
                            {
                                if (m.GetSender() == DBusBus &&
                                    !String.IsNullOrEmpty(m.GetDestination()))
                                {
                                    isSuccess = true;
                                }
                            }
                        }
                    }
                }
                finally
                {
                    ecore_main_loop_quit();
                }
            };

            const int timeoutSendMs = 1000;

            eldbus.Pending pending = conn.Send(msg, messageMethodCb, timeoutSendMs);

            AssertEquals(pending.GetMethod(), methodName);

            timeout = ecore_timer_add(2.0, GetEcoreLoopClose(), IntPtr.Zero);
            Assert(timeout != IntPtr.Zero);

            ecore_main_loop_begin();

            Assert(isSuccess, $"Method {methodName} is not call");

            msg.Dispose();
            conn.Dispose();
        }
Exemplo n.º 14
0
        public static void utc_eldbus_object_send_info_get_p()
        {
            var conn = new eldbus.Connection(eldbus.Connection.Type.System);

            var obj = new eldbus.Object(conn, DBusBus, DBusPath);

            string busFromObject = obj.GetBusName();

            AssertEquals(DBusBus, busFromObject);

            string pathFromObject = obj.GetPath();

            AssertEquals(DBusPath, pathFromObject);

            obj.Ref();
            obj.Unref();

            {
                var connectionFromObj = obj.GetConnection();
                Assert(conn.Handle == connectionFromObj.Handle);
                connectionFromObj.Dispose();
            }

            IntPtr timeout        = IntPtr.Zero;
            int    messageCapture = 0;
            bool   isSuccess      = false;

            eldbus.MessageDelegate objectMessageCb = delegate(eldbus.Message msg, eldbus.Pending p)
            {
                try
                {
                    if (timeout != IntPtr.Zero)
                    {
                        ecore_timer_del(timeout);
                        timeout = IntPtr.Zero;
                    }

                    string errname;
                    string errmsg;

                    if (messageCapture == 5)
                    {
                        if (!msg.GetError(out errname, out errmsg))
                        {
                            string txt;
                            if (msg.Get(out txt))
                            {
                                if (!String.IsNullOrEmpty(txt))
                                {
                                    isSuccess = true;
                                }
                            }
                        }
                    }
                }
                finally
                {
                    ecore_main_loop_quit();
                }
            };

            var methodName = "GetId";
            var message    = obj.NewMethodCall(DBusInterface, methodName);

            eldbus.Pending pending = obj.Send(message, objectMessageCb, -1);

            AssertEquals(pending.GetMethod(), methodName);

            timeout = ecore_timer_add(2.0, GetEcoreLoopClose(), IntPtr.Zero);
            Assert(timeout != IntPtr.Zero);

            messageCapture = 5;

            ecore_main_loop_begin();

            Assert(isSuccess, $"Method {methodName} is not call");

            message.Dispose();
            obj.Dispose();
            conn.Dispose();
        }