+ Xapian::Enquire enquire (*notmuch->xapian_db);
+ Xapian::Query mail_query ("Kmail");
+ Xapian::Query string_query, final_query;
+ Xapian::MSet mset;
+ unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN &
+ Xapian::QueryParser::FLAG_PHRASE &
+ Xapian::QueryParser::FLAG_LOVEHATE &
+ Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE &
+ Xapian::QueryParser::FLAG_WILDCARD);
+
+ if (strcmp (query_string, "") == 0) {
+ final_query = mail_query;
+ } else {
+ string_query = notmuch->query_parser->
+ parse_query (query_string, flags);
+ final_query = Xapian::Query (Xapian::Query::OP_AND,
+ mail_query, string_query);
+ }
+
+ switch (query->sort) {
+ case NOTMUCH_SORT_DATE_OLDEST_FIRST:
+ enquire.set_sort_by_value (NOTMUCH_VALUE_DATE, FALSE);
+ break;
+ case NOTMUCH_SORT_DATE_NEWEST_FIRST:
+ enquire.set_sort_by_value (NOTMUCH_VALUE_DATE, TRUE);
+ break;
+ case NOTMUCH_SORT_MESSAGE_ID:
+ enquire.set_sort_by_value (NOTMUCH_VALUE_MESSAGE_ID, FALSE);
+ break;