Changeset 93ee554 for functions.c


Ignore:
Timestamp:
Dec 23, 2007, 7:52:17 PM (13 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
5bc0f68
Parents:
34509d5 (diff), 78667f3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merged revisions 734-776 via svnmerge from 
file:///afs/sipb.mit.edu/project/barnowl/src/svn/trunk

........
  r738 | nelhage | 2007-07-07 17:42:45 -0400 (Sat, 07 Jul 2007) | 3 lines
  
  Make the built-in regression tests output TAP and add a perl wrapper
  to call it.
........
  r739 | nelhage | 2007-07-07 17:43:22 -0400 (Sat, 07 Jul 2007) | 2 lines
  
  Forgot these in the last commit; Make all the tests output TAP
........
  r740 | nelhage | 2007-07-07 19:46:16 -0400 (Sat, 07 Jul 2007) | 2 lines
  
  Clean up an unused var warning.
........
  r741 | nelhage | 2007-07-08 15:37:43 -0400 (Sun, 08 Jul 2007) | 2 lines
  
  Adding a -s switch to change the location of the config dir (~/.owl)
........
  r742 | nelhage | 2007-07-08 15:39:57 -0400 (Sun, 08 Jul 2007) | 2 lines
  
  I don't understand why this didn't commit last time. I blame psvn.
........
  r743 | nelhage | 2007-07-11 22:37:16 -0400 (Wed, 11 Jul 2007) | 3 lines
  
  Don't allow you to go off the end of an empty message list. [fixes:
  #9]
........
  r744 | nelhage | 2007-07-30 18:47:39 -0400 (Mon, 30 Jul 2007) | 2 lines
  
  Fix sending to -c message -i personal
........
  r745 | chmrr | 2007-07-30 20:21:18 -0400 (Mon, 30 Jul 2007) | 3 lines
  
   r20981@zoq-fot-pik:  chmrr | 2007-07-30 20:20:44 -0400
    * message length 0 means no fields
........
  r746 | nelhage | 2007-07-30 20:25:59 -0400 (Mon, 30 Jul 2007) | 4 lines
  
  * zero-len message means no fields
  * Actually use owl_zephyr_get_zsig to get the zsig, which handles 0-
    and 1- field zephyrs correctly.
........
  r747 | nelhage | 2007-07-30 20:29:36 -0400 (Mon, 30 Jul 2007) | 2 lines
  
  Making that last patch actually compile. Bad me.
........
  r748 | nelhage | 2007-08-01 01:42:53 -0400 (Wed, 01 Aug 2007) | 3 lines
  
  owl_message_get_text needs to make sure there's text to return before
  returning it. fixes: #15
........
  r749 | nelhage | 2007-08-01 01:52:08 -0400 (Wed, 01 Aug 2007) | 5 lines
  
  zephyr smartnarrow now uses the ``personal'' filter to decide whether
  to narrow to user or not, and the zephyr-user filter now checks for
  `filter personal' instead of <message,personal,*>.
  closes #2
........
  r750 | nelhage | 2007-08-01 02:27:30 -0400 (Wed, 01 Aug 2007) | 5 lines
  
  Changing the default personal filter to <message,personal,*> for
  zephyr.
  
  refs 2
........
  r751 | nelhage | 2007-08-01 22:58:31 -0400 (Wed, 01 Aug 2007) | 2 lines
  
  Display opcodes with the default style
........
  r752 | nelhage | 2007-08-08 18:01:51 -0400 (Wed, 08 Aug 2007) | 2 lines
  
  Applying ctl's variable shuffling patch for better ANSI C-ness. closes #18
........
  r753 | nelhage | 2007-08-11 01:04:07 -0400 (Sat, 11 Aug 2007) | 3 lines
  
  Implement :punt and :unpunt to punt arbitrary filters, rather than
  just z-triplets. closes #6
........
  r754 | nelhage | 2007-08-11 01:18:37 -0400 (Sat, 11 Aug 2007) | 2 lines
  
  Show non-personal pings like stock owl does. closes #12
........
  r756 | asedeno | 2007-08-17 12:48:37 -0400 (Fri, 17 Aug 2007) | 8 lines
  
  Apply patch from:
  http://rt.cpan.org/Public/Bug/Display.html?id=17484
  
  Fixing problems with jabber servers keeping the same stream id when negotiating TLS.
  
  Thanks to ghudson for tracking this down.
........
  r757 | nelhage | 2007-08-17 17:26:44 -0400 (Fri, 17 Aug 2007) | 4 lines
  
  When we're narrowing to an instance, properly include
  un-instances. This fixes narrowing to any instance that starts with
  ``un-''
........
  r758 | nelhage | 2007-08-27 19:17:20 -0400 (Mon, 27 Aug 2007) | 2 lines
  
  Don't read before the start of the string for an instance
........
  r759 | nelhage | 2007-09-07 00:13:45 -0400 (Fri, 07 Sep 2007) | 3 lines
  
  Adding an explicit -f - to the tar commands for FreeBSD compatibility
  (reported by ecprice)
........
  r760 | ecprice | 2007-09-08 17:33:34 -0400 (Sat, 08 Sep 2007) | 3 lines
  
  Fixes for FreeBSD.
........
  r761 | nelhage | 2007-09-10 20:00:45 -0400 (Mon, 10 Sep 2007) | 3 lines
  
  Use "" instead of `undef' as a default for messages with no reply
  command to hopefully squelch perl warnings.
........
  r762 | nelhage | 2007-09-12 21:37:41 -0400 (Wed, 12 Sep 2007) | 2 lines
  
  Do ~-expansion in :loadsubs. closes #26
........
  r763 | nelhage | 2007-09-12 21:54:51 -0400 (Wed, 12 Sep 2007) | 2 lines
  
  Validate JIDs passed to jmuc join. closes #25
........
  r764 | nelhage | 2007-09-12 22:46:17 -0400 (Wed, 12 Sep 2007) | 2 lines
  
  Show full JIDs for users in non-anonymous JIDs in :jmuc presence. closes #24
........
  r766 | nelhage | 2007-10-02 00:38:49 -0400 (Tue, 02 Oct 2007) | 3 lines
  
  Don't crash if we hit `i' on iso-8859-*. This is not the right
  solution, but at least it doesn't SEGV.
........
  r767 | asedeno | 2007-10-10 15:21:13 -0400 (Wed, 10 Oct 2007) | 1 line
  
  Fixing a typo pointed out by kchen.
........
  r768 | matt | 2007-10-14 17:16:35 -0400 (Sun, 14 Oct 2007) | 1 line
  
  added -m flag to aimwrite
........
  r769 | austein | 2007-10-14 18:16:44 -0400 (Sun, 14 Oct 2007) | 1 line
  
  aimwrite -m displays according to displayoutgoing
........
  r770 | asedeno | 2007-12-06 14:38:05 -0500 (Thu, 06 Dec 2007) | 3 lines
  
  Making usleep call more reasonable.
  Responsiveness seems okay on linerva, no-knife, and darkmatter, and reported good
  on zephyr.
........
  r771 | nelhage | 2007-12-10 21:34:46 -0500 (Mon, 10 Dec 2007) | 2 lines
  
  Add zip as build-depends
........
  r772 | nelhage | 2007-12-10 21:36:25 -0500 (Mon, 10 Dec 2007) | 2 lines
  
  We're not ktools
........
  r773 | nelhage | 2007-12-23 11:32:02 -0500 (Sun, 23 Dec 2007) | 2 lines
  
  bind END in popless windows. closes #41
........
  r774 | chmrr | 2007-12-23 15:16:26 -0500 (Sun, 23 Dec 2007) | 3 lines
  
   r1805@utwig:  chmrr | 2007-12-23 15:15:33 -0500
    * Allow C-r on outgoing messages (useful for CCs)
........
  r775 | chmrr | 2007-12-23 15:16:29 -0500 (Sun, 23 Dec 2007) | 3 lines
  
   r1806@utwig:  chmrr | 2007-12-23 15:15:50 -0500
    * Identify ourselves as barnowl in a couple more places
........
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r34509d5 r93ee554  
    580580
    581581  if (i>owl_view_get_size(v)-1) i=owl_view_get_size(v)-1;
     582  if (i<0) i=0;
    582583
    583584  if (!found) {
     
    848849{
    849850  int ret, ret2;
    850   char *foo;
     851  char *foo, *path;
    851852
    852853  if (file==NULL) {
    853854    ret=owl_zephyr_loadsubs(NULL, 0);
    854855  } else {
    855     ret=owl_zephyr_loadsubs(file, 1);
     856    path = owl_util_makepath(file);
     857    ret=owl_zephyr_loadsubs(path, 1);
     858    free(path);
    856859  }
    857860
     
    20572060      /* if it's a zephyr we sent, send it out the same way again */
    20582061      if (owl_message_is_direction_out(m)) {
    2059         owl_function_zwrite_setup(owl_message_get_zwriteline(m));
    2060         owl_global_set_buffercommand(&g, owl_message_get_zwriteline(m));
    2061         return;
     2062          buff = owl_strdup(owl_message_get_zwriteline(m));
     2063      } else {
     2064
     2065        /* Special case a personal reply to a webzephyr user on a class */
     2066        if ((type==1) && !strcasecmp(owl_message_get_opcode(m), OWL_WEBZEPHYR_OPCODE)) {
     2067          class=OWL_WEBZEPHYR_CLASS;
     2068          inst=owl_message_get_sender(m);
     2069          to=OWL_WEBZEPHYR_PRINCIPAL;
     2070        } else if (!strcasecmp(owl_message_get_class(m), OWL_WEBZEPHYR_CLASS) && owl_message_is_loginout(m)) {
     2071          /* Special case LOGIN/LOGOUT notifications on class "webzephyr" */
     2072          class=OWL_WEBZEPHYR_CLASS;
     2073          inst=owl_message_get_instance(m);
     2074          to=OWL_WEBZEPHYR_PRINCIPAL;
     2075        } else if (owl_message_is_loginout(m)) {
     2076          /* Normal LOGIN/LOGOUT messages */
     2077          class="MESSAGE";
     2078          inst="PERSONAL";
     2079          to=owl_message_get_sender(m);
     2080        } else if (type==1) {
     2081          /* Personal reply */
     2082          class="MESSAGE";
     2083          inst="PERSONAL";
     2084          to=owl_message_get_sender(m);
     2085        } else {
     2086          /* General reply */
     2087          class=owl_message_get_class(m);
     2088          inst=owl_message_get_instance(m);
     2089          to=owl_message_get_recipient(m);
     2090          cc=owl_message_get_cc_without_recipient(m);
     2091          if (!strcmp(to, "") || !strcmp(to, "*")) {
     2092            to="";
     2093          } else if (to[0]=='@') {
     2094            /* leave it, to get the realm */
     2095          } else {
     2096            to=owl_message_get_sender(m);
     2097          }
     2098        }
     2099
     2100        /* create the command line */
     2101        if (!strcasecmp(owl_message_get_opcode(m), "CRYPT")) {
     2102          buff=owl_strdup("zcrypt");
     2103        } else {
     2104          buff = owl_strdup("zwrite");
     2105        }
     2106        if (strcasecmp(class, "message")) {
     2107          buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class));
     2108          owl_free(oldbuff);
     2109        }
     2110        if (strcasecmp(inst, "personal")) {
     2111          buff = owl_sprintf("%s -i %s%s%s", oldbuff=buff, owl_getquoting(inst), inst, owl_getquoting(inst));
     2112          owl_free(oldbuff);
     2113        }
     2114        if (*to != '\0') {
     2115          char *tmp, *oldtmp, *tmp2;
     2116          tmp=short_zuser(to);
     2117          if (cc) {
     2118            tmp = owl_util_uniq(oldtmp=tmp, cc, "-");
     2119            owl_free(oldtmp);
     2120            buff = owl_sprintf("%s -C %s", oldbuff=buff, tmp);
     2121            owl_free(oldbuff);
     2122          } else {
     2123            if (owl_global_is_smartstrip(&g)) {
     2124              tmp2=tmp;
     2125              tmp=owl_zephyr_smartstripped_user(tmp2);
     2126              owl_free(tmp2);
     2127            }
     2128            buff = owl_sprintf("%s %s", oldbuff=buff, tmp);
     2129            owl_free(oldbuff);
     2130          }
     2131          owl_free(tmp);
     2132        }
     2133        if (cc) owl_free(cc);
    20622134      }
    2063 
    2064       /* Special case a personal reply to a webzephyr user on a class */
    2065       if ((type==1) && !strcasecmp(owl_message_get_opcode(m), OWL_WEBZEPHYR_OPCODE)) {
    2066         class=OWL_WEBZEPHYR_CLASS;
    2067         inst=owl_message_get_sender(m);
    2068         to=OWL_WEBZEPHYR_PRINCIPAL;
    2069       } else if (!strcasecmp(owl_message_get_class(m), OWL_WEBZEPHYR_CLASS) && owl_message_is_loginout(m)) {
    2070         /* Special case LOGIN/LOGOUT notifications on class "webzephyr" */
    2071         class=OWL_WEBZEPHYR_CLASS;
    2072         inst=owl_message_get_instance(m);
    2073         to=OWL_WEBZEPHYR_PRINCIPAL;
    2074       } else if (owl_message_is_loginout(m)) {
    2075         /* Normal LOGIN/LOGOUT messages */
    2076         class="MESSAGE";
    2077         inst="PERSONAL";
    2078         to=owl_message_get_sender(m);
    2079       } else if (type==1) {
    2080         /* Personal reply */
    2081         class="MESSAGE";
    2082         inst="PERSONAL";
    2083         to=owl_message_get_sender(m);
    2084       } else {
    2085         /* General reply */
    2086         class=owl_message_get_class(m);
    2087         inst=owl_message_get_instance(m);
    2088         to=owl_message_get_recipient(m);
    2089         cc=owl_message_get_cc_without_recipient(m);
    2090         if (!strcmp(to, "") || !strcmp(to, "*")) {
    2091           to="";
    2092         } else if (to[0]=='@') {
    2093           /* leave it, to get the realm */
    2094         } else {
    2095           to=owl_message_get_sender(m);
    2096         }
    2097       }
    2098        
    2099       /* create the command line */
    2100       if (!strcasecmp(owl_message_get_opcode(m), "CRYPT")) {
    2101         buff=owl_strdup("zcrypt");
    2102       } else {
    2103         buff = owl_strdup("zwrite");
    2104       }
    2105       if (strcasecmp(class, "message")) {
    2106         buff = owl_sprintf("%s -c %s%s%s", oldbuff=buff, owl_getquoting(class), class, owl_getquoting(class));
    2107         owl_free(oldbuff);
    2108       }
    2109       if (strcasecmp(inst, "personal")) {
    2110         buff = owl_sprintf("%s -i %s%s%s", oldbuff=buff, owl_getquoting(inst), inst, owl_getquoting(inst));
    2111         owl_free(oldbuff);
    2112       }
    2113       if (*to != '\0') {
    2114         char *tmp, *oldtmp, *tmp2;
    2115         tmp=short_zuser(to);
    2116         if (cc) {
    2117           tmp = owl_util_uniq(oldtmp=tmp, cc, "-");
    2118           owl_free(oldtmp);
    2119           buff = owl_sprintf("%s -C %s", oldbuff=buff, tmp);
    2120           owl_free(oldbuff);
    2121         } else {
    2122           if (owl_global_is_smartstrip(&g)) {
    2123             tmp2=tmp;
    2124             tmp=owl_zephyr_smartstripped_user(tmp2);
    2125             owl_free(tmp2);
    2126           }
    2127           buff = owl_sprintf("%s %s", oldbuff=buff, tmp);
    2128           owl_free(oldbuff);
    2129         }
    2130         owl_free(tmp);
    2131       }
    2132       if (cc) owl_free(cc);
    21332135    } else if (owl_message_is_type_aim(m)) {
    21342136      /* aim */
     
    25572559  for (i=0; i<j; i++) {
    25582560    f=owl_list_get_element(fl, i);
     2561    snprintf(buff, sizeof(buff), "[% 2d] ", i+1);
     2562    owl_fmtext_append_normal(&fm, buff);
    25592563    owl_filter_print(f, buff);
    25602564    owl_fmtext_append_normal(&fm, buff);
     
    26222626  sprintf(argbuff, "class ^(un)*%s(\\.d)*$", tmpclass);
    26232627  if (tmpinstance) {
    2624     sprintf(argbuff, "%s and ( instance ^%s(\\.d)*$ )", argbuff, tmpinstance);
     2628    sprintf(argbuff, "%s and ( instance ^(un)*%s(\\.d)*$ )", argbuff, tmpinstance);
    26252629  }
    26262630  owl_free(tmpclass);
     
    26702674
    26712675  argbuff=owl_malloc(strlen(longuser)+1000);
    2672   sprintf(argbuff, "( type ^zephyr$ and ( class ^message$ and instance ^personal$ and ");
     2676  sprintf(argbuff, "( type ^zephyr$ and filter personal and ");
    26732677  sprintf(argbuff, "%s ( ( direction ^in$ and sender ^%s$ ) or ( direction ^out$ and recipient ^%s$ ) ) )", argbuff, longuser, longuser);
    2674   sprintf(argbuff, "%s or ( ( class ^login$ ) and ( sender ^%s$ ) ) )", argbuff, longuser);
     2678  sprintf(argbuff, "%s or ( ( class ^login$ ) and ( sender ^%s$ ) )", argbuff, longuser);
    26752679
    26762680  owl_filter_init_fromstring(f, filtname, argbuff);
     
    28002804  owl_message *m;
    28012805  char *zperson, *filtname=NULL;
     2806  char *argv[1];
    28022807 
    28032808  v=owl_global_get_current_view(&g);
     
    28312836  /* narrow personal and login messages to the sender or recip as appropriate */
    28322837  if (owl_message_is_type_zephyr(m)) {
    2833     if (owl_message_is_private(m) || owl_message_is_loginout(m)) {
     2838    if (owl_message_is_personal(m) || owl_message_is_loginout(m)) {
    28342839      if (owl_message_is_direction_in(m)) {
    28352840        zperson=short_zuser(owl_message_get_sender(m));
     
    28582863
    28592864  /* pass it off to perl */
    2860   char *argv[1];
    28612865  if(type) {
    28622866    argv[0] = "-i";
     
    30163020void owl_function_zpunt(char *class, char *inst, char *recip, int direction)
    30173021{
    3018   owl_filter *f;
    3019   owl_list *fl;
    30203022  char *buff;
    30213023  char *quoted;
    3022   int ret, i, j;
    3023 
    3024   fl=owl_global_get_puntlist(&g);
    3025 
    3026   /* first, create the filter */
    3027   f=owl_malloc(sizeof(owl_filter));
     3024
    30283025  buff=owl_malloc(strlen(class)+strlen(inst)+strlen(recip)+100);
    30293026  strcpy(buff, "class");
     
    30563053    owl_free(quoted);
    30573054  }
    3058  
    3059   owl_function_debugmsg("About to filter %s", buff);
    3060   ret=owl_filter_init_fromstring(f, "punt-filter", buff);
     3055
     3056  owl_function_punt(buff, direction);
    30613057  owl_free(buff);
     3058}
     3059
     3060void owl_function_punt(char *filter, int direction)
     3061{
     3062  owl_filter *f;
     3063  owl_list *fl;
     3064  int ret, i, j;
     3065  fl=owl_global_get_puntlist(&g);
     3066
     3067  /* first, create the filter */
     3068  f=malloc(sizeof(owl_filter));
     3069
     3070  owl_function_debugmsg("About to filter %s", filter);
     3071  ret=owl_filter_init_fromstring(f, "punt-filter", filter);
    30623072  if (ret) {
    30633073    owl_function_error("Error creating filter for zpunt");
     
    30703080  for (i=0; i<j; i++) {
    30713081    if (owl_filter_equiv(f, owl_list_get_element(fl, i))) {
     3082      owl_function_debugmsg("found an equivalent punt filter");
    30723083      /* if we're punting, then just silently bow out on this duplicate */
    30733084      if (direction==0) {
     
    30803091        owl_filter_free(owl_list_get_element(fl, i));
    30813092        owl_list_remove_element(fl, i);
     3093        owl_filter_free(f);
    30823094        return;
    30833095      }
     
    30853097  }
    30863098
     3099  owl_function_debugmsg("punting");
    30873100  /* If we're punting, add the filter to the global punt list */
    30883101  if (direction==0) {
     
    34613474  char *filename;
    34623475
    3463   filename=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE);
     3476  filename=owl_global_get_startupfile(&g);
    34643477  file=fopen(filename, "a");
    34653478  if (!file) {
    34663479    owl_function_error("Error opening startupfile for new command");
    3467     owl_free(filename);
    34683480    return;
    34693481  }
     
    34713483  /* delete earlier copies */
    34723484  owl_util_file_deleteline(filename, buff, 1);
    3473   owl_free(filename);
    34743485
    34753486  /* add this line */
     
    34833494{
    34843495  char *filename;
    3485   filename=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE);
     3496  filename=owl_global_get_startupfile(&g);
    34863497  owl_util_file_deleteline(filename, buff, 1);
    3487   owl_free(filename);
    34883498}
    34893499
     
    34973507
    34983508  if (!filename) {
    3499     filename=owl_sprintf("%s/%s", owl_global_get_homedir(&g), OWL_STARTUP_FILE);
     3509    filename=owl_global_get_startupfile(&g);
    35003510    file=fopen(filename, "r");
    3501     owl_free(filename);
    35023511  } else {
    35033512    file=fopen(filename, "r");
Note: See TracChangeset for help on using the changeset viewer.