Notmuch query functions. More...
#include <stdbool.h>#include <stddef.h> Include dependency graph for query.h:
 Include dependency graph for query.h: This graph shows which files directly or indirectly include this file:
 This graph shows which files directly or indirectly include this file:Go to the source code of this file.
| Enumerations | |
| enum | NmQueryType { NM_QUERY_TYPE_MESGS = 1 , NM_QUERY_TYPE_THREADS , NM_QUERY_TYPE_UNKNOWN } | 
| Notmuch Query Types.  More... | |
| enum | NmWindowQueryRc { NM_WINDOW_QUERY_SUCCESS = 1 , NM_WINDOW_QUERY_INVALID_TIMEBASE , NM_WINDOW_QUERY_INVALID_DURATION } | 
| Return codes for nm_windowed_query_from_query()  More... | |
| Functions | |
| enum NmQueryType | nm_parse_type_from_query (char *buf, enum NmQueryType fallback) | 
| Parse a query type out of a query. | |
| enum NmQueryType | nm_string_to_query_type (const char *str) | 
| Lookup a query type. | |
| enum NmQueryType | nm_string_to_query_type_mapper (const char *str) | 
| Lookup a query type. | |
| const char * | nm_query_type_to_string (enum NmQueryType query_type) | 
| Turn a query type into a string. | |
| enum NmWindowQueryRc | nm_windowed_query_from_query (char *buf, size_t buflen, const bool force_enable, const short duration, const short current_pos, const char *current_search, const char *timebase, const char *or_terms) | 
| Windows bufwith notmuchdate:search term. | |
| bool | nm_query_window_check_timebase (const char *timebase) | 
| Checks if a given timebase string is valid. | |
Notmuch query functions.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file query.h.
| enum NmQueryType | 
Notmuch Query Types.
Read whole-thread or matching messages only?
| Enumerator | |
|---|---|
| NM_QUERY_TYPE_MESGS | Default: Messages only. | 
| NM_QUERY_TYPE_THREADS | Whole threads. | 
| NM_QUERY_TYPE_UNKNOWN | Unknown query type. Error in notmuch query. | 
Definition at line 34 of file query.h.
| enum NmWindowQueryRc | 
Return codes for nm_windowed_query_from_query()
| Enumerator | |
|---|---|
| NM_WINDOW_QUERY_SUCCESS | Query was successful. | 
| NM_WINDOW_QUERY_INVALID_TIMEBASE | Invalid timebase. | 
| NM_WINDOW_QUERY_INVALID_DURATION | Invalid duration. | 
Definition at line 44 of file query.h.
| enum NmQueryType nm_parse_type_from_query | ( | char * | buf, | 
| enum NmQueryType | fallback ) | 
Parse a query type out of a query.
| buf | Buffer for URL | 
| fallback | Fallback query type if buf doesn't contain a type= statement | 
| enum | NmQueryType, Notmuch query type | 
If a user writes a query for a vfolder and includes a type= statement, that type= will be encoded, which Notmuch will treat as part of the query= statement. This method will remove the type= and return its corresponding NmQueryType representation.
Definition at line 49 of file query.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| enum NmQueryType nm_string_to_query_type | ( | const char * | str | ) | 
Lookup a query type.
| str | String to lookup | 
| enum | NmQueryType, e.g. NM_QUERY_TYPE_MESGS | 
If there's an unknown query type, default to NM_QUERY_TYPE_MESGS.
Definition at line 110 of file query.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| enum NmQueryType nm_string_to_query_type_mapper | ( | const char * | str | ) | 
Lookup a query type.
| str | String to lookup | 
| num | Query type | 
| NM_QUERY_TYPE_UNKNOWN | on error | 
Definition at line 129 of file query.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| const char * nm_query_type_to_string | ( | enum NmQueryType | query_type | ) | 
| enum NmWindowQueryRc nm_windowed_query_from_query | ( | char * | buf, | 
| size_t | buflen, | ||
| const bool | force_enable, | ||
| const short | duration, | ||
| const short | cur_pos, | ||
| const char * | cur_search, | ||
| const char * | timebase, | ||
| const char * | or_terms ) | 
Windows buf with notmuch date: search term. 
| [out] | buf | allocated string buffer to receive the modified search query | 
| [in] | buflen | allocated maximum size of the buf string buffer | 
| [in] | force_enable | Enables windowing for duration=0 | 
| [in] | duration | Duration of time between beginning and end for notmuch datesearch term | 
| [in] | cur_pos | Current position of vfolder window | 
| [in] | cur_search | Current notmuch search | 
| [in] | timebase | Timebase for date:search term. Must be:hour,day,week,month, oryear | 
| [in] | or_terms | Additional notmuch search terms | 
| NM_WINDOW_QUERY_SUCCESS | Prepended bufwithdate:search term | 
| NM_WINDOW_QUERY_INVALID_DURATION | Duration out-of-range for search term. bufnot prepended withdate: | 
| NM_WINDOW_QUERY_INVALID_TIMEBASE | Timebase isn't one of hour,day,week,month, oryear | 
This is where the magic of windowed queries happens. Taking a vfolder search query string as parameter, it will use the following two user settings:
duration andtimebaseto amend given vfolder search window. Then using a third parameter:
cur_posit will generate a proper notmuch date: parameter. For example, given a duration of 2, a timebase set to week and a position defaulting to 0, it will prepend to the 'tag:inbox' notmuch search query the following string:
query: tag:inboxbuf: date:2week..now and tag:inboxIf the position is set to 4, with duration=3 and timebase=month:
query: tag:archivedbuf: date:12month..9month and tag:archivedThe window won't be applied:
0 this function will be disabled unless a user explicitly enables windowed queries. This returns NM_WINDOW_QUERY_INVALID_DURATIONDefinition at line 206 of file query.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function:| bool nm_query_window_check_timebase | ( | const char * | timebase | ) | 
Checks if a given timebase string is valid.
| [in] | timebase | string containing a time base | 
| true | The given time base is valid | 
This function returns whether a given timebase string is valid or not, which is used to validate the user settable configuration setting:
nm_query_window_timebase
Definition at line 149 of file query.c.
 Here is the call graph for this function:
 Here is the call graph for this function: Here is the caller graph for this function:
 Here is the caller graph for this function: