/* Generated by GOB (v2.0.15)   (do not edit directly) */

/* End world hunger, donate to the World Food Programme, http://www.wfp.org */

#define GOB_VERSION_MAJOR 2
#define GOB_VERSION_MINOR 0
#define GOB_VERSION_PATCHLEVEL 15

#define selfp (self->_priv)

#include <string.h> /* memset() */

#include "mn-server.h"

#include "mn-server-private.h"

#ifdef G_LIKELY
#define ___GOB_LIKELY(expr) G_LIKELY(expr)
#define ___GOB_UNLIKELY(expr) G_UNLIKELY(expr)
#else /* ! G_LIKELY */
#define ___GOB_LIKELY(expr) (expr)
#define ___GOB_UNLIKELY(expr) (expr)
#endif /* G_LIKELY */

#line 30 "src/mn-server.gob"

#include <glib/gi18n.h>
#include <dbus/dbus-glib-bindings.h>
#include "mn-shell.h"
#include "mn-util.h"

#line 33 "mn-server.c"
/* self casting macros */
#define SELF(x) MN_SERVER(x)
#define SELF_CONST(x) MN_SERVER_CONST(x)
#define IS_SELF(x) MN_IS_SERVER(x)
#define TYPE_SELF MN_TYPE_SERVER
#define SELF_CLASS(x) MN_SERVER_CLASS(x)

#define SELF_GET_CLASS(x) MN_SERVER_GET_CLASS(x)

/* self typedefs */
typedef MNServer Self;
typedef MNServerClass SelfClass;

/* here are local prototypes */
#line 0 "src/mn-server.gob"
static void mn_server_init (MNServer * o);
#line 50 "mn-server.c"
#line 48 "src/mn-server.gob"
static void mn_server_class_init (MNServerClass * class);
#line 53 "mn-server.c"
#line 53 "src/mn-server.gob"
static gboolean mn_server_has_mailboxes (MNServer * self, gboolean * ret, GError ** err);
#line 56 "mn-server.c"
#line 60 "src/mn-server.gob"
static gboolean mn_server_get_summary (MNServer * self, char ** ret, GError ** err);
#line 59 "mn-server.c"
#line 67 "src/mn-server.gob"
static gboolean mn_server_consider_new_mail_as_read (MNServer * self, GError ** err);
#line 62 "mn-server.c"
#line 77 "src/mn-server.gob"
static gboolean mn_server_update (MNServer * self, GError ** err);
#line 65 "mn-server.c"
#line 87 "src/mn-server.gob"
static gboolean mn_server_display_properties (MNServer * self, GError ** err);
#line 68 "mn-server.c"
#line 97 "src/mn-server.gob"
static gboolean mn_server_display_about (MNServer * self, GError ** err);
#line 71 "mn-server.c"
#line 107 "src/mn-server.gob"
static gboolean mn_server_quit (MNServer * self, GError ** err);
#line 74 "mn-server.c"

/* pointer to the class of our parent */
static GObjectClass *parent_class = NULL;

/* Short form macros */
#define self_has_mailboxes mn_server_has_mailboxes
#define self_get_summary mn_server_get_summary
#define self_consider_new_mail_as_read mn_server_consider_new_mail_as_read
#define self_update mn_server_update
#define self_display_properties mn_server_display_properties
#define self_display_about mn_server_display_about
#define self_quit mn_server_quit
#define self_start mn_server_start
GType
mn_server_get_type (void)
{
	static GType type = 0;

	if ___GOB_UNLIKELY(type == 0) {
		static const GTypeInfo info = {
			sizeof (MNServerClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) mn_server_class_init,
			(GClassFinalizeFunc) NULL,
			NULL /* class_data */,
			sizeof (MNServer),
			0 /* n_preallocs */,
			(GInstanceInitFunc) mn_server_init,
			NULL
		};

		type = g_type_register_static (G_TYPE_OBJECT, "MNServer", &info, (GTypeFlags)0);
	}

	return type;
}

/* a macro for creating a new object of our type */
#define GET_NEW ((MNServer *)g_object_new(mn_server_get_type(), NULL))

