[PATCH 3/3] Go bindings: Wrap (most) remaining notmuch thread functions

Julius Plenz julius at plenz.com
Sat Mar 2 06:50:56 PST 2013


---
 bindings/go/src/notmuch/notmuch.go |   89 +++++++++++++++++++++++++++++++++++-
 1 file changed, 88 insertions(+), 1 deletion(-)

diff --git a/bindings/go/src/notmuch/notmuch.go b/bindings/go/src/notmuch/notmuch.go
index 306b104..8829f82 100644
--- a/bindings/go/src/notmuch/notmuch.go
+++ b/bindings/go/src/notmuch/notmuch.go
@@ -385,7 +385,94 @@ func (self *Query) CountMessages() uint {
 	return uint(C.notmuch_query_count_messages(self.query))
 }
 
-// TODO: wrap threads and thread
+func (self *Thread) GetToplevelMessages() *Messages {
+	if self.thread == nil {
+		return nil
+	}
+	msgs := C.notmuch_thread_get_toplevel_messages(self.thread)
+	if msgs == nil {
+		return nil
+	}
+	return &Messages{messages: msgs}
+}
+
+func (self *Thread) GetThreadId() string {
+	if self.thread == nil {
+		return ""
+	}
+	id := C.notmuch_thread_get_thread_id(self.thread)
+	if id == nil {
+		return ""
+	}
+	return C.GoString(id)
+}
+
+func (self *Thread) GetTotalMessages() uint {
+	if self.thread == nil {
+		return 0
+	}
+	return uint(C.notmuch_thread_get_total_messages(self.thread))
+}
+
+func (self *Thread) GetMatchedMessages() uint {
+	if self.thread == nil {
+		return 0
+	}
+	return uint(C.notmuch_thread_get_matched_messages(self.thread))
+}
+
+func (self *Thread) GetAuthors() string {
+	if self.thread == nil {
+		return ""
+	}
+	authors := C.notmuch_thread_get_authors(self.thread)
+	if authors == nil {
+		return ""
+	}
+	return C.GoString(authors)
+}
+
+func (self *Thread) GetSubject() string {
+	if self.thread == nil {
+		return ""
+	}
+	subject := C.notmuch_thread_get_subject(self.thread)
+	if subject == nil {
+		return ""
+	}
+	return C.GoString(subject)
+}
+
+func (self *Threads) MoveToNext() {
+	if self.threads == nil {
+		return
+	}
+	C.notmuch_threads_move_to_next(self.threads)
+}
+
+func (self *Threads) Get() *Thread {
+	if self.threads == nil {
+		return nil
+	}
+	t := C.notmuch_threads_get(self.threads)
+	if t == nil {
+		return nil
+	}
+	return &Thread{thread: t}
+}
+
+// TODO: notmuch_thread_get_oldest_date and notmuch_thread_get_newest_date
+
+func (self *Thread) GetTags() *Tags {
+	if self.thread == nil {
+		return nil
+	}
+	tags := C.notmuch_thread_get_tags(self.thread)
+	if tags == nil {
+		return nil
+	}
+	return &Tags{tags: tags}
+}
 
 func (self *Threads) Valid() bool {
 	if self.threads == nil {
-- 
1.7.10.4



More information about the notmuch mailing list