int notification_imp::proc_notification_thread_callback() { DWORD dwEvent; while (true) { dwEvent = WaitForMultipleObjects(2, poll_events, FALSE, INFINITE); if (dwEvent == (WAIT_OBJECT_0 + NOTIFICATION_EVENT)) { if ((write_index - read_index) > 0) { notification_callback(user_obj, notification_buf[read_index % NOTIFICATION_BUF_COUNT].notification_type, notification_buf[read_index % NOTIFICATION_BUF_COUNT].entity_id, notification_buf[read_index % NOTIFICATION_BUF_COUNT].cmd_type, notification_buf[read_index % NOTIFICATION_BUF_COUNT].desc_type, notification_buf[read_index % NOTIFICATION_BUF_COUNT].desc_index, notification_buf[read_index % NOTIFICATION_BUF_COUNT].cmd_status, notification_buf[read_index % NOTIFICATION_BUF_COUNT].notification_id); // Call callback function read_index++; } } else { SetEvent(poll_events[KILL_EVENT]); break; } } return 0; }
void * notification_imp::dispatch_callbacks(void) { int status; while (true) { status = sem_wait(notify_waiting); if((write_index - read_index) > 0) { notification_callback(user_obj, notification_buf[read_index % NOTIFICATION_BUF_COUNT].notification_type, notification_buf[read_index % NOTIFICATION_BUF_COUNT].guid, notification_buf[read_index % NOTIFICATION_BUF_COUNT].cmd_type, notification_buf[read_index % NOTIFICATION_BUF_COUNT].desc_type, notification_buf[read_index % NOTIFICATION_BUF_COUNT].desc_index, notification_buf[read_index % NOTIFICATION_BUF_COUNT].cmd_status, notification_buf[read_index % NOTIFICATION_BUF_COUNT].notification_id ); read_index++; } else { break; } } return 0; }
G_MODULE_EXPORT void spop_awesome_init() { GError* err = NULL; /* Init D-Bus */ g_type_init(); g_connection = dbus_g_bus_get(DBUS_BUS_SESSION, &err); if (!g_connection) g_error("Can't connect to D-Bus: %s", err->message); g_proxy = dbus_g_proxy_new_for_name(g_connection, AWESOME_DBUS_SERVICE, AWESOME_DBUS_PATH, AWESOME_DBUS_INTERFACE); /* Add a notification callback */ if (!interface_notify_add_callback(notification_callback, NULL)) g_error("Could not add Awesome callback."); /* Add a timeout callback */ g_timeout_add_seconds(1, timeout_callback, NULL); /* Display something */ //set_text("[spop]"); notification_callback(NULL, NULL); }
static gboolean timeout_callback(gpointer data) { notification_callback(NULL, NULL); return TRUE; }