/* * Copyright 2019 by its authors. See AUTHORS. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma warning disable 1591 using System; using System.Runtime.InteropServices; using System.ComponentModel; using static eldbus.EldbusMessageNativeFunctions; namespace eldbus { /// /// Representation for Timeout flags. /// Since EFL 1.23. /// public static class Timeout { /// /// Infinite flag. /// Since EFL 1.23. /// public const int Infinite = 0x7fffffff; } /// /// The path to an object. /// Since EFL 1.23. /// [StructLayout(LayoutKind.Sequential)] public struct ObjectPath { /// /// The string of the path. /// Since EFL 1.23. /// public string value; /// /// Constructor /// Since EFL 1.23. /// /// The string of the path. public ObjectPath(string str) { value = str; } /// /// Conversion operator of ObjectPath from string. /// Since EFL 1.23. /// /// The string of the path. public static implicit operator ObjectPath(string str) { return new ObjectPath(str); } /// /// Conversion operator of string from ObjectPath. /// Since EFL 1.23. /// /// The ObjectPath to be converted. public static implicit operator string(ObjectPath path) { return path.value; } } /// /// String to a signature. /// Since EFL 1.23. /// [StructLayout(LayoutKind.Sequential)] public struct SignatureString { /// /// The string of the signature. /// Since EFL 1.23. /// public string value; /// /// Constructor. /// Since EFL 1.23. /// /// The string of the signature. public SignatureString(string str) { value = str; } /// /// Conversion operator of SignatureString from string. /// Since EFL 1.23. /// /// The string of the signature. public static implicit operator SignatureString(string str) { return new SignatureString(str); } /// /// Conversion operator of string from SignatureString. /// Since EFL 1.23. /// /// The SignatureString to be conversion. public static implicit operator string(SignatureString sig) { return sig.value; } } /// /// Representation for Unix file descriptor. /// Since EFL 1.23. /// [StructLayout(LayoutKind.Sequential)] public struct UnixFd { /// /// The value of the file descriptor. /// Since EFL 1.23. /// public Int32 value; /// /// Constructor. /// Since EFL 1.23. /// /// The file descriptor. public UnixFd(Int32 fd) { value = fd; } /// /// Conversion operator of UnixFd from Int32. /// Since EFL 1.23. /// /// The file descriptor. public static implicit operator UnixFd(Int32 fd) { return new UnixFd(fd); } /// /// Conversion operator of Int32 from UnixFd. /// Since EFL 1.23. /// /// The UnixFd to be converted. public static implicit operator Int32(UnixFd unix_fd) { return unix_fd.value; } } /// /// Arguments of EldBus. /// Since EFL 1.23. /// public static class Argument { /// /// The type of a byte. /// Since EFL 1.23. /// public static class ByteType { /// /// The code of the byte. /// Since EFL 1.23. /// public const char Code = 'y'; /// /// The signature of the byte. /// Since EFL 1.23. /// public const string Signature = "y"; } /// /// The type of a boolean /// Since EFL 1.23. /// public static class BooleanType { /// /// The code of the boolean. /// Since EFL 1.23. /// public const char Code = 'b'; /// /// The signature of the boolean. /// Since EFL 1.23. /// public const string Signature = "b"; } /// /// The type of a Int16. /// Since EFL 1.23. /// public static class Int16Type { /// /// The code of the Int16. /// Since EFL 1.23. /// public const char Code = 'n'; /// /// The signature of the Int16. /// Since EFL 1.23. /// public const string Signature = "n"; } /// /// The type of an unsigned Int16. /// Since EFL 1.23. /// public static class UInt16Type { /// /// The code of the unsigned Int16. /// Since EFL 1.23. /// public const char Code = 'q'; /// /// The signature of the unsigned Int16. /// Since EFL 1.23. /// public const string Signature = "q"; } /// /// The type of a Int32. /// Since EFL 1.23. /// public static class Int32Type { /// /// The code of the Int32. /// Since EFL 1.23. /// public const char Code = 'i'; /// /// The signature of the Int32. /// Since EFL 1.23. /// public const string Signature = "i"; } /// /// The type of an unsigned Int32. /// Since EFL 1.23. /// public static class UInt32Type { /// /// The code of the unsigned Int32. /// Since EFL 1.23. /// public const char Code = 'u'; /// /// The signature of the unsigned Int32. /// Since EFL 1.23. /// public const string Signature = "u"; } /// /// The type of a Int64. /// Since EFL 1.23. /// public static class Int64Type { /// /// The code of the Int64. /// Since EFL 1.23. /// public const char Code = 'x'; /// /// The signature of the Int64. /// Since EFL 1.23. /// public const string Signature = "x"; } /// /// The type of an unsigned Int64. /// Since EFL 1.23. /// public static class UInt64Type { /// /// The code of the unsigned Int64. /// Since EFL 1.23. /// public const char Code = 't'; /// /// The signature of the unsigned Int64. /// Since EFL 1.23. /// public const string Signature = "t"; } /// /// The type of the double. /// Since EFL 1.23. /// public static class DoubleType { /// /// The code of the double. /// Since EFL 1.23. /// public const char Code = 'd'; /// /// The signature of the double. /// Since EFL 1.23. /// public const string Signature = "d"; } /// /// The type of a string. /// Since EFL 1.23. /// public static class StringType { /// /// The code of the string. /// Since EFL 1.23. /// public const char Code = 's'; /// /// The signature of the string. /// Since EFL 1.23. /// public const string Signature = "s"; } /// /// The type of an object path. /// Since EFL 1.23. /// public static class ObjectPathType { /// /// The code of the object path. /// Since EFL 1.23. /// public const char Code = 'o'; /// /// The signature of the object path. /// Since EFL 1.23. /// public const string Signature = "o"; } /// /// The type of a signature. /// Since EFL 1.23. /// public static class SignatureType { /// /// The code of the signature. /// Since EFL 1.23. /// public const char Code = 'g'; /// /// The signature of the signature. /// Since EFL 1.23. /// public const string Signature = "g"; } /// /// The type of a array. /// Since EFL 1.23. /// public static class ArrayType { /// /// The code of the array. /// Since EFL 1.23. /// public const char Code = 'a'; /// /// The signature of the array. /// Since EFL 1.23. /// public const string Signature = "a"; } /// /// The type of a struct. /// Since EFL 1.23. /// public static class StructType { /// /// The code of the struct. /// Since EFL 1.23. /// public const char Code = 'r'; /// /// The signature of the struct. /// Since EFL 1.23. /// public const string Signature = "r"; } /// /// The type of a variant. /// Since EFL 1.23. /// public static class VariantType { /// /// The code of the variant. /// Since EFL 1.23. /// public const char Code = 'v'; /// /// The signature of the variant. /// Since EFL 1.23. /// public const string Signature = "v"; } /// /// The type of a dictionary. /// Since EFL 1.23. /// public static class DictEntryType { /// /// The code of the dictionary. /// Since EFL 1.23. /// public const char Code = 'e'; /// /// The signature of the dictionary. /// Since EFL 1.23. /// public const string Signature = "e"; } /// /// The type of an unix file descriptor. /// Since EFL 1.23. /// public static class UnixFdType { /// /// The code of unix fd. /// Since EFL 1.23. /// public const char Code = 'h'; /// /// The signature of the unix fd. /// Since EFL 1.23. /// public const string Signature = "h"; } // public static readonly ByteType ByteT = new ByteType(); // public static readonly BooleanType BooleanT = new BooleanType(); // public static readonly Int16Type Int16T = new Int16Type(); // public static readonly UInt16Type UInt16T = new UInt16Type(); // public static readonly Int32Type Int32T = new Int32Type(); // public static readonly UInt32Type UInt32T = new UInt32Type(); // public static readonly Int64Type Int64T = new Int64Type(); // public static readonly UInt64Type UInt64T = new UInt64Type(); // public static readonly DoubleType DoubleT = new DoubleType(); // public static readonly StringType StringT = new StringType(); // public static readonly ObjectPathType ObjectPathT = new ObjectPathType(); // public static readonly SignatureType SignatureT = new SignatureType(); // public static readonly ArrayType ArrayT = new ArrayType(); // public static readonly StructType StructT = new StructType(); // public static readonly VariantType VariantT = new VariantType(); // public static readonly DictEntryType DictEntryT = new DictEntryType(); // public static readonly UnixFdType UnixFdT = new UnixFdType(); // // public static readonly ByteType y = ByteT; // public static readonly BooleanType b = BooleanT; // public static readonly Int16Type n = Int16T; // public static readonly UInt16Type q = UInt16T; // public static readonly Int32Type i = Int32T; // public static readonly UInt32Type u = UInt32T; // public static readonly Int64Type x = Int64T; // public static readonly UInt64Type t = UInt64T; // public static readonly DoubleType d = DoubleT; // public static readonly StringType s = StringT; // public static readonly ObjectPathType o = ObjectPathT; // public static readonly SignatureType g = SignatureT; // public static readonly ArrayType a = ArrayT; // public static readonly StructType r = StructT; // public static readonly VariantType v = VariantT; // public static readonly DictEntryType e = DictEntryT; // public static readonly UnixFdType h = UnixFdT; } /// /// Arguments to a basic message eldbus. /// Since EFL 1.23. /// public abstract class BasicMessageArgument { /// /// Appends a message to eldbus. /// Since EFL 1.23. /// /// The message to be appended. public void AppendTo(eldbus.Message msg) { if (!InternalAppendTo(msg)) { throw new SEHException("Eldbus: could not append basic type to eldbus.Message"); } } /// /// Appends a message to eldbus. /// Since EFL 1.23. /// /// The messages to append. public void AppendTo(eldbus.MessageIterator iter) { if (!InternalAppendTo(iter)) { throw new SEHException("Eldbus: could not append basic type to eldbus.MessageIterator"); } } /// /// The code of the type. /// Since EFL 1.23. /// public abstract char TypeCode {get;} /// /// The signature of the type. /// Since EFL 1.23. /// public abstract string Signature {get;} [EditorBrowsable(EditorBrowsableState.Never)] protected abstract bool InternalAppendTo(eldbus.Message msg); [EditorBrowsable(EditorBrowsableState.Never)] protected abstract bool InternalAppendTo(eldbus.MessageIterator iter); /// /// Conversion operator of BasicMessageArgument from byte. /// Since EFL 1.23. /// /// The byte to be converted. public static implicit operator BasicMessageArgument(byte arg) { return new ByteMessageArgument(arg); } /// /// Conversion operator of BasicMessageArgument from bool. /// Since EFL 1.23. /// /// The bool to be converted. public static implicit operator BasicMessageArgument(bool arg) { return new BoolMessageArgument(arg); } /// /// Conversion operator of BasicMessageArgument from Int16. /// Since EFL 1.23. /// /// The int16 to be converted. public static implicit operator BasicMessageArgument(Int16 arg) { return new Int16MessageArgument(arg); } /// /// Conversion operator of BasicMessageArgument from unsigned int16. /// Since EFL 1.23. /// /// The unsigned int16 to be converted. public static implicit operator BasicMessageArgument(UInt16 arg) { return new UInt16MessageArgument(arg); } /// /// Conversion operator of BasicMessageArgument from int32. /// Since EFL 1.23. /// /// The int32 to be converted. public static implicit operator BasicMessageArgument(Int32 arg) { return new Int32MessageArgument(arg); } /// /// Conversion operator of BasicMessageArgument from unsigned int32. /// Since EFL 1.23. /// /// The unsigned int32 to be converted. public static implicit operator BasicMessageArgument(UInt32 arg) { return new UInt32MessageArgument(arg); } /// /// Conversion operator of BasicMessageArgument from int64. /// Since EFL 1.23. /// /// The int64 to be converted. public static implicit operator BasicMessageArgument(Int64 arg) { return new Int64MessageArgument(arg); } /// /// Conversion operator of BasicMessageArgument from unsigned int64. /// Since EFL 1.23. /// /// The unsigned int64 to be converted. public static implicit operator BasicMessageArgument(UInt64 arg) { return new UInt64MessageArgument(arg); } /// /// Conversion operator of BasicMessageArgument from string. /// Since EFL 1.23. /// /// the string to be converted. public static implicit operator BasicMessageArgument(string arg) { return new StringMessageArgument(arg); } /// /// Conversion operator of BasicMessageArgument from signature. /// Since EFL 1.23. /// /// The signature to be converted. public static implicit operator BasicMessageArgument(SignatureString arg) { return new SignatureMessageArgument(arg); } /// /// Conversion operator of BasicMessageArgument from object path. /// Since EFL 1.23. /// /// The object path to be converted. public static implicit operator BasicMessageArgument(ObjectPath arg) { return new ObjectPathMessageArgument(arg); } /// /// Conversion operator of BasicMessageArgument from unix fd. /// Since EFL 1.23. /// /// The unix fd to be converted. public static implicit operator BasicMessageArgument(UnixFd arg) { return new UnixFdMessageArgument(arg); } } /// /// Arguments to a byte message eldbus. /// Since EFL 1.23. /// public class ByteMessageArgument : BasicMessageArgument { private byte value; /// /// Constructor. /// Since EFL 1.23. /// /// The argument of the eldbus. public ByteMessageArgument(byte arg) { value = arg; } /// /// The code of the type. /// Since EFL 1.23. /// public override char TypeCode { get { return Argument.ByteType.Code; } } /// /// The signature of the type. /// Since EFL 1.23. /// public override string Signature { get { return Argument.ByteType.Signature; } } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.Message msg) { return eldbus_message_arguments_append(msg.Handle, Signature, value); } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.MessageIterator iter) { return eldbus_message_iter_basic_append(iter.Handle, TypeCode, value); } } /// /// Arguments to a bool message eldbus. /// Since EFL 1.23. /// public class BoolMessageArgument : BasicMessageArgument { private Int32 value; /// /// Constructor. /// Since EFL 1.23. /// /// The arguments of the eldbus. public BoolMessageArgument(bool arg) { value = Convert.ToInt32(arg); } /// /// The code of the type. /// Since EFL 1.23. /// public override char TypeCode { get { return Argument.BooleanType.Code; } } /// /// The signature of the type. /// Since EFL 1.23. /// public override string Signature { get { return Argument.ByteType.Signature; } } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.Message msg) { return eldbus_message_arguments_append(msg.Handle, Signature, value); } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.MessageIterator iter) { return eldbus_message_iter_basic_append(iter.Handle, TypeCode, value); } } /// /// Arguments to an int16 message eldbus. /// Since EFL 1.23. /// public class Int16MessageArgument : BasicMessageArgument { private Int16 value; /// /// Constructor. /// Since EFL 1.23. /// /// The arguments of the eldbus. public Int16MessageArgument(Int16 arg) { value = arg; } /// /// The code of the type. /// Since EFL 1.23. /// public override char TypeCode { get { return Argument.Int16Type.Code; } } /// /// The signature of the type. /// Since EFL 1.23. /// public override string Signature { get { return Argument.ByteType.Signature; } } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.Message msg) { return eldbus_message_arguments_append(msg.Handle, Signature, value); } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.MessageIterator iter) { return eldbus_message_iter_basic_append(iter.Handle, TypeCode, value); } } /// /// Arguments to an unsigned int16 message eldbus. /// Since EFL 1.23. /// public class UInt16MessageArgument : BasicMessageArgument { private UInt16 value; /// /// Constructor. /// Since EFL 1.23. /// /// the arguments of the eldbus. public UInt16MessageArgument(UInt16 arg) { value = arg; } /// /// The code of the type. /// Since EFL 1.23. /// public override char TypeCode { get { return Argument.UInt16Type.Code; } } /// /// The signature of the type. /// Since EFL 1.23. /// public override string Signature { get { return Argument.ByteType.Signature; } } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.Message msg) { return eldbus_message_arguments_append(msg.Handle, Signature, value); } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.MessageIterator iter) { return eldbus_message_iter_basic_append(iter.Handle, TypeCode, value); } } /// /// Arguments to an int32 message eldbus. /// Since EFL 1.23. /// public class Int32MessageArgument : BasicMessageArgument { private Int32 value; /// /// Constructor. /// Since EFL 1.23. /// /// The arguments of the eldbus. public Int32MessageArgument(Int32 arg) { value = arg; } /// /// The code of the type. /// Since EFL 1.23. /// public override char TypeCode { get { return Argument.Int32Type.Code; } } /// /// The signature of the type. /// Since EFL 1.23. /// public override string Signature { get { return Argument.ByteType.Signature; } } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.Message msg) { return eldbus_message_arguments_append(msg.Handle, Signature, value); } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.MessageIterator iter) { return eldbus_message_iter_basic_append(iter.Handle, TypeCode, value); } } /// /// Arguments to an unsigned int32 message eldbus. /// Since EFL 1.23. /// public class UInt32MessageArgument : BasicMessageArgument { private UInt32 value; /// /// Constructor. /// Since EFL 1.23. /// /// The arguments of the unsigned type. public UInt32MessageArgument(UInt32 arg) { value = arg; } /// /// The code of the type. /// Since EFL 1.23. /// public override char TypeCode { get { return Argument.UInt32Type.Code; } } /// /// The signature of the type. /// Since EFL 1.23. /// public override string Signature { get { return Argument.ByteType.Signature; } } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.Message msg) { return eldbus_message_arguments_append(msg.Handle, Signature, value); } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.MessageIterator iter) { return eldbus_message_iter_basic_append(iter.Handle, TypeCode, value); } } /// /// Arguments to an int64 message eldbus. /// Since EFL 1.23. /// public class Int64MessageArgument : BasicMessageArgument { private Int64 value; /// /// Constructor. /// Since EFL 1.23. /// /// The arguments of the eldbus. public Int64MessageArgument(Int64 arg) { value = arg; } /// /// The code of the type. /// Since EFL 1.23. /// public override char TypeCode { get { return Argument.Int64Type.Code; } } /// /// The signature of the type. /// Since EFL 1.23. /// public override string Signature { get { return Argument.ByteType.Signature; } } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.Message msg) { return eldbus_message_arguments_append(msg.Handle, Signature, value); } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.MessageIterator iter) { return eldbus_message_iter_basic_append(iter.Handle, TypeCode, value); } } /// /// Arguments to an unsigned int64 message eldbus. /// Since EFL 1.23. /// public class UInt64MessageArgument : BasicMessageArgument { private UInt64 value; /// /// Constructor. /// Since EFL 1.23. /// /// The arguments of the eldbus. public UInt64MessageArgument(UInt64 arg) { value = arg; } /// /// The code of the type. /// Since EFL 1.23. /// public override char TypeCode { get { return Argument.UInt64Type.Code; } } /// /// The signature of the type. /// Since EFL 1.23. /// public override string Signature { get { return Argument.ByteType.Signature; } } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.Message msg) { return eldbus_message_arguments_append(msg.Handle, Signature, value); } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.MessageIterator iter) { return eldbus_message_iter_basic_append(iter.Handle, TypeCode, value); } } /// /// Arguments to a double message eldbus. /// Since EFL 1.23. /// public class DoubleMessageArgument : BasicMessageArgument { private double value; /// /// Constructor. /// Since EFL 1.23. /// /// The arguments of the eldbus. public DoubleMessageArgument(double arg) { value = arg; } /// /// The code of the type. /// Since EFL 1.23. /// public override char TypeCode { get { return Argument.DoubleType.Code; } } /// /// The signature of the type. /// Since EFL 1.23. /// public override string Signature { get { return Argument.ByteType.Signature; } } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.Message msg) { return eldbus_message_arguments_append(msg.Handle, Signature, value); } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.MessageIterator iter) { return eldbus_message_iter_basic_append(iter.Handle, TypeCode, value); } } /// /// Arguments to a string like message eldbus. /// Since EFL 1.23. /// public abstract class StringLikeMessageArgument : BasicMessageArgument { private string value; /// /// Constructor. /// Since EFL 1.23. /// /// The arguments of the eldbus. public StringLikeMessageArgument(string arg) { value = arg; } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.Message msg) { return eldbus_message_arguments_append(msg.Handle, Signature, value); } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.MessageIterator iter) { return eldbus_message_iter_basic_append(iter.Handle, TypeCode, value); } } /// /// Arguments to a string message eldbus. /// Since EFL 1.23. /// public class StringMessageArgument : StringLikeMessageArgument { /// /// Constructor. /// Since EFL 1.23. /// /// The arguments of the eldbus. public StringMessageArgument(string arg) : base(arg) { } /// /// The code of the type. /// Since EFL 1.23. /// public override char TypeCode { get { return Argument.StringType.Code; } } /// /// The signature of the type. /// Since EFL 1.23. /// public override string Signature { get { return Argument.ByteType.Signature; } } } /// /// Arguments to an object path message eldbus. /// Since EFL 1.23. /// public class ObjectPathMessageArgument : StringLikeMessageArgument { /// /// Constructor. /// Since EFL 1.23. /// /// public ObjectPathMessageArgument(ObjectPath arg) : base(arg.value) { } /// /// The code of the type. /// Since EFL 1.23. /// public override char TypeCode { get { return Argument.ObjectPathType.Code; } } /// /// The signature of the type. /// Since EFL 1.23. /// public override string Signature { get { return Argument.ByteType.Signature; } } } /// /// Arguments to a signature message eldbus. /// Since EFL 1.23. /// public class SignatureMessageArgument : StringLikeMessageArgument { /// /// Constructor. /// Since EFL 1.23. /// /// The arguments of the eldbus. public SignatureMessageArgument(SignatureString arg) : base(arg.value) { } /// /// The code of the type. /// Since EFL 1.23. /// public override char TypeCode { get { return Argument.SignatureType.Code; } } /// /// The signature of the type. /// Since EFL 1.23. /// public override string Signature { get { return Argument.ByteType.Signature; } } } /// /// Arguments to an unixfd message eldbus. /// Since EFL 1.23. /// public class UnixFdMessageArgument : BasicMessageArgument { private Int32 value; /// /// Constructor. /// Since EFL 1.23. /// /// The arguments of the eldbus. public UnixFdMessageArgument(UnixFd arg) { value = arg.value; } /// /// The code of the type. /// Since EFL 1.23. /// public override char TypeCode { get { return Argument.UnixFdType.Code; } } /// /// The signature of the type. /// Since EFL 1.23. /// public override string Signature { get { return Argument.ByteType.Signature; } } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.Message msg) { return eldbus_message_arguments_append(msg.Handle, Signature, value); } [EditorBrowsable(EditorBrowsableState.Never)] protected override bool InternalAppendTo(eldbus.MessageIterator iter) { return eldbus_message_iter_basic_append(iter.Handle, TypeCode, value); } } /// /// Function type to delegate a message. /// Since EFL 1.23. /// /// The message. /// public delegate void MessageDelegate(eldbus.Message msg, eldbus.Pending pending); /// /// Commons for eldbus. /// Since EFL 1.23. /// public static class Common { /// /// Register the NullError. /// Since EFL 1.23. /// public static void RaiseNullHandle() { if (NullHandleError == 0) { NullHandleError = Eina.Error.Register("Eldbus: null handle"); } Eina.Error.Raise(NullHandleError); } /// /// Instance for a EldBus_Message_Cb. /// Since EFL 1.23. /// /// The data to the eldbus. /// The message to eldbus. /// public delegate void Eldbus_Message_Cb(IntPtr data, IntPtr msg, IntPtr pending); /// /// Get a wrapper for the message instance. /// Since EFL 1.23. /// public static IntPtr GetMessageCbWrapperPtr() { return Marshal.GetFunctionPointerForDelegate(GetMessageCbWrapper()); } /// /// Gets the message wrapper. /// Since EFL 1.23. /// public static Eldbus_Message_Cb GetMessageCbWrapper() { if (message_cb_wrapper == null) { message_cb_wrapper = new Eldbus_Message_Cb(MessageCbWrapper); } return message_cb_wrapper; } /// /// Wraps the data to a message. /// Since EFL 1.23. /// /// /// /// 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()); } } private static Eldbus_Message_Cb message_cb_wrapper = null; private static Eina.Error NullHandleError = 0; } }