NeoMutt  2024-12-12-14-g7b49f7
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
tags_edit()

Prompt and validate new messages tags. More...

+ Collaboration diagram for tags_edit():

Functions

static int comp_tags_edit (struct Mailbox *m, const char *tags, struct Buffer *buf)
 Prompt and validate new messages tags - Implements MxOps::tags_edit() -.
 
static int imap_tags_edit (struct Mailbox *m, const char *tags, struct Buffer *buf)
 Prompt and validate new messages tags - Implements MxOps::tags_edit() -.
 
static int nm_tags_edit (struct Mailbox *m, const char *tags, struct Buffer *buf)
 Prompt and validate new messages tags - Implements MxOps::tags_edit() -.
 

Detailed Description

Prompt and validate new messages tags.

Parameters
mMailbox
tagsExisting tags
bufBuffer to store the tags
Return values
-1Error
0No valid user input
1Buf set
Precondition
m is not NULL
buf is not NULL

Function Documentation

◆ comp_tags_edit()

static int comp_tags_edit ( struct Mailbox m,
const char *  tags,
struct Buffer buf 
)
static

Prompt and validate new messages tags - Implements MxOps::tags_edit() -.

Definition at line 831 of file compress.c.

832{
833 if (!m->compress_info)
834 return 0;
835
836 struct CompressInfo *ci = m->compress_info;
837
838 const struct MxOps *ops = ci->child_ops;
839 if (!ops || !ops->tags_edit)
840 return 0;
841
842 return ops->tags_edit(m, tags, buf);
843}
Private data for compress.
Definition: lib.h:60
const struct MxOps * child_ops
callbacks of de-compressed file
Definition: lib.h:65
void * compress_info
Compressed mbox module private data.
Definition: mailbox.h:121
Definition: mxapi.h:91
int(* tags_edit)(struct Mailbox *m, const char *tags, struct Buffer *buf)
Definition: mxapi.h:306

◆ imap_tags_edit()

static int imap_tags_edit ( struct Mailbox m,
const char *  tags,
struct Buffer buf 
)
static

Prompt and validate new messages tags - Implements MxOps::tags_edit() -.

Definition at line 2189 of file imap.c.

2190{
2191 struct ImapMboxData *mdata = imap_mdata_get(m);
2192 if (!mdata)
2193 return -1;
2194
2195 char *new_tag = NULL;
2196 char *checker = NULL;
2197
2198 /* Check for \* flags capability */
2199 if (!imap_has_flag(&mdata->flags, NULL))
2200 {
2201 mutt_error(_("IMAP server doesn't support custom flags"));
2202 return -1;
2203 }
2204
2205 buf_reset(buf);
2206 if (tags)
2207 buf_strcpy(buf, tags);
2208
2209 if (mw_get_field("Tags: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0)
2210 return -1;
2211
2212 /* each keyword must be atom defined by rfc822 as:
2213 *
2214 * atom = 1*<any CHAR except specials, SPACE and CTLs>
2215 * CHAR = ( 0.-127. )
2216 * specials = "(" / ")" / "<" / ">" / "@"
2217 * / "," / ";" / ":" / "\" / <">
2218 * / "." / "[" / "]"
2219 * SPACE = ( 32. )
2220 * CTLS = ( 0.-31., 127.)
2221 *
2222 * And must be separated by one space.
2223 */
2224
2225 new_tag = buf->data;
2226 checker = buf->data;
2227 SKIPWS(checker);
2228 while (*checker != '\0')
2229 {
2230 if ((*checker < 32) || (*checker >= 127) || // We allow space because it's the separator
2231 (*checker == 40) || // (
2232 (*checker == 41) || // )
2233 (*checker == 60) || // <
2234 (*checker == 62) || // >
2235 (*checker == 64) || // @
2236 (*checker == 44) || // ,
2237 (*checker == 59) || // ;
2238 (*checker == 58) || // :
2239 (*checker == 92) || // backslash
2240 (*checker == 34) || // "
2241 (*checker == 46) || // .
2242 (*checker == 91) || // [
2243 (*checker == 93)) // ]
2244 {
2245 mutt_error(_("Invalid IMAP flags"));
2246 return 0;
2247 }
2248
2249 /* Skip duplicate space */
2250 while ((checker[0] == ' ') && (checker[1] == ' '))
2251 checker++;
2252
2253 /* copy char to new_tag and go the next one */
2254 *new_tag++ = *checker++;
2255 }
2256 *new_tag = '\0';
2257 new_tag = buf->data; /* rewind */
2259
2260 return !mutt_str_equal(tags, buf_string(buf));
2261}
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:76
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:395
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
int mw_get_field(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
Ask the user for a string -.
Definition: window.c:274
#define mutt_error(...)
Definition: logging2.h:92
@ HC_OTHER
Miscellaneous strings.
Definition: lib.h:58
struct ImapMboxData * imap_mdata_get(struct Mailbox *m)
Get the Mailbox data for this mailbox.
Definition: mdata.c:61
bool imap_has_flag(struct ListHead *flag_list, const char *flag)
Does the flag exist in the list.
Definition: imap.c:873
#define _(a)
Definition: message.h:28
void mutt_str_remove_trailing_ws(char *s)
Trim trailing whitespace from a string.
Definition: string.c:565
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:660
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition: mutt.h:56
#define SKIPWS(ch)
Definition: string2.h:45
char * data
Pointer to data.
Definition: buffer.h:37
IMAP-specific Mailbox data -.
Definition: mdata.h:40
void * mdata
Driver specific data.
Definition: mailbox.h:132
+ Here is the call graph for this function:

◆ nm_tags_edit()

static int nm_tags_edit ( struct Mailbox m,
const char *  tags,
struct Buffer buf 
)
static

Prompt and validate new messages tags - Implements MxOps::tags_edit() -.

Definition at line 2404 of file notmuch.c.

2405{
2406 buf_reset(buf);
2407 if (mw_get_field("Add/remove labels: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER,
2408 &CompleteNmTagOps, NULL) != 0)
2409 {
2410 return -1;
2411 }
2412 return 1;
2413}
const struct CompleteOps CompleteNmTagOps
Auto-Completion of NmTags.
Definition: complete.c:254
+ Here is the call graph for this function: