Logo Search packages:      
Sourcecode: mail-notification version File versions

mn-mh-mailbox.c

/* Generated by GOB (v2.0.11) on Sun Mar  6 22:34:26 2005
   (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 11

#define selfp (self->_priv)

#include "mn-mh-mailbox.h"

#include "mn-mh-mailbox-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 "mn-mh-mailbox.gob"

#include "config.h"
#include <stdio.h>
#include <string.h>
#include <glib/gi18n.h>
#include <gdk/gdk.h>
#include "mn-mailbox-private.h"
#include "mn-vfs.h"
#include "mn-util.h"
#include "mn-message-mime.h"

#line 37 "mn-mh-mailbox.c"
/* self casting macros */
#define SELF(x) MN_MH_MAILBOX(x)
#define SELF_CONST(x) MN_MH_MAILBOX_CONST(x)
#define IS_SELF(x) MN_IS_MH_MAILBOX(x)
#define TYPE_SELF MN_TYPE_MH_MAILBOX
#define SELF_CLASS(x) MN_MH_MAILBOX_CLASS(x)

#define SELF_GET_CLASS(x) MN_MH_MAILBOX_GET_CLASS(x)

/* self typedefs */
typedef MNMHMailbox Self;
typedef MNMHMailboxClass SelfClass;

/* here are local prototypes */
static void mn_mh_mailbox_init (MNMHMailbox * o) G_GNUC_UNUSED;
static void mn_mh_mailbox_class_init (MNMHMailboxClass * class) G_GNUC_UNUSED;
static GObject * ___2_mn_mh_mailbox_constructor (GType type, unsigned int n_construct_properties, GObjectConstructParam * construct_params) G_GNUC_UNUSED;
static gboolean ___3_mn_mh_mailbox_impl_is (MNMailbox * dummy, MNURI * uri) G_GNUC_UNUSED;
static void ___4_mn_mh_mailbox_impl_check (MNMailbox * self) G_GNUC_UNUSED;

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

GType
mn_mh_mailbox_get_type (void)
{
      static GType type = 0;

      if ___GOB_UNLIKELY(type == 0) {
            static const GTypeInfo info = {
                  sizeof (MNMHMailboxClass),
                  (GBaseInitFunc) NULL,
                  (GBaseFinalizeFunc) NULL,
                  (GClassInitFunc) mn_mh_mailbox_class_init,
                  (GClassFinalizeFunc) NULL,
                  NULL /* class_data */,
                  sizeof (MNMHMailbox),
                  0 /* n_preallocs */,
                  (GInstanceInitFunc) mn_mh_mailbox_init,
                  NULL
            };

            type = g_type_register_static (MN_TYPE_MAILBOX, "MNMHMailbox", &info, (GTypeFlags)0);
      }

      return type;
}

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

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

static void 
mn_mh_mailbox_init (MNMHMailbox * o G_GNUC_UNUSED)
{
#define __GOB_FUNCTION__ "MN:MH:Mailbox::init"
}
#undef __GOB_FUNCTION__
#line 38 "mn-mh-mailbox.gob"
static void 
mn_mh_mailbox_class_init (MNMHMailboxClass * class G_GNUC_UNUSED)
#line 112 "mn-mh-mailbox.c"
{
#define __GOB_FUNCTION__ "MN:MH:Mailbox::class_init"
      GObjectClass *g_object_class = (GObjectClass *)class;
      MNMailboxClass *mn_mailbox_class = (MNMailboxClass *)class;

      parent_class = g_type_class_ref (MN_TYPE_MAILBOX);

#line 43 "mn-mh-mailbox.gob"
      g_object_class->constructor = ___2_mn_mh_mailbox_constructor;
#line 67 "mn-mh-mailbox.gob"
      mn_mailbox_class->impl_is = ___3_mn_mh_mailbox_impl_is;
#line 84 "mn-mh-mailbox.gob"
      mn_mailbox_class->impl_check = ___4_mn_mh_mailbox_impl_check;
#line 126 "mn-mh-mailbox.c"
 {
#line 39 "mn-mh-mailbox.gob"

    MN_MAILBOX_CLASS(class)->format = "MH";
  
#line 132 "mn-mh-mailbox.c"
 }
}
#undef __GOB_FUNCTION__



#line 43 "mn-mh-mailbox.gob"
static GObject * 
___2_mn_mh_mailbox_constructor (GType type G_GNUC_UNUSED, unsigned int n_construct_properties, GObjectConstructParam * construct_params)
#line 142 "mn-mh-mailbox.c"
#define PARENT_HANDLER(___type,___n_construct_properties,___construct_params) \
      ((G_OBJECT_CLASS(parent_class)->constructor)? \
            (* G_OBJECT_CLASS(parent_class)->constructor)(___type,___n_construct_properties,___construct_params): \
            ((GObject * )0))
{
#define __GOB_FUNCTION__ "MN:MH:Mailbox::constructor"
{
#line 45 "mn-mh-mailbox.gob"
      
    GObject *object;
    MNMailbox *self;

    object = PARENT_HANDLER(type, n_construct_properties, construct_params);
    self = MN_MAILBOX(object);

    GDK_THREADS_ENTER();

    mn_mailbox_monitor(self,
                   self->uri->text,
                   GNOME_VFS_MONITOR_DIRECTORY,
                   MN_MAILBOX_MONITOR_EVENT_CHANGED
                   | MN_MAILBOX_MONITOR_EVENT_DELETED
                   | MN_MAILBOX_MONITOR_EVENT_CREATED);

    gdk_flush();
    GDK_THREADS_LEAVE();

    return object;
  }}
