From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id UG2vAegAL2AgMgAA0tVLHw (envelope-from ) for ; Fri, 19 Feb 2021 00:06:00 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id aOkaOecAL2BFIAAAB5/wlQ (envelope-from ) for ; Fri, 19 Feb 2021 00:05:59 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 44756190AE for ; Fri, 19 Feb 2021 01:05:59 +0100 (CET) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id DADE726A29; Thu, 18 Feb 2021 19:05:50 -0500 (EST) Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by mail.notmuchmail.org (Postfix) with ESMTPS id 7899D1FB0D for ; Thu, 18 Feb 2021 19:05:47 -0500 (EST) Received: by mail-pg1-x529.google.com with SMTP id m2so2368455pgq.5 for ; Thu, 18 Feb 2021 16:05:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dorileo-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XpWURPfRPbQpm4+KmBA6AkerWMypJ5rMrZkCCpCbbjA=; b=bw9qyyx2yVz4h3d2/5//Cy8y1g4HdR3UkBv0LYqlchAaR5XhhusKrA5Dioc7/+QOBj tilmIj7J8x+iotP6QR0YBA3a9LNr8RHrc5ABy03QkXzSx4/q847hU7mna+QTBglah9vL GhWHJPBINSqeSHGv0+/pmPoA6FvOyY5wv5+6cBovQIFrmbi1vI7WZahgX+8gI05HsZgE auCazMcW/ex9d1Q3NRaW8krP/3d6P0ZbD+ra7xi2vagTnUIbieWf2h/+NMjiJOtDHv6G CTCsYpIUpOvZwrU0279pmmyHpS5785sEKhz4Xykhj/D3546ydEpcNLgUZYoT3aBTeG7w dApw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XpWURPfRPbQpm4+KmBA6AkerWMypJ5rMrZkCCpCbbjA=; b=eiv+oVbh0J6ePR54KN3MvqEKllH1ZuKM3mzRo7Tz/y/83yk2R7LmuNFJAFl4fv0kri R59oX13xCV2X9I3DxQdtNP0iJjrnmH1+/dov4YEacqvz14wjY5LMlo6vwTjDJyvWcNJm KrHyflylJBnOEpEorlt2wU0yd5E/cj8c3zSwcsCjm+fmh5V4EBRrh/5f1boibTMENB5I t7xvIQDjhtAu5bf9wGKRqZPr2aRtwCAsf/xNU94cQDQY2SZtJ2uXwwFojmWRH0PbJvls J/fsampQo5d0T35KKIKQKwsrLb23EGTZFwIi0pxzuFg0Ip640nkZVxofaAbkaThtPeAH ey2Q== X-Gm-Message-State: AOAM533LkNXftAyXANhmrsAwao6cN0TYLMoGDLKxtpl6RGGmThD/cIvH 049tSz/A6TGSPiNtowlII50ah3QIo4rT42Tb X-Google-Smtp-Source: ABdhPJyai6dDKiSe0C9Q0+g1Z2+tCWMbdCctVtP5pQvSPUbfJr3erG1qxYhdLyngN+5ox1PC/Cnyzg== X-Received: by 2002:a63:4442:: with SMTP id t2mr5894926pgk.23.1613693139512; Thu, 18 Feb 2021 16:05:39 -0800 (PST) Received: from dorilex.hsd1.or.comcast.net ([2601:1c0:6a01:6410::ad3f]) by smtp.gmail.com with ESMTPSA id d19sm1773831pjz.0.2021.02.18.16.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 16:05:39 -0800 (PST) From: Leandro Dorileo To: notmuch@notmuchmail.org Subject: [PATCH resend] contrib/go: update the go binding Date: Thu, 18 Feb 2021 16:05:13 -0800 Message-Id: <20210219000513.1324753-1-l@dorileo.org> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Message-ID-Hash: S3UJLOQV3U7NNDTAWQPEJA4QX3N3JAEI X-Message-ID-Hash: S3UJLOQV3U7NNDTAWQPEJA4QX3N3JAEI X-MailFrom: l@dorileo.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Leandro Dorileo X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -0.03 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=dorileo-org.20150623.gappssmtp.com header.s=20150623 header.b=bw9qyyx2; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 44756190AE X-Spam-Score: -0.03 X-Migadu-Scanner: scn1.migadu.com X-TUID: 7DYB8JW82xGp Make sure to update the go binding to reflect the recent changes to notmuch api. --- .../go/src/notmuch-addrlookup/addrlookup.go | 22 ++++++++++-- contrib/go/src/notmuch/notmuch.go | 34 +++++++++++-------- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/contrib/go/src/notmuch-addrlookup/addrlookup.go b/contrib/go/src/notmuch-addrlookup/addrlookup.go index 916e5bb2..b1023f24 100644 --- a/contrib/go/src/notmuch-addrlookup/addrlookup.go +++ b/contrib/go/src/notmuch-addrlookup/addrlookup.go @@ -130,7 +130,12 @@ func search_address_passes(queries [3]*notmuch.Query, name string) []string { //println("**warning: idx [",idx,"] contains a nil query") continue } - msgs := query.SearchMessages() + + msgs, status := query.SearchMessages() + if status != notmuch.STATUS_SUCCESS { + continue + } + ht := addresses_by_frequency(msgs, name, pass, &addr_to_realname) for addr, count := range *ht { freq, ok := addr_freq[addr] @@ -231,8 +236,21 @@ func (self *address_matcher) run(name string) { } queries[1] = self.db.CreateQuery(query) + cnt1, cnt2 := uint(0), uint(0) + status := notmuch.STATUS_SUCCESS + // if that leads only to a few hits, we check every from too - if queries[0].CountMessages()+queries[1].CountMessages() < 10 { + cnt1, status = queries[0].CountMessages() + if status != notmuch.STATUS_SUCCESS { + log.Fatalf("Failed to count messages: %v.", status) + } + + cnt2, status = queries[1].CountMessages() + if status != notmuch.STATUS_SUCCESS { + log.Fatalf("Failed to count messages: %v.", status) + } + + if cnt1+cnt2 < 10 { query = "" if name != "" { query = "from:" + name + "*" diff --git a/contrib/go/src/notmuch/notmuch.go b/contrib/go/src/notmuch/notmuch.go index 5496198a..c04c4c5a 100644 --- a/contrib/go/src/notmuch/notmuch.go +++ b/contrib/go/src/notmuch/notmuch.go @@ -255,10 +255,10 @@ func (self *Database) AddMessage(fname string) (*Message, Status) { return nil, STATUS_OUT_OF_MEMORY } - var c_msg *C.notmuch_message_t = new(C.notmuch_message_t) - st := Status(C.notmuch_database_add_message(self.db, c_fname, &c_msg)) + msg := &Message{message: nil} + st := Status(C.notmuch_database_add_message(self.db, c_fname, &msg.message)) - return &Message{message: c_msg}, st + return msg, st } /* Remove a message from the given notmuch database. @@ -454,12 +454,13 @@ func (self *Query) GetSort() Sort { * * If a Xapian exception occurs this function will return NULL. */ -func (self *Query) SearchThreads() *Threads { - threads := C.notmuch_query_search_threads(self.query) - if threads == nil { - return nil +func (self *Query) SearchThreads() (*Threads, Status) { + threads := &Threads{threads: nil} + st := Status(C.notmuch_query_search_threads(self.query, &threads.threads)) + if st != STATUS_SUCCESS { + return nil, st } - return &Threads{threads: threads} + return threads, st } /* Execute a query for messages, returning a notmuch_messages_t object @@ -500,12 +501,13 @@ func (self *Query) SearchThreads() *Threads { * * If a Xapian exception occurs this function will return NULL. */ -func (self *Query) SearchMessages() *Messages { - msgs := C.notmuch_query_search_messages(self.query) - if msgs == nil { - return nil +func (self *Query) SearchMessages() (*Messages, Status) { + msgs := &Messages{messages: nil} + st := Status(C.notmuch_query_search_messages(self.query, &msgs.messages)) + if st != STATUS_SUCCESS { + return nil, st } - return &Messages{messages: msgs} + return msgs, st } /* Destroy a notmuch_query_t along with any associated resources. @@ -530,8 +532,10 @@ func (self *Query) Destroy() { * If a Xapian exception occurs, this function may return 0 (after * printing a message). */ -func (self *Query) CountMessages() uint { - return uint(C.notmuch_query_count_messages(self.query)) +func (self *Query) CountMessages() (uint, Status) { + var cnt C.uint + st := Status(C.notmuch_query_count_messages(self.query, &cnt)) + return uint(cnt), st } /* Is the given 'threads' iterator pointing at a valid thread. -- 2.30.1