Changes in / [3066d23:1cf32e7d]
- Files:
-
- 59 added
- 44 deleted
- 10 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] -
Makefile.in
ra956288 r702aee7 31 31 32 32 EXE = barnowl 33 PERL_MODULES = Jabber 34 MODULE_DIRS = $(PERL_MODULES:%=perl/modules/%) 33 35 34 36 BASE_OBJS = $(BASE_SRCS:.c=.o) … … 57 59 ./tester reg 58 60 59 clean: libfaimclean 61 clean: libfaimclean modules_clean 60 62 $(RM) $(EXE) tester *.o $(AUTOGEN) owl_prototypes.h.new 61 63 62 64 distclean: clean libfaimdistclean 63 65 $(RM) config.cache config.log config.status Makefile config.h TAGS *~ core 66 67 .PHONY: $(MODULE_DIRS) 68 69 modules: $(MODULE_DIRS) 70 modules_clean: 71 for i in $(MODULE_DIRS); do \ 72 cd $$i; test ! -f Makefile || make clean; \ 73 done 74 75 $(MODULE_DIRS): %: %/Makefile 76 ( cd $@ && make $(notdir $@).par ) 77 78 $(MODULE_DIRS:=/Makefile): %/Makefile: %/Makefile.PL 79 ( cd $(dir $@) && perl -I../../lib Makefile.PL ) 64 80 65 81 proto: owl_prototypes.h … … 104 120 (cd libfaim; $(MAKE) distclean) 105 121 106 all: $(EXE) 122 all: $(EXE) $(MODULE_DIRS) 107 123 108 124 install: all installdirs 109 125 ${INSTALL_PROGRAM} $(EXE) ${DESTDIR}${bindir}/$(EXE) 110 126 ${INSTALL_DATA} doc/owl.1 ${DESTDIR}${mandir}/man1/barnowl.1 111 tar -C perl -c . | tar -C ${DESTDIR}${datadir} -x 127 ${INSTALL} -d ${DESTDIR}${datadir}/lib 128 ${INSTALL} -d ${DESTDIR}${datadir}/modules 129 tar -C perl/lib --exclude .svn -c . | tar -C ${DESTDIR}${datadir}/lib -x 130 for i in $(PERL_MODULES); do \ 131 ${INSTALL_DATA} perl/modules/$$i/$$i.par ${DESTDIR}${datadir}/modules/$$i.par; \ 132 done 112 133 113 134 installdirs: mkinstalldirs -
fmtext.c
r801b7ac ra387d12e 9 9 { 10 10 f->textlen=0; 11 f->textbuff=owl_strdup(""); 11 f->bufflen=5; 12 f->textbuff=owl_malloc(5); 12 13 f->fmbuff=owl_malloc(5); 13 14 f->fgcolorbuff=owl_malloc(5); 14 15 f->bgcolorbuff=owl_malloc(5); 16 f->textbuff[0]=0; 15 17 f->fmbuff[0]=OWL_FMTEXT_ATTR_NONE; 16 18 f->fgcolorbuff[0]=OWL_COLOR_DEFAULT; … … 18 20 } 19 21 22 /* Clear the data from an fmtext, but don't deallocate memory. This 23 fmtext can then be appended to again. */ 24 void owl_fmtext_clear(owl_fmtext *f) 25 { 26 f->textlen = 0; 27 f->textbuff[0] = 0; 28 f->fmbuff[0]=OWL_FMTEXT_ATTR_NONE; 29 f->fgcolorbuff[0]=OWL_COLOR_DEFAULT; 30 f->bgcolorbuff[0]=OWL_COLOR_DEFAULT; 31 } 32 20 33 /* Internal function. Set the attribute 'attr' from index 'first' to 21 34 * index 'last' … … 59 72 } 60 73 74 void _owl_fmtext_realloc(owl_fmtext *f, int newlen) /*noproto*/ 75 { 76 if(newlen + 1 > f->bufflen) { 77 f->textbuff=owl_realloc(f->textbuff, newlen+1); 78 f->fmbuff=owl_realloc(f->fmbuff, newlen+1); 79 f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+1); 80 f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+1); 81 f->bufflen = newlen+1; 82 } 83 } 84 61 85 /* append text to the end of 'f' with attribute 'attr' and color 62 86 * 'color' … … 65 89 { 66 90 int newlen; 67 68 91 newlen=strlen(f->textbuff)+strlen(text); 69 f->textbuff=owl_realloc(f->textbuff, newlen+2); 70 f->fmbuff=owl_realloc(f->fmbuff, newlen+2); 71 f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+2); 72 f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+2); 73 92 _owl_fmtext_realloc(f, newlen); 93 74 94 strcat(f->textbuff, text); 75 95 _owl_fmtext_set_attr(f, attr, f->textlen, newlen); … … 154 174 155 175 newlen=strlen(f->textbuff)+(stop-start+1); 156 f->textbuff=owl_realloc(f->textbuff, newlen+1); 157 f->fmbuff=owl_realloc(f->fmbuff, newlen+1); 158 f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+1); 159 f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+1); 176 _owl_fmtext_realloc(f, newlen); 160 177 161 178 strncat(f->textbuff, in->textbuff+start, stop-start+1); -
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); -
global.c
r8e401cae ra387d12e 108 108 109 109 owl_obarray_init(&(g->obarray)); 110 111 owl_message_init_fmtext_cache(); 110 112 } 111 113 -
message.c
r963542b ra387d12e 13 13 static const char fileIdent[] = "$Id$"; 14 14 15 static owl_fmtext_cache fmtext_cache[OWL_FMTEXT_CACHE_SIZE]; 16 static owl_fmtext_cache * fmtext_cache_next = fmtext_cache; 17 18 void owl_message_init_fmtext_cache () 19 { 20 int i; 21 for(i = 0; i < OWL_FMTEXT_CACHE_SIZE; i++) { 22 owl_fmtext_init_null(&(fmtext_cache[i].fmtext)); 23 fmtext_cache[i].message = NULL; 24 } 25 } 26 27 owl_fmtext_cache * owl_message_next_fmtext() /*noproto*/ 28 { 29 if(fmtext_cache_next->message != NULL) { 30 owl_message_invalidate_format(fmtext_cache_next->message); 31 } 32 owl_fmtext_cache * f = fmtext_cache_next; 33 fmtext_cache_next++; 34 if(fmtext_cache_next - fmtext_cache == OWL_FMTEXT_CACHE_SIZE) 35 fmtext_cache_next = fmtext_cache; 36 return f; 37 } 38 15 39 void owl_message_init(owl_message *m) 16 40 { … … 19 43 m->delete=0; 20 44 m->zwriteline=NULL; 21 m->invalid_format=1;22 45 23 46 owl_message_set_hostname(m, ""); … … 29 52 m->timestr[strlen(m->timestr)-1]='\0'; 30 53 31 /* initialize the fmtext */ 32 owl_fmtext_init_null(&(m->fmtext)); 54 m->fmtext = NULL; 33 55 } 34 56 … … 106 128 void owl_message_invalidate_format(owl_message *m) 107 129 { 108 m->invalid_format=1; 130 if(m->fmtext) { 131 m->fmtext->message = NULL; 132 owl_fmtext_clear(&(m->fmtext->fmtext)); 133 m->fmtext=NULL; 134 } 109 135 } 110 136 … … 112 138 { 113 139 owl_message_format(m); 114 return(&(m->fmtext ));140 return(&(m->fmtext->fmtext)); 115 141 } 116 142 … … 120 146 owl_view *v; 121 147 122 if (m->invalid_format) { 148 if (!m->fmtext) { 149 m->fmtext = owl_message_next_fmtext(); 150 m->fmtext->message = m; 123 151 /* for now we assume there's just the one view and use that style */ 124 152 v=owl_global_get_current_view(&g); 125 153 s=owl_view_get_style(v); 126 154 127 owl_fmtext_free(&(m->fmtext)); 128 owl_fmtext_init_null(&(m->fmtext)); 129 owl_style_get_formattext(s, &(m->fmtext), m); 130 m->invalid_format=0; 155 owl_style_get_formattext(s, &(m->fmtext->fmtext), m); 131 156 } 132 157 } … … 392 417 char *owl_message_get_text(owl_message *m) 393 418 { 394 return(owl_fmtext_get_text(&(m->fmtext )));419 return(owl_fmtext_get_text(&(m->fmtext->fmtext))); 395 420 } 396 421 … … 437 462 if (m == NULL) return(0); 438 463 owl_message_format(m); 439 return(owl_fmtext_num_lines(&(m->fmtext )));464 return(owl_fmtext_num_lines(&(m->fmtext->fmtext))); 440 465 } 441 466 … … 504 529 owl_fmtext_init_null(&b); 505 530 506 owl_fmtext_truncate_lines(&(m->fmtext ), aline, bline-aline+1, &a);531 owl_fmtext_truncate_lines(&(m->fmtext->fmtext), aline, bline-aline+1, &a); 507 532 owl_fmtext_truncate_cols(&a, acol, bcol, &b); 508 533 if (fgcolor!=OWL_COLOR_DEFAULT) { … … 698 723 owl_message_format(m); /* is this necessary? */ 699 724 700 return (owl_fmtext_search(&(m->fmtext ), string));725 return (owl_fmtext_search(&(m->fmtext->fmtext), string)); 701 726 } 702 727 … … 989 1014 owl_list_free_simple(&(m->attributes)); 990 1015 991 owl_ fmtext_free(&(m->fmtext));992 } 1016 owl_message_invalidate_format(m); 1017 } -
owl.c
r2058d7a r72c210f 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 … … 397 397 398 398 owl_function_debugmsg("startup: set style for the view: %s", owl_global_get_default_style(&g)); 399 owl_view_set_style(owl_global_get_current_view(&g), 400 owl_global_get_style_by_name(&g, owl_global_get_default_style(&g))); 399 s = owl_global_get_style_by_name(&g, owl_global_get_default_style(&g)); 400 if(s) 401 owl_view_set_style(owl_global_get_current_view(&g), s); 402 else 403 owl_function_error("No such style: %s", owl_global_get_default_style(&g)); 401 404 402 405 owl_function_debugmsg("startup: setting context interactive"); -
owl.h
rd08162a ra387d12e 249 249 typedef struct _owl_fmtext { 250 250 int textlen; 251 int bufflen; 251 252 char *textbuff; 252 253 char *fmbuff; … … 329 330 } owl_pair; 330 331 332 struct _owl_fmtext_cache; 333 331 334 typedef struct _owl_message { 332 335 int id; … … 335 338 ZNotice_t notice; 336 339 #endif 337 owl_fmtext fmtext; /* this is now only a CACHED copy */ 338 int invalid_format; /* indicates whether fmtext needs to be regenerated */ 340 struct _owl_fmtext_cache * fmtext; 339 341 int delete; 340 342 char *hostname; … … 344 346 char *zwriteline; 345 347 } owl_message; 348 349 #define OWL_FMTEXT_CACHE_SIZE 1000 350 /* We cache the saved fmtexts for the last bunch of messages we 351 rendered */ 352 typedef struct _owl_fmtext_cache { 353 owl_message * message; 354 owl_fmtext fmtext; 355 } owl_fmtext_cache; 346 356 347 357 typedef struct _owl_style { -
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
r37dd88c r18a99d2 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; … … 15 14 16 15 package BarnOwl; 17 18 16 19 17 BEGIN { … … 44 42 my ($m) = @_; 45 43 $m->legacy_populate_global(); 46 return &BarnOwl::Hooks:: receive_msg($m);44 return &BarnOwl::Hooks::_receive_msg($m); 47 45 } 48 46 … … 204 202 205 203 sub smartfilter { 206 die("smartfilter not supported for this message ");204 die("smartfilter not supported for this message\n"); 207 205 } 208 206 … … 351 349 ##################################################################### 352 350 ################################################################################ 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 } 351 352 package BarnOwl::Hook; 353 354 sub new { 355 my $class = shift; 356 return bless [], $class; 357 } 358 359 sub run { 360 my $self = shift; 361 my @args = @_; 362 return map {$_->(@args)} @$self; 363 } 364 365 sub add { 366 my $self = shift; 367 my $func = shift; 368 die("Not a coderef!") unless ref($func) eq 'CODE'; 369 push @$self, $func; 370 } 371 372 sub clear { 373 my $self = shift; 374 @$self = (); 375 } 376 377 package BarnOwl::Hooks; 378 379 use Exporter; 380 381 our @EXPORT_OK = qw($startup $shutdown 382 $receiveMessage $mainLoop 383 $getBuddyList); 384 385 our %EXPORT_TAGS = (all => [@EXPORT_OK]); 386 387 our $startup = BarnOwl::Hook->new; 388 our $shutdown = BarnOwl::Hook->new; 389 our $receiveMessage = BarnOwl::Hook->new; 390 our $mainLoop = BarnOwl::Hook->new; 391 our $getBuddyList = BarnOwl::Hook->new; 392 393 # Internal startup/shutdown routines called by the C code 432 394 433 395 sub _load_owlconf { 434 # Only do this the first time435 return if $BarnOwl::reload;436 396 # load the config file 437 397 if ( -r $BarnOwl::configfile ) { … … 451 411 } 452 412 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 413 sub _startup { 414 _load_owlconf(); 415 416 if(eval {require BarnOwl::ModuleLoader}) { 417 eval { 418 BarnOwl::ModuleLoader->load_all; 419 }; 420 BarnOwl::error("Error loading modules: $@") if $@; 421 } else { 422 BarnOwl::error("Can't load BarnOwl::ModuleLoader, loadable module support disabled:\n$@"); 423 } 424 425 $startup->run(0); 494 426 BarnOwl::startup() if *BarnOwl::startup{CODE}; 495 427 } 496 428 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; 429 sub _shutdown { 430 $shutdown->run; 431 432 BarnOwl::shutdown() if *BarnOwl::shutdown{CODE}; 433 } 434 435 sub _receive_msg { 436 my $m = shift; 437 438 $receiveMessage->run($m); 439 440 BarnOwl::receive_msg($m) if *BarnOwl::receive_msg{CODE}; 441 } 442 443 sub _mainloop_hook { 444 $mainLoop->run; 504 445 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); 446 } 447 448 sub _get_blist { 449 return join("\n", $getBuddyList->run); 533 450 } 534 451 … … 644 561 # switch to package main when we're done 645 562 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 } 563 564 # Shove a bunch of fake entries into @INC so modules can use or 565 # require them without choking 566 $::INC{$_} = 1 for (qw(BarnOwl.pm BarnOwl/Hooks.pm 567 BarnOwl/Message.pm BarnOwl/Style.pm)); 657 568 658 569 1; 570
Note: See TracChangeset
for help on using the changeset viewer.