Commit 0e8ae1c3 0e8ae1c37611759936ce66eefff2ef392c3b8de0 by Sergey Poznyakoff

Implement UID command in mu imap

1 parent 7d68b3cd
Showing 1 changed file with 23 additions and 5 deletions
...@@ -61,6 +61,7 @@ static struct argp imap_argp = { ...@@ -61,6 +61,7 @@ static struct argp imap_argp = {
61 61
62 62
63 static mu_imap_t imap; 63 static mu_imap_t imap;
64 static int uid_mode;
64 65
65 static enum mu_imap_session_state 66 static enum mu_imap_session_state
66 current_imap_state () 67 current_imap_state ()
...@@ -315,7 +316,20 @@ imap_fetch_callback (void *data, int code, size_t sdat, void *pdat) ...@@ -315,7 +316,20 @@ imap_fetch_callback (void *data, int code, size_t sdat, void *pdat)
315 mu_list_foreach (list, fetch_response_printer, str); 316 mu_list_foreach (list, fetch_response_printer, str);
316 mu_stream_printf (str, "\n\n"); 317 mu_stream_printf (str, "\n\n");
317 } 318 }
319
320 static int
321 com_uid (int argc, char **argv)
322 {
323 int bv;
318 324
325 if (argc == 1)
326 mu_printf ("%s\n", uid_mode ? _("UID is on") : _("UID is off"));
327 else if (get_bool (argv[1], &bv) == 0)
328 uid_mode = bv;
329 else
330 mu_error (_("invalid boolean value"));
331 return 0;
332 }
319 333
320 static int 334 static int
321 com_disconnect (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED) 335 com_disconnect (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
...@@ -346,10 +360,10 @@ com_connect (int argc, char **argv) ...@@ -346,10 +360,10 @@ com_connect (int argc, char **argv)
346 if (strcmp (argv[i], "-tls") == 0) 360 if (strcmp (argv[i], "-tls") == 0)
347 { 361 {
348 #ifdef WITH_TLS 362 #ifdef WITH_TLS
349 tls = 1; 363 tls = 1;
350 #else 364 #else
351 mu_error (_("TLS not supported")); 365 mu_error (_("TLS not supported"));
352 return 0; 366 return 0;
353 #endif 367 #endif
354 } 368 }
355 else 369 else
...@@ -753,7 +767,7 @@ com_fetch (int argc, char **argv) ...@@ -753,7 +767,7 @@ com_fetch (int argc, char **argv)
753 mu_imap_register_callback_function (imap, MU_IMAP_CB_FETCH, 767 mu_imap_register_callback_function (imap, MU_IMAP_CB_FETCH,
754 imap_fetch_callback, 768 imap_fetch_callback,
755 out); 769 out);
756 status = mu_imap_fetch (imap, 0, argv[1], argv[2]); 770 status = mu_imap_fetch (imap, uid_mode, argv[1], argv[2]);
757 mu_stream_destroy (&out); 771 mu_stream_destroy (&out);
758 mu_imap_register_callback_function (imap, MU_IMAP_CB_FETCH, 772 mu_imap_register_callback_function (imap, MU_IMAP_CB_FETCH,
759 imap_fetch_callback, 773 imap_fetch_callback,
...@@ -766,7 +780,7 @@ com_fetch (int argc, char **argv) ...@@ -766,7 +780,7 @@ com_fetch (int argc, char **argv)
766 static int 780 static int
767 com_store (int argc, char **argv) 781 com_store (int argc, char **argv)
768 { 782 {
769 int status = mu_imap_store (imap, 0, argv[1], argv[2]); 783 int status = mu_imap_store (imap, uid_mode, argv[1], argv[2]);
770 if (status) 784 if (status)
771 report_failure ("store", status); 785 report_failure ("store", status);
772 return 0; 786 return 0;
...@@ -1085,6 +1099,10 @@ struct mutool_command imap_comtab[] = { ...@@ -1085,6 +1099,10 @@ struct mutool_command imap_comtab[] = {
1085 com_unsubscribe, 1099 com_unsubscribe,
1086 N_("MBOX"), 1100 N_("MBOX"),
1087 N_("Remove mailbox from subscription list") }, 1101 N_("Remove mailbox from subscription list") },
1102 { "uid", 1, 2, 0,
1103 com_uid,
1104 N_("[on|off]"),
1105 N_("control UID mode") },
1088 { "quit", 1, 1, 0, 1106 { "quit", 1, 1, 0,
1089 com_logout, 1107 com_logout,
1090 NULL, 1108 NULL,
......