Re: flags patch
- From: Philip Van Hoof <pvanhoof gnome org>
- To: Florian Boor <florian boor kernelconcepts de>
- Cc: tinymail-devel-list gnome org
- Subject: Re: flags patch
- Date: Tue, 23 May 2006 21:53:40 +0200
What about an API like this?
typedef enum _TnyMsgHeaderFlags TnyMsgHeaderFlags;
enum _TnyMsgHeaderFlags
{
TNY_MSG_HEADER_FLAG_ANSWERED = 1<<0,
TNY_MSG_HEADER_FLAG_DELETED = 1<<1,
TNY_MSG_HEADER_FLAG_DRAFT = 1<<2,
TNY_MSG_HEADER_FLAG_FLAGGED = 1<<3,
TNY_MSG_HEADER_FLAG_SEEN = 1<<4,
TNY_MSG_HEADER_FLAG_ATTACHMENTS = 1<<5,
TNY_MSG_HEADER_FLAG_ANSWERED_ALL = 1<<6,
TNY_MSG_HEADER_FLAG_JUNK = 1<<7,
TNY_MSG_HEADER_FLAG_SECURE = 1<<8,
TNY_MSG_HEADER_FLAG_FOLDER_FLAGGED = 1<<16,
TNY_MSG_HEADER_FLAG_JUNK_LEARN = 1<<30,
TNY_MSG_HEADER_FLAG_USER = 1<<31
};
TnyMsgHeaderFlags
tny_msg_header_iface_get_flags (TnyMsgHeaderIface *self);
static void
tny_msg_header_iface_set_flags (TnyMsgHeaderIface *self,
TnyMsgHeaderFlags flags);
static void
tny_msg_header_iface_unset_flags (TnyMsgHeaderIface *self,
TnyMsgHeaderFlags flags);
This removes the need for the changed_mask and simplifies it a little
bit.
On Tue, 2006-05-23 at 21:18 +0200, Florian Boor wrote:
> Hi,
>
> so far it basically seems to do waht it is expected to do but i'm not that happy
> with it because it lacks a proper mapping of te camel flags to tinymail flags.
> So far the fields are just defined with the same values like in camel...
> And it came to my mind that it might be not that clever to make a column for
> each flag to TnyMsgHeaderListModel. I guess we want a single one and let the GUI
> take care about displaying the correct stuff (which might be a symbol for the
> mail status like e.g. Thunderbird and Evolution do).
> I'll work on this again tomorrow... if you have some ideas how to improve it
> please let me know.
--
Philip Van Hoof, software developer at x-tend
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: vanhoof at x-tend dot be
http://www.pvanhoof.be - http://www.x-tend.be
Index: tinymail/tny-main.c
===================================================================
--- tinymail/tny-main.c (revision 369)
+++ tinymail/tny-main.c (working copy)
@@ -83,7 +83,7 @@
#ifdef MOZEMBED
G_CALLBACK (tny_main_shutdown), 0);
#else
- G_CALLBACK (gtk_exit), 0);
+ G_CALLBACK (gtk_main_quit), 0);
#endif
gtk_main();
Index: libtinymail-camel/tny-msg-header.c
===================================================================
--- libtinymail-camel/tny-msg-header.c (revision 369)
+++ libtinymail-camel/tny-msg-header.c (working copy)
@@ -397,6 +397,40 @@
return retval;
}
+static const guint32
+tny_msg_header_get_flags (TnyMsgHeaderIface *self)
+{
+ TnyMsgHeader *me = TNY_MSG_HEADER (self);
+
+ guint32 retval;
+
+ g_mutex_lock (me->hdr_lock);
+
+ load_msg_header (me);
+
+ if (G_LIKELY (me->use_summary) && G_LIKELY (me->message_info))
+ retval = camel_message_info_flags (me->message_info);
+
+ g_mutex_unlock (me->hdr_lock);
+
+ return (const guint32)retval;
+}
+
+static void
+tny_msg_header_set_flags (TnyMsgHeaderIface *self, guint32 change_mask, guint32 value_mask)
+{
+ TnyMsgHeader *me = TNY_MSG_HEADER (self);
+
+ g_mutex_lock (me->hdr_lock);
+
+ prepare_for_write (me);
+
+ if (G_LIKELY (me->use_summary) && G_LIKELY (me->message_info))
+ camel_message_info_set_flags (me->message_info, change_mask, value_mask);
+
+ g_mutex_unlock (me->hdr_lock);
+}
+
static const time_t
tny_msg_header_get_date_received (TnyMsgHeaderIface *self)
{
@@ -722,6 +756,8 @@
klass->set_replyto_func = tny_msg_header_set_replyto;
klass->has_cache_func = tny_msg_header_has_cache;
klass->uncache_func = tny_msg_header_uncache;
+ klass->set_flags_func = tny_msg_header_set_flags;
+ klass->get_flags_func = tny_msg_header_get_flags;
return;
}
Index: libtinymail-camel/tny-msg-header.h
===================================================================
--- libtinymail-camel/tny-msg-header.h (revision 369)
+++ libtinymail-camel/tny-msg-header.h (working copy)
@@ -23,8 +23,8 @@
#include <glib.h>
#include <glib-object.h>
#include <tny-msg-header-iface.h>
+#include <camel/camel-folder-summary.h>
-
G_BEGIN_DECLS
#define TNY_TYPE_MSG_HEADER (tny_msg_header_get_type ())
Index: libtinymailui-gtk/tny-msg-header-list-model.h
===================================================================
--- libtinymailui-gtk/tny-msg-header-list-model.h (revision 369)
+++ libtinymailui-gtk/tny-msg-header-list-model.h (working copy)
@@ -45,6 +45,7 @@
TNY_MSG_HEADER_LIST_MODEL_DATE_SENT_COLUMN,
TNY_MSG_HEADER_LIST_MODEL_DATE_RECEIVED_COLUMN,
TNY_MSG_HEADER_LIST_MODEL_INSTANCE_COLUMN,
+ TNY_MSG_HEADER_LIST_MODEL_ANSWERED_COLUMN,
TNY_MSG_HEADER_LIST_MODEL_NUM_COLUMNS
};
Index: libtinymailui-gtk/tny-msg-header-list-model.c
===================================================================
--- libtinymailui-gtk/tny-msg-header-list-model.c (revision 369)
+++ libtinymailui-gtk/tny-msg-header-list-model.c (working copy)
@@ -77,6 +77,9 @@
case TNY_MSG_HEADER_LIST_MODEL_INSTANCE_COLUMN:
retval = G_TYPE_POINTER;
break;
+ case TNY_MSG_HEADER_LIST_MODEL_ANSWERED_COLUMN:
+ retval = G_TYPE_BOOLEAN;
+ break;
default:
retval = G_TYPE_INVALID;
break;
@@ -211,6 +214,11 @@
g_value_init (value, G_TYPE_STRING);
g_value_set_string (value, tny_msg_header_iface_get_from (header));
break;
+ case TNY_MSG_HEADER_LIST_MODEL_ANSWERED_COLUMN:
+ g_value_init (value, G_TYPE_BOOLEAN);
+ g_value_set_boolean (value,
+ (tny_msg_header_iface_get_flags (header) & TNY_MSG_FLAG_ANSWERED) ? TRUE : FALSE);
+ break;
default:
break;
}
Index: libtinymail/tny-msg-header-iface.h
===================================================================
--- libtinymail/tny-msg-header-iface.h (revision 369)
+++ libtinymail/tny-msg-header-iface.h (working copy)
@@ -38,6 +38,22 @@
G_BEGIN_DECLS
+typedef enum _TinymailMessageFlags {
+ TNY_MSG_FLAG_ANSWERED = 1<<0,
+ TNY_MSG_FLAG_DELETED = 1<<1,
+ TNY_MSG_FLAG_DRAFT = 1<<2,
+ TNY_MSG_FLAG_FLAGGED = 1<<3,
+ TNY_MSG_FLAG_SEEN = 1<<4,
+ TNY_MSG_FLAG_ATTACHMENTS = 1<<5,
+ TNY_MSG_FLAG_ANSWERED_ALL = 1<<6,
+ TNY_MSG_FLAG_JUNK = 1<<7,
+ TNY_MSG_FLAG_SECURE = 1<<8,
+ TNY_MSG_FLAG_FOLDER_FLAGGED = 1<<16,
+ TNY_MSG_FLAG_JUNK_LEARN = 1<<30,
+ TNY_MSG_FLAG_USER = 1<<31
+} TinymailMessageFlags;
+
+
#define TNY_TYPE_MSG_HEADER_IFACE (tny_msg_header_iface_get_type ())
#define TNY_MSG_HEADER_IFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TNY_TYPE_MSG_HEADER_IFACE, TnyMsgHeaderIface))
#define TNY_MSG_HEADER_IFACE_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), TNY_TYPE_MSG_HEADER_IFACE, TnyMsgHeaderIfaceClass))
@@ -77,6 +93,8 @@
void (*uncache_func) (TnyMsgHeaderIface *self);
const gboolean (*has_cache_func) (TnyMsgHeaderIface *self);
+ const gint32 (*get_flags_func) (TnyMsgHeaderIface *self);
+ void (*set_flags_func) (TnyMsgHeaderIface *self, gint32 change_mask, gint32 value_mask);
};
GType tny_msg_header_iface_get_type (void);
@@ -104,7 +122,9 @@
const TnyMsgFolderIface*
tny_msg_header_iface_get_folder (TnyMsgHeaderIface *self);
+const guint32 tny_msg_header_iface_get_flags (TnyMsgHeaderIface *self);
void tny_msg_header_iface_set_folder (TnyMsgHeaderIface *self, const TnyMsgFolderIface *folder);
+void tny_msg_header_iface_set_flags (TnyMsgHeaderIface *self, guint32 change_mask, guint32 value_mask);
void tny_msg_header_iface_uncache (TnyMsgHeaderIface *self);
const gboolean tny_msg_header_iface_has_cache (TnyMsgHeaderIface *self);
Index: libtinymail/tny-msg-header-iface.c
===================================================================
--- libtinymail/tny-msg-header-iface.c (revision 369)
+++ libtinymail/tny-msg-header-iface.c (working copy)
@@ -273,7 +273,6 @@
return TNY_MSG_HEADER_IFACE_GET_CLASS (self)->get_folder_func (self);
}
-
/**
* tny_msg_header_iface_set_folder:
* @self: a #TnyMsgHeaderIface object
@@ -289,6 +288,34 @@
}
/**
+ * tny_msg_header_iface_get_flags:
+ * @self: a #TnyMsgHeaderIface object
+ *
+ * Get message information flags.
+ *
+ * Return value: flag bitmask
+ **/
+const guint32
+tny_msg_header_iface_get_flags (TnyMsgHeaderIface *self)
+{
+ return TNY_MSG_HEADER_IFACE_GET_CLASS (self)->get_flags_func (self);
+}
+
+/**
+ * tny_msg_header_iface_set_flags:
+ * @self: a #TnyMsgHeaderIface object
+ *
+ * Modify message flags.
+ *
+ **/
+void
+tny_msg_header_iface_set_flags (TnyMsgHeaderIface *self, guint32 change_mask, guint32 value_mask)
+{
+ return TNY_MSG_HEADER_IFACE_GET_CLASS (self)->set_flags_func (self, change_mask, value_mask);
+}
+
+
+/**
* tny_msg_header_iface_set_message_id:
* @self: a #TnyMsgHeaderIface object
* @id: an unique follow-up uid
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]