AXEvent
ax_event_stateless_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 event = TRUE;
/* Initialize an AXEventKeyValueSet that sets the value of the key "event"
* which is marked as a wild-card value in the template.
*/
"event", NULL, &event, AX_VALUE_TYPE_BOOL,
NULL);
/* The AXEventKeyValueSet has been initialized, now it's time to declare the
* event. Notice that the .xml-suffix i omitted when naming the template.
*/
"com.vendor.Stateless.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;
}