Changeset 85d1795


Ignore:
Timestamp:
Apr 16, 2007, 9:54:27 PM (18 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
d754b0a
Parents:
1d7e094
Message:
Change special casing rules to refer to default format strings instead
of senders.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • message.c

    ra387d12e r85d1795  
    851851  m->zwriteline=strdup("");
    852852
    853   /* set the body */
    854   tmp=owl_zephyr_get_message(n);
    855   if (owl_global_is_newlinestrip(&g)) {
    856     tmp2=owl_util_stripnewlines(tmp);
    857     owl_message_set_body(m, tmp2);
    858     owl_free(tmp2);
    859   } else {
    860     owl_message_set_body(m, tmp);
    861   }
    862   owl_free(tmp);
    863 
    864 #ifdef OWL_ENABLE_ZCRYPT
    865   /* if zcrypt is enabled try to decrypt the message */
    866   if (owl_global_is_zcrypt(&g) && !strcasecmp(n->z_opcode, "crypt")) {
    867     char *out;
    868     int ret;
    869 
    870     out=owl_malloc(strlen(owl_message_get_body(m))*16+20);
    871     ret=owl_zcrypt_decrypt(out, owl_message_get_body(m), owl_message_get_class(m), owl_message_get_instance(m));
    872     if (ret==0) {
    873       owl_message_set_body(m, out);
    874     } else {
    875       owl_free(out);
    876     }
    877   }
    878 #endif 
    879 
    880853  /* save the hostname */
    881854  owl_function_debugmsg("About to do gethostbyaddr");
     
    886859    owl_message_set_hostname(m, inet_ntoa(n->z_sender_addr));
    887860  }
     861
     862  /* set the body */
     863  tmp=owl_zephyr_get_message(n, m);
     864  if (owl_global_is_newlinestrip(&g)) {
     865    tmp2=owl_util_stripnewlines(tmp);
     866    owl_message_set_body(m, tmp2);
     867    owl_free(tmp2);
     868  } else {
     869    owl_message_set_body(m, tmp);
     870  }
     871  owl_free(tmp);
     872
     873#ifdef OWL_ENABLE_ZCRYPT
     874  /* if zcrypt is enabled try to decrypt the message */
     875  if (owl_global_is_zcrypt(&g) && !strcasecmp(n->z_opcode, "crypt")) {
     876    char *out;
     877    int ret;
     878
     879    out=owl_malloc(strlen(owl_message_get_body(m))*16+20);
     880    ret=owl_zcrypt_decrypt(out, owl_message_get_body(m), owl_message_get_class(m), owl_message_get_instance(m));
     881    if (ret==0) {
     882      owl_message_set_body(m, out);
     883    } else {
     884      owl_free(out);
     885    }
     886  }
     887#endif 
    888888}
    889889#else
  • zephyr.c

    rbb2c60d r85d1795  
    381381 * caller must free the return
    382382 */
    383 char *owl_zephyr_get_message(ZNotice_t *n)
     383char *owl_zephyr_get_message(ZNotice_t *n, owl_message *m)
    384384{
    385385  /* don't let ping messages have a body */
     
    388388  }
    389389
    390   /* deal with MIT Athena OLC messages */
    391   if (!strcasecmp(n->z_sender, "olc.matisse@ATHENA.MIT.EDU")) {
    392     return(owl_zephyr_get_field(n, 1));
    393   }
    394390  /* deal with MIT NOC messages */
    395   else if (!strcasecmp(n->z_sender, "rcmd.achilles@ATHENA.MIT.EDU")) {
    396     /* $opcode service on $instance $3.\n$4 */
    397     char *msg, *opcode, *instance, *field3, *field4;
    398 
    399     opcode = n->z_opcode;
    400     instance = n->z_class_inst;
     391  if (!strcasecmp(n->z_default_format, "@center(@bold(NOC Message))\n\n@bold(Sender:) $1 <$sender>\n@bold(Time:  ) $time\n\n@italic($opcode service on $instance $3.) $4\n")) {
     392    char *msg, *field3, *field4;
     393
    401394    field3 = owl_zephyr_get_field(n, 3);
    402395    field4 = owl_zephyr_get_field(n, 4);
    403396
    404     msg = owl_sprintf("%s service on %s %s\n%s", opcode, instance, field3, field4);
     397    msg = owl_sprintf("%s service on %s %s\n%s", n->z_opcode, n->z_class_inst, field3, field4);
    405398    owl_free(field3);
    406399    owl_free(field4);
     
    410403  }
    411404  /* deal with MIT Discuss messages */
    412   else if (!strcasecmp(n->z_sender, "daemon@ATHENA.MIT.EDU") &&
    413            !strcasecmp(n->z_class, "DISCUSS")) {
    414     /*New transaction [$1] entered in $2
    415       From: $3 ($5)
    416       Subject: $4 */
    417    
     405  else if (!strcasecmp(n->z_default_format, "New transaction [$1] entered in $2\nFrom: $3 ($5)\nSubject: $4")) {
    418406    char *msg, *field1, *field2, *field3, *field4, *field5;
    419407   
     
    434422    }
    435423  }
    436 
    437   return(owl_zephyr_get_field(n, 2));
     424  /* deal with MIT Moira messages */
     425  else if (!strcasecmp(n->z_default_format, "MOIRA $instance on $fromhost:\n $message\n")) {
     426    char *msg, *field1;
     427   
     428    field1 = owl_zephyr_get_field(n, 1);
     429   
     430    msg = owl_sprintf("MOIRA %s on %s: %s", n->z_class_inst, owl_message_get_hostname(m), field1);
     431    owl_free(field1);
     432    if (msg) {
     433      return msg;
     434    }
     435  }
     436
     437  if (owl_zephyr_get_num_fields(n) == 1) {
     438    return(owl_zephyr_get_field(n, 1));
     439  }
     440  else {
     441    return(owl_zephyr_get_field(n, 2));
     442  }
    438443}
    439444#endif
     
    450455  }
    451456
    452   /* No zsig for OLC messages */
    453   if (!strcasecmp(n->z_sender, "olc.matisse@ATHENA.MIT.EDU")) {
     457  /* If there's only one field, no zsig */
     458  if (owl_zephyr_get_num_fields(n) == 1) {
     459    *k=0;
    454460    return("");
    455461  }
Note: See TracChangeset for help on using the changeset viewer.