/* 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-vfs-mailbox-backend.h"

#include "mn-vfs-mailbox-backend-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 24 "src/mn-vfs-mailbox-backend.gob"

#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include "mn-mailbox-private.h"
#include "mn-reentrant-mailbox-private.h"
#include "mn-vfs-mailbox-private.h"
#include "mn-conf.h"
#include "mn-util.h"

#line 36 "mn-vfs-mailbox-backend.c"
/* self casting macros */
#define SELF(x) MN_VFS_MAILBOX_BACKEND(x)
#define SELF_CONST(x) MN_VFS_MAILBOX_BACKEND_CONST(x)
#define IS_SELF(x) MN_IS_VFS_MAILBOX_BACKEND(x)
#define TYPE_SELF MN_TYPE_VFS_MAILBOX_BACKEND
#define SELF_CLASS(x) MN_VFS_MAILBOX_BACKEND_CLASS(x)

#define SELF_GET_CLASS(x) MN_VFS_MAILBOX_BACKEND_GET_CLASS(x)

/* self typedefs */
typedef MNVFSMailboxBackend Self;
typedef MNVFSMailboxBackendClass SelfClass;

/* here are local prototypes */
static void ___object_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
static void ___object_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
#line 0 "src/mn-vfs-mailbox-backend.gob"
static void mn_vfs_mailbox_backend_init (MNVFSMailboxBackend * o);
#line 55 "mn-vfs-mailbox-backend.c"
#line 0 "src/mn-vfs-mailbox-backend.gob"
static void mn_vfs_mailbox_backend_class_init (MNVFSMailboxBackendClass * c);
#line 58 "mn-vfs-mailbox-backend.c"
#line 57 "src/mn-vfs-mailbox-backend.gob"
static void mn_vfs_mailbox_backend_finalize (MNVFSMailboxBackend * self);
#line 61 "mn-vfs-mailbox-backend.c"
#line 81 "src/mn-vfs-mailbox-backend.gob"
static void mn_vfs_mailbox_backend_real_monitor_cb (GnomeVFSMonitorHandle * handle, const char * monitor_uri, const char * info_uri, GnomeVFSMonitorEventType event_type, gpointer user_data);
#line 64 "mn-vfs-mailbox-backend.c"
static void ___real_mn_vfs_mailbox_backend_monitor_cb (MNVFSMailboxBackend * self, const char * info_uri, GnomeVFSMonitorEventType event_type);
#line 91 "src/mn-vfs-mailbox-backend.gob"
static void mn_vfs_mailbox_backend_monitor_cb (MNVFSMailboxBackend * self, const char * info_uri, GnomeVFSMonitorEventType event_type);
#line 68 "mn-vfs-mailbox-backend.c"
#line 124 "src/mn-vfs-mailbox-backend.gob"
static gboolean mn_vfs_mailbox_backend_queue_check_cb (gpointer data);
#line 71 "mn-vfs-mailbox-backend.c"

enum {
	PROP_0,
	PROP_MAILBOX
};

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

/* Short form macros */
#define self_monitor mn_vfs_mailbox_backend_monitor
#define self_real_monitor_cb mn_vfs_mailbox_backend_real_monitor_cb
#define self_monitor_cb mn_vfs_mailbox_backend_monitor_cb
#define self_queue_check mn_vfs_mailbox_backend_queue_check
#define self_queue_check_cb mn_vfs_mailbox_backend_queue_check_cb
#define self_is mn_vfs_mailbox_backend_is
#define self_check mn_vfs_mailbox_backend_check
GType
mn_vfs_mailbox_backend_get_type (void)
{
	static GType type = 0;

	if ___GOB_UNLIKELY(type == 0) {
		static const GTypeInfo info = {
			sizeof (MNVFSMailboxBackendClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) mn_vfs_mailbox_backend_class_init,
			(GClassFinalizeFunc) NULL,
			NULL /* class_data */,
			sizeof (MNVFSMailboxBackend),
			0 /* n_preallocs */,
			(GInstanceInitFunc) mn_vfs_mailbox_backend_init,
			NULL
		};

		type = g_type_register_static (G_TYPE_OBJECT, "MNVFSMailboxBackend", &info, (GTypeFlags)G_TYPE_FLAG_ABSTRACT);
	}

	return type;
}

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

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