/* a function for creating a new object of our type */
#include <stdarg.h>
static MNServer * GET_NEW_VARG (const char *first, ...) G_GNUC_UNUSED;
static MNServer *
GET_NEW_VARG (const char *first, ...)
{
	MNServer *ret;
	va_list ap;
	va_start (ap, first);
	ret = (MNServer *)g_object_new_valist (mn_server_get_type (), first, ap);
	va_end (ap);
	return ret;
}


#line 37 "src/mn-server.gob"

#include "mn-server-dbus.h"

#line 135 "mn-server.c"
static void 
mn_server_init (MNServer * o G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "MN:Server::init"
}
#undef __GOB_FUNCTION__
#line 48 "src/mn-server.gob"
static void 
mn_server_class_init (MNServerClass * class G_GNUC_UNUSED)
{
#line 146 "mn-server.c"
#define __GOB_FUNCTION__ "MN:Server::class_init"

	parent_class = g_type_class_ref (G_TYPE_OBJECT);

 {
#line 49 "src/mn-server.gob"

    dbus_g_object_type_install_info(TYPE_SELF, &dbus_glib_mn_server_object_info);
  
#line 156 "mn-server.c"
 }
}
#undef __GOB_FUNCTION__



#line 53 "src/mn-server.gob"
static gboolean 
mn_server_has_mailboxes (MNServer * self, gboolean * ret, GError ** err)
{
#line 167 "mn-server.c"
#define __GOB_FUNCTION__ "MN:Server::has_mailboxes"
#line 53 "src/mn-server.gob"
	g_return_val_if_fail (self != NULL, (gboolean )0);
#line 53 "src/mn-server.gob"
	g_return_val_if_fail (MN_IS_SERVER (self), (gboolean )0);
#line 53 "src/mn-server.gob"
	g_return_val_if_fail (ret != NULL, (gboolean )0);
#line 175 "mn-server.c"
{
#line 55 "src/mn-server.gob"
	
    *ret = mn_shell->mailboxes->list != NULL;
    return TRUE;
  }}
#line 182 "mn-server.c"
#undef __GOB_FUNCTION__

#line 60 "src/mn-server.gob"
static gboolean 
mn_server_get_summary (MNServer * self, char ** ret, GError ** err)
{
#line 189 "mn-server.c"
#define __GOB_FUNCTION__ "MN:Server::get_summary"
#line 60 "src/mn-server.gob"
	g_return_val_if_fail (self != NULL, (gboolean )0);
#line 60 "src/mn-server.gob"
	g_return_val_if_fail (MN_IS_SERVER (self), (gboolean )0);
#line 60 "src/mn-server.gob"
	g_return_val_if_fail (ret != NULL, (gboolean )0);
#line 197 "mn-server.c"
{
#line 62 "src/mn-server.gob"
	
    *ret = mn_shell_get_summary(mn_shell);
    return TRUE;
  }}
#line 204 "mn-server.c"
#undef __GOB_FUNCTION__

#line 67 "src/mn-server.gob"
static gboolean 
mn_server_consider_new_mail_as_read (MNServer * self, GError ** err)
{
#line 211 "mn-server.c"
#define __GOB_FUNCTION__ "MN:Server::consider_new_mail_as_read"
#line 67 "src/mn-server.gob"
	g_return_val_if_fail (self != NULL, (gboolean )0);
#line 67 "src/mn-server.gob"
	g_return_val_if_fail (MN_IS_SERVER (self), (gboolean )0);
#line 217 "mn-server.c"
{
#line 69 "src/mn-server.gob"
	
    GDK_THREADS_ENTER();
    mn_shell_consider_new_mail_as_read(mn_shell);
    GDK_THREADS_LEAVE();

    return TRUE;
  }}
#line 227 "mn-server.c"
#undef __GOB_FUNCTION__

#line 77 "src/mn-server.gob"
static gboolean 
mn_server_update (MNServer * self, GError ** err)
{
#line 234 "mn-server.c"
#define __GOB_FUNCTION__ "MN:Server::update"
#line 77 "src/mn-server.gob"
	g_return_val_if_fail (self != NULL, (gboolean )0);
#line 77 "src/mn-server.gob"
	g_return_val_if_fail (MN_IS_SERVER (self), (gboolean )0);
#line 240 "mn-server.c"
{
#line 79 "src/mn-server.gob"
	
    GDK_THREADS_ENTER();
    mn_shell_update(mn_shell);
    GDK_THREADS_LEAVE();

    return TRUE;
  }}
