Changeset 56330ff


Ignore:
Timestamp:
Aug 25, 2002, 3:02:14 PM (19 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
c01e477
Parents:
4b464a4
Message:
Moved zsig generation to the zwrite object
Print the zsig used for outgoing messages
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r4b464a4 r56330ff  
    1616        Renamed pretty_sender to short_zuser and renamed long_sender to
    1717             long_zuser
     18        Moved zsig generation to the zwrite object
     19        Print the zsig used for outgoing messages
    1820       
    19211.2.2
  • functions.c

    r4b464a4 r56330ff  
    8080}
    8181
    82 void owl_function_make_outgoing_zephyr(char *header, char *body, char *zwriteline) {
     82void owl_function_make_outgoing_zephyr(char *header, char *body, char *zwriteline, char *zsig) {
    8383  owl_message *m;
    8484  int followlast;
     
    9494   * Right now this only works for one recipient */
    9595  tobuff=owl_malloc(strlen(owl_zwrite_get_recip_n(&z, 0))+100);
    96   sprintf(tobuff, "Zephyr sent to %s", owl_zwrite_get_recip_n(&z, 0));
     96  sprintf(tobuff, "Zephyr sent to %s  (Zsig: %s)", owl_zwrite_get_recip_n(&z, 0), zsig);
    9797
    9898  /* create the message */
     
    129129  owl_global_set_needrefresh(&g);
    130130  owl_free(tobuff);
     131  owl_zwrite_free(&z);
    131132}
    132133
     
    153154  /* create and setup the editwin */
    154155  e=owl_global_get_typwin(&g);
    155   owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE,
    156                         owl_global_get_msg_history(&g));
     156  owl_editwin_new_style(e, OWL_EDITWIN_STYLE_MULTILINE, owl_global_get_msg_history(&g));
    157157
    158158  if (!owl_global_get_lockout_ctrld(&g)) {
     
    183183  owl_function_makemsg("Waiting for ack...");
    184184
    185   /* display the message as an admin message in the receive window */
     185  /* display the message as an outgoing message in the receive window */
    186186  if (owl_global_is_displayoutgoing(&g) && owl_zwrite_is_personal(&z)) {
    187187    owl_zwrite_get_recipstr(&z, buff);
    188188    tmpbuff = owl_sprintf("Message sent to %s", buff);
    189     owl_function_make_outgoing_zephyr(tmpbuff, owl_editwin_get_text(owl_global_get_typwin(&g)), line);
     189    owl_function_make_outgoing_zephyr(tmpbuff, owl_editwin_get_text(owl_global_get_typwin(&g)), line, owl_zwrite_get_zsig(&z));
    190190    owl_free(tmpbuff);
    191191  }
  • owl.h

    r4b464a4 r56330ff  
    219219  char realm[LINE];
    220220  char opcode[LINE];
     221  char *zsig;
    221222  owl_list recips;
    222223  int cc;
  • zephyr.c

    r4b464a4 r56330ff  
    66#include <zephyr/zephyr.h>
    77#include <com_err.h>
    8 #include <pwd.h>
    98#include "owl.h"
    109
     
    259258  int ret;
    260259  ZNotice_t notice;
    261   char *ptr;
    262   struct passwd *pw;
    263   char zsigtmp[LINE];
    264   char *zsigexec, *zsigowlvar, *zsigzvar;
    265  
    266   zsigexec = owl_global_get_zsig_exec(&g);
    267   zsigowlvar = owl_global_get_zsig(&g);
    268   zsigzvar = ZGetVariable("zwrite-signature");
    269 
    270   if (zsig) {
    271     strcpy(zsigtmp, zsig);
    272   } else if (zsigowlvar && *zsigowlvar) {
    273     strncpy(zsigtmp, zsigowlvar, LINE);
    274   } else if (zsigexec && *zsigexec) {
    275     FILE *file;
    276     char buff[LINE];
    277     strcpy(zsigtmp, "");
    278     file=popen(zsigexec, "r");
    279     if (!file) {
    280       if (zsigzvar && *zsigzvar) {
    281         strncpy(zsigtmp, zsigzvar, LINE);
    282       }
    283     } else {
    284       while (fgets(buff, LINE, file)) { /* wrong sizing */
    285         strcat(zsigtmp, buff);
    286       }
    287       pclose(file);
    288       if (zsigtmp[strlen(zsigtmp)-1]=='\n') {
    289         zsigtmp[strlen(zsigtmp)-1]='\0';
    290       }
    291     }
    292   } else if (zsigzvar) {
    293     strncpy(zsigtmp, zsigzvar, LINE);
    294   } else if (((pw=getpwuid(getuid()))!=NULL) && (pw->pw_gecos)) {
    295     strncpy(zsigtmp, pw->pw_gecos, LINE);
    296     ptr=strchr(zsigtmp, ',');
    297     if (ptr) {
    298       ptr[0]='\0';
    299     }
    300   } else {
    301     strcpy(zsigtmp, "");
    302   }
    303260   
    304261  memset(&notice, 0, sizeof(notice));
     
    317274  if (opcode) notice.z_opcode=opcode;
    318275
    319   notice.z_message_len=strlen(zsigtmp)+1+strlen(message);
     276  notice.z_message_len=strlen(zsig)+1+strlen(message);
    320277  notice.z_message=owl_malloc(notice.z_message_len+10);
    321   strcpy(notice.z_message, zsigtmp);
    322   memcpy(notice.z_message+strlen(zsigtmp)+1, message, strlen(message));
     278  strcpy(notice.z_message, zsig);
     279  memcpy(notice.z_message+strlen(zsig)+1, message, strlen(message));
    323280
    324281  /* ret=ZSendNotice(&notice, ZAUTH); */
  • zwrite.c

    r4b464a4 r56330ff  
    11#include <string.h>
     2#include <pwd.h>
     3#include <sys/types.h>
     4#include <unistd.h>
    25#include "owl.h"
    36
     
    1720  int argc, badargs, myargc;
    1821  char **argv, **myargv;
     22  char *zsigexec, *zsigowlvar, *zsigzvar, *ptr;
     23  struct passwd *pw;
    1924
    2025  badargs=0;
     
    2530  strcpy(z->inst, "personal");
    2631  strcpy(z->opcode, "");
     32  z->zsig=owl_strdup("");
    2733  z->cc=0;
    2834  z->noping=0;
     
    103109  }
    104110
     111  /* set a zsig */
     112  zsigexec = owl_global_get_zsig_exec(&g);
     113  zsigowlvar = owl_global_get_zsig(&g);
     114  zsigzvar = ZGetVariable("zwrite-signature");
     115
     116  if (zsigowlvar && *zsigowlvar) {
     117    owl_free(z->zsig);
     118    z->zsig=strdup(zsigowlvar);
     119  } else if (zsigexec && *zsigexec) {
     120    FILE *file;
     121    char buff[LINE];
     122
     123    file=popen(zsigexec, "r");
     124    if (!file) {
     125      if (zsigzvar && *zsigzvar) {
     126        owl_free(z->zsig);
     127        z->zsig=owl_strdup(zsigzvar);
     128      }
     129    } else {
     130      owl_free(z->zsig);
     131      z->zsig=owl_malloc(LINE);
     132      strcpy(z->zsig, "");
     133      while (fgets(buff, LINE, file)) { /* wrong sizing */
     134        strcat(z->zsig, buff);
     135      }
     136      pclose(file);
     137      if (z->zsig[strlen(z->zsig)-1]=='\n') {
     138        z->zsig[strlen(z->zsig)-1]='\0';
     139      }
     140    }
     141  } else if (zsigzvar) {
     142    owl_free(z->zsig);
     143    z->zsig=owl_strdup(zsigzvar);
     144  } else if (((pw=getpwuid(getuid()))!=NULL) && (pw->pw_gecos)) {
     145    owl_free(z->zsig);
     146    z->zsig=strdup(pw->pw_gecos);
     147    ptr=strchr(z->zsig, ',');
     148    if (ptr) {
     149      ptr[0]='\0';
     150    }
     151  }
     152
    105153  return(0);
    106154}
     
    160208      }
    161209      if (z->cc) {
    162         send_zephyr(z->opcode, NULL, z->class, z->inst, to, tmpmsg);
     210        send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, tmpmsg);
    163211      } else {
    164         send_zephyr(z->opcode, NULL, z->class, z->inst, to, msg);
     212        send_zephyr(z->opcode, z->zsig, z->class, z->inst, to, msg);
    165213      }
    166214    }
     
    190238}
    191239
     240char *owl_zwrite_get_zsig(owl_zwrite *z) {
     241  return(z->zsig);
     242}
     243
    192244void owl_zwrite_get_recipstr(owl_zwrite *z, char *buff) {
    193245  int i, j;
     
    225277void owl_zwrite_free(owl_zwrite *z) {
    226278  owl_list_free_all(&(z->recips), &owl_free);
    227 }
     279  owl_free(z->zsig);
     280}
Note: See TracChangeset for help on using the changeset viewer.