DBus Glib Send Signal - Signals that are not emitted

I am trying to send a signal through the session message bus. I can name the methods perfectly using the d-foot dbus debugger, no problem. Unfortunately, d-foot does not allow you to connect to signals to debug them. In return, I use dbus-monitor "type='signal'"to find out if anything has been sent. As long as it works, apart from everything I send.

My assumption is that when called, dbus_g_connection_register_g_object (connection, path, object);it registers all the methods, properties, and signals found in your introspection XML file. It would look like this because before I added them, dbus would complain about signals that do not exist.

I am trying to send a signal using g_signal_emit_by_name(self,"application_identifier_changed","some new crazy aid",NULL);. This works in the application itself, I can connect to the signal, and it works. However, nothing appears in the dbus monitor. I have to miss something simple.

Here are the files:
main.c

int
main (int argc, char *argv[])
{
guint   result;
GError* error = NULL;
GObject * obj = NULL;

gtk_init(&argc,&argv);

gchar* bus_name = g_strdup_printf("org.maskwa.PowerviewApplicationPresence_%d",getpid());

dbus = dbus_g_bus_get(DBUS_BUS_SESSION,&error);
if (NULL != error) {
    g_error("error establishing dbus connection %s",error->message);
    g_error_free(error);
    return 1;
}
    //dbus_connection_setup_with_g_main(dbus_g_connection_get_connection(dbus),NULL);

proxy = dbus_g_proxy_new_for_name(dbus,
    DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);

org_freedesktop_DBus_request_name(proxy,
            bus_name, 
            DBUS_NAME_FLAG_DO_NOT_QUEUE, &result, &error);

obj = g_object_new (POWERVIEW_TYPE_APPLICATION_PRESENCE, NULL);
dbus_g_connection_register_g_object (dbus, "/org/maskwa/powerview_application_presence", obj);

gtk_main();

if (NULL != bus_name) g_free(bus_name);
return 0;
}

Display of the PowerView application presence.gob:

%headertop{

#include <dbus/dbus-glib.h>
#include "main.h"
%}

%{
#include "powerview-application-presence-glue.h"
%}

class Powerview:Application:Presence from G:Object {

class_init (class)
{
    dbus_g_object_type_install_info (POWERVIEW_TYPE_APPLICATION_PRESENCE,&dbus_glib_powerview_application_presence_object_info);
}

public void
get_application_identifier(self, gchar** OUT_aid, GError** error)
{
    g_print("%p      powerview_application_presence_get_application_identifier()\n",self);
    *OUT_aid = g_strdup("tld.domain.pong");
}

public void
get_display_name(self, gchar** OUT_display_name, GError** error)
{
    g_print("%p powerview_application_presence_get_display_name()\n",self);
    *OUT_display_name = g_strdup("Test Application");

    g_signal_emit_by_name(self,"application_identifier_changed","some new crazy aid",NULL);
}

signal last NONE (POINTER)
void application_identifier_changed (self, gchar** new_aid)
{
    g_print("application_identifier_changed()\n");
}

signal last NONE (POINTER)
void display_name_changed(self, gchar** new_display_name)
{

}
}

PowerView-application-presence-instance.xml

<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!-- 
http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format
http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-signatures
-->
<node name="/">
<interface name="org.maskwa.PowerviewApplicationPresence">

    <method name="GetApplicationIdentifier">
        <arg type="s" name="OUT_aid" direction="out" />
    </method>
    <signal name="ApplicationIdentifierChanged">
        <arg type="s" name="new_aid" />
    </signal>

    <method name="GetDisplayName">
        <arg type="s" name="OUT_display_name" direction="out" />
    </method>
    <signal name="DisplayNameChanged">
        <arg type="s" name="new_display_name" />
    </signal>
</interface>
</node>

project archive: https://www.slello.com/tmp/PowerviewTestApp.tar.gz

I would appreciate any help.

+3
source share
1 answer

I found the source of the problem. In powerview-application-presence.gob, there signal last NONE (POINTER)should have been signal last NONE (STRING).

0
source

Source: https://habr.com/ru/post/1729736/


All Articles