Re: flags patch
- From: Florian Boor <florian boor kernelconcepts de>
- To: Philip Van Hoof <pvanhoof gnome org>
- Cc: tinymail-devel-list gnome org
- Subject: Re: flags patch
- Date: Wed, 24 May 2006 15:58:53 +0200
Hi,
Philip Van Hoof wrote:
> What about an API like this?
yes, that's better - the implementation is attached. In addition to this the
patch fixes a missing sanity check and the use of a deprecated function.
The still missing implementation is support for providers without the summary stuff.
Greetings
Florian
--
The dream of yesterday Florian Boor
is the hope of today Tel: +49 271-771091-14
and the reality of tomorrow. Fax: +49 271-771091-19
[Robert Hutchings Goddard, 1904] florian boor kernelconcepts de
1D78 2D4D 6C53 1CA4 5588 D07B A8E7 940C 25B7 9A76
Index: tinymail/tny-main.c
===================================================================
--- tinymail/tny-main.c (Revision 374)
+++ tinymail/tny-main.c (Arbeitskopie)
@@ -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 374)
+++ libtinymail-camel/tny-msg-header.c (Arbeitskopie)
@@ -397,6 +397,55 @@
return retval;
}
+static const TnyMsgHeaderFlags
+tny_msg_header_get_flags (TnyMsgHeaderIface *self)
+{
+ TnyMsgHeader *me = TNY_MSG_HEADER (self);
+
+ TnyMsgHeaderFlags 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 TnyMsgHeaderFlags)retval;
+}
+
+static void
+tny_msg_header_set_flags (TnyMsgHeaderIface *self, TnyMsgHeaderFlags 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, mask, ~0);
+
+ g_mutex_unlock (me->hdr_lock);
+}
+
+static void
+tny_msg_header_unset_flags (TnyMsgHeaderIface *self, TnyMsgHeaderFlags 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, mask, 0);
+
+ g_mutex_unlock (me->hdr_lock);
+}
+
static const time_t
tny_msg_header_get_date_received (TnyMsgHeaderIface *self)
{
@@ -722,6 +771,9 @@
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->unset_flags_func = tny_msg_header_unset_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 374)
+++ libtinymail-camel/tny-msg-header.h (Arbeitskopie)
@@ -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 374)
+++ libtinymailui-gtk/tny-msg-header-list-model.h (Arbeitskopie)
@@ -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_FLAGS_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 374)
+++ libtinymailui-gtk/tny-msg-header-list-model.c (Arbeitskopie)
@@ -76,6 +76,9 @@
case TNY_MSG_HEADER_LIST_MODEL_INSTANCE_COLUMN:
retval = G_TYPE_POINTER;
break;
+ case TNY_MSG_HEADER_LIST_MODEL_FLAGS_COLUMN:
+ retval = G_TYPE_INT;
+ break;
default:
retval = G_TYPE_INVALID;
break;
@@ -213,6 +216,10 @@
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_FLAGS_COLUMN:
+ g_value_init (value, G_TYPE_INT);
+ g_value_set_int (value, tny_msg_header_iface_get_flags (header));
+ break;
default:
break;
}
@@ -375,11 +382,12 @@
g_mutex_lock (self->folder_lock);
/* We have to unreference all */
- headers = tny_msg_folder_iface_get_headers (self->folder, FALSE);
- g_list_foreach ((GList*)headers, unref_header, NULL);
+ if (self->folder) {
+ headers = tny_msg_folder_iface_get_headers (self->folder, FALSE);
+ g_list_foreach ((GList*)headers, unref_header, NULL);
+ g_object_unref (G_OBJECT (self->folder));
+ }
- if (self->folder)
- g_object_unref (G_OBJECT (self->folder));
g_mutex_unlock (self->folder_lock);
g_mutex_free (self->folder_lock);
Index: libtinymail/tny-msg-header-iface.h
===================================================================
--- libtinymail/tny-msg-header-iface.h (Revision 374)
+++ libtinymail/tny-msg-header-iface.h (Arbeitskopie)
@@ -38,6 +38,22 @@
G_BEGIN_DECLS
+typedef 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;
+
+
#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,9 @@
void (*uncache_func) (TnyMsgHeaderIface *self);
const gboolean (*has_cache_func) (TnyMsgHeaderIface *self);
+ const TnyMsgHeaderFlags (*get_flags_func) (TnyMsgHeaderIface *self);
+ void (*set_flags_func) (TnyMsgHeaderIface *self, TnyMsgHeaderFlags mask);
+ void (*unset_flags_func) (TnyMsgHeaderIface *self, TnyMsgHeaderFlags mask);
};
GType tny_msg_header_iface_get_type (void);
@@ -104,7 +123,10 @@
const TnyMsgFolderIface*
tny_msg_header_iface_get_folder (TnyMsgHeaderIface *self);
+const TnyMsgHeaderFlags 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, TnyMsgHeaderFlags mask);
+void tny_msg_header_iface_unset_flags (TnyMsgHeaderIface *self, TnyMsgHeaderFlags 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 374)
+++ libtinymail/tny-msg-header-iface.c (Arbeitskopie)
@@ -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,48 @@
}
/**
+ * tny_msg_header_iface_get_flags:
+ * @self: a #TnyMsgHeaderIface object
+ *
+ * Get message information flags.
+ *
+ * Return value: flag bitmask
+ **/
+const TnyMsgHeaderFlags
+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
+ * @mask: A #TnyMsgHeaderFlags bitmask of flags to set.
+ *
+ * Modify message flags.
+ *
+ **/
+void
+tny_msg_header_iface_set_flags (TnyMsgHeaderIface *self, TnyMsgHeaderFlags mask)
+{
+ return TNY_MSG_HEADER_IFACE_GET_CLASS (self)->set_flags_func (self, mask);
+}
+
+/**
+ * tny_msg_header_iface_unset_flags:
+ * @self: a #TnyMsgHeaderIface object
+ * @mask: A #TnyMsgHeaderFlags bitmask of flags to clear.
+ *
+ * Modify message flags.
+ *
+ **/
+void
+tny_msg_header_iface_unset_flags (TnyMsgHeaderIface *self, TnyMsgHeaderFlags mask)
+{
+ return TNY_MSG_HEADER_IFACE_GET_CLASS (self)->unset_flags_func (self, 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]