/* NotificationManager.c generated by valac 0.26.2, the Vala compiler
 * generated from NotificationManager.vala, do not modify */

/*  This file is part of corebird, a Gtk+ linux Twitter client.
 *  Copyright (C) 2013 Timm Bäder
 *
 *  corebird 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 3 of the License, or
 *  (at your option) any later version.
 *
 *  corebird 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 corebird.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>


#define TYPE_ACCOUNT (account_get_type ())
#define ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ACCOUNT, Account))
#define ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ACCOUNT, AccountClass))
#define IS_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ACCOUNT))
#define IS_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ACCOUNT))
#define ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ACCOUNT, AccountClass))

typedef struct _Account Account;
typedef struct _AccountClass AccountClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))



GType account_get_type (void) G_GNUC_CONST;
void notification_manager_notify (Account* acc, const gchar* summary, const gchar* body, const gchar* icon);
gint64 account_get_id (Account* self);
static GVariant* _variant_new2 (gint64 value);
void notification_manager_withdraw (const gchar* notification_id);


static GVariant* _variant_new2 (gint64 value) {
	return g_variant_ref_sink (g_variant_new_int64 (value));
}


void notification_manager_notify (Account* acc, const gchar* summary, const gchar* body, const gchar* icon) {
	GNotification* n = NULL;
	const gchar* _tmp0_ = NULL;
	GNotification* _tmp1_ = NULL;
	GNotification* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	GNotification* _tmp11_ = NULL;
	Account* _tmp12_ = NULL;
	gint64 _tmp13_ = 0LL;
	gint64 _tmp14_ = 0LL;
	GVariant* _tmp15_ = NULL;
	GApplication* _tmp16_ = NULL;
	GNotification* _tmp17_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (IS_ACCOUNT (acc));
	g_return_if_fail (summary != NULL);
	g_return_if_fail (body != NULL);
	_tmp0_ = summary;
	_tmp1_ = g_notification_new (_tmp0_);
	n = _tmp1_;
	_tmp2_ = n;
	_tmp3_ = body;
	g_notification_set_body (_tmp2_, _tmp3_);
	_tmp4_ = icon;
	if (_tmp4_ != NULL) {
		{
			GIcon* gicon = NULL;
			const gchar* _tmp5_ = NULL;
			GIcon* _tmp6_ = NULL;
			GNotification* _tmp7_ = NULL;
			GIcon* _tmp8_ = NULL;
			_tmp5_ = icon;
			_tmp6_ = g_icon_new_for_string (_tmp5_, &_inner_error_);
			gicon = _tmp6_;
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				goto __catch24_g_error;
			}
			_tmp7_ = n;
			_tmp8_ = gicon;
			g_notification_set_icon (_tmp7_, _tmp8_);
			_g_object_unref0 (gicon);
		}
		goto __finally24;
		__catch24_g_error:
		{
			GError* e = NULL;
			GError* _tmp9_ = NULL;
			const gchar* _tmp10_ = NULL;
			e = _inner_error_;
			_inner_error_ = NULL;
			_tmp9_ = e;
			_tmp10_ = _tmp9_->message;
			g_warning ("NotificationManager.vala:31: %s", _tmp10_);
			_g_error_free0 (e);
		}
		__finally24:
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_object_unref0 (n);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_tmp11_ = n;
	_tmp12_ = acc;
	_tmp13_ = account_get_id (_tmp12_);
	_tmp14_ = _tmp13_;
	_tmp15_ = _variant_new2 (_tmp14_);
	g_notification_set_default_action_and_target_value (_tmp11_, "app.show-window", _tmp15_);
	_g_variant_unref0 (_tmp15_);
	_tmp16_ = g_application_get_default ();
	_tmp17_ = n;
	g_application_send_notification (_tmp16_, NULL, _tmp17_);
	_g_object_unref0 (n);
}


void notification_manager_withdraw (const gchar* notification_id) {
	GApplication* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	g_return_if_fail (notification_id != NULL);
	_tmp0_ = g_application_get_default ();
	_tmp1_ = notification_id;
	g_application_withdraw_notification (_tmp0_, _tmp1_);
}



