* Added the ability to handle embedded URL's from the text client
authorArt Cancro <ajc@citadel.org>
Wed, 1 Sep 1999 01:51:49 +0000 (01:51 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 1 Sep 1999 01:51:49 +0000 (01:51 +0000)
citadel/ChangeLog
citadel/citadel.rc
citadel/commands.c
citadel/commands.h
citadel/messages.c
citadel/messages.h

index 4f8cda8c05aa8bb993f6d682d015d494a974a098..276605069bb25df13898507febc86c0a8c8ddcb9 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 1.357  1999/09/01 01:51:48  ajc
+* Added the ability to handle embedded URL's from the text client
+
 Revision 1.356  1999/09/01 01:02:47  ajc
 * Implemented "maximum message length" in global system config
 
@@ -1214,3 +1217,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
+
index 2b8867ba54a7221f10d22dd2d21b92421eef0baa..0c94c8d2f4c8aaf6e5a44c1122fe0630cc519540 100644 (file)
@@ -78,6 +78,13 @@ allow_attachments=0
 #
 #password=mypassword
 
+# If URLCMD is defined, users can hit 'U' after reading a message which
+# contains embedded URL's, and the command will be executed.  Usually this
+# will be used to remote-control a web browser.  (Do not enable this command
+# for 'safe' public clients.)
+#
+#urlcmd=netscape -remote "openURL(%s)"
+
 
 # COMMAND SET CONFIGURATION
 #
index 8e437bd9bb4958c7bdc6a51e90d73b1c8c8bda80..2b91bca8bec4647430713bdd64ef54c9fb1bd5e4 100644 (file)
@@ -39,6 +39,7 @@
 #include "citadel_decls.h"
 #include "routines.h"
 #include "routines2.h"
+#include "tools.h"
 #ifndef HAVE_SNPRINTF
 #include "snprintf.h"
 #endif
@@ -59,6 +60,9 @@ int rc_allow_attachments;
 int rc_display_message_numbers;
 int rc_force_mail_prompts;
 int rc_ansi_color;
+int num_urls = 0;
+char urls[MAXURLS][256];
+char rc_url_cmd[256];
 
 char *gl_string;
 int next_lazy_cmd = 5;
@@ -412,6 +416,7 @@ void load_command_set(void)
        rc_display_message_numbers = 0;
        rc_force_mail_prompts = 0;
        rc_ansi_color = 0;
+       strcpy(rc_url_cmd, "");
 
        /* now try to open the citadel.rc file */
 
@@ -471,11 +476,11 @@ void load_command_set(void)
                        rc_force_mail_prompts = atoi(&buf[19]);
                }
                if (!struncmp(buf, "ansi_color=", 11)) {
-                       if (!strncasecmp(&buf[11], "on", 2))
+                       if (!struncmp(&buf[11], "on", 2))
                                rc_ansi_color = 1;
-                       if (!strncasecmp(&buf[11], "auto", 4))
+                       if (!struncmp(&buf[11], "auto", 4))
                                rc_ansi_color = 2;      /* autodetect */
-                       if (!strncasecmp(&buf[11], "user", 4))
+                       if (!struncmp(&buf[11], "user", 4))
                                rc_ansi_color = 3;      /* user config */
                }
                if (!struncmp(buf, "username=", 9))
@@ -484,6 +489,9 @@ void load_command_set(void)
                if (!struncmp(buf, "password=", 9))
                        strcpy(rc_password, &buf[9]);
 
