X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=bindings%2Fruby%2Fmessage.c;h=49dbace3afec546596fc15e117354f16b031689f;hp=2babfd047e64cf0db9c6ebd4778d4c0ba59439aa;hb=b4049316cc3bc933453268ed8d3e89b1ee0098a1;hpb=c7893408bbe6904ae7da97aa203587af4ec2fac7 diff --git a/bindings/ruby/message.c b/bindings/ruby/message.c index 2babfd04..49dbace3 100644 --- a/bindings/ruby/message.c +++ b/bindings/ruby/message.c @@ -30,9 +30,10 @@ notmuch_rb_message_destroy(VALUE self) { notmuch_message_t *message; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); notmuch_message_destroy(message); + DATA_PTR(self) = NULL; return Qnil; } @@ -48,7 +49,7 @@ notmuch_rb_message_get_message_id(VALUE self) const char *msgid; notmuch_message_t *message; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); msgid = notmuch_message_get_message_id(message); @@ -66,7 +67,7 @@ notmuch_rb_message_get_thread_id(VALUE self) const char *tid; notmuch_message_t *message; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); tid = notmuch_message_get_thread_id(message); @@ -84,7 +85,7 @@ notmuch_rb_message_get_replies(VALUE self) notmuch_messages_t *messages; notmuch_message_t *message; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); messages = notmuch_message_get_replies(message); @@ -102,13 +103,31 @@ notmuch_rb_message_get_filename(VALUE self) const char *fname; notmuch_message_t *message; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); fname = notmuch_message_get_filename(message); return rb_str_new2(fname); } +/* + * call-seq: MESSAGE.filanames => FILENAMES + * + * Get all filenames for the email corresponding to MESSAGE. + */ +VALUE +notmuch_rb_message_get_filenames(VALUE self) +{ + notmuch_filenames_t *fnames; + notmuch_message_t *message; + + Data_Get_Notmuch_Message(self, message); + + fnames = notmuch_message_get_filenames(message); + + return Data_Wrap_Struct(notmuch_rb_cFileNames, NULL, NULL, fnames); +} + /* * call-seq: MESSAGE.get_flag(flag) => true or false * @@ -119,7 +138,7 @@ notmuch_rb_message_get_flag(VALUE self, VALUE flagv) { notmuch_message_t *message; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); if (!FIXNUM_P(flagv)) rb_raise(rb_eTypeError, "Flag not a Fixnum"); @@ -137,7 +156,7 @@ notmuch_rb_message_set_flag(VALUE self, VALUE flagv, VALUE valuev) { notmuch_message_t *message; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); if (!FIXNUM_P(flagv)) rb_raise(rb_eTypeError, "Flag not a Fixnum"); @@ -157,7 +176,7 @@ notmuch_rb_message_get_date(VALUE self) { notmuch_message_t *message; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); return UINT2NUM(notmuch_message_get_date(message)); } @@ -173,7 +192,7 @@ notmuch_rb_message_get_header(VALUE self, VALUE headerv) const char *header, *value; notmuch_message_t *message; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); #if !defined(RSTRING_PTR) #define RSTRING_PTR(v) (RSTRING((v))->ptr) @@ -200,7 +219,7 @@ notmuch_rb_message_get_tags(VALUE self) notmuch_message_t *message; notmuch_tags_t *tags; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); tags = notmuch_message_get_tags(message); if (!tags) @@ -221,7 +240,7 @@ notmuch_rb_message_add_tag(VALUE self, VALUE tagv) notmuch_status_t ret; notmuch_message_t *message; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); #if !defined(RSTRING_PTR) #define RSTRING_PTR(v) (RSTRING((v))->ptr) @@ -248,7 +267,7 @@ notmuch_rb_message_remove_tag(VALUE self, VALUE tagv) notmuch_status_t ret; notmuch_message_t *message; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); #if !defined(RSTRING_PTR) #define RSTRING_PTR(v) (RSTRING((v))->ptr) @@ -274,7 +293,7 @@ notmuch_rb_message_remove_all_tags(VALUE self) notmuch_status_t ret; notmuch_message_t *message; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); ret = notmuch_message_remove_all_tags(message); notmuch_rb_status_raise(ret); @@ -282,6 +301,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 * @@ -293,7 +350,7 @@ notmuch_rb_message_freeze(VALUE self) notmuch_status_t ret; notmuch_message_t *message; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); ret = notmuch_message_freeze(message); notmuch_rb_status_raise(ret); @@ -312,7 +369,7 @@ notmuch_rb_message_thaw(VALUE self) notmuch_status_t ret; notmuch_message_t *message; - Data_Get_Struct(self, notmuch_message_t, message); + Data_Get_Notmuch_Message(self, message); ret = notmuch_message_thaw(message); notmuch_rb_status_raise(ret);