[PATCH 2/4] ruby: Add wrappers for maildir sync. interface
Ali Polatel
alip at exherbo.org
Mon Jan 10 06:39:26 PST 2011
New wrappers:
notmuch_message_maildir_flags_to_tags(): MESSAGE.maildir_flags_to_tags
notmuch_message_tags_to_maildir_flags(): MESSAGE.tags_to_maildir_flags
---
bindings/ruby/defs.h | 6 ++++++
bindings/ruby/init.c | 2 ++
bindings/ruby/message.c | 38 ++++++++++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
index db53096..1f52988 100644
--- a/bindings/ruby/defs.h
+++ b/bindings/ruby/defs.h
@@ -293,6 +293,12 @@ VALUE
notmuch_rb_message_remove_all_tags(VALUE self);
VALUE
+notmuch_rb_message_maildir_flags_to_tags(VALUE self);
+
+VALUE
+notmuch_rb_message_tags_to_maildir_flags(VALUE self);
+
+VALUE
notmuch_rb_message_freeze(VALUE self);
VALUE
diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
index 63ab205..4a63ba0 100644
--- a/bindings/ruby/init.c
+++ b/bindings/ruby/init.c
@@ -273,6 +273,8 @@ Init_notmuch(void)
rb_define_alias(notmuch_rb_cMessage, "<<", "add_tag");
rb_define_method(notmuch_rb_cMessage, "remove_tag", notmuch_rb_message_remove_tag, 1);
rb_define_method(notmuch_rb_cMessage, "remove_all_tags", notmuch_rb_message_remove_all_tags, 0);
+ rb_define_method(notmuch_rb_cMessage, "maildir_flags_to_tags", notmuch_rb_message_maildir_flags_to_tags, 0);
+ rb_define_method(notmuch_rb_cMessage, "tags_to_maildir_flags", notmuch_rb_message_tags_to_maildir_flags, 0);
rb_define_method(notmuch_rb_cMessage, "freeze", notmuch_rb_message_freeze, 0);
rb_define_method(notmuch_rb_cMessage, "thaw", notmuch_rb_message_thaw, 0);
diff --git a/bindings/ruby/message.c b/bindings/ruby/message.c
index f97e1a4..1b2c01e 100644
--- a/bindings/ruby/message.c
+++ b/bindings/ruby/message.c
@@ -284,6 +284,44 @@ notmuch_rb_message_remove_all_tags(VALUE self)
}
/*
+ * call-seq: MESSAGE.maildir_flags_to_tags => true
+ *
+ * Add/remove tags according to maildir flags in the message filename(s)
+ */
+VALUE
+notmuch_rb_message_maildir_flags_to_tags(VALUE self)
+{
+ notmuch_status_t ret;
+ notmuch_message_t *message;
+
+ Data_Get_Notmuch_Message(self, message);
+
+ ret = notmuch_message_maildir_flags_to_tags(message);
+ notmuch_rb_status_raise(ret);
+
+ return Qtrue;
+}
+
+/*
+ * call-seq: MESSAGE.tags_to_maildir_flags => true
+ *
+ * Rename message filename(s) to encode tags as maildir flags
+ */
+VALUE
+notmuch_rb_message_tags_to_maildir_flags(VALUE self)
+{
+ notmuch_status_t ret;
+ notmuch_message_t *message;
+
+ Data_Get_Notmuch_Message(self, message);
+
+ ret = notmuch_message_tags_to_maildir_flags(message);
+ notmuch_rb_status_raise(ret);
+
+ return Qtrue;
+}
+
+/*
* call-seq: MESSAGE.freeze => true
*
* Freeze the 'message'
--
1.7.3.5
More information about the notmuch
mailing list