Changeset bc9436f


Ignore:
Timestamp:
Jan 16, 2007, 12:14:33 PM (18 years ago)
Author:
Nelson Elhage <nelhage@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:
e1b197e8
Parents:
f3c1aba
git-author:
Nelson Elhage <nelhage@mit.edu> (01/16/07 12:14:30)
git-committer:
Nelson Elhage <nelhage@mit.edu> (01/16/07 12:14:33)
Message:
Refactoring rendering the body of messages into a separate
function. (The stylefunc code scares me)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • stylefunc.c

    r789462a rbc9436f  
    66 * initialized.
    77 */
    8    
     8
     9void owl_style_basic_format_body(owl_fmtext *fm, owl_message *m) {
     10  char *indent, *body;
     11
     12  /* get the body */
     13  body=owl_strdup(owl_message_get_body(m));
     14  body=realloc(body, strlen(body)+30);
     15
     16  /* add a newline if we need to */
     17  if (body[0]!='\0' && body[strlen(body)-1]!='\n') {
     18    strcat(body, "\n");
     19  }
     20
     21  /* do the indenting into indent */
     22  indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10);
     23  owl_text_indent(indent, body, OWL_MSGTAB);
     24  owl_fmtext_append_ztext(fm, indent);
     25
     26  owl_free(indent);
     27  owl_free(body);
     28}
     29 
    930void owl_stylefunc_basic(owl_fmtext *fm, owl_message *m)
    1031{
    1132#ifdef HAVE_LIBZEPHYR
    12   char *body, *indent, *ptr, *zsigbuff, frombuff[LINE];
     33  char *ptr, *zsigbuff, frombuff[LINE];
    1334  ZNotice_t *n;
    1435#endif
     
    1839    n=owl_message_get_notice(m);
    1940 
    20     /* get the body */
    21     body=owl_strdup(owl_message_get_body(m));
    22     body=realloc(body, strlen(body)+30);
    23 
    24     /* add a newline if we need to */
    25     if (body[0]!='\0' && body[strlen(body)-1]!='\n') {
    26       strcat(body, "\n");
    27     }
    28    
    29     /* do the indenting into indent */
    30     indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10);
    31     owl_text_indent(indent, body, OWL_MSGTAB);
    32    
    3341    /* edit the from addr for printing */
    3442    strcpy(frombuff, owl_message_get_sender(m));
     
    95103     
    96104      /* then the indented message */
    97       owl_fmtext_append_ztext(fm, indent);
     105      owl_style_basic_format_body(fm, m);
    98106     
    99107      /* make personal messages bold for smaat users */
     
    105113    }
    106114   
     115#endif
     116  } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) {
     117    char *zsigbuff, *foo;
     118    owl_fmtext_append_normal(fm, OWL_TABSTR);
     119    owl_fmtext_append_normal(fm, "To: ");
     120    foo=short_zuser(owl_message_get_recipient(m));
     121    owl_fmtext_append_normal(fm, foo);
     122    owl_free(foo);
     123    owl_fmtext_append_normal(fm, "  (Zsig: ");
     124   
     125    zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
     126    owl_message_pretty_zsig(m, zsigbuff);
     127    owl_fmtext_append_ztext(fm, zsigbuff);
     128    owl_free(zsigbuff);
     129   
     130    owl_fmtext_append_normal(fm, ")");
     131    owl_fmtext_append_normal(fm, "\n");
     132    owl_style_basic_format_body(fm, m);
     133  } else if (owl_message_is_type_aim(m)) {
     134    if (owl_message_is_loginout(m)) {
     135      owl_fmtext_append_normal(fm, OWL_TABSTR);
     136      if (owl_message_is_login(m)) {
     137        owl_fmtext_append_bold(fm, "AIM LOGIN");
     138      } else {
     139        owl_fmtext_append_bold(fm, "AIM LOGOUT");
     140      }
     141      owl_fmtext_append_normal(fm, " for ");
     142      owl_fmtext_append_normal(fm, owl_message_get_sender(m));
     143      owl_fmtext_append_normal(fm, "\n");
     144    } else if (owl_message_is_direction_in(m)) {
     145      owl_fmtext_append_bold(fm, OWL_TABSTR);
     146      owl_fmtext_append_bold(fm, "AIM from ");
     147      owl_fmtext_append_bold(fm, owl_message_get_sender(m));
     148      owl_fmtext_append_bold(fm, "\n");
     149      owl_style_basic_format_body(fm, m);
     150    } else if (owl_message_is_direction_out(m)) {
     151      owl_fmtext_append_normal(fm, OWL_TABSTR);
     152      owl_fmtext_append_normal(fm, "AIM sent to ");
     153      owl_fmtext_append_normal(fm, owl_message_get_recipient(m));
     154      owl_fmtext_append_normal(fm, "\n");
     155      owl_style_basic_format_body(fm, m);
     156    }
     157  } else if (owl_message_is_type_admin(m)) {
     158    char *text, *header;
     159   
     160    text=owl_message_get_body(m);
     161    header=owl_message_get_attribute_value(m, "adminheader");
     162
     163    owl_fmtext_append_normal(fm, OWL_TABSTR);
     164    owl_fmtext_append_bold(fm, "OWL ADMIN ");
     165    owl_fmtext_append_ztext(fm, header);
     166    owl_fmtext_append_normal(fm, "\n");
     167    owl_style_basic_format_body(fm, m);
     168  } else {
     169    char *header;
     170
     171    header=owl_sprintf("%s from: %s to: %s",
     172                       owl_message_get_type(m),
     173                       owl_message_get_sender(m),
     174                       owl_message_get_recipient(m));
     175
     176    owl_fmtext_append_normal(fm, OWL_TABSTR);
     177    owl_fmtext_append_normal(fm, header);
     178    owl_fmtext_append_normal(fm, "\n");
     179    owl_style_basic_format_body(fm, m);
     180   
     181    owl_free(header);
     182  }
     183}
     184
     185void owl_stylefunc_default(owl_fmtext *fm, owl_message *m)
     186{
     187  char *shorttimestr;
     188#ifdef HAVE_LIBZEPHYR
     189  char *ptr, *zsigbuff, frombuff[LINE];
     190  ZNotice_t *n;
     191#endif
     192
     193  shorttimestr=owl_message_get_shorttimestr(m);
     194
     195  if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
     196#ifdef HAVE_LIBZEPHYR
     197    n=owl_message_get_notice(m);
     198
     199    /* edit the from addr for printing */
     200    strcpy(frombuff, owl_message_get_sender(m));
     201    ptr=strchr(frombuff, '@');
     202    if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
     203      *ptr='\0';
     204    }
     205   
     206    /* set the message for printing */
     207    owl_fmtext_append_normal(fm, OWL_TABSTR);
     208   
     209    if (owl_message_is_ping(m) && owl_message_is_private(m)) {
     210      owl_fmtext_append_bold(fm, "PING");
     211      owl_fmtext_append_normal(fm, " from ");
     212      owl_fmtext_append_bold(fm, frombuff);
     213      owl_fmtext_append_normal(fm, "\n");
     214    } else if (owl_message_is_loginout(m)) {
     215      char *host, *tty;
     216     
     217      host=owl_message_get_attribute_value(m, "loginhost");
     218      tty=owl_message_get_attribute_value(m, "logintty");
     219     
     220      if (owl_message_is_login(m)) {
     221        owl_fmtext_append_bold(fm, "LOGIN");
     222      } else if (owl_message_is_logout(m)) {
     223        owl_fmtext_append_bold(fm, "LOGOUT");
     224      }
     225
     226      if (owl_message_is_pseudo(m)) owl_fmtext_append_bold(fm, " (PSEUDO)");
     227       
     228      owl_fmtext_append_normal(fm, " for ");
     229      ptr=short_zuser(owl_message_get_instance(m));
     230      owl_fmtext_append_bold(fm, ptr);
     231      owl_free(ptr);
     232      owl_fmtext_append_normal(fm, " at ");
     233      owl_fmtext_append_normal(fm, host ? host : "");
     234      owl_fmtext_append_normal(fm, " ");
     235      owl_fmtext_append_normal(fm, tty ? tty : "");
     236      owl_fmtext_append_normal(fm, " ");
     237      owl_fmtext_append_normal(fm, shorttimestr);
     238      owl_fmtext_append_normal(fm, "\n");
     239    } else {
     240      owl_fmtext_append_normal(fm, owl_message_get_class(m));
     241      owl_fmtext_append_normal(fm, " / ");
     242      owl_fmtext_append_normal(fm, owl_message_get_instance(m));
     243      owl_fmtext_append_normal(fm, " / ");
     244      owl_fmtext_append_bold(fm, frombuff);
     245      if (strcasecmp(owl_message_get_realm(m), ZGetRealm())) {
     246        owl_fmtext_append_normal(fm, " {");
     247        owl_fmtext_append_normal(fm, owl_message_get_realm(m));
     248        owl_fmtext_append_normal(fm, "}");
     249      }
     250      if (strcmp(owl_message_get_opcode(m), "")) {
     251        owl_fmtext_append_normal(fm, " [");
     252        owl_fmtext_append_normal(fm, owl_message_get_opcode(m));
     253        owl_fmtext_append_normal(fm, "]");
     254      }
     255
     256      owl_fmtext_append_normal(fm, "  ");
     257      owl_fmtext_append_normal(fm, shorttimestr);
     258
     259      /* stick on the zsig */
     260      zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
     261      owl_message_pretty_zsig(m, zsigbuff);
     262      owl_fmtext_append_normal(fm, "    (");
     263      owl_fmtext_append_ztext(fm, zsigbuff);
     264      owl_fmtext_append_normal(fm, ")");
     265      owl_fmtext_append_normal(fm, "\n");
     266      owl_free(zsigbuff);
     267     
     268      owl_style_basic_format_body(fm, m);
     269     
     270      /* make private messages bold for smaat users */
     271      if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
     272        if (owl_message_is_personal(m)) {
     273          owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD);
     274        }
     275      }
     276    }
     277   
     278#endif
     279  } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) {
     280    char *zsigbuff, *foo;
     281   
     282    owl_fmtext_append_normal(fm, OWL_TABSTR);
     283    owl_fmtext_append_normal(fm, "Zephyr sent to ");
     284    foo=short_zuser(owl_message_get_recipient(m));
     285    owl_fmtext_append_normal(fm, foo);
     286    owl_free(foo);
     287
     288    owl_fmtext_append_normal(fm, "  ");
     289    owl_fmtext_append_normal(fm, shorttimestr);
     290
     291    owl_fmtext_append_normal(fm, "  (Zsig: ");
     292   
     293    zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
     294    owl_message_pretty_zsig(m, zsigbuff);
     295    owl_fmtext_append_ztext(fm, zsigbuff);
     296    owl_free(zsigbuff);
     297   
     298    owl_fmtext_append_normal(fm, ")");
     299    owl_fmtext_append_normal(fm, "\n");
     300    owl_style_basic_format_body(fm, m);
     301  } else if (owl_message_is_type_aim(m)) {
     302    if (owl_message_is_loginout(m)) {
     303      owl_fmtext_append_normal(fm, OWL_TABSTR);
     304      if (owl_message_is_login(m)) {
     305        owl_fmtext_append_bold(fm, "AIM LOGIN");
     306      } else {
     307        owl_fmtext_append_bold(fm, "AIM LOGOUT");
     308      }
     309      owl_fmtext_append_normal(fm, " for ");
     310      owl_fmtext_append_normal(fm, owl_message_get_sender(m));
     311      owl_fmtext_append_normal(fm, " ");
     312      owl_fmtext_append_normal(fm, shorttimestr);
     313      owl_fmtext_append_normal(fm, "\n");
     314    } else if (owl_message_is_direction_in(m)) {
     315      owl_fmtext_append_bold(fm, OWL_TABSTR);
     316      owl_fmtext_append_bold(fm, "AIM from ");
     317      owl_fmtext_append_bold(fm, owl_message_get_sender(m));
     318     
     319      owl_fmtext_append_normal(fm, "  ");
     320      owl_fmtext_append_normal(fm, shorttimestr);
     321
     322      owl_fmtext_append_bold(fm, "\n");
     323      owl_style_basic_format_body(fm, m);
     324    } else if (owl_message_is_direction_out(m)) {
     325      owl_fmtext_append_normal(fm, OWL_TABSTR);
     326      owl_fmtext_append_normal(fm, "AIM sent to ");
     327      owl_fmtext_append_normal(fm, owl_message_get_recipient(m));
     328      owl_fmtext_append_normal(fm, "  ");
     329      owl_fmtext_append_normal(fm, shorttimestr);
     330      owl_fmtext_append_normal(fm, "\n");
     331      owl_style_basic_format_body(fm, m);
     332    }
     333  } else if (owl_message_is_type_admin(m)) {
     334    char *header;
     335   
     336    header=owl_message_get_attribute_value(m, "adminheader");
     337   
     338    owl_fmtext_append_normal(fm, OWL_TABSTR);
     339    owl_fmtext_append_bold(fm, "OWL ADMIN ");
     340    owl_fmtext_append_ztext(fm, header);
     341    owl_fmtext_append_normal(fm, "\n");
     342    owl_style_basic_format_body(fm, m);
     343  } else {
     344    char *header;
     345   
     346    header=owl_sprintf("%s from: %s to: %s",
     347                       owl_message_get_type(m),
     348                       owl_message_get_sender(m),
     349                       owl_message_get_recipient(m));
     350   
     351    owl_fmtext_append_normal(fm, OWL_TABSTR);
     352    owl_fmtext_append_normal(fm, header);
     353    owl_fmtext_append_normal(fm, "  ");
     354    owl_fmtext_append_normal(fm, shorttimestr);
     355    owl_fmtext_append_normal(fm, "\n");
     356    owl_style_basic_format_body(fm, m);
     357  }
     358  owl_free(shorttimestr);
     359}
     360
     361void owl_stylefunc_oneline(owl_fmtext *fm, owl_message *m)
     362{
     363  char *tmp;
     364  char *baseformat="%s %-13.13s %-11.11s %-12.12s ";
     365  char *sender, *recip;
     366#ifdef HAVE_LIBZEPHYR
     367  ZNotice_t *n;
     368#endif
     369
     370  sender=short_zuser(owl_message_get_sender(m));
     371  recip=short_zuser(owl_message_get_recipient(m));
     372 
     373  if (owl_message_is_type_zephyr(m)) {
     374#ifdef HAVE_LIBZEPHYR
     375    n=owl_message_get_notice(m);
     376   
     377    owl_fmtext_append_spaces(fm, OWL_TAB);
     378
     379    if (owl_message_is_loginout(m)) {
     380      char *host, *tty;
     381     
     382      host=owl_message_get_attribute_value(m, "loginhost");
     383      tty=owl_message_get_attribute_value(m, "logintty");
     384
     385      if (owl_message_is_login(m)) {
     386        tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGIN-P":"LOGIN", "", sender);
     387        owl_fmtext_append_normal(fm, tmp);
     388        owl_free(tmp);
     389      } else if (owl_message_is_logout(m)) {
     390        tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGOUT-P":"LOGOUT", "", sender);
     391        owl_fmtext_append_normal(fm, tmp);
     392        owl_free(tmp);
     393      }
     394
     395      owl_fmtext_append_normal(fm, "at ");
     396      owl_fmtext_append_normal(fm, host ? host : "");
     397      owl_fmtext_append_normal(fm, " ");
     398      owl_fmtext_append_normal(fm, tty ? tty : "");
     399      owl_fmtext_append_normal(fm, "\n");
     400
     401    } else if (owl_message_is_ping(m)) {
     402      tmp=owl_sprintf(baseformat, "<", "PING", "", sender);
     403      owl_fmtext_append_normal(fm, tmp);
     404      owl_fmtext_append_normal(fm, "\n");
     405      owl_free(tmp);
     406
     407    } else {
     408      if (owl_message_is_direction_in(m)) {
     409        tmp=owl_sprintf(baseformat, "<", owl_message_get_class(m), owl_message_get_instance(m), sender);
     410      } else if (owl_message_is_direction_out(m)) {
     411        tmp=owl_sprintf(baseformat, ">", owl_message_get_class(m), owl_message_get_instance(m), recip);
     412      } else {
     413        tmp=owl_sprintf(baseformat, "-", owl_message_get_class(m), owl_message_get_instance(m), sender);
     414      }
     415      owl_fmtext_append_normal(fm, tmp);
     416      if (tmp) owl_free(tmp);
     417     
     418      tmp=owl_strdup(owl_message_get_body(m));
     419      owl_text_tr(tmp, '\n', ' ');
     420      owl_fmtext_append_ztext(fm, tmp);
     421      owl_fmtext_append_normal(fm, "\n");
     422      if (tmp) owl_free(tmp);
     423    }
     424     
     425    /* make personal messages bold for smaat users */
     426    if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) &&
     427        owl_message_is_personal(m) &&
     428        owl_message_is_direction_in(m)) {
     429      owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
     430    }
     431
     432    owl_free(sender);
     433    owl_free(recip);
     434#endif
     435  } else if (owl_message_is_type_aim(m)) {
     436    owl_fmtext_append_spaces(fm, OWL_TAB);
     437    if (owl_message_is_login(m)) {
     438      tmp=owl_sprintf(baseformat, "<", "AIM LOGIN", "", owl_message_get_sender(m));
     439      owl_fmtext_append_normal(fm, tmp);
     440      owl_fmtext_append_normal(fm, "\n");
     441      if (tmp) owl_free(tmp);
     442    } else if (owl_message_is_logout(m)) {
     443      tmp=owl_sprintf(baseformat, "<", "AIM LOGOUT", "", owl_message_get_sender(m));
     444      owl_fmtext_append_normal(fm, tmp);
     445      owl_fmtext_append_normal(fm, "\n");
     446      if (tmp) owl_free(tmp);
     447    } else {
     448      if (owl_message_is_direction_in(m)) {
     449        tmp=owl_sprintf(baseformat, "<", "AIM", "", owl_message_get_sender(m));
     450        owl_fmtext_append_normal(fm, tmp);
     451        if (tmp) owl_free(tmp);
     452      } else if (owl_message_is_direction_out(m)) {
     453        tmp=owl_sprintf(baseformat, ">", "AIM", "", owl_message_get_recipient(m));
     454        owl_fmtext_append_normal(fm, tmp);
     455        if (tmp) owl_free(tmp);
     456      }
     457     
     458      tmp=owl_strdup(owl_message_get_body(m));
     459      owl_text_tr(tmp, '\n', ' ');
     460      owl_fmtext_append_normal(fm, tmp);
     461      owl_fmtext_append_normal(fm, "\n");
     462      if (tmp) owl_free(tmp);
     463
     464      /* make personal messages bold for smaat users */
     465      if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && owl_message_is_direction_in(m)) {
     466        owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
     467      }
     468    }
     469  } else if (owl_message_is_type_admin(m)) {
     470    owl_fmtext_append_spaces(fm, OWL_TAB);
     471    owl_fmtext_append_normal(fm, "< ADMIN                                  ");
     472   
     473    tmp=owl_strdup(owl_message_get_body(m));
     474    owl_text_tr(tmp, '\n', ' ');
     475    owl_fmtext_append_normal(fm, tmp);
     476    owl_fmtext_append_normal(fm, "\n");
     477    if (tmp) owl_free(tmp);
     478  } else {
     479    owl_fmtext_append_spaces(fm, OWL_TAB);
     480    owl_fmtext_append_normal(fm, "< LOOPBACK                               ");
     481   
     482    tmp=owl_strdup(owl_message_get_body(m));
     483    owl_text_tr(tmp, '\n', ' ');
     484    owl_fmtext_append_normal(fm, tmp);
     485    owl_fmtext_append_normal(fm, "\n");
     486    if (tmp) owl_free(tmp);
     487  }   
     488
     489}
     490
     491void owl_stylefunc_vt(owl_fmtext *fm, owl_message *m)
     492{
     493#ifdef HAVE_LIBZEPHYR
     494  char *body, *indent, *ptr, frombuff[LINE];
     495  owl_fmtext fm_first, fm_other, fm_tmp;
     496  ZNotice_t *n;
     497#endif
     498  char *sender, *hostname, *timestr, *classinst1, *classinst2;
     499
     500  if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
     501#ifdef HAVE_LIBZEPHYR
     502    n=owl_message_get_notice(m);
     503
     504    /* get the body */
     505    body=owl_malloc(strlen(owl_message_get_body(m))+30);
     506    strcpy(body, owl_message_get_body(m));
     507   
     508    /* add a newline if we need to */
     509    if (body[0]!='\0' && body[strlen(body)-1]!='\n') {
     510      strcat(body, "\n");
     511    }
     512
     513    owl_fmtext_init_null(&fm_tmp);
     514    owl_fmtext_append_ztext(&fm_tmp, body);
     515    owl_fmtext_init_null(&fm_first);
     516    owl_fmtext_truncate_lines(&fm_tmp, 0, 1, &fm_first);
     517
     518    /* do the indenting into indent */
     519    indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10);
     520    owl_text_indent(indent, body, 31);
     521
     522    owl_fmtext_free(&fm_tmp);
     523    owl_fmtext_init_null(&fm_tmp);
     524    owl_fmtext_append_ztext(&fm_tmp, indent);
     525    owl_fmtext_init_null(&fm_other);
     526    owl_fmtext_truncate_lines(&fm_tmp, 1, owl_fmtext_num_lines(&fm_tmp)-1, &fm_other);
     527    owl_fmtext_free(&fm_tmp);
     528   
     529    /* edit the from addr for printing */
     530    strcpy(frombuff, owl_message_get_sender(m));
     531    ptr=strchr(frombuff, '@');
     532    if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
     533      *ptr='\0';
     534    }
     535    sender=owl_sprintf("%-9.9s", frombuff);
     536
     537    hostname=owl_sprintf("%-9.9s", owl_message_get_hostname(m));
     538    timestr=owl_strdup("00:00");
     539    classinst1=owl_sprintf("<%s>[%s]", owl_message_get_class(m), owl_message_get_instance(m));
     540    classinst2=owl_sprintf("%-9.9s", classinst1);
     541   
     542    /* set the message for printing */
     543    owl_fmtext_append_normal(fm, OWL_TABSTR);
     544   
     545    if (owl_message_is_ping(m) && owl_message_is_private(m)) {
     546      owl_fmtext_append_bold(fm, "PING");
     547      owl_fmtext_append_normal(fm, " from ");
     548      owl_fmtext_append_bold(fm, frombuff);
     549      owl_fmtext_append_normal(fm, "\n");
     550    } else if (owl_message_is_loginout(m)) {
     551      char *host, *tty;
     552     
     553      host=owl_message_get_attribute_value(m, "loginhost");
     554      tty=owl_message_get_attribute_value(m, "logintty");
     555     
     556      if (owl_message_is_login(m)) {
     557        owl_fmtext_append_bold(fm, "LOGIN");
     558      } else if (owl_message_is_logout(m)) {
     559        owl_fmtext_append_bold(fm, "LOGOUT");
     560      }
     561      if (owl_message_is_pseudo(m)) owl_fmtext_append_bold(fm, " (PSEUDO)");
     562
     563      owl_fmtext_append_normal(fm, " for ");
     564      ptr=short_zuser(owl_message_get_instance(m));
     565      owl_fmtext_append_bold(fm, ptr);
     566      owl_free(ptr);
     567      owl_fmtext_append_normal(fm, " at ");
     568      owl_fmtext_append_normal(fm, host ? host : "");
     569      owl_fmtext_append_normal(fm, " ");
     570      owl_fmtext_append_normal(fm, tty ? tty : "");
     571      owl_fmtext_append_normal(fm, "\n");
     572    } else {
     573      owl_fmtext_append_normal(fm, sender);
     574      owl_fmtext_append_normal(fm, "|");
     575      owl_fmtext_append_normal(fm, hostname);
     576      owl_fmtext_append_normal(fm, " ");
     577      owl_fmtext_append_normal(fm, timestr);
     578      owl_fmtext_append_normal(fm, " ");
     579      owl_fmtext_append_normal(fm, classinst2);
     580
     581      owl_fmtext_append_normal(fm, "   ");
     582      owl_fmtext_append_fmtext(fm, &fm_first);
     583      owl_fmtext_append_fmtext(fm, &fm_other);
     584
     585      owl_fmtext_free(&fm_other);
     586      owl_fmtext_free(&fm_first);
     587     
     588      /* make private messages bold for smaat users */
     589      if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
     590        if (owl_message_is_personal(m)) {
     591          owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD);
     592        }
     593      }
     594    }
     595
     596    owl_free(sender);
     597    owl_free(hostname);
     598    owl_free(timestr);
     599    owl_free(classinst1);
     600    owl_free(classinst2);
     601   
    107602    owl_free(body);
    108603    owl_free(indent);
     
    110605  } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) {
    111606    char *indent, *text, *zsigbuff, *foo;
    112      
     607   
    113608    text=owl_message_get_body(m);
    114609   
     
    116611    owl_text_indent(indent, text, OWL_MSGTAB);
    117612    owl_fmtext_append_normal(fm, OWL_TABSTR);
    118     owl_fmtext_append_normal(fm, "To: ");
     613    owl_fmtext_append_normal(fm, "Zephyr sent to ");
    119614    foo=short_zuser(owl_message_get_recipient(m));
    120615    owl_fmtext_append_normal(fm, foo);
     
    192687    owl_free(indent);
    193688  } else {
    194     char *text, *header, *indent;
    195    
    196     text=owl_message_get_body(m);
    197     header=owl_sprintf("%s from: %s to: %s",
    198                        owl_message_get_type(m),
    199                        owl_message_get_sender(m),
    200                        owl_message_get_recipient(m));
    201    
    202     indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    203     owl_text_indent(indent, text, OWL_MSGTAB);
    204     owl_fmtext_append_normal(fm, OWL_TABSTR);
    205     owl_fmtext_append_normal(fm, header);
    206     owl_fmtext_append_normal(fm, "\n");
    207     owl_fmtext_append_normal(fm, indent);
    208     if (text[strlen(text)-1]!='\n') {
    209       owl_fmtext_append_normal(fm, "\n");
    210     }
    211    
    212     owl_free(indent);
    213     owl_free(header);
     689
    214690  }
    215691}
    216 
    217 void owl_stylefunc_default(owl_fmtext *fm, owl_message *m)
    218 {
    219   char *shorttimestr;
    220 #ifdef HAVE_LIBZEPHYR
    221   char *body, *indent, *ptr, *zsigbuff, frombuff[LINE];
    222   ZNotice_t *n;
    223 #endif
    224 
    225   shorttimestr=owl_message_get_shorttimestr(m);
    226 
    227   if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
    228 #ifdef HAVE_LIBZEPHYR
    229     n=owl_message_get_notice(m);
    230 
    231     /* get the body */
    232     body=owl_malloc(strlen(owl_message_get_body(m))+30);
    233     strcpy(body, owl_message_get_body(m));
    234    
    235     /* add a newline if we need to */
    236     if (body[0]!='\0' && body[strlen(body)-1]!='\n') {
    237       strcat(body, "\n");
    238     }
    239    
    240     /* do the indenting into indent */
    241     indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10);
    242     owl_text_indent(indent, body, OWL_MSGTAB);
    243    
    244     /* edit the from addr for printing */
    245     strcpy(frombuff, owl_message_get_sender(m));
    246     ptr=strchr(frombuff, '@');
    247     if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
    248       *ptr='\0';
    249     }
    250    
    251     /* set the message for printing */
    252     owl_fmtext_append_normal(fm, OWL_TABSTR);
    253    
    254     if (owl_message_is_ping(m) && owl_message_is_private(m)) {
    255       owl_fmtext_append_bold(fm, "PING");
    256       owl_fmtext_append_normal(fm, " from ");
    257       owl_fmtext_append_bold(fm, frombuff);
    258       owl_fmtext_append_normal(fm, "\n");
    259     } else if (owl_message_is_loginout(m)) {
    260       char *host, *tty;
    261      
    262       host=owl_message_get_attribute_value(m, "loginhost");
    263       tty=owl_message_get_attribute_value(m, "logintty");
    264      
    265       if (owl_message_is_login(m)) {
    266         owl_fmtext_append_bold(fm, "LOGIN");
    267       } else if (owl_message_is_logout(m)) {
    268         owl_fmtext_append_bold(fm, "LOGOUT");
    269       }
    270 
    271       if (owl_message_is_pseudo(m)) owl_fmtext_append_bold(fm, " (PSEUDO)");
    272        
    273       owl_fmtext_append_normal(fm, " for ");
    274       ptr=short_zuser(owl_message_get_instance(m));
    275       owl_fmtext_append_bold(fm, ptr);
    276       owl_free(ptr);
    277       owl_fmtext_append_normal(fm, " at ");
    278       owl_fmtext_append_normal(fm, host ? host : "");
    279       owl_fmtext_append_normal(fm, " ");
    280       owl_fmtext_append_normal(fm, tty ? tty : "");
    281       owl_fmtext_append_normal(fm, " ");
    282       owl_fmtext_append_normal(fm, shorttimestr);
    283       owl_fmtext_append_normal(fm, "\n");
    284     } else {
    285       owl_fmtext_append_normal(fm, owl_message_get_class(m));
    286       owl_fmtext_append_normal(fm, " / ");
    287       owl_fmtext_append_normal(fm, owl_message_get_instance(m));
    288       owl_fmtext_append_normal(fm, " / ");
    289       owl_fmtext_append_bold(fm, frombuff);
    290       if (strcasecmp(owl_message_get_realm(m), ZGetRealm())) {
    291         owl_fmtext_append_normal(fm, " {");
    292         owl_fmtext_append_normal(fm, owl_message_get_realm(m));
    293         owl_fmtext_append_normal(fm, "}");
    294       }
    295       if (strcmp(owl_message_get_opcode(m), "")) {
    296         owl_fmtext_append_normal(fm, " [");
    297         owl_fmtext_append_normal(fm, owl_message_get_opcode(m));
    298         owl_fmtext_append_normal(fm, "]");
    299       }
    300 
    301       owl_fmtext_append_normal(fm, "  ");
    302       owl_fmtext_append_normal(fm, shorttimestr);
    303 
    304       /* stick on the zsig */
    305       zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
    306       owl_message_pretty_zsig(m, zsigbuff);
    307       owl_fmtext_append_normal(fm, "    (");
    308       owl_fmtext_append_ztext(fm, zsigbuff);
    309       owl_fmtext_append_normal(fm, ")");
    310       owl_fmtext_append_normal(fm, "\n");
    311       owl_free(zsigbuff);
    312      
    313       /* then the indented message */
    314       owl_fmtext_append_ztext(fm, indent);
    315      
    316       /* make private messages bold for smaat users */
    317       if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
    318         if (owl_message_is_personal(m)) {
    319           owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD);
    320         }
    321       }
    322     }
    323    
    324     owl_free(body);
    325     owl_free(indent);
    326 #endif
    327   } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) {
    328     char *indent, *text, *zsigbuff, *foo;
    329    
    330     text=owl_message_get_body(m);
    331    
    332     indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    333     owl_text_indent(indent, text, OWL_MSGTAB);
    334     owl_fmtext_append_normal(fm, OWL_TABSTR);
    335     owl_fmtext_append_normal(fm, "Zephyr sent to ");
    336     foo=short_zuser(owl_message_get_recipient(m));
    337     owl_fmtext_append_normal(fm, foo);
    338     owl_free(foo);
    339 
    340     owl_fmtext_append_normal(fm, "  ");
    341     owl_fmtext_append_normal(fm, shorttimestr);
    342 
    343     owl_fmtext_append_normal(fm, "  (Zsig: ");
    344    
    345     zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
    346     owl_message_pretty_zsig(m, zsigbuff);
    347     owl_fmtext_append_ztext(fm, zsigbuff);
    348     owl_free(zsigbuff);
    349    
    350     owl_fmtext_append_normal(fm, ")");
    351     owl_fmtext_append_normal(fm, "\n");
    352     owl_fmtext_append_ztext(fm, indent);
    353     if (text[strlen(text)-1]!='\n') {
    354       owl_fmtext_append_normal(fm, "\n");
    355     }
    356    
    357     owl_free(indent);
    358   } else if (owl_message_is_type_aim(m)) {
    359     char *indent;
    360    
    361     if (owl_message_is_loginout(m)) {
    362       owl_fmtext_append_normal(fm, OWL_TABSTR);
    363       if (owl_message_is_login(m)) {
    364         owl_fmtext_append_bold(fm, "AIM LOGIN");
    365       } else {
    366         owl_fmtext_append_bold(fm, "AIM LOGOUT");
    367       }
    368       owl_fmtext_append_normal(fm, " for ");
    369       owl_fmtext_append_normal(fm, owl_message_get_sender(m));
    370       owl_fmtext_append_normal(fm, " ");
    371       owl_fmtext_append_normal(fm, shorttimestr);
    372       owl_fmtext_append_normal(fm, "\n");
    373     } else if (owl_message_is_direction_in(m)) {
    374       indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
    375       owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
    376       owl_fmtext_append_bold(fm, OWL_TABSTR);
    377       owl_fmtext_append_bold(fm, "AIM from ");
    378       owl_fmtext_append_bold(fm, owl_message_get_sender(m));
    379      
    380       owl_fmtext_append_normal(fm, "  ");
    381       owl_fmtext_append_normal(fm, shorttimestr);
    382 
    383       owl_fmtext_append_bold(fm, "\n");
    384       owl_fmtext_append_bold(fm, indent);
    385       if (indent[strlen(indent)-1]!='\n') {
    386         owl_fmtext_append_normal(fm, "\n");
    387       }
    388       owl_free(indent);
    389     } else if (owl_message_is_direction_out(m)) {
    390       indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
    391       owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
    392       owl_fmtext_append_normal(fm, OWL_TABSTR);
    393       owl_fmtext_append_normal(fm, "AIM sent to ");
    394       owl_fmtext_append_normal(fm, owl_message_get_recipient(m));
    395       owl_fmtext_append_normal(fm, "  ");
    396       owl_fmtext_append_normal(fm, shorttimestr);
    397       owl_fmtext_append_normal(fm, "\n");
    398       owl_fmtext_append_ztext(fm, indent);
    399       if (indent[strlen(indent)-1]!='\n') {
    400         owl_fmtext_append_normal(fm, "\n");
    401       }
    402       owl_free(indent);
    403     }
    404   } else if (owl_message_is_type_admin(m)) {
    405     char *text, *header, *indent;
    406    
    407     text=owl_message_get_body(m);
    408     header=owl_message_get_attribute_value(m, "adminheader");
    409    
    410     indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    411     owl_text_indent(indent, text, OWL_MSGTAB);
    412     owl_fmtext_append_normal(fm, OWL_TABSTR);
    413     owl_fmtext_append_bold(fm, "OWL ADMIN ");
    414     owl_fmtext_append_ztext(fm, header);
    415     owl_fmtext_append_normal(fm, "\n");
    416     owl_fmtext_append_ztext(fm, indent);
    417     if (text[strlen(text)-1]!='\n') {
    418       owl_fmtext_append_normal(fm, "\n");
    419     }
    420    
    421     owl_free(indent);
    422   } else {
    423     char *text, *header, *indent;
    424    
    425     text=owl_message_get_body(m);
    426     header=owl_sprintf("%s from: %s to: %s",
    427                        owl_message_get_type(m),
    428                        owl_message_get_sender(m),
    429                        owl_message_get_recipient(m));
    430    
    431     indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    432     owl_text_indent(indent, text, OWL_MSGTAB);
    433     owl_fmtext_append_normal(fm, OWL_TABSTR);
    434     owl_fmtext_append_normal(fm, header);
    435     owl_fmtext_append_normal(fm, "  ");
    436     owl_fmtext_append_normal(fm, shorttimestr);
    437     owl_fmtext_append_normal(fm, "\n");
    438     owl_fmtext_append_normal(fm, indent);
    439     if (text[strlen(text)-1]!='\n') {
    440       owl_fmtext_append_normal(fm, "\n");
    441     }
    442    
    443     owl_free(indent);
    444     owl_free(header);
    445   }
    446   owl_free(shorttimestr);
    447 }
    448 
    449 void owl_stylefunc_oneline(owl_fmtext *fm, owl_message *m)
    450 {
    451   char *tmp;
    452   char *baseformat="%s %-13.13s %-11.11s %-12.12s ";
    453   char *sender, *recip;
    454 #ifdef HAVE_LIBZEPHYR
    455   ZNotice_t *n;
    456 #endif
    457 
    458   sender=short_zuser(owl_message_get_sender(m));
    459   recip=short_zuser(owl_message_get_recipient(m));
    460  
    461   if (owl_message_is_type_zephyr(m)) {
    462 #ifdef HAVE_LIBZEPHYR
    463     n=owl_message_get_notice(m);
    464    
    465     owl_fmtext_append_spaces(fm, OWL_TAB);
    466 
    467     if (owl_message_is_loginout(m)) {
    468       char *host, *tty;
    469      
    470       host=owl_message_get_attribute_value(m, "loginhost");
    471       tty=owl_message_get_attribute_value(m, "logintty");
    472 
    473       if (owl_message_is_login(m)) {
    474         tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGIN-P":"LOGIN", "", sender);
    475         owl_fmtext_append_normal(fm, tmp);
    476         owl_free(tmp);
    477       } else if (owl_message_is_logout(m)) {
    478         tmp=owl_sprintf(baseformat, "<", owl_message_is_pseudo(m)?"LOGOUT-P":"LOGOUT", "", sender);
    479         owl_fmtext_append_normal(fm, tmp);
    480         owl_free(tmp);
    481       }
    482 
    483       owl_fmtext_append_normal(fm, "at ");
    484       owl_fmtext_append_normal(fm, host ? host : "");
    485       owl_fmtext_append_normal(fm, " ");
    486       owl_fmtext_append_normal(fm, tty ? tty : "");
    487       owl_fmtext_append_normal(fm, "\n");
    488 
    489     } else if (owl_message_is_ping(m)) {
    490       tmp=owl_sprintf(baseformat, "<", "PING", "", sender);
    491       owl_fmtext_append_normal(fm, tmp);
    492       owl_fmtext_append_normal(fm, "\n");
    493       owl_free(tmp);
    494 
    495     } else {
    496       if (owl_message_is_direction_in(m)) {
    497         tmp=owl_sprintf(baseformat, "<", owl_message_get_class(m), owl_message_get_instance(m), sender);
    498       } else if (owl_message_is_direction_out(m)) {
    499         tmp=owl_sprintf(baseformat, ">", owl_message_get_class(m), owl_message_get_instance(m), recip);
    500       } else {
    501         tmp=owl_sprintf(baseformat, "-", owl_message_get_class(m), owl_message_get_instance(m), sender);
    502       }
    503       owl_fmtext_append_normal(fm, tmp);
    504       if (tmp) owl_free(tmp);
    505      
    506       tmp=owl_strdup(owl_message_get_body(m));
    507       owl_text_tr(tmp, '\n', ' ');
    508       owl_fmtext_append_ztext(fm, tmp);
    509       owl_fmtext_append_normal(fm, "\n");
    510       if (tmp) owl_free(tmp);
    511     }
    512      
    513     /* make personal messages bold for smaat users */
    514     if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) &&
    515         owl_message_is_personal(m) &&
    516         owl_message_is_direction_in(m)) {
    517       owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
    518     }
    519 
    520     owl_free(sender);
    521     owl_free(recip);
    522 #endif
    523   } else if (owl_message_is_type_aim(m)) {
    524     owl_fmtext_append_spaces(fm, OWL_TAB);
    525     if (owl_message_is_login(m)) {
    526       tmp=owl_sprintf(baseformat, "<", "AIM LOGIN", "", owl_message_get_sender(m));
    527       owl_fmtext_append_normal(fm, tmp);
    528       owl_fmtext_append_normal(fm, "\n");
    529       if (tmp) owl_free(tmp);
    530     } else if (owl_message_is_logout(m)) {
    531       tmp=owl_sprintf(baseformat, "<", "AIM LOGOUT", "", owl_message_get_sender(m));
    532       owl_fmtext_append_normal(fm, tmp);
    533       owl_fmtext_append_normal(fm, "\n");
    534       if (tmp) owl_free(tmp);
    535     } else {
    536       if (owl_message_is_direction_in(m)) {
    537         tmp=owl_sprintf(baseformat, "<", "AIM", "", owl_message_get_sender(m));
    538         owl_fmtext_append_normal(fm, tmp);
    539         if (tmp) owl_free(tmp);
    540       } else if (owl_message_is_direction_out(m)) {
    541         tmp=owl_sprintf(baseformat, ">", "AIM", "", owl_message_get_recipient(m));
    542         owl_fmtext_append_normal(fm, tmp);
    543         if (tmp) owl_free(tmp);
    544       }
    545      
    546       tmp=owl_strdup(owl_message_get_body(m));
    547       owl_text_tr(tmp, '\n', ' ');
    548       owl_fmtext_append_normal(fm, tmp);
    549       owl_fmtext_append_normal(fm, "\n");
    550       if (tmp) owl_free(tmp);
    551 
    552       /* make personal messages bold for smaat users */
    553       if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES) && owl_message_is_direction_in(m)) {
    554         owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
    555       }
    556     }
    557   } else if (owl_message_is_type_admin(m)) {
    558     owl_fmtext_append_spaces(fm, OWL_TAB);
    559     owl_fmtext_append_normal(fm, "< ADMIN                                  ");
    560    
    561     tmp=owl_strdup(owl_message_get_body(m));
    562     owl_text_tr(tmp, '\n', ' ');
    563     owl_fmtext_append_normal(fm, tmp);
    564     owl_fmtext_append_normal(fm, "\n");
    565     if (tmp) owl_free(tmp);
    566   } else {
    567     owl_fmtext_append_spaces(fm, OWL_TAB);
    568     owl_fmtext_append_normal(fm, "< LOOPBACK                               ");
    569    
    570     tmp=owl_strdup(owl_message_get_body(m));
    571     owl_text_tr(tmp, '\n', ' ');
    572     owl_fmtext_append_normal(fm, tmp);
    573     owl_fmtext_append_normal(fm, "\n");
    574     if (tmp) owl_free(tmp);
    575   }   
    576 
    577 }
    578 
    579 void owl_stylefunc_vt(owl_fmtext *fm, owl_message *m)
    580 {
    581 #ifdef HAVE_LIBZEPHYR
    582   char *body, *indent, *ptr, frombuff[LINE];
    583   owl_fmtext fm_first, fm_other, fm_tmp;
    584   ZNotice_t *n;
    585 #endif
    586   char *sender, *hostname, *timestr, *classinst1, *classinst2;
    587 
    588   if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
    589 #ifdef HAVE_LIBZEPHYR
    590     n=owl_message_get_notice(m);
    591 
    592     /* get the body */
    593     body=owl_malloc(strlen(owl_message_get_body(m))+30);
    594     strcpy(body, owl_message_get_body(m));
    595    
    596     /* add a newline if we need to */
    597     if (body[0]!='\0' && body[strlen(body)-1]!='\n') {
    598       strcat(body, "\n");
    599     }
    600 
    601     owl_fmtext_init_null(&fm_tmp);
    602     owl_fmtext_append_ztext(&fm_tmp, body);
    603     owl_fmtext_init_null(&fm_first);
    604     owl_fmtext_truncate_lines(&fm_tmp, 0, 1, &fm_first);
    605 
    606     /* do the indenting into indent */
    607     indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10);
    608     owl_text_indent(indent, body, 31);
    609 
    610     owl_fmtext_free(&fm_tmp);
    611     owl_fmtext_init_null(&fm_tmp);
    612     owl_fmtext_append_ztext(&fm_tmp, indent);
    613     owl_fmtext_init_null(&fm_other);
    614     owl_fmtext_truncate_lines(&fm_tmp, 1, owl_fmtext_num_lines(&fm_tmp)-1, &fm_other);
    615     owl_fmtext_free(&fm_tmp);
    616    
    617     /* edit the from addr for printing */
    618     strcpy(frombuff, owl_message_get_sender(m));
    619     ptr=strchr(frombuff, '@');
    620     if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
    621       *ptr='\0';
    622     }
    623     sender=owl_sprintf("%-9.9s", frombuff);
    624 
    625     hostname=owl_sprintf("%-9.9s", owl_message_get_hostname(m));
    626     timestr=owl_strdup("00:00");
    627     classinst1=owl_sprintf("<%s>[%s]", owl_message_get_class(m), owl_message_get_instance(m));
    628     classinst2=owl_sprintf("%-9.9s", classinst1);
    629    
    630     /* set the message for printing */
    631     owl_fmtext_append_normal(fm, OWL_TABSTR);
    632    
    633     if (owl_message_is_ping(m) && owl_message_is_private(m)) {
    634       owl_fmtext_append_bold(fm, "PING");
    635       owl_fmtext_append_normal(fm, " from ");
    636       owl_fmtext_append_bold(fm, frombuff);
    637       owl_fmtext_append_normal(fm, "\n");
    638     } else if (owl_message_is_loginout(m)) {
    639       char *host, *tty;
    640      
    641       host=owl_message_get_attribute_value(m, "loginhost");
    642       tty=owl_message_get_attribute_value(m, "logintty");
    643      
    644       if (owl_message_is_login(m)) {
    645         owl_fmtext_append_bold(fm, "LOGIN");
    646       } else if (owl_message_is_logout(m)) {
    647         owl_fmtext_append_bold(fm, "LOGOUT");
    648       }
    649       if (owl_message_is_pseudo(m)) owl_fmtext_append_bold(fm, " (PSEUDO)");
    650 
    651       owl_fmtext_append_normal(fm, " for ");
    652       ptr=short_zuser(owl_message_get_instance(m));
    653       owl_fmtext_append_bold(fm, ptr);
    654       owl_free(ptr);
    655       owl_fmtext_append_normal(fm, " at ");
    656       owl_fmtext_append_normal(fm, host ? host : "");
    657       owl_fmtext_append_normal(fm, " ");
    658       owl_fmtext_append_normal(fm, tty ? tty : "");
    659       owl_fmtext_append_normal(fm, "\n");
    660     } else {
    661       owl_fmtext_append_normal(fm, sender);
    662       owl_fmtext_append_normal(fm, "|");
    663       owl_fmtext_append_normal(fm, hostname);
    664       owl_fmtext_append_normal(fm, " ");
    665       owl_fmtext_append_normal(fm, timestr);
    666       owl_fmtext_append_normal(fm, " ");
    667       owl_fmtext_append_normal(fm, classinst2);
    668 
    669       owl_fmtext_append_normal(fm, "   ");
    670       owl_fmtext_append_fmtext(fm, &fm_first);
    671       owl_fmtext_append_fmtext(fm, &fm_other);
    672 
    673       owl_fmtext_free(&fm_other);
    674       owl_fmtext_free(&fm_first);
    675      
    676       /* make private messages bold for smaat users */
    677       if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
    678         if (owl_message_is_personal(m)) {
    679           owl_fmtext_addattr((&m->fmtext), OWL_FMTEXT_ATTR_BOLD);
    680         }
    681       }
    682     }
    683 
    684     owl_free(sender);
    685     owl_free(hostname);
    686     owl_free(timestr);
    687     owl_free(classinst1);
    688     owl_free(classinst2);
    689    
    690     owl_free(body);
    691     owl_free(indent);
    692 #endif
    693   } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) {
    694     char *indent, *text, *zsigbuff, *foo;
    695    
    696     text=owl_message_get_body(m);
    697    
    698     indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    699     owl_text_indent(indent, text, OWL_MSGTAB);
    700     owl_fmtext_append_normal(fm, OWL_TABSTR);
    701     owl_fmtext_append_normal(fm, "Zephyr sent to ");
    702     foo=short_zuser(owl_message_get_recipient(m));
    703     owl_fmtext_append_normal(fm, foo);
    704     owl_free(foo);
    705     owl_fmtext_append_normal(fm, "  (Zsig: ");
    706    
    707     zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
    708     owl_message_pretty_zsig(m, zsigbuff);
    709     owl_fmtext_append_ztext(fm, zsigbuff);
    710     owl_free(zsigbuff);
    711    
    712     owl_fmtext_append_normal(fm, ")");
    713     owl_fmtext_append_normal(fm, "\n");
    714     owl_fmtext_append_ztext(fm, indent);
    715     if (text[strlen(text)-1]!='\n') {
    716       owl_fmtext_append_normal(fm, "\n");
    717     }
    718    
    719     owl_free(indent);
    720   } else if (owl_message_is_type_aim(m)) {
    721     char *indent;
    722    
    723     if (owl_message_is_loginout(m)) {
    724       owl_fmtext_append_normal(fm, OWL_TABSTR);
    725       if (owl_message_is_login(m)) {
    726         owl_fmtext_append_bold(fm, "AIM LOGIN");
    727       } else {
    728         owl_fmtext_append_bold(fm, "AIM LOGOUT");
    729       }
    730       owl_fmtext_append_normal(fm, " for ");
    731       owl_fmtext_append_normal(fm, owl_message_get_sender(m));
    732       owl_fmtext_append_normal(fm, "\n");
    733     } else if (owl_message_is_direction_in(m)) {
    734       indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
    735       owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
    736       owl_fmtext_append_bold(fm, OWL_TABSTR);
    737       owl_fmtext_append_bold(fm, "AIM from ");
    738       owl_fmtext_append_bold(fm, owl_message_get_sender(m));
    739       owl_fmtext_append_bold(fm, "\n");
    740       owl_fmtext_append_bold(fm, indent);
    741       if (indent[strlen(indent)-1]!='\n') {
    742         owl_fmtext_append_normal(fm, "\n");
    743       }
    744       owl_free(indent);
    745     } else if (owl_message_is_direction_out(m)) {
    746       indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
    747       owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
    748       owl_fmtext_append_normal(fm, OWL_TABSTR);
    749       owl_fmtext_append_normal(fm, "AIM sent to ");
    750       owl_fmtext_append_normal(fm, owl_message_get_recipient(m));
    751       owl_fmtext_append_normal(fm, "\n");
    752       owl_fmtext_append_ztext(fm, indent);
    753       if (indent[strlen(indent)-1]!='\n') {
    754         owl_fmtext_append_normal(fm, "\n");
    755       }
    756       owl_free(indent);
    757     }
    758   } else if (owl_message_is_type_admin(m)) {
    759     char *text, *header, *indent;
    760    
    761     text=owl_message_get_body(m);
    762     header=owl_message_get_attribute_value(m, "adminheader");
    763    
    764     indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    765     owl_text_indent(indent, text, OWL_MSGTAB);
    766     owl_fmtext_append_normal(fm, OWL_TABSTR);
    767     owl_fmtext_append_bold(fm, "OWL ADMIN ");
    768     owl_fmtext_append_ztext(fm, header);
    769     owl_fmtext_append_normal(fm, "\n");
    770     owl_fmtext_append_ztext(fm, indent);
    771     if (text[strlen(text)-1]!='\n') {
    772       owl_fmtext_append_normal(fm, "\n");
    773     }
    774    
    775     owl_free(indent);
    776   } else {
    777 
    778   }
    779 }
Note: See TracChangeset for help on using the changeset viewer.