+               if (!struncmp(buf, "urlcmd=", 7))
+                       strcpy(rc_url_cmd, &buf[7]);
+
                if (!struncmp(buf, "cmd=", 4)) {
                        strcpy(buf, &buf[4]);
 
@@ -882,6 +890,8 @@ int fmout(int width, FILE * fp, char pagin, int height, int starting_lp, char su
        char buffer[512];
        int eof_flag = 0;
 
+       num_urls = 0;   /* Start with a clean slate of embedded URL's */
+
        if (starting_lp >= 0) {
                lines_printed = starting_lp;
        }
@@ -893,7 +903,8 @@ int fmout(int width, FILE * fp, char pagin, int height, int starting_lp, char su
        sigcaught = 0;
        sttybbs(1);
 
-      FMTA:while ((eof_flag == 0) && (strlen(buffer) < 126)) {
+FMTA:  while ((eof_flag == 0) && (strlen(buffer) < 126)) {
+       
                if (sigcaught)
                        goto OOPS;
                if (fp != NULL) {       /* read from file */
@@ -921,6 +932,18 @@ int fmout(int width, FILE * fp, char pagin, int height, int starting_lp, char su
                }
        }
 
+       if ( (!struncmp(buffer, "http://", 7))
+          || (!struncmp(buffer, "ftp://", 6)) ) {
+               safestrncpy(urls[num_urls], buffer, 255);
+               for (a=0; a<strlen(urls[num_urls]); ++a) {
+                       b = urls[num_urls][a];
+                       if ( (b==' ') || (b==')') || (b=='>') || (b==10)
+                          || (b==13) || (b==9) )
+                               urls[num_urls][a] = 0;
+               }
+               ++num_urls;
+       }
+
        buffer[strlen(buffer) + 1] = 0;
        a = buffer[0];
        strcpy(buffer, &buffer[1]);
index 60e1403f57badb772c7c28df6acf2eaab2648d44..cef70d16dc968e25c2b5af66cf0cc3f8d4d7c6aa 100644 (file)
@@ -22,6 +22,8 @@
 #define COLOR_PUSH     16      /* Save current color */
 #define COLOR_POP      17      /* Restore saved color */
 
+#define MAXURLS                50      /* Max embedded URL's per message */
+
 /*
  * declarations
  */
@@ -45,3 +47,7 @@ extern int enable_color;
 int yesno(void);
 int yesno_d(int d);
 void keyopt(char *);
+
+extern int num_urls;
+extern char urls[MAXURLS][256];
+extern char rc_url_cmd[256];
index 0b2204e66dbd5db2f60d048d78640e946256f23a..ba2cf2a83cc4d16f001be612fc1ef8023a9dc3a3 100644 (file)
@@ -904,6 +904,31 @@ int line,qstart,qend;
        }
 
 
+
+/*
+ * List the URL's which were embedded in the previous message
+ */
+void list_urls() {
+       int i;
+       char cmd[256];
+
+       if (num_urls == 0) {
+               printf("There were no URL's in the previous message.\n\n");
+               return;
+       }
+
+       for (i=0; i<num_urls; ++i) {
+               printf("%3d %s\n", i+1, urls[i]);
+       }
+
+       i = intprompt("Display which one", 1, 1, num_urls);
+
+       sprintf(cmd, rc_url_cmd, urls[i-1]);
+       system(cmd);
+       printf("\n");
+}
+
+
 void readmsgs(int c, int rdir, int q)  /* read contents of a room */
                /* 0=Read all  1=Read new  2=Read old 3=Read last q */
                /* 1=Forward (-1)=Reverse */
@@ -1041,10 +1066,12 @@ RMSGREAD:       fflush(stdout);
 /* print only if available */  if ((e=='p')&&(strlen(printcmd)==0)) e=0;
 /* can't reply in public rms */        if ((e=='r')&&(is_mail!=1)) e=0;
 /* can't file if not allowed */        if ((e=='f')&&(rc_allow_attachments==0)) e=0;
+/* link only if browser avail*/        if ((e=='u')&&(strlen(rc_url_cmd)==0)) e=0;
                                } while((e!='a')&&(e!='n')&&(e!='s')
                                        &&(e!='d')&&(e!='m')&&(e!='p')
                                        &&(e!='q')&&(e!='b')&&(e!='h')
-                                       &&(e!='r')&&(e!='f')&&(e!='?'));
+                                       &&(e!='r')&&(e!='f')&&(e!='?')
+                                       &&(e!='u'));
                        switch(e) {
                                case 's':       printf("Stop\r");       break;
                                case 'a':       printf("Again\r");      break;
@@ -1057,6 +1084,7 @@ RMSGREAD: fflush(stdout);
                                case 'h':       printf("Header\r");     break;
                                case 'r':       printf("Reply\r");      break;
                                case 'f':       printf("File\r");       break;
+                               case 'u':       printf("URL's\r");      break;
                                case '?':       printf("? <help>\r");   break;
                                }
                        if (userflags & US_DISAPPEAR)
@@ -1085,6 +1113,8 @@ RMSGREAD: fflush(stdout);
                                        printf(" R  Reply to this message\n");
                                if (rc_allow_attachments)
                                        printf(" F  (save attachments to a file)\n");
+                               if (strlen(rc_url_cmd)>0)
+                                       printf(" U  (list URL's for display)\n");
                                printf("\n");
                                goto RMSGREAD;
                   case 'p':    fflush(stdout);
@@ -1149,6 +1179,8 @@ RMSGREAD: fflush(stdout);
                                goto RMSGREAD;
                   case 'r':    entmsg(1,(DEFAULT_ENTRY==46 ? 2 : 0));
                                goto RMSGREAD;
+                  case 'u':    list_urls();
+                               goto RMSGREAD;
                        }
                } /* end for loop */
        } /* end read routine */
index 2d3bf21b9b734a38243fd79e0f66a020343dd1a9..73523f76ef6764f55e3fad89ecdd6370a0dd7565 100644 (file)
@@ -5,3 +5,4 @@ void readmsgs(int c, int rdir, int q);
 void edit_system_message(char *which_message);
 extern int lines_printed;
 pid_t ka_wait(int *kstatus);
+void list_urls(void);