/*
 * This file is part of roccat-tools.
 *
 * roccat-tools is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * roccat-tools is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with roccat-tools. If not, see <http://www.gnu.org/licenses/>.
 */

#include "roccat_notification_timer_osd.h"
#include "roccat_osd_note.h"
#include <libnotify/notification.h>

void roccat_notification_osd_timer_tick(gpointer data, gchar const *prefix, gchar const *name, guint seconds) {
	if (data) {
		if (seconds == 0)
			roccat_osd_note_update((RoccatOsdNote *)data, "%s timer %s: Go!", prefix, name);
		else
			roccat_osd_note_update((RoccatOsdNote *)data, "%s timer %s: %i", prefix, name, seconds);
	}
}

void roccat_notification_osd_timer_stop(gpointer data, gchar const *prefix, gchar const *name, guint seconds) {
	if (data)
		roccat_osd_note_update((RoccatOsdNote *)data, "%s timer %s deactivated", prefix, name);
}

void roccat_notification_osd_timer_cancel(gpointer data) {
	if (data)
		roccat_osd_note_close((RoccatOsdNote *)data);
}

void roccat_notification_osd_timer_start(gpointer data, gchar const *prefix, gchar const *name, guint seconds) {
	if (data)
		roccat_osd_note_update((RoccatOsdNote *)data, "%s timer %s activated", prefix, name);
}

gpointer roccat_notification_osd_timer_new(RoccatNotificator *notificator) {
	return notificator->osd_usable ? roccat_osd_note_new(notificator, NOTIFY_EXPIRES_DEFAULT) : NULL;
}

void roccat_notification_osd_timer_free(gpointer data) {
	if (data)
		roccat_osd_note_free((RoccatOsdNote *)data);
}
