Exemplo n.º 1
0
 public void AppendTo(eldbus.Message msg)
 {
     if (!InternalAppendTo(msg))
     {
         throw new SEHException("Eldbus: could not append basic type to eldbus.Message");
     }
 }
Exemplo n.º 2
0
        public static void MessageCbWrapper(IntPtr data, IntPtr msg_hdl, IntPtr pending_hdl)
        {
            MessageDelegate dlgt = Marshal.GetDelegateForFunctionPointer(data, typeof(MessageDelegate)) as MessageDelegate;

            if (dlgt == null)
            {
                Eina.Log.Error("Eldbus: invalid delegate pointer from Eldbus_Message_Cb");
                return;
            }

            eldbus.Message msg;
            eldbus.Pending pending;

            try
            {
                msg     = new eldbus.Message(msg_hdl, false);
                pending = new eldbus.Pending(pending_hdl, false);
            }
            catch (Exception e)
            {
                Eina.Log.Error("Eldbus: could not convert Eldbus_Message_Cb parameters. Exception: " + e.ToString());
                return;
            }

            try
            {
                dlgt(msg, pending);
            }
            catch (Exception e)
            {
                Eina.Log.Error("Eldbus: Eldbus_Message_Cb delegate error. Exception: " + e.ToString());
            }
        }
Exemplo n.º 3
0
        eldbus.Pending Send(eldbus.Message msg, eldbus.MessageDelegate dlgt = null, double timeout = -1)
        {
            CheckHandle();

            if (msg == null)
            {
                throw new ArgumentNullException(nameof(msg));
            }

            // Native send() takes ownership of the message. We ref here to keep the IDisposable
            // behavior simpler and keeping the original object alive in case the user wants.
            msg.Ref();

            IntPtr cb_wrapper = dlgt == null ? IntPtr.Zero : eldbus.Common.GetMessageCbWrapperPtr();
            IntPtr cb_data    = dlgt == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(dlgt);

            var pending_hdl = eldbus_proxy_send(Handle, msg.Handle, cb_wrapper, cb_data, timeout);

            if (pending_hdl == IntPtr.Zero)
            {
                throw new SEHException("Eldbus: could not get `Pending' object from eldbus_proxy_send");
            }

            return(new eldbus.Pending(pending_hdl, false));
        }
 public void AppendTo(eldbus.Message msg)
 {
     if (!InternalAppendTo(msg))
     {
         eina.Error.RaiseIfOccurred();
         throw new SEHException("Eldbus: could not append basic type to eldbus.Message");
     }
 }
Exemplo n.º 5
0
        eldbus.Message SendAndBlock(eldbus.Message msg, double timeout = -1)
        {
            CheckHandle();
            var ptr = eldbus_proxy_send_and_block(Handle, msg.Handle, timeout);

            if (ptr == IntPtr.Zero)
            {
                throw new SEHException("Eldbus: could not get `Message' object from eldbus_proxy_send_and_block");
            }
            return(new eldbus.Message(ptr, true));
        }
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
        eldbus.Pending Send(eldbus.Message msg, eldbus.MessageDelegate dlgt = null, double timeout = -1)
        {
            CheckHandle();

            if (msg == null)
            {
                throw new ArgumentNullException("msg");
            }

            IntPtr cb_wrapper = dlgt == null ? IntPtr.Zero : eldbus.Common.GetMessageCbWrapperPtr();
            IntPtr cb_data    = dlgt == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(dlgt);

            var pending_hdl = eldbus_proxy_send(Handle, msg.Handle, cb_wrapper, cb_data, timeout);

            if (pending_hdl == IntPtr.Zero)
            {
                throw new SEHException("Eldbus: could not get `Pending' object from eldbus_proxy_send");
            }

            return(new eldbus.Pending(pending_hdl, false));
        }
Exemplo n.º 8
0
 protected override bool InternalAppendTo(eldbus.Message msg)
 {
     return(eldbus_message_arguments_append(msg.Handle, Signature, value));
 }
Exemplo n.º 9
0
 protected abstract bool InternalAppendTo(eldbus.Message msg);
Exemplo n.º 10
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.º 11
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();
        }