NeoMutt  2025-01-09-117-gace867
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 824 of file compress.c.

825{
826 if (!m->compress_info)
827 return 0;
828
829 struct CompressInfo *ci = m->compress_info;
830
831 const struct MxOps *ops = ci->child_ops;
832 if (!ops || !ops->tags_edit)
833 return 0;
834
835 return ops->tags_edit(m, tags, buf);
836}
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:88
int(* tags_edit)(struct Mailbox *m, const char *tags, struct Buffer *buf)
Definition: mxapi.h:303

◆ 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 2193 of file imap.c.

2194{
2195 struct ImapMboxData *mdata = imap_mdata_get(m);
2196 if (!mdata)
2197 return -1;
2198
2199 char *new_tag = NULL;
2200 char *checker = NULL;
2201
2202 /* Check for \* flags capability */
2203 if (!imap_has_flag(&mdata->flags, NULL))
2204 {
2205 mutt_error(_("IMAP server doesn't support custom flags"));
2206 return -1;
2207 }
2208
2209 buf_reset(buf);
2210 if (tags)
2211 buf_strcpy(buf, tags);
2212
2213 if (mw_get_field("Tags: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER, NULL, NULL) != 0)
2214 return -1;
2215
2216 /* each keyword must be atom defined by rfc822 as:
2217 *
2218 * atom = 1*<any CHAR except specials, SPACE and CTLs>
2219 * CHAR = ( 0.-127. )
2220 * specials = "(" / ")" / "<" / ">" / "@"
2221 * / "," / ";" / ":" / "\" / <">
2222 * / "." / "[" / "]"
2223 * SPACE = ( 32. )
2224 * CTLS = ( 0.-31., 127.)
2225 *
2226 * And must be separated by one space.
2227 */
2228
2229 new_tag = buf->data;
2230 checker = buf->data;
2231 SKIPWS(checker);
2232 while (*checker != '\0')
2233 {
2234 if ((*checker < 32) || (*checker >= 127) || // We allow space because it's the separator
2235 (*checker == 40) || // (
2236 (*checker == 41) || // )
2237 (*checker == 60) || // <
2238 (*checker == 62) || // >
2239 (*checker == 64) || // @
2240 (*checker == 44) || // ,
2241 (*checker == 59) || // ;
2242 (*checker == 58) || // :
2243 (*checker == 92) || // backslash
2244 (*checker == 34) || // "
2245 (*checker == 46) || // .
2246 (*checker == 91) || // [
2247 (*checker == 93)) // ]
2248 {
2249 mutt_error(_("Invalid IMAP flags"));
2250 return 0;
2251 }
2252
2253 /* Skip duplicate space */
2254 while ((checker[0] == ' ') && (checker[1] == ' '))
2255 checker++;
2256
2257 /* copy char to new_tag and go the next one */
2258 *new_tag++ = *checker++;
2259 }
2260 *new_tag = '\0';
2261 new_tag = buf->data; /* rewind */
2263
2264 return !mutt_str_equal(tags, buf_string(buf));
2265}
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:273
#define mutt_error(...)
Definition: logging2.h:93
@ 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:877
#define _(a)
Definition: message.h:28
void mutt_str_remove_trailing_ws(char *s)
Trim trailing whitespace from a string.
Definition: string.c:566
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:661
#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 2424 of file notmuch.c.

2425{
2426 buf_reset(buf);
2427 if (mw_get_field("Add/remove labels: ", buf, MUTT_COMP_NO_FLAGS, HC_OTHER,
2428 &CompleteNmTagOps, NULL) != 0)
2429 {
2430 return -1;
2431 }
2432 return 1;
2433}
const struct CompleteOps CompleteNmTagOps
Auto-Completion of NmTags.
Definition: complete.c:254
+ Here is the call graph for this function: