X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=lib%2Fquery.cc;h=9acf2b03b84da6729f78a8e6ee843a7eb35d0afd;hb=1cb28764d86e5e0c98bdd49140568e523571a5a2;hp=3e20f59c8ce9951a1501ac8b7002e2f0a56df7a1;hpb=4971b85641def6b17072ae1b0de0adf15d197f2c;p=notmuch diff --git a/lib/query.cc b/lib/query.cc index 3e20f59c..9acf2b03 100644 --- a/lib/query.cc +++ b/lib/query.cc @@ -70,12 +70,24 @@ notmuch_query_create (notmuch_database_t *notmuch, return query; } +const char * +notmuch_query_get_query_string (notmuch_query_t *query) +{ + return query->query_string; +} + void notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort) { query->sort = sort; } +notmuch_sort_t +notmuch_query_get_sort (notmuch_query_t *query) +{ + return query->sort; +} + /* We end up having to call the destructors explicitly because we had * to use "placement new" in order to initialize C++ objects within a * block that we allocated with talloc. So C++ is making talloc @@ -148,6 +160,8 @@ notmuch_query_search_messages (notmuch_query_t *query) case NOTMUCH_SORT_MESSAGE_ID: enquire.set_sort_by_value (NOTMUCH_VALUE_MESSAGE_ID, FALSE); break; + case NOTMUCH_SORT_UNSORTED: + break; } #if DEBUG_QUERY @@ -161,14 +175,16 @@ notmuch_query_search_messages (notmuch_query_t *query) messages->iterator = mset.begin (); messages->iterator_end = mset.end (); + return &messages->base; + } catch (const Xapian::Error &error) { fprintf (stderr, "A Xapian exception occurred performing query: %s\n", error.get_msg().c_str()); fprintf (stderr, "Query string was: %s\n", query->query_string); notmuch->exception_reported = TRUE; + talloc_free (messages); + return NULL; } - - return &messages->base; } notmuch_bool_t @@ -245,6 +261,10 @@ notmuch_query_search_threads (notmuch_query_t *query) free, NULL); threads->messages = notmuch_query_search_messages (query); + if (threads->messages == NULL) { + talloc_free (threads); + return NULL; + } threads->thread_id = NULL;