#line 172 "mn-mh-mailbox.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 67 "mn-mh-mailbox.gob"
static gboolean 
___3_mn_mh_mailbox_impl_is (MNMailbox * dummy G_GNUC_UNUSED, MNURI * uri)
#line 179 "mn-mh-mailbox.c"
#define PARENT_HANDLER(___dummy,___uri) \
      ((MN_MAILBOX_CLASS(parent_class)->impl_is)? \
            (* MN_MAILBOX_CLASS(parent_class)->impl_is)(___dummy,___uri): \
            ((gboolean )0))
{
#define __GOB_FUNCTION__ "MN:MH:Mailbox::impl_is"
#line 67 "mn-mh-mailbox.gob"
      g_return_val_if_fail (uri != NULL, (gboolean )0);
#line 67 "mn-mh-mailbox.gob"
      g_return_val_if_fail (MN_IS_URI (uri), (gboolean )0);
#line 190 "mn-mh-mailbox.c"
{
#line 69 "mn-mh-mailbox.gob"
      
    gboolean is = FALSE;

    if (uri->vfs)
      {
      GnomeVFSURI *sequences_uri;

      sequences_uri = gnome_vfs_uri_append_file_name(uri->vfs, ".mh_sequences");
      is = mn_vfs_test(sequences_uri, G_FILE_TEST_IS_REGULAR);
      gnome_vfs_uri_unref(sequences_uri);
      }
    
    return is;
  }}
#line 207 "mn-mh-mailbox.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

#line 84 "mn-mh-mailbox.gob"
static void 
___4_mn_mh_mailbox_impl_check (MNMailbox * self G_GNUC_UNUSED)
#line 214 "mn-mh-mailbox.c"
#define PARENT_HANDLER(___self) \
      { if(MN_MAILBOX_CLASS(parent_class)->impl_check) \
            (* MN_MAILBOX_CLASS(parent_class)->impl_check)(___self); }
{
#define __GOB_FUNCTION__ "MN:MH:Mailbox::impl_check"
#line 84 "mn-mh-mailbox.gob"
      g_return_if_fail (self != NULL);
#line 84 "mn-mh-mailbox.gob"
      g_return_if_fail (MN_IS_MAILBOX (self));
#line 224 "mn-mh-mailbox.c"
{
#line 86 "mn-mh-mailbox.gob"
      
    GnomeVFSURI *sequences_uri;
    GnomeVFSResult result;
    GnomeVFSHandle *handle;
  
    sequences_uri = gnome_vfs_uri_append_file_name(self->uri->vfs, ".mh_sequences");
    result = gnome_vfs_open_uri(&handle, sequences_uri, GNOME_VFS_OPEN_READ);
    gnome_vfs_uri_unref(sequences_uri);

    if (result == GNOME_VFS_OK)
      {
      MNVFSReadLineContext *context = NULL;
      const char *line;
      GSList *messages = NULL;

      while ((result = mn_vfs_read_line(&context, handle, &line)) == GNOME_VFS_OK)
        if (g_str_has_prefix(line, "unseen: "))
          {
            int first;
            char **elements;
            int i;
            
            elements = g_strsplit(line + 8, " ", 0);
            for (i = 0; elements[i]; i++)
            {
              int last;
              int n;

              n = sscanf(elements[i], "%d-%d", &first, &last);
              if (n >= 1)
                {
                  int j;

                  if (n == 1)
                  last = first;
              
                  for (j = first; j <= last; j++)
                  {
                    char *filename;
                    GnomeVFSURI *message_uri;

                    filename = g_strdup_printf("%i", j);
                    message_uri = gnome_vfs_uri_append_file_name(self->uri->vfs, filename);
                    g_free(filename);

                    messages = g_slist_append(messages, mn_message_new_from_uri(self->uri, message_uri));
                    gnome_vfs_uri_unref(message_uri);
                  }
                }
            }
            g_strfreev(elements);
          }

      mn_vfs_read_line_context_free(context);
      gnome_vfs_close(handle);

      GDK_THREADS_ENTER();
      
      if (result == GNOME_VFS_OK || result == GNOME_VFS_ERROR_EOF)
        mn_mailbox_set_messages(self, messages);
      else
        mn_mailbox_set_error(self, _("error while reading .mh_sequences: %s"), gnome_vfs_result_to_string(result));
      
      gdk_flush();
      GDK_THREADS_LEAVE();

      mn_g_object_slist_free(messages);
      }
    else
      {
      GDK_THREADS_ENTER();
      mn_mailbox_set_error(self, _("unable to open .mh_sequences: %s"), gnome_vfs_result_to_string(result));
      gdk_flush();
      GDK_THREADS_LEAVE();
      }

    GDK_THREADS_ENTER();
    mn_mailbox_end_check(self);
    gdk_flush();
    GDK_THREADS_LEAVE();
  }}
#line 308 "mn-mh-mailbox.c"
#undef __GOB_FUNCTION__
#undef PARENT_HANDLER

Generated by  Doxygen 1.6.0   Back to index