1 Return-Path: <laochailan@web.de>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id A394B6DE17A6
\r
6 for <notmuch@notmuchmail.org>; Sun, 31 May 2015 05:07:56 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=-0.56 tagged_above=-999 required=5 tests=[AWL=-0.009,
\r
12 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001,
\r
13 RP_MATCHES_RCVD=-0.55, SPF_PASS=-0.001] autolearn=disabled
\r
14 Received: from arlo.cworth.org ([127.0.0.1])
\r
15 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id DQlLnaLJSnh1 for <notmuch@notmuchmail.org>;
\r
17 Sun, 31 May 2015 05:07:55 -0700 (PDT)
\r
18 Received: from mout.web.de (mout.web.de [212.227.15.14])
\r
19 by arlo.cworth.org (Postfix) with ESMTPS id 95E5A6DE17A3
\r
20 for <notmuch@notmuchmail.org>; Sun, 31 May 2015 05:07:54 -0700 (PDT)
\r
21 Received: from localhost ([92.204.48.23]) by smtp.web.de (mrweb003) with
\r
22 ESMTPSA (Nemesis) id 0Mb8xf-1Yeslp1e2t-00KdaH; Sun, 31 May 2015 14:02:46
\r
24 From: laochailan <laochailan@web.de>
\r
25 To: notmuch@notmuchmail.org
\r
26 Subject: [PATCH 1/5] Added thread bindings to go bindings
\r
27 Date: Sun, 31 May 2015 14:02:11 +0200
\r
28 Message-Id: <1433073735-7721-2-git-send-email-laochailan@web.de>
\r
29 X-Mailer: git-send-email 2.4.2
\r
30 In-Reply-To: <1433073735-7721-1-git-send-email-laochailan@web.de>
\r
31 References: <1433073735-7721-1-git-send-email-laochailan@web.de>
\r
32 X-Provags-ID: V03:K0:/SkHwg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X-Mailman-Approved-At: Mon, 01 Jun 2015 09:14:43 -0700
\r
48 Cc: laochailan <laochailan@web.de>
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.18
\r
52 List-Id: "Use and development of the notmuch mail system."
\r
53 <notmuch.notmuchmail.org>
\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
57 List-Post: <mailto:notmuch@notmuchmail.org>
\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
61 X-List-Received-Date: Sun, 31 May 2015 12:07:56 -0000
\r
64 bindings/go/src/notmuch/notmuch.go | 262 ++++++++++++++++++++++++++++++++++++-
\r
65 1 file changed, 260 insertions(+), 2 deletions(-)
\r
67 diff --git a/bindings/go/src/notmuch/notmuch.go b/bindings/go/src/notmuch/notmuch.go
\r
68 index 0fff1ab..a0b901f 100644
\r
69 --- a/bindings/go/src/notmuch/notmuch.go
\r
70 +++ b/bindings/go/src/notmuch/notmuch.go
\r
71 @@ -534,8 +534,6 @@ func (self *Query) CountMessages() uint {
\r
72 return uint(C.notmuch_query_count_messages(self.query))
\r
75 -// TODO: wrap threads and thread
\r
77 /* Is the given 'threads' iterator pointing at a valid thread.
\r
79 * When this function returns TRUE, notmuch_threads_get will return a
\r
80 @@ -556,6 +554,45 @@ func (self *Threads) Valid() bool {
\r
84 +/* Get the current thread from 'threads' as a notmuch_thread_t.
\r
86 + * Note: The returned thread belongs to 'threads' and has a lifetime
\r
87 + * identical to it (and the query to which it belongs).
\r
89 + * See the documentation of notmuch_query_search_threads for example
\r
90 + * code showing how to iterate over a notmuch_threads_t object.
\r
92 + * If an out-of-memory situation occurs, this function will return
\r
95 +func (self *Threads) Get() *Thread {
\r
96 + if self.threads == nil {
\r
99 + thread := C.notmuch_threads_get(self.threads)
\r
100 + if thread == nil {
\r
103 + return &Thread{thread}
\r
106 +/* Move the 'threads' iterator to the next thread.
\r
108 + * If 'threads' is already pointing at the last thread then the
\r
109 + * iterator will be moved to a point just beyond that last thread,
\r
110 + * (where notmuch_threads_valid will return FALSE and
\r
111 + * notmuch_threads_get will return NULL).
\r
113 + * See the documentation of notmuch_query_search_threads for example
\r
114 + * code showing how to iterate over a notmuch_threads_t object.
\r
116 +func (self *Threads) MoveToNext() {
\r
117 + if self.threads == nil {
\r
120 + C.notmuch_threads_move_to_next(self.threads)
\r
123 /* Destroy a notmuch_threads_t object.
\r
125 * It's not strictly necessary to call this function. All memory from
\r
126 @@ -568,6 +605,227 @@ func (self *Threads) Destroy() {
\r
131 + * Get the thread ID of 'thread'.
\r
133 + * The returned string belongs to 'thread' and as such, should not be
\r
134 + * modified by the caller and will only be valid for as long as the
\r
135 + * thread is valid, (which is until notmuch_thread_destroy or until
\r
136 + * the query from which it derived is destroyed).
\r
138 +func (self *Thread) GetThreadId() string {
\r
139 + if self.thread == nil {
\r
142 + id := C.notmuch_thread_get_thread_id(self.thread)
\r
146 + return C.GoString(id)
\r
150 + * Get the total number of messages in 'thread'.
\r
152 + * This count consists of all messages in the database belonging to
\r
153 + * this thread. Contrast with notmuch_thread_get_matched_messages() .
\r
155 +func (self *Thread) GetTotalMessages() int {
\r
156 + if self.thread == nil {
\r
159 + return int(C.notmuch_thread_get_total_messages(self.thread))
\r
163 + * Get a notmuch_messages_t iterator for the top-level messages in
\r
164 + * 'thread' in oldest-first order.
\r
166 + * This iterator will not necessarily iterate over all of the messages
\r
167 + * in the thread. It will only iterate over the messages in the thread
\r
168 + * which are not replies to other messages in the thread.
\r
170 + * The returned list will be destroyed when the thread is destroyed.
\r
172 +func (self *Thread) GetToplevelMessages() (*Messages, Status) {
\r
173 + if self.thread == nil {
\r
174 + return nil, STATUS_NULL_POINTER
\r
177 + msgs := C.notmuch_thread_get_toplevel_messages(self.thread)
\r
179 + return nil, STATUS_NULL_POINTER
\r
181 + return &Messages{msgs}, STATUS_SUCCESS
\r
185 + * Get a notmuch_thread_t iterator for all messages in 'thread' in
\r
186 + * oldest-first order.
\r
188 + * The returned list will be destroyed when the thread is destroyed.
\r
190 +func (self *Thread) GetMessages() (*Messages, Status) {
\r
191 + if self.thread == nil {
\r
192 + return nil, STATUS_NULL_POINTER
\r
195 + msgs := C.notmuch_thread_get_messages(self.thread)
\r
197 + return nil, STATUS_NULL_POINTER
\r
199 + return &Messages{msgs}, STATUS_SUCCESS
\r
203 + * Get the number of messages in 'thread' that matched the search.
\r
205 + * This count includes only the messages in this thread that were
\r
206 + * matched by the search from which the thread was created and were
\r
207 + * not excluded by any exclude tags passed in with the query (see
\r
208 + * notmuch_query_add_tag_exclude). Contrast with
\r
209 + * notmuch_thread_get_total_messages() .
\r
211 +func (self *Thread) GetMatchedMessages() int {
\r
212 + if self.thread == nil {
\r
215 + return int(C.notmuch_thread_get_matched_messages(self.thread))
\r
219 + * Get the authors of 'thread' as a UTF-8 string.
\r
221 + * The returned string is a comma-separated list of the names of the
\r
222 + * authors of mail messages in the query results that belong to this
\r
225 + * The string contains authors of messages matching the query first, then
\r
226 + * non-matched authors (with the two groups separated by '|'). Within
\r
227 + * each group, authors are ordered by date.
\r
229 + * The returned string belongs to 'thread' and as such, should not be
\r
230 + * modified by the caller and will only be valid for as long as the
\r
231 + * thread is valid, (which is until notmuch_thread_destroy or until
\r
232 + * the query from which it derived is destroyed).
\r
234 +func (self *Thread) GetAuthors() string {
\r
235 + if self.thread == nil {
\r
238 + str := C.notmuch_thread_get_authors(self.thread)
\r
242 + return C.GoString(str)
\r
246 + * Get the subject of 'thread' as a UTF-8 string.
\r
248 + * The subject is taken from the first message (according to the query
\r
249 + * order---see notmuch_query_set_sort) in the query results that
\r
250 + * belongs to this thread.
\r
252 + * The returned string belongs to 'thread' and as such, should not be
\r
253 + * modified by the caller and will only be valid for as long as the
\r
254 + * thread is valid, (which is until notmuch_thread_destroy or until
\r
255 + * the query from which it derived is destroyed).
\r
257 +func (self *Thread) GetSubject() string {
\r
258 + if self.thread == nil {
\r
261 + str := C.notmuch_thread_get_subject(self.thread)
\r
265 + return C.GoString(str)
\r
269 + * Get the date of the oldest message in 'thread' as a time_t value.
\r
271 +func (self *Thread) GetOldestDate() int64 {
\r
272 + if self.thread == nil {
\r
275 + date := C.notmuch_thread_get_oldest_date(self.thread)
\r
277 + return int64(date)
\r
281 + * Get the date of the newest message in 'thread' as a time_t value.
\r
283 +func (self *Thread) GetNewestDate() int64 {
\r
284 + if self.thread == nil {
\r
287 + date := C.notmuch_thread_get_newest_date(self.thread)
\r
289 + return int64(date)
\r
293 + * Get the tags for 'thread', returning a notmuch_tags_t object which
\r
294 + * can be used to iterate over all tags.
\r
296 + * Note: In the Notmuch database, tags are stored on individual
\r
297 + * messages, not on threads. So the tags returned here will be all
\r
298 + * tags of the messages which matched the search and which belong to
\r
301 + * The tags object is owned by the thread and as such, will only be
\r
302 + * valid for as long as the thread is valid, (for example, until
\r
303 + * notmuch_thread_destroy or until the query from which it derived is
\r
306 + * Typical usage might be:
\r
308 + * notmuch_thread_t *thread;
\r
309 + * notmuch_tags_t *tags;
\r
310 + * const char *tag;
\r
312 + * thread = notmuch_threads_get (threads);
\r
314 + * for (tags = notmuch_thread_get_tags (thread);
\r
315 + * notmuch_tags_valid (tags);
\r
316 + * notmuch_tags_move_to_next (tags))
\r
318 + * tag = notmuch_tags_get (tags);
\r
322 + * notmuch_thread_destroy (thread);
\r
324 + * Note that there's no explicit destructor needed for the
\r
325 + * notmuch_tags_t object. (For consistency, we do provide a
\r
326 + * notmuch_tags_destroy function, but there's no good reason to call
\r
327 + * it if the message is about to be destroyed).
\r
329 +func (self *Thread) GetTags() *Tags {
\r
330 + if self.thread == nil {
\r
334 + tags := C.notmuch_thread_get_tags(self.thread)
\r
339 + return &Tags{tags}
\r
343 + * Destroy a notmuch_thread_t object.
\r
345 +func (self *Thread) Destroy() {
\r
346 + if self.thread != nil {
\r
347 + C.notmuch_thread_destroy(self.thread)
\r
351 /* Is the given 'messages' iterator pointing at a valid message.
\r
353 * When this function returns TRUE, notmuch_messages_get will return a
\r