AXEvent
ax_event_property_state_declaration_from_template_example.c
#include <glib.h>
#include <glib-object.h>
#include <axsdk/axevent.h>
static void
declaration_complete(guint declaration, gpointer user_data);
static guint
setup_declaration(AXEventHandler *event_handler);
static void
declaration_complete(guint declaration, gpointer user_data)
{
/* This callback will be called when the declaration has been registered
* with the event system. The event declaration can now be used to send
* events.
*/
((void)user_data);
g_message("Declaration complete for: %d", declaration);
}
static guint
setup_declaration(AXEventHandler *event_handler)
{
guint declaration;
gboolean enabled = TRUE;
/* Initialize an AXEventKeyValueSet that sets the value of the keys "feature"
* and "enabled" which are marked as a wild-card values in the template.
*/
NULL,
"feature", NULL, "myfeature", AX_VALUE_TYPE_STRING,
"enabled", NULL, &enabled, AX_VALUE_TYPE_BOOL,
NULL);
/* The AXEventKeyValueSet has been initialized, now it's time to declare the
* event.
*/
"com.vendor.PropertyState.Example",
set,
&declaration,
declaration_complete,
NULL,
NULL);
return declaration;
}
gint main(void)
{
GMainLoop *loop;
AXEventHandler *event_handler;
guint declaration;
/* Create an AXEventHandler */
event_handler = ax_event_handler_new();
declaration = setup_declaration(event_handler);
g_message("Got declaration: %d", declaration);
/* Create and start the GMainLoop */
loop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(loop);
declaration,
NULL);
ax_event_handler_free(event_handler);
return 0;
}