static void
___finalize(GObject *obj_self)
{
#define __GOB_FUNCTION__ "MN:VFS:Mailbox:Backend::finalize"
	MNVFSMailboxBackend *self G_GNUC_UNUSED = MN_VFS_MAILBOX_BACKEND (obj_self);
	gpointer priv G_GNUC_UNUSED = self->_priv;
#line 57 "src/mn-vfs-mailbox-backend.gob"
	mn_vfs_mailbox_backend_finalize (self);
#line 140 "mn-vfs-mailbox-backend.c"
	if(G_OBJECT_CLASS(parent_class)->finalize) \
		(* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);
}
#undef __GOB_FUNCTION__

static void 
mn_vfs_mailbox_backend_init (MNVFSMailboxBackend * o G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "MN:VFS:Mailbox:Backend::init"
	o->_priv = G_TYPE_INSTANCE_GET_PRIVATE(o,MN_TYPE_VFS_MAILBOX_BACKEND,MNVFSMailboxBackendPrivate);
}
#undef __GOB_FUNCTION__
static void 
mn_vfs_mailbox_backend_class_init (MNVFSMailboxBackendClass * c G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "MN:VFS:Mailbox:Backend::class_init"
	GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) c;

	g_type_class_add_private(c,sizeof(MNVFSMailboxBackendPrivate));

	parent_class = g_type_class_ref (G_TYPE_OBJECT);

#line 91 "src/mn-vfs-mailbox-backend.gob"
	c->monitor_cb = ___real_mn_vfs_mailbox_backend_monitor_cb;
#line 165 "mn-vfs-mailbox-backend.c"
	c->is = NULL;
	c->check = NULL;
	g_object_class->finalize = ___finalize;
	g_object_class->get_property = ___object_get_property;
	g_object_class->set_property = ___object_set_property;
    {
	GParamSpec   *param_spec;

	param_spec = g_param_spec_pointer
		("mailbox" /* name */,
		 NULL /* nick */,
		 NULL /* blurb */,
		 (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (g_object_class,
		PROP_MAILBOX,
		param_spec);
    }
}
#undef __GOB_FUNCTION__

static void
___object_set_property (GObject *object,
	guint property_id,
	const GValue *VAL G_GNUC_UNUSED,
	GParamSpec *pspec G_GNUC_UNUSED)
#define __GOB_FUNCTION__ "MN:VFS:Mailbox:Backend::set_property"
{
	MNVFSMailboxBackend *self G_GNUC_UNUSED;

	self = MN_VFS_MAILBOX_BACKEND (object);

	switch (property_id) {
	case PROP_MAILBOX:
		{
#line 45 "src/mn-vfs-mailbox-backend.gob"
self->mailbox = g_value_get_pointer (VAL);
#line 202 "mn-vfs-mailbox-backend.c"
		}
		break;
	default:
/* Apparently in g++ this is needed, glib is b0rk */
#ifndef __PRETTY_FUNCTION__
#  undef G_STRLOC
#  define G_STRLOC	__FILE__ ":" G_STRINGIFY (__LINE__)
#endif
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}
#undef __GOB_FUNCTION__

static void
___object_get_property (GObject *object,
	guint property_id,
	GValue *VAL G_GNUC_UNUSED,
	GParamSpec *pspec G_GNUC_UNUSED)
#define __GOB_FUNCTION__ "MN:VFS:Mailbox:Backend::get_property"
{
	MNVFSMailboxBackend *self G_GNUC_UNUSED;

	self = MN_VFS_MAILBOX_BACKEND (object);

	switch (property_id) {
	case PROP_MAILBOX:
		{
#line 45 "src/mn-vfs-mailbox-backend.gob"
g_value_set_pointer (VAL, self->mailbox);
#line 233 "mn-vfs-mailbox-backend.c"
		}
		break;
	default:
/* Apparently in g++ this is needed, glib is b0rk */
#ifndef __PRETTY_FUNCTION__
#  undef G_STRLOC
#  define G_STRLOC	__FILE__ ":" G_STRINGIFY (__LINE__)
#endif
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}
#undef __GOB_FUNCTION__



#line 57 "src/mn-vfs-mailbox-backend.gob"
static void 
mn_vfs_mailbox_backend_finalize (MNVFSMailboxBackend * self)
{
#line 254 "mn-vfs-mailbox-backend.c"
#define __GOB_FUNCTION__ "MN:VFS:Mailbox:Backend::finalize"
{
#line 58 "src/mn-vfs-mailbox-backend.gob"
	
    if (selfp->queue_check_id)
      g_source_remove(selfp->queue_check_id);

    /*
     * If the calling mailbox is being finalized, there is no need to
     * hold its lock. Otherwise, it holds its lock while finalizing us
     * (see reentrant_check() in mn-vfs-mailbox.gob).
     */
    mn_vfs_mailbox_remove_monitors_by_owner(self->mailbox, self);
  }}
#line 269 "mn-vfs-mailbox-backend.c"
#undef __GOB_FUNCTION__

#line 70 "src/mn-vfs-mailbox-backend.gob"
void 
mn_vfs_mailbox_backend_monitor (MNVFSMailboxBackend * self, int check_id, const char * uri, GnomeVFSMonitorType type)
{
#line 276 "mn-vfs-mailbox-backend.c"
#define __GOB_FUNCTION__ "MN:VFS:Mailbox:Backend::monitor"
#line 70 "src/mn-vfs-mailbox-backend.gob"
	g_return_if_fail (self != NULL);
#line 70 "src/mn-vfs-mailbox-backend.gob"
	g_return_if_fail (MN_IS_VFS_MAILBOX_BACKEND (self));
#line 70 "src/mn-vfs-mailbox-backend.gob"
	g_return_if_fail (uri != NULL);
#line 284 "mn-vfs-mailbox-backend.c"
{
#line 75 "src/mn-vfs-mailbox-backend.gob"
	
    mn_vfs_mailbox_lock(self->mailbox);
    mn_vfs_mailbox_monitor(self->mailbox, uri, self, type, self_real_monitor_cb, self);
    mn_vfs_mailbox_unlock(self->mailbox);
  }}
#line 292 "mn-vfs-mailbox-backend.c"
#undef __GOB_FUNCTION__

#line 81 "src/mn-vfs-mailbox-backend.gob"
static void 
mn_vfs_mailbox_backend_real_monitor_cb (GnomeVFSMonitorHandle * handle, const char * monitor_uri, const char * info_uri, GnomeVFSMonitorEventType event_type, gpointer user_data)
{
#line 299 "mn-vfs-mailbox-backend.c"
#define __GOB_FUNCTION__ "MN:VFS:Mailbox:Backend::real_monitor_cb"
{
#line 87 "src/mn-vfs-mailbox-backend.gob"
	
    self_monitor_cb(user_data, info_uri, event_type);
  }}
#line 306 "mn-vfs-mailbox-backend.c"
#undef __GOB_FUNCTION__

#line 91 "src/mn-vfs-mailbox-backend.gob"
static void 
mn_vfs_mailbox_backend_monitor_cb (MNVFSMailboxBackend * self, const char * info_uri, GnomeVFSMonitorEventType event_type)
{
#line 313 "mn-vfs-mailbox-backend.c"
	MNVFSMailboxBackendClass *klass;
#line 91 "src/mn-vfs-mailbox-backend.gob"
	g_return_if_fail (self != NULL);
#line 91 "src/mn-vfs-mailbox-backend.gob"
	g_return_if_fail (MN_IS_VFS_MAILBOX_BACKEND (self));
#line 319 "mn-vfs-mailbox-backend.c"
	klass = MN_VFS_MAILBOX_BACKEND_GET_CLASS(self);

	if(klass->monitor_cb)
		(*klass->monitor_cb)(self,info_uri,event_type);
}
#line 91 "src/mn-vfs-mailbox-backend.gob"
static void 
___real_mn_vfs_mailbox_backend_monitor_cb (MNVFSMailboxBackend * self G_GNUC_UNUSED, const char * info_uri, GnomeVFSMonitorEventType event_type)
{
#line 329 "mn-vfs-mailbox-backend.c"
#define __GOB_FUNCTION__ "MN:VFS:Mailbox:Backend::monitor_cb"
{
#line 95 "src/mn-vfs-mailbox-backend.gob"
	
    if (event_type == GNOME_VFS_MONITOR_EVENT_CHANGED
	|| event_type == GNOME_VFS_MONITOR_EVENT_DELETED
	|| event_type == GNOME_VFS_MONITOR_EVENT_CREATED)
      self_queue_check(self);
  }}
#line 339 "mn-vfs-mailbox-backend.c"
#undef __GOB_FUNCTION__

#line 112 "src/mn-vfs-mailbox-backend.gob"
void 
mn_vfs_mailbox_backend_queue_check (MNVFSMailboxBackend * self)
{
#line 346 "mn-vfs-mailbox-backend.c"
#define __GOB_FUNCTION__ "MN:VFS:Mailbox:Backend::queue_check"
#line 112 "src/mn-vfs-mailbox-backend.gob"
	g_return_if_fail (self != NULL);
#line 112 "src/mn-vfs-mailbox-backend.gob"
	g_return_if_fail (MN_IS_VFS_MAILBOX_BACKEND (self));
#line 352 "mn-vfs-mailbox-backend.c"
{
#line 114 "src/mn-vfs-mailbox-backend.gob"
	
    if (selfp->queue_check_id)
      mn_source_clear(&selfp->queue_check_id);

    if (self->check_latency)
      selfp->queue_check_id = gdk_threads_add_timeout(self->check_latency, self_queue_check_cb, self);
    else
      mn_reentrant_mailbox_queue_check(MN_REENTRANT_MAILBOX(self->mailbox));
  }}
#line 364 "mn-vfs-mailbox-backend.c"
#undef __GOB_FUNCTION__

#line 124 "src/mn-vfs-mailbox-backend.gob"
static gboolean 
mn_vfs_mailbox_backend_queue_check_cb (gpointer data)
{
#line 371 "mn-vfs-mailbox-backend.c"
#define __GOB_FUNCTION__ "MN:VFS:Mailbox:Backend::queue_check_cb"
{
#line 126 "src/mn-vfs-mailbox-backend.gob"
	
    Self *self = data;

    mn_mailbox_check(MN_MAILBOX(self->mailbox));

    selfp->queue_check_id = 0;
    return FALSE;		/* remove source */
  }}
#line 383 "mn-vfs-mailbox-backend.c"
#undef __GOB_FUNCTION__

#line 135 "src/mn-vfs-mailbox-backend.gob"
gboolean 
mn_vfs_mailbox_backend_is (MNVFSMailboxBackend * self, MNVFSMailboxBackendClass * class, MNVFSMailbox * mailbox)
{
#line 390 "mn-vfs-mailbox-backend.c"
	MNVFSMailboxBackendClass *klass;
#line 135 "src/mn-vfs-mailbox-backend.gob"
	g_return_val_if_fail (self != NULL, (gboolean )0);
#line 135 "src/mn-vfs-mailbox-backend.gob"
	g_return_val_if_fail (MN_IS_VFS_MAILBOX_BACKEND (self), (gboolean )0);
#line 396 "mn-vfs-mailbox-backend.c"
	klass = MN_VFS_MAILBOX_BACKEND_GET_CLASS(self);

	if(klass->is)
		return (*klass->is)(self,class,mailbox);
	else
		return (gboolean )(0);
}

#line 138 "src/mn-vfs-mailbox-backend.gob"
void 
mn_vfs_mailbox_backend_check (MNVFSMailboxBackend * self, int check_id)
{
#line 409 "mn-vfs-mailbox-backend.c"
	MNVFSMailboxBackendClass *klass;
#line 138 "src/mn-vfs-mailbox-backend.gob"
	g_return_if_fail (self != NULL);
#line 138 "src/mn-vfs-mailbox-backend.gob"
	g_return_if_fail (MN_IS_VFS_MAILBOX_BACKEND (self));
#line 138 "src/mn-vfs-mailbox-backend.gob"
	g_return_if_fail (check_id != 0);
#line 417 "mn-vfs-mailbox-backend.c"
	klass = MN_VFS_MAILBOX_BACKEND_GET_CLASS(self);

	if(klass->check)
		(*klass->check)(self,check_id);
}
