add --send cli option
authorPaul Mangan <paul@claws-mail.org>
Fri, 1 Feb 2002 08:45:07 +0000 (08:45 +0000)
committerPaul Mangan <paul@claws-mail.org>
Fri, 1 Feb 2002 08:45:07 +0000 (08:45 +0000)
ChangeLog.claws
configure.in
src/main.c

index ffc6d20..fa827db 100644 (file)
@@ -1,3 +1,9 @@
+2002-02-01 [paul]      0.7.0claws43
+
+       * src/main.c
+               add --send option to command line interface, sends all
+               queued mail. Patch submitted by Ricardo Mones Lastra.
+
 2002-01-31 [paul]      0.7.0claws42
 
        * src/mainwindow.c
index 2748c6e..ef33588 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=7
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws42
+EXTRA_VERSION=claws43
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index fc45841..04a8dde 100644 (file)
@@ -94,6 +94,7 @@ static struct Cmd {
        gboolean compose;
        const gchar *compose_mailto;
        gboolean status;
+       gboolean send;
 } cmd;
 
 static void parse_cmd_opt(int argc, char *argv[]);
@@ -309,6 +310,11 @@ int main(int argc, char *argv[])
        if (cmd.compose)
                open_compose_new_with_recipient(cmd.compose_mailto);
 
+       if (cmd.send) {
+               if (procmsg_send_queue() < 0)
+                       alertpanel_error(_("Some errors occurred while sending queued messages."));
+       }
+       
        /* ignore SIGPIPE signal for preventing sudden death of program */
        signal(SIGPIPE, SIG_IGN);
 
@@ -349,6 +355,8 @@ static void parse_cmd_opt(int argc, char *argv[])
                        exit(0);
                } else if (!strncmp(argv[i], "--status", 8)) {
                        cmd.status = TRUE;
+               } else if (!strncmp(argv[i], "--send", 6)) {
+                       cmd.send = TRUE;
                } else if (!strncmp(argv[i], "--help", 6)) {
                        g_print(_("Usage: %s [OPTION]...\n"),
                                g_basename(argv[0]));
@@ -356,6 +364,7 @@ static void parse_cmd_opt(int argc, char *argv[])
                        puts(_("  --compose [address]    open composition window"));
                        puts(_("  --receive              receive new messages"));
                        puts(_("  --receive-all          receive new messages of all accounts"));
+                       puts(_("  --send                 send all queued messages"));
                        puts(_("  --status               show the total number of messages"));
                        puts(_("  --debug                debug mode"));
                        puts(_("  --help                 display this help and exit"));
@@ -477,6 +486,13 @@ static gint prohibit_duplicate_launch(void)
                fd_write(uxsock, "receive_all\n", 12);
        else if (cmd.receive)
                fd_write(uxsock, "receive\n", 8);
+       else if (cmd.send) {
+               gchar buf[BUFFSIZE];
+
+               fd_write(uxsock, "send\n", 5);
+               fd_gets(uxsock, buf, sizeof(buf));
+               fputs(buf, stdout);
+       }
        else if (cmd.compose) {
                gchar *compose_str;
 
@@ -519,6 +535,21 @@ static void lock_socket_input_cb(gpointer data,
        } else if (!strncmp(buf, "receive", 7)){
                main_window_popup(mainwin);
                inc_mail(mainwin);
+       } else if (!strncmp(buf, "send", 4)) {
+               gint queued = get_queued_message_num();
+
+               if (queued > 0) {
+                       if (procmsg_send_queue() < 0)
+                               g_snprintf(buf, sizeof(buf),
+                                       "%s\n", /* avoids adding another translatable */
+                                       _("Some errors occurred while sending queued messages."));
+                       else    /* queue sent ok */
+                               g_snprintf(buf, sizeof(buf), _("\%d queued message(s) sent\n"), queued);
+               } 
+               else {
+                       g_snprintf(buf, sizeof(buf), "%s\n", _("No queued messages found."));
+               }
+               fd_write(sock, buf, strlen(buf));
        } else if (!strncmp(buf, "compose", 7)) {
                open_compose_new_with_recipient(buf + strlen("compose") + 1);
        } else if (!strncmp(buf, "status", 6)) {