Changeset 484b14d
- Timestamp:
- Mar 16, 2009, 9:04:38 AM (15 years ago)
- Branches:
- debian
- Children:
- 0f8bdd7
- Parents:
- 4779b8c (diff), 879e90dc (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 25 added
- 2 deleted
- 14 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r8d07892a r484b14d 1 1 *.a 2 *.o 3 *.par 4 *~ 5 META.yml 6 Makefile 7 TAGS 8 aclocal.m4 2 9 autom4te.cache 3 10 barnowl … … 5 12 config.cache 6 13 config.h 14 config.h.in 7 15 config.log 8 16 config.status … … 10 18 core 11 19 jabber.log 12 Makefile13 META.yml14 *.o15 20 owl_prototypes.h 16 21 owl_prototypes.h.new 17 *.par18 22 perlglue.c 19 23 perlwrap.c 20 24 pm_to_blib 21 TAGS22 25 tester 23 26 varstubs.c -
COPYING
r17e2357 r23e1110 1 Copyright (c) 2006-200 8The BarnOwl Developers. All rights reserved.1 Copyright (c) 2006-2009 The BarnOwl Developers. All rights reserved. 2 2 Copyright (c) 2004 James Kretchmar. All rights reserved. 3 3 -
ChangeLog
reef5b52 r879e90dc 1 1.1 2 * Support building with -fstack-protector. -hartmans 3 * Don't save partial passwords in editwin history. -nelhage 4 * Improve IRC documentation. -nelhage 5 * Don't use the 'zsender' variable for personals. -geofft 6 * Implement irc-quote and irc-mode. -nelhage 7 * Leave a one-column margin when wordwrapping. -nelhage 8 * Remove some autotools-generated files. -andersk 9 * Include IRC in the default build. -nelhage 10 * Add a wordwrapping variant of the default style. -nelhage 11 * Don't send stderr to admin messages. -nelhage 12 * Remove a build-dependency on krb4. -hartmans 13 * Allow the creation of type zephyr messages from perl. -geofft 14 * Initialize Zephyr asynchronously at startup. -nelhage 15 1 16 1.0.5 2 17 * Implement initial support for real timers. -nelhage -
Makefile.in
rf4d817d rf200413 33 33 34 34 EXE = barnowl 35 PERL_MODULES = Jabber IRC 35 PERL_MODULES = Jabber IRC WordWrap 36 36 MODULE_DIRS = $(PERL_MODULES:%=perl/modules/%) 37 37 … … 79 79 modules_clean: 80 80 for i in $(MODULE_DIRS); do \ 81 cd $$i; test ! -f Makefile || make clean;\81 (cd $$i && (test ! -f Makefile || make clean)) \ 82 82 done 83 83 -
commands.c
rf34dd65 r6e400cc 2650 2650 owl_function_makemsg("Command cancelled."); 2651 2651 2652 hist=owl_editwin_get_history(e); 2653 owl_history_store(hist, owl_editwin_get_text(e)); 2654 owl_history_reset(hist); 2652 if(e->echochar == 0) { 2653 hist=owl_editwin_get_history(e); 2654 owl_history_store(hist, owl_editwin_get_text(e)); 2655 owl_history_reset(hist); 2656 } 2655 2657 2656 2658 owl_editwin_fullclear(e); -
configure.ac
r17acafb rb5fe6d2 11 11 CFLAGS="$CFLAGS -Wall -g"; 12 12 fi 13 14 m4_include(/usr/share/aclocal/pkg.m4)15 dnl m4_include(pkg.m4)16 13 17 14 dnl Check for Athena -
functions.c
rb4c270c r45cf49f 127 127 text="" 128 128 "barnowl version " OWL_VERSION_STRING "\n" 129 "Copyright (c) 2006-200 8The BarnOwl Developers. All rights reserved.\n"129 "Copyright (c) 2006-2009 The BarnOwl Developers. All rights reserved.\n" 130 130 "Copyright (c) 2004 James Kretchmar. All rights reserved.\n" 131 131 "\n" … … 921 921 if (!owl_context_is_interactive(owl_global_get_context(&g))) return; 922 922 if (ret==0) { 923 owl_function_makemsg("Subscribed to login messages from file.");924 923 } else if (ret==-1) { 925 924 owl_function_error("Could not open file for login subscriptions."); … … 1398 1397 "because we feel our owls should live closer to our ponies.\n" 1399 1398 "\n" 1400 "Copyright (c) 2006-200 8The BarnOwl Developers. All rights reserved.\n"1399 "Copyright (c) 2006-2009 The BarnOwl Developers. All rights reserved.\n" 1401 1400 "Copyright (c) 2004 James Kretchmar. All rights reserved.\n" 1402 1401 "Copyright 2002 Massachusetts Institute of Technology\n" … … 3289 3288 void owl_function_source(char *filename) 3290 3289 { 3290 char *path; 3291 3291 FILE *file; 3292 3292 char buff[LINE]; … … 3295 3295 if (!filename) { 3296 3296 fail_silent = 1; 3297 filename=owl_global_get_startupfile(&g); 3298 } 3299 file=fopen(filename, "r"); 3297 path = owl_strdup(owl_global_get_startupfile(&g)); 3298 } else { 3299 path = owl_util_makepath(filename); 3300 } 3301 file=fopen(path, "r"); 3302 owl_free(path); 3300 3303 if (!file) { 3301 3304 if (!fail_silent) { … … 3349 3352 { 3350 3353 va_list ap; 3351 char *buff , *buff2;3354 char *buff; 3352 3355 char *nl; 3353 char *date;3354 time_t now;3355 3356 now=time(NULL);3357 date=owl_strdup(ctime(&now));3358 date[strlen(date)-1]='\0';3359 3356 3360 3357 va_start(ap, fmt); 3361 3358 3362 3359 buff = g_strdup_vprintf(fmt, ap); 3363 buff2 = owl_sprintf("%s %s", date, buff);3364 3360 owl_function_debugmsg("ERROR: %s", buff); 3365 3361 nl = strchr(buff, '\n'); … … 3370 3366 owl_function_makemsg("[Error] %s", buff); 3371 3367 } 3372 owl_ errqueue_append_err(owl_global_get_errqueue(&g), buff2);3368 owl_function_log_err(buff); 3373 3369 va_end(ap); 3370 owl_free(buff); 3371 } 3372 3373 void owl_function_log_err(char *string) 3374 { 3375 char *date; 3376 time_t now; 3377 char *buff; 3378 3379 now=time(NULL); 3380 date=owl_strdup(ctime(&now)); 3381 date[strlen(date)-1]='\0'; 3382 3383 buff = owl_sprintf("%s %s", date, string); 3384 3385 owl_errqueue_append_err(owl_global_get_errqueue(&g), buff); 3386 3387 owl_free(buff); 3374 3388 owl_free(date); 3375 owl_free(buff);3376 owl_free(buff2);3377 3389 } 3378 3390 -
owl.c
r28fa23c r5283b01 1 /* Copyright (c) 2006-200 8The BarnOwl Developers. All rights reserved.1 /* Copyright (c) 2006-2009 The BarnOwl Developers. All rights reserved. 2 2 * Copyright (c) 2004 James Kretchmar. All rights reserved. 3 3 * … … 43 43 owl_editwin *tw; 44 44 owl_popwin *pw; 45 int ret, initialsubs,debug, argcsave, followlast;45 int debug, argcsave, followlast; 46 46 int newmsgs, nexttimediff; 47 47 struct sigaction sigact; … … 65 65 tty=NULL; 66 66 debug=0; 67 initialsubs=1;67 g.load_initial_subs = 1; 68 68 69 69 setlocale(LC_ALL, ""); … … 75 75 while (argc>0) { 76 76 if (!strcmp(argv[0], "-n")) { 77 initialsubs=0;77 g.load_initial_subs = 0; 78 78 argv++; 79 79 argc--; … … 191 191 owl_select_add_dispatch(d); 192 192 } 193 194 #ifdef HAVE_LIBZEPHYR 195 /* zephyr init */ 196 ret=owl_zephyr_initialize(); 197 if (!ret) { 198 owl_dispatch *d = owl_malloc(sizeof(owl_dispatch)); 199 d->fd = ZGetFD(); 200 d->cfunc = &owl_zephyr_process_events; 201 d->destroy = NULL; 202 owl_select_add_dispatch(d); 203 owl_global_set_havezephyr(&g); 204 } 205 206 #endif 193 194 owl_zephyr_initialize(); 207 195 208 196 #if OWL_STDERR_REDIR … … 339 327 340 328 wrefresh(sepwin); 341 342 /* load zephyr subs */343 if (initialsubs) {344 int ret2;345 owl_function_debugmsg("startup: loading initial zephyr subs");346 347 /* load default subscriptions */348 ret=owl_zephyr_loaddefaultsubs();349 350 /* load subscriptions from subs file */351 ret2=owl_zephyr_loadsubs(NULL, 0);352 353 if (ret || ret2) {354 owl_function_adminmsg("", "Error loading zephyr subscriptions");355 } else if (ret2!=-1) {356 owl_global_add_userclue(&g, OWL_USERCLUE_CLASSES);357 }358 359 /* load login subscriptions */360 if (owl_global_is_loginsubs(&g)) {361 owl_function_debugmsg("startup: loading login subs");362 owl_function_loadloginsubs(NULL);363 }364 }365 329 366 330 /* First buddy check to sync the list without notifications */ … … 753 717 char buf[4096]; 754 718 int rfd = d->fd; 719 char *err; 720 755 721 if (rfd<0) return; 756 722 if (-1 == ioctl(rfd, FIONREAD, (void*)&navail)) { … … 766 732 buf[navail] = '\0'; 767 733 } 768 owl_function_error("[stderr]\n%s", buf); 734 735 err = owl_sprintf("[stderr]\n%s", buf); 736 737 owl_function_log_err(err); 769 738 } 770 739 -
owl.h
reef5b52 r879e90dc 1 /* Copyright (c) 2006-200 8The BarnOwl Developers. All rights reserved.1 /* Copyright (c) 2006-2009 The BarnOwl Developers. All rights reserved. 2 2 * Copyright (c) 2004 James Kretchmar. All rights reserved. 3 3 * … … 52 52 53 53 #ifndef OWL_VERSION_STRING 54 #define OWL_VERSION_STRING "1. 0.5"54 #define OWL_VERSION_STRING "1.1" 55 55 #endif 56 56 … … 594 594 GList *timerlist; 595 595 owl_timer *aim_nop_timer; 596 int load_initial_subs; 596 597 } owl_global; 597 598 -
perl/modules/IRC/lib/BarnOwl/Module/IRC.pm
r56d0189 re0fba58 69 69 } 70 70 71 sub quickstart { 72 return <<'END_QUICKSTART'; 73 @b[IRC:] 74 Use ':irc-connect @b[server]' to connect to an IRC server, and 75 ':irc-join @b[#channel]' to join a channel. ':irc-msg @b[#channel] 76 @b[message]' sends a message to a channel. 77 END_QUICKSTART 78 } 79 71 80 #sub mainloop_hook { 72 81 # return unless defined $irc; … … 93 102 } 94 103 104 use constant OPTIONAL_CHANNEL => 1; 105 use constant REQUIRE_CHANNEL => 2; 106 95 107 sub register_commands { 96 BarnOwl::new_command('irc-connect' => \&cmd_connect, 97 { 98 summary => 'Connect to an IRC server', 99 usage => 'irc-connect [-a ALIAS ] [-s] [-p PASSWORD] [-n NICK] SERVER [port]', 100 description => 101 102 "Connect to an IRC server. Supported options are\n\n" . 103 "-a <alias> Define an alias for this server\n" . 104 "-s Use SSL\n" . 105 "-p <password> Specify the password to use\n" . 106 "-n <nick> Use a non-default nick" 107 }); 108 BarnOwl::new_command('irc-disconnect' => \&cmd_disconnect); 109 BarnOwl::new_command('irc-msg' => \&cmd_msg); 110 BarnOwl::new_command('irc-join' => \&cmd_join); 111 BarnOwl::new_command('irc-part' => \&cmd_part); 112 BarnOwl::new_command('irc-nick' => \&cmd_nick); 113 BarnOwl::new_command('irc-names' => \&cmd_names); 114 BarnOwl::new_command('irc-whois' => \&cmd_whois); 115 BarnOwl::new_command('irc-motd' => \&cmd_motd); 116 BarnOwl::new_command('irc-list' => \&cmd_list); 117 BarnOwl::new_command('irc-who' => \&cmd_who); 118 BarnOwl::new_command('irc-stats' => \&cmd_stats); 119 BarnOwl::new_command('irc-topic' => \&cmd_topic); 120 } 108 BarnOwl::new_command( 109 'irc-connect' => \&cmd_connect, 110 { 111 summary => 'Connect to an IRC server', 112 usage => 113 'irc-connect [-a ALIAS ] [-s] [-p PASSWORD] [-n NICK] SERVER [port]', 114 description => 115 116 <<END_DESCR 117 Connect to an IRC server. Supported options are 118 119 -a <alias> Define an alias for this server 120 -s Use SSL 121 -p <password> Specify the password to use 122 -n <nick> Use a non-default nick 123 124 The -a option specifies an alias to use for this connection. This 125 alias can be passed to the '-a' argument of any other IRC command to 126 control which connection it operates on. 127 128 For servers with hostnames of the form "irc.FOO.{com,org,...}", the 129 alias will default to "FOO"; For other servers the full hostname is 130 used. 131 END_DESCR 132 } 133 ); 134 135 BarnOwl::new_command( 136 'irc-disconnect' => mk_irc_command( \&cmd_disconnect ), 137 { 138 summary => 'Disconnect from an IRC server', 139 usage => 'irc-disconnect [-a ALIAS]', 140 141 description => <<END_DESCR 142 Disconnect from an IRC server. You can specify a specific server with 143 "-a SERVER-ALIAS" if necessary. 144 END_DESCR 145 } 146 ); 147 148 BarnOwl::new_command( 149 'irc-msg' => mk_irc_command( \&cmd_msg ), 150 { 151 summary => 'Send an IRC message', 152 usage => 'irc-msg [-a ALIAS] DESTINATION MESSAGE', 153 154 description => <<END_DESCR 155 Send an IRC message 156 END_DESCR 157 } 158 ); 159 160 BarnOwl::new_command( 161 'irc-mode' => mk_irc_command( \&cmd_mode, OPTIONAL_CHANNEL ), 162 { 163 summary => 'Change an IRC channel or user mode', 164 usage => 'irc-mode [-a ALIAS] TARGET [+-]MODE OPTIONS', 165 166 description => <<END_DESCR 167 168 Change the mode of an IRC user or channel. 169 END_DESCR 170 } 171 ); 172 173 BarnOwl::new_command( 174 'irc-join' => mk_irc_command( \&cmd_join ), 175 { 176 summary => 'Join an IRC channel', 177 usage => 'irc-join [-a ALIAS] #channel', 178 179 description => <<END_DESCR 180 181 Join an IRC channel. 182 END_DESCR 183 } 184 ); 185 186 BarnOwl::new_command( 187 'irc-part' => mk_irc_command( \&cmd_part, REQUIRE_CHANNEL ), 188 { 189 summary => 'Leave an IRC channel', 190 usage => 'irc-part [-a ALIAS] #channel', 191 192 description => <<END_DESCR 193 194 Part from an IRC channel. 195 END_DESCR 196 } 197 ); 198 199 BarnOwl::new_command( 200 'irc-nick' => mk_irc_command( \&cmd_nick ), 201 { 202 summary => 'Change your IRC nick on an existing connection.', 203 usage => 'irc-nick [-a ALIAS] NEW-NICK', 204 205 description => <<END_DESCR 206 207 Set your IRC nickname on an existing connect. To change it prior to 208 connecting, adjust the `irc:nick' variable. 209 END_DESCR 210 } 211 ); 212 213 BarnOwl::new_command( 214 'irc-names' => mk_irc_command( \&cmd_names, REQUIRE_CHANNEL ), 215 { 216 summary => 'View the list of users in a channel', 217 usage => 'irc-names [-a ALIAS] #channel', 218 219 description => <<END_DESCR 220 221 `irc-names' displays the list of users in a given channel in a pop-up 222 window. 223 END_DESCR 224 } 225 ); 226 227 BarnOwl::new_command( 228 'irc-whois' => mk_irc_command( \&cmd_whois ), 229 { 230 summary => 'Displays information about a given IRC user', 231 usage => 'irc-whois [-a ALIAS] NICK', 232 233 description => <<END_DESCR 234 235 Pops up information about a given IRC user. 236 END_DESCR 237 } 238 ); 239 240 BarnOwl::new_command( 241 'irc-motd' => mk_irc_command( \&cmd_motd ), 242 { 243 summary => 'Displays an IRC server\'s MOTD (Message of the Day)', 244 usage => 'irc-motd [-a ALIAS]', 245 246 description => <<END_DESCR 247 248 Displays an IRC server's message of the day. 249 END_DESCR 250 } 251 ); 252 253 BarnOwl::new_command( 254 'irc-list' => \&cmd_list, 255 { 256 summary => 'Show all the active IRC connections.', 257 usage => 'irc-list', 258 259 description => <<END_DESCR 260 261 Show all the currently active IRC connections with their aliases and 262 server names. 263 END_DESCR 264 } 265 ); 266 267 BarnOwl::new_command( 'irc-who' => mk_irc_command( \&cmd_who ) ); 268 BarnOwl::new_command( 'irc-stats' => mk_irc_command( \&cmd_stats ) ); 269 270 BarnOwl::new_command( 271 'irc-topic' => mk_irc_command( \&cmd_topic, REQUIRE_CHANNEL ), 272 { 273 summary => 'View or change the topic of an IRC channel', 274 usage => 'irc-topic [-a ALIAS] #channel [TOPIC]', 275 276 description => <<END_DESCR 277 278 Without extra arguments, fetches and displays a given channel's topic. 279 280 With extra arguments, changes the target channel's topic string. This 281 may require +o on some channels. 282 END_DESCR 283 } 284 ); 285 286 BarnOwl::new_command( 287 'irc-quote' => mk_irc_command( \&cmd_quote ), 288 { 289 summary => 'Send a raw command to the IRC servers.', 290 usage => 'irc-quote [-a ALIAS] TEXT', 291 292 description => <<END_DESCR 293 294 Send a raw command line to an IRC server. 295 296 This can be used to perform some operation not yet supported by 297 BarnOwl, or to define new IRC commands. 298 END_DESCR 299 } 300 ); 301 } 302 121 303 122 304 $BarnOwl::Hooks::startup->add('BarnOwl::Module::IRC::startup'); 123 305 $BarnOwl::Hooks::shutdown->add('BarnOwl::Module::IRC::shutdown'); 306 $BarnOwl::Hooks::getQuickstart->add('BarnOwl::Module::IRC::quickstart'); 124 307 125 308 ################################################################################ … … 189 372 sub cmd_disconnect { 190 373 my $cmd = shift; 191 my $conn = get_connection(\@_);374 my $conn = shift; 192 375 $conn->conn->disconnect; 193 376 delete $ircnets{$conn->alias}; … … 195 378 196 379 sub cmd_msg { 197 my $cmd = shift;198 my $conn = get_connection(\@_);199 my $to = shift or die("Usage: $cmd NICK\n");380 my $cmd = shift; 381 my $conn = shift; 382 my $to = shift or die("Usage: $cmd [NICK|CHANNEL]\n"); 200 383 # handle multiple recipients? 201 384 if(@_) { … … 234 417 } 235 418 419 sub cmd_mode { 420 my $cmd = shift; 421 my $conn = shift; 422 my $target = shift; 423 $target ||= shift; 424 $conn->conn->mode($target, @_); 425 } 426 236 427 sub cmd_join { 237 428 my $cmd = shift; 238 my $conn = get_connection(\@_);429 my $conn = shift; 239 430 my $chan = shift or die("Usage: $cmd channel\n"); 240 431 $channels{$chan} ||= []; … … 245 436 sub cmd_part { 246 437 my $cmd = shift; 247 my $conn = get_connection(\@_);248 my $chan = get_channel(\@_) || die("Usage: $cmd <channel>\n");438 my $conn = shift; 439 my $chan = shift; 249 440 $channels{$chan} = [grep {$_ ne $conn} @{$channels{$chan} || []}]; 250 441 $conn->conn->part($chan); … … 253 444 sub cmd_nick { 254 445 my $cmd = shift; 255 my $conn = get_connection(\@_);446 my $conn = shift; 256 447 my $nick = shift or die("Usage: $cmd <new nick>\n"); 257 448 $conn->conn->nick($nick); … … 260 451 sub cmd_names { 261 452 my $cmd = shift; 262 my $conn = get_connection(\@_);263 my $chan = get_channel(\@_) || die("Usage: $cmd <channel>\n");453 my $conn = shift; 454 my $chan = shift; 264 455 $conn->names_tmp([]); 265 456 $conn->conn->names($chan); … … 268 459 sub cmd_whois { 269 460 my $cmd = shift; 270 my $conn = get_connection(\@_);461 my $conn = shift; 271 462 my $who = shift || die("Usage: $cmd <user>\n"); 272 463 $conn->conn->whois($who); … … 275 466 sub cmd_motd { 276 467 my $cmd = shift; 277 my $conn = get_connection(\@_);468 my $conn = shift; 278 469 $conn->conn->motd; 279 470 } … … 290 481 sub cmd_who { 291 482 my $cmd = shift; 292 my $conn = get_connection(\@_);483 my $conn = shift; 293 484 my $who = shift || die("Usage: $cmd <user>\n"); 485 BarnOwl::error("WHO $cmd $conn $who"); 294 486 $conn->conn->who($who); 295 487 } … … 297 489 sub cmd_stats { 298 490 my $cmd = shift; 299 my $conn = get_connection(\@_);491 my $conn = shift; 300 492 my $type = shift || die("Usage: $cmd <chiklmouy> [server] \n"); 301 493 $conn->conn->stats($type, @_); … … 304 496 sub cmd_topic { 305 497 my $cmd = shift; 306 my $conn = get_connection(\@_); 307 $conn->conn->topic(@_); 498 my $conn = shift; 499 my $chan = shift; 500 $conn->conn->topic($chan, @_ ? join(" ", @_) : undef); 501 } 502 503 sub cmd_quote { 504 my $cmd = shift; 505 my $conn = shift; 506 $conn->conn->sl(join(" ", @_)); 308 507 } 309 508 … … 312 511 ################################################################################ 313 512 314 sub get_connection { 315 my $args = shift; 316 if(scalar @$args >= 2 && $args->[0] eq '-a') { 317 shift @$args; 318 return get_connection_by_alias(shift @$args); 319 } 320 my $channel = $args->[-1]; 321 if (defined($channel) && $channel =~ /^#/ 322 and $channels{$channel} and @{$channels{$channel}} == 1) { 323 return $channels{$channel}[0]; 324 } 325 my $m = BarnOwl::getcurmsg(); 326 if($m && $m->type eq 'IRC') { 327 return get_connection_by_alias($m->network); 328 } 329 if(scalar keys %ircnets == 1) { 330 return [values(%ircnets)]->[0]; 331 } 332 die("You must specify a network with -a\n"); 333 } 334 335 sub get_channel { 336 my $args = shift; 337 if(scalar @$args) { 338 return shift @$args; 339 } 340 my $m = BarnOwl::getcurmsg(); 341 if($m && $m->type eq 'IRC') { 342 return $m->channel if !$m->is_private; 343 } 344 return undef; 513 sub mk_irc_command { 514 my $sub = shift; 515 my $use_channel = shift || 0; 516 return sub { 517 my $cmd = shift; 518 my $conn; 519 my $alias; 520 my $channel; 521 my $getopt = Getopt::Long::Parser->new; 522 my $m = BarnOwl::getcurmsg(); 523 524 local @ARGV = @_; 525 $getopt->configure(qw(pass_through permute no_getopt_compat prefix_pattern=-|--)); 526 $getopt->getoptions("alias=s" => \$alias); 527 528 if(defined($alias)) { 529 $conn = get_connection_by_alias($alias); 530 } 531 if(!$conn && $use_channel) { 532 $channel = $ARGV[0]; 533 if(defined($channel) && $channel =~ /^#/) { 534 if($channels{$channel} && @{$channels{$channel}} == 1) { 535 shift @ARGV; 536 $conn = $channels{$channel}[0]; 537 } 538 } else { 539 if($m && $m->type eq 'IRC' && !$m->is_private) { 540 $channel = $m->channel; 541 } else { 542 undef $channel; 543 } 544 } 545 } 546 if(!$channel && $use_channel == REQUIRE_CHANNEL) { 547 die("Usage: $cmd <channel>\n"); 548 } 549 if(!$conn) { 550 if($m && $m->type eq 'IRC') { 551 $conn = get_connection_by_alias($m->network); 552 } 553 } 554 if(!$conn && scalar keys %ircnets == 1) { 555 $conn = [values(%ircnets)]->[0]; 556 } 557 if(!$conn) { 558 die("You must specify an IRC network using -a.\n"); 559 } 560 if($use_channel) { 561 $sub->($cmd, $conn, $channel, @ARGV); 562 } else { 563 $sub->($cmd, $conn, @ARGV); 564 } 565 }; 345 566 } 346 567 -
perl/modules/IRC/lib/BarnOwl/Module/IRC/Connection.pm
r3048f1f r4df2568 73 73 $self->conn->add_handler(endofnames=> sub { shift; $self->on_endofnames(@_) }); 74 74 $self->conn->add_handler(endofwhois=> sub { shift; $self->on_endofwhois(@_) }); 75 $self->conn->add_handler(mode => sub { shift; $self->on_mode(@_) }); 76 77 # * nosuchchannel 78 # * 75 79 76 80 return $self; … … 273 277 } 274 278 279 sub on_mode { 280 my ($self, $evt) = @_; 281 BarnOwl::admin_message("IRC", 282 "[" . $self->alias . "] User " . ($evt->nick) . + " set mode " . 283 join(" ", $evt->args) . "on " . $evt->to->[0] 284 ); 285 } 286 275 287 sub on_event { 276 288 my ($self, $evt) = @_; -
perlconfig.c
re8c6d8f r87dfeb7 129 129 message2hashref and hashref2message. Currently we lose 130 130 zephyr-specific properties stored in the ZNotice_t 131 132 This has been somewhat addressed, but is still not lossless. 131 133 */ 132 134 owl_message * owl_perlconfig_hashref2message(SV *msg) … … 173 175 owl_message_set_attribute(m, "adminheader", ""); 174 176 } 177 #ifdef HAVE_LIBZEPHYR 178 if (owl_message_is_type_zephyr(m)) { 179 ZNotice_t *n = &(m->notice); 180 n->z_kind = ACKED; 181 n->z_port = 0; 182 n->z_auth = ZAUTH_NO; 183 n->z_checked_auth = 0; 184 n->z_class = owl_message_get_class(m); 185 n->z_class_inst = owl_message_get_instance(m); 186 n->z_opcode = owl_message_get_opcode(m); 187 n->z_sender = owl_message_get_sender(m); 188 n->z_recipient = owl_message_get_recipient(m); 189 n->z_default_format = "[zephyr created from perl]"; 190 n->z_multinotice = "[zephyr created from perl]"; 191 n->z_num_other_fields = 0; 192 n->z_message = owl_sprintf("%s%c%s", owl_message_get_zsig(m), '\0', owl_message_get_body(m)); 193 n->z_message_len = strlen(owl_message_get_zsig(m)) + strlen(owl_message_get_body(m)) + 1; 194 } 195 #endif 175 196 return m; 176 197 } -
perlwrap.pm
re9708d2 r19aeff4 1048 1048 my $sender = $m->long_sender; 1049 1049 $sender =~ s/\n.*$//s; 1050 return " (" . $sender . '@color[default]' . ")"; 1050 if (BarnOwl::getvar('colorztext') eq 'on') { 1051 return " (" . $sender . '@color[default]' . ")"; 1052 } else { 1053 return " ($sender)"; 1054 } 1051 1055 } 1052 1056 … … 1058 1062 my $body = $m->body; 1059 1063 if ($m->{should_wordwrap}) { 1060 $body = BarnOwl::wordwrap($body, BarnOwl::getnumcols()- 8);1064 $body = BarnOwl::wordwrap($body, BarnOwl::getnumcols()-9); 1061 1065 } 1062 1066 # replace newline followed by anything with … … 1086 1090 1087 1091 ################################################################################ 1092 1093 sub maybe { 1094 my $thing = shift; 1095 return defined($thing) ? $thing : ""; 1096 } 1088 1097 1089 1098 sub format_login { … … 1136 1145 $line = sprintf(BASE_FORMAT, 1137 1146 $dirsym, 1138 $m->context,1139 $m->subcontext,1147 maybe($m->context), 1148 maybe($m->subcontext), 1140 1149 ($dir eq 'out' 1141 1150 ? $m->pretty_recipient -
zephyr.c
re2a620b ra5e7ed6 9 9 static const char fileIdent[] = "$Id$"; 10 10 11 static GList *deferred_subs = NULL; 12 typedef struct _owl_sub_list { /* noproto */ 13 ZSubscription_t *subs; 14 int nsubs; 15 } owl_sub_list; 16 11 17 #ifdef HAVE_LIBZEPHYR 12 18 Code_t ZResetAuthentication(); 13 19 #endif 14 20 15 int owl_zephyr_initialize() 16 { 17 #ifdef HAVE_LIBZEPHYR 21 #define HM_SVC_FALLBACK htons((unsigned short) 2104) 22 23 #ifdef HAVE_LIBZEPHYR 24 void owl_zephyr_initialize() 25 { 18 26 int ret; 19 ZNotice_t notice;20 21 /* Stat the zhm manually, with a shorter timeout */22 if ((ret = ZOpenPort(NULL)) != ZERR_NONE)23 return(ret);24 25 if ((ret = owl_zhm_stat(¬ice)) != ZERR_NONE)26 return(ret);27 28 ZClosePort();29 30 if ((ret = ZInitialize()) != ZERR_NONE) {31 com_err("owl",ret,"while initializing");32 return(1);33 }34 if ((ret = ZOpenPort(NULL)) != ZERR_NONE) {35 com_err("owl",ret,"while opening port");36 return(1);37 }38 #endif39 return(0);40 }41 42 #ifdef HAVE_LIBZEPHYR43 #define HM_SVC_FALLBACK htons((unsigned short) 2104)44 45 /*46 * Code modified from libzephyr's ZhmStat.c47 *48 * Modified to only wait one second to time out if there is no49 * hostmanager present, rather than a rather excessive 10 seconds.50 */51 Code_t owl_zhm_stat(ZNotice_t *notice) {52 27 struct servent *sp; 53 28 struct sockaddr_in sin; 54 29 ZNotice_t req; 55 30 Code_t code; 56 struct timeval tv; 57 fd_set readers; 31 owl_dispatch *dispatch; 32 33 /* 34 * Code modified from libzephyr's ZhmStat.c 35 * 36 * Modified to add the fd to our select loop, rather than hanging 37 * until we get an ack. 38 */ 39 40 if ((ret = ZOpenPort(NULL)) != ZERR_NONE) { 41 owl_function_error("Error opening Zephyr port: %s", error_message(ret)); 42 return; 43 } 58 44 59 45 (void) memset((char *)&sin, 0, sizeof(struct sockaddr_in)); … … 76 62 req.z_default_format = ""; 77 63 req.z_message_len = 0; 78 79 if ((code = ZSetDestAddr(&sin)) != ZERR_NONE) 80 return(code); 81 82 if ((code = ZSendNotice(&req, ZNOAUTH)) != ZERR_NONE) 83 return(code); 84 85 /* Wait up to 1 second for a response. */ 86 FD_ZERO(&readers); 87 FD_SET(ZGetFD(), &readers); 88 tv.tv_sec = 1; 89 tv.tv_usec = 0; 90 code = select(ZGetFD() + 1, &readers, NULL, NULL, &tv); 91 if (code < 0 && errno != EINTR) 92 return(errno); 93 if (code == 0 || (code < 0 && errno == EINTR) || ZPending() == 0) 94 return(ZERR_HMDEAD); 95 96 return(ZReceiveNotice(notice, (struct sockaddr_in *) 0)); 97 } 98 99 #endif 64 65 if ((code = ZSetDestAddr(&sin)) != ZERR_NONE) { 66 owl_function_error("Initializing Zephyr: %s", error_message(code)); 67 return; 68 } 69 70 if ((code = ZSendNotice(&req, ZNOAUTH)) != ZERR_NONE) { 71 owl_function_error("Initializing Zephyr: %s", error_message(code)); 72 return; 73 } 74 75 dispatch = owl_malloc(sizeof(*dispatch)); 76 dispatch->fd = ZGetFD(); 77 dispatch->cfunc = owl_zephyr_finish_initialization; 78 dispatch->destroy = (void(*)(owl_dispatch*))owl_free; 79 80 owl_select_add_dispatch(dispatch); 81 } 82 83 void owl_zephyr_finish_initialization(owl_dispatch *d) { 84 Code_t code; 85 86 owl_select_remove_dispatch(d->fd); 87 88 ZClosePort(); 89 90 if ((code = ZInitialize()) != ZERR_NONE) { 91 owl_function_error("Initializing Zephyr: %s", error_message(code)); 92 return; 93 } 94 95 if ((code = ZOpenPort(NULL)) != ZERR_NONE) { 96 owl_function_error("Initializing Zephyr: %s", error_message(code)); 97 return; 98 } 99 100 d = owl_malloc(sizeof(owl_dispatch)); 101 d->fd = ZGetFD(); 102 d->cfunc = &owl_zephyr_process_events; 103 d->destroy = NULL; 104 owl_select_add_dispatch(d); 105 owl_global_set_havezephyr(&g); 106 107 if(g.load_initial_subs) { 108 owl_zephyr_load_initial_subs(); 109 } 110 while(deferred_subs != NULL) { 111 owl_sub_list *subs = deferred_subs->data; 112 owl_function_debugmsg("Loading %d deferred subs.", subs->nsubs); 113 owl_zephyr_loadsubs_helper(subs->subs, subs->nsubs); 114 deferred_subs = g_list_delete_link(deferred_subs, deferred_subs); 115 owl_free(subs); 116 } 117 } 118 119 void owl_zephyr_load_initial_subs() { 120 int ret, ret2; 121 122 owl_function_debugmsg("startup: loading initial zephyr subs"); 123 124 /* load default subscriptions */ 125 ret = owl_zephyr_loaddefaultsubs(); 126 127 /* load subscriptions from subs file */ 128 ret2 = owl_zephyr_loadsubs(NULL, 0); 129 130 if (ret || ret2) { 131 owl_function_error("Error loading zephyr subscriptions"); 132 } else if (ret2!=-1) { 133 owl_global_add_userclue(&g, OWL_USERCLUE_CLASSES); 134 } 135 136 /* load login subscriptions */ 137 if (owl_global_is_loginsubs(&g)) { 138 owl_function_debugmsg("startup: loading login subs"); 139 owl_function_loadloginsubs(NULL); 140 } 141 } 142 #else 143 void owl_zephyr_initialize() 144 { 145 } 146 #endif 147 100 148 101 149 int owl_zephyr_shutdown() … … 143 191 int owl_zephyr_loadsubs_helper(ZSubscription_t subs[], int count) 144 192 { 145 int i, ret = 0; 146 /* sub without defaults */ 147 if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) { 148 owl_function_error("Error subscribing to zephyr notifications."); 149 ret=-2; 150 } 151 152 /* free stuff */ 153 for (i=0; i<count; i++) { 154 owl_free(subs[i].zsub_class); 155 owl_free(subs[i].zsub_classinst); 156 owl_free(subs[i].zsub_recipient); 193 int ret; 194 if (owl_global_is_havezephyr(&g)) { 195 int i; 196 /* sub without defaults */ 197 if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) { 198 owl_function_error("Error subscribing to zephyr notifications."); 199 ret=-2; 200 } 201 202 /* free stuff */ 203 for (i=0; i<count; i++) { 204 owl_free(subs[i].zsub_class); 205 owl_free(subs[i].zsub_classinst); 206 owl_free(subs[i].zsub_recipient); 207 } 208 209 owl_free(subs); 210 } else { 211 owl_sub_list *s = owl_malloc(sizeof(owl_sub_list)); 212 s->subs = subs; 213 s->nsubs = count; 214 deferred_subs = g_list_append(deferred_subs, s); 157 215 } 158 216 … … 207 265 208 266 if (count >= subSize) { 209 ZSubscription_t* newsubs; 210 newsubs = owl_realloc(subs, sizeof(ZSubscription_t) * subSize * 2); 211 if (NULL == newsubs) { 212 /* If realloc fails, load what we've got, clear, and continue */ 213 ret = owl_zephyr_loadsubs_helper(subs, count); 214 if (ret != 0) { 215 fclose(file); 216 return(ret); 217 } 218 count=0; 219 } 220 else { 221 subs = newsubs; 222 subSize *= 2; 223 } 267 subSize *= 2; 268 subs = owl_realloc(subs, sizeof(ZSubscription_t) * subSize); 224 269 } 225 270 … … 246 291 fclose(file); 247 292 248 ret=owl_zephyr_loadsubs_helper(subs, count); 249 owl_free(subs); 293 owl_zephyr_loadsubs_helper(subs, count); 250 294 return(ret); 251 295 #else … … 273 317 #ifdef HAVE_LIBZEPHYR 274 318 FILE *file; 275 ZSubscription_t subs[3001]; 319 ZSubscription_t *subs; 320 int numSubs = 100; 276 321 char subsfile[1024], buffer[1024]; 277 int count, ret , i;322 int count, ret; 278 323 struct stat statbuff; 324 325 subs = owl_malloc(numSubs * sizeof(ZSubscription_t)); 279 326 280 327 if (filename==NULL) { … … 290 337 291 338 ZResetAuthentication(); 292 /* need to redo this to do chunks, not just bag out after 3000 */293 339 count=0; 294 340 file=fopen(subsfile, "r"); … … 297 343 if (buffer[0]=='#' || buffer[0]=='\n' || buffer[0]=='\n') continue; 298 344 299 if (count >= 3000) break; /* also tell the user */ 345 if (count == numSubs) { 346 numSubs *= 2; 347 subs = owl_realloc(subs, numSubs * sizeof(ZSubscription_t)); 348 } 300 349 301 350 buffer[strlen(buffer)-1]='\0'; 302 subs[count].zsub_class= "login";303 subs[count].zsub_recipient= "*";351 subs[count].zsub_class=owl_strdup("login"); 352 subs[count].zsub_recipient=owl_strdup("*"); 304 353 if (strchr(buffer, '@')) { 305 354 subs[count].zsub_classinst=owl_strdup(buffer); 306 355 } else { 307 356 subs[count].zsub_classinst=owl_sprintf("%s@%s", buffer, ZGetRealm()); 308 357 } 309 358 … … 316 365 } 317 366 318 /* sub with defaults */ 319 if (ZSubscribeToSansDefaults(subs,count,0) != ZERR_NONE) { 320 owl_function_error("Error subscribing to zephyr notifications."); 321 ret=-2; 322 } 323 324 /* free stuff */ 325 for (i=0; i<count; i++) { 326 owl_free(subs[i].zsub_classinst); 327 } 328 367 ret = owl_zephyr_loadsubs_helper(subs, count); 329 368 return(ret); 330 369 #else … … 602 641 notice.z_class=class; 603 642 notice.z_class_inst=instance; 643 notice.z_sender=NULL; 604 644 if (!strcmp(recipient, "*") || !strcmp(recipient, "@")) { 605 645 notice.z_recipient=""; 646 if (*owl_global_get_zsender(&g)) 647 notice.z_sender=owl_global_get_zsender(&g); 606 648 } else { 607 649 notice.z_recipient=recipient; 608 650 } 609 651 notice.z_default_format="Class $class, Instance $instance:\nTo: @bold($recipient) at $time $date\nFrom: @bold{$1 <$sender>}\n\n$2"; 610 if (*owl_global_get_zsender(&g))611 notice.z_sender=owl_global_get_zsender(&g);612 else613 notice.z_sender=NULL;614 652 if (opcode) notice.z_opcode=opcode; 615 653
Note: See TracChangeset
for help on using the changeset viewer.