Changes in / [c1522ec:f92080c]


Ignore:
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • owl.c

    rcde4a71 r0b7082c  
    262262  owl_style_create_internal(s, "basic", &owl_stylefunc_basic, "Basic message formatting.");
    263263  owl_global_add_style(&g, s);
    264 #if 0
    265   s=owl_malloc(sizeof(owl_style));
    266   owl_style_create_internal(s, "vt", &owl_stylefunc_vt, "VT message formatting.");
    267   owl_global_add_style(&g, s);
    268 #endif
    269264  s=owl_malloc(sizeof(owl_style));
    270265  owl_style_create_internal(s, "oneline", &owl_stylefunc_oneline, "Formats for one-line-per-message");
  • owl.h

    r62fdd29 r88dc766  
    6767/* logout is defined in FreeBSD. */
    6868#define logout logout_
     69/* aim.h defines bool */
     70#define HAS_BOOL
    6971#include <perl.h>
    7072#undef logout
     
    7678static const char owl_h_fileIdent[] = "$Id$";
    7779
    78 #define STRINGIFY(x) _STRINGIFY(x)
     80#define BARNOWL_STRINGIFY(x) _STRINGIFY(x)
    7981#define _STRINGIFY(x) #x
    8082
     
    8385#endif
    8486
    85 #define OWL_VERSION_STRING "r" STRINGIFY(OWL_SVN_REVNO)
     87#define OWL_VERSION_STRING "r" BARNOWL_STRINGIFY(OWL_SVN_REVNO)
    8688
    8789
  • perl/modules/IRC/lib/BarnOwl/Module/IRC.pm

    rb0c8011 rfe8cad8  
    2828# Hash alias -> BarnOwl::Module::IRC::Connection object
    2929our %ircnets;
     30our %channels;
    3031
    3132sub startup {
     
    210211    my $conn = get_connection(\@_);
    211212    my $chan = shift or die("Usage: $cmd channel\n");
     213    $channels{$chan} ||= [];
     214    push @{$channels{$chan}}, $conn;
    212215    $conn->join($chan);
    213216}
     
    217220    my $conn = get_connection(\@_);
    218221    my $chan = get_channel(\@_) || die("Usage: $cmd <channel>\n");
     222    $channels{$chan} = [grep {$_ ne $conn} @{$channels{$chan} || []}];
    219223    $conn->part($chan);
    220224}
     
    251255        return get_connection_by_alias(shift @$args);
    252256    }
     257    my $channel = $args->[-1];
     258    if ($channel =~ /^#/ and $channels{$channel} and @{$channels{$channel}} == 1) {
     259        return $channels{$channel}[0];
     260    }
    253261    my $m = BarnOwl::getcurmsg();
    254262    if($m && $m->type eq 'IRC') {
  • stylefunc.c

    r9aba27b r0b7082c  
    221221}
    222222
    223 void owl_stylefunc_default(owl_fmtext *fm, owl_message *m)
    224 {
    225   char *shorttimestr;
    226 #ifdef HAVE_LIBZEPHYR
    227   char *ptr, *zsigbuff, frombuff[LINE];
    228   ZNotice_t *n;
    229 #endif
    230 
    231   shorttimestr=owl_message_get_shorttimestr(m);
    232 
    233   if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
    234 #ifdef HAVE_LIBZEPHYR
    235     n=owl_message_get_notice(m);
    236 
    237     /* edit the from addr for printing */
    238     strcpy(frombuff, owl_message_get_sender(m));
    239     ptr=strchr(frombuff, '@');
    240     if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
    241       *ptr='\0';
    242     }
    243    
    244     /* set the message for printing */
    245     owl_fmtext_append_normal(fm, OWL_TABSTR);
    246    
    247     if (owl_message_is_ping(m) && owl_message_is_private(m)) {
    248       owl_fmtext_append_bold(fm, "PING");
    249       owl_fmtext_append_normal(fm, " from ");
    250       owl_fmtext_append_bold(fm, frombuff);
    251       owl_fmtext_append_normal(fm, "\n");
    252     } else if (owl_message_is_loginout(m)) {
    253       char *host, *tty;
    254      
    255       host=owl_message_get_attribute_value(m, "loginhost");
    256       tty=owl_message_get_attribute_value(m, "logintty");
    257      
    258       if (owl_message_is_login(m)) {
    259         owl_fmtext_append_bold(fm, "LOGIN");
    260       } else if (owl_message_is_logout(m)) {
    261         owl_fmtext_append_bold(fm, "LOGOUT");
    262       }
    263 
    264       if (owl_message_is_pseudo(m)) owl_fmtext_append_bold(fm, " (PSEUDO)");
    265        
    266       owl_fmtext_append_normal(fm, " for ");
    267       ptr=short_zuser(owl_message_get_instance(m));
    268       owl_fmtext_append_bold(fm, ptr);
    269       owl_free(ptr);
    270       owl_fmtext_append_normal(fm, " at ");
    271       owl_fmtext_append_normal(fm, host ? host : "");
    272       owl_fmtext_append_normal(fm, " ");
    273       owl_fmtext_append_normal(fm, tty ? tty : "");
    274       owl_fmtext_append_normal(fm, " ");
    275       owl_fmtext_append_normal(fm, shorttimestr);
    276       owl_fmtext_append_normal(fm, "\n");
    277     } else {
    278       owl_fmtext_append_normal(fm, owl_message_get_class(m));
    279       owl_fmtext_append_normal(fm, " / ");
    280       owl_fmtext_append_normal(fm, owl_message_get_instance(m));
    281       owl_fmtext_append_normal(fm, " / ");
    282       owl_fmtext_append_bold(fm, frombuff);
    283       if (strcasecmp(owl_message_get_realm(m), ZGetRealm())) {
    284         owl_fmtext_append_normal(fm, " {");
    285         owl_fmtext_append_normal(fm, owl_message_get_realm(m));
    286         owl_fmtext_append_normal(fm, "}");
    287       }
    288       if (strcmp(owl_message_get_opcode(m), "")) {
    289         owl_fmtext_append_normal(fm, " [");
    290         owl_fmtext_append_normal(fm, owl_message_get_opcode(m));
    291         owl_fmtext_append_normal(fm, "]");
    292       }
    293 
    294       owl_fmtext_append_normal(fm, "  ");
    295       owl_fmtext_append_normal(fm, shorttimestr);
    296 
    297       /* stick on the zsig */
    298       zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
    299       owl_message_pretty_zsig(m, zsigbuff);
    300       owl_fmtext_append_normal(fm, "    (");
    301       owl_fmtext_append_ztext(fm, zsigbuff);
    302       owl_fmtext_append_normal(fm, ")");
    303       owl_fmtext_append_normal(fm, "\n");
    304       owl_free(zsigbuff);
    305      
    306       owl_style_basic_format_body(fm, m);
    307      
    308       /* make private messages bold for smaat users */
    309       if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
    310         if (owl_message_is_personal(m)) {
    311           owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
    312         }
    313       }
    314     }
    315    
    316 #endif
    317   } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) {
    318     char *zsigbuff, *foo;
    319    
    320     owl_fmtext_append_normal(fm, OWL_TABSTR);
    321     owl_fmtext_append_normal(fm, "Zephyr sent to ");
    322     foo=short_zuser(owl_message_get_recipient(m));
    323     owl_fmtext_append_normal(fm, foo);
    324     owl_free(foo);
    325 
    326     owl_fmtext_append_normal(fm, "  ");
    327     owl_fmtext_append_normal(fm, shorttimestr);
    328 
    329     owl_fmtext_append_normal(fm, "  (Zsig: ");
    330    
    331     zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
    332     owl_message_pretty_zsig(m, zsigbuff);
    333     owl_fmtext_append_ztext(fm, zsigbuff);
    334     owl_free(zsigbuff);
    335    
    336     owl_fmtext_append_normal(fm, ")");
    337     owl_fmtext_append_normal(fm, "\n");
    338     owl_style_basic_format_body(fm, m);
    339   } else if (owl_message_is_type_aim(m)) {
    340     if (owl_message_is_loginout(m)) {
    341       owl_fmtext_append_normal(fm, OWL_TABSTR);
    342       if (owl_message_is_login(m)) {
    343         owl_fmtext_append_bold(fm, "AIM LOGIN");
    344       } else {
    345         owl_fmtext_append_bold(fm, "AIM LOGOUT");
    346       }
    347       owl_fmtext_append_normal(fm, " for ");
    348       owl_fmtext_append_normal(fm, owl_message_get_sender(m));
    349       owl_fmtext_append_normal(fm, " ");
    350       owl_fmtext_append_normal(fm, shorttimestr);
    351       owl_fmtext_append_normal(fm, "\n");
    352     } else if (owl_message_is_direction_in(m)) {
    353       owl_fmtext_append_bold(fm, OWL_TABSTR);
    354       owl_fmtext_append_bold(fm, "AIM from ");
    355       owl_fmtext_append_bold(fm, owl_message_get_sender(m));
    356      
    357       owl_fmtext_append_normal(fm, "  ");
    358       owl_fmtext_append_normal(fm, shorttimestr);
    359 
    360       owl_fmtext_append_bold(fm, "\n");
    361       owl_style_basic_format_body(fm, m);
    362     } else if (owl_message_is_direction_out(m)) {
    363       owl_fmtext_append_normal(fm, OWL_TABSTR);
    364       owl_fmtext_append_normal(fm, "AIM sent to ");
    365       owl_fmtext_append_normal(fm, owl_message_get_recipient(m));
    366       owl_fmtext_append_normal(fm, "  ");
    367       owl_fmtext_append_normal(fm, shorttimestr);
    368       owl_fmtext_append_normal(fm, "\n");
    369       owl_style_basic_format_body(fm, m);
    370     }
    371   } else if (owl_message_is_type_admin(m)) {
    372     char *header;
    373    
    374     header=owl_message_get_attribute_value(m, "adminheader");
    375    
    376     owl_fmtext_append_normal(fm, OWL_TABSTR);
    377     owl_fmtext_append_bold(fm, "OWL ADMIN ");
    378     owl_fmtext_append_ztext(fm, header);
    379     owl_fmtext_append_normal(fm, "\n");
    380     owl_style_basic_format_body(fm, m);
    381   } else {
    382     char *header;
    383    
    384     header=owl_sprintf("%s from: %s to: %s",
    385                        owl_message_get_type(m),
    386                        owl_message_get_sender(m),
    387                        owl_message_get_recipient(m));
    388    
    389     owl_fmtext_append_normal(fm, OWL_TABSTR);
    390     owl_fmtext_append_normal(fm, header);
    391     owl_fmtext_append_normal(fm, "  ");
    392     owl_fmtext_append_normal(fm, shorttimestr);
    393     owl_fmtext_append_normal(fm, "\n");
    394     owl_style_basic_format_body(fm, m);
    395   }
    396   owl_free(shorttimestr);
    397 }
    398 
    399223void owl_stylefunc_oneline(owl_fmtext *fm, owl_message *m)
    400224{
     
    526350
    527351}
    528 
    529 void owl_stylefunc_vt(owl_fmtext *fm, owl_message *m)
    530 {
    531 #ifdef HAVE_LIBZEPHYR
    532   char *body, *indent, *ptr, frombuff[LINE];
    533   owl_fmtext fm_first, fm_other, fm_tmp;
    534   ZNotice_t *n;
    535 #endif
    536   char *sender, *hostname, *timestr, *classinst1, *classinst2;
    537 
    538   if (owl_message_is_type_zephyr(m) && owl_message_is_direction_in(m)) {
    539 #ifdef HAVE_LIBZEPHYR
    540     n=owl_message_get_notice(m);
    541 
    542     /* get the body */
    543     body=owl_malloc(strlen(owl_message_get_body(m))+30);
    544     strcpy(body, owl_message_get_body(m));
    545    
    546     /* add a newline if we need to */
    547     if (body[0]!='\0' && body[strlen(body)-1]!='\n') {
    548       strcat(body, "\n");
    549     }
    550 
    551     owl_fmtext_init_null(&fm_tmp);
    552     owl_fmtext_append_ztext(&fm_tmp, body);
    553     owl_fmtext_init_null(&fm_first);
    554     owl_fmtext_truncate_lines(&fm_tmp, 0, 1, &fm_first);
    555 
    556     /* do the indenting into indent */
    557     indent=owl_malloc(strlen(body)+owl_text_num_lines(body)*OWL_MSGTAB+10);
    558     owl_text_indent(indent, body, 31);
    559 
    560     owl_fmtext_free(&fm_tmp);
    561     owl_fmtext_init_null(&fm_tmp);
    562     owl_fmtext_append_ztext(&fm_tmp, indent);
    563     owl_fmtext_init_null(&fm_other);
    564     owl_fmtext_truncate_lines(&fm_tmp, 1, owl_fmtext_num_lines(&fm_tmp)-1, &fm_other);
    565     owl_fmtext_free(&fm_tmp);
    566    
    567     /* edit the from addr for printing */
    568     strcpy(frombuff, owl_message_get_sender(m));
    569     ptr=strchr(frombuff, '@');
    570     if (ptr && !strncmp(ptr+1, owl_zephyr_get_realm(), strlen(owl_zephyr_get_realm()))) {
    571       *ptr='\0';
    572     }
    573     sender=owl_sprintf("%-9.9s", frombuff);
    574 
    575     hostname=owl_sprintf("%-9.9s", owl_message_get_hostname(m));
    576     timestr=owl_strdup("00:00");
    577     classinst1=owl_sprintf("<%s>[%s]", owl_message_get_class(m), owl_message_get_instance(m));
    578     classinst2=owl_sprintf("%-9.9s", classinst1);
    579    
    580     /* set the message for printing */
    581     owl_fmtext_append_normal(fm, OWL_TABSTR);
    582    
    583     if (owl_message_is_ping(m) && owl_message_is_private(m)) {
    584       owl_fmtext_append_bold(fm, "PING");
    585       owl_fmtext_append_normal(fm, " from ");
    586       owl_fmtext_append_bold(fm, frombuff);
    587       owl_fmtext_append_normal(fm, "\n");
    588     } else if (owl_message_is_loginout(m)) {
    589       char *host, *tty;
    590      
    591       host=owl_message_get_attribute_value(m, "loginhost");
    592       tty=owl_message_get_attribute_value(m, "logintty");
    593      
    594       if (owl_message_is_login(m)) {
    595         owl_fmtext_append_bold(fm, "LOGIN");
    596       } else if (owl_message_is_logout(m)) {
    597         owl_fmtext_append_bold(fm, "LOGOUT");
    598       }
    599       if (owl_message_is_pseudo(m)) owl_fmtext_append_bold(fm, " (PSEUDO)");
    600 
    601       owl_fmtext_append_normal(fm, " for ");
    602       ptr=short_zuser(owl_message_get_instance(m));
    603       owl_fmtext_append_bold(fm, ptr);
    604       owl_free(ptr);
    605       owl_fmtext_append_normal(fm, " at ");
    606       owl_fmtext_append_normal(fm, host ? host : "");
    607       owl_fmtext_append_normal(fm, " ");
    608       owl_fmtext_append_normal(fm, tty ? tty : "");
    609       owl_fmtext_append_normal(fm, "\n");
    610     } else {
    611       owl_fmtext_append_normal(fm, sender);
    612       owl_fmtext_append_normal(fm, "|");
    613       owl_fmtext_append_normal(fm, hostname);
    614       owl_fmtext_append_normal(fm, " ");
    615       owl_fmtext_append_normal(fm, timestr);
    616       owl_fmtext_append_normal(fm, " ");
    617       owl_fmtext_append_normal(fm, classinst2);
    618 
    619       owl_fmtext_append_normal(fm, "   ");
    620       owl_fmtext_append_fmtext(fm, &fm_first);
    621       owl_fmtext_append_fmtext(fm, &fm_other);
    622 
    623       owl_fmtext_free(&fm_other);
    624       owl_fmtext_free(&fm_first);
    625      
    626       /* make private messages bold for smaat users */
    627       if (owl_global_is_userclue(&g, OWL_USERCLUE_CLASSES)) {
    628         if (owl_message_is_personal(m)) {
    629           owl_fmtext_addattr(fm, OWL_FMTEXT_ATTR_BOLD);
    630         }
    631       }
    632     }
    633 
    634     owl_free(sender);
    635     owl_free(hostname);
    636     owl_free(timestr);
    637     owl_free(classinst1);
    638     owl_free(classinst2);
    639    
    640     owl_free(body);
    641     owl_free(indent);
    642 #endif
    643   } else if (owl_message_is_type_zephyr(m) && owl_message_is_direction_out(m)) {
    644     char *indent, *text, *zsigbuff, *foo;
    645    
    646     text=owl_message_get_body(m);
    647    
    648     indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    649     owl_text_indent(indent, text, OWL_MSGTAB);
    650     owl_fmtext_append_normal(fm, OWL_TABSTR);
    651     owl_fmtext_append_normal(fm, "Zephyr sent to ");
    652     foo=short_zuser(owl_message_get_recipient(m));
    653     owl_fmtext_append_normal(fm, foo);
    654     owl_free(foo);
    655     owl_fmtext_append_normal(fm, "  (Zsig: ");
    656    
    657     zsigbuff=owl_malloc(strlen(owl_message_get_zsig(m))+30);
    658     owl_message_pretty_zsig(m, zsigbuff);
    659     owl_fmtext_append_ztext(fm, zsigbuff);
    660     owl_free(zsigbuff);
    661    
    662     owl_fmtext_append_normal(fm, ")");
    663     owl_fmtext_append_normal(fm, "\n");
    664     owl_fmtext_append_ztext(fm, indent);
    665     if (text[strlen(text)-1]!='\n') {
    666       owl_fmtext_append_normal(fm, "\n");
    667     }
    668    
    669     owl_free(indent);
    670   } else if (owl_message_is_type_aim(m)) {
    671     char *indent;
    672    
    673     if (owl_message_is_loginout(m)) {
    674       owl_fmtext_append_normal(fm, OWL_TABSTR);
    675       if (owl_message_is_login(m)) {
    676         owl_fmtext_append_bold(fm, "AIM LOGIN");
    677       } else {
    678         owl_fmtext_append_bold(fm, "AIM LOGOUT");
    679       }
    680       owl_fmtext_append_normal(fm, " for ");
    681       owl_fmtext_append_normal(fm, owl_message_get_sender(m));
    682       owl_fmtext_append_normal(fm, "\n");
    683     } else if (owl_message_is_direction_in(m)) {
    684       indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
    685       owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
    686       owl_fmtext_append_bold(fm, OWL_TABSTR);
    687       owl_fmtext_append_bold(fm, "AIM from ");
    688       owl_fmtext_append_bold(fm, owl_message_get_sender(m));
    689       owl_fmtext_append_bold(fm, "\n");
    690       owl_fmtext_append_bold(fm, indent);
    691       if (indent[strlen(indent)-1]!='\n') {
    692         owl_fmtext_append_normal(fm, "\n");
    693       }
    694       owl_free(indent);
    695     } else if (owl_message_is_direction_out(m)) {
    696       indent=owl_malloc(strlen(owl_message_get_body(m))+owl_text_num_lines(owl_message_get_body(m))*OWL_MSGTAB+10);
    697       owl_text_indent(indent, owl_message_get_body(m), OWL_MSGTAB);
    698       owl_fmtext_append_normal(fm, OWL_TABSTR);
    699       owl_fmtext_append_normal(fm, "AIM sent to ");
    700       owl_fmtext_append_normal(fm, owl_message_get_recipient(m));
    701       owl_fmtext_append_normal(fm, "\n");
    702       owl_fmtext_append_ztext(fm, indent);
    703       if (indent[strlen(indent)-1]!='\n') {
    704         owl_fmtext_append_normal(fm, "\n");
    705       }
    706       owl_free(indent);
    707     }
    708   } else if (owl_message_is_type_admin(m)) {
    709     char *text, *header, *indent;
    710    
    711     text=owl_message_get_body(m);
    712     header=owl_message_get_attribute_value(m, "adminheader");
    713    
    714     indent=owl_malloc(strlen(text)+owl_text_num_lines(text)*OWL_MSGTAB+10);
    715     owl_text_indent(indent, text, OWL_MSGTAB);
    716     owl_fmtext_append_normal(fm, OWL_TABSTR);
    717     owl_fmtext_append_bold(fm, "OWL ADMIN ");
    718     owl_fmtext_append_ztext(fm, header);
    719     owl_fmtext_append_normal(fm, "\n");
    720     owl_fmtext_append_ztext(fm, indent);
    721     if (text[strlen(text)-1]!='\n') {
    722       owl_fmtext_append_normal(fm, "\n");
    723     }
    724    
    725     owl_free(indent);
    726   } else {
    727 
    728   }
    729 }
  • zephyr.c

    r1151f0b r60c2e1e  
    603603    #define BUFFLEN 1024
    604604    if (retnotice->z_recipient == NULL
    605         || *retnotice->z_recipient == NULL
     605        || *retnotice->z_recipient == 0
    606606        || *retnotice->z_recipient == '@') {
    607607      char buff[BUFFLEN];
Note: See TracChangeset for help on using the changeset viewer.