Changeset 0337203
- Timestamp:
- Mar 16, 2007, 12:45:19 AM (18 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:
- 4dd6e58
- Parents:
- 69d66aa7
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
BUGS
r69d66aa7 r0337203 5 5 * reply to resource names from ichat (foo's computer) fails badly [hartmans] 6 6 * viewuser doesn't work with AIM or Jabber 7 * jmuc join'ing a MUC you're already in has weird behavior [nelhage] -
functions.c
ra5fc448 r0337203 1035 1035 1036 1036 /* execute the commands in shutdown */ 1037 ret = owl_perlconfig_execute("BarnOwl::Hooks:: shutdown();");1037 ret = owl_perlconfig_execute("BarnOwl::Hooks::_shutdown();"); 1038 1038 if (ret) owl_free(ret); 1039 1039 … … 3365 3365 3366 3366 if(aim && zephyr) { 3367 if(owl_perlconfig_is_function("BarnOwl::Hooks:: get_blist")) {3368 char * perlblist = owl_perlconfig_execute("BarnOwl::Hooks:: get_blist()");3367 if(owl_perlconfig_is_function("BarnOwl::Hooks::_get_blist")) { 3368 char * perlblist = owl_perlconfig_execute("BarnOwl::Hooks::_get_blist()"); 3369 3369 if(perlblist) { 3370 3370 owl_fmtext_append_ztext(&fm, perlblist); -
owl.c
r2058d7a r0337203 318 318 /* execute the startup function in the configfile */ 319 319 owl_function_debugmsg("startup: executing perl startup, if applicable"); 320 perlout = owl_perlconfig_execute("BarnOwl::Hooks:: startup();");320 perlout = owl_perlconfig_execute("BarnOwl::Hooks::_startup();"); 321 321 if (perlout) owl_free(perlout); 322 322 -
perlconfig.c
r1cc95709 r0337203 422 422 } else { 423 423 char *ptr = NULL; 424 if (owl_perlconfig_is_function("BarnOwl::Hooks:: receive_msg")) {424 if (owl_perlconfig_is_function("BarnOwl::Hooks::_receive_msg")) { 425 425 ptr = owl_perlconfig_call_with_message(subname?subname 426 426 :"BarnOwl::_receive_msg_legacy_wrap", m); … … 506 506 void owl_perlconfig_mainloop() 507 507 { 508 if (!owl_perlconfig_is_function("BarnOwl::Hooks:: mainloop_hook"))508 if (!owl_perlconfig_is_function("BarnOwl::Hooks::_mainloop_hook")) 509 509 return; 510 510 dSP ; 511 511 PUSHMARK(SP) ; 512 call_pv("BarnOwl::Hooks:: mainloop_hook", G_DISCARD|G_EVAL);512 call_pv("BarnOwl::Hooks::_mainloop_hook", G_DISCARD|G_EVAL); 513 513 if(SvTRUE(ERRSV)) { 514 514 STRLEN n_a; -
perlwrap.pm
rbb2c60d r0337203 7 7 # XXX NOTE: This file is sourced before almost any barnowl 8 8 # architecture is loaded. This means, for example, that it cannot 9 # execute any owl commands. Any code that needs to do so, should 10 # create a function wrapping it and push it onto @onStartSubs 11 9 # execute any owl commands. Any code that needs to do so should live 10 # in BarnOwl::Hooks::_startup 12 11 13 12 use strict; 14 13 use warnings; 14 15 package BarnOwl; 15 16 16 17 package BarnOwl; … … 44 45 my ($m) = @_; 45 46 $m->legacy_populate_global(); 46 return &BarnOwl::Hooks:: receive_msg($m);47 return &BarnOwl::Hooks::_receive_msg($m); 47 48 } 48 49 … … 204 205 205 206 sub smartfilter { 206 die("smartfilter not supported for this message ");207 die("smartfilter not supported for this message\n"); 207 208 } 208 209 … … 351 352 ##################################################################### 352 353 ################################################################################ 353 package BarnOwl; 354 355 ################################################################################ 356 # Mainloop hook 357 ################################################################################ 358 359 our $shutdown; 360 $shutdown = 0; 361 our $reload; 362 $reload = 0; 363 364 #Run this on start and reload. Adds modules 365 sub onStart 366 { 367 _load_owlconf(); 368 reload_init(); 369 loadModules(); 370 } 371 ################################################################################ 372 # Reload Code, taken from /afs/sipb/user/jdaniel/project/owl/perl 373 ################################################################################ 374 sub reload_hook (@) 375 { 376 BarnOwl::Hooks::startup(); 377 return 1; 378 } 379 380 sub reload 381 { 382 # Use $reload to tell modules that we're performing a reload. 383 { 384 local $reload = 1; 385 BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE}; 386 } 387 388 @BarnOwl::Hooks::onMainLoop = (); 389 @BarnOwl::Hooks::onStartSubs = (); 390 391 # Do reload 392 package main; 393 if (-r $BarnOwl::configfile) { 394 undef $@; 395 do $BarnOwl::configfile; 396 BarnOwl::error("Error reloading $BarnOwl::configfile: $@") if $@; 397 } 398 BarnOwl::reload_hook(@_); 399 package BarnOwl; 400 } 401 402 sub reload_init () 403 { 404 BarnOwl::command('alias reload perl BarnOwl::reload()'); 405 BarnOwl::command('bindkey global "C-x C-r" command reload'); 406 } 407 408 ################################################################################ 409 # Loads modules from ~/.owl/modules and owl's data directory 410 ################################################################################ 411 412 sub loadModules () { 413 my @modules; 414 my $rv; 415 foreach my $dir ( BarnOwl::get_data_dir() . "/modules", 416 $ENV{HOME} . "/.owl/modules" ) 417 { 418 opendir( MODULES, $dir ); 419 420 # source ./modules/*.pl 421 @modules = sort grep( /\.pl$/, readdir(MODULES) ); 422 423 foreach my $mod (@modules) { 424 unless ($rv = do "$dir/$mod") { 425 BarnOwl::error("Couldn't load $dir/$mod:\n $@") if $@; 426 BarnOwl::error("Couldn't run $dir/$mod:\n $!") unless defined $rv; 427 } 428 } 429 closedir(MODULES); 430 } 431 } 354 355 package BarnOwl::Hook; 356 357 sub new { 358 my $class = shift; 359 return bless [], $class; 360 } 361 362 sub run { 363 my $self = shift; 364 my @args = @_; 365 return map {$_->(@args)} @$self; 366 } 367 368 sub add { 369 my $self = shift; 370 my $func = shift; 371 die("Not a coderef!") unless ref($func) eq 'CODE'; 372 push @$self, $func; 373 } 374 375 sub clear { 376 my $self = shift; 377 @$self = (); 378 } 379 380 package BarnOwl::Hooks; 381 382 use Exporter; 383 384 our @EXPORT_OK = qw($startup $shutdown 385 $receiveMessage $mainLoop 386 $getBuddyList); 387 388 our %EXPORT_TAGS = (all => [@EXPORT_OK]); 389 390 our $startup = BarnOwl::Hook->new; 391 our $shutdown = BarnOwl::Hook->new; 392 our $receiveMessage = BarnOwl::Hook->new; 393 our $mainLoop = BarnOwl::Hook->new; 394 our $getBuddyList = BarnOwl::Hook->new; 395 396 # Internal startup/shutdown routines called by the C code 432 397 433 398 sub _load_owlconf { 434 # Only do this the first time435 return if $BarnOwl::reload;436 399 # load the config file 437 400 if ( -r $BarnOwl::configfile ) { … … 451 414 } 452 415 453 package BarnOwl::Hooks; 454 455 # Arrays of subrefs to be called at specific times. 456 our @onStartSubs = (); 457 our @onReceiveMsg = (); 458 our @onMainLoop = (); 459 our @onGetBuddyList = (); 460 461 # Functions to call hook lists 462 sub runHook($@) 463 { 464 my $hook = shift; 465 my @args = @_; 466 $_->(@args) for (@$hook); 467 } 468 469 sub runHook_accumulate($@) 470 { 471 my $hook = shift; 472 my @args = @_; 473 return join("\n", map {$_->(@args)} @$hook); 474 } 475 476 ################################################################################ 477 # Startup and Shutdown code 478 ################################################################################ 479 sub startup 480 { 481 # Modern versions of owl provides a great place to have startup stuff. 482 # Put things in ~/.owl/startup 483 484 #So that the user's .owlconf can have startsubs, we don't clear 485 #onStartSubs; reload does however 486 @onReceiveMsg = (); 487 @onMainLoop = (); 488 @onGetBuddyList = (); 489 490 BarnOwl::onStart(); 491 492 runHook(\@onStartSubs); 493 416 sub _startup { 417 _load_owlconf(); 418 419 if(eval {require BarnOwl::ModuleLoader}) { 420 eval { 421 BarnOwl::ModuleLoader->load_all; 422 }; 423 } else { 424 BarnOwl::error("Can't load BarnOwl::ModuleLoader, loadable module support disabled:\n$@"); 425 } 426 427 $startup->run; 494 428 BarnOwl::startup() if *BarnOwl::startup{CODE}; 495 429 } 496 430 497 sub shutdown 498 { 499 # Modern versions of owl provides a great place to have shutdown stuff. 500 # Put things in ~/.owl/shutdown 501 502 # use $shutdown to tell modules that that's what we're doing. 503 $BarnOwl::shutdown = 1; 431 sub _shutdown { 432 $shutdown->run; 433 434 BarnOwl::shutdown() if *BarnOwl::shutdown{CODE}; 435 } 436 437 sub _receive_msg { 438 my $m = shift; 439 440 $receiveMessage->run($m); 441 442 BarnOwl::receive_msg($m) if *BarnOwl::receive_msg{CODE}; 443 } 444 445 sub _mainloop_hook { 446 $mainLoop->run; 504 447 BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE}; 505 506 BarnOwl::shutdown() if *BarnOwl::shutdown{CODE}; 507 } 508 509 sub mainloop_hook 510 { 511 runHook(\@onMainLoop); 512 BarnOwl::mainloop_hook() if *BarnOwl::mainloop_hook{CODE}; 513 } 514 515 ################################################################################ 516 # Hooks into receive_msg() 517 ################################################################################ 518 519 sub receive_msg 520 { 521 my $m = shift; 522 runHook(\@onReceiveMsg, $m); 523 BarnOwl::receive_msg($m) if *BarnOwl::receive_msg{CODE}; 524 } 525 526 ################################################################################ 527 # Hooks into get_blist() 528 ################################################################################ 529 530 sub get_blist 531 { 532 return runHook_accumulate(\@onGetBuddyList); 448 } 449 450 sub _get_blist { 451 return join("\n", $getBuddyList->run); 533 452 } 534 453 … … 554 473 } 555 474 } 475 476 BarnOwl::_create_style("default", "BarnOwl::Style::Default::format_message", "Default style"); 556 477 557 478 BarnOwl::_create_style("default", "BarnOwl::Style::Default::format_message", "Default style"); … … 644 565 # switch to package main when we're done 645 566 package main; 646 # alias the hooks 647 { 648 no strict 'refs'; 649 foreach my $hook qw (onStartSubs 650 onReceiveMsg 651 onMainLoop 652 onGetBuddyList ) { 653 *{"main::".$hook} = \*{"BarnOwl::Hooks::".$hook}; 654 *{"owl::".$hook} = \*{"BarnOwl::Hooks::".$hook}; 655 } 656 } 567 568 # Shove a bunch of fake entries into @INC so modules can use or 569 # require them without choking 570 $::INC{$_} = 1 for (qw(BarnOwl.pm BarnOwl/Hooks.pm 571 BarnOwl/Message.pm BarnOwl/Style.pm)); 657 572 658 573 1; 574
Note: See TracChangeset
for help on using the changeset viewer.