Changeset f2f5815
- Timestamp:
- Nov 2, 2006, 10:19:15 PM (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:
- 0ff8d110
- Parents:
- 591ea418
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
perlwrap.pm
r591ea418 rf2f5815 284 284 package owl; 285 285 286 # Arrays of function pointers to be called at specific times.286 # Arrays of subrefs to be called at specific times. 287 287 our @onStartSubs = (); 288 our @onReceiveMsg = undef;289 our @onMainLoop = undef;290 our @onGetBuddyList = undef;288 our @onReceiveMsg = (); 289 our @onMainLoop = (); 290 our @onGetBuddyList = (); 291 291 292 292 ################################################################################ … … 306 306 $reload = 0; 307 307 308 sub owl::mainloop_hook 309 { 310 foreach (@onMainLoop) 311 { 312 &$_(); 313 } 314 return; 308 # Functions to call hook lists 309 sub runHook($@) 310 { 311 my $hook = shift; 312 my @args = @_; 313 $_->(@args) for (@$hook); 314 } 315 316 sub runHook_accumulate($@) 317 { 318 my $hook = shift; 319 use Data::Dumper; 320 my @args = @_; 321 return join("\n", map {$_->(@args)} @$hook); 322 } 323 324 sub mainloop_hook 325 { 326 runHook(\@onMainLoop); 315 327 } 316 328 … … 318 330 # Startup and Shutdown code 319 331 ################################################################################ 320 sub owl::startup332 sub startup 321 333 { 322 334 # Modern versions of owl provides a great place to have startup stuff. … … 325 337 } 326 338 327 sub owl::shutdown339 sub shutdown 328 340 { 329 341 # Modern versions of owl provides a great place to have shutdown stuff. … … 333 345 # should terminate. 334 346 $shutdown = 1; 335 owl::mainloop_hook();347 mainloop_hook(); 336 348 } 337 349 … … 347 359 348 360 loadModules(); 349 foreach (@onStartSubs) 350 { 351 &$_(); 352 } 361 runHook(\@onStartSubs); 353 362 } 354 363 ################################################################################ … … 395 404 ################################################################################ 396 405 397 sub loadModules () 398 { 399 my @modules; 400 foreach my $dir (owl::get_data_dir()."/owl/modules", $ENV{HOME}."/.owl/modules") { 401 opendir(MODULES, $dir); 402 # source ./modules/*.pl 403 @modules = grep(/\.pl$/, readdir(MODULES)); 404 405 foreach my $mod (@modules) { 406 do "$dir/$mod"; 407 } 408 closedir(MODULES); 409 } 410 } 406 sub loadModules () { 407 my @modules; 408 foreach my $dir ( owl::get_data_dir() . "/owl/modules", 409 $ENV{HOME} . "/.owl/modules" ) 410 { 411 opendir( MODULES, $dir ); 412 413 # source ./modules/*.pl 414 @modules = grep( /\.pl$/, readdir(MODULES) ); 415 416 foreach my $mod (@modules) { 417 do "$dir/$mod"; 418 } 419 closedir(MODULES); 420 } 421 422 } 423 411 424 412 425 … … 415 428 ################################################################################ 416 429 417 sub owl::receive_msg430 sub receive_msg 418 431 { 419 432 my $m = shift; 420 foreach (@onReceiveMsg) 421 { 422 &$_($m); 423 } 433 runHook(\@onReceiveMsg, $m); 424 434 } 425 435 … … 428 438 ################################################################################ 429 439 430 sub owl::get_blist440 sub get_blist 431 441 { 432 442 my $m = shift; 433 foreach (@onGetBuddyList) 434 { 435 &$_($m); 436 } 443 return runHook_accumulate(\@onGetBuddyList, $m); 437 444 } 438 445
Note: See TracChangeset
for help on using the changeset viewer.