ruby: Add wrappers for maildir sync. interface
authorAli Polatel <alip@exherbo.org>
Mon, 10 Jan 2011 14:02:43 +0000 (16:02 +0200)
committerAli Polatel <alip@exherbo.org>
Tue, 25 Jan 2011 10:03:37 +0000 (12:03 +0200)
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
bindings/ruby/init.c
bindings/ruby/message.c

index db53096850e471cfe33cf7815f93cb069aa0897d..1f5298838ac73df389d11043d9aac16249caf6ba 100644 (file)
@@ -292,6 +292,12 @@ notmuch_rb_message_remove_tag(VALUE self, VALUE tagv);
 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);
 
index 63ab205e701da16096f644bb3dc90bf7902be9de..4a63ba07c7572f11e93a0e4002de8a885b33ea81 100644 (file)
@@ -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);
 
index f97e1a4ef1f0f04bad3ed4a1941eb5aeb4bb39fd..1b2c01ef4cbfb79cb02b1305e2397644159540f6 100644 (file)
@@ -283,6 +283,44 @@ notmuch_rb_message_remove_all_tags(VALUE self)
     return Qtrue;
 }
 
+/*
+ * 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
  *