NeoMutt  2024-04-16-36-g75b6fb
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 859 of file compress.c.

860{
861 if (!m->compress_info)
862 return 0;
863
864 struct CompressInfo *ci = m->compress_info;
865
866 const struct MxOps *ops = ci->child_ops;
867 if (!ops || !ops->tags_edit)
868 return 0;
869
870 return ops->tags_edit(m, tags, buf);
871}
Private data for compress.
Definition: lib.h:58
const struct MxOps * child_ops
callbacks of de-compressed file
Definition: lib.h:63
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 2190 of file imap.c.

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