Add Messages.Is_Signal function
authorReto Buerki <reet@codelabs.ch>
Wed, 7 Oct 2020 13:55:28 +0000 (15:55 +0200)
committerReto Buerki <reet@codelabs.ch>
Mon, 19 Oct 2020 16:35:55 +0000 (18:35 +0200)
src/d_bus-messages.adb
src/d_bus-messages.ads

index 9d2dca7472b04ff9ff459148839cf69b732ad4fb..d1ee0212a1037e62f3595c2b359f11346b3f03dc 100644 (file)
@@ -191,6 +191,31 @@ package body D_Bus.Messages is
 
    -------------------------------------------------------------------------
 
 
    -------------------------------------------------------------------------
 
+   function Is_Signal
+     (Msg         : Message_Type;
+      Iface       : String;
+      Signal_Name : String)
+      return Boolean
+   is
+      use type C.unsigned;
+
+      C_Iface  : C.Strings.chars_ptr := C.Strings.New_String
+        (Str => Iface);
+      C_Signal : C.Strings.chars_ptr := C.Strings.New_String
+        (Str => Signal_Name);
+      Res      : C.unsigned;
+   begin
+      Res := dbus_message_is_signal
+        (message     => Msg.Thin_Msg,
+         iface       => C_Iface,
+         signal_name => C_Signal);
+      C.Strings.Free (Item => C_Iface);
+      C.Strings.Free (Item => C_Signal);
+      return Res = 1;
+   end Is_Signal;
+
+   -------------------------------------------------------------------------
+
    function New_Error
      (Reply_To      : Message_Type;
       Error_Name    : String;
    function New_Error
      (Reply_To      : Message_Type;
       Error_Name    : String;
index 3aced2ac244d0094528726921dd16afebca29f0d..2fe548326817caf3bf7aab7818c0dfdfa99e559f 100644 (file)
@@ -99,6 +99,14 @@ package D_Bus.Messages is
    --  Checks whether the given message is a method call with specified
    --  interface and member fields.
 
    --  Checks whether the given message is a method call with specified
    --  interface and member fields.
 
+   function Is_Signal
+     (Msg         : Message_Type;
+      Iface       : String;
+      Signal_Name : String)
+      return Boolean;
+   --  Checks whether the given message is a signal with specified interface
+   --  and name.
+
    function Is_Null (Msg : Message_Type) return Boolean;
    --  Returns True if given message is nil.
 
    function Is_Null (Msg : Message_Type) return Boolean;
    --  Returns True if given message is nil.