开发者

DBus Glib Send Signal - No signals being emitted

I am attempting to send a signal out over the session message bus. I am able to call methods fine using d-feet dbus debugger with no problem. Unfortunately d-feet does not allow you to connect to signals to debug those. In replacement I am using dbus-monitor "type='signal'" to see if anything is sent. So far this works except for anything that I send.

My assumption is that when one calls dbus_g_connection_register_g_object (connection, path, object); it registers all methods,properties, and signals located within your introspection xml file. This would appear to hold true because before I added them dbus would complain about the signals not existing.

I attempt to dispatch a signal using g_signal_emit_by_name(self,"application_identifier_changed","some new crazy aid",NULL); . 开发者_高级运维This functions within the app itself, I can connect to the signal and it does trigger. However nothing appears within dbus monitor. I must be missing something simple.

Here are the files involved:

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;
}

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 tarball: https://www.slello.com/tmp/PowerviewTestApp.tar.gz

I would appreciate any help.


I found the source of the issue. In powerview-application-presence.gob, signal last NONE (POINTER) had to be signal last NONE (STRING).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