#line 250 "mn-server.c"
#undef __GOB_FUNCTION__

#line 87 "src/mn-server.gob"
static gboolean 
mn_server_display_properties (MNServer * self, GError ** err)
{
#line 257 "mn-server.c"
#define __GOB_FUNCTION__ "MN:Server::display_properties"
#line 87 "src/mn-server.gob"
	g_return_val_if_fail (self != NULL, (gboolean )0);
#line 87 "src/mn-server.gob"
	g_return_val_if_fail (MN_IS_SERVER (self), (gboolean )0);
#line 263 "mn-server.c"
{
#line 89 "src/mn-server.gob"
	
    GDK_THREADS_ENTER();
    mn_shell_show_properties_dialog(mn_shell, 0);
    GDK_THREADS_LEAVE();

    return TRUE;
  }}
#line 273 "mn-server.c"
#undef __GOB_FUNCTION__

#line 97 "src/mn-server.gob"
static gboolean 
mn_server_display_about (MNServer * self, GError ** err)
{
#line 280 "mn-server.c"
#define __GOB_FUNCTION__ "MN:Server::display_about"
#line 97 "src/mn-server.gob"
	g_return_val_if_fail (self != NULL, (gboolean )0);
#line 97 "src/mn-server.gob"
	g_return_val_if_fail (MN_IS_SERVER (self), (gboolean )0);
#line 286 "mn-server.c"
{
#line 99 "src/mn-server.gob"
	
    GDK_THREADS_ENTER();
    mn_shell_show_about_dialog(mn_shell, 0);
    GDK_THREADS_LEAVE();

    return TRUE;
  }}
#line 296 "mn-server.c"
#undef __GOB_FUNCTION__

#line 107 "src/mn-server.gob"
static gboolean 
mn_server_quit (MNServer * self, GError ** err)
{
#line 303 "mn-server.c"
#define __GOB_FUNCTION__ "MN:Server::quit"
#line 107 "src/mn-server.gob"
	g_return_val_if_fail (self != NULL, (gboolean )0);
#line 107 "src/mn-server.gob"
	g_return_val_if_fail (MN_IS_SERVER (self), (gboolean )0);
#line 309 "mn-server.c"
{
#line 109 "src/mn-server.gob"
	
    GDK_THREADS_ENTER();
    mn_shell_quit(mn_shell);
    GDK_THREADS_LEAVE();

    return TRUE;
  }}
#line 319 "mn-server.c"
#undef __GOB_FUNCTION__

#line 118 "src/mn-server.gob"
gboolean 
mn_server_start (DBusGConnection * bus, DBusGProxy * bus_proxy)
{
#line 326 "mn-server.c"
#define __GOB_FUNCTION__ "MN:Server::start"
#line 118 "src/mn-server.gob"
	g_return_val_if_fail (bus != NULL, (gboolean )0);
#line 118 "src/mn-server.gob"
	g_return_val_if_fail (bus_proxy != NULL, (gboolean )0);
#line 118 "src/mn-server.gob"
	g_return_val_if_fail (DBUS_IS_G_PROXY (bus_proxy), (gboolean )0);
#line 334 "mn-server.c"
{
#line 121 "src/mn-server.gob"
	
    Self *self;
    GError *err = NULL;
    unsigned int name_reply;

    self = GET_NEW;

    dbus_g_connection_register_g_object(bus, MN_SERVER_PATH, G_OBJECT(self));

    if (! org_freedesktop_DBus_request_name(bus_proxy,
					    MN_SERVER_SERVICE,
					    DBUS_NAME_FLAG_DO_NOT_QUEUE,
					    &name_reply,
					    &err))
      {
	mn_show_fatal_error_dialog(NULL, _("Unable to register the Mail Notification D-Bus server: %s."), err->message);
	g_error_free(err);
      }

    if (name_reply != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
      {
	g_object_unref(self);
	return FALSE;
      }

    return TRUE;
  }}
#line 364 "mn-server.c"
#undef __GOB_FUNCTION__
