mail-notification

Fork of Jean-Yves Lefort's mail-notification, a tray icon to notify of new mail
git clone https://code.djc.id.au/git/mail-notification/

src/mn-vfs-message.gob (3055B) - raw

      1 /*
      2  * Mail Notification
      3  * Copyright (C) 2003-2008 Jean-Yves Lefort <jylefort@brutele.be>
      4  *
      5  * This program is free software; you can redistribute it and/or modify
      6  * it under the terms of the GNU General Public License as published by
      7  * the Free Software Foundation; either version 3 of the License, or
      8  * (at your option) any later version.
      9  *
     10  * This program is distributed in the hope that it will be useful,
     11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  * GNU General Public License for more details.
     14  *
     15  * You should have received a copy of the GNU General Public License along
     16  * with this program; if not, write to the Free Software Foundation, Inc.,
     17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
     18  */
     19 
     20 %headertop{
     21 #include <libgnomevfs/gnome-vfs.h>
     22 #include "mn-message.h"
     23 #include "mn-decls.h"
     24 %}
     25 
     26 %{
     27 #include "mn-vfs-mailbox-backend.h"
     28 #include "mn-message-mime.h"
     29 #include "mn-util.h"
     30 %}
     31 
     32 class MN:VFS:Message from MN:Message (abstract)
     33 {
     34   /* can only be NULL during construction (see new()) */
     35   protected GnomeVFSURI *vfs_uri unrefwith gnome_vfs_uri_unref;
     36   property POINTER vfs_uri (flags = CONSTRUCT_ONLY, type = GnomeVFSURI *)
     37     set
     38     {
     39       GnomeVFSURI *uri;
     40 
     41       g_assert(self->vfs_uri == NULL);
     42 
     43       uri = g_value_get_pointer(VAL);
     44       if (uri)
     45 	self->vfs_uri = gnome_vfs_uri_ref(uri);
     46     }
     47     get
     48     {
     49       g_value_set_pointer(VAL, self->vfs_uri != NULL ? gnome_vfs_uri_ref(self->vfs_uri) : NULL);
     50     };
     51 
     52   public MNVFSMessage *
     53     new (GType type,
     54 	 MN:VFS:Mailbox:Backend *backend (check null type),
     55 	 const char *mid,
     56 	 GnomeVFSURI *dir_uri (check null),
     57 	 const char *filename (check null),
     58 	 MNMessageFlags flags,
     59 	 gboolean handle_status,
     60 	 GError **err)
     61   {
     62     GnomeVFSURI *message_uri;
     63     MNVFSMessage *message;
     64 
     65     message_uri = gnome_vfs_uri_append_file_name(dir_uri, filename);
     66 
     67     message = MN_VFS_MESSAGE(mn_message_new_from_uri_full(type,
     68 							  MN_MAILBOX(MN_VFS_MAILBOX_BACKEND(backend)->mailbox),
     69 							  mid,
     70 							  message_uri,
     71 							  flags,
     72 							  handle_status,
     73 							  err));
     74 
     75     if (message)
     76       message->vfs_uri = gnome_vfs_uri_ref(message_uri);
     77 
     78     gnome_vfs_uri_unref(message_uri);
     79 
     80     return message;
     81   }
     82 
     83   public MNVFSMessage *
     84     new_from_message (MN:VFS:Message *message (check null type),
     85 		      GnomeVFSURI *dir_uri (check null),
     86 		      const char *filename (check null),
     87 		      MNMessageFlags flags)
     88   {
     89     GnomeVFSURI *message_uri;
     90     char *message_text_uri;
     91     MNVFSMessage *new_message;
     92 
     93     message_uri = gnome_vfs_uri_append_file_name(dir_uri, filename);
     94     message_text_uri = gnome_vfs_uri_to_string(message_uri, GNOME_VFS_URI_HIDE_NONE);
     95 
     96     new_message = mn_g_object_clone(message,
     97 				    MN_MESSAGE_PROP_URI((char *) message_text_uri),
     98 				    MN_MESSAGE_PROP_FLAGS(flags),
     99 				    MN_VFS_MESSAGE_PROP_VFS_URI(message_uri),
    100 				    NULL);
    101 
    102     gnome_vfs_uri_unref(message_uri);
    103     g_free(message_text_uri);
    104 
    105     return new_message;
    106   }
    107 }