Changeset 25dd31a for stylefunc.c


Ignore:
Timestamp:
Oct 26, 2003, 2:43:40 PM (21 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
70b53ec
Parents:
eec69e1
Message:
Added a timestamp to the default style.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • stylefunc.c

    r37eab7f r25dd31a  
    225225void owl_stylefunc_default(owl_fmtext *fm, owl_message *m)
    226226{
     227  char *shorttimestr;
    227228#ifdef HAVE_LIBZEPHYR
    228229  char *body, *indent, *ptr, *zsigbuff, frombuff[LINE];
    229230  ZNotice_t *n;
    230231#endif
     232
     233  shorttimestr=owl_message_get_shorttimestr(m);
    231234
    232235  if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
     
    302305        owl_fmtext_append_normal(fm, " {");
    303306        owl_fmtext_append_normal(fm, owl_message_get_realm(m));
    304         owl_fmtext_append_normal(fm, "} ");
     307        owl_fmtext_append_normal(fm, "}");
    305308      }
    306309      if (strcmp(owl_message_get_opcode(m), "")) {
    307310        owl_fmtext_append_normal(fm, " [");
    308311        owl_fmtext_append_normal(fm, owl_message_get_opcode(m));
    309         owl_fmtext_append_normal(fm, "] ");
    310       }
    311      
     312        owl_fmtext_append_normal(fm, "]");
     313      }
     314
     315      owl_fmtext_append_normal(fm, "  ");
     316      owl_fmtext_append_normal(fm, shorttimestr);
     317
    312318      /* stick on the zsig */
    313319      zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
     
    329335      }
    330336    }
     337   
     338    owl_free(body);
     339    owl_free(indent);
     340#endif
     341  } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) {
     342    char *indent, *text, *zsigbuff, *foo;
     343   
     344    text=owl_message_get_body(m);
     345   
     346    indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
     347    owl_text_indent(indent, text, OWL_MSGTAB);
     348    owl_fmtext_append_normal(fm, OWL_TABSTR);
     349    owl_fmtext_append_normal(fm, "Zephyr sent to ");
     350    foo=short_zuser(owl_message_get_recipient(m));
     351    owl_fmtext_append_normal(fm, foo);
     352    owl_free(foo);
     353
     354    owl_fmtext_append_normal(fm, "  ");
     355    owl_fmtext_append_normal(fm, shorttimestr);
     356
     357    owl_fmtext_append_normal(fm, "  (Zsig: ");
     358   
     359    zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
     360    owl_message_pretty_zsig(m, zsigbuff);
     361    owl_fmtext_append_ztext(fm, zsigbuff);
     362    owl_free(zsigbuff);
     363   
     364    owl_fmtext_append_normal(fm, ")");
     365    owl_fmtext_append_normal(fm, "\n");
     366    owl_fmtext_append_ztext(fm, indent);
     367    if (text[strlen(text)-1]!='\n') {
     368      owl_fmtext_append_normal(fm, "\n");
     369    }
     370   
     371    owl_free(indent);
     372  } else if (owl_message_is_type_aim(m)) {
     373    char *indent;
     374   
     375    if (owl_message_is_loginout(m)) {
     376      owl_fmtext_append_normal(fm, OWL_TABSTR);
     377      if (owl_message_is_login(m)) {
     378        owl_fmtext_append_bold(fm, "AIM LOGIN");
     379      } else {
     380        owl_fmtext_append_bold(fm, "AIM LOGOUT");
     381      }
     382      owl_fmtext_append_normal(fm, " for ");
     383      owl_fmtext_append_normal(fm, owl_message_get_sender(m));
     384      owl_fmtext_append_normal(fm, "\n");
     385    } else if (owl_message_is_direction_in(m)) {
     386      indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
     387      owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
     388      owl_fmtext_append_bold(fm, OWL_TABSTR);
     389      owl_fmtext_append_bold(fm, "AIM from ");
     390      owl_fmtext_append_bold(fm, owl_message_get_sender(m));
     391     
     392      owl_fmtext_append_normal(fm, "  ");
     393      owl_fmtext_append_normal(fm, shorttimestr);
     394
     395      owl_fmtext_append_bold(fm, "\n");
     396      owl_fmtext_append_bold(fm, indent);
     397      if (indent[strlen(indent)-1]!='\n') {
     398        owl_fmtext_append_normal(fm, "\n");
     399      }
     400      owl_free(indent);
     401    } else if (owl_message_is_direction_out(m)) {
     402      indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
     403      owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
     404      owl_fmtext_append_normal(fm, OWL_TABSTR);
     405      owl_fmtext_append_normal(fm, "AIM sent to ");
     406      owl_fmtext_append_normal(fm, owl_message_get_recipient(m));
     407      owl_fmtext_append_normal(fm, "  ");
     408      owl_fmtext_append_normal(fm, shorttimestr);
     409      owl_fmtext_append_normal(fm, "\n");
     410      owl_fmtext_append_ztext(fm, indent);
     411      if (indent[strlen(indent)-1]!='\n') {
     412        owl_fmtext_append_normal(fm, "\n");
     413      }
     414      owl_free(indent);
     415    }
     416  } else if (owl_message_is_type_admin(m)) {
     417    char *text, *header, *indent;
     418   
     419    text=owl_message_get_body(m);
     420    header=owl_message_get_attribute_value(m, "adminheader");
     421   
     422    indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
     423    owl_text_indent(indent, text, OWL_MSGTAB);
     424    owl_fmtext_append_normal(fm, OWL_TABSTR);
     425    owl_fmtext_append_bold(fm, "OWL ADMIN ");
     426    owl_fmtext_append_ztext(fm, header);
     427    owl_fmtext_append_normal(fm, "\n");
     428    owl_fmtext_append_ztext(fm, indent);
     429    if (text[strlen(text)-1]!='\n') {
     430      owl_fmtext_append_normal(fm, "\n");
     431    }
     432   
     433    owl_free(indent);
     434  } else {
     435    char *text, *header, *indent;
     436   
     437    text=owl_message_get_body(m);
     438    header=owl_sprintf("%s from: %s to: %s",
     439                       owl_message_get_type(m),
     440                       owl_message_get_sender(m),
     441                       owl_message_get_recipient(m));
     442   
     443    indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
     444    owl_text_indent(indent, text, OWL_MSGTAB);
     445    owl_fmtext_append_normal(fm, OWL_TABSTR);
     446    owl_fmtext_append_normal(fm, header);
     447    owl_fmtext_append_normal(fm, "  ");
     448    owl_fmtext_append_normal(fm, shorttimestr);
     449    owl_fmtext_append_normal(fm, "\n");
     450    owl_fmtext_append_normal(fm, indent);
     451    if (text[strlen(text)-1]!='\n') {
     452      owl_fmtext_append_normal(fm, "\n");
     453    }
     454   
     455    owl_free(indent);
     456    owl_free(header);
     457  }
     458  owl_free(shorttimestr);
     459}
     460
     461void owl_stylefunc_oneline(owl_fmtext *fm, owl_message *m)
     462{
     463  char *tmp;
     464  char *baseformat="%s %-13.13s %-11.11s %-12.12s ";
     465  char *sender, *recip;
     466#ifdef HAVE_LIBZEPHYR
     467  ZNotice_t *n;
     468#endif
     469
     470  sender=short_zuser(owl_message_get_sender(m));
     471  recip=short_zuser(owl_message_get_recipient(m));
     472 
     473  if (owl_message_is_type_zephyr(m)) {
     474#ifdef HAVE_LIBZEPHYR
     475    n=owl_message_get_notice(m);
     476   
     477    owl_fmtext_append_spaces(fm, OWL_TAB);
     478
     479    if (owl_message_is_loginout(m)) {
     480      char *ptr, *host, *tty;
     481      int len;
     482     
     483      ptr=owl_zephyr_get_field(n, 1, &len);
     484      host=owl_malloc(len+10);
     485      strncpy(host, ptr, len);
     486      host[len]='\0';
     487
     488      ptr=owl_zephyr_get_field(n, 3, &len);
     489      tty=owl_malloc(len+10);
     490      strncpy(tty, ptr, len);
     491      tty[len]='\0';
     492
     493      if (owl_message_is_login(m)) {
     494        tmp=owl_sprintf(baseformat, "<", "LOGIN", "", sender);
     495        owl_fmtext_append_normal(fm, tmp);
     496        owl_free(tmp);
     497      } else if (owl_message_is_logout(m)) {
     498        tmp=owl_sprintf(baseformat, "<", "LOGOUT", "", sender);
     499        owl_fmtext_append_normal(fm, tmp);
     500        owl_free(tmp);
     501      }
     502
     503      owl_fmtext_append_normal(fm, "at ");
     504      owl_fmtext_append_normal(fm, host);
     505      owl_fmtext_append_normal(fm, " ");
     506      owl_fmtext_append_normal(fm, tty);
     507      owl_fmtext_append_normal(fm, "\n");
     508
     509      owl_free(host);
     510      owl_free(tty);
     511
     512    } else if (owl_message_is_ping(m)) {
     513      tmp=owl_sprintf(baseformat, "<", "PING", "", sender);
     514      owl_fmtext_append_normal(fm, tmp);
     515      owl_fmtext_append_normal(fm, "\n");
     516      owl_free(tmp);
     517
     518    } else {
     519      if (owl_message_is_direction_in(m)) {
     520        tmp=owl_sprintf(baseformat, "<", owl_message_get_class(m), owl_message_get_instance(m), sender);
     521      } else if (owl_message_is_direction_out(m)) {
     522        tmp=owl_sprintf(baseformat, ">", owl_message_get_class(m), owl_message_get_instance(m), recip);
     523      } else {
     524        tmp=owl_sprintf(baseformat, "-", owl_message_get_class(m), owl_message_get_instance(m), sender);
     525      }
     526      owl_fmtext_append_normal(fm, tmp);
     527      if (tmp) owl_free(tmp);
     528     
     529      tmp=owl_strdup(owl_message_get_body(m));
     530      owl_util_tr(tmp, '\n', ' ');
     531      owl_fmtext_append_ztext(fm, tmp);
     532      owl_fmtext_append_normal(fm, "\n");
     533      if (tmp) owl_free(tmp);
     534    }
     535     
     536    /* make personal messages bold for smaat users */
     537    if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) &&
     538        owl_message_is_personal(m) &&
     539        owl_message_is_direction_in(m)) {
     540      owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
     541    }
     542
     543    owl_free(sender);
     544    owl_free(recip);
     545#endif
     546  } else if (owl_message_is_type_aim(m)) {
     547    owl_fmtext_append_spaces(fm, OWL_TAB);
     548    if (owl_message_is_login(m)) {
     549      tmp=owl_sprintf(baseformat, "<", "AIM LOGIN", "", owl_message_get_sender(m));
     550      owl_fmtext_append_normal(fm, tmp);
     551      owl_fmtext_append_normal(fm, "\n");
     552      if (tmp) owl_free(tmp);
     553    } else if (owl_message_is_logout(m)) {
     554      tmp=owl_sprintf(baseformat, "<", "AIM LOGOUT", "", owl_message_get_sender(m));
     555      owl_fmtext_append_normal(fm, tmp);
     556      owl_fmtext_append_normal(fm, "\n");
     557      if (tmp) owl_free(tmp);
     558    } else {
     559      if (owl_message_is_direction_in(m)) {
     560        tmp=owl_sprintf(baseformat, "<", "AIM", "", owl_message_get_sender(m));
     561        owl_fmtext_append_normal(fm, tmp);
     562        if (tmp) owl_free(tmp);
     563      } else if (owl_message_is_direction_out(m)) {
     564        tmp=owl_sprintf(baseformat, ">", "AIM", "", owl_message_get_recipient(m));
     565        owl_fmtext_append_normal(fm, tmp);
     566        if (tmp) owl_free(tmp);
     567      }
     568     
     569      tmp=owl_strdup(owl_message_get_body(m));
     570      owl_util_tr(tmp, '\n', ' ');
     571      owl_fmtext_append_normal(fm, tmp);
     572      owl_fmtext_append_normal(fm, "\n");
     573      if (tmp) owl_free(tmp);
     574
     575      /* make personal messages bold for smaat users */
     576      if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && owl_message_is_direction_in(m)) {
     577        owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
     578      }
     579    }
     580  } else if (owl_message_is_type_admin(m)) {
     581    owl_fmtext_append_spaces(fm, OWL_TAB);
     582    owl_fmtext_append_normal(fm, "< ADMIN                                        ");
     583   
     584    tmp=owl_strdup(owl_message_get_body(m));
     585    owl_util_tr(tmp, '\n', ' ');
     586    owl_fmtext_append_normal(fm, tmp);
     587    owl_fmtext_append_normal(fm, "\n");
     588    if (tmp) owl_free(tmp);
     589  } else {
     590    owl_fmtext_append_spaces(fm, OWL_TAB);
     591    owl_fmtext_append_normal(fm, "< LOOPBACK                                     ");
     592   
     593    tmp=owl_strdup(owl_message_get_body(m));
     594    owl_util_tr(tmp, '\n', ' ');
     595    owl_fmtext_append_normal(fm, tmp);
     596    owl_fmtext_append_normal(fm, "\n");
     597    if (tmp) owl_free(tmp);
     598  }   
     599
     600}
     601
     602void owl_stylefunc_vt(owl_fmtext *fm, owl_message *m)
     603{
     604#ifdef HAVE_LIBZEPHYR
     605  char *body, *indent, *ptr, *zsigbuff, frombuff[LINE];
     606  owl_fmtext fm_first, fm_other, fm_tmp;
     607  ZNotice_t *n;
     608#endif
     609  char *sender, *hostname, *timestr, *classinst1, *classinst2;
     610
     611  if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
     612#ifdef HAVE_LIBZEPHYR
     613    n=owl_message_get_notice(m);
     614
     615    /* get the body */
     616    body=owl_malloc(strlen(owl_message_get_body(m))+30);
     617    strcpy(body, owl_message_get_body(m));
     618   
     619    /* add a newline if we need to */
     620    if (body[0]!='\0' && body[strlen(body)-1]!='\n') {
     621      strcat(body, "\n");
     622    }
     623
     624    owl_fmtext_init_null(&fm_tmp);
     625    owl_fmtext_append_ztext(&fm_tmp, body);
     626    owl_fmtext_init_null(&fm_first);
     627    owl_fmtext_truncate_lines(&fm_tmp, 0, 1, &fm_first);
     628
     629    /* do the indenting into indent */
     630    indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10);
     631    owl_text_indent(indent, body, 31);
     632
     633    owl_fmtext_free(&fm_tmp);
     634    owl_fmtext_init_null(&fm_tmp);
     635    owl_fmtext_append_ztext(&fm_tmp, indent);
     636    owl_fmtext_init_null(&fm_other);
     637    owl_fmtext_truncate_lines(&fm_tmp, 1, owl_fmtext_num_lines(&fm_tmp)-1, &fm_other);
     638    owl_fmtext_free(&fm_tmp);
     639   
     640    /* edit the from addr for printing */
     641    strcpy(frombuff, owl_message_get_sender(m));
     642    ptr=strchr(frombuff, '@');
     643    if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
     644      *ptr='\0';
     645    }
     646    sender=owl_sprintf("%-9.9s", frombuff);
     647
     648    hostname=owl_sprintf("%-9.9s", owl_message_get_hostname(m));
     649    timestr=owl_strdup("00:00");
     650    classinst1=owl_sprintf("<%s>[%s]", owl_message_get_class(m), owl_message_get_instance(m));
     651    classinst2=owl_sprintf("%-9.9s", classinst1);
     652   
     653    /* set the message for printing */
     654    owl_fmtext_append_normal(fm, OWL_TABSTR);
     655   
     656    if (owl_message_is_ping(m) && owl_message_is_private(m)) {
     657      owl_fmtext_append_bold(fm, "PING");
     658      owl_fmtext_append_normal(fm, " from ");
     659      owl_fmtext_append_bold(fm, frombuff);
     660      owl_fmtext_append_normal(fm, "\n");
     661    } else if (owl_message_is_loginout(m)) {
     662      char *ptr, *host, *tty;
     663      int len;
     664
     665      ptr=owl_zephyr_get_field(n, 1, &len);
     666      host=owl_malloc(len+10);
     667      strncpy(host, ptr, len);
     668      host[len]='\0';
     669
     670      ptr=owl_zephyr_get_field(n, 3, &len);
     671      tty=owl_malloc(len+10);
     672      strncpy(tty, ptr, len);
     673      tty[len]='\0';
     674     
     675      if (owl_message_is_login(m)) {
     676        owl_fmtext_append_bold(fm, "LOGIN");
     677      } else if (owl_message_is_logout(m)) {
     678        owl_fmtext_append_bold(fm, "LOGOUT");
     679      }
     680      owl_fmtext_append_normal(fm, " for ");
     681      ptr=short_zuser(owl_message_get_instance(m));
     682      owl_fmtext_append_bold(fm, ptr);
     683      owl_free(ptr);
     684      owl_fmtext_append_normal(fm, " at ");
     685      owl_fmtext_append_normal(fm, host);
     686      owl_fmtext_append_normal(fm, " ");
     687      owl_fmtext_append_normal(fm, tty);
     688      owl_fmtext_append_normal(fm, "\n");
     689
     690      owl_free(host);
     691      owl_free(tty);
     692    } else {
     693      owl_fmtext_append_normal(fm, sender);
     694      owl_fmtext_append_normal(fm, "|");
     695      owl_fmtext_append_normal(fm, hostname);
     696      owl_fmtext_append_normal(fm, " ");
     697      owl_fmtext_append_normal(fm, timestr);
     698      owl_fmtext_append_normal(fm, " ");
     699      owl_fmtext_append_normal(fm, classinst2);
     700
     701      owl_fmtext_append_normal(fm, "   ");
     702      owl_fmtext_append_fmtext(fm, &fm_first);
     703      owl_fmtext_append_fmtext(fm, &fm_other);
     704
     705      owl_fmtext_free(&fm_other);
     706      owl_fmtext_free(&fm_first);
     707     
     708      /* make private messages bold for smaat users */
     709      if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
     710        if (owl_message_is_personal(m)) {
     711          owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD);
     712        }
     713      }
     714    }
     715
     716    owl_free(sender);
     717    owl_free(hostname);
     718    owl_free(timestr);
     719    owl_free(classinst1);
     720    owl_free(classinst2);
    331721   
    332722    owl_free(body);
     
    417807    owl_free(indent);
    418808  } else {
    419     char *text, *header, *indent;
    420    
    421     text=owl_message_get_body(m);
    422     header=owl_sprintf("%s from: %s to: %s",
    423                        owl_message_get_type(m),
    424                        owl_message_get_sender(m),
    425                        owl_message_get_recipient(m));
    426    
    427     indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    428     owl_text_indent(indent, text, OWL_MSGTAB);
    429     owl_fmtext_append_normal(fm, OWL_TABSTR);
    430     owl_fmtext_append_normal(fm, header);
    431     owl_fmtext_append_normal(fm, "\n");
    432     owl_fmtext_append_normal(fm, indent);
    433     if (text[strlen(text)-1]!='\n') {
    434       owl_fmtext_append_normal(fm, "\n");
    435     }
    436    
    437     owl_free(indent);
    438     owl_free(header);
     809
    439810  }
    440811}
    441 
    442 void owl_stylefunc_oneline(owl_fmtext *fm, owl_message *m)
    443 {
    444   char *tmp;
    445   char *baseformat="%s %-13.13s %-11.11s %-12.12s ";
    446   char *sender, *recip;
    447 #ifdef HAVE_LIBZEPHYR
    448   ZNotice_t *n;
    449 #endif
    450 
    451   sender=short_zuser(owl_message_get_sender(m));
    452   recip=short_zuser(owl_message_get_recipient(m));
    453  
    454   if (owl_message_is_type_zephyr(m)) {
    455 #ifdef HAVE_LIBZEPHYR
    456     n=owl_message_get_notice(m);
    457    
    458     owl_fmtext_append_spaces(fm, OWL_TAB);
    459 
    460     if (owl_message_is_loginout(m)) {
    461       char *ptr, *host, *tty;
    462       int len;
    463      
    464       ptr=owl_zephyr_get_field(n, 1, &len);
    465       host=owl_malloc(len+10);
    466       strncpy(host, ptr, len);
    467       host[len]='\0';
    468 
    469       ptr=owl_zephyr_get_field(n, 3, &len);
    470       tty=owl_malloc(len+10);
    471       strncpy(tty, ptr, len);
    472       tty[len]='\0';
    473 
    474       if (owl_message_is_login(m)) {
    475         tmp=owl_sprintf(baseformat, "<", "LOGIN", "", sender);
    476         owl_fmtext_append_normal(fm, tmp);
    477         owl_free(tmp);
    478       } else if (owl_message_is_logout(m)) {
    479         tmp=owl_sprintf(baseformat, "<", "LOGOUT", "", sender);
    480         owl_fmtext_append_normal(fm, tmp);
    481         owl_free(tmp);
    482       }
    483 
    484       owl_fmtext_append_normal(fm, "at ");
    485       owl_fmtext_append_normal(fm, host);
    486       owl_fmtext_append_normal(fm, " ");
    487       owl_fmtext_append_normal(fm, tty);
    488       owl_fmtext_append_normal(fm, "\n");
    489 
    490       owl_free(host);
    491       owl_free(tty);
    492 
    493     } else if (owl_message_is_ping(m)) {
    494       tmp=owl_sprintf(baseformat, "<", "PING", "", sender);
    495       owl_fmtext_append_normal(fm, tmp);
    496       owl_fmtext_append_normal(fm, "\n");
    497       owl_free(tmp);
    498 
    499     } else {
    500       if (owl_message_is_direction_in(m)) {
    501         tmp=owl_sprintf(baseformat, "<", owl_message_get_class(m), owl_message_get_instance(m), sender);
    502       } else if (owl_message_is_direction_out(m)) {
    503         tmp=owl_sprintf(baseformat, ">", owl_message_get_class(m), owl_message_get_instance(m), recip);
    504       } else {
    505         tmp=owl_sprintf(baseformat, "-", owl_message_get_class(m), owl_message_get_instance(m), sender);
    506       }
    507       owl_fmtext_append_normal(fm, tmp);
    508       if (tmp) owl_free(tmp);
    509      
    510       tmp=owl_strdup(owl_message_get_body(m));
    511       owl_util_tr(tmp, '\n', ' ');
    512       owl_fmtext_append_ztext(fm, tmp);
    513       owl_fmtext_append_normal(fm, "\n");
    514       if (tmp) owl_free(tmp);
    515     }
    516      
    517     /* make personal messages bold for smaat users */
    518     if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) &&
    519         owl_message_is_personal(m) &&
    520         owl_message_is_direction_in(m)) {
    521       owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
    522     }
    523 
    524     owl_free(sender);
    525     owl_free(recip);
    526 #endif
    527   } else if (owl_message_is_type_aim(m)) {
    528     owl_fmtext_append_spaces(fm, OWL_TAB);
    529     if (owl_message_is_login(m)) {
    530       tmp=owl_sprintf(baseformat, "<", "AIM LOGIN", "", owl_message_get_sender(m));
    531       owl_fmtext_append_normal(fm, tmp);
    532       owl_fmtext_append_normal(fm, "\n");
    533       if (tmp) owl_free(tmp);
    534     } else if (owl_message_is_logout(m)) {
    535       tmp=owl_sprintf(baseformat, "<", "AIM LOGOUT", "", owl_message_get_sender(m));
    536       owl_fmtext_append_normal(fm, tmp);
    537       owl_fmtext_append_normal(fm, "\n");
    538       if (tmp) owl_free(tmp);
    539     } else {
    540       if (owl_message_is_direction_in(m)) {
    541         tmp=owl_sprintf(baseformat, "<", "AIM", "", owl_message_get_sender(m));
    542         owl_fmtext_append_normal(fm, tmp);
    543         if (tmp) owl_free(tmp);
    544       } else if (owl_message_is_direction_out(m)) {
    545         tmp=owl_sprintf(baseformat, ">", "AIM", "", owl_message_get_recipient(m));
    546         owl_fmtext_append_normal(fm, tmp);
    547         if (tmp) owl_free(tmp);
    548       }
    549      
    550       tmp=owl_strdup(owl_message_get_body(m));
    551       owl_util_tr(tmp, '\n', ' ');
    552       owl_fmtext_append_normal(fm, tmp);
    553       owl_fmtext_append_normal(fm, "\n");
    554       if (tmp) owl_free(tmp);
    555 
    556       /* make personal messages bold for smaat users */
    557       if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && owl_message_is_direction_in(m)) {
    558         owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
    559       }
    560     }
    561   } else if (owl_message_is_type_admin(m)) {
    562     owl_fmtext_append_spaces(fm, OWL_TAB);
    563     owl_fmtext_append_normal(fm, "< ADMIN                                        ");
    564    
    565     tmp=owl_strdup(owl_message_get_body(m));
    566     owl_util_tr(tmp, '\n', ' ');
    567     owl_fmtext_append_normal(fm, tmp);
    568     owl_fmtext_append_normal(fm, "\n");
    569     if (tmp) owl_free(tmp);
    570   } else {
    571     owl_fmtext_append_spaces(fm, OWL_TAB);
    572     owl_fmtext_append_normal(fm, "< LOOPBACK                                     ");
    573    
    574     tmp=owl_strdup(owl_message_get_body(m));
    575     owl_util_tr(tmp, '\n', ' ');
    576     owl_fmtext_append_normal(fm, tmp);
    577     owl_fmtext_append_normal(fm, "\n");
    578     if (tmp) owl_free(tmp);
    579   }   
    580 
    581 }
    582 
    583 void owl_stylefunc_vt(owl_fmtext *fm, owl_message *m)
    584 {
    585 #ifdef HAVE_LIBZEPHYR
    586   char *body, *indent, *ptr, *zsigbuff, frombuff[LINE];
    587   owl_fmtext fm_first, fm_other, fm_tmp;
    588   ZNotice_t *n;
    589 #endif
    590   char *sender, *hostname, *timestr, *classinst1, *classinst2;
    591 
    592   if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
    593 #ifdef HAVE_LIBZEPHYR
    594     n=owl_message_get_notice(m);
    595 
    596     /* get the body */
    597     body=owl_malloc(strlen(owl_message_get_body(m))+30);
    598     strcpy(body, owl_message_get_body(m));
    599    
    600     /* add a newline if we need to */
    601     if (body[0]!='\0' && body[strlen(body)-1]!='\n') {
    602       strcat(body, "\n");
    603     }
    604 
    605     owl_fmtext_init_null(&fm_tmp);
    606     owl_fmtext_append_ztext(&fm_tmp, body);
    607     owl_fmtext_init_null(&fm_first);
    608     owl_fmtext_truncate_lines(&fm_tmp, 0, 1, &fm_first);
    609 
    610     /* do the indenting into indent */
    611     indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10);
    612     owl_text_indent(indent, body, 31);
    613 
    614     owl_fmtext_free(&fm_tmp);
    615     owl_fmtext_init_null(&fm_tmp);
    616     owl_fmtext_append_ztext(&fm_tmp, indent);
    617     owl_fmtext_init_null(&fm_other);
    618     owl_fmtext_truncate_lines(&fm_tmp, 1, owl_fmtext_num_lines(&fm_tmp)-1, &fm_other);
    619     owl_fmtext_free(&fm_tmp);
    620    
    621     /* edit the from addr for printing */
    622     strcpy(frombuff, owl_message_get_sender(m));
    623     ptr=strchr(frombuff, '@');
    624     if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
    625       *ptr='\0';
    626     }
    627     sender=owl_sprintf("%-9.9s", frombuff);
    628 
    629     hostname=owl_sprintf("%-9.9s", owl_message_get_hostname(m));
    630     timestr=owl_strdup("00:00");
    631     classinst1=owl_sprintf("<%s>[%s]", owl_message_get_class(m), owl_message_get_instance(m));
    632     classinst2=owl_sprintf("%-9.9s", classinst1);
    633    
    634     /* set the message for printing */
    635     owl_fmtext_append_normal(fm, OWL_TABSTR);
    636    
    637     if (owl_message_is_ping(m) && owl_message_is_private(m)) {
    638       owl_fmtext_append_bold(fm, "PING");
    639       owl_fmtext_append_normal(fm, " from ");
    640       owl_fmtext_append_bold(fm, frombuff);
    641       owl_fmtext_append_normal(fm, "\n");
    642     } else if (owl_message_is_loginout(m)) {
    643       char *ptr, *host, *tty;
    644       int len;
    645 
    646       ptr=owl_zephyr_get_field(n, 1, &len);
    647       host=owl_malloc(len+10);
    648       strncpy(host, ptr, len);
    649       host[len]='\0';
    650 
    651       ptr=owl_zephyr_get_field(n, 3, &len);
    652       tty=owl_malloc(len+10);
    653       strncpy(tty, ptr, len);
    654       tty[len]='\0';
    655      
    656       if (owl_message_is_login(m)) {
    657         owl_fmtext_append_bold(fm, "LOGIN");
    658       } else if (owl_message_is_logout(m)) {
    659         owl_fmtext_append_bold(fm, "LOGOUT");
    660       }
    661       owl_fmtext_append_normal(fm, " for ");
    662       ptr=short_zuser(owl_message_get_instance(m));
    663       owl_fmtext_append_bold(fm, ptr);
    664       owl_free(ptr);
    665       owl_fmtext_append_normal(fm, " at ");
    666       owl_fmtext_append_normal(fm, host);
    667       owl_fmtext_append_normal(fm, " ");
    668       owl_fmtext_append_normal(fm, tty);
    669       owl_fmtext_append_normal(fm, "\n");
    670 
    671       owl_free(host);
    672       owl_free(tty);
    673     } else {
    674       owl_fmtext_append_normal(fm, sender);
    675       owl_fmtext_append_normal(fm, "|");
    676       owl_fmtext_append_normal(fm, hostname);
    677       owl_fmtext_append_normal(fm, " ");
    678       owl_fmtext_append_normal(fm, timestr);
    679       owl_fmtext_append_normal(fm, " ");
    680       owl_fmtext_append_normal(fm, classinst2);
    681 
    682       owl_fmtext_append_normal(fm, "   ");
    683       owl_fmtext_append_fmtext(fm, &fm_first);
    684       owl_fmtext_append_fmtext(fm, &fm_other);
    685 
    686       owl_fmtext_free(&fm_other);
    687       owl_fmtext_free(&fm_first);
    688      
    689       /* make private messages bold for smaat users */
    690       if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
    691         if (owl_message_is_personal(m)) {
    692           owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD);
    693         }
    694       }
    695     }
    696 
    697     owl_free(sender);
    698     owl_free(hostname);
    699     owl_free(timestr);
    700     owl_free(classinst1);
    701     owl_free(classinst2);
    702    
    703     owl_free(body);
    704     owl_free(indent);
    705 #endif
    706   } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) {
    707     char *indent, *text, *zsigbuff, *foo;
    708    
    709     text=owl_message_get_body(m);
    710    
    711     indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    712     owl_text_indent(indent, text, OWL_MSGTAB);
    713     owl_fmtext_append_normal(fm, OWL_TABSTR);
    714     owl_fmtext_append_normal(fm, "Zephyr sent to ");
    715     foo=short_zuser(owl_message_get_recipient(m));
    716     owl_fmtext_append_normal(fm, foo);
    717     owl_free(foo);
    718     owl_fmtext_append_normal(fm, "  (Zsig: ");
    719    
    720     zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
    721     owl_message_pretty_zsig(m, zsigbuff);
    722     owl_fmtext_append_ztext(fm, zsigbuff);
    723     owl_free(zsigbuff);
    724    
    725     owl_fmtext_append_normal(fm, ")");
    726     owl_fmtext_append_normal(fm, "\n");
    727     owl_fmtext_append_ztext(fm, indent);
    728     if (text[strlen(text)-1]!='\n') {
    729       owl_fmtext_append_normal(fm, "\n");
    730     }
    731    
    732     owl_free(indent);
    733   } else if (owl_message_is_type_aim(m)) {
    734     char *indent;
    735    
    736     if (owl_message_is_loginout(m)) {
    737       owl_fmtext_append_normal(fm, OWL_TABSTR);
    738       if (owl_message_is_login(m)) {
    739         owl_fmtext_append_bold(fm, "AIM LOGIN");
    740       } else {
    741         owl_fmtext_append_bold(fm, "AIM LOGOUT");
    742       }
    743       owl_fmtext_append_normal(fm, " for ");
    744       owl_fmtext_append_normal(fm, owl_message_get_sender(m));
    745       owl_fmtext_append_normal(fm, "\n");
    746     } else if (owl_message_is_direction_in(m)) {
    747       indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
    748       owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
    749       owl_fmtext_append_bold(fm, OWL_TABSTR);
    750       owl_fmtext_append_bold(fm, "AIM from ");
    751       owl_fmtext_append_bold(fm, owl_message_get_sender(m));
    752       owl_fmtext_append_bold(fm, "\n");
    753       owl_fmtext_append_bold(fm, indent);
    754       if (indent[strlen(indent)-1]!='\n') {
    755         owl_fmtext_append_normal(fm, "\n");
    756       }
    757       owl_free(indent);
    758     } else if (owl_message_is_direction_out(m)) {
    759       indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
    760       owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
    761       owl_fmtext_append_normal(fm, OWL_TABSTR);
    762       owl_fmtext_append_normal(fm, "AIM sent to ");
    763       owl_fmtext_append_normal(fm, owl_message_get_recipient(m));
    764       owl_fmtext_append_normal(fm, "\n");
    765       owl_fmtext_append_ztext(fm, indent);
    766       if (indent[strlen(indent)-1]!='\n') {
    767         owl_fmtext_append_normal(fm, "\n");
    768       }
    769       owl_free(indent);
    770     }
    771   } else if (owl_message_is_type_admin(m)) {
    772     char *text, *header, *indent;
    773    
    774     text=owl_message_get_body(m);
    775     header=owl_message_get_attribute_value(m, "adminheader");
    776    
    777     indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    778     owl_text_indent(indent, text, OWL_MSGTAB);
    779     owl_fmtext_append_normal(fm, OWL_TABSTR);
    780     owl_fmtext_append_bold(fm, "OWL ADMIN ");
    781     owl_fmtext_append_ztext(fm, header);
    782     owl_fmtext_append_normal(fm, "\n");
    783     owl_fmtext_append_ztext(fm, indent);
    784     if (text[strlen(text)-1]!='\n') {
    785       owl_fmtext_append_normal(fm, "\n");
    786     }
    787    
    788     owl_free(indent);
    789   } else {
    790 
    791   }
    792 }
Note: See TracChangeset for help on using the changeset viewer.