/* 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-evolution-message.h"

#include "mn-evolution-message-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-evolution-message.gob"

#include <glib/gi18n.h>
#include <camel/camel-folder-summary.h>
#include "mn-evolution-mailbox.h"
#include "mn-message-private.h"
#include "mn-evolution-client.h"
#include "mn-evolution-client-dbus.h"
#include "mn-util.h"

#define CLIENT_METHOD(invocation)					\
  {									\
    MNEvolutionMailbox *mailbox = MN_EVOLUTION_MAILBOX(message->mailbox); \
    MNEvolutionClient *client;						\
    GError *tmp_err = NULL;						\
    GError *err = NULL;							\
									\
    client = mn_evolution_client_get();					\
									\
    if (! client->proxy)						\
      {									\
	g_set_error(&err, 0, 0, _("Unable to contact Evolution."));	\
	goto end;							\
      }									\
									\
    if (! invocation)							\
      {									\
	g_set_error(&err, 0, 0, _("An Evolution error has occurred: %s."), tmp_err->message); \
	g_error_free(tmp_err);						\
      }									\
									\
  end:									\
    mn_message_action_done(request, err);				\
  }

#line 61 "mn-evolution-message.c"
/* self casting macros */
#define SELF(x) MN_EVOLUTION_MESSAGE(x)
#define SELF_CONST(x) MN_EVOLUTION_MESSAGE_CONST(x)
#define IS_SELF(x) MN_IS_EVOLUTION_MESSAGE(x)
#define TYPE_SELF MN_TYPE_EVOLUTION_MESSAGE
#define SELF_CLASS(x) MN_EVOLUTION_MESSAGE_CLASS(x)

#define SELF_GET_CLASS(x) MN_EVOLUTION_MESSAGE_GET_CLASS(x)

/* self typedefs */
typedef MNEvolutionMessage Self;
typedef MNEvolutionMessageClass 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-evolution-message.gob"
static void mn_evolution_message_init (MNEvolutionMessage * o);
#line 80 "mn-evolution-message.c"
#line 0 "src/mn-evolution-message.gob"
static void mn_evolution_message_class_init (MNEvolutionMessageClass * c);
#line 83 "mn-evolution-message.c"
#line 83 "src/mn-evolution-message.gob"
static gboolean ___2_mn_evolution_message_builtin_can_open (MNMessage * message);
#line 86 "mn-evolution-message.c"
#line 89 "src/mn-evolution-message.gob"
static void ___3_mn_evolution_message_builtin_open (MNMessage * message, MNMessageActionRequest * request);
#line 89 "mn-evolution-message.c"
#line 96 "src/mn-evolution-message.gob"
static void mn_evolution_message_set_flags (MNEvolutionMessage * self, guint32 flags, MNMessageActionRequest * request);
#line 92 "mn-evolution-message.c"
#line 103 "src/mn-evolution-message.gob"
static void ___5_mn_evolution_message_builtin_mark_as_read (MNMessage * message, MNMessageActionRequest * request);
#line 95 "mn-evolution-message.c"
#line 109 "src/mn-evolution-message.gob"
static void ___6_mn_evolution_message_builtin_mark_as_spam (MNMessage * message, MNMessageActionRequest * request);
#line 98 "mn-evolution-message.c"
#line 115 "src/mn-evolution-message.gob"
static void ___7_mn_evolution_message_builtin_delete (MNMessage * message, MNMessageActionRequest * request);
#line 101 "mn-evolution-message.c"

enum {
	PROP_0,
	PROP_UID
};

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

/* Short form macros */
#define self_new mn_evolution_message_new
#define self_set_flags mn_evolution_message_set_flags
GType
mn_evolution_message_get_type (void)
{
	static GType type = 0;

	if ___GOB_UNLIKELY(type == 0) {
		static const GTypeInfo info = {
			sizeof (MNEvolutionMessageClass),
			(GBaseInitFunc) NULL,
			(GBaseFinalizeFunc) NULL,
			(GClassInitFunc) mn_evolution_message_class_init,
			(GClassFinalizeFunc) NULL,
			NULL /* class_data */,
			sizeof (MNEvolutionMessage),
			0 /* n_preallocs */,
			(GInstanceInitFunc) mn_evolution_message_init,
			NULL
		};

		type = g_type_register_static (MN_TYPE_MESSAGE, "MNEvolutionMessage", &info, (GTypeFlags)0);
	}

	return type;
}

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

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


