Notmuch query functions. More...
Include dependency graph for query.c:Go to the source code of this file.
Functions | |
| enum NmQueryType | nm_parse_type_from_query (char *buf, enum NmQueryType fallback) |
| Parse a query type out of a query. | |
| const char * | nm_query_type_to_string (enum NmQueryType query_type) |
| Turn a query type into a string. | |
| 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. | |
| bool | nm_query_window_check_timebase (const char *timebase) |
| Checks if a given timebase string is valid. | |
| 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. | |
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.c.
| 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 caller graph for this function:| const char * nm_query_type_to_string | ( | enum NmQueryType | query_type | ) |
| 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 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 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 caller graph for this function:| 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 date search 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, or year |
| [in] | or_terms | Additional notmuch search terms |
| NM_WINDOW_QUERY_SUCCESS | Prepended buf with date: search term |
| NM_WINDOW_QUERY_INVALID_DURATION | Duration out-of-range for search term. buf not prepended with date: |
| NM_WINDOW_QUERY_INVALID_TIMEBASE | Timebase isn't one of hour, day, week, month, or year |
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 caller graph for this function: