Changeset 0b7082c for stylefunc.c


Ignore:
Timestamp:
Jan 11, 2008, 10:17:19 PM (16 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:
60c2e1e
Parents:
216e621
Message:
Nuke the vt style as well
File:
1 edited

Legend:

Unmodified
Added
Removed
  • stylefunc.c

    r216e621 r0b7082c  
    350350
    351351}
    352 
    353 void owl_stylefunc_vt(owl_fmtext *fm, owl_message *m)
    354 {
    355 #ifdef HAVE_LIBZEPHYR
    356   char *body, *indent, *ptr, frombuff[LINE];
    357   owl_fmtext fm_first, fm_other, fm_tmp;
    358   ZNotice_t *n;
    359 #endif
    360   char *sender, *hostname, *timestr, *classinst1, *classinst2;
    361 
    362   if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
    363 #ifdef HAVE_LIBZEPHYR
    364     n=owl_message_get_notice(m);
    365 
    366     /* get the body */
    367     body=owl_malloc(strlen(owl_message_get_body(m))+30);
    368     strcpy(body, owl_message_get_body(m));
    369    
    370     /* add a newline if we need to */
    371     if (body[0]!='\0' && body[strlen(body)-1]!='\n') {
    372       strcat(body, "\n");
    373     }
    374 
    375     owl_fmtext_init_null(&fm_tmp);
    376     owl_fmtext_append_ztext(&fm_tmp, body);
    377     owl_fmtext_init_null(&fm_first);
    378     owl_fmtext_truncate_lines(&fm_tmp, 0, 1, &fm_first);
    379 
    380     /* do the indenting into indent */
    381     indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10);
    382     owl_text_indent(indent, body, 31);
    383 
    384     owl_fmtext_free(&fm_tmp);
    385     owl_fmtext_init_null(&fm_tmp);
    386     owl_fmtext_append_ztext(&fm_tmp, indent);
    387     owl_fmtext_init_null(&fm_other);
    388     owl_fmtext_truncate_lines(&fm_tmp, 1, owl_fmtext_num_lines(&fm_tmp)-1, &fm_other);
    389     owl_fmtext_free(&fm_tmp);
    390    
    391     /* edit the from addr for printing */
    392     strcpy(frombuff, owl_message_get_sender(m));
    393     ptr=strchr(frombuff, '@');
    394     if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
    395       *ptr='\0';
    396     }
    397     sender=owl_sprintf("%-9.9s", frombuff);
    398 
    399     hostname=owl_sprintf("%-9.9s", owl_message_get_hostname(m));
    400     timestr=owl_strdup("00:00");
    401     classinst1=owl_sprintf("<%s>[%s]", owl_message_get_class(m), owl_message_get_instance(m));
    402     classinst2=owl_sprintf("%-9.9s", classinst1);
    403    
    404     /* set the message for printing */
    405     owl_fmtext_append_normal(fm, OWL_TABSTR);
    406    
    407     if (owl_message_is_ping(m) && owl_message_is_private(m)) {
    408       owl_fmtext_append_bold(fm, "PING");
    409       owl_fmtext_append_normal(fm, " from ");
    410       owl_fmtext_append_bold(fm, frombuff);
    411       owl_fmtext_append_normal(fm, "\n");
    412     } else if (owl_message_is_loginout(m)) {
    413       char *host, *tty;
    414      
    415       host=owl_message_get_attribute_value(m, "loginhost");
    416       tty=owl_message_get_attribute_value(m, "logintty");
    417      
    418       if (owl_message_is_login(m)) {
    419         owl_fmtext_append_bold(fm, "LOGIN");
    420       } else if (owl_message_is_logout(m)) {
    421         owl_fmtext_append_bold(fm, "LOGOUT");
    422       }
    423       if (owl_message_is_pseudo(m)) owl_fmtext_append_bold(fm, " (PSEUDO)");
    424 
    425       owl_fmtext_append_normal(fm, " for ");
    426       ptr=short_zuser(owl_message_get_instance(m));
    427       owl_fmtext_append_bold(fm, ptr);
    428       owl_free(ptr);
    429       owl_fmtext_append_normal(fm, " at ");
    430       owl_fmtext_append_normal(fm, host ? host : "");
    431       owl_fmtext_append_normal(fm, " ");
    432       owl_fmtext_append_normal(fm, tty ? tty : "");
    433       owl_fmtext_append_normal(fm, "\n");
    434     } else {
    435       owl_fmtext_append_normal(fm, sender);
    436       owl_fmtext_append_normal(fm, "|");
    437       owl_fmtext_append_normal(fm, hostname);
    438       owl_fmtext_append_normal(fm, " ");
    439       owl_fmtext_append_normal(fm, timestr);
    440       owl_fmtext_append_normal(fm, " ");
    441       owl_fmtext_append_normal(fm, classinst2);
    442 
    443       owl_fmtext_append_normal(fm, "   ");
    444       owl_fmtext_append_fmtext(fm, &fm_first);
    445       owl_fmtext_append_fmtext(fm, &fm_other);
    446 
    447       owl_fmtext_free(&fm_other);
    448       owl_fmtext_free(&fm_first);
    449      
    450       /* make private messages bold for smaat users */
    451       if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
    452         if (owl_message_is_personal(m)) {
    453           owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
    454         }
    455       }
    456     }
    457 
    458     owl_free(sender);
    459     owl_free(hostname);
    460     owl_free(timestr);
    461     owl_free(classinst1);
    462     owl_free(classinst2);
    463    
    464     owl_free(body);
    465     owl_free(indent);
    466 #endif
    467   } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) {
    468     char *indent, *text, *zsigbuff, *foo;
    469    
    470     text=owl_message_get_body(m);
    471    
    472     indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    473     owl_text_indent(indent, text, OWL_MSGTAB);
    474     owl_fmtext_append_normal(fm, OWL_TABSTR);
    475     owl_fmtext_append_normal(fm, "Zephyr sent to ");
    476     foo=short_zuser(owl_message_get_recipient(m));
    477     owl_fmtext_append_normal(fm, foo);
    478     owl_free(foo);
    479     owl_fmtext_append_normal(fm, "  (Zsig: ");
    480    
    481     zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
    482     owl_message_pretty_zsig(m, zsigbuff);
    483     owl_fmtext_append_ztext(fm, zsigbuff);
    484     owl_free(zsigbuff);
    485    
    486     owl_fmtext_append_normal(fm, ")");
    487     owl_fmtext_append_normal(fm, "\n");
    488     owl_fmtext_append_ztext(fm, indent);
    489     if (text[strlen(text)-1]!='\n') {
    490       owl_fmtext_append_normal(fm, "\n");
    491     }
    492    
    493     owl_free(indent);
    494   } else if (owl_message_is_type_aim(m)) {
    495     char *indent;
    496    
    497     if (owl_message_is_loginout(m)) {
    498       owl_fmtext_append_normal(fm, OWL_TABSTR);
    499       if (owl_message_is_login(m)) {
    500         owl_fmtext_append_bold(fm, "AIM LOGIN");
    501       } else {
    502         owl_fmtext_append_bold(fm, "AIM LOGOUT");
    503       }
    504       owl_fmtext_append_normal(fm, " for ");
    505       owl_fmtext_append_normal(fm, owl_message_get_sender(m));
    506       owl_fmtext_append_normal(fm, "\n");
    507     } else if (owl_message_is_direction_in(m)) {
    508       indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
    509       owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
    510       owl_fmtext_append_bold(fm, OWL_TABSTR);
    511       owl_fmtext_append_bold(fm, "AIM from ");
    512       owl_fmtext_append_bold(fm, owl_message_get_sender(m));
    513       owl_fmtext_append_bold(fm, "\n");
    514       owl_fmtext_append_bold(fm, indent);
    515       if (indent[strlen(indent)-1]!='\n') {
    516         owl_fmtext_append_normal(fm, "\n");
    517       }
    518       owl_free(indent);
    519     } else if (owl_message_is_direction_out(m)) {
    520       indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
    521       owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
    522       owl_fmtext_append_normal(fm, OWL_TABSTR);
    523       owl_fmtext_append_normal(fm, "AIM sent to ");
    524       owl_fmtext_append_normal(fm, owl_message_get_recipient(m));
    525       owl_fmtext_append_normal(fm, "\n");
    526       owl_fmtext_append_ztext(fm, indent);
    527       if (indent[strlen(indent)-1]!='\n') {
    528         owl_fmtext_append_normal(fm, "\n");
    529       }
    530       owl_free(indent);
    531     }
    532   } else if (owl_message_is_type_admin(m)) {
    533     char *text, *header, *indent;
    534    
    535     text=owl_message_get_body(m);
    536     header=owl_message_get_attribute_value(m, "adminheader");
    537    
    538     indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    539     owl_text_indent(indent, text, OWL_MSGTAB);
    540     owl_fmtext_append_normal(fm, OWL_TABSTR);
    541     owl_fmtext_append_bold(fm, "OWL ADMIN ");
    542     owl_fmtext_append_ztext(fm, header);
    543     owl_fmtext_append_normal(fm, "\n");
    544     owl_fmtext_append_ztext(fm, indent);
    545     if (text[strlen(text)-1]!='\n') {
    546       owl_fmtext_append_normal(fm, "\n");
    547     }
    548    
    549     owl_free(indent);
    550   } else {
    551 
    552   }
    553 }
Note: See TracChangeset for help on using the changeset viewer.