static void
___finalize(GObject *obj_self)
{
#define __GOB_FUNCTION__ "MN:Evolution:Message::finalize"
	MNEvolutionMessage *self G_GNUC_UNUSED = MN_EVOLUTION_MESSAGE (obj_self);
	gpointer priv G_GNUC_UNUSED = self->_priv;
	if(G_OBJECT_CLASS(parent_class)->finalize) \
		(* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);
#line 61 "src/mn-evolution-message.gob"
	if(self->_priv->uid) { g_free ((gpointer) self->_priv->uid); self->_priv->uid = NULL; }
#line 167 "mn-evolution-message.c"
}
#undef __GOB_FUNCTION__

static void 
mn_evolution_message_init (MNEvolutionMessage * o G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "MN:Evolution:Message::init"
	o->_priv = G_TYPE_INSTANCE_GET_PRIVATE(o,MN_TYPE_EVOLUTION_MESSAGE,MNEvolutionMessagePrivate);
}
#undef __GOB_FUNCTION__
static void 
mn_evolution_message_class_init (MNEvolutionMessageClass * c G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "MN:Evolution:Message::class_init"
	GObjectClass *g_object_class G_GNUC_UNUSED = (GObjectClass*) c;
	MNMessageClass *mn_message_class = (MNMessageClass *)c;

	g_type_class_add_private(c,sizeof(MNEvolutionMessagePrivate));

	parent_class = g_type_class_ref (MN_TYPE_MESSAGE);

#line 83 "src/mn-evolution-message.gob"
	mn_message_class->builtin_can_open = ___2_mn_evolution_message_builtin_can_open;
#line 89 "src/mn-evolution-message.gob"
	mn_message_class->builtin_open = ___3_mn_evolution_message_builtin_open;
#line 103 "src/mn-evolution-message.gob"
	mn_message_class->builtin_mark_as_read = ___5_mn_evolution_message_builtin_mark_as_read;
#line 109 "src/mn-evolution-message.gob"
	mn_message_class->builtin_mark_as_spam = ___6_mn_evolution_message_builtin_mark_as_spam;
#line 115 "src/mn-evolution-message.gob"
	mn_message_class->builtin_delete = ___7_mn_evolution_message_builtin_delete;
#line 199 "mn-evolution-message.c"
	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_string
		("uid" /* name */,
		 NULL /* nick */,
		 NULL /* blurb */,
		 NULL /* default_value */,
		 (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | MN_MESSAGE_PARAM_EXPORT | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (g_object_class,
		PROP_UID,
		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:Evolution:Message::set_property"
{
	MNEvolutionMessage *self G_GNUC_UNUSED;

	self = MN_EVOLUTION_MESSAGE (object);

	switch (property_id) {
	case PROP_UID:
		{
#line 62 "src/mn-evolution-message.gob"
{ char *old = self->_priv->uid; self->_priv->uid = g_value_dup_string (VAL); g_free (old); }
#line 235 "mn-evolution-message.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:Evolution:Message::get_property"
{
	MNEvolutionMessage *self G_GNUC_UNUSED;

	self = MN_EVOLUTION_MESSAGE (object);

	switch (property_id) {
	case PROP_UID:
		{
#line 62 "src/mn-evolution-message.gob"
g_value_set_string (VAL, self->_priv->uid);
#line 266 "mn-evolution-message.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 64 "src/mn-evolution-message.gob"
MNMessage * 
mn_evolution_message_new (MNMailbox * mailbox, time_t sent_time, const char * id, const char * from, const char * subject, MNMessageFlags flags, const char * uid)
{
#line 287 "mn-evolution-message.c"
#define __GOB_FUNCTION__ "MN:Evolution:Message::new"
#line 64 "src/mn-evolution-message.gob"
	g_return_val_if_fail (uid != NULL, (MNMessage * )0);
#line 291 "mn-evolution-message.c"
{
#line 72 "src/mn-evolution-message.gob"
	
    return MN_MESSAGE(GET_NEW_VARG(MN_MESSAGE_PROP_MAILBOX(mailbox),
				   MN_MESSAGE_PROP_SENT_TIME(sent_time),
				   MN_MESSAGE_PROP_ID((char *) id),
				   MN_MESSAGE_PROP_FROM((char *) from),
				   MN_MESSAGE_PROP_SUBJECT((char *) subject),
				   MN_MESSAGE_PROP_FLAGS(flags),
				   MN_EVOLUTION_MESSAGE_PROP_UID((char *) uid),
				   NULL));
  }}
#line 304 "mn-evolution-message.c"
#undef __GOB_FUNCTION__

#line 83 "src/mn-evolution-message.gob"
static gboolean 
___2_mn_evolution_message_builtin_can_open (MNMessage * message G_GNUC_UNUSED)
#line 310 "mn-evolution-message.c"
#define PARENT_HANDLER(___message) \
	((MN_MESSAGE_CLASS(parent_class)->builtin_can_open)? \
		(* MN_MESSAGE_CLASS(parent_class)->builtin_can_open)(___message): \
		((gboolean )0))
{
#define __GOB_FUNCTION__ "MN:Evolution:Message::builtin_can_open"
{
#line 85 "src/mn-evolution-message.gob"
	
    return TRUE;
  }}
#line 322 "mn-evolution-message.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 89 "src/mn-evolution-message.gob"
static void 
___3_mn_evolution_message_builtin_open (MNMessage * message G_GNUC_UNUSED, MNMessageActionRequest * request)
#line 329 "mn-evolution-message.c"
#define PARENT_HANDLER(___message,___request) \
	{ if(MN_MESSAGE_CLASS(parent_class)->builtin_open) \
		(* MN_MESSAGE_CLASS(parent_class)->builtin_open)(___message,___request); }
{
#define __GOB_FUNCTION__ "MN:Evolution:Message::builtin_open"
{
#line 91 "src/mn-evolution-message.gob"
	
    Self *self = SELF(message);
    CLIENT_METHOD(org_gnome_MailNotification_Evolution_open_message(client->proxy, mailbox->uri, selfp->uid, &tmp_err));
  }}
#line 341 "mn-evolution-message.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 96 "src/mn-evolution-message.gob"
static void 
mn_evolution_message_set_flags (MNEvolutionMessage * self, guint32 flags, MNMessageActionRequest * request)
{
#line 349 "mn-evolution-message.c"
#define __GOB_FUNCTION__ "MN:Evolution:Message::set_flags"
#line 96 "src/mn-evolution-message.gob"
	g_return_if_fail (self != NULL);
#line 96 "src/mn-evolution-message.gob"
	g_return_if_fail (MN_IS_EVOLUTION_MESSAGE (self));
#line 355 "mn-evolution-message.c"
{
#line 98 "src/mn-evolution-message.gob"
	
    MNMessage *message = MN_MESSAGE(self);
    CLIENT_METHOD(org_gnome_MailNotification_Evolution_set_message_flags(client->proxy, mailbox->uri, selfp->uid, flags, &tmp_err));
  }}
#line 362 "mn-evolution-message.c"
#undef __GOB_FUNCTION__

#line 103 "src/mn-evolution-message.gob"
static void 
___5_mn_evolution_message_builtin_mark_as_read (MNMessage * message G_GNUC_UNUSED, MNMessageActionRequest * request)
#line 368 "mn-evolution-message.c"
#define PARENT_HANDLER(___message,___request) \
	{ if(MN_MESSAGE_CLASS(parent_class)->builtin_mark_as_read) \
		(* MN_MESSAGE_CLASS(parent_class)->builtin_mark_as_read)(___message,___request); }
{
#define __GOB_FUNCTION__ "MN:Evolution:Message::builtin_mark_as_read"
{
#line 105 "src/mn-evolution-message.gob"
	
    self_set_flags(SELF(message), CAMEL_MESSAGE_SEEN, request);
  }}
#line 379 "mn-evolution-message.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 109 "src/mn-evolution-message.gob"
static void 
___6_mn_evolution_message_builtin_mark_as_spam (MNMessage * message G_GNUC_UNUSED, MNMessageActionRequest * request)
#line 386 "mn-evolution-message.c"
#define PARENT_HANDLER(___message,___request) \
	{ if(MN_MESSAGE_CLASS(parent_class)->builtin_mark_as_spam) \
		(* MN_MESSAGE_CLASS(parent_class)->builtin_mark_as_spam)(___message,___request); }
{
#define __GOB_FUNCTION__ "MN:Evolution:Message::builtin_mark_as_spam"
{
#line 111 "src/mn-evolution-message.gob"
	
    self_set_flags(SELF(message), CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_JUNK | CAMEL_MESSAGE_JUNK_LEARN, request);
  }}
#line 397 "mn-evolution-message.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 115 "src/mn-evolution-message.gob"
static void 
___7_mn_evolution_message_builtin_delete (MNMessage * message G_GNUC_UNUSED, MNMessageActionRequest * request)
#line 404 "mn-evolution-message.c"
#define PARENT_HANDLER(___message,___request) \
	{ if(MN_MESSAGE_CLASS(parent_class)->builtin_delete) \
		(* MN_MESSAGE_CLASS(parent_class)->builtin_delete)(___message,___request); }
{
#define __GOB_FUNCTION__ "MN:Evolution:Message::builtin_delete"
{
#line 117 "src/mn-evolution-message.gob"
	
    self_set_flags(SELF(message), CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_DELETED, request);
  }}
#line 415 "mn-evolution-message.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER
