Changeset 9b70dd4


Ignore:
Timestamp:
Dec 13, 2008, 5:40:50 PM (12 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Children:
160d3f4
Parents:
5d2248c
git-author:
Anders Kaseorg <andersk@mit.edu> (12/06/08 23:37:40)
git-committer:
Nelson Elhage <nelhage@mit.edu> (12/13/08 17:40:50)
Message:
Rip out the openurl function.
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r2b237308 r9b70dd4  
    453453  OWLCMD_VOID("pop-message", owl_command_pop_message, OWL_CTX_RECWIN,
    454454              "pops up a message in a window", "", ""),
    455 
    456   OWLCMD_VOID("openurl", owl_command_openurl, OWL_CTX_INTERACTIVE,
    457               "opens up a URL from the current message",
    458               "",
    459               "Uses the 'webbrowser' variable to determine\n"
    460               "which browser to use.  Currently, 'netscape'\n"
    461               "and 'galeon' are supported.\n"),
    462455
    463456  OWLCMD_ARGS("zaway", owl_command_zaway, OWL_CTX_INTERACTIVE,
     
    22532246}
    22542247
    2255 void owl_command_openurl(void)
    2256 {
    2257   owl_function_openurl();
    2258 }
    2259 
    22602248char *owl_command_delete(int argc, char **argv, char *buff)
    22612249{
  • functions.c

    r5547211b r9b70dd4  
    10511051  owl_function_debugmsg("Quitting Owl");
    10521052  exit(0);
    1053 }
    1054 
    1055 void owl_function_openurl()
    1056 {
    1057   /* visit the first url in the current message */
    1058   owl_message *m;
    1059   owl_view *v;
    1060   char *ptr1, *ptr2, *text, url[LINE], tmpbuff[LINE];
    1061   int webbrowser;
    1062 
    1063   webbrowser = owl_global_get_webbrowser(&g);
    1064 
    1065   if (webbrowser < 0 || webbrowser == OWL_WEBBROWSER_NONE) {
    1066     owl_function_error("No browser selected");
    1067     return;
    1068   }
    1069 
    1070   v=owl_global_get_current_view(&g);
    1071  
    1072   m=owl_view_get_element(v, owl_global_get_curmsg(&g));
    1073 
    1074   if (!m || owl_view_get_size(v)==0) {
    1075     owl_function_error("No current message selected");
    1076     return;
    1077   }
    1078 
    1079   text=owl_message_get_text(m);
    1080 
    1081   /* First look for a good URL */ 
    1082   if ((ptr1=strstr(text, "http://"))!=NULL) {
    1083     ptr2=strpbrk(ptr1, " \n\t");
    1084     if (ptr2) {
    1085       strncpy(url, ptr1, ptr2-ptr1+1);
    1086       url[ptr2-ptr1+1]='\0';
    1087     } else {
    1088       strcpy(url, ptr1);
    1089     }
    1090 
    1091     /* if we had <http strip a trailing > */
    1092     if (ptr1>text && ptr1[-1]=='<') {
    1093       if (url[strlen(url)-1]=='>') {
    1094         url[strlen(url)-1]='\0';
    1095       }
    1096     }
    1097   } else if ((ptr1=strstr(text, "https://"))!=NULL) {
    1098     /* Look for an https URL */ 
    1099     ptr2=strpbrk(ptr1, " \n\t");
    1100     if (ptr2) {
    1101       strncpy(url, ptr1, ptr2-ptr1+1);
    1102       url[ptr2-ptr1+1]='\0';
    1103     } else {
    1104       strcpy(url, ptr1);
    1105     }
    1106    
    1107     /* if we had <http strip a trailing > */
    1108     if (ptr1>text && ptr1[-1]=='<') {
    1109       if (url[strlen(url)-1]=='>') {
    1110         url[strlen(url)-1]='\0';
    1111       }
    1112     }
    1113   } else if ((ptr1=strstr(text, "www."))!=NULL) {
    1114     /* if we can't find a real url look for www.something */
    1115     ptr2=strpbrk(ptr1, " \n\t");
    1116     if (ptr2) {
    1117       strncpy(url, ptr1, ptr2-ptr1+1);
    1118       url[ptr2-ptr1+1]='\0';
    1119     } else {
    1120       strcpy(url, ptr1);
    1121     }
    1122   } else {
    1123     owl_function_beep();
    1124     owl_function_error("Could not find URL to open.");
    1125     return;
    1126   }
    1127 
    1128   /* Make sure there aren't any quotes or \'s in the url */
    1129   for (ptr1 = url; *ptr1; ptr1++) {
    1130     if (*ptr1 == '"' || *ptr1 == '\\') {
    1131       owl_function_beep();
    1132       owl_function_error("URL contains invalid characters.");
    1133       return;
    1134     }
    1135   }
    1136  
    1137   /* NOTE: There are potentially serious security issues here... */
    1138 
    1139   /* open the page */
    1140   owl_function_makemsg("Opening %s", url);
    1141   if (webbrowser == OWL_WEBBROWSER_NETSCAPE) {
    1142     snprintf(tmpbuff, LINE, "netscape -remote \"openURL(%s)\" > /dev/null 2> /dev/null", url);
    1143     system(tmpbuff);
    1144   } else if (webbrowser == OWL_WEBBROWSER_GALEON) {
    1145     snprintf(tmpbuff, LINE, "galeon \"%s\" > /dev/null 2> /dev/null &", url);
    1146     system(tmpbuff);
    1147   } else if (webbrowser == OWL_WEBBROWSER_OPERA) {
    1148     snprintf(tmpbuff, LINE, "opera \"%s\" > /dev/null 2> /dev/null &", url);
    1149     system(tmpbuff);
    1150   }
    11511053}
    11521054
  • keys.c

    rdb0ac7e r9b70dd4  
    282282  BIND_CMD("M-r", "reply -e",         "reply to the current message, but allow editing of recipient");
    283283  BIND_CMD("M-R", "reply -e sender",  "reply to sender of the current message, but allow editing of recipient");
    284                  
    285   BIND_CMD("w",   "openurl",          "open a URL using a webbrowser");
    286284
    287285  BIND_CMD("W",   "start-command webzephyr ", "start a webzephyr command");
Note: See TracChangeset for help on using the changeset viewer.