1 /* The Ruby interface to the notmuch mail library
3 * Copyright © 2010 Ali Polatel
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see http://www.gnu.org/licenses/ .
18 * Author: Ali Polatel <alip@exherbo.org>
23 /* call-seq: MESSAGES.each {|item| block } => MESSAGES
25 * Calls +block+ once for each message in +self+, passing that element as a
29 notmuch_rb_messages_each(VALUE self)
31 notmuch_rb_message_t *message;
32 notmuch_rb_messages_t *messages;
35 Data_Get_Struct(self, notmuch_rb_messages_t, messages);
36 if (!messages->nm_messages)
39 for (; notmuch_messages_valid(messages->nm_messages);
40 notmuch_messages_move_to_next(messages->nm_messages))
42 messagev = Data_Make_Struct(notmuch_rb_cMessage, notmuch_rb_message_t,
43 notmuch_rb_message_mark, notmuch_rb_message_free, message);
44 message->nm_message = notmuch_messages_get(messages->nm_messages);
45 message->parent = self;
53 * call-seq: MESSAGES.tags => TAGS
55 * Collect tags from the messages
58 notmuch_rb_messages_collect_tags(VALUE self)
60 notmuch_rb_tags_t *tags;
61 notmuch_rb_messages_t *messages;
64 Data_Get_Struct(self, notmuch_rb_messages_t, messages);
66 tagsv = Data_Make_Struct(notmuch_rb_cTags, notmuch_rb_tags_t,
67 notmuch_rb_tags_mark, notmuch_rb_tags_free, tags);
68 tags->nm_tags = notmuch_messages_collect_tags(messages->nm_messages);
71 rb_raise(notmuch_rb_eMemoryError, "out of memory");