Changeset b67ab6b
- Timestamp:
- Apr 29, 2008, 1:21:15 AM (17 years ago)
- 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:
- 52f8dd6
- Parents:
- 864ed35
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
owl.c
r864ed35 rb67ab6b 589 589 if(owl_message_is_direction_in(m)) { 590 590 /* let perl know about it*/ 591 owl_perlconfig_getmsg(m, 0,NULL);591 owl_perlconfig_getmsg(m, NULL); 592 592 593 593 /* do we need to autoreply? */ -
perlconfig.c
r9c7a701 rb67ab6b 411 411 } 412 412 413 char *owl_perlconfig_getmsg(owl_message *m, int mode, char *subname) 414 { 415 /* if mode==1 we are doing message formatting. The returned 416 * formatted message needs to be freed by the caller. 417 * 418 * if mode==0 we are just doing the message-has-been-received 419 * thing. 420 */ 421 if (!owl_global_have_config(&g)) return(NULL); 422 423 /* run the procedure corresponding to the mode */ 424 if (mode==1) { 425 char *ret = NULL; 426 ret = owl_perlconfig_call_with_message(subname?subname 427 :"BarnOwl::_format_msg_legacy_wrap", m); 428 if (!ret) { 429 ret = owl_sprintf("@b([Perl Message Formatting Failed!])\n"); 430 } 431 return ret; 432 } else { 433 char *ptr = NULL; 434 if (owl_perlconfig_is_function("BarnOwl::Hooks::_receive_msg")) { 435 ptr = owl_perlconfig_call_with_message(subname?subname 436 :"BarnOwl::_receive_msg_legacy_wrap", m); 437 } 438 if (ptr) owl_free(ptr); 439 return(NULL); 440 } 413 void owl_perlconfig_getmsg(owl_message *m, char *subname) 414 { 415 char *ptr = NULL; 416 if (owl_perlconfig_is_function("BarnOwl::Hooks::_receive_msg")) { 417 ptr = owl_perlconfig_call_with_message(subname?subname 418 :"BarnOwl::_receive_msg_legacy_wrap", m); 419 } 420 if (ptr) owl_free(ptr); 441 421 } 442 422 -
perlglue.xs
r864ed35 rb67ab6b 256 256 257 257 void 258 _create_style(name, object)258 create_style(name, object) 259 259 char *name 260 260 SV *object 261 261 PREINIT: 262 /* This is to allow us to bootstrap the default style before the263 command architecture has been initialized */264 262 owl_style *s; 265 263 CODE: -
perlwrap.pm
r864ed35 rb67ab6b 153 153 } 154 154 $configfile ||= $ENV{HOME}."/.owlconf"; 155 156 # populate global variable space for legacy owlconf files157 sub _format_msg_legacy_wrap {158 my ($m) = @_;159 $m->legacy_populate_global();160 return &BarnOwl::format_msg($m);161 }162 155 163 156 # populate global variable space for legacy owlconf files … … 702 695 if(*BarnOwl::format_msg{CODE}) { 703 696 # if the config defines a legacy formatting function, add 'perl' as a style 704 # BarnOwl::_create_style("perl", "BarnOwl::_format_msg_legacy_wrap", 705 # "User-defined perl style that calls BarnOwl::format_msg" 706 # . " with legacy global variable support"); 707 # BarnOwl::set("-q default_style perl"); 697 BarnOwl::create_style("perl", BarnOwl::Style::Legacy->new( 698 "BarnOwl::format_msg", 699 "User-defined perl style that calls BarnOwl::format_msg" 700 . " with legacy global variable support", 701 1)); 702 BarnOwl::set("-q default_style perl"); 708 703 } 709 704 } … … 779 774 sub description {"Default style";} 780 775 781 BarnOwl:: _create_style("default", "BarnOwl::Style::Default");776 BarnOwl::create_style("default", "BarnOwl::Style::Default"); 782 777 783 778 ################################################################################ … … 869 864 sub description {"Compatability alias for the default style";} 870 865 871 BarnOwl:: _create_style("basic", "BarnOwl::Style::Basic");866 BarnOwl::create_style("basic", "BarnOwl::Style::Basic"); 872 867 873 868 package BarnOwl::Style::OneLine; … … 896 891 sub description {"Formats for one-line-per-message"} 897 892 898 BarnOwl:: _create_style("oneline", "BarnOwl::Style::OneLine");893 BarnOwl::create_style("oneline", "BarnOwl::Style::OneLine"); 899 894 900 895 ################################################################################ … … 996 991 } 997 992 993 package BarnOwl::Style::Legacy; 994 995 sub new { 996 my $class = shift; 997 my $func = shift; 998 my $desc = shift; 999 my $useglobals = shift; 1000 $useglobals = 0 unless defined($useglobals); 1001 return bless {function => $func, 1002 description => $desc, 1003 useglobals => $useglobals}, $class; 1004 } 1005 1006 sub description {shift->{description}}; 1007 1008 sub format_message { 1009 my $self = shift; 1010 if($self->{useglobals}) { 1011 $_[0]->legacy_populate_global(); 1012 } 1013 no strict 'refs'; 1014 goto \&{$self->{function}}; 1015 } 1016 998 1017 999 1018 # switch to package main when we're done
Note: See TracChangeset
for help on using the changeset